@stillwind/integration 0.7.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin-ByYcpBcE.js","names":["finalizeModuleWithMap","finalizeHostModuleWithMap","finalizeModuleWithMap"],"sources":["../src/vite/module-ids.ts","../src/vite/chunk-styles.ts","../src/vite/css-minify.ts","../src/vite/file-access.ts","../src/vite/build-assets.ts","../src/vite/emission.ts","../src/vite/resources.ts","../src/vite/build.ts","../src/vite/http.ts","../src/vite/development.ts","../src/vite/browser-source-map.ts","../src/vite/browser-css.ts","../src/vite/css-targets.ts","../src/vite/finalize.ts","../src/vite/server-source-resolve.ts","../src/vite/compile.ts","../src/vite/design-system.ts","../src/vite/module-registry.ts","../src/vite/stylesheet.ts","../src/vite/environment.ts","../src/vite/project.ts","../src/vite/projection-imports.ts","../src/vite/transform.ts","../src/vite/virtual-modules.ts","../src/vite/vue.ts","../src/vite/plugin.ts"],"sourcesContent":["import { cleanModuleId, compilerModuleId } from \"@stillwind/host\";\n\n/** Shared stylesheet alias resolved to the environment's development runtime or production carrier. */\nexport const virtualCssId = \"virtual:stillwind.css\";\n/** Resolved runtime identity recognized before registry-backed modules. */\nexport const runtimeId = \"\\0stillwind:runtime\";\n/** Resolved prefix for explicit module CSS values issued by ModuleRegistry. */\nexport const valuePrefix = \"\\0stillwind:value:\";\n/** Resolved prefix for stylesheet fragment references issued by ModuleRegistry. */\nexport const fragmentPrefix = \"\\0stillwind:fragment:\";\n/** Resolved prefix for CSS-only source projection references. */\nexport const projectionPrefix = \"\\0stillwind:projection:\";\n/** Resolved prefix for producer registration modules. */\nexport const producerPrefix = \"\\0stillwind:producer:\";\n/** Public alias used by generated producer modules to import the environment runtime. */\nexport const runtimeSpecifier = \"virtual:stillwind/runtime\";\n\n/**\n * Derives a compiler identity while retaining the source identity's query or fragment suffix.\n * @param root - Absolute project root used by compilerModuleId.\n * @param id - Full source resolver identity.\n * @returns The compiler identity of the cleaned path followed by its original suffix.\n */\nexport function sourceModuleId(root: string, id: string): string {\n const file = cleanModuleId(id);\n return compilerModuleId(root, file) + id.slice(file.length);\n}\n","import { posix } from \"node:path\";\n\nimport type { Rollup } from \"vite\";\n\nimport { producerPrefix } from \"./module-ids.ts\";\nimport type { ViteProject } from \"./project.ts\";\n\n/**\n * Browser code that keeps loader links across Astro ClientRouter navigations.\n *\n * Astro removes each head element that the incoming document does not contain, and the chunk that\n * added a link does not run again, so the link would stay missing. Astro keeps an old stylesheet\n * link when the incoming head has a link with the same `href`, and each incoming link matches one\n * old link. The listener therefore copies each loader link while the incoming head has fewer links\n * with its `href` than the current head, which also keeps repeated split occurrences. One listener\n * serves all chunks in a document.\n */\nconst persistAcrossSwaps = `const key = Symbol.for(\"stillwind.persistLinks\");\n if (!globalThis[key]) {\n globalThis[key] = true;\n document.addEventListener(\"astro:before-swap\", (event) => {\n const head = event.newDocument.head;\n const count = (parent, href) =>\n [...parent.querySelectorAll('link[rel=\"stylesheet\"]')].filter((l) => l.getAttribute(\"href\") === href).length;\n for (const link of document.head.querySelectorAll(\"link[data-stillwind-loader]\")) {\n const href = link.getAttribute(\"href\");\n if (count(head, href) < count(document.head, href)) {\n head.append(link.cloneNode());\n }\n }\n });\n }`;\n\n/**\n * Associates emitted CSS with a chunk and loads its stylesheets in the browser.\n *\n * Split parts retain manifest order and relative-base URLs resolve against the chunk. Hosts can\n * request a loader for single emission when they do not deliver CSS from chunk metadata.\n *\n * @param project - Project with build output produced by `renderStart`.\n * @param name - Vite environment name, or `undefined` for `client`.\n * @param context - Build context that reads module dependencies and resolves emitted filenames.\n * @param code - Rendered JavaScript for the chunk.\n * @param chunk - Chunk whose modules select CSS parts and whose Vite metadata is updated.\n * @param loadSingleStylesheet - Loads single emission through a browser link. Defaults to false.\n * @returns JavaScript with a null map when a loader is needed, otherwise `null`.\n */\nexport function renderChunkStyles(\n project: ViteProject,\n name: string | undefined,\n context: Pick<Rollup.PluginContext, \"getModuleInfo\" | \"getFileName\">,\n code: string,\n chunk: Rollup.RenderedChunk,\n loadSingleStylesheet = false,\n) {\n const { config, settings, inputs, moduleRegistry } = project;\n const { manifest, buildCss } = project.buildOutput(name);\n\n /**\n * Records a stylesheet in the chunk's Vite metadata, creating the metadata when absent.\n * @param file - Emitted asset filename without the public base prefix.\n */\n const attachCss = (file: string) => {\n chunk.viteMetadata ??= {\n importedCss: new Set(),\n importedAssets: new Set(),\n __modules: new Set(),\n };\n chunk.viteMetadata.importedCss.add(file);\n };\n\n if (config.emission === \"split\" && manifest) {\n const graph = new Set(Object.keys(chunk.modules));\n if (chunk.facadeModuleId) {\n graph.add(chunk.facadeModuleId);\n }\n for (const id of graph) {\n for (const dependency of context.getModuleInfo(id)?.importedIds ?? []) {\n graph.add(dependency);\n }\n }\n const ids = new Set(\n [...graph].flatMap((id) => {\n const moduleId =\n inputs(name).get(id)?.moduleId ??\n context.getModuleInfo(id)?.meta.stillwind?.moduleId ??\n (id.startsWith(producerPrefix)\n ? (() => {\n const entry = moduleRegistry(name).get(id);\n return entry?.kind === \"producer\" ? entry.moduleId : \"\";\n })()\n : \"\");\n return manifest.modules[moduleId] ?? [];\n }),\n );\n const parts = manifest.parts\n .filter((part) => ids.has(part.id))\n .map((part) => ({\n ...part,\n order: manifest.parts.indexOf(part),\n relative: settings.publicBase === \"./\" || settings.publicBase === \"\",\n href:\n settings.publicBase === \"./\" || settings.publicBase === \"\"\n ? posix.relative(\n posix.dirname(chunk.fileName),\n part.href.slice(settings.publicBase.length),\n )\n : part.href,\n }));\n if (parts.length) {\n for (const part of manifest.parts.filter((part) => ids.has(part.id))) {\n attachCss(part.href.slice(settings.publicBase.length));\n }\n return {\n code: `${code}\n\n/* Stillwind CSS Loader */\nif (typeof document !== \"undefined\") {\n for (const p of ${JSON.stringify(parts)}) {\n const links = [...document.querySelectorAll(\"link[data-stillwind-part]\")];\n if (links.some((l) => l.dataset.stillwindPart === p.id)) {\n continue;\n }\n const l = document.createElement(\"link\");\n l.rel = \"stylesheet\";\n l.href = p.relative ? new URL(p.href, import.meta.url).href : p.href;\n l.dataset.stillwindPart = p.id;\n l.dataset.stillwindOrder = String(p.order);\n l.dataset.stillwindLoader = \"\";\n document.head.insertBefore(l, links.find((e) => Number(e.dataset.stillwindOrder) > p.order) ?? null);\n }\n ${persistAcrossSwaps}\n}\n`,\n map: null,\n };\n }\n }\n if (buildCss) {\n const file = context.getFileName(buildCss);\n attachCss(file);\n if (!loadSingleStylesheet) {\n return null;\n }\n const relative = settings.publicBase === \"./\" || settings.publicBase === \"\";\n const href = relative\n ? posix.relative(posix.dirname(chunk.fileName), file)\n : settings.publicBase + file;\n return {\n code: `${code}\n\n/* Stillwind CSS Loader */\nif (typeof document !== \"undefined\") {\n const href = new URL(${JSON.stringify(href)}, ${relative ? \"import.meta.url\" : \"document.baseURI\"}).href;\n if (![...document.querySelectorAll('link[rel=\"stylesheet\"]')].some((link) => link.href === href)) {\n const link = document.createElement(\"link\");\n link.rel = \"stylesheet\";\n link.href = href;\n link.dataset.stillwindLoader = \"\";\n document.head.append(link);\n }\n ${persistAcrossSwaps}\n}\n`,\n map: null,\n };\n }\n\n return null;\n}\n","import { minifyCss } from \"@stillwind/native\";\nimport type { Rollup } from \"vite\";\n\nimport type { ProjectSettings } from \"./project.ts\";\n\n/**\n * Minifies expanded CSS and reports native parser warnings through the bundler.\n * @param css - Generated CSS with valid resource URLs or resource placeholder tokens.\n * @param settings - Browser targets shared with compiler generation.\n * @param context - Bundler warning reporter.\n * @param sourceMap - Optional v3 map for this exact input, composed into the returned map.\n * @returns Minified CSS and an optional separate map without embedded source contents.\n * @throws If native parsing, minification, or source-map composition fails.\n */\nexport function minifyStylesheet(\n css: string,\n settings: Pick<ProjectSettings, \"cssTargets\">,\n context: Pick<Rollup.PluginContext, \"warn\">,\n sourceMap?: string,\n) {\n const result = minifyCss(css, {\n filename: \"stillwind.css\",\n targets: settings.cssTargets,\n sourceMap: sourceMap !== undefined,\n inputSourceMap: sourceMap,\n includeSourcesContent: false,\n });\n for (const warning of result.warnings) {\n context.warn(warning);\n }\n return result;\n}\n","import { realpath } from \"node:fs/promises\";\nimport { isAbsolute } from \"node:path\";\n\nimport { cleanModuleId } from \"@stillwind/host\";\nimport { isFileServingAllowed, type ViteDevServer } from \"vite\";\n\n/**\n * Checks both the requested and canonical file before a plugin reads it.\n * @param id - Absolute filesystem identity, optionally with a query or fragment removed for access checks.\n * @param server - Optional development server whose file-serving policy applies to both paths.\n * @returns The canonical absolute path after resolving symlinks.\n * @throws If the identity is invalid, either path is denied, or realpath fails.\n */\nexport async function readableFile(id: string, server?: ViteDevServer): Promise<string> {\n const file = cleanModuleId(id);\n if (!isAbsolute(file) || file.includes(\"\\0\")) {\n throw new Error(\"Stillwind requires an absolute file path\");\n }\n if (server && !isFileServingAllowed(file, server)) {\n throw new Error(\"Stillwind file access denied\");\n }\n const canonical = await realpath(file);\n if (server && !isFileServingAllowed(canonical, server)) {\n throw new Error(\"Stillwind file access denied\");\n }\n return canonical;\n}\n","import { createHash } from \"node:crypto\";\nimport { readFile } from \"node:fs/promises\";\nimport { posix } from \"node:path\";\n\nimport type { Rollup } from \"vite\";\n\nimport { minifyStylesheet } from \"./css-minify.ts\";\nimport { readableFile } from \"./file-access.ts\";\nimport type { ViteProject } from \"./project.ts\";\nimport type { StylesheetResource } from \"./resources.ts\";\n\n/**\n * Emits referenced resource files and computes URLs relative to the CSS asset directory.\n *\n * Only resources referenced by `css` are emitted. References to the same readable file share one\n * emitted asset within this call.\n *\n * @param context - Build context that emits assets and resolves their filenames.\n * @param css - CSS text containing resource placeholder tokens.\n * @param resources - Resolved resources indexed by placeholder token.\n * @param assetsDirectory - Output directory containing the emitted CSS, using forward slashes.\n * @returns Placeholder replacements containing escaped paths relative to `assetsDirectory`.\n * @throws If a referenced resource cannot be read or emitted.\n */\nexport async function emitBuildResources(\n context: Pick<Rollup.PluginContext, \"emitFile\" | \"getFileName\">,\n css: string,\n resources: ReadonlyMap<string, StylesheetResource>,\n assetsDirectory: string,\n): Promise<Map<string, string>> {\n const assets = new Map<string, string>();\n const replacements = new Map<string, string>();\n for (const [placeholder, resource] of resources) {\n if (!css.includes(placeholder)) {\n continue;\n }\n const file = await readableFile(resource.id);\n let reference = assets.get(file);\n if (!reference) {\n reference = context.emitFile({\n type: \"asset\",\n name: file.replaceAll(\"\\\\\", \"/\").split(\"/\").at(-1),\n source: await readFile(file),\n });\n assets.set(file, reference);\n }\n replacements.set(\n placeholder,\n JSON.stringify(posix.relative(assetsDirectory, context.getFileName(reference))).slice(1, -1),\n );\n }\n return replacements;\n}\n\n/**\n * Emits a stylesheet and its optional external source map with filenames derived from its content.\n *\n * Minification follows project settings. Source maps use public source names and are emitted beside\n * the CSS asset.\n *\n * @param project - CSS minification settings, asset directory, and public source-map rewriting\n * operations.\n * @param name - Vite environment name, or `undefined` for `client`.\n * @param context - Build context used to emit the CSS and map assets.\n * @param text - CSS text whose resource placeholders have already been replaced.\n * @param sourceMap - Serialized upstream CSS map, or `undefined` to omit a map.\n * @returns The bundler reference ID of the emitted CSS asset, suitable for `getFileName`.\n * @throws If CSS transformation, map decoding, or asset emission fails.\n */\nexport async function emitBuildCss(\n project: {\n /** Effective minification policy and emitted asset directory for the environment. */\n settings: Pick<ViteProject[\"settings\"], \"minifyCss\" | \"cssTargets\" | \"assetsDirectory\">;\n /** Rewrites source-map identities for publicly emitted CSS. */\n publicSourceMap: ViteProject[\"publicSourceMap\"];\n },\n name: string | undefined,\n context: Pick<Rollup.PluginContext, \"emitFile\" | \"warn\">,\n text: string,\n sourceMap?: string,\n): Promise<string> {\n const { settings, publicSourceMap } = project;\n if (settings.minifyCss) {\n const result = minifyStylesheet(text, settings, context, sourceMap);\n text = result.css;\n sourceMap = result.sourceMap ?? undefined;\n }\n const hash = createHash(\"sha256\").update(text).digest(\"hex\").slice(0, 16);\n if (sourceMap) {\n sourceMap = JSON.stringify(publicSourceMap(name, sourceMap));\n context.emitFile({\n type: \"asset\",\n fileName: `${settings.assetsDirectory}/stillwind-${hash}.css.map`,\n source: sourceMap,\n });\n text += `\\n/*# sourceMappingURL=stillwind-${hash}.css.map */`;\n }\n return context.emitFile({\n type: \"asset\",\n fileName: `${settings.assetsDirectory}/stillwind-${hash}.css`,\n source: text,\n });\n}\n","import { createHash } from \"node:crypto\";\n\nimport type { NativeStylesheetPart } from \"@stillwind/native\";\nimport { cssBanners } from \"stillwind/css\";\n\n/**\n * Packs adjacent occurrences with identical ordered producer lists without moving any rule.\n *\n * @param parts - Native partitions in stylesheet order. Input records and source-map arrays are unchanged.\n * @returns New partitions with concatenated CSS, shifted UTF-8 source-map offsets, and content hashes for merged parts.\n */\nexport function partitionStylesheet(\n parts: readonly NativeStylesheetPart[],\n): NativeStylesheetPart[] {\n const output: NativeStylesheetPart[] = [];\n for (const part of parts) {\n const previous = output.at(-1);\n if (previous && JSON.stringify(previous.producers) === JSON.stringify(part.producers)) {\n const byteOffset = Buffer.byteLength(previous.css);\n const sourceOffset = previous.sourceMap.sources.length;\n previous.sourceMap.sources.push(...part.sourceMap.sources);\n previous.sourceMap.entries.push(\n ...part.sourceMap.entries.map((entry) => ({\n ...entry,\n source: entry.source + sourceOffset,\n generatedStart: entry.generatedStart + byteOffset,\n generatedEnd: entry.generatedEnd + byteOffset,\n })),\n );\n previous.css += part.css;\n previous.banners = cssBanners([...previous.banners, ...part.banners]);\n previous.key = createHash(\"sha256\")\n .update(previous.css)\n .update(JSON.stringify(previous.banners))\n .digest(\"hex\");\n } else {\n output.push({\n ...part,\n sourceMap: {\n sources: [...part.sourceMap.sources],\n entries: [...part.sourceMap.entries],\n },\n });\n }\n }\n return output;\n}\n","import { isAbsolute } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\n/** Resolved local resource retained for CSS emission and development access checks. */\nexport interface StylesheetResource {\n /** Resolver identity, including any resource query. */\n readonly id: string;\n /** Canonical absolute path checked before reading or serving the resource. */\n readonly file: string;\n}\n\n/**\n * Converts local resource placeholders to escaped Vite filesystem URLs.\n * @param resources - Placeholder records whose files have already passed access checks.\n * @returns A new map of placeholders to JSON-escaped URL contents without surrounding quotes.\n */\nexport function resourceReplacements(\n resources: Iterable<readonly [string, StylesheetResource]>,\n): Map<string, string> {\n return new Map(\n [...resources].map(([placeholder, resource]) => [\n placeholder,\n JSON.stringify(resourceUrl(resource.file)).slice(1, -1),\n ]),\n );\n}\n\n/**\n * Encodes an absolute file path as a Vite filesystem URL.\n * @param file - Canonical absolute path, using either path separator spelling.\n * @returns An /@fs/ URL with each path segment encoded for use in stylesheet resource requests.\n */\nexport function resourceUrl(file: string): string {\n return `/@fs/${file\n .replaceAll(\"\\\\\", \"/\")\n .split(\"/\")\n .map((segment) =>\n encodeURIComponent(segment)\n .replaceAll(\"'\", \"%27\")\n .replaceAll(\"(\", \"%28\")\n .replaceAll(\")\", \"%29\"),\n )\n .join(\"/\")}`;\n}\n\n/**\n * Extracts a readable identity from a bundler resolution without checking file existence or access.\n * @param result - Resolution, possibly external or a file URI. Absolute external paths remain readable.\n * @param description - Resource description included in failure messages.\n * @returns The resolved identity, converting file URIs to filesystem paths.\n * @throws If resolution is absent, an external identity is not an absolute path, or a file URI is invalid.\n */\nexport function resolvedFile(\n result: {\n /** Resolved identity or file URI returned by the bundler. */\n id: string;\n /** Truthy values mark external modules, which require a file URI or absolute path. */\n external?: boolean | string;\n } | null,\n description: string,\n): string {\n if (!result) {\n throw new Error(`Cannot resolve ${description}`);\n }\n if (result.id.startsWith(\"file:\")) {\n return fileURLToPath(result.id);\n }\n if (!result.external || isAbsolute(result.id)) {\n return result.id;\n }\n throw new Error(`Cannot read external ${description}: ${result.id}`);\n}\n\n/**\n * Replaces recorded CSS tokens in map order without further URL escaping.\n * @param css - Generated text containing resource placeholders.\n * @param references - Placeholders mapped to replacement contents already escaped for CSS.\n * @returns Replaced CSS. The supplied map is unchanged.\n */\nexport function resolveResources(css: string, references = new Map<string, string>()): string {\n for (const [placeholder, url] of references) {\n css = css.replaceAll(placeholder, url);\n }\n return css;\n}\n","import { createHash } from \"node:crypto\";\n\nimport { decodeCssSourceMap, finalizeCss } from \"@stillwind/host\";\nimport type { Plugin } from \"vite\";\n\nimport { emitBuildCss, emitBuildResources } from \"./build-assets.ts\";\nimport { renderChunkStyles } from \"./chunk-styles.ts\";\nimport { partitionStylesheet } from \"./emission.ts\";\nimport { producerPrefix, projectionPrefix, runtimeId } from \"./module-ids.ts\";\nimport type { ViteProject } from \"./project.ts\";\nimport { resolveResources } from \"./resources.ts\";\n\n/**\n * A production stylesheet manifest that preserves CSS part order and records each producer's\n * required parts.\n */\nexport interface StylesheetManifest {\n /** Serialized manifest schema version. Consumers must interpret this structure as version 1. */\n version: 1;\n /** SHA-256 fingerprint of the design system, original CSS, and producer artifacts. */\n revision: string;\n /**\n * Stylesheet occurrences in cascade order. Repeated payloads may share a URL but retain distinct\n * IDs.\n */\n parts: {\n /** Occurrence identity referenced by `modules`. Single emission uses `document`. */\n id: string;\n /** Public URL formed from the configured Vite base and emitted asset filename. */\n href: string;\n }[];\n /**\n * Compiler module identities mapped to required part IDs in manifest order, including shared and\n * composed styles.\n */\n modules: Record<string, string[]>;\n}\n\n/**\n * Emitted CSS references and stylesheet metadata for one Vite environment.\n */\nexport interface BuildOutput {\n /**\n * Bundler reference ID for the single document CSS asset. Split emission leaves this undefined.\n */\n buildCss?: string;\n /** Manifest for emitted document styles. Undefined until a build has emitted Stillwind CSS. */\n manifest?: StylesheetManifest;\n}\n\n/**\n * Creates production hooks that emit complete document CSS and associate it with rendered chunks.\n *\n * @param project - Project whose compiler hooks collect producers and initialize environment\n * settings.\n * @returns Hooks for stylesheet emission at render start and CSS association during chunk\n * rendering.\n */\nexport function buildHooks(project: ViteProject): Pick<Plugin, \"renderStart\" | \"renderChunk\"> {\n const { config, settings, inputs, cssForBrowser, documentPlan, compile } = project;\n\n return {\n /**\n * Recovers cached producers from the completed graph and emits CSS, resources, and the\n * manifest.\n *\n * The Vite hook context must expose the completed module graph. Recovered inputs include lazy\n * modules before the stylesheet receives complete coverage.\n *\n * @returns A promise that resolves after build output is stored, or immediately for development\n * and graphs without document CSS references.\n */\n async renderStart() {\n if (settings.watching) {\n return;\n }\n const name = this.environment?.name;\n // The final graph includes lazy modules and cached transforms. Recover inputs\n // from graph metadata before making a complete-coverage claim.\n for (const id of this.getModuleIds()) {\n const metadata = this.getModuleInfo(id)?.meta.stillwind;\n if (metadata?.input !== undefined && !inputs(name).has(metadata.id ?? id)) {\n await compile(name, metadata.input, metadata.id ?? id, this);\n }\n if (metadata?.projection) {\n await project.environment(name).markProjection(metadata.id ?? id);\n }\n }\n const plan = await documentPlan(name, this, true);\n if (\n ![...this.getModuleIds()].some(\n (id) =>\n id === runtimeId || id.startsWith(producerPrefix) || id.startsWith(projectionPrefix),\n )\n ) {\n return;\n }\n const replacements = await emitBuildResources(\n this,\n plan.originalCss,\n plan.resources,\n settings.assetsDirectory,\n );\n const css = resolveResources(plan.originalCss, replacements);\n /**\n * Emits a stylesheet using this build's environment, asset directory, and map settings.\n *\n * @param text - Final CSS with resource placeholders replaced.\n * @param sourceMap - Optional serialized map for the final CSS.\n * @returns The bundler's reference for the emitted asset.\n */\n const emitCss = (text: string, sourceMap?: string) =>\n emitBuildCss(project, name, this, text, sourceMap);\n /**\n * Builds the stylesheet URL recorded in the document manifest.\n *\n * @param reference - Asset reference already issued by this build context.\n * @returns The emitted filename prefixed by the configured public base.\n */\n const href = (reference: string) => settings.publicBase + this.getFileName(reference);\n const revision = createHash(\"sha256\")\n .update(plan.designSystem)\n .update(\"\\0\")\n .update(plan.originalCss)\n .update(JSON.stringify(plan.banners))\n .update(\"\\0\")\n .update(JSON.stringify(plan.producers))\n .update(\"\\0\")\n .digest(\"hex\");\n const output: BuildOutput = {};\n if (config.emission !== \"split\") {\n const mapped = settings.sourceMaps\n ? decodeCssSourceMap(\n cssForBrowser(\n name,\n {\n css: plan.originalCss,\n sourceMap: plan.sourceMap,\n banners: plan.banners,\n },\n replacements,\n ),\n )\n : undefined;\n output.buildCss = await emitCss(\n mapped?.code ??\n finalizeCss({\n css,\n banners: plan.banners,\n }),\n mapped?.map ? JSON.stringify(mapped.map) : undefined,\n );\n output.manifest = {\n version: 1,\n revision,\n parts: [\n {\n id: \"document\",\n href: href(output.buildCss),\n },\n ],\n modules: Object.fromEntries(\n plan.producers.map((producer) => [producer.module, [\"document\"]]),\n ),\n };\n } else {\n const references = new Map<string, string>();\n const parts: {\n /** Occurrence identity preserving partition position even when content shares an asset. */\n id: string;\n /** Public URL of the emitted partition asset. */\n href: string;\n }[] = [];\n const partitions = partitionStylesheet(plan.rawParts);\n for (const [index, part] of partitions.entries()) {\n let reference = references.get(part.key);\n if (!reference) {\n const mapped = settings.sourceMaps\n ? decodeCssSourceMap(cssForBrowser(name, part, replacements))\n : undefined;\n references.set(\n part.key,\n (reference = await emitCss(\n mapped?.code ??\n finalizeCss({\n css: resolveResources(part.css, replacements),\n banners: part.banners,\n }),\n mapped?.map ? JSON.stringify(mapped.map) : undefined,\n )),\n );\n }\n parts.push({\n id: `${index}:${part.key}`,\n href: href(reference),\n });\n }\n const dependencies = new Map(\n [...inputs(name).values()].map((input) => [input.moduleId, input.dependencies]),\n );\n const modules = Object.fromEntries(\n plan.producers.map((producer) => {\n const closure = new Set([producer.module]);\n for (const module of closure) {\n for (const dependency of dependencies.get(module) ?? []) {\n closure.add(dependency);\n }\n }\n return [\n producer.module,\n parts\n .filter(\n (_, index) =>\n partitions[index].producers.length === 0 ||\n partitions[index].producers.some((owner) => closure.has(owner)),\n )\n .map((part) => part.id),\n ];\n }),\n );\n output.manifest = {\n version: 1,\n revision,\n parts,\n modules,\n };\n }\n project.setBuildOutput(name, output);\n this.emitFile({\n type: \"asset\",\n fileName: \"stillwind-manifest.json\",\n source: JSON.stringify(output.manifest, null, 2),\n });\n },\n /**\n * Adds CSS metadata or a split stylesheet loader to a rendered production chunk.\n *\n * @param code - Rendered JavaScript for this chunk.\n * @param chunk - Chunk metadata, updated with the selected CSS files.\n * @returns A rewritten chunk with a null map for split CSS, otherwise `null`.\n */\n renderChunk(code, chunk) {\n return renderChunkStyles(project, this.environment?.name, this, code, chunk);\n },\n };\n}\n","import type { ServerResponse } from \"node:http\";\n\n/**\n * Ends a response with JSON and disables caching for development snapshots.\n * @param response - Writable response whose status and content-type/cache-control headers are replaced.\n * @param value - Value accepted by JSON.stringify.\n * @param statusCode - HTTP status to send, defaulting to 200.\n * @throws If serialization or writing the response fails.\n */\nexport function sendJson(response: ServerResponse, value: unknown, statusCode = 200) {\n response.statusCode = statusCode;\n response.setHeader(\"content-type\", \"application/json; charset=utf-8\");\n response.setHeader(\"cache-control\", \"no-store\");\n response.end(JSON.stringify(value));\n}\n","import { resolve } from \"node:path\";\n\nimport { cleanModuleId } from \"@stillwind/host\";\nimport type { Plugin, ViteDevServer } from \"vite\";\n\nimport type { CssContext } from \"./design-system.ts\";\nimport { sendJson } from \"./http.ts\";\nimport type { ViteProject } from \"./project.ts\";\n\n/**\n * Returns development hooks that use `project`'s state for each Vite environment. The server hook\n * adds routes for requesting stylesheets. Hot updates compile changed inputs and send CSS before\n * invalidating JS modules. The caller must also install the compiler hooks to initialize project\n * settings.\n *\n * @param project - Shared project configured and attached to the server by the compiler plugin.\n * @returns Hooks for serving stylesheet requests and handling CSS hot updates.\n */\nexport function developmentHooks(\n project: ViteProject,\n): Pick<Plugin, \"hotUpdate\" | \"configureServer\"> {\n const { settings, inputs, valueSpecifier, documentPlan, publish, compile } = project;\n\n return {\n /**\n * Recompiles changed styles and selects JavaScript modules that require hot invalidation.\n *\n * The hook publishes CSS before returning modules for invalidation. Failed updates warn and\n * leave the last published styles in use.\n *\n * @param context - Vite hot-update event with the current server, changed file, and source\n * reader.\n * @returns Modules affected by a design-system update, an empty list when a producer edit\n * changes only CSS and no request has compiled the edited source yet, or `undefined` to retain\n * normal Vite handling.\n */\n async hotUpdate(context) {\n const name = this.environment.name;\n const state = project.environment(name);\n const id = cleanModuleId(context.file);\n const host: CssContext = {\n resolve: (specifier, importer, options) =>\n this.environment.pluginContainer.resolveId(specifier, importer, options),\n addWatchFile: (id: string) => {\n context.server.watcher.add(id);\n },\n warn: (message: string) => {\n this.warn(message);\n },\n };\n try {\n if (state.designSystem.observes(resolve(context.file), context.type !== \"update\")) {\n await state.refreshDesignSystem(host);\n await publish(name, host);\n const changed = state.takeThemeChanges();\n const modules = [...inputs(name).values()]\n .filter((input) => input.manual || changed.has(input.moduleId))\n .flatMap((input) => [\n ...(this.environment.moduleGraph.getModulesByFile(cleanModuleId(input.id)) ?? []),\n ...(input.manual\n ? [\n this.environment.moduleGraph.getModuleById(\n valueSpecifier(input.id, name).replace(\"virtual:stillwind/\", \"\\0stillwind:\"),\n ),\n ].filter((module): module is NonNullable<typeof module> => Boolean(module))\n : []),\n ]);\n for (const module of modules) {\n this.environment.moduleGraph.invalidateModule(\n module,\n new Set(),\n context.timestamp,\n true,\n );\n }\n return modules;\n }\n const previous = inputs(name).get(id);\n if (previous && context.type !== \"delete\") {\n const source = await context.read();\n const result = await compile(name, source, id, host);\n await publish(name, host);\n const values = [];\n for (const input of inputs(name).values()) {\n if (!input.manual) {\n continue;\n }\n const value = this.environment.moduleGraph.getModuleById(\n valueSpecifier(input.id, name).replace(\"virtual:stillwind/\", \"\\0stillwind:\"),\n );\n if (!value) {\n continue;\n }\n const plan = await state.modulePlan([input.moduleId], host, false);\n if (plan.producers.some((producer) => producer.module === previous.moduleId)) {\n // Framework hooks can filter this module out of the update list. The HMR\n // timestamp still makes its importers request the new CSS value.\n this.environment.moduleGraph.invalidateModule(\n value,\n new Set(),\n context.timestamp,\n true,\n );\n values.push(value);\n }\n }\n if (values.length) {\n return [...new Set([...context.modules, ...values])];\n }\n // A transform request can compile the changed source before this hook runs, for example\n // when TanStack Start transforms a route for the server. The recorded output then\n // matches the new output, but the module runner still holds the module from before the\n // change.\n if (\n !previous.manual &&\n previous.code !== source &&\n result?.code === previous.javascript\n ) {\n return [];\n }\n }\n } catch (error) {\n this.warn(`Stillwind update failed; retaining published styles: ${String(error)}`);\n }\n return undefined;\n },\n /**\n * Registers routes that serve document CSS and revisioned stylesheet snapshots.\n *\n * The document route supports repeated `module` selections and defaults to `ssr`. It records each\n * served URL so that later CSS changes in that environment reload the document's link. The\n * snapshot route defaults to `client`. Unknown environments return 404 and stylesheet failures return\n * 500.\n *\n * @param server - Active server with the project's initialized Vite environments.\n */\n configureServer(server: ViteDevServer) {\n server.middlewares.use(\"/__stillwind/style.css\", (request, response) => {\n const params = new URL(request.url ?? \"\", \"http://stillwind.local\").searchParams;\n const name = params.get(\"environment\") ?? \"ssr\";\n const selection = params.getAll(\"module\");\n const environment = server.environments[name];\n if (!environment) {\n return sendJson(response, { error: \"Unknown environment\" }, 404);\n }\n const link = new URL(request.originalUrl ?? request.url ?? \"\", \"http://stillwind.local\");\n link.searchParams.delete(\"t\");\n project.observeDocumentStylesheet(name, link.pathname + link.search);\n void documentPlan(\n name,\n {\n resolve: (specifier, importer, options) =>\n environment.pluginContainer.resolveId(specifier, importer, options),\n addWatchFile: (id) => {\n server.watcher.add(id);\n },\n warn: (message) => {\n server.config.logger.warn(message);\n },\n },\n false,\n selection.length ? selection : undefined,\n )\n .then((plan) => {\n response.setHeader(\"Content-Type\", \"text/css; charset=utf-8\");\n response.setHeader(\"Cache-Control\", \"no-store\");\n response.end(plan.css);\n })\n .catch((error) => {\n sendJson(response, { error: String(error) }, 500);\n });\n });\n server.middlewares.use(`${settings.publicBase}__stillwind/css`, (request, response) => {\n const name =\n new URL(request.url ?? \"\", \"http://stillwind.local\").searchParams.get(\"environment\") ??\n \"client\";\n const environment = server.environments[name];\n if (!environment) {\n return sendJson(response, { error: \"Unknown environment\" }, 404);\n }\n void project\n .snapshot(name, {\n resolve: (specifier, importer, options) =>\n environment.pluginContainer.resolveId(specifier, importer, options),\n addWatchFile: (id) => {\n server.watcher.add(id);\n },\n warn: (message) => {\n server.config.logger.warn(message);\n },\n })\n .then((snapshot) => sendJson(response, snapshot))\n .catch((error) => {\n sendJson(response, { error: String(error) }, 500);\n });\n });\n },\n };\n}\n","import {\n GenMapping,\n addSegment,\n toEncodedMap,\n type EncodedSourceMap,\n} from \"@jridgewell/gen-mapping\";\nimport { TraceMap, eachMapping } from \"@jridgewell/trace-mapping\";\n\n/** Serialized or object source map accepted by the tracing library, including readonly arrays. */\nexport type BrowserSourceMapInput = ConstructorParameters<typeof TraceMap>[0];\n\n/**\n * Publishes positions with caller-approved source names and no source text or symbol names.\n *\n * @param input - Serialized or object source map accepted by the tracing library.\n * @param sourceName - Maps each original source name to the name approved for browser delivery.\n * @returns An encoded map retaining positions with the approved names and no embedded source text.\n * @throws If the input is not a valid source map.\n */\nexport function browserSourceMap(\n input: BrowserSourceMapInput,\n sourceName: (source: string) => string,\n): EncodedSourceMap {\n const trace = new TraceMap(input);\n const map = new GenMapping();\n const sources = new Map<string, string>();\n eachMapping(trace, (entry) => {\n if (entry.source !== null && entry.originalLine !== null) {\n let source = sources.get(entry.source);\n if (source === undefined) {\n source = sourceName(entry.source);\n sources.set(entry.source, source);\n }\n addSegment(\n map,\n entry.generatedLine - 1,\n entry.generatedColumn,\n source,\n entry.originalLine - 1,\n entry.originalColumn,\n );\n } else {\n addSegment(map, entry.generatedLine - 1, entry.generatedColumn);\n }\n });\n const result = toEncodedMap(map);\n delete result.sourcesContent;\n return result;\n}\n","import { createHash } from \"node:crypto\";\nimport { isAbsolute } from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\n\nimport type { EncodedSourceMap } from \"@jridgewell/gen-mapping\";\nimport {\n cleanModuleId,\n cssWithSourceMap,\n decodeCssSourceMap,\n type CssSourceMapInput,\n} from \"@stillwind/host\";\n\nimport { browserSourceMap, type BrowserSourceMapInput } from \"./browser-source-map.ts\";\nimport type { ProducerInput } from \"./compile.ts\";\nimport { sourceModuleId } from \"./module-ids.ts\";\n\n/** Project sources used to compose CSS maps and choose source names safe to send to a browser. */\nexport interface BrowserCssSources {\n /** Absolute project root used to compute public source names. */\n root: string;\n /**\n * Vite environment name. Only `client` allows ordinary script producers to retain\n * project-relative names.\n */\n environment: string;\n /** Absolute paths read by the design system and used as visible CSS sources. */\n cssFiles: ReadonlySet<string>;\n /**\n * Compiled producers and their upstream maps. SFCs and projections retain opaque public source\n * names.\n */\n inputs: readonly Readonly<ProducerInput>[];\n}\n\n/**\n * Rewrites CSS map sources without exposing absolute paths or embedded source text.\n *\n * Known CSS files inside the project and ordinary client scripts receive project-relative names.\n * All other source identities receive SHA-256 names.\n *\n * @param sources - Known CSS files and producer inputs for one project environment.\n * @param map - Encoded map object or serialized source map.\n * @returns An encoded map with positions preserved, no source text or symbol names, and approved or\n * hashed source names.\n */\nexport function publicCssSourceMap(\n sources: BrowserCssSources,\n map: BrowserSourceMapInput,\n): EncodedSourceMap {\n const visible = new Map<string, string>();\n\n /**\n * Allows a known source inside the project to use a public relative name.\n * @param id - Resolver identity whose query and fragment are removed before checking its path.\n */\n const add = (id: string) => {\n const relative = sourceModuleId(sources.root, cleanModuleId(id));\n if (relative !== \"..\" && !relative.startsWith(\"../\") && !isAbsolute(relative)) {\n visible.set(pathToFileURL(cleanModuleId(id)).href, `stillwind-source:/${relative}`);\n }\n };\n for (const file of sources.cssFiles) {\n add(file);\n }\n if (sources.environment === \"client\") {\n for (const input of sources.inputs) {\n if (!input.projection && !/\\.(?:astro|svelte|vue)$/.test(cleanModuleId(input.id))) {\n add(input.id);\n }\n }\n }\n\n const publicNames = new Set(visible.values());\n return browserSourceMap(map, (source) => {\n if (/^stillwind-source:[a-f0-9]{64}$/.test(source) || publicNames.has(source)) {\n return source;\n }\n return (\n visible.get(source) ?? `stillwind-source:${createHash(\"sha256\").update(source).digest(\"hex\")}`\n );\n });\n}\n\n/**\n * Replaces CSS resource placeholders and composes a source map for browser delivery.\n *\n * @param sources - Environment sources and upstream producer maps.\n * @param output - Compiler CSS and its native source map.\n * @param replacements - Map from resource placeholder tokens to escaped URL text.\n * @returns CSS with replaced resources and, when a map is available, an inline map containing\n * public source names.\n */\nexport function cssForBrowser(\n sources: BrowserCssSources,\n output: CssSourceMapInput,\n replacements: ReadonlyMap<string, string>,\n): string {\n const decoded = decodeCssSourceMap(\n cssWithSourceMap(\n output,\n replacements,\n sources.inputs.flatMap((input) => (input.upstream ? [input.upstream] : [])),\n false,\n ),\n );\n if (!decoded.map) {\n return decoded.code;\n }\n\n const encoded = Buffer.from(JSON.stringify(publicCssSourceMap(sources, decoded.map))).toString(\n \"base64\",\n );\n return `${decoded.code}\\n/*# sourceMappingURL=data:application/json;base64,${encoded} */`;\n}\n","import type { BaseConfig } from \"@stillwind/config\";\nimport type { NativeCssMinifyOptions } from \"@stillwind/native\";\nimport type { ResolvedConfig } from \"vite\";\n\nconst browserTarget =\n /^(android|chrome|edge|firefox|ie|ios|opera|safari|samsung)(\\d+(?:\\.\\d+){0,2})$/;\n\n/**\n * Selects browser versions from Vite's resolved CSS target without inferring versions from JS levels.\n * @param target - Resolved CSS target, including disabled targets and language-level strings.\n * @returns A copy of the browser list, or an empty list if any entry cannot identify browser versions.\n */\nexport function inheritCssTarget(target: ResolvedConfig[\"build\"][\"cssTarget\"]): string[] {\n const entries = typeof target === \"string\" ? [target] : target || [];\n return entries.every((entry) => browserTarget.test(entry)) ? [...entries] : [];\n}\n\n/**\n * Converts Stillwind browser versions to Lightning CSS's packed minimum versions.\n * @param target - Validated compiler targets. Omission and empty lists leave minifier targets unspecified.\n * @returns Browser versions with the oldest entry retained for each browser and ios named ios_saf.\n * @throws If a target cannot be represented by Lightning CSS's three one-byte version components.\n */\nexport function minifyTargets(target: BaseConfig[\"target\"]): NativeCssMinifyOptions[\"targets\"] {\n const entries = typeof target === \"string\" ? [target] : (target ?? []);\n if (!entries.length) {\n return undefined;\n }\n const targets: Record<string, number> = {};\n for (const entry of entries) {\n const match = browserTarget.exec(entry);\n const parts = match?.[2].split(\".\").map(Number);\n if (!match || !parts || parts.some((part) => part > 255)) {\n throw new Error(\n `Cannot represent CSS minifier target ${JSON.stringify(entry)}: each version component must be 0..255`,\n );\n }\n const [major, minor = 0, patch = 0] = parts;\n const version = major * 65536 + minor * 256 + patch;\n const browser = match[1] === \"ios\" ? \"ios_saf\" : match[1];\n targets[browser] = Math.min(targets[browser] ?? version, version);\n }\n return targets;\n}\n","import { finalizeModuleWithMap as finalizeHostModuleWithMap } from \"@stillwind/host\";\n\nimport { virtualCssId } from \"./module-ids.ts\";\n\n/**\n * Prepends the shared virtual stylesheet import when automatic delivery is requested.\n * @param code - Compiled JavaScript before host finalization.\n * @param includeStylesheet - Whether to activate the shared stylesheet. Defaults to true.\n * @returns Final JavaScript text.\n */\nexport function finalizeModule(code: string, includeStylesheet = true) {\n return finalizeModuleWithMap(code, includeStylesheet).code;\n}\n\n/**\n * Finalizes source while retaining prefix metadata for source-map generation.\n * @param code - Compiled JavaScript before finalization.\n * @param includeStylesheet - Whether to prepend the shared virtual stylesheet import.\n * @returns Final code, the inserted prefix, and host finalization's removed intervals.\n */\nexport function finalizeModuleWithMap(code: string, includeStylesheet = true) {\n return finalizeHostModuleWithMap(code, includeStylesheet ? virtualCssId : undefined);\n}\n","/**\n * Options that let Stillwind resolve a server-only source from a client module. React Router's\n * `react-router:dot-server` plugin skips its client import check when it receives the `custom`\n * flag. Stillwind reads such a source only for type and style facts, and Vite still checks the\n * imports that remain in the transformed client code.\n */\ninterface ServerSourceResolveOptions {\n /** Avoids re-entering the Stillwind plugin that initiated resolution. */\n skipSelf: true;\n /** Flag read by React Router's `react-router:dot-server` resolver hook. */\n custom: { \"react-router:dot-server\": true };\n}\n\n/** Text of the error that React Router throws when a client module resolves a server-only source. */\nconst serverOnlyImportMessage = \"Server-only module referenced by client\";\n\n/** Number of resolutions before a React Router server-only import error is passed to the caller. */\nconst serverSourceResolveAttempts = 5;\n\n/**\n * Resolves an import whose target may be a server-only source, through the other Vite plugins.\n *\n * Rolldown can deliver the `custom` option of one `this.resolve()` call to a different call that\n * runs at the same time (https://github.com/rolldown/rolldown/issues/11180). It stores the options\n * of each pending call under the current size of a map. After an earlier call finishes, a new call\n * can receive the key of a pending call and replace its options. React Router then does not see\n * the flag from {@link ServerSourceResolveOptions} and throws for a valid Stillwind read, for example\n * `../server.server.js?stillwind.css` in a route module. This retry is a workaround and is not\n * needed after Rolldown gives each pending call its own key. Other plugin errors and other\n * failures are passed to the caller without a retry.\n *\n * @param resolve - Resolver of the current Vite hook context. Each call must be independent, so\n * the same arguments can be resolved again. Each call receives a new options object.\n * @param specifier - Import text without the Stillwind resource query.\n * @param importer - Resolver identity of the importing module.\n * @returns The result of the first resolution that does not throw React Router's server-only\n * import error.\n * @throws The error of the last attempt if each attempt throws React Router's server-only import\n * error, or the first error of another kind.\n */\nexport async function resolveServerSource<T>(\n resolve: (specifier: string, importer: string, options: ServerSourceResolveOptions) => Promise<T>,\n specifier: string,\n importer: string,\n): Promise<T> {\n for (let attempt = 1; ; attempt++) {\n try {\n return await resolve(specifier, importer, {\n skipSelf: true,\n custom: { \"react-router:dot-server\": true },\n });\n } catch (error) {\n if (attempt >= serverSourceResolveAttempts || !isServerOnlyImportError(error)) {\n throw error;\n }\n }\n }\n}\n\n/**\n * Checks whether a resolver error, or one of its causes, is React Router's server-only import error.\n *\n * @param error - Value thrown by a resolver. Rolldown can wrap the plugin error in another error.\n * @returns True when the message of the error or of a cause contains React Router's message.\n */\nfunction isServerOnlyImportError(error: unknown): boolean {\n for (let current = error; current instanceof Error; current = current.cause) {\n if (current.message.includes(serverOnlyImportMessage)) {\n return true;\n }\n }\n return false;\n}\n","import { createHash } from \"node:crypto\";\nimport { readFile } from \"node:fs/promises\";\nimport { resolve } from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\n\nimport type { EncodedSourceMap } from \"@jridgewell/gen-mapping\";\nimport {\n cleanModuleId,\n fileSourceKind,\n moduleSourceMap,\n type CssUpstreamMap,\n} from \"@stillwind/host\";\nimport type { Rollup } from \"vite\";\n\nimport type { IntegrationSession } from \"../session.ts\";\nimport type { CssContext } from \"./design-system.ts\";\nimport { finalizeModuleWithMap } from \"./finalize.ts\";\nimport { sourceModuleId } from \"./module-ids.ts\";\nimport type { ModuleRegistry } from \"./module-registry.ts\";\nimport type { IntegrationConfig, ProjectSettings } from \"./project.ts\";\nimport { resolveServerSource } from \"./server-source-resolve.ts\";\n\n/** Metadata retained in the Vite module graph to reconstruct a producer from a cached transform. */\nexport interface ProducerMetadata {\n /** Source before Stillwind compilation, absent when a projection produces no compiled code. */\n input?: string;\n /** Full Vite source identity, including any query suffix, when compilation succeeds. */\n id?: string;\n /** Compiler identity used for stylesheet selection, when compilation succeeds. */\n moduleId?: string;\n /** Whether the source imports an explicit CSS value, independently of `automatic`. */\n manual?: boolean;\n /** Whether this virtual module supplies an automatic stylesheet projection. */\n projection?: boolean;\n}\n\n/**\n * Producer source, transformed output, and dependency metadata retained for CSS planning and\n * cache recovery.\n */\nexport interface ProducerInput {\n /**\n * Whether the source was compiled for a stylesheet projection. Its public source name remains\n * opaque in browser CSS maps.\n */\n projection?: boolean;\n /**\n * Map from the source received by Stillwind to its original source, retained across recompilation\n * when no new map is supplied.\n */\n upstream?: CssUpstreamMap;\n /** Source text before Stillwind transformation, retained for later recompilation. */\n code: string;\n /** Map from transformed source to `code`, used when composing framework maps. */\n sourceMap?: EncodedSourceMap;\n /** Full Vite source identity, including any query suffix. */\n id: string;\n /** Compiler module identity used for stylesheet selection and composition dependencies. */\n moduleId: string;\n /**\n * Whether the producer is excluded from automatic document styles because it uses explicit CSS or\n * automatic emission is disabled.\n */\n manual: boolean;\n /** Whether the source imports `stillwind/module-css`, independently of automatic emission. */\n hasModuleCssImport: boolean;\n /**\n * Transformed source returned to Vite, used to detect CSS changes that require no JavaScript hot\n * update.\n */\n javascript: string;\n /** Compiler module identities referenced through style composition. */\n dependencies: string[];\n}\n\n/** Vite operations needed to compile producers and compose their upstream source maps. */\nexport interface CompileContext extends CssContext {\n /**\n * Reads the map produced by plugins that transformed the source before Stillwind.\n *\n * @returns The upstream map supplied by the Vite transform context.\n */\n getCombinedSourcemap?: () => Pick<\n Rollup.SourceMap,\n \"version\" | \"sources\" | \"names\" | \"mappings\" | \"sourcesContent\"\n >;\n}\n\n/** A successful producer compilation, ready to record in the environment and return to Vite. */\nexport interface ProducerCompilation {\n /** Input retained for document planning, CSS reloads, and framework source-map composition. */\n input: ProducerInput;\n /** Transformed source and metadata returned by Vite's transform hook. */\n result: ProducerTransform;\n}\n\n/** A producer transform whose graph metadata allows recovery from cached Vite modules. */\nexport interface ProducerTransform {\n /** Transformed source, retaining SFC syntax or JavaScript and any automatic producer import. */\n code: string;\n /** Serialized map from transformed source to the source received by Stillwind. */\n map: string;\n /** Metadata saved in the Vite module graph across cached transforms. */\n meta: {\n /** Original source and identities used to recover a producer before production emission. */\n stillwind: Required<Pick<ProducerMetadata, \"input\" | \"id\" | \"moduleId\" | \"manual\">>;\n };\n}\n\n/**\n * Compiles a producer and prepares its generated imports, source map, and cache metadata.\n *\n * Successful compilation updates the session and registers CSS references. The caller must store\n * the returned input. SFC output keeps framework syntax, while script output is finalized and may\n * import an automatic producer module.\n *\n * @param compiler - Initialized session for the current environment.\n * @param settings - Configured root used to derive compiler and checker file identities.\n * @param config - Compiler config, including whether document CSS is automatic.\n * @param registry - Virtual reference registry for the same environment.\n * @param code - Source text before Stillwind transformation.\n * @param id - Full Vite identity of the source, including any query suffix.\n * @param context - Resolver, watcher, warning handler, and optional upstream-map reader.\n * @param previous - Previously recorded input whose projection flag and upstream map may be\n * retained.\n * @returns A promise for the recorded input and Vite transform result, or `undefined` when the\n * compiler produces no code.\n * @throws If dependency loading, compilation, or upstream-map reading fails.\n */\nexport async function compileProducer(\n compiler: IntegrationSession,\n settings: ProjectSettings,\n config: IntegrationConfig,\n registry: ModuleRegistry,\n code: string,\n id: string,\n context: CompileContext,\n previous?: Readonly<ProducerInput>,\n): Promise<ProducerCompilation | undefined> {\n const sfc = /\\.(?:astro|svelte|vue)$/.test(cleanModuleId(id));\n\n /**\n * Gives a producer a document identity suitable for compiler reports and maps.\n * @param id - Full resolver identity. Queries and fragments are removed from the document name.\n * @returns An encoded `stillwind-virtual:` URI for virtual modules, or a file URL for a file.\n */\n const documentUri = (id: string) => {\n const clean = cleanModuleId(id);\n return clean.startsWith(\"\\0\") || clean.startsWith(\"virtual:\")\n ? `stillwind-virtual:${encodeURIComponent(clean)}`\n : pathToFileURL(clean).href;\n };\n\n const output = await compiler.compile(\n code,\n id,\n {\n // Dependency reads supply type and style facts. Vite validates the imports retained in the\n // transformed application when it constructs the JavaScript graph.\n resolve: (specifier, importer) =>\n resolveServerSource(\n (specifier, importer, options) => context.resolve(specifier, importer, options),\n specifier,\n importer,\n ),\n read: (id) => readFile(cleanModuleId(id), \"utf8\"),\n describe: (resolvedId) => {\n const virtual = resolvedId.startsWith(\"\\0\") || resolvedId.startsWith(\"virtual:\");\n const file = virtual\n ? resolve(\n settings.projectRoot,\n \".stillwind-checker\",\n `${createHash(\"sha256\").update(resolvedId).digest(\"hex\")}.ts`,\n )\n : cleanModuleId(resolvedId);\n const { syntax, format } = fileSourceKind(resolvedId);\n return {\n moduleId: virtual\n ? `virtual:${encodeURIComponent(resolvedId)}`\n : sourceModuleId(settings.projectRoot, resolvedId),\n document: {\n uri: documentUri(resolvedId),\n format,\n },\n checkerFileName: file,\n projectionFileName: file.replaceAll(\"\\\\\", \"/\"),\n syntax,\n };\n },\n watch: (id) => {\n context.addWatchFile(id);\n },\n warn: (message) => {\n context.warn(message);\n },\n },\n {\n stylesheetImports:\n sfc && config.automatic !== false ? [registry.source(\"producer\", id)] : undefined,\n moduleCssImport: registry.source(\"value\", id),\n },\n );\n if (!output?.code) {\n return;\n }\n\n const finalized = sfc\n ? {\n code: output.code,\n removed: [],\n prefix: \"\",\n }\n : finalizeModuleWithMap(output.code, false);\n const suffix =\n sfc || output.hasModuleCssImport || config.automatic === false\n ? \"\"\n : `\\nimport ${JSON.stringify(registry.source(\"producer\", id))};\\n`;\n const javascript = finalized.code + suffix;\n const sourceMap = moduleSourceMap(\n code,\n output.code,\n id,\n output.mappings,\n finalized.removed,\n finalized.prefix,\n );\n\n const input: ProducerInput = {\n sourceMap,\n projection: previous?.projection,\n upstream: context.getCombinedSourcemap\n ? {\n id: cleanModuleId(id),\n sourceMapSource: documentUri(id),\n map: JSON.stringify(context.getCombinedSourcemap()),\n }\n : previous?.upstream,\n code,\n id,\n moduleId: output.moduleId,\n manual: output.hasModuleCssImport || config.automatic === false,\n hasModuleCssImport: output.hasModuleCssImport,\n javascript,\n dependencies: output.compositionModules,\n };\n\n const result = {\n code: javascript,\n map: JSON.stringify(sourceMap),\n meta: {\n stillwind: {\n input: code,\n id,\n moduleId: output.moduleId,\n manual: output.hasModuleCssImport,\n },\n },\n };\n\n return {\n input,\n result,\n };\n}\n","import { createHash } from \"node:crypto\";\nimport { realpathSync } from \"node:fs\";\nimport { readdir, readFile, realpath } from \"node:fs/promises\";\nimport { dirname, resolve } from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\n\nimport {\n attachPlugins,\n cleanModuleId,\n createStylesheetResolver,\n cssEntrypoint,\n isStylesheet,\n loadCssGraph,\n nodePluginHost,\n type PluginRuntime,\n} from \"@stillwind/host\";\nimport type {\n NativeDesignSystemLoader,\n NativeProjectSession,\n NativeSkippedCss,\n} from \"@stillwind/native\";\n\nimport { buildCompilerOptions, IntegrationSession, warnSkippedCss } from \"../session.ts\";\nimport { readableFile } from \"./file-access.ts\";\nimport type { IntegrationConfig, ProjectSettings } from \"./project.ts\";\nimport { resolvedFile, type StylesheetResource } from \"./resources.ts\";\n\n/**\n * Vite operations needed to resolve design-system CSS and record files used by compilation.\n */\nexport interface CssContext {\n /**\n * Resolves an import through the other Vite plugins.\n *\n * @param specifier - Import text from CSS or a producer.\n * @param importer - Resolver identity of the importing file.\n * @param options - Resolution options. Stillwind passes `skipSelf: true` to avoid resolving its\n * own request again.\n * @returns A resolved identity with optional external status, or `null` when resolution fails.\n */\n resolve: (\n specifier: string,\n importer: string,\n options: {\n /** Avoids re-entering the Stillwind plugin that initiated resolution. */\n skipSelf: boolean;\n /** Metadata keyed by plugin name and forwarded to Vite's resolver hooks. */\n custom?: Record<string, unknown>;\n },\n ) => Promise<{\n /** Full resolved identity, including any resource query. */\n id: string;\n /** Truthy values mark an external resolution that requires a readable filesystem identity. */\n external?: boolean | string;\n } | null>;\n /**\n * Registers a file as a dependency of the current Vite operation.\n *\n * @param id - Resolved file identity to observe for changes.\n */\n addWatchFile: (id: string) => void;\n /**\n * Reports compiler warnings, including generator fallbacks without source locations.\n *\n * @param message - Formatted warning text.\n **/\n warn: (message: string) => void;\n}\n\n/**\n * Read-only progress of design-system loading, used to schedule refreshes and report retained\n * failures.\n */\nexport interface DesignSystemStatus {\n /** Files required by the last successful design-system load, stored as absolute paths. */\n readonly cssFiles: ReadonlySet<string>;\n /**\n * Absolute paths observed during loading, including candidates whose failed reads must be retried\n * after changes.\n */\n readonly cssObservedFiles: ReadonlySet<string>;\n /** Absolute directories whose entry additions and removals the last load observes. */\n readonly cssObservedDirectories: ReadonlySet<string>;\n /** Number of observed file-change events. Several events can advance this before one reload. */\n readonly cssChange: number;\n /** Change counter captured by the last successful load or reload. */\n readonly cssApplied: number;\n /**\n * Change counter captured by the latest load or reload attempt. Starts at -1 before\n * initialization.\n */\n readonly cssAttempted: number;\n /** Failure from the latest refresh attempt. Successful loads and reloads clear it. */\n readonly cssError?: unknown;\n /**\n * Checks whether a file event changes an input of the loaded design system.\n *\n * @param file - Absolute path of the changed file.\n * @param entry - Whether the event adds or removes the file, rather than changing its content.\n * @returns Whether `cssObservedFiles` contains the file, or the event adds or removes an entry\n * of a directory in `cssObservedDirectories`.\n */\n observes(file: string, entry: boolean): boolean;\n}\n\n/**\n * Owns one environment's compiler, design-system resources, and CSS reload state.\n */\nexport class DesignSystem {\n /** Compiler session retained across CSS reloads and replaced when initialization restarts. */\n #compiler?: IntegrationSession;\n /** Plugin runtime of the applied design system, kept as the previous runtime of reloads. */\n #plugins?: PluginRuntime;\n /** Whether the compiler is ready for producer compilation and stylesheet planning. */\n #initialized = false;\n\n /**\n * Resource placeholders mapped to resolved file identities and readable paths from the last\n * successful load.\n */\n resources = new Map<string, StylesheetResource>();\n /**\n * Absolute paths required by the last successful design-system load, including referenced\n * resource files.\n */\n cssFiles = new Set<string>();\n /**\n * Absolute paths tracked for changes, including unresolved relative candidates discovered during\n * failed loads.\n */\n cssObservedFiles = new Set<string>();\n /** Absolute directories that plugins list. Adding or removing an entry is an observed change. */\n cssObservedDirectories = new Set<string>();\n /** Content fingerprint used to detect changes when development runs without a CSS watcher. */\n cssVersion?: string;\n /** Counter advanced by changes to observed files. */\n cssChange = 0;\n /** Change counter last applied successfully to the compiler. */\n cssApplied = 0;\n /**\n * Change counter last attempted. Starts at -1 so the first watched revision cannot be skipped.\n */\n cssAttempted = -1;\n /**\n * Latest refresh error. Recording an error does not clear the initialized compiler session.\n */\n cssError?: unknown;\n\n /**\n * Creates design-system state without loading CSS or opening a compiler session.\n *\n * @param settings - Shared project settings configured before initialization.\n * @param config - Compiler options that identify the CSS entrypoint.\n */\n constructor(\n private readonly settings: ProjectSettings,\n private readonly config: IntegrationConfig,\n ) {}\n\n /**\n * Obtains the initialized compiler session.\n *\n * @returns The session currently holding the loaded design system.\n * @throws If `ensure` has not initialized the session or `reset` has invalidated it.\n */\n get compiler(): IntegrationSession {\n if (!this.#initialized || !this.#compiler) {\n throw new Error(\"Stillwind environment has not been initialized\");\n }\n return this.#compiler;\n }\n\n /**\n * Reports whether producer compilation can use the current session.\n *\n * @returns True after successful initialization and until the next reset.\n */\n get initialized(): boolean {\n return this.#initialized;\n }\n\n /**\n * Invalidates initialization so the next `ensure` reloads CSS and replaces the retained compiler\n * session.\n */\n reset(): void {\n this.#initialized = false;\n }\n\n /**\n * Closes the compiler's type-facts service while retaining native compilation state and CSS\n * reload metadata.\n */\n close(): void {\n this.#compiler?.close();\n }\n\n /**\n * Checks whether a file event changes an input of the loaded design system.\n *\n * @param file - Absolute path of the changed file.\n * @param entry - Whether the event adds or removes the file, rather than changing its content.\n * @returns Whether `cssObservedFiles` contains the file, or the event adds or removes an entry\n * of a directory in `cssObservedDirectories`.\n */\n observes(file: string, entry: boolean): boolean {\n return (\n this.cssObservedFiles.has(file) || (entry && this.cssObservedDirectories.has(dirname(file)))\n );\n }\n\n /**\n * Marks a design-system revision pending when an observed file changes.\n *\n * @param file - Absolute path of the changed file. Paths that {@link DesignSystem.observes}\n * rejects have no effect.\n * @param entry - Whether the event adds or removes the file.\n */\n changed(file: string, entry: boolean): void {\n if (this.observes(file, entry)) {\n this.cssChange++;\n }\n }\n\n /**\n * Loads a stable design-system revision and creates the compiler if initialization is pending.\n *\n * While watching, changes observed during loading cause the load to retry.\n *\n * @param context - Vite resolver and watch operations for the current build or server.\n * @param onInitialize - Called after the new session and CSS state are installed.\n * @returns A promise that resolves when the compiler is ready. An initialized session is reused.\n * @throws If loading CSS, resolving resources, or creating the compiler fails.\n */\n async ensure(context: CssContext, onInitialize: () => void): Promise<void> {\n if (this.#initialized) {\n return;\n }\n while (true) {\n const change = this.cssChange;\n let loaded: DesignSystemRevision;\n try {\n loaded = await this.#loadRevision(context);\n } catch (error) {\n if (this.settings.cssWatching && change !== this.cssChange) {\n continue;\n }\n throw error;\n }\n const version =\n this.settings.watching && !this.settings.cssWatching\n ? await designSystemVersion(loaded.dependencies, loaded.directories)\n : undefined;\n if (this.settings.cssWatching && change !== this.cssChange) {\n continue;\n }\n this.#compiler?.close();\n this.#compiler = new IntegrationSession(\n this.settings.projectRoot,\n loaded.loader,\n this.config,\n this.settings.watching,\n this.settings.compilerMode,\n loaded.plugins,\n );\n this.#plugins = loaded.plugins;\n this.#initialized = true;\n this.resources = loaded.resources;\n this.cssFiles = loaded.dependencies;\n this.cssObservedFiles = loaded.observed;\n this.cssObservedDirectories = loaded.directories;\n this.cssVersion = version;\n this.cssApplied = this.cssAttempted = change;\n this.cssError = undefined;\n warnSkippedCss(loaded.skipped, (message) => context.warn(message));\n onInitialize();\n return;\n }\n }\n\n /**\n * Reloads changed development CSS and records failed refresh attempts.\n *\n * Production returns after initialization. Development uses observed change counters or file\n * fingerprints. Refresh failures are recorded and warned. If loading the next CSS revision\n * fails, the compiler keeps the previously loaded design system.\n *\n * @param context - Vite resolver and watch operations for loading the next design-system\n * revision.\n * @param onInitialize - Called if initialization must create a compiler session.\n * @param onReload - Receives compiler module identities whose generated JavaScript changed after\n * a reload.\n * @returns A promise that resolves after initialization and any required refresh.\n * @throws If initial loading fails. Failures during a later refresh are recorded in `cssError`.\n */\n async refresh(\n context: CssContext,\n onInitialize: () => void,\n onReload: (modules: string[]) => void,\n ): Promise<void> {\n await this.ensure(context, onInitialize);\n if (!this.settings.watching) {\n return;\n }\n while (true) {\n const change = this.cssChange;\n if (this.settings.cssWatching && this.cssAttempted === change) {\n return;\n }\n try {\n const version = this.settings.cssWatching\n ? undefined\n : await designSystemVersion(this.cssFiles, this.cssObservedDirectories);\n if (!this.settings.cssWatching && version === this.cssVersion) {\n return;\n }\n const loaded = await this.#loadRevision(context);\n const nextVersion = this.settings.cssWatching\n ? undefined\n : await designSystemVersion(loaded.dependencies, loaded.directories);\n if (\n this.settings.cssWatching\n ? change !== this.cssChange\n : version !== (await designSystemVersion(this.cssFiles, this.cssObservedDirectories))\n ) {\n continue;\n }\n const update = this.compiler.native.reload(loaded.loader);\n attachPlugins(this.compiler.native, loaded.plugins);\n this.#plugins = loaded.plugins;\n onReload(update.transformedModules);\n this.resources = loaded.resources;\n this.cssFiles = loaded.dependencies;\n this.cssObservedFiles = loaded.observed;\n this.cssObservedDirectories = loaded.directories;\n this.cssVersion = nextVersion;\n this.cssApplied = this.cssAttempted = change;\n this.cssError = undefined;\n warnSkippedCss(loaded.skipped, (message) => context.warn(message));\n return;\n } catch (error) {\n if (this.settings.cssWatching && change !== this.cssChange) {\n continue;\n }\n this.cssAttempted = change;\n this.cssError = error;\n this.settings.devServerRef?.config.logger.warn(\n `Stillwind update failed; retaining published styles: ${String(error)}`,\n );\n return;\n }\n }\n }\n\n /**\n * Loads CSS and resources while recording successful dependencies and attempted file reads.\n *\n * Files are registered with Vite and the development watcher as they are discovered. Failed loads\n * retain newly observed paths so later edits can trigger another attempt.\n *\n * @param context - Vite resolver and watch operations.\n * @returns The loaded design system, resolved resources, required file set, and observed file\n * set.\n * @throws If CSS loading or resource resolution fails.\n */\n async #loadRevision(context: CssContext): Promise<DesignSystemRevision> {\n const dependencies = new Set<string>();\n const observed = new Set<string>();\n // Keep this set so reads that finish later cannot change the next revision's file set.\n const tracking = this.cssObservedFiles;\n /**\n * Records a dependency once for this load and registers it with Vite's watchers.\n *\n * @param file - Attempted or resolved file path, normalized to an absolute path.\n */\n const watch = (file: string) => {\n const path = resolve(file);\n if (observed.has(path)) {\n return;\n }\n observed.add(path);\n tracking.add(path);\n context.addWatchFile(path);\n this.settings.devServerRef?.watcher.add(path);\n };\n const directories = new Set<string>();\n const trackingDirectories = this.cssObservedDirectories;\n /**\n * Records a directory that a plugin lists once for this load and registers it with Vite's\n * watchers.\n *\n * @param directory - Absolute directory path.\n */\n const watchDirectory = (directory: string) => {\n const path = resolve(directory);\n if (directories.has(path)) {\n return;\n }\n directories.add(path);\n trackingDirectories.add(path);\n context.addWatchFile(path);\n this.settings.devServerRef?.watcher.add(path);\n };\n const result = await loadDesignSystem(\n this.settings,\n this.config,\n async (specifier, importer) =>\n resolvedFile(\n await context.resolve(specifier, importer, { skipSelf: true }),\n `CSS ${specifier} from ${importer}`,\n ),\n dependencies,\n this.#initialized ? this.#compiler?.native : undefined,\n watch,\n watchDirectory,\n this.#plugins,\n );\n return { ...result, dependencies, observed, directories };\n }\n}\n\n/**\n * Loaded design system and resolved resource files for one Vite environment.\n */\nexport interface LoadedDesignSystem {\n /** Native loader containing the complete CSS graph and compiler settings. */\n loader: NativeDesignSystemLoader;\n /** Resource placeholder tokens mapped to resolver identities and checked filesystem paths. */\n resources: Map<string, StylesheetResource>;\n /** Plugins of the CSS graph's `@plugin` statements. */\n plugins?: PluginRuntime;\n /** Statements that loading skipped instead of failing, in source order. */\n skipped: NativeSkippedCss[];\n}\n\n/**\n * Loaded design system with the file sets needed to watch and apply its revision.\n */\nexport interface DesignSystemRevision extends LoadedDesignSystem {\n /** Absolute paths required by the successful load, including referenced assets. */\n dependencies: Set<string>;\n /** Absolute paths observed during loading, including unresolved relative candidates. */\n observed: Set<string>;\n /** Absolute directories that plugins list during loading. */\n directories: Set<string>;\n}\n\n/**\n * Loads the configured CSS graph and resolves each referenced resource to a readable file.\n *\n * @param settings - Configured project root and optional development server used to check resource\n * access.\n * @param config - Compiler settings and the CSS entrypoint, resolved against the project root.\n * @param resolveImport - Resolves a specifier relative to its importer and returns a file identity.\n * @param dependencies - Mutable set receiving files required by the CSS graph and its resources.\n * @param session - Existing native session used to create a compatible loader during reload.\n * @param watch - Records attempted and resolved file paths, including unresolved relative\n * candidates.\n * @param watchDirectory - Records directories that plugins list.\n * @param previous - Plugin runtime of the previous load, whose candidates are resolved again.\n * @returns A native design-system loader, a map from resource placeholders to resolved files, the\n * plugin runtime, and the skipped statements.\n * @throws If the entrypoint is missing or not readable, CSS cannot be divided into statements, or a\n * referenced resource is not readable. Imports that cannot be resolved or read are skipped.\n */\nasync function loadDesignSystem(\n settings: ProjectSettings,\n config: IntegrationConfig,\n resolveImport: (specifier: string, importer: string) => Promise<string>,\n dependencies: Set<string>,\n session?: NativeProjectSession,\n watch: (file: string) => void = () => {},\n watchDirectory: (directory: string) => void = () => {},\n previous?: PluginRuntime,\n): Promise<LoadedDesignSystem> {\n const entry = resolve(settings.projectRoot, cssEntrypoint(config));\n watch(entry);\n const root = realpathSync(entry);\n /**\n * Watches relative candidates before resolution and the resolved file after success.\n * @param specifier - CSS import or resource request passed to the configured resolver.\n * @param importer - Full identity of the source containing the request.\n * @returns The resolver's identity with its query and fragment retained.\n * @throws If resolution or a watch callback fails.\n */\n const resolveCss = async (specifier: string, importer: string) => {\n if (specifier.startsWith(\".\")) {\n watch(resolve(dirname(importer), cleanModuleId(specifier)));\n }\n const file = await resolveImport(specifier, importer);\n watch(cleanModuleId(file));\n return file;\n };\n const nativeOptions = buildCompilerOptions(config);\n const resolvePackageCss = createStylesheetResolver();\n const {\n loader,\n resources: resourceReferences,\n plugins,\n skipped,\n } = await loadCssGraph(\n root,\n nativeOptions,\n {\n resolve: async (specifier, importer) => {\n let resolved: string | undefined;\n let failure: unknown;\n try {\n resolved = await resolveCss(specifier, importer);\n } catch (error) {\n failure = error;\n }\n if (resolved && isStylesheet(cleanModuleId(resolved))) {\n return realpath(cleanModuleId(resolved));\n }\n const stylesheet =\n !specifier.startsWith(\".\") && !specifier.startsWith(\"/\")\n ? await resolvePackageCss(specifier, importer)\n : undefined;\n if (stylesheet) {\n return realpath(stylesheet);\n }\n if (resolved) {\n return realpath(cleanModuleId(resolved));\n }\n throw failure;\n },\n read: (name) => readFile(name, \"utf8\"),\n documentUri: (name) => pathToFileURL(name).href,\n sourceMapSource: (name) => pathToFileURL(name).href,\n watch: (name) => {\n dependencies.add(name);\n watch(name);\n },\n watchDirectory,\n plugins: nodePluginHost,\n },\n undefined,\n session?.newLoader(nativeOptions),\n {\n plugins: config.plugins,\n tailwind: config.tailwind,\n important: config.important,\n root: settings.projectRoot,\n previous,\n },\n );\n const references = new Map<string, StylesheetResource>();\n for (const resource of resourceReferences) {\n const resolved = await resolveCss(resource.specifier, resource.sourceName);\n const file = await readableFile(resolved, settings.devServerRef);\n references.set(resource.placeholder, {\n id: resolved,\n file,\n });\n dependencies.add(cleanModuleId(resolved));\n }\n return {\n loader,\n resources: references,\n plugins,\n skipped,\n };\n}\n\n/**\n * Computes a stable fingerprint of the paths and contents used by the design system, and of the\n * entry names of the directories that plugins list.\n *\n * @param files - Absolute dependency paths. Iteration order does not affect the fingerprint.\n * @param directories - Absolute directory paths. Iteration order and entry order do not affect the\n * fingerprint.\n * @returns A SHA-256 hexadecimal fingerprint. Missing files and directories contribute a fixed\n * marker.\n * @throws If reading a file or directory fails for a reason other than `ENOENT`.\n */\nasync function designSystemVersion(files: Set<string>, directories: ReadonlySet<string>) {\n const hash = createHash(\"sha256\");\n for (const directory of [...directories].sort()) {\n let names: string;\n try {\n names = (await readdir(directory)).sort().join(\"\\0\");\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== \"ENOENT\") {\n throw error;\n }\n names = \"\\0missing\";\n }\n hash.update(directory).update(\"\\0\\0\").update(names).update(\"\\0\");\n }\n const ordered = [...files].sort();\n for (let offset = 0; offset < ordered.length; offset += 64) {\n const batch = ordered.slice(offset, offset + 64);\n const contents = await Promise.all(\n batch.map(async (file) => {\n try {\n return await readFile(file);\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== \"ENOENT\") {\n throw error;\n }\n return \"\\0missing\";\n }\n }),\n );\n for (const [index, file] of batch.entries()) {\n hash.update(file).update(\"\\0\").update(contents[index]).update(\"\\0\");\n }\n }\n return hash.digest(\"hex\");\n}\n","import { createHash } from \"node:crypto\";\n\nimport { cleanModuleId } from \"@stillwind/host\";\n\nimport { sourceModuleId } from \"./module-ids.ts\";\nimport type { StylesheetResource } from \"./resources.ts\";\n\n/** Payload for an issued virtual reference in one compiler environment. */\ntype ModuleEntry =\n | {\n /** Selects explicit CSS values or source projections that compile CSS without application execution. */\n readonly kind: \"value\" | \"projection\";\n /** Full source resolver identity, including any query selecting distinct source. */\n readonly sourceId: string;\n }\n | {\n /** Selects the runtime registration module for an automatic CSS producer. */\n readonly kind: \"producer\";\n /** Full source resolver identity. */\n readonly sourceId: string;\n /** Compiler identity used for stylesheet activation and composition dependencies. */\n readonly moduleId: string;\n }\n | {\n /** Selects a generated module exporting one stylesheet fragment. */\n readonly kind: \"fragment\";\n /** Fragment CSS containing the recorded resource placeholders. */\n readonly css: string;\n /** Placeholder records selected because they occur in this fragment. */\n readonly resources: readonly (readonly [string, StylesheetResource])[];\n };\n\n/** References issued by one project environment. Unknown IDs never supply file paths. */\nexport class ModuleRegistry {\n /** Issued virtual identities mapped to their payloads. References are not interpreted as paths. */\n readonly #entries = new Map<string, ModuleEntry>();\n /** Projection imports keyed by full importer identity and authored specifier. */\n readonly #projections = new Map<string, Map<string, string>>();\n\n /**\n * Creates an empty registry for one project environment.\n * @param root - Project root used to derive compiler identities from source resolver identities.\n * @param environment - Environment name included in every issued reference's fingerprint.\n */\n constructor(\n readonly root: string,\n readonly environment: string,\n ) {}\n\n /**\n * Issues a deterministic reference. Identical fragments reuse their fixed payloads.\n * @param kind - Reference family included in the virtual prefix and fingerprint.\n * @param key - Source identity or serialized fragment content used within that family.\n * @param entry - Owned payload fixed under the resulting identity.\n * @returns A virtual:stillwind reference containing a SHA-256 token scoped to the environment.\n */\n #register(kind: string, key: string, entry: ModuleEntry): string {\n const token = createHash(\"sha256\")\n .update(JSON.stringify([this.environment, kind, key]))\n .digest(\"hex\");\n const id = `virtual:stillwind/${kind}:${token}`;\n if (entry.kind === \"fragment\" && this.#entries.has(id)) {\n return id;\n }\n this.#entries.set(id, entry);\n return id;\n }\n\n /**\n * Registers a source-backed generated module.\n * @param kind - CSS value, projection, or producer registration module family.\n * @param sourceId - Full resolver identity, including queries that select distinct source.\n * @returns A deterministic reference for that environment, family, and compiler module identity.\n */\n source(kind: \"value\" | \"projection\" | \"producer\", sourceId: string): string {\n const moduleId = sourceModuleId(this.root, sourceId);\n return this.#register(kind, moduleId, {\n kind,\n sourceId,\n moduleId,\n });\n }\n\n /**\n * Registers CSS with only the resource records whose placeholders occur in it.\n * @param css - Generated fragment text before resource replacement.\n * @param resources - Available placeholder records. The supplied map is unchanged.\n * @returns A reference fingerprinted from CSS and selected records in map order.\n */\n fragment(css: string, resources: ReadonlyMap<string, StylesheetResource>): string {\n const selected: (readonly [string, StylesheetResource])[] = [];\n for (const [placeholder, resource] of resources) {\n if (css.includes(placeholder)) {\n selected.push([\n placeholder,\n {\n id: resource.id,\n file: resource.file,\n },\n ]);\n }\n }\n return this.#register(\"fragment\", JSON.stringify([css, selected]), {\n kind: \"fragment\",\n css,\n resources: selected,\n });\n }\n\n /**\n * Looks up an issued public or resolved virtual reference.\n * @param id - virtual:stillwind identity or its NUL-prefixed resolved spelling.\n * @returns The retained payload, or undefined for an unregistered identity.\n */\n get(id: string): ModuleEntry | undefined {\n return this.#entries.get(id.replace(/^\\0stillwind:/, \"virtual:stillwind/\"));\n }\n\n /**\n * Replaces an importer's projection edges and removes previous references with no remaining owner.\n * @param importer - Full resolver identity of the original importing document.\n * @param sources - Authored projection specifiers mapped to resolved source identities. The map is copied.\n */\n projections(importer: string, sources: ReadonlyMap<string, string>): void {\n const previous = this.#projections.get(importer);\n this.#projections.set(\n importer,\n new Map(\n [...sources].map(([specifier, source]) => [specifier, this.source(\"projection\", source)]),\n ),\n );\n for (const reference of previous?.values() ?? []) {\n if (\n ![...this.#projections.values()].some((edges) => [...edges.values()].includes(reference))\n ) {\n this.#entries.delete(reference);\n }\n }\n }\n\n /**\n * Resolves a projection only through an importer's previously registered edge.\n * @param specifier - Authored projection request, including ?stillwind.css.\n * @param importer - Full importer identity. Omission cannot select an edge.\n * @returns The issued reference, or undefined when no corresponding edge exists.\n */\n projection(specifier: string, importer?: string): string | undefined {\n return importer === undefined ? undefined : this.#projections.get(importer)?.get(specifier);\n }\n\n /**\n * Removes source-backed references and projection edges after source removal.\n * @param sourceId - Full resolver identity to remove.\n * @param file - Whether to match all queries and fragments of the cleaned file identity.\n */\n remove(sourceId: string, file = false): void {\n /**\n * Applies the selected source-removal policy to a registered identity.\n * @param id - Full resolver identity from a source entry or projection importer.\n * @returns Whether the exact identity, or its cleaned file identity when requested, matches.\n */\n const matches = (id: string) =>\n file ? cleanModuleId(id) === cleanModuleId(sourceId) : id === sourceId;\n for (const [id, entry] of this.#entries) {\n if (\"sourceId\" in entry && matches(entry.sourceId)) {\n this.#entries.delete(id);\n }\n }\n for (const [importer, edges] of this.#projections) {\n if (matches(importer)) {\n this.#projections.delete(importer);\n } else {\n for (const [specifier, target] of edges) {\n if (!this.#entries.has(target)) {\n edges.delete(specifier);\n }\n }\n }\n }\n }\n\n /** Removes every issued reference and projection edge when the environment is reset. */\n clear(): void {\n this.#entries.clear();\n this.#projections.clear();\n }\n}\n","import {\n decodeCssSourceMap,\n finalizeCss,\n warnRejectedNames,\n type DecodedCssSourceMap,\n} from \"@stillwind/host\";\nimport type { NativeStylesheetPlan } from \"@stillwind/native\";\n\nimport { cssForBrowser, type BrowserCssSources } from \"./browser-css.ts\";\nimport type { CssContext, DesignSystem } from \"./design-system.ts\";\nimport { readableFile } from \"./file-access.ts\";\nimport type { ProjectSettings } from \"./project.ts\";\nimport {\n resolvedFile,\n resolveResources,\n resourceReplacements,\n type StylesheetResource,\n} from \"./resources.ts\";\n\n/**\n * A rendered stylesheet with resolved resources and browser-ready parts, retaining native\n * provenance and coverage.\n */\nexport interface StylesheetPlan extends Omit<NativeStylesheetPlan, \"css\" | \"resources\" | \"parts\"> {\n /** Environment revision when this selection was planned. */\n revision: number;\n /** CSS with compiler resource placeholders retained for production asset emission. */\n originalCss: string;\n /** Resource placeholders mapped to resolved identities and readable absolute paths. */\n resources: Map<string, StylesheetResource>;\n /** Placeholder tokens mapped to escaped URLs used in resolved CSS. */\n resourceReplacements: Map<string, string>;\n /** Document CSS with resource placeholders replaced by readable resource URLs. */\n css: string;\n /** Native occurrences in cascade order, retaining placeholders and native source maps. */\n rawParts: NativeStylesheetPlan[\"parts\"];\n /** Resolved occurrences in the same order as `rawParts`, ready for development delivery. */\n parts: ResolvedStylesheetPart[];\n}\n\n/** A stylesheet occurrence whose resources and optional map are ready for the browser. */\nexport interface ResolvedStylesheetPart {\n /** Preserved notices required by this occurrence. */\n banners: string[];\n /** Native content fingerprint used by the runtime to share equal CSS payloads. */\n key: string;\n /** Compiler module identities that activate this occurrence. Empty means shared support CSS. */\n producers: string[];\n /** CSS with resolved resource URLs, excluding the inline source-map comment. */\n css: string;\n /**\n * Public source map when available. Undefined when development maps are disabled, or null when\n * the CSS contains no encoded map.\n */\n map: DecodedCssSourceMap[\"map\"] | undefined;\n}\n\n/**\n * Plans selected compiler modules and resolves their stylesheet resource placeholders.\n *\n * Referenced resources are checked for readability and registered as watch dependencies.\n * Development parts include public source maps only when development CSS maps are enabled.\n *\n * @param designSystem - Initialized design system for the current environment.\n * @param settings - Project root, source-map settings, and optional server used to validate\n * resource access.\n * @param sources - Environment sources used to compose browser CSS maps.\n * @param revision - Environment revision recorded in the resulting plan.\n * @param modules - Compiler module identities selected for document placement.\n * @param context - Vite resolver and watch operations for referenced resources.\n * @param complete - Whether the caller has collected the complete application graph. False uses\n * observed coverage.\n * @returns A promise for resolved CSS, raw compiler parts, browser-ready parts, and resource\n * replacements.\n * @throws If the compiler is uninitialized, stylesheet planning fails, or a resource cannot be\n * resolved or read.\n */\nexport async function resolveStylesheet(\n designSystem: DesignSystem,\n settings: ProjectSettings,\n sources: BrowserCssSources,\n revision: number,\n modules: string[],\n context: CssContext,\n complete = false,\n): Promise<StylesheetPlan> {\n const plan = designSystem.compiler.native.planStylesheet(\n {\n modules,\n coverage: complete\n ? {\n kind: \"complete\",\n target: \"application\",\n revision: String(revision),\n }\n : {\n kind: \"observed\",\n },\n placement: \"document\",\n },\n settings.watching ? settings.devSourceMaps : settings.sourceMaps,\n );\n warnRejectedNames(plan.rejectedNames, (message) => context.warn(message));\n\n const resources = new Map(designSystem.resources);\n for (const resource of plan.resources) {\n const resolved = await context.resolve(\n resource.specifier,\n designSystem.compiler.resolverId(resource.moduleId),\n {\n skipSelf: true,\n },\n );\n const id = resolvedFile(resolved, `Stillwind resource ${resource.specifier}`);\n const file = await readableFile(id, settings.devServerRef);\n context.addWatchFile(file);\n resources.set(resource.placeholder, {\n id,\n file,\n });\n }\n\n const replacements = resourceReplacements(resources);\n\n return {\n ...plan,\n revision,\n originalCss: plan.css,\n resources,\n resourceReplacements: replacements,\n css: finalizeCss({\n css: resolveResources(plan.css, replacements),\n banners: plan.banners,\n }),\n rawParts: plan.parts,\n parts: plan.parts.map((part) => {\n const mapped =\n settings.watching && settings.devSourceMaps\n ? // The runtime adds the notices of the active parts when it combines them.\n decodeCssSourceMap(\n cssForBrowser(\n sources,\n {\n ...part,\n banners: [],\n },\n replacements,\n ),\n )\n : undefined;\n return {\n banners: part.banners,\n key: part.key,\n producers: part.producers,\n css: mapped?.code ?? resolveResources(part.css, replacements),\n map: mapped?.map,\n };\n }),\n };\n}\n","import { cleanModuleId, compilerModuleId } from \"@stillwind/host\";\n\nimport type { BrowserCssSources } from \"./browser-css.ts\";\nimport type { BuildOutput } from \"./build.ts\";\nimport { compileProducer, type CompileContext, type ProducerInput } from \"./compile.ts\";\nimport { DesignSystem, type CssContext, type DesignSystemStatus } from \"./design-system.ts\";\nimport { ModuleRegistry } from \"./module-registry.ts\";\nimport type { IntegrationConfig, ProjectSettings } from \"./project.ts\";\nimport { resolveStylesheet, type StylesheetPlan } from \"./stylesheet.ts\";\n\n/** A development stylesheet snapshot and producer dependency graph for one environment. */\nexport interface CssSnapshot {\n /** Environment revision used by the runtime to discard older stylesheet snapshots. */\n revision: number;\n /** Stylesheet occurrences in cascade order, with resource URLs and optional browser-safe maps. */\n parts: StylesheetPlan[\"parts\"];\n /**\n * Compiler module identities mapped to their composition dependencies, including manual\n * producers.\n */\n dependencies: Record<string, string[]>;\n}\n\n/** Owns compiler inputs, virtual references, and serialized CSS work for one Vite environment. */\nexport class ViteEnvironment {\n /** Design system and compiler used only by this environment. */\n readonly #designSystem: DesignSystem;\n /** Producer inputs keyed by their full Vite identities, including query suffixes. */\n readonly #inputs = new Map<string, ProducerInput>();\n /**\n * Compiler module identities whose JavaScript changed after a CSS reload, pending consumption by\n * hot-update handling.\n */\n readonly #themeChanges = new Set<string>();\n\n /**\n * Promise released by the latest queued operation. It resolves even when that operation fails, so\n * later work can continue.\n */\n #work = Promise.resolve();\n /** Virtual references created lazily after the project root has been configured. */\n #registry?: ModuleRegistry;\n\n /** Revision counter advanced when the compiler initializes or a snapshot is published. */\n revision = 0;\n /**\n * Production assets and manifest from the latest stylesheet emission. Build start clears this\n * value.\n */\n buildOutput?: BuildOutput;\n\n /**\n * Creates isolated compilation state for a Vite environment.\n *\n * @param name - Vite environment name used for virtual module identities and runtime snapshots.\n * @param settings - Shared project settings that must be configured before compilation starts.\n * @param config - Compiler options shared by the project.\n * @param invalidate - Invalidates Vite source identities whose JavaScript changes after a\n * design-system reload.\n */\n constructor(\n readonly name: string,\n private readonly settings: ProjectSettings,\n private readonly config: IntegrationConfig,\n private readonly invalidate: (ids: readonly string[]) => void,\n ) {\n this.#designSystem = new DesignSystem(settings, config);\n }\n\n /**\n * Exposes design-system reload progress without allowing callers to replace its state.\n *\n * @returns The current environment's live design-system status.\n */\n get designSystem(): DesignSystemStatus {\n return this.#designSystem;\n }\n\n /**\n * Exposes compiled producers for stylesheet selection and graph recovery.\n *\n * @returns The live producer map keyed by full Vite source identity. Callers must not mutate its\n * entries.\n */\n get inputs(): ReadonlyMap<string, Readonly<ProducerInput>> {\n return this.#inputs;\n }\n\n /**\n * Obtains the registry of virtual references for this environment.\n *\n * @returns The existing registry, or a registry created using the configured project root.\n */\n get registry(): ModuleRegistry {\n this.#registry ??= new ModuleRegistry(this.settings.projectRoot, this.name);\n return this.#registry;\n }\n\n /**\n * Collects source metadata for composing browser-visible CSS maps.\n *\n * @returns The project root, environment name, current CSS file set, and current producer inputs.\n */\n get browserSources(): BrowserCssSources {\n return {\n root: this.settings.projectRoot,\n environment: this.name,\n cssFiles: this.#designSystem.cssFiles,\n inputs: [...this.#inputs.values()],\n };\n }\n\n /**\n * Records a changed file for the next design-system refresh.\n *\n * @param file - Absolute path of the changed file.\n * @param entry - Whether the event adds or removes the file, rather than changing its content.\n */\n changed(file: string, entry: boolean): void {\n this.#designSystem.changed(file, entry);\n }\n\n /**\n * Closes the environment's type-facts service while retaining native compiler state and producer\n * inputs.\n */\n closeTypeFacts(): void {\n this.#designSystem.close();\n }\n\n /**\n * Closes type facts and clears virtual references. Producer inputs and native compiler state\n * remain allocated.\n */\n close(): void {\n this.closeTypeFacts();\n this.#registry?.clear();\n }\n\n /**\n * Starts a compilation cycle by clearing inputs and loading a fresh design system.\n *\n * The operation clears virtual references and build output. It runs after earlier environment\n * operations have finished.\n *\n * @param context - Vite resolver and watch operations for this environment.\n * @returns A promise that resolves after compiler initialization, or rejects if initialization\n * fails.\n */\n start(context: CssContext) {\n return this.#inTurn(async () => {\n this.#designSystem.reset();\n this.#inputs.clear();\n this.registry.clear();\n this.buildOutput = undefined;\n await this.#designSystem.ensure(context, () => {\n this.revision++;\n });\n });\n }\n\n /**\n * Applies any pending CSS changes and records producers whose JavaScript changed.\n *\n * @param context - Vite resolver and watch operations.\n * @returns A promise that resolves after the serialized refresh. Initial loading failures reject\n * it.\n */\n refreshDesignSystem(context: CssContext) {\n return this.#inTurn(async () => {\n await this.#refresh(context);\n });\n }\n\n /**\n * Compiles a source producer and records its input for document or explicit CSS emission.\n *\n * Compilation runs after design-system refresh and earlier environment work. A successful result\n * replaces the recorded producer input.\n *\n * @param code - Source text received before Stillwind transformation.\n * @param id - Full Vite source identity, including any query suffix.\n * @param context - Vite resolution, watch, warning, and optional upstream-map operations.\n * @returns A promise for the transformed module, or `undefined` when the compiler produces no\n * code.\n */\n compile(code: string, id: string, context: CompileContext) {\n return this.#compile(code, id, context, false);\n }\n\n /**\n * Compiles source for a stylesheet projection and forces its styles into document selection.\n *\n * A successful input is marked as a projection and made automatic even when the source uses\n * explicit CSS values.\n *\n * @param code - Original producer source read for the projection.\n * @param id - Full identity of the projected producer.\n * @param context - Resolver, watcher, and warning operations for the projection.\n * @returns A promise for the transformed producer, or `undefined` when the compiler produces no\n * code.\n */\n compileProjection(code: string, id: string, context: CompileContext) {\n return this.#compile(code, id, context, true);\n }\n\n /**\n * Serializes producer compilation and updates recorded input after a successful transform.\n *\n * @param code - Producer source before Stillwind compilation.\n * @param id - Full Vite producer identity.\n * @param context - Compilation operations and optional upstream source map.\n * @param projection - Whether to mark the result as an automatic stylesheet projection.\n * @returns A promise for the transformed module, or `undefined` if no code was produced.\n */\n #compile(code: string, id: string, context: CompileContext, projection: boolean) {\n return this.#inTurn(async () => {\n await this.#refresh(context);\n const output = await compileProducer(\n this.#designSystem.compiler,\n this.settings,\n this.config,\n this.registry,\n code,\n id,\n context,\n this.#inputs.get(id),\n );\n if (!output) {\n return;\n }\n if (projection) {\n output.input.manual = false;\n output.input.projection = true;\n }\n this.#inputs.set(id, output.input);\n return output.result;\n });\n }\n\n /**\n * Marks a recovered producer as a stylesheet projection.\n *\n * @param id - Exact identity of an input already recorded in this environment.\n * @returns A promise that resolves after the input is updated. Missing inputs have no effect.\n */\n markProjection(id: string) {\n return this.#inTurn(async () => {\n const input = this.#inputs.get(id);\n if (input) {\n this.#inputs.set(id, { ...input, projection: true });\n }\n });\n }\n\n /**\n * Replaces the stylesheet projection imports recorded for an importer.\n *\n * @param id - Full identity of the importing module.\n * @param sources - Projection specifiers mapped to their resolved producer identities.\n * @returns A promise that resolves after registry references are updated and unused previous\n * references are removed.\n */\n projections(id: string, sources: ReadonlyMap<string, string>) {\n return this.#inTurn(async () => {\n this.registry.projections(id, sources);\n });\n }\n\n /**\n * Removes one source identity from producer inputs, virtual references, and the native compiler.\n *\n * @param id - Exact producer identity, including its query suffix.\n * @returns A promise resolving to true when a producer input was removed.\n */\n removeSource(id: string) {\n return this.#remove(id, false);\n }\n\n /**\n * Removes every producer identity associated with a file, including query-qualified inputs.\n *\n * @param id - File identity. Its query is ignored when matching producer inputs and references.\n * @returns A promise resolving to true when at least one producer input was removed.\n */\n removeFile(id: string) {\n return this.#remove(id, true);\n }\n\n /**\n * Removes matching producer inputs and their associated compiler artifacts.\n *\n * @param id - Producer or file identity to remove.\n * @param file - Whether to match all query variants of the underlying file.\n * @returns A promise resolving to true when at least one recorded input was removed.\n */\n #remove(id: string, file: boolean) {\n return this.#inTurn(async () => {\n this.registry.remove(id, file);\n let removed = false;\n for (const [key, input] of this.#inputs) {\n if (file ? cleanModuleId(input.id) === cleanModuleId(id) : input.id === id) {\n this.#inputs.delete(key);\n if (this.#designSystem.initialized) {\n this.#designSystem.compiler.native.remove(input.moduleId);\n }\n removed = true;\n }\n }\n return removed;\n });\n }\n\n /**\n * Reserves identifiers from authored CSS before generating conflicting compiler identifiers.\n *\n * @param id - Identity of the authored stylesheet. Its query is ignored for the compiler module\n * path.\n * @param code - Authored CSS text containing identifiers to reserve.\n * @param context - Resolver and watch operations used if the design system needs initialization.\n * @returns A promise that resolves after identifiers are registered in the native compiler.\n */\n reserveAuthoredCss(id: string, code: string, context: CssContext) {\n return this.#inTurn(async () => {\n await this.#designSystem.ensure(context, () => {\n this.revision++;\n });\n this.#designSystem.compiler.native.reserveAuthoredCss(\n compilerModuleId(this.settings.projectRoot, cleanModuleId(id)),\n code,\n );\n });\n }\n\n /**\n * Plans document styles for automatic producers after applying pending CSS changes.\n *\n * @param context - Resolver and watch operations for resources referenced by the selected styles.\n * @param complete - Whether the caller has collected the complete application graph. Defaults to\n * observed coverage.\n * @param selection - Optional compiler module paths without query suffixes. Omission selects all\n * automatic inputs. An empty list selects none.\n * @returns A promise for an ordered stylesheet with resolved resources and browser-ready parts.\n */\n documentPlan(context: CssContext, complete = false, selection?: readonly string[]) {\n return this.#inTurn(async () => {\n await this.#refresh(context);\n return this.#plan(this.#documentModules(selection), context, complete);\n });\n }\n\n /**\n * Plans styles for explicitly selected compiler modules.\n *\n * @param modules - Compiler module identities in selection order, including manual producers when\n * needed.\n * @param context - Resolver and watch operations for referenced resources.\n * @param complete - Whether the selection comes from a complete application graph. Defaults to\n * observed coverage.\n * @returns A promise for the stylesheet and its ordered parts after any design-system refresh.\n */\n modulePlan(modules: string[], context: CssContext, complete = false) {\n return this.#inTurn(async () => {\n await this.#refresh(context);\n return this.#plan(modules, context, complete);\n });\n }\n\n /**\n * Builds a development snapshot without incrementing the publication revision.\n *\n * @param context - Resolver and watch operations for the current stylesheet.\n * @returns A promise for document parts and producer dependencies at the current revision.\n */\n snapshot(context: CssContext) {\n return this.#inTurn(async () => {\n await this.#refresh(context);\n return this.#snapshot(await this.#plan(this.#documentModules(), context));\n });\n }\n\n /**\n * Advances the publication revision and delivers a current document stylesheet snapshot.\n *\n * The operation is serialized with compilation. A planning failure rejects before the callback is\n * called.\n *\n * @param context - Resolver and watch operations for stylesheet planning.\n * @param send - Receives the snapshot if its revision is still current when planning finishes.\n * @returns A promise that resolves after planning and any delivery.\n */\n publish(context: CssContext, send: (snapshot: CssSnapshot) => void) {\n return this.#inTurn(async () => {\n await this.#refresh(context);\n const revision = ++this.revision;\n const plan = await this.#plan(this.#documentModules(), context);\n if (revision === this.revision) {\n send(this.#snapshot(plan));\n }\n });\n }\n\n /**\n * Consumes producer identities changed by design-system reloads since the previous call.\n *\n * @returns A copy of the pending identities. The internal set is cleared.\n */\n takeThemeChanges(): Set<string> {\n const changes = new Set(this.#themeChanges);\n this.#themeChanges.clear();\n return changes;\n }\n\n /**\n * Refreshes the design system and records compiler modules requiring JavaScript invalidation.\n *\n * @param context - Resolver and watch operations for CSS reloads.\n * @returns A promise that resolves after refresh and invalidation callbacks.\n */\n async #refresh(context: CssContext) {\n await this.#designSystem.refresh(\n context,\n () => {\n this.revision++;\n },\n (modules) => {\n for (const module of modules) {\n this.#themeChanges.add(module);\n }\n if (modules.length) {\n this.invalidate(\n [...this.#inputs.values()]\n .filter((input) => modules.includes(input.moduleId))\n .map((input) => input.id),\n );\n }\n },\n );\n }\n\n /**\n * Selects automatic producer identities for document stylesheet planning.\n *\n * @param selection - Optional compiler module paths without query suffixes. An empty list selects\n * no inputs.\n * @returns Compiler module identities from nonmanual inputs, in their recorded order.\n */\n #documentModules(selection?: readonly string[]): string[] {\n return [...this.#inputs.values()]\n .filter(\n (input) =>\n !input.manual && (!selection || selection.includes(cleanModuleId(input.moduleId))),\n )\n .map((input) => input.moduleId);\n }\n\n /**\n * Resolves a stylesheet using the initialized compiler and current environment revision.\n *\n * @param modules - Compiler module identities selected for the stylesheet.\n * @param context - Resolver and watch operations for referenced resources.\n * @param complete - Whether to claim complete application coverage for this selection.\n * @returns A promise for resolved CSS and its ordered parts.\n */\n #plan(modules: string[], context: CssContext, complete = false) {\n return resolveStylesheet(\n this.#designSystem,\n this.settings,\n this.browserSources,\n this.revision,\n modules,\n context,\n complete,\n );\n }\n\n /**\n * Adds the current composition graph to a resolved development stylesheet.\n *\n * @param plan - Resolved stylesheet plan whose revision and parts are ready for the browser.\n * @returns A snapshot containing the plan's revision and parts plus dependencies from all\n * recorded inputs.\n */\n #snapshot(plan: StylesheetPlan): CssSnapshot {\n return {\n revision: plan.revision,\n parts: plan.parts,\n dependencies: Object.fromEntries(\n [...this.#inputs.values()].map((input) => [input.moduleId, input.dependencies]),\n ),\n };\n }\n\n /**\n * Runs an operation after earlier work and always releases the queue afterward.\n *\n * The queue release is independent of the operation result, so one failed operation does not\n * block later work.\n *\n * @param operation - Asynchronous compiler or registry operation. It must not enqueue and await\n * another environment operation.\n * @returns A promise for the operation's result, preserving any rejection.\n */\n async #inTurn<T>(operation: () => Promise<T>): Promise<T> {\n const previous = this.#work;\n let release!: () => void;\n this.#work = new Promise<void>((resolve) => {\n release = resolve;\n });\n await previous;\n\n try {\n return await operation();\n } finally {\n release();\n }\n }\n}\n","import { watch } from \"node:fs\";\nimport { dirname, resolve } from \"node:path\";\n\nimport type { EncodedSourceMap } from \"@jridgewell/gen-mapping\";\nimport type { InlineConfig } from \"@stillwind/config\";\nimport { resolveIntegrationConfig } from \"@stillwind/config/node\";\nimport { cleanModuleId, type CssSourceMapInput } from \"@stillwind/host\";\nimport type { NativeCssMinifyOptions } from \"@stillwind/native\";\nimport type { Environment, InferCustomEventPayload, ResolvedConfig, ViteDevServer } from \"vite\";\n\nimport { cssForBrowser, publicCssSourceMap } from \"./browser-css.ts\";\nimport type { BrowserSourceMapInput } from \"./browser-source-map.ts\";\nimport type { BuildOutput } from \"./build.ts\";\nimport type { CompileContext, ProducerTransform } from \"./compile.ts\";\nimport { inheritCssTarget, minifyTargets } from \"./css-targets.ts\";\nimport type { CssContext } from \"./design-system.ts\";\nimport { ViteEnvironment, type CssSnapshot } from \"./environment.ts\";\nimport type { StylesheetPlan } from \"./stylesheet.ts\";\n\n/** Vite environment instance whose identity and top-level configuration own compiler state. */\nexport type EnvironmentOwner = Pick<Environment, \"name\" | \"getTopLevelConfig\">;\n\n/** File selection and compiler overrides for Vite, Astro, and Nuxt, with CSS emission placement. */\nexport interface IntegrationConfig extends InlineConfig {\n /**\n * Production CSS placement. `single` emits one document stylesheet. `split` emits ordered parts\n * selected by chunks. Defaults to `single`.\n */\n emission?: \"single\" | \"split\";\n}\n\n/** Configuration shared by all compiler environments in one Vite integration instance. */\nexport interface ProjectSettings {\n /** Whether the Vite command is `serve`. This selects development compilation and CSS delivery. */\n watching: boolean;\n /**\n * Whether the attached server has an active CSS watcher. Otherwise development detects CSS\n * changes through file fingerprints.\n */\n cssWatching: boolean;\n /** Native compilation mode: `development` for serving and `release` for production builds. */\n compilerMode: string;\n /** Absolute project root after configuration, including the optional compiler root override. */\n projectRoot: string;\n /** Active development server used for resource checks, file watching, and CSS hot messages. */\n devServerRef?: ViteDevServer;\n /**\n * Build asset directory copied from Vite, used to place CSS files and compute relative resource\n * URLs.\n */\n assetsDirectory: string;\n /** Public URL base copied from Vite, including its trailing slash or relative-base form. */\n publicBase: string;\n /** Whether production CSS should carry source maps, derived from `build.sourcemap`. */\n sourceMaps: boolean;\n /** Whether development CSS should carry source maps, derived from `css.devSourcemap`. */\n devSourceMaps: boolean;\n /**\n * Whether emitted production CSS is minified. Disabled only when Vite sets `build.cssMinify` to\n * false.\n */\n minifyCss: boolean;\n /** Browser versions for final CSS processing. Omission preserves unspecified compiler targets. */\n cssTargets?: NativeCssMinifyOptions[\"targets\"];\n}\n\n/**\n * Shared project operations that route compilation and stylesheet work to isolated Vite\n * environments.\n */\nexport interface ViteProject {\n /**\n * Obtains the project owned by a resolved Vite configuration.\n * @param config - Top-level configuration, obtained from a server or getTopLevelConfig().\n * @returns This project for its first configuration, or an isolated project for another configuration.\n */\n forConfig: (config: ResolvedConfig) => ViteProject;\n /**\n * Evaluated compiler settings shared by all environments. Empty before configure. Reconfiguration\n * replaces the fields of this same object so plugin hooks retain the current settings.\n */\n config: IntegrationConfig;\n /** Mutable settings initialized by the compiler plugin before environment startup. */\n settings: ProjectSettings;\n /**\n * Obtains isolated compilation state for a Vite environment, creating it on first use.\n *\n * @param name - Owning Vite instance, or a name selecting the current state. Omission selects `client`.\n * @returns The environment retained for this project lifetime.\n */\n environment: (name?: string | EnvironmentOwner) => ViteEnvironment;\n /**\n * Closes the state owned by an environment without closing other environments.\n * @param environment - The owning Vite instance. Development also removes its state from watch tracking.\n */\n closeEnvironment: (environment: EnvironmentOwner) => void;\n /**\n * Evaluates Stillwind settings and replaces all existing compiler environments.\n *\n * @param config - Resolved configuration for this project. Call before starting environments.\n * @returns A promise that resolves after settings and configuration watch paths are updated.\n * Previously obtained environments must not be used after successful reconfiguration.\n * @throws If configuration evaluation or closing an existing environment fails.\n */\n configure: (config: ResolvedConfig) => Promise<void>;\n /** Absolute configuration dependencies and missing discovery candidates. Callers must not mutate this set. */\n configurationFiles: Set<string>;\n /**\n * Marks build configuration dirty when a watched path can affect its evaluation.\n *\n * @param id - Changed filesystem path, resolved to an absolute path for comparison.\n * @returns Whether the path belongs to configurationFiles. Other changes have no effect.\n */\n configurationChanged: (id: string) => boolean;\n /**\n * Reevaluates settings when configurationChanged marked them dirty and configure has already run.\n *\n * @returns A promise that resolves after reconfiguration, or immediately when no refresh is needed.\n * @throws If configuration evaluation or environment cleanup fails.\n */\n refreshConfiguration: () => Promise<void>;\n /**\n * Attaches a development server and replaces any previously registered CSS watch listener.\n *\n * @param server - Active Vite server. Call after configure so watch paths are known. A null watch\n * configuration disables event tracking. Configuration changes restart the server. CSS changes\n * invalidate existing environments.\n * @throws If a directory watcher for a missing configuration candidate cannot be created.\n */\n attachServer: (server: ViteDevServer) => void;\n /** Closes type-facts services in existing environments while retaining native compiler state. */\n closeTypeFacts: () => void;\n /** Removes CSS watch listeners, closes type facts, and clears environment virtual references. */\n close: () => void;\n /**\n * Obtains recorded producer inputs for one environment.\n *\n * @param name - Environment name. Omission selects `client`.\n * @returns The live map keyed by full Vite source identity. Callers must not mutate entries.\n */\n inputs: (name?: string) => ViteEnvironment[\"inputs\"];\n /**\n * Obtains virtual references owned by one environment.\n *\n * @param name - Environment name. Omission selects `client`.\n * @returns The environment registry, created using the configured project root on first use.\n */\n moduleRegistry: (name?: string) => ViteEnvironment[\"registry\"];\n /**\n * Registers the virtual producer module that activates automatic document styles.\n *\n * @param id - Full Vite source identity of the producer.\n * @param name - Environment name. Omission selects `client`.\n * @returns A registered `virtual:stillwind/producer:` specifier.\n */\n producerSpecifier: (id: string, name?: string) => string;\n /**\n * Registers the virtual module supplying an explicit CSS value for a producer.\n *\n * @param id - Full Vite source identity of the producer.\n * @param name - Environment name. Omission selects `client`.\n * @returns A registered `virtual:stillwind/value:` specifier.\n */\n valueSpecifier: (id: string, name?: string) => string;\n /**\n * Compiles and records a producer in its environment.\n *\n * @param name - Environment name, or `undefined` for `client`.\n * @param code - Source text before Stillwind transformation.\n * @param id - Full Vite source identity, including its query suffix.\n * @param context - Resolution, watch, warning, and optional upstream-map operations.\n * @returns A promise for the transform result, or `undefined` when no code was produced.\n */\n compile: (\n name: string | undefined,\n code: string,\n id: string,\n context: CompileContext,\n ) => Promise<ProducerTransform | undefined>;\n /**\n * Plans document CSS for automatic producers in one environment.\n *\n * @param name - Environment name, or `undefined` for `client`.\n * @param context - Resolver and watch operations for referenced resources.\n * @param complete - Whether the caller has collected the complete application graph.\n * @param selection - Optional compiler module paths without queries. Omission selects all\n * automatic inputs. An empty list selects none.\n * @returns A promise for resolved document CSS and ordered stylesheet parts.\n */\n documentPlan: (\n name: string | undefined,\n context: CssContext,\n complete?: boolean,\n selection?: readonly string[],\n ) => Promise<StylesheetPlan>;\n /**\n * Obtains document parts and producer dependencies at the current environment revision.\n *\n * @param name - Environment name, or `undefined` for `client`.\n * @param context - Resolver and watch operations for stylesheet planning.\n * @returns A promise for the current development snapshot without advancing its revision.\n */\n snapshot: (name: string | undefined, context: CssContext) => Promise<CssSnapshot>;\n /**\n * Publishes a new stylesheet snapshot through the environment's hot channel.\n *\n * @param name - Environment name, or `undefined` for `client`.\n * @param context - Resolver and watch operations for stylesheet planning.\n * @returns A promise that resolves after publication. Production and unattached servers return\n * without planning or sending a snapshot.\n */\n publish: (name: string | undefined, context: CssContext) => Promise<void>;\n /**\n * Records a document stylesheet URL that the development server served for an environment.\n * Later publications that change the environment's CSS ask the browser to reload each recorded\n * stylesheet link.\n *\n * @param name - Environment whose document CSS the URL returns.\n * @param url - Request path and query under the server origin, without Vite's `t` parameter.\n */\n observeDocumentStylesheet: (name: string, url: string) => void;\n /**\n * Rewrites CSS map sources for browser delivery using the selected environment's sources.\n *\n * @param name - Environment name, or `undefined` for `client`.\n * @param map - Encoded or serialized CSS source map.\n * @returns A map with approved or opaque source names and no embedded source text.\n */\n publicSourceMap: (name: string | undefined, map: BrowserSourceMapInput) => EncodedSourceMap;\n /**\n * Replaces CSS resource placeholders and composes browser-safe upstream maps.\n *\n * @param name - Environment name, or `undefined` for `client`.\n * @param output - Compiler CSS and its native source map.\n * @param replacements - Resource placeholder tokens mapped to escaped URL text.\n * @returns Resolved CSS with an inline public source map when a map is available.\n */\n cssForBrowser: (\n name: string | undefined,\n output: CssSourceMapInput,\n replacements: ReadonlyMap<string, string>,\n ) => string;\n /**\n * Obtains stylesheet assets and metadata from the latest production emission.\n *\n * @param name - Environment name. Omission selects `client`.\n * @returns Recorded build output, or an empty object if no stylesheet has been emitted.\n */\n buildOutput: (name?: string) => BuildOutput;\n /**\n * Replaces stylesheet assets and metadata for one environment.\n *\n * @param name - Environment name, or `undefined` for `client`.\n * @param output - Emitted references and manifest produced by the build hooks.\n */\n setBuildOutput: (name: string | undefined, output: BuildOutput) => void;\n}\n\n/**\n * Creates project state shared by compiler, development, and build plugins.\n *\n * Call `configure` before environment initialization, then `attachServer` when serving. Close the\n * project when its build or server lifetime ends.\n *\n * @param supplied - Configuration discovery, compiler overrides, and production CSS emission mode.\n * Omission reads stillwind.config.* when configure runs.\n * @param applicationRoot - Called during each configuration evaluation. Its directory overrides\n * Vite's root as the base for discovery and inline paths. Undefined uses Vite's root.\n * @returns An unconfigured project whose environments are created lazily.\n */\nexport function createViteProject(\n supplied: IntegrationConfig = {},\n applicationRoot: () => string | undefined = () => undefined,\n): ViteProject {\n const settings: ProjectSettings = {\n watching: false,\n cssWatching: false,\n compilerMode: \"release\",\n projectRoot: \"\",\n assetsDirectory: \"assets\",\n publicBase: \"/\",\n sourceMaps: false,\n devSourceMaps: false,\n minifyCss: true,\n };\n const config: IntegrationConfig = {};\n const generations = new WeakMap<ResolvedConfig, ViteProject>();\n let claimed = false;\n const configurationFiles = new Set<string>();\n let resolvedViteConfig: ResolvedConfig | undefined;\n let configurationDirty = false;\n let configurationDependencies: string[] = [];\n let missingConfigurations: string[] = [];\n\n const environments = new Map<string, ViteEnvironment>();\n /** Document stylesheet URLs served in development, keyed by environment name. */\n const documentStylesheets = new Map<string, Set<string>>();\n /** CSS of the latest publication that refreshed document stylesheets, keyed by environment name. */\n const publishedDocumentCss = new Map<string, string>();\n let bindings = new WeakMap<EnvironmentOwner, ViteEnvironment>();\n /**\n * Gets or creates the compiler state owned by one Vite environment.\n * @param owner - Owning Vite instance, or a name selecting the current state. Omission selects `client`.\n * @returns The retained environment state. Newly created non-client states invalidate their\n * affected modules in the corresponding development module graph.\n */\n const environment = (owner: string | EnvironmentOwner = \"client\") => {\n const name = typeof owner === \"string\" ? owner : owner.name;\n let state = typeof owner === \"string\" ? environments.get(name) : bindings.get(owner);\n if (!state) {\n state = new ViteEnvironment(name, settings, config, (ids) => {\n if (name === \"client\") {\n return;\n }\n const graph = settings.devServerRef?.environments[name]?.moduleGraph;\n for (const id of ids) {\n for (const module of graph?.getModulesByFile(cleanModuleId(id)) ?? []) {\n graph!.invalidateModule(module);\n }\n }\n });\n environments.set(name, state);\n if (typeof owner !== \"string\") {\n bindings.set(owner, state);\n }\n }\n return state;\n };\n\n const closeEnvironment = (owner: EnvironmentOwner) => {\n const state = bindings.get(owner);\n if (!state) {\n return;\n }\n state.close();\n if (settings.watching && environments.get(owner.name) === state) {\n environments.delete(owner.name);\n }\n };\n\n /** Releases checker services in all currently retained compiler environments. */\n const closeTypeFacts = () => {\n for (const state of environments.values()) {\n state.closeTypeFacts();\n }\n };\n\n /**\n * Replaces compiler environments and applied settings after resolving project configuration.\n * @param viteConfig - Resolved Vite configuration supplying root, asset, source-map, and watch settings.\n * @returns A promise that resolves after old environments close and configuration dependencies\n * and missing paths replace the previous discovery state.\n * @throws If the emission mode is invalid, project configuration fails, or an old environment cannot close.\n */\n const configure = async (viteConfig: ResolvedConfig) => {\n const { emission, ...inline } = supplied;\n if (emission !== undefined && emission !== \"single\" && emission !== \"split\") {\n throw new Error(\"config.emission: must be single or split\");\n }\n const cssTarget = viteConfig.environments.client?.build.cssTarget ?? viteConfig.build.cssTarget;\n const resolved = await resolveIntegrationConfig(inline, applicationRoot() ?? viteConfig.root, {\n target: inheritCssTarget(cssTarget),\n });\n for (const state of environments.values()) {\n state.close();\n }\n environments.clear();\n bindings = new WeakMap();\n for (const key of Object.keys(config) as (keyof IntegrationConfig)[]) {\n delete config[key];\n }\n Object.assign(config, resolved.config, { emission });\n configurationFiles.clear();\n configurationDependencies = resolved.dependencies;\n missingConfigurations = resolved.missing;\n for (const file of [...resolved.dependencies, ...resolved.missing]) {\n configurationFiles.add(file);\n }\n resolvedViteConfig = viteConfig;\n configurationDirty = false;\n settings.projectRoot = resolve(viteConfig.root, config.root ?? \".\");\n settings.assetsDirectory = viteConfig.build.assetsDir;\n settings.publicBase = viteConfig.base;\n settings.sourceMaps = Boolean(viteConfig.build.sourcemap);\n settings.devSourceMaps = Boolean(viteConfig.css.devSourcemap);\n settings.minifyCss = viteConfig.build.cssMinify !== false;\n settings.cssTargets = settings.minifyCss ? minifyTargets(config.target) : undefined;\n settings.watching = viteConfig.command === \"serve\";\n settings.compilerMode = settings.watching ? \"development\" : \"release\";\n };\n\n /** Detaches the current server's change listeners and closes its configuration discovery watchers. */\n let stopCssWatching = () => {};\n\n /**\n * Replaces server watch registrations and retains the server for module invalidation and HMR.\n * @param server - Configured development server. A null watch setting disables these watches.\n * @throws If a missing configuration's parent directory cannot be watched.\n */\n const attachServer = (server: ViteDevServer) => {\n settings.devServerRef = server;\n stopCssWatching();\n settings.cssWatching = server.config.server.watch !== null;\n if (!settings.cssWatching) {\n return;\n }\n /**\n * Restarts on configuration changes or invalidates affected compiler environments.\n * @param event - Watch event. Only `add`, `change`, and `unlink` are handled.\n * @param file - Changed filesystem path, normalized before dependency lookup.\n */\n const changed = (event: string, file: string) => {\n if (event !== \"add\" && event !== \"change\" && event !== \"unlink\") {\n return;\n }\n const path = resolve(file);\n if (configurationFiles.has(path)) {\n void server.restart();\n return;\n }\n for (const state of environments.values()) {\n state.changed(path, event !== \"change\");\n }\n };\n /** Closes discovery watchers, detaches server listeners, and clears the CSS-watching flag. */\n const stop = () => {\n for (const watcher of discoveryWatchers) {\n watcher.close();\n }\n server.watcher.off(\"all\", changed);\n server.httpServer?.off(\"close\", stop);\n settings.cssWatching = false;\n };\n // Missing files in ancestor directories need nonrecursive watches. Adding them to Vite's\n // recursive watcher can include every sibling project above the application root.\n const discoveryWatchers = [...new Set(missingConfigurations.map(dirname))].map((directory) =>\n watch(directory, (_event, filename) => {\n if (filename && configurationFiles.has(resolve(directory, String(filename)))) {\n void server.restart();\n }\n }),\n );\n server.watcher.on(\"all\", changed);\n server.watcher.add(configurationDependencies);\n server.httpServer?.once(\"close\", stop);\n stopCssWatching = stop;\n };\n\n /** Detaches server listeners, closes discovery watchers, and closes every retained compiler environment. */\n const close = () => {\n stopCssWatching();\n documentStylesheets.clear();\n publishedDocumentCss.clear();\n for (const state of environments.values()) {\n state.close();\n }\n };\n\n /**\n * Publishes a CSS snapshot through the matching environment's HMR channel when serving.\n * @param name - Vite environment name, or undefined for `client`.\n * @param context - Resolver and watch operations used to refresh the environment's CSS.\n * @returns A promise that resolves after publication, or immediately when no active server exists.\n * @throws If refreshing the environment or generating its CSS snapshot fails.\n */\n const publish = (name: string | undefined, context: CssContext) => {\n if (!settings.watching || !settings.devServerRef) {\n return Promise.resolve();\n }\n const environmentName = name ?? \"client\";\n return environment(name).publish(context, (snapshot) => {\n const environments = settings.devServerRef?.environments;\n environments?.[environmentName]?.hot.send({\n type: \"custom\",\n event: \"stillwind:css\",\n data: snapshot satisfies InferCustomEventPayload<\"stillwind:css\">,\n });\n const urls = documentStylesheets.get(environmentName);\n if (!urls) {\n return;\n }\n const css = snapshot.parts.map((part) => part.css).join(\"\\n\");\n if (publishedDocumentCss.get(environmentName) === css) {\n return;\n }\n publishedDocumentCss.set(environmentName, css);\n // Pages whose framework never loads the Stillwind runtime, such as resumable Qwik pages,\n // receive no `stillwind:css` listener. Vite's client reloads a link whose URL contains the\n // update path. Longer URLs come first so that a link with `module` selections is claimed\n // by its own URL before a shorter URL that is a substring of it.\n const timestamp = Date.now();\n environments?.client?.hot.send({\n type: \"update\",\n updates: [...urls]\n .sort((left, right) => right.length - left.length)\n .map((path) => ({\n type: \"css-update\",\n path,\n acceptedPath: path,\n timestamp,\n })),\n });\n });\n };\n\n const project: ViteProject = {\n forConfig: (viteConfig) => {\n let generation = generations.get(viteConfig);\n if (!generation) {\n generation = claimed ? createViteProject(supplied, applicationRoot) : project;\n claimed = true;\n generations.set(viteConfig, generation);\n }\n return generation;\n },\n config,\n configurationFiles,\n configurationChanged: (id) => {\n if (!configurationFiles.has(resolve(id))) {\n return false;\n }\n configurationDirty = true;\n return true;\n },\n refreshConfiguration: async () => {\n if (configurationDirty && resolvedViteConfig) {\n await configure(resolvedViteConfig);\n }\n },\n settings,\n environment,\n closeEnvironment,\n configure,\n attachServer,\n closeTypeFacts,\n close,\n inputs: (name?: string) => environment(name).inputs,\n moduleRegistry: (name?: string) => environment(name).registry,\n producerSpecifier: (id: string, name?: string) =>\n environment(name).registry.source(\"producer\", id),\n valueSpecifier: (id: string, name?: string) => environment(name).registry.source(\"value\", id),\n compile: (name: string | undefined, code: string, id: string, context: CompileContext) =>\n environment(name).compile(code, id, context),\n documentPlan: (\n name: string | undefined,\n context: CssContext,\n complete = false,\n selection?: readonly string[],\n ) => environment(name).documentPlan(context, complete, selection),\n snapshot: (name: string | undefined, context: CssContext) =>\n environment(name).snapshot(context),\n publish,\n observeDocumentStylesheet: (name: string, url: string) => {\n let urls = documentStylesheets.get(name);\n if (!urls) {\n urls = new Set();\n documentStylesheets.set(name, urls);\n }\n urls.add(url);\n },\n publicSourceMap: (name: string | undefined, map: BrowserSourceMapInput) =>\n publicCssSourceMap(environment(name).browserSources, map),\n cssForBrowser: (\n name: string | undefined,\n output: CssSourceMapInput,\n replacements: ReadonlyMap<string, string>,\n ) => cssForBrowser(environment(name).browserSources, output, replacements),\n buildOutput: (name?: string): BuildOutput => environment(name).buildOutput ?? {},\n setBuildOutput: (name: string | undefined, output: BuildOutput) => {\n environment(name).buildOutput = output;\n },\n };\n return project;\n}\n","import { pathToFileURL } from \"node:url\";\n\nimport { cleanModuleId, fileSourceKind } from \"@stillwind/host\";\nimport { prepareSource } from \"@stillwind/host/projection\";\nimport { parseSync } from \"rolldown/utils\";\n\n/**\n * Finds literal projection imports in a source document without evaluating its code.\n * @param code - Original source, optionally in a supported component format.\n * @param id - Full source identity whose cleaned path determines the frontend and parser language.\n * @returns Distinct static and literal dynamic requests ending in ?stillwind.css, in traversal order.\n * @throws If preparation or parsing fails.\n */\nexport async function projectionImports(code: string, id: string) {\n if (!code.includes(\"stillwind.css\")) {\n return [];\n }\n\n const file = cleanModuleId(id);\n const { format, syntax } = fileSourceKind(id);\n const prepared = await prepareSource({\n resolverId: id,\n checkerFileName: file,\n projectionFileName: file,\n moduleId: id,\n document: {\n code,\n uri: pathToFileURL(file).href,\n format,\n },\n syntax,\n });\n const script = prepared.kind === \"projected\" ? prepared.projection.code : code;\n const parser = prepared.kind === \"projected\" ? prepared.projection.syntax : syntax;\n const parsed = parseSync(file, script, {\n lang: parser.language,\n sourceType: parser.moduleKind,\n });\n if (parsed.errors.length) {\n throw new Error(`${id}: ${parsed.errors.map((error) => error.message).join(\"\\n\")}`);\n }\n const imports = new Set<string>();\n /**\n * Collects literal projection requests while traversing enumerable AST fields.\n * @param node - Parser AST node or child value. Primitive values are skipped.\n */\n const visit = (node: unknown): void => {\n if (!node || typeof node !== \"object\") {\n return;\n }\n const record = node as Record<string, unknown>;\n if (record.declare === true) {\n return;\n }\n if (\n (record.type === \"ImportDeclaration\" && record.importKind !== \"type\") ||\n ((record.type === \"ExportNamedDeclaration\" || record.type === \"ExportAllDeclaration\") &&\n record.exportKind !== \"type\") ||\n record.type === \"ImportExpression\"\n ) {\n const source = record.source as\n | {\n /** Parser literal value, used only when it is a string with the projection suffix. */\n value?: unknown;\n }\n | undefined;\n if (typeof source?.value === \"string\" && source.value.endsWith(\"?stillwind.css\")) {\n imports.add(source.value);\n }\n }\n for (const value of Object.values(record)) {\n if (Array.isArray(value)) {\n value.forEach(visit);\n } else if (value && typeof value === \"object\") {\n visit(value);\n }\n }\n };\n visit(parsed.program);\n return [...imports];\n}\n","import { readFile } from \"node:fs/promises\";\nimport { relative, resolve } from \"node:path\";\n\nimport { cleanModuleId } from \"@stillwind/host\";\nimport type { Plugin } from \"vite\";\n\nimport { readableFile } from \"./file-access.ts\";\nimport type { ViteProject } from \"./project.ts\";\nimport { projectionImports } from \"./projection-imports.ts\";\nimport { resolveServerSource } from \"./server-source-resolve.ts\";\n\n/** Project settings whose configured CSS entrypoint has already produced an import warning. */\nconst warnedEntrypointImports = new WeakSet<ViteProject[\"settings\"]>();\n\n/** Selects the compiler's position and source after a framework regenerates scripts. */\nexport interface TransformOptions {\n /** Runs before other pre transforms by default, or in plugin order with `normal`. */\n order?: \"pre\" | \"normal\";\n /** Compiles the original file when an earlier framework transform regenerated its script. */\n originalSource?: boolean;\n}\n\n/**\n * Creates source transform and watch hooks for the project compiler plugin.\n *\n * Development changes publish CSS after compilation. Invalid projection imports fail through the\n * Vite hook context.\n *\n * @param project - Project configured and initialized by the compiler plugin.\n * @param virtualModules - Virtual module hooks for the same project, used to reload cached\n * generated modules.\n * @param options - Source selection and ordering required by the framework integration.\n * @returns Hooks that recompile cached producers, register stylesheet projections, reserve authored\n * CSS identifiers, and remove deleted inputs. The transform warns once per project when the\n * configured CSS entrypoint is imported as an ordinary stylesheet.\n */\nexport function transformHooks(\n project: ViteProject,\n virtualModules: Pick<Plugin, \"load\">,\n options: TransformOptions = {},\n): Pick<Plugin, \"shouldTransformCachedModule\" | \"watchChange\" | \"transform\"> {\n const { settings, publish, compile } = project;\n const cachedVirtualModules = new Map<string, Set<string>>();\n\n return {\n /**\n * Selects cached modules that need current compiler state and records virtual modules for reloading.\n * @param module - Cached module descriptor whose id includes any source query.\n * @returns Whether to rerun transformation for Stillwind virtual modules or supported application sources.\n */\n shouldTransformCachedModule({ id }) {\n if (id.startsWith(\"\\0stillwind:\")) {\n const name = this.environment?.name ?? \"client\";\n let modules = cachedVirtualModules.get(name);\n if (!modules) {\n modules = new Set();\n cachedVirtualModules.set(name, modules);\n }\n modules.add(id);\n return true;\n }\n return (\n /\\.(?:[cm]?[jt]sx?|astro|svelte|vue)$/.test(cleanModuleId(id)) &&\n !id.includes(\"node_modules\")\n );\n },\n /**\n * Invalidates changed configuration or removes deleted source state and publishes resulting CSS.\n * @param id - Watched filesystem identity.\n * @param change - Vite event. Source removal is performed only for delete events.\n * @returns Completion of removal and publication when required.\n * @throws If environment removal or CSS publication fails.\n */\n async watchChange(id, change) {\n if (project.configurationChanged(id)) {\n return;\n }\n if (change.event !== \"delete\") {\n return;\n }\n const name = this.environment?.name;\n const removed = await project.environment(name).removeFile(id);\n if (removed) {\n await publish(name, this);\n }\n },\n transform: {\n order: options.order === \"normal\" ? undefined : \"pre\",\n /**\n * Reserves authored CSS names, registers source projections, and compiles supported producers.\n * @param code - Source after earlier transforms in the configured order.\n * @param id - Full Vite identity, including queries that select distinct source.\n * @returns Compiler output, a reloaded virtual module, or undefined when no transformed source is needed.\n * @throws If a projection cannot resolve or pass access checks, or compilation or publication fails.\n */\n async handler(code, id) {\n const name = this.environment?.name;\n if (cachedVirtualModules.get(name ?? \"client\")?.delete(id)) {\n const load = virtualModules.load;\n if (typeof load === \"function\") {\n return load.call(this, id);\n }\n }\n if (isAuthoredStylesheet(id)) {\n if (\n project.config.css &&\n !warnedEntrypointImports.has(settings) &&\n relative(resolve(settings.projectRoot, project.config.css), cleanModuleId(id)) === \"\"\n ) {\n warnedEntrypointImports.add(settings);\n this.warn(\n `The Stillwind CSS entrypoint ${project.config.css} is imported as an ordinary stylesheet. ` +\n \"The integration already delivers its compiled CSS. Remove the import so that Vite \" +\n \"does not also emit the uncompiled Stillwind rules.\",\n );\n }\n await project.environment(name).reserveAuthoredCss(id, code, this);\n return;\n }\n if (\n !/\\.(?:[cm]?[jt]sx?|astro|svelte|vue)$/.test(cleanModuleId(id)) ||\n id.includes(\"node_modules\") ||\n id.startsWith(\"\\0\") ||\n /[?&](?:raw|url|type)(?:[=&]|$)/.test(id)\n ) {\n return;\n }\n if (options.originalSource) {\n id = cleanModuleId(id);\n code = await readFile(await readableFile(id, settings.devServerRef), \"utf8\");\n }\n const projections = new Map<string, string>();\n for (const specifier of await projectionImports(code, id)) {\n const source = await resolveServerSource(\n this.resolve.bind(this),\n specifier.slice(0, -\"?stillwind.css\".length),\n id,\n );\n if (!source || source.external) {\n this.error(`Cannot resolve Stillwind projection ${specifier}`);\n }\n await readableFile(source.id, settings.devServerRef);\n projections.set(specifier, source.id);\n }\n if (\n !/stillwind\\/(?:alpine|astro|lit|preact|qwik|react|solid|svelte|vanilla|vue|module-css)/.test(\n code,\n )\n ) {\n const input = project.inputs(name).get(id);\n if (input) {\n await project.environment(name).removeSource(id);\n await publish(name, this);\n }\n await project.environment(name).projections(id, projections);\n return;\n }\n await project.environment(name).projections(id, projections);\n const context = options.originalSource\n ? {\n resolve: this.resolve.bind(this),\n addWatchFile: this.addWatchFile.bind(this),\n warn: this.warn.bind(this),\n }\n : this;\n const result = await compile(name, code, id, context);\n await publish(name, this);\n return result;\n },\n },\n };\n}\n\n/**\n * Checks whether a module contains authored CSS whose identifiers must be reserved.\n *\n * @param id - Vite module identity, optionally containing a resource query.\n * @returns True for a plain `.css` file that is neither virtual nor query-qualified.\n */\nfunction isAuthoredStylesheet(id: string): boolean {\n if (!cleanModuleId(id).endsWith(\".css\")) {\n return false;\n }\n if (id.startsWith(\"virtual:\") || id.includes(\"?\")) {\n return false;\n }\n const path = cleanModuleId(id).replaceAll(\"\\\\\", \"/\");\n return !path.startsWith(\"\\0stillwind:\");\n}\n","import { readFile } from \"node:fs/promises\";\nimport { resolve } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nimport { cleanModuleId, decodeCssSourceMap } from \"@stillwind/host\";\nimport type { Plugin } from \"vite\";\n\nimport { minifyStylesheet } from \"./css-minify.ts\";\nimport { readableFile } from \"./file-access.ts\";\nimport {\n fragmentPrefix,\n producerPrefix,\n projectionPrefix,\n runtimeId,\n runtimeSpecifier,\n valuePrefix,\n virtualCssId,\n} from \"./module-ids.ts\";\nimport type { ViteProject } from \"./project.ts\";\n\n/**\n * Public specifier for the packaged development runtime, resolved through the published Vite\n * entrypoint.\n */\nconst runtimeEntry = \"virtual:stillwind/runtime-entry\";\n\n/** Public specifier for the optional runtime that renders development CSS source maps. */\nconst sourceMapEntry = \"virtual:stillwind/runtime-source-map\";\n\n/**\n * Locates a packaged runtime module beside the published Vite entrypoint.\n *\n * @param file - Runtime basename without an extension, such as `runtime` or `runtime-source-map`.\n * @returns Absolute path to the runtime JavaScript file.\n */\nfunction runtimeFile(file: string) {\n return fileURLToPath(new URL(`./${file}.js`, import.meta.resolve(\"@stillwind/integration/vite\")));\n}\n\n/**\n * Creates hooks that resolve registered Stillwind references and load their generated modules.\n *\n * Unregistered references fail through the hook context. Projections compile source for CSS without\n * importing its application JavaScript.\n *\n * @param project - Configured project whose environment registry owns the references and producer\n * inputs.\n * @returns Resolution and loading hooks for runtime, producer, projection, fragment, CSS value, and\n * stylesheet snapshot modules.\n */\nexport function virtualModuleHooks(project: ViteProject): Pick<Plugin, \"resolveId\" | \"load\"> {\n const {\n settings,\n inputs,\n cssForBrowser,\n moduleRegistry,\n producerSpecifier,\n documentPlan,\n publish,\n } = project;\n\n return {\n /**\n * Resolves runtime aliases and issued references in the current environment's registry.\n * @param id - Authored request or resolved virtual identity.\n * @param importer - Full importer identity required for registered projection edges.\n * @returns A resolved virtual identity or packaged runtime path, or undefined for unrelated requests.\n * @throws If a projection or source-backed reference is unregistered.\n */\n async resolveId(id, importer) {\n const registry = moduleRegistry(this.environment?.name);\n if (id === runtimeEntry) {\n return runtimeFile(\"runtime\");\n }\n if (id === sourceMapEntry) {\n return runtimeFile(\"runtime-source-map\");\n }\n if (id.endsWith(\"?stillwind.css\")) {\n const registered = registry.projection(id, importer);\n if (!registered) {\n this.error(\"Unregistered Stillwind projection\");\n }\n return registered.replace(\"virtual:stillwind/\", \"\\0stillwind:\");\n }\n if (id === runtimeSpecifier || id === virtualCssId || id === runtimeId) {\n return runtimeId;\n }\n if (id === \"virtual:stillwind/snapshot.css\" || id === \"\\0stillwind:snapshot.css\") {\n return \"\\0stillwind:snapshot.css\";\n }\n if (/^(?:virtual:stillwind\\/|\\0stillwind:)(?:value|fragment|producer|projection):/.test(id)) {\n if (!registry.get(id)) {\n this.error(\"Unregistered Stillwind module\");\n }\n return id.replace(\"virtual:stillwind/\", \"\\0stillwind:\");\n }\n return undefined;\n },\n /**\n * Loads generated runtime, producer, projection, fragment, and explicit CSS-value modules.\n * @param id - Resolved virtual identity issued or recognized by this environment.\n * @returns Generated JavaScript or snapshot CSS and its map, or undefined for unrelated modules.\n * @throws If a reference is invalid, source or resource access fails, or CSS planning or compilation fails.\n */\n async load(id) {\n const name = this.environment?.name;\n const registry = moduleRegistry(name);\n const entry = registry.get(id);\n if (\n [producerPrefix, projectionPrefix, fragmentPrefix, valuePrefix].some((prefix) =>\n id.startsWith(prefix),\n ) &&\n !entry\n ) {\n this.error(\"Unregistered Stillwind module\");\n }\n if (id === \"\\0stillwind:snapshot.css\") {\n const plan = await documentPlan(name, this);\n return decodeCssSourceMap(\n cssForBrowser(\n name,\n {\n css: plan.originalCss,\n sourceMap: plan.sourceMap,\n banners: plan.banners,\n },\n plan.resourceReplacements,\n ),\n );\n }\n if (id.startsWith(producerPrefix)) {\n if (!settings.watching) {\n return \"// Stillwind producer (vite)\\nexport {};\\n\";\n }\n if (entry?.kind !== \"producer\") {\n this.error(\"Invalid Stillwind producer\");\n }\n const producer = entry.moduleId;\n return `// Stillwind producer (vite)\nimport { register, synchronize, unregister } from ${JSON.stringify(runtimeSpecifier)};\n\nawait synchronize(${project.environment(name).revision});\nregister(${JSON.stringify(producer)});\nif (import.meta.hot) {\n import.meta.hot.prune(() => {\n unregister(${JSON.stringify(producer)});\n });\n}\n`;\n }\n if (id.startsWith(projectionPrefix)) {\n if (entry?.kind !== \"projection\") {\n this.error(\"Invalid Stillwind projection\");\n }\n const source = entry.sourceId;\n const file = await readableFile(source, settings.devServerRef);\n // Vite's addWatchFile also creates a JavaScript dependency during import analysis.\n const context = settings.watching\n ? {\n resolve: this.resolve.bind(this),\n warn: this.warn.bind(this),\n addWatchFile: (id: string) => {\n settings.devServerRef?.watcher.add(cleanModuleId(id));\n },\n }\n : this;\n context.addWatchFile(source);\n const result = await project\n .environment(name)\n .compileProjection(await readFile(file, \"utf8\"), source, context);\n await publish(name, context);\n return {\n code: `// Stillwind projection (vite)\\nimport ${JSON.stringify(producerSpecifier(source, name))};\\n`,\n meta: {\n stillwind: {\n ...result?.meta.stillwind,\n projection: true,\n },\n },\n };\n }\n if (id === runtimeId) {\n if (!settings.watching) {\n return \"// Stillwind runtime (vite)\\nexport {};\\n\";\n }\n const snapshot = await project.snapshot(name, this);\n const endpoint = `${settings.publicBase}__stillwind/css?environment=${encodeURIComponent(name ?? \"client\")}`;\n return `// Stillwind runtime (vite)\nimport { createDevelopmentRuntime } from ${JSON.stringify(runtimeEntry)};\n${settings.devSourceMaps ? `import { renderCssWithSourceMap } from ${JSON.stringify(sourceMapEntry)};` : \"\"}\n\nconst runtime = createDevelopmentRuntime({\n snapshot: ${JSON.stringify(snapshot)},\n endpoint: ${JSON.stringify(endpoint)},\n ${settings.devSourceMaps ? \"renderCss: renderCssWithSourceMap,\" : \"\"}\n});\n\nexport const register = runtime.register;\nexport const unregister = runtime.unregister;\nexport const synchronize = runtime.synchronize;\n\nif (import.meta.hot) {\n import.meta.hot.on(\"stillwind:css\", runtime.apply);\n import.meta.hot.accept();\n import.meta.hot.dispose(() => {\n import.meta.hot.off(\"stillwind:css\", runtime.apply);\n });\n}\n`;\n }\n if (id.startsWith(fragmentPrefix)) {\n if (entry?.kind !== \"fragment\") {\n this.error(\"Invalid Stillwind fragment\");\n }\n let css = entry.css;\n if (!settings.watching && settings.minifyCss) {\n css = minifyStylesheet(css, settings, this).css;\n }\n const resources = [...entry.resources];\n for (const [, resource] of resources) {\n await readableFile(resource.id, settings.devServerRef);\n }\n const imports = resources.map(\n ([, resource], index) =>\n `import asset${index} from ${JSON.stringify(resource.id + (resource.id.includes(\"?\") ? \"&url\" : \"?url\"))};\\n`,\n );\n if (settings.watching && settings.devSourceMaps) {\n return [\n \"// Stillwind CSS fragment (vite)\\n\",\n ...imports,\n `import { replaceCssResources } from ${JSON.stringify(sourceMapEntry)};\\n`,\n `export const css = replaceCssResources(${JSON.stringify(css)}, [${resources.map(([placeholder], index) => `[${JSON.stringify(placeholder)}, JSON.stringify(asset${index}).slice(1, -1)]`).join(\",\")}]);\\n`,\n ].join(\"\");\n }\n const replacements = resources\n .map(\n ([placeholder], index) =>\n `.replaceAll(${JSON.stringify(placeholder)}, JSON.stringify(asset${index}).slice(1, -1))`,\n )\n .join(\"\");\n return [\n \"// Stillwind CSS fragment (vite)\\n\",\n ...imports,\n \"\\n\",\n `export const css = ${JSON.stringify(css)}${replacements};\\n`,\n ].join(\"\");\n }\n if (id.startsWith(valuePrefix)) {\n if (entry?.kind !== \"value\") {\n this.error(\"Invalid Stillwind value\");\n }\n const sourceId = entry.sourceId;\n const input = inputs(name).get(sourceId);\n if (!input) {\n this.error(`No Stillwind producer for ${sourceId}`);\n }\n const watchSource = settings.watching\n ? (file: string) => settings.devServerRef?.watcher.add(cleanModuleId(file))\n : this.addWatchFile.bind(this);\n watchSource(sourceId);\n const plan = await project\n .environment(name)\n .modulePlan([input.moduleId], this, !settings.watching);\n for (const producer of plan.producers) {\n watchSource(resolve(settings.projectRoot, cleanModuleId(producer.module)));\n }\n for (const file of project.environment(name).designSystem.cssFiles) {\n this.addWatchFile(file);\n }\n const imports = plan.rawParts.map(\n (part, index) =>\n `import { css as p${index} } from ${JSON.stringify(\n registry.fragment(\n settings.watching && settings.devSourceMaps\n ? // `cssText` adds the notices once when it combines the fragments.\n cssForBrowser(\n name,\n {\n ...part,\n banners: [],\n },\n new Map(),\n )\n : part.css,\n plan.resources,\n ),\n )};\\n`,\n );\n return [\n \"// Stillwind CSS value (vite)\\n\",\n 'import { cssText } from \"stillwind/css\";\\n',\n ...imports,\n \"\\n\",\n \"export const parts = [\",\n ...plan.parts.map(\n (part, index) =>\n ` { key: ${JSON.stringify(part.key)}, banners: ${JSON.stringify(part.banners)}, css: p${index} },\\n`,\n ),\n \"];\\n\",\n \"export const css = cssText(parts);\\n\",\n \"export default css;\\n\",\n ].join(\"\");\n }\n return undefined;\n },\n };\n}\n","import { cleanModuleId, composeFrameworkSourceMap } from \"@stillwind/host\";\nimport type { Plugin } from \"vite\";\n\nimport type { EnvironmentOwner, ViteProject } from \"./project.ts\";\n\n/**\n * Callable form of a Vite load hook, used to wrap either hook representation without changing its\n * options.\n */\ntype Load = Extract<NonNullable<Plugin[\"load\"]>, Function>;\n\n/**\n * Callable form of a Vite transform hook, used to wrap either hook representation without changing\n * its options.\n */\ntype Transform = Extract<NonNullable<Plugin[\"transform\"]>, Function>;\n\n/**\n * Original Vue hooks saved before wrapping. Reusing them prevents repeated configuration from\n * composing a wrapper with itself.\n */\nconst hooks = new WeakMap<Plugin, Pick<Plugin, \"load\" | \"transform\">>();\n\n/**\n * Wraps Vue hooks to compose source maps and reload components with explicit CSS values.\n *\n * Only Vue query results with a source map and a recorded Stillwind map are composed. Repeated\n * calls reuse the saved original hooks. Explicit CSS values require component reloads during\n * template edits so Vue replaces the component's styles.\n *\n * @param plugins - Resolved plugin instances. Hooks on plugins named `vite:vue` are replaced in\n * place.\n * @param project - Project containing Stillwind transforms for the corresponding environment and\n * original Vue file.\n */\nexport function attachVueHooks(plugins: readonly Plugin[], project: ViteProject): void {\n /**\n * Composes a Vue block's map through the recorded Stillwind transform for its source file.\n * @param result - Original load or transform result, left unchanged when a required map is absent.\n * @param id - Full Vue block identity, including its `vue` query.\n * @param environment - Vite environment whose top-level configuration owns the recorded input.\n * @returns The original result or a copy containing a serialized composed map.\n * @throws If the input map cannot be parsed or the maps cannot be composed.\n */\n const compose = <T extends Awaited<ReturnType<Load>> | Awaited<ReturnType<Transform>>>(\n result: T,\n id: string,\n environment?: EnvironmentOwner,\n ) => {\n if (!result || typeof result !== \"object\" || !/[?&]vue(?:[=&]|$)/.test(id) || !result.map) {\n return result;\n }\n const generation = environment ? project.forConfig(environment.getTopLevelConfig()) : project;\n const input = generation.inputs(environment?.name).get(cleanModuleId(id));\n if (!input?.sourceMap) {\n return result;\n }\n const map = typeof result.map === \"string\" ? JSON.parse(result.map) : result.map;\n if (!map.sources?.length) {\n return result;\n }\n return {\n ...result,\n map: JSON.stringify(\n composeFrameworkSourceMap(map, JSON.stringify(input.sourceMap), input.javascript),\n ),\n };\n };\n\n for (const plugin of plugins) {\n if (plugin.name !== \"vite:vue\") {\n continue;\n }\n const original = hooks.get(plugin) ?? {\n load: plugin.load,\n transform: plugin.transform,\n };\n hooks.set(plugin, original);\n if (original.load) {\n const hook = original.load;\n const handler = typeof hook === \"function\" ? hook : hook.handler;\n /**\n * Runs the saved Vue load hook with its original receiver, then composes its map.\n * @param id - Resolver identity passed by Vite.\n * @param args - Remaining load-hook arguments forwarded unchanged.\n * @returns The delegated result with its map composed when the recorded input permits it.\n * @throws If the original hook or map composition fails.\n */\n const wrapped: Load = async function (id, ...args) {\n return compose(await handler.call(this, id, ...args), id, this.environment);\n };\n plugin.load =\n typeof hook === \"function\"\n ? wrapped\n : {\n ...hook,\n handler: wrapped,\n };\n }\n if (original.transform) {\n const hook = original.transform;\n const handler = typeof hook === \"function\" ? hook : hook.handler;\n /**\n * Composes Vue's map and reloads components with explicit CSS values on template edits.\n * @param code - Vue block source passed by Vite.\n * @param id - Resolver identity passed by Vite.\n * @param args - Remaining transform-hook arguments forwarded unchanged.\n * @returns Vue's result with a composed map and reloads for components with explicit CSS values.\n * @throws If the original hook or map composition fails.\n */\n const wrapped: Transform = async function (code, id, ...args) {\n const result = compose(await handler.call(this, code, id, ...args), id, this.environment);\n const file = cleanModuleId(id);\n if (id !== file || !file.endsWith(\".vue\") || !result) {\n return result;\n }\n const generation = this.environment\n ? project.forConfig(this.environment.getTopLevelConfig())\n : project;\n if (!generation.inputs(this.environment?.name).get(file)?.hasModuleCssImport) {\n return result;\n }\n const javascript = (typeof result === \"string\" ? result : result.code)?.toString();\n if (!javascript) {\n return result;\n }\n const marker = \"export const _rerender_only =\";\n const declaration = javascript.indexOf(marker);\n if (declaration < 0) {\n return result;\n }\n // Keep the declaration width so Vue's source map remains valid.\n const start = declaration + \"export \".length;\n const updated =\n javascript.slice(0, start) +\n \"let \" +\n javascript.slice(start + \"const\".length) +\n \"\\n_rerender_only = false;\\n\";\n return typeof result === \"string\"\n ? { code: updated, map: null }\n : { ...result, code: updated };\n };\n plugin.transform =\n typeof hook === \"function\"\n ? wrapped\n : {\n ...hook,\n handler: wrapped,\n };\n }\n }\n}\n","import type { Plugin } from \"vite\";\n\nimport { buildHooks } from \"./build.ts\";\nimport { developmentHooks } from \"./development.ts\";\nimport {\n createViteProject,\n type EnvironmentOwner,\n type IntegrationConfig,\n type ViteProject,\n} from \"./project.ts\";\nimport { transformHooks, type TransformOptions } from \"./transform.ts\";\nimport { virtualModuleHooks } from \"./virtual-modules.ts\";\nimport { attachVueHooks } from \"./vue.ts\";\n\nexport type { IntegrationConfig } from \"./project.ts\";\n\n/**\n * Creates Vite plugins that share compiler state across development and production.\n *\n * @param config - File discovery, project selection, compiler overrides, and CSS emission mode.\n * @returns Plugins for compilation, development CSS delivery, and production emission. Use the\n * array as `plugins: [stillwind()]` to use the project's configuration file.\n */\nexport function stillwind(config: IntegrationConfig = {}): Plugin[] {\n return createVitePlugins(createViteProject(config));\n}\n\n/**\n * Creates the compiler, development, and build plugins around an existing project.\n *\n * @param project - Project shared by all returned plugins. Its settings are initialized by the\n * compiler plugin.\n * @param transform - Ordering and source selection required by a framework's transforms.\n * @returns Plugins in compiler, development, and build order. Development and build plugins apply\n * only to their matching Vite command.\n */\nexport function createVitePlugins(\n project: ViteProject,\n transform: TransformOptions = {},\n): Plugin[] {\n const servers = new Map<ViteProject, Set<EnvironmentOwner>>();\n return [\n {\n name: \"stillwind:compiler\",\n enforce: \"pre\",\n /**\n * Initializes the project owned by this configuration and composes Vue source maps.\n * @param config - Resolved Vite configuration whose plugin chain includes Stillwind.\n * @returns Completion of project configuration.\n * @throws If configuration discovery or evaluation fails.\n */\n async configResolved(config) {\n await project.forConfig(config).configure(config);\n attachVueHooks(config.plugins, project);\n },\n /**\n * Defers watch registration until the server's plugin setup succeeds.\n * @param server - Server whose configuration owns the project.\n * @returns A post hook that attaches watches and records the server's environments.\n */\n configureServer(server) {\n const generation = project.forConfig(server.config);\n return () => {\n generation.attachServer(server);\n servers.set(generation, new Set(Object.values(server.environments)));\n server.httpServer?.once(\"close\", generation.closeTypeFacts);\n };\n },\n /**\n * Creates compiler hooks while Vite resolves plugins for an environment.\n * @param environment - Descriptor supplied during plugin resolution. Runtime hooks receive\n * their owning instance as this.environment.\n * @returns Hooks that initialize and close the compiler state owned by this.environment.\n */\n applyToEnvironment(environment) {\n const generation = project.forConfig(environment.getTopLevelConfig());\n return compilerPlugin(generation, transform, (owner) => {\n servers.get(generation)?.delete(owner);\n });\n },\n /** Releases projects after all environments owned by their server have closed. */\n closeServer() {\n for (const [generation, remaining] of servers) {\n if (remaining.size === 0) {\n generation.close();\n servers.delete(generation);\n }\n }\n },\n },\n {\n name: \"stillwind:development\",\n enforce: \"pre\",\n apply: \"serve\",\n configureServer(server) {\n const hook = developmentHooks(project.forConfig(server.config)).configureServer;\n if (typeof hook === \"function\") {\n return hook.call(this, server);\n }\n },\n applyToEnvironment(environment) {\n const { hotUpdate } = developmentHooks(project.forConfig(environment.getTopLevelConfig()));\n return {\n name: \"stillwind:development\",\n hotUpdate:\n transform.originalSource && typeof hotUpdate === \"function\"\n ? {\n order: \"pre\",\n handler: hotUpdate,\n }\n : hotUpdate,\n };\n },\n },\n {\n name: \"stillwind:build\",\n enforce: \"pre\",\n apply: \"build\",\n applyToEnvironment(environment) {\n return {\n name: \"stillwind:build\",\n ...buildHooks(project.forConfig(environment.getTopLevelConfig())),\n };\n },\n },\n ];\n}\n\n/**\n * Creates the plugin that owns project configuration, source compilation, and compiler lifetime.\n *\n * @param project - Project whose environments are initialized at build start and closed at bundle\n * close.\n * @param closed - Records which Vite instance has released its state.\n * @returns A plugin with `enforce: \"pre\"` that installs virtual modules and source transforms.\n */\nfunction compilerPlugin(\n project: ViteProject,\n transform: TransformOptions,\n closed: (environment: EnvironmentOwner) => void,\n): Plugin {\n const virtualModules = virtualModuleHooks(project);\n\n return {\n name: \"stillwind:compiler\",\n enforce: \"pre\",\n perEnvironmentStartEndDuringDev: true,\n perEnvironmentWatchChangeDuringDev: true,\n /**\n * Delegates generated-reference resolution using the current environment's hook context.\n * @param id - Requested module identity.\n * @param importer - Importing resolver identity, when available.\n * @param options - Vite resolution options forwarded unchanged.\n * @returns The virtual resolver's result, or undefined if it has no callable hook.\n */\n resolveId(id, importer, options) {\n if (typeof virtualModules.resolveId === \"function\") {\n return virtualModules.resolveId.call(this, id, importer, options);\n }\n },\n /**\n * Delegates generated-module loading through the current environment's registry.\n * @param id - Resolved module identity.\n * @param options - Vite load options forwarded unchanged.\n * @returns The virtual loader's result, or undefined when no callable hook is available.\n */\n load(id, options) {\n if (typeof virtualModules.load === \"function\") {\n return virtualModules.load.call(this, id, options);\n }\n },\n ...transformHooks(project, virtualModules, transform),\n /**\n * Refreshes configuration, registers its watches, and starts the current compiler environment.\n * @returns Completion of configuration refresh and environment initialization.\n * @throws If refresh or environment startup fails.\n */\n async buildStart() {\n await project.refreshConfiguration();\n for (const file of project.configurationFiles) {\n this.addWatchFile(file);\n }\n await project.environment(this.environment).start(this);\n },\n /** Releases this environment's state when its plugin container closes. */\n closeBundle() {\n project.closeEnvironment(this.environment);\n closed(this.environment);\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAGA,MAAa,eAAe;;AAE5B,MAAa,YAAY;;AAUzB,MAAa,mBAAmB;;;;;;;AAQhC,SAAgB,eAAe,MAAc,IAAoB;CAC/D,MAAM,OAAO,cAAc,EAAE;CAC7B,OAAO,iBAAiB,MAAM,IAAI,IAAI,GAAG,MAAM,KAAK,MAAM;AAC5D;;;;;;;;;;;;ACTA,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8B3B,SAAgB,kBACd,SACA,MACA,SACA,MACA,OACA,uBAAuB,OACvB;CACA,MAAM,EAAE,QAAQ,UAAU,QAAQ,mBAAmB;CACrD,MAAM,EAAE,UAAU,aAAa,QAAQ,YAAY,IAAI;;;;;CAMvD,MAAM,aAAa,SAAiB;EAClC,MAAM,iBAAiB;GACrB,6BAAa,IAAI,IAAI;GACrB,gCAAgB,IAAI,IAAI;GACxB,2BAAW,IAAI,IAAI;EACrB;EACA,MAAM,aAAa,YAAY,IAAI,IAAI;CACzC;CAEA,IAAI,OAAO,aAAa,WAAW,UAAU;EAC3C,MAAM,QAAQ,IAAI,IAAI,OAAO,KAAK,MAAM,OAAO,CAAC;EAChD,IAAI,MAAM,gBACR,MAAM,IAAI,MAAM,cAAc;EAEhC,KAAK,MAAM,MAAM,OACf,KAAK,MAAM,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,UAAU,YAAY,kBAAkB,CAAC,CAAC;IACzF,OAAO;KACL,MAAM;KACN,WACE,UAAU,kBAAkB,OAAO,cAAc,aAC7C;MACE,OAAO;MACP,SAAS;KACX,IACA;IACR;GACF;EACF;EACA;GACE,MAAM;GACN,SAAS;GACT,OAAO;GACP,mBAAmB,aAAa;IAC9B,OAAO;KACL,MAAM;KACN,GAAG,WAAW,QAAQ,UAAU,YAAY,kBAAkB,CAAC,CAAC;IAClE;GACF;EACF;CACF;AACF;;;;;;;;;AAUA,SAAS,eACP,SACA,WACA,QACQ;CACR,MAAM,iBAAiB,mBAAmB,OAAO;CAEjD,OAAO;EACL,MAAM;EACN,SAAS;EACT,iCAAiC;EACjC,oCAAoC;;;;;;;;EAQpC,UAAU,IAAI,UAAU,SAAS;GAC/B,IAAI,OAAO,eAAe,cAAc,YACtC,OAAO,eAAe,UAAU,KAAK,MAAM,IAAI,UAAU,OAAO;EAEpE;;;;;;;EAOA,KAAK,IAAI,SAAS;GAChB,IAAI,OAAO,eAAe,SAAS,YACjC,OAAO,eAAe,KAAK,KAAK,MAAM,IAAI,OAAO;EAErD;EACA,GAAG,eAAe,SAAS,gBAAgB,SAAS;;;;;;EAMpD,MAAM,aAAa;GACjB,MAAM,QAAQ,qBAAqB;GACnC,KAAK,MAAM,QAAQ,QAAQ,oBACzB,KAAK,aAAa,IAAI;GAExB,MAAM,QAAQ,YAAY,KAAK,WAAW,CAAC,CAAC,MAAM,IAAI;EACxD;;EAEA,cAAc;GACZ,QAAQ,iBAAiB,KAAK,WAAW;GACzC,OAAO,KAAK,WAAW;EACzB;CACF;AACF"}
@@ -1 +1 @@
1
- export { n as stillwind } from "../plugin-DOKl8qk3.js";
1
+ export { n as stillwind } from "../plugin-ByYcpBcE.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stillwind/integration",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "description": "Stillwind plugins for Vite, Astro, Next.js, Nuxt, SvelteKit, Fresh, webpack, Rspack, Rsbuild, and Turbopack",
5
5
  "keywords": [
6
6
  "astro",
@@ -100,9 +100,9 @@
100
100
  "@jridgewell/gen-mapping": "^0.3.13",
101
101
  "@jridgewell/remapping": "^2.3.5",
102
102
  "@jridgewell/trace-mapping": "^0.3.31",
103
- "@stillwind/config": "0.7.0",
104
- "@stillwind/host": "0.7.0",
105
- "@stillwind/native": "0.7.0",
103
+ "@stillwind/config": "0.8.0",
104
+ "@stillwind/host": "0.8.0",
105
+ "@stillwind/native": "0.8.0",
106
106
  "rolldown": "^1.2.16"
107
107
  },
108
108
  "devDependencies": {
@@ -119,7 +119,7 @@
119
119
  "css-loader": "^7.1.5",
120
120
  "next": "^16.4.3",
121
121
  "nuxt": "^4.6.3",
122
- "stillwind": "0.7.0",
122
+ "stillwind": "0.8.0",
123
123
  "svelte": "^5.57.3",
124
124
  "svelte-loader": "^3.2.4",
125
125
  "swc-loader": "^0.2.7",
@@ -136,7 +136,7 @@
136
136
  "@sveltejs/kit": "^2.0.0 || ^3.0.0",
137
137
  "astro": "^6.0.0 || ^7.0.0",
138
138
  "nuxt": "^4.0.0",
139
- "stillwind": "0.7.0",
139
+ "stillwind": "0.8.0",
140
140
  "vite": "^7.0.0 || ^8.0.0"
141
141
  },
142
142
  "peerDependenciesMeta": {