@stillwind/integration 0.12.0 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,31 @@
1
1
  # @stillwind/integration
2
2
 
3
+ ## 0.14.0
4
+
5
+ ### Patch Changes
6
+
7
+ - `StillwindPlugin` from `@stillwind/integration/rspack` now works with Rspack 2.3.4 and later. These Rspack versions failed the build with a `compilation.rebuildModule()` error when the plugin wrote document CSS.
8
+
9
+ - Updated dependencies:
10
+ - @stillwind/config@0.14.0
11
+ - @stillwind/host@0.14.0
12
+ - @stillwind/native@0.14.0
13
+ - stillwind@0.14.0
14
+
15
+ ## 0.13.0
16
+
17
+ ### Patch Changes
18
+
19
+ - The Vite integration no longer stops a build when an import that Stillwind reads for type facts does not resolve. For example, a Svelte component with `import type { HTMLAttributes } from "svelte/elements"` now builds without an alias, although `svelte/elements` exports that path only under the `types` condition.
20
+
21
+ - Vite development servers now load fonts, images, and other files that the stylesheet references from a directory whose name contains `@`, `+`, or `:`, such as a scoped package like `@fontsource-variable/geist`. Before this fix, the development CSS referred to these files by URLs that Vite did not serve, so the page received an HTML response instead of the file. Production builds were not affected.
22
+
23
+ - Updated dependencies:
24
+ - @stillwind/config@0.13.0
25
+ - @stillwind/host@0.13.0
26
+ - @stillwind/native@0.13.0
27
+ - stillwind@0.13.0
28
+
3
29
  ## 0.12.0
4
30
 
5
31
  ### Patch Changes
@@ -28,7 +28,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
28
  SOFTWARE.
29
29
 
30
30
  ================================================================================
31
- @jridgewell/resolve-uri 3.1.2 (MIT) https://github.com/jridgewell/resolve-uri
31
+ @jridgewell/resolve-uri 3.1.3 (MIT) https://github.com/jridgewell/resolve-uri
32
32
  ================================================================================
33
33
 
34
34
  Copyright 2019 Justin Ridgewell <jridgewell@google.com>
@@ -1,4 +1,4 @@
1
- import { i as renderChunkStyles, r as createViteProject, t as createVitePlugins } from "../plugin-DiebeZNj.js";
1
+ import { i as renderChunkStyles, r as createViteProject, t as createVitePlugins } from "../plugin-CXT0YnEQ.js";
2
2
  import { registerDevelopmentCss } from "./development.js";
3
3
  import { randomUUID } from "node:crypto";
4
4
  import { fileURLToPath } from "node:url";
@@ -585,22 +585,21 @@ function recordProducer(context, input) {
585
585
  context._module.buildInfo.stillwind = input;
586
586
  }
587
587
  /**
588
- * Registers CSS reconstruction after all modules in the compilation have finished.
588
+ * Registers CSS reconstruction for a compilation, which `reconstructDocumentCss` later runs.
589
589
  *
590
- * Registration is idempotent for a compilation. The hook collects cached and newly built producers,
591
- * stores document CSS, and rebuilds each carrier through the host CSS pipeline.
590
+ * Registration is idempotent for a compilation. Reconstruction collects cached and newly built
591
+ * producers, stores document CSS, and rebuilds each carrier through the host CSS pipeline.
592
592
  *
593
593
  * @param context - Context with a compilation, filesystem, and resolver. Register it before
594
594
  * producer loaders run.
595
- * @throws If the context has no compilation with a `finishModules` hook.
595
+ * @throws If the context has no compilation with a module graph.
596
596
  */
597
597
  function installEmission(context) {
598
598
  const compilation = requireCompilation(context);
599
- if (installed.has(compilation)) return;
600
- installed.add(compilation);
599
+ if (reconstructions.has(compilation)) return;
601
600
  const io = createCompilationHost(context);
602
- compilation.hooks.finishModules.tapPromise("StillwindEmission", async (modules) => {
603
- const completed = [...modules];
601
+ reconstructions.set(compilation, async () => {
602
+ const completed = [...compilation.modules];
604
603
  const producers = completed.map((module) => module.buildInfo?.stillwind).filter((input) => Boolean(input));
605
604
  const carriers = completed.filter((module) => module.resource?.includes("stillwind-webpack.css?stillwind-document"));
606
605
  if (!carriers.length || !producers.length) return;
@@ -625,21 +624,35 @@ function installEmission(context) {
625
624
  });
626
625
  }
627
626
  /**
628
- * Compilations whose emission hooks have been registered. Membership is required before automatic
627
+ * Rebuilds the document CSS carriers of a compilation registered by `installEmission`.
628
+ *
629
+ * Call it from the compiler's `finishMake` hook. Rspack rejects `rebuildModule()` in
630
+ * `finishModules` and later hooks.
631
+ *
632
+ * @param compilation - Compilation whose module graph is complete. Unregistered compilations,
633
+ * such as child compilations, are ignored.
634
+ * @returns Completion after every carrier has been rebuilt.
635
+ * @throws If configuration, CSS reconstruction, or a carrier rebuild fails.
636
+ */
637
+ async function reconstructDocumentCss(compilation) {
638
+ await reconstructions.get(compilation)?.();
639
+ }
640
+ /**
641
+ * Reconstruction operations of registered compilations. Membership is required before automatic
629
642
  * loaders record producers.
630
643
  */
631
- const installed = /* @__PURE__ */ new WeakSet();
644
+ const reconstructions = /* @__PURE__ */ new WeakMap();
632
645
  const incompleteGraphMessage = "Automatic Stillwind CSS requires new StillwindPlugin(config) before compilation begins";
633
646
  /**
634
647
  * Obtains the compilation operations needed to reconstruct document CSS.
635
648
  *
636
- * @param context - Bundler context that must expose a `finishModules` compilation hook.
649
+ * @param context - Bundler context that must expose a compilation module graph.
637
650
  * @returns The compilation attached to the context.
638
651
  * @throws If the context cannot supply a completed compilation graph.
639
652
  */
640
653
  function requireCompilation(context) {
641
654
  const compilation = context._compilation;
642
- if (!compilation?.hooks?.finishModules) throw new Error(incompleteGraphMessage);
655
+ if (!compilation?.modules) throw new Error(incompleteGraphMessage);
643
656
  return compilation;
644
657
  }
645
658
  /**
@@ -651,13 +664,13 @@ function requireCompilation(context) {
651
664
  */
652
665
  function requireEmission(context) {
653
666
  let compilation = requireCompilation(context);
654
- while (!installed.has(compilation)) {
667
+ while (!reconstructions.has(compilation)) {
655
668
  const parent = compilation.compiler?.parentCompilation;
656
669
  if (!parent) throw new Error(incompleteGraphMessage);
657
670
  compilation = parent;
658
671
  }
659
672
  return compilation;
660
673
  }
661
- export { createLoaderHost as a, classifyRequest as c, virtualRequest as d, stillwindRules as f, useProject as i, relativeRequest as l, recordProducer as n, watchCompilerFiles as o, requireEmission as r, sourceDescriptor as s, installEmission as t, requestOptions as u };
674
+ export { useProject as a, sourceDescriptor as c, requestOptions as d, virtualRequest as f, requireEmission as i, classifyRequest as l, reconstructDocumentCss as n, createLoaderHost as o, stillwindRules as p, recordProducer as r, watchCompilerFiles as s, installEmission as t, relativeRequest as u };
662
675
 
663
- //# sourceMappingURL=emission-BpaN4Z4m.js.map
676
+ //# sourceMappingURL=emission-Q6WeluCM.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"emission-BpaN4Z4m.js","names":[],"sources":["../src/webpack/rules.ts","../src/webpack/requests.ts","../src/webpack/sources.ts","../src/webpack/compilation-styles.ts","../src/webpack/host.ts","../src/webpack/project.ts","../src/webpack/emission.ts"],"sourcesContent":["import { createHash } from \"node:crypto\";\nimport { fileURLToPath } from \"node:url\";\n\nimport type { InlineConfig } from \"@stillwind/config\";\n\n/**\n * Derives the webpack rule identifier used by inline SFC loader requests.\n *\n * @param config - The same configuration values registered on the loader rule. JSON serialization\n * omits callbacks, so namingRevision must distinguish changed naming implementations.\n * @returns A stillwind-prefixed SHA-256 hash of the serialized configuration.\n * @throws If the configuration cannot be serialized as JSON.\n */\nexport function loaderOptionsId(config: InlineConfig): string {\n return \"stillwind-\" + createHash(\"sha256\").update(JSON.stringify(config)).digest(\"hex\");\n}\n\n/** webpack-compatible producer and source-map rules, also consumed by Rspack. */\nexport interface StillwindRule {\n /** Matches resource paths, including synthetic component script suffixes where required. */\n test: RegExp;\n /** Optional exclusion applied before the loader chain, normally for node_modules. */\n exclude?: RegExp;\n /** Placement relative to ordinary loaders. Omission uses the normal loader phase. */\n enforce?: \"pre\" | \"post\";\n /** Loader entries in webpack rule order, executed according to the bundler's loader phases. */\n use: (\n | string\n | {\n /** Absolute installed loader path. */\n loader: string;\n /** Discovery and inline settings retained by the rule and evaluated by its producer loader. */\n options: InlineConfig;\n /** Registered rule identity referenced by requests that retain naming callbacks. */\n ident: string;\n }\n )[];\n}\n\n/**\n * Builds producer, document CSS, and SFC source-map loader rules without evaluating configuration.\n *\n * @param config - Discovery and inline settings shared by producer rules. The object is retained.\n * @returns Rules using absolute paths in the installed integration package. The host provides its\n * CSS pipeline and registers StillwindPlugin when automatic document CSS is required.\n * @throws If loader resolution or configuration serialization fails.\n */\nexport function stillwindRules(config: InlineConfig): StillwindRule[] {\n return [\n {\n test: /\\.[cm]?[jt]sx?$/,\n exclude: /node_modules/,\n enforce: \"pre\",\n use: [\n {\n loader: fileURLToPath(\n new URL(\"./loader.js\", import.meta.resolve(\"@stillwind/integration/webpack\")),\n ),\n options: config,\n ident: loaderOptionsId(config),\n },\n ],\n },\n {\n test: /\\.(?:astro|svelte|vue)$/,\n exclude: /node_modules/,\n enforce: \"pre\",\n use: [\n {\n loader: fileURLToPath(\n new URL(\"./loader.js\", import.meta.resolve(\"@stillwind/integration/webpack\")),\n ),\n options: config,\n ident: loaderOptionsId(config),\n },\n ],\n },\n {\n test: /stillwind-webpack\\.css$/,\n enforce: \"post\",\n use: [\n fileURLToPath(\n new URL(\"./document-loader.js\", import.meta.resolve(\"@stillwind/integration/webpack\")),\n ),\n ],\n },\n {\n test: /stillwind-webpack\\.css$/,\n enforce: \"pre\",\n use: [\n fileURLToPath(\n new URL(\"./css-loader.js\", import.meta.resolve(\"@stillwind/integration/webpack\")),\n ),\n ],\n },\n {\n // Vue inline match resources select script rules with a synthetic .vue.ts suffix.\n test: /\\.(?:astro|svelte|vue)(?:\\.[cm]?[jt]sx?)?$/,\n exclude: /node_modules/,\n enforce: \"post\",\n use: [\n fileURLToPath(\n new URL(\"./source-map-loader.js\", import.meta.resolve(\"@stillwind/integration/webpack\")),\n ),\n ],\n },\n ];\n}\n","import path from \"node:path\";\n\nimport type { BuildConfig, InlineConfig } from \"@stillwind/config\";\n\nimport { loaderOptionsId } from \"./rules.ts\";\n\n/** Compiler options carried by a loader rule or an encoded SFC subrequest. */\nexport type LoaderOptions = InlineConfig & {\n /**\n * Base64url-encoded JSON configuration for an SFC subrequest. Omit when the rule supplies options\n * directly.\n */\n stillwindOptions?: string;\n};\n\n/** Producer identity and flags that select compilation behavior for one loader request. */\nexport interface ProducerRequest {\n /** Whether `stillwind.css` requests document CSS without importing application JavaScript. */\n projection: boolean;\n /** Whether `stillwind-module-css` requests an explicit CSS value module. */\n cssValue: boolean;\n /** Whether the resource is an Astro, Svelte, or Vue file, including its generated blocks. */\n sfc: boolean;\n /**\n * Full script identity. SFC blocks, projections, CSS values, and export selections share the\n * original producer identity.\n */\n id: string;\n /** Whether a `raw` or `url` query requires the loader to leave the input unchanged. */\n passthrough: boolean;\n}\n\n/**\n * Classifies a resource request and chooses the producer identity used for compilation.\n *\n * @param resourcePath - Absolute resource path without its query.\n * @param resourceQuery - Query including its leading `?`, or an empty string.\n * @returns Request flags and a producer ID. SFC blocks, CSS values, and projections share the\n * original file identity. Export-selection queries do not change the producer identity.\n */\nexport function classifyRequest(resourcePath: string, resourceQuery = \"\"): ProducerRequest {\n const projection = /[?&]stillwind\\.css(?:&|$)/.test(resourceQuery);\n const cssValue = /[?&]stillwind-module-css(?:&|$)/.test(resourceQuery);\n const sfc = /\\.(?:astro|svelte|vue)$/.test(resourcePath);\n const parameters = new URLSearchParams(resourceQuery);\n let sourceQuery = resourceQuery;\n if (parameters.has(\"export\")) {\n parameters.delete(\"export\");\n const query = parameters.toString();\n sourceQuery = query ? `?${query}` : \"\";\n }\n\n return {\n projection,\n cssValue,\n sfc,\n // SFC integrations re-enter the loader for blocks compiled from the original producer.\n id: resourcePath + (projection || cssValue || sfc ? \"\" : sourceQuery),\n passthrough: /[?&](?:raw|url)(?:[=&]|$)/.test(resourceQuery),\n };\n}\n\n/**\n * Reads compiler options from a rule or an encoded SFC subrequest.\n *\n * @param supplied - Rule options, optionally containing `stillwindOptions` encoded as base64url\n * JSON.\n * @returns Decoded options when `stillwindOptions` is present, otherwise the supplied object.\n * @throws If encoded configuration is not valid JSON.\n */\nexport function requestOptions(supplied: LoaderOptions): InlineConfig {\n return supplied.stillwindOptions\n ? JSON.parse(Buffer.from(supplied.stillwindOptions, \"base64url\").toString(\"utf8\"))\n : supplied;\n}\n\n/**\n * Creates a module request with forward slashes, relative to the importer when possible.\n *\n * @param from - Absolute directory containing the importing module.\n * @param to - Absolute path of the requested resource.\n * @returns A relative request with `./` when needed, or an absolute path across Windows volumes.\n */\nexport function relativeRequest(from: string, to: string): string {\n const value = path.relative(from, to).replaceAll(\"\\\\\", \"/\");\n return path.isAbsolute(value) || value.startsWith(\".\") ? value : `./${value}`;\n}\n\n/**\n * Creates a CSS projection or CSS value request that retains the producer configuration.\n *\n * SFC requests bypass other loaders. Naming callbacks use a registered rule identifier because JSON\n * cannot encode functions.\n *\n * @param resourcePath - Absolute path of the original producer.\n * @param sfc - Whether the producer is an Astro, Svelte, or Vue file.\n * @param config - Compiler config used for the original producer.\n * @param loaderPath - Absolute path of the producer loader.\n * @param query - Stillwind query text without a leading `?`.\n * @param identityConfig - Original inline settings registered on the loader rule. When evaluated\n * config contains naming callbacks, this selects that rule instead of serializing callbacks.\n * Defaults to config when file evaluation has not changed the registered settings.\n * @returns A relative resource request for scripts, or an inline loader request for SFCs.\n * @throws If SFC settings cannot be serialized for their inline request.\n */\nexport function virtualRequest(\n resourcePath: string,\n sfc: boolean,\n config: BuildConfig,\n loaderPath: string,\n query: string,\n identityConfig: InlineConfig = config,\n): string {\n if (!sfc) {\n return `${relativeRequest(path.dirname(resourcePath), resourcePath)}?${query}`;\n }\n\n const configuration = config.naming\n ? \"??\" + loaderOptionsId(identityConfig)\n : \"?stillwindOptions=\" + Buffer.from(JSON.stringify(config)).toString(\"base64url\");\n return `!!${loaderPath.replaceAll(\"\\\\\", \"/\")}${configuration}!${resourcePath.replaceAll(\"\\\\\", \"/\")}?${query}`;\n}\n","import { createHash } from \"node:crypto\";\nimport path from \"node:path\";\n\nimport { cleanModuleId, fileModuleDescriptor } from \"@stillwind/host\";\n\n/**\n * Keeps each query-selected derivative's compiler, checker, and source-map identities distinct.\n *\n * @param root - Absolute project root used to derive compiler identities.\n * @param id - Full source identity, including any query or fragment selecting transformed source.\n * @returns Ordinary file metadata without a suffix, or distinct module/document identities and a hashed checker filename.\n */\nexport function sourceDescriptor(root: string, id: string) {\n const descriptor = fileModuleDescriptor(root, id);\n const file = cleanModuleId(id);\n const suffix = id.slice(file.length);\n if (!suffix) {\n return descriptor;\n }\n const extension = path.extname(file);\n const key = createHash(\"sha256\").update(id).digest(\"hex\");\n const checkerFileName = path.join(\n path.dirname(file),\n `.${path.basename(file, extension)}.stillwind-${key}${extension}`,\n );\n return {\n ...descriptor,\n moduleId: descriptor.moduleId + suffix,\n document: {\n ...descriptor.document,\n uri: descriptor.document.uri + suffix,\n },\n checkerFileName,\n projectionFileName: checkerFileName.replaceAll(\"\\\\\", \"/\"),\n };\n}\n","import { createHash } from \"node:crypto\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nimport {\n cleanModuleId,\n cssWithSourceMap,\n warnRejectedNames,\n type CssUpstreamMap,\n} from \"@stillwind/host\";\n\nimport { warnSkippedCss } from \"../session.ts\";\nimport type { ProducerInput } from \"./emission.ts\";\nimport type { CompilationHost } from \"./host.ts\";\nimport type { SharedProject } from \"./project.ts\";\nimport { relativeRequest } from \"./requests.ts\";\nimport { sourceDescriptor } from \"./sources.ts\";\n\n/**\n * Renders document CSS for a completed compilation from the producers that it recorded.\n *\n * A producer is compiled again only when the shared compiler holds no loader compilation of its\n * current source. Manual producers are compiled for dependency composition but are excluded from\n * the document selection.\n *\n * @param producers - Nonempty list of producers from the completed graph. Every producer must use\n * the same root and config.\n * @param io - Compilation host that reads captured dependency sources and resolves scripts and\n * assets.\n * @param project - Shared project of the producers' design system, which no producer loader uses\n * meanwhile.\n * @param watch - Registers a file as a compilation dependency.\n * @param warn - Reports compiler warnings and the CSS statements that loading skipped through the\n * bundler.\n * @returns Document CSS with asset requests and an inline source map composed with recorded\n * upstream maps.\n * @throws If producers use different design systems, a dependency source is missing, or\n * compilation fails.\n */\nexport async function compilationStyles(\n producers: readonly ProducerInput[],\n io: CompilationHost,\n project: SharedProject,\n watch: (id: string) => void,\n warn: (message: string) => void,\n): Promise<string> {\n const { config, root } = producers[0];\n const { compiler, loaded, outputs } = project;\n const readDependency = io.dependencyReader(producers);\n warnSkippedCss(loaded.skipped, warn);\n const selection: string[] = [];\n for (const input of producers) {\n if (input.root !== root || JSON.stringify(input.config) !== JSON.stringify(config)) {\n throw new Error(\"A compilation must use one Stillwind design system\");\n }\n const previous = outputs.get(input.id);\n if (previous?.source === input.source) {\n if (previous.moduleId !== undefined && !input.manual) {\n selection.push(previous.moduleId);\n }\n continue;\n }\n const output = await compiler.compile(\n input.source,\n input.id,\n {\n describe: (id) => sourceDescriptor(root, id),\n resolve: async (specifier, importer) => ({\n id: await io.resolveJs(specifier, importer),\n }),\n read: readDependency,\n watch: (id) => {\n watch(cleanModuleId(id));\n },\n warn,\n },\n {\n moduleCssImport: \"stillwind/module-css\",\n },\n );\n outputs.set(input.id, { source: input.source, moduleId: output?.moduleId });\n if (output && !input.manual) {\n selection.push(output.moduleId);\n }\n }\n const revision = createHash(\"sha256\")\n .update(producers.map((input) => `${input.source}\\0`).join(\"\"))\n .digest(\"hex\");\n const plan = compiler.native.planStylesheet({\n modules: selection,\n coverage: {\n kind: \"complete\",\n target: \"compilation\",\n revision,\n },\n placement: \"document\",\n });\n warnRejectedNames(plan.rejectedNames, warn);\n const replacements = new Map<string, string>();\n for (const resource of [...loaded.resources, ...plan.resources]) {\n const owner =\n \"moduleId\" in resource ? compiler.resolverId(resource.moduleId) : resource.sourceName;\n const file = await io.resolveAsset(resource.specifier, owner);\n watch(file);\n const request = relativeRequest(\n path.dirname(fileURLToPath(import.meta.resolve(\"@stillwind/integration/webpack\"))),\n file,\n );\n replacements.set(resource.placeholder, JSON.stringify(request).slice(1, -1));\n }\n return cssWithSourceMap(\n plan,\n replacements,\n producers.flatMap((input) =>\n [\n input.upstream,\n ...(input.dependencies ?? []).map((dependency) => dependency.upstream),\n ].filter((upstream): upstream is CssUpstreamMap => Boolean(upstream)),\n ),\n );\n}\n","import fs from \"node:fs\";\nimport { isBuiltin } from \"node:module\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nimport { cleanModuleId, type UpstreamSourceMap } from \"@stillwind/host\";\n\nimport { nativeBindingFiles } from \"../binding-files.ts\";\nimport type { ProducerInput } from \"./emission.ts\";\n\n/**\n * Resolver policies passed to webpack or Rspack for CSS, script, and asset imports.\n */\nexport interface ResolveSettings {\n /** Dependency category used to select bundler resolution behavior, such as `esm`. */\n dependencyType?: string;\n /** Package export conditions considered when resolving a request. */\n conditionNames?: string[];\n /** File extensions tested for extensionless requests, in resolution order. */\n extensions?: string[];\n /** Package metadata fields considered in resolution order. */\n mainFields?: string[];\n}\n\n/**\n * Completion handler for webpack or Rspack resolution.\n *\n * @param error - Resolution failure, or null or undefined when no error occurred.\n * @param id - Resolved resource identity. A missing or false ID declines the request.\n */\nexport type ResolveCallback = (error?: Error | null, id?: string | false) => void;\n\n/**\n * Resolver bound to the bundler's configured conditions, extensions, and package fields.\n *\n * @param directory - Absolute directory of the importing file.\n * @param specifier - Import or resource request text, including any query suffix.\n * @param callback - Receives the resolution failure or resulting resource identity.\n */\nexport type Resolver = (directory: string, specifier: string, callback: ResolveCallback) => void;\n\n/**\n * Bundler filesystem and resolver operations shared by producer loaders and CSS reconstruction.\n */\nexport interface ResolverHost {\n /** Bundler input filesystem. Reads may return UTF-8 text or bytes through the callback. */\n fs: {\n /**\n * Reads through the bundler filesystem rather than bypassing its virtual files.\n *\n * @param id - Filesystem identity without a resource query.\n * @param callback - Receives an error or file contents. Callers convert successful contents to text.\n */\n readFile(id: string, callback: (error?: Error | null, value?: string | Buffer) => void): void;\n };\n /**\n * Creates a callback resolver with the requested dependency policy.\n *\n * @param settings - Conditions, extensions, and package fields used for this resolver.\n * @returns A resolver accepting the importer directory, request text, and a completion callback.\n */\n getResolve(settings: ResolveSettings): Resolver;\n}\n\n/**\n * Loader operations required to resolve producers, capture transformed dependencies, and report\n * compilation inputs.\n */\ninterface LoaderHostContext extends ResolverHost {\n /**\n * Complete loader chain. Entries after `loaderIndex` run before Stillwind in the normal loader\n * phase.\n */\n loaders: readonly {\n /** Complete inline loader request, including its options, reused for dependency capture. */\n request: string;\n }[];\n /** Index of the currently executing Stillwind loader within `loaders`. */\n loaderIndex: number;\n /**\n * Evaluates a generated capture module through the specified loader chain.\n *\n * @param request - Inline request whose capture loader exports source and map instead of\n * executing application code.\n * @returns A promise for the generated capture module exports.\n */\n importModule(request: string): Promise<unknown>;\n /**\n * Registers a source or compiler file as a dependency of this loader result.\n *\n * @param id - Absolute filesystem path without a resource query.\n */\n addDependency(id: string): void;\n /**\n * Reports a compilation warning through the loader context.\n *\n * @param error - Warning represented as an Error instance.\n */\n emitWarning(error: Error): void;\n}\n\n/**\n * Source and map exported by the capture loader after preceding framework transforms.\n */\nexport interface CapturedDependency {\n /** Transformed source text consumed by the compiler, without executing its application code. */\n source: string;\n /** Upstream map supplied by preceding loaders, or null when none was supplied. */\n map: UpstreamSourceMap;\n}\n\n/**\n * Compiler operations and retained dependency captures for one producer loader invocation.\n */\nexport interface LoaderHost {\n /**\n * Reads a resource through the bundler input filesystem.\n *\n * @param id - Readable filesystem path without a query.\n * @returns A promise for the file contents converted to a string.\n */\n read: (id: string) => Promise<string>;\n /**\n * Reads ordinary files or captures query-qualified source through preceding loaders.\n *\n * @param dependency - Full resolver identity, including any query suffix.\n * @returns A promise for source text, rejecting if reading or capture fails.\n */\n readDependency: (dependency: string) => Promise<string>;\n /**\n * Pending transformed-source captures keyed by full resolver identity, retained for emission\n * metadata.\n */\n dependencySources: Map<string, Promise<CapturedDependency>>;\n /**\n * Resolves a CSS import using style export conditions and CSS extensions.\n *\n * @param specifier - CSS import text.\n * @param importer - Absolute path of the importing stylesheet.\n * @returns A promise for the resolved identity, or an empty string when the resolver declines it.\n */\n resolveCss: (specifier: string, importer: string) => Promise<string>;\n /**\n * Resolves an asset using the bundler's default resolution policy.\n *\n * @param specifier - Asset request text.\n * @param importer - Absolute identity of the resource owner.\n * @returns A promise for the resolved identity, or an empty string when the resolver declines it.\n */\n resolveAsset: (specifier: string, importer: string) => Promise<string>;\n /**\n * Resolves a script dependency and marks Node builtins as external.\n *\n * @param specifier - Script import text, optionally naming a Node builtin.\n * @param importer - Absolute identity of the importing producer.\n * @returns A promise for the resolved identity and optional external status, or null when the\n * resolver declines the request. Other resolution errors reject the promise.\n */\n resolve: (\n specifier: string,\n importer: string,\n ) => Promise<{\n /** Full resolved source identity or Node builtin name. */\n id: string;\n /** Whether semantic traversal must skip loading the dependency as source. */\n external?: boolean;\n } | null>;\n /**\n * Registers the underlying file of a resolver identity as a loader dependency.\n *\n * @param id - File identity, optionally including a resource query that is removed before\n * registration.\n */\n watch: (id: string) => void;\n /**\n * Reports a compiler warning through the loader context.\n *\n * @param message - Warning text converted to an Error instance for the bundler.\n */\n warn: (message: string) => void;\n}\n\n/**\n * Creates compiler operations from a producer loader context and tracks the loader itself as a\n * dependency.\n *\n * Ordinary dependencies are read from the filesystem. Query-qualified dependencies pass through\n * preceding loaders and the capture loader. Pending captures are reused by their full resolver\n * identity.\n *\n * @param context - Active loader context with a complete loader chain and an `importModule`\n * implementation for query-qualified dependencies.\n * @param loaderPath - Absolute path of the Stillwind loader to register as a dependency.\n * @returns A host that resolves imports, reads files, captures transformed dependencies, and\n * forwards warnings.\n */\nexport function createLoaderHost(context: LoaderHostContext, loaderPath: string): LoaderHost {\n const read = createReadFile(context.fs);\n const dependencySources = new Map<string, Promise<CapturedDependency>>();\n /**\n * Reads an ordinary dependency or captures transformed text through preceding loaders.\n *\n * @param dependency - Full resolver identity. A query or fragment requires a loader capture.\n * @returns File text or captured text. Capture promises, including failures, are retained by identity.\n * @throws If filesystem reading or the dependency's loader chain fails.\n */\n const readDependency = async (dependency: string) => {\n if (cleanModuleId(dependency) === dependency) {\n return read(dependency);\n }\n let pending = dependencySources.get(dependency);\n if (!pending) {\n const capture = fileURLToPath(\n new URL(\"./source-loader.js\", import.meta.resolve(\"@stillwind/integration/webpack\")),\n );\n const preceding = context.loaders\n .slice(context.loaderIndex + 1)\n .map((loader) => loader.request);\n pending = context.importModule(\n `!!${[capture, ...preceding, dependency].join(\"!\")}`,\n ) as Promise<CapturedDependency>;\n dependencySources.set(dependency, pending);\n }\n return (await pending).source;\n };\n /**\n * Adapts loader resolution to requests relative to a source file.\n *\n * @param settings - Resolution policy passed to the loader's resolver factory.\n * @returns An asynchronous resolver accepting a specifier and full importer identity. Resolver\n * errors reject its promise, and a missing result becomes an empty string.\n */\n const resolver = (settings: ResolveSettings) => {\n const resolve = context.getResolve(settings);\n return (specifier: string, importer: string) =>\n new Promise<string>((done, reject) =>\n resolve(path.dirname(cleanModuleId(importer)), specifier, (error, id) =>\n error ? reject(error) : done(id || \"\"),\n ),\n );\n };\n const resolveCss = resolver(cssResolveOptions);\n const resolveJs = resolver({\n dependencyType: \"esm\",\n extensions: [\".tsx\", \".ts\", \".jsx\", \".js\", \".mjs\", \".cjs\", \".json\"],\n });\n const resolveAsset = resolver({});\n /**\n * Registers a filesystem dependency for loader invalidation.\n *\n * @param id - Full resolver identity whose query and fragment are removed before registration.\n */\n const watch = (id: string) => context.addDependency(cleanModuleId(id));\n watch(loaderPath);\n return {\n read,\n readDependency,\n dependencySources,\n resolveCss,\n resolveAsset,\n resolve: async (specifier: string, importer: string) => {\n if (specifier.startsWith(\"node:\") && isBuiltin(specifier)) {\n return { id: specifier, external: true };\n }\n try {\n const id = await resolveJs(specifier, importer);\n return id ? { id } : null;\n } catch (error) {\n if (isBuiltin(specifier)) {\n return { id: specifier, external: true };\n }\n throw error;\n }\n },\n watch,\n warn: (message: string) => context.emitWarning(new Error(message)),\n };\n}\n\n/**\n * Registers compiler runtime files so changes invalidate cached loader results.\n *\n * The function includes native binding files and JavaScript files beside the published host\n * entrypoint.\n *\n * @param watch - Registers an absolute file path as a loader dependency.\n * @throws If the host runtime directory cannot be read.\n */\nexport function watchCompilerFiles(watch: (id: string) => void): void {\n for (const file of nativeBindingFiles()) {\n watch(file);\n }\n const directory = path.dirname(fileURLToPath(import.meta.resolve(\"@stillwind/host\")));\n for (const file of fs.readdirSync(directory)) {\n if (file.endsWith(\".js\")) {\n watch(path.join(directory, file));\n }\n }\n}\n\n/**\n * File and resolver operations used after producer modules have completed compilation.\n */\nexport interface CompilationHost {\n /**\n * Reads the underlying file through the bundler input filesystem.\n *\n * @param id - Resolver identity whose query suffix is removed before reading.\n * @returns A promise for the file contents converted to a string.\n */\n read: (id: string) => Promise<string>;\n /**\n * Creates a reader that prefers captured producer and dependency sources over filesystem reads.\n *\n * @param producers - Producer metadata collected from the completed compilation graph.\n * @returns A reader keyed by full resolver identity. Missing query-qualified captures reject.\n * Ordinary uncaptured files are read through the filesystem.\n */\n dependencyReader: (producers: readonly ProducerInput[]) => (id: string) => Promise<string>;\n /**\n * Resolves an import from the design-system CSS graph.\n *\n * @param specifier - CSS import text.\n * @param importer - Absolute path of the importing stylesheet.\n * @returns A promise for the resolver's file identity, rejecting on resolution errors.\n */\n resolveCss: (specifier: string, importer: string) => Promise<string>;\n /**\n * Resolves a producer dependency, including supported framework source extensions.\n *\n * @param specifier - Script or framework import text.\n * @param importer - Absolute identity of the importing producer.\n * @returns A promise for the resolver's identity, retaining resource queries.\n */\n resolveJs: (specifier: string, importer: string) => Promise<string>;\n /**\n * Resolves a stylesheet asset using the bundler's default resolution policy.\n *\n * @param specifier - Asset request text.\n * @param importer - Absolute identity of the stylesheet or producer that owns the resource.\n * @returns A promise for the resolver's identity, rejecting on resolution errors.\n */\n resolveAsset: (specifier: string, importer: string) => Promise<string>;\n}\n\n/**\n * Creates filesystem and resolution operations for reconstructing a completed compilation.\n *\n * Reconstruction resolves framework source files as well as scripts. Query-qualified dependency\n * reads require captured source from producer metadata.\n *\n * @param context - Bundler input filesystem and resolver factory operations.\n * @returns A host that reads files and builds dependency readers from retained producer metadata.\n */\nexport function createCompilationHost(context: ResolverHost): CompilationHost {\n const read = createReadFile(context.fs, cleanModuleId);\n /**\n * Adapts compilation resolution to requests relative to a source file.\n *\n * @param settings - Resolution policy passed to the bundler's resolver factory.\n * @returns An asynchronous resolver accepting a specifier and full importer identity. It forwards\n * successful resolver results without checking for an absent identity, and rejects resolver errors.\n */\n const resolver = (settings: ResolveSettings) => {\n const resolve = context.getResolve(settings);\n return (specifier: string, importer: string) =>\n new Promise<string>((done, reject) =>\n resolve(path.dirname(cleanModuleId(importer)), specifier, (error, id) =>\n error ? reject(error) : done(id as string),\n ),\n );\n };\n return {\n read,\n /**\n * Creates a reader using source captured by the completed module graph.\n *\n * @param producers - Producer and dependency records. Later records replace earlier text for the same identity.\n * @returns A reader that uses exact captured identities before falling back to ordinary filesystem reads.\n */\n dependencyReader(producers: readonly ProducerInput[]) {\n const sources = new Map<string, string>();\n for (const input of producers) {\n sources.set(input.id, input.source);\n for (const dependency of input.dependencies ?? []) {\n sources.set(dependency.id, dependency.source);\n }\n }\n return (id: string) => {\n if (sources.has(id)) {\n return Promise.resolve(sources.get(id)!);\n }\n if (cleanModuleId(id) !== id) {\n return Promise.reject(new Error(`No transformed source captured for ${id}`));\n }\n return read(id);\n };\n },\n resolveCss: resolver(cssResolveOptions),\n resolveJs: resolver({\n dependencyType: \"esm\",\n extensions: [\".tsx\", \".ts\", \".jsx\", \".js\", \".mjs\", \".cjs\", \".vue\", \".svelte\", \".astro\"],\n }),\n resolveAsset: resolver({}),\n };\n}\n\n/**\n * CSS resolution policy that prefers style exports and metadata fields before ordinary package\n * entrypoints.\n */\nconst cssResolveOptions = {\n conditionNames: [\"style\", \"import\", \"default\"],\n extensions: [\".css\"],\n mainFields: [\"style\", \"main\"],\n};\n\n/**\n * Adapts the bundler filesystem to asynchronous string reads.\n *\n * @param filesystem - Input filesystem that completes reads through a callback.\n * @param fileId - Maps resolver identities to readable paths. Defaults to keeping the identity\n * unchanged.\n * @returns A reader that resolves to the filesystem value converted to a string, or rejects on read\n * failure.\n */\nfunction createReadFile(filesystem: ResolverHost[\"fs\"], fileId = (id: string) => id) {\n return (id: string) =>\n new Promise<string>((resolve, reject) =>\n filesystem.readFile(fileId(id), (error, value) =>\n error ? reject(error) : resolve(String(value)),\n ),\n );\n}\n","/**\n * Shares one loaded design system and compiler session between the producer loader calls and the\n * document CSS reconstruction of a webpack or Rspack compiler.\n *\n * The main entry point is {@link useProject}.\n */\nimport path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\n\nimport type { BuildConfig } from \"@stillwind/config\";\nimport type { ProjectScope } from \"@stillwind/config/node\";\nimport { cssEntrypoint, loadCssGraph, nodePluginHost, type LoadedCssGraph } from \"@stillwind/host\";\n\nimport { LoaderCache, recordInputs, type InputReader } from \"../loader-cache.ts\";\nimport { buildCompilerOptions, IntegrationSession } from \"../session.ts\";\nimport { buildSourceEntries, isSourceEntry } from \"../source-entries.ts\";\n\n/**\n * Compiler operations of webpack and Rspack that a shared project uses.\n */\nexport interface ProjectCompiler {\n /** Top compiler of a child compiler. Child compilers use the projects of their top compiler. */\n root?: ProjectCompiler;\n /** Application directory against which relative entry requests resolve. */\n context?: string;\n /** Whether the compiler runs in watch mode, so that later compilations follow file changes. */\n watchMode?: boolean;\n /** Absolute paths that changed or were added since the previous compilation of a watch run. */\n modifiedFiles?: ReadonlySet<string>;\n /** Absolute paths that were removed since the previous compilation of a watch run. */\n removedFiles?: ReadonlySet<string>;\n /** Normalized entry settings. A function selects entries at compilation time. */\n options?: {\n /** Entry descriptions keyed by name, or a function. */\n entry?: unknown;\n };\n /** Hooks that end the compiler's use of its shared projects. */\n hooks: {\n /** Runs after each compilation finishes. */\n done: {\n /**\n * @param name - Plugin registration name.\n * @param callback - Operation run after the compilation.\n */\n tap(name: string, callback: () => void): void;\n };\n /** Runs when the compiler closes. Absent in compilers without a shutdown hook. */\n shutdown?: {\n /**\n * @param name - Plugin registration name.\n * @param callback - Operation run when the compiler closes.\n */\n tap(name: string, callback: () => void): void;\n };\n };\n}\n\n/**\n * Loader context operations that {@link useProject} uses.\n */\nexport interface ProjectContext {\n /** Compiler that runs the loader, or undefined outside a webpack or Rspack compilation. */\n _compiler?: ProjectCompiler;\n /** Compilation that runs the loader, used to apply each compilation's file changes once. */\n _compilation?: object;\n /**\n * Registers a file whose changes invalidate this loader result.\n *\n * @param id - Absolute file path.\n */\n addDependency(id: string): void;\n /**\n * Registers a missing file whose creation invalidates this loader result.\n *\n * @param id - Absolute file path.\n */\n addMissingDependency(id: string): void;\n /**\n * Registers a directory whose listing affects this loader result.\n *\n * @param id - Absolute directory path.\n */\n addContextDependency(id: string): void;\n}\n\n/** File operations of one loader call that loading the CSS graph uses. */\nexport interface ProjectHost {\n /**\n * Reads a file through the bundler filesystem.\n *\n * @param id - Absolute file path.\n * @returns A promise for the file text, rejecting when the file cannot be read.\n */\n read: (id: string) => Promise<string>;\n /**\n * Resolves a CSS import.\n *\n * @param specifier - CSS import text.\n * @param importer - Absolute path of the importing stylesheet.\n * @returns A promise for the resolved path, or an empty string when the resolver declines it.\n */\n resolveCss: (specifier: string, importer: string) => Promise<string>;\n}\n\n/**\n * Design system and compiler that loader calls with equal settings share.\n */\nexport interface SharedProject {\n /** Completed CSS graph and authored resources used by the compiler. */\n loaded: LoadedCssGraph;\n /** Compiler that concurrent loader calls use. The caller must not close it. */\n compiler: IntegrationSession;\n /** Compilations whose file changes the compiler has received. */\n applied: WeakSet<object>;\n /**\n * Last loader compilation of each producer, keyed by full resolver identity. Document CSS\n * reconstruction compiles a producer again only when its source differs.\n */\n outputs: Map<string, ProducerOutput>;\n}\n\n/**\n * Result of a producer loader compilation that the compiler session still holds.\n */\nexport interface ProducerOutput {\n /** Source text that the compilation received. */\n source: string;\n /** Compiler module ID, or undefined when the compilation produced no code. */\n moduleId?: string;\n}\n\n/**\n * Shared projects of each compiler, keyed by settings. A compiler's projects never serve another\n * compiler, because two compilers can resolve the same import differently.\n */\nconst projects = new WeakMap<object, LoaderCache<SharedProject>>();\n\n/** Shared projects of loader calls that run outside a compiler. */\nconst detachedProjects = new LoaderCache<SharedProject>(closeProject, 30_000);\n\n/**\n * Closes the checker of a shared project and discards its prepared sources. The project stays\n * usable, and a later compilation starts a new checker.\n *\n * @param project - Project whose checker to close.\n */\nfunction closeProject(project: SharedProject): void {\n project.compiler.close();\n}\n\n/**\n * Returns the project cache of a compiler, creating it on first use.\n *\n * A build closes idle checkers after each compilation, because no later compilation of the run\n * uses them. A watch run keeps them until the compiler closes or they stay idle for 30 seconds.\n *\n * @param compiler - Compiler that runs the loader.\n * @returns The compiler's cache.\n */\nfunction compilerProjects(compiler: ProjectCompiler): LoaderCache<SharedProject> {\n let cache = projects.get(compiler);\n if (!cache) {\n const created = new LoaderCache<SharedProject>(closeProject, 30_000);\n cache = created;\n projects.set(compiler, created);\n compiler.hooks.done.tap(\"StillwindProject\", () => {\n if (!compiler.watchMode) {\n created.closeIdle();\n }\n });\n compiler.hooks.shutdown?.tap(\"StillwindProject\", () => created.closeIdle());\n }\n return cache;\n}\n\n/**\n * Lists the entry files of a compiler that are local script or component files.\n *\n * @param compiler - Compiler whose normalized entry settings to read.\n * @returns Absolute paths of the relative and absolute entry requests. Package requests and\n * entries that a function selects are not listed.\n */\nfunction compilerEntries(compiler: ProjectCompiler): string[] {\n const entry = compiler.options?.entry;\n if (!entry || typeof entry !== \"object\") {\n return [];\n }\n const context = compiler.context ?? process.cwd();\n return Object.values(entry).flatMap((description: unknown) => {\n const requests = (description as { import?: unknown } | null)?.import;\n return (Array.isArray(requests) ? requests : []).flatMap((request: unknown) =>\n typeof request === \"string\" &&\n (request.startsWith(\".\") || path.isAbsolute(request)) &&\n isSourceEntry(request)\n ? [path.resolve(context, request)]\n : [],\n );\n });\n}\n\n/**\n * Loads the design system and compiler for a producer loader call, or reuses them.\n *\n * Calls of one compiler share them while the configuration and the CSS files stay unchanged. In a\n * build, the compiler loads the source files of the entries and of the selected project into one\n * checker before its first compilation. In a watch run, each compilation reports the files that\n * webpack or Rspack saw change to the compiler first. CSS dependencies are registered with the\n * loader context of every call.\n *\n * @param context - Loader context that supplies the compiler and dependency registration.\n * @param scope - Target globs of the selected project, or undefined when no configuration file\n * selects a project.\n * @param config - Evaluated compiler settings.\n * @param root - Absolute project root.\n * @param mode - Native compilation mode.\n * @param host - File reads and CSS resolution of this call. Later calls reuse only the loaded\n * graph, which does not read or resolve CSS again.\n * @returns A lease for the shared project. The caller must end it after its last use.\n * @throws If reading the recorded inputs fails, the CSS graph cannot be loaded, or compiler\n * initialization fails.\n */\nexport async function useProject(\n context: ProjectContext,\n scope: ProjectScope | undefined,\n config: BuildConfig,\n root: string,\n mode: string,\n host: ProjectHost,\n) {\n const compiler = context._compiler?.root ?? context._compiler;\n const cache = compiler ? compilerProjects(compiler) : detachedProjects;\n const probe: InputReader = (id) =>\n host.read(id).catch((error: NodeJS.ErrnoException) => {\n if (error.code === \"ENOENT\" || error.code === \"ENOTDIR\") {\n return undefined;\n }\n throw error;\n });\n const lease = await cache.use(JSON.stringify([config, root, mode]), probe, async () => {\n const recorder = recordInputs(probe);\n const loaded = await loadCssGraph(\n path.resolve(root, cssEntrypoint(config)),\n buildCompilerOptions(config),\n {\n resolve: host.resolveCss,\n read: recorder.read,\n documentUri: (id) => pathToFileURL(id).href,\n sourceMapSource: (id) => pathToFileURL(id).href,\n watch: recorder.watch,\n watchDirectory: recorder.watchDirectory,\n plugins: nodePluginHost,\n },\n undefined,\n undefined,\n {\n plugins: config.plugins,\n tailwind: config.tailwind,\n important: config.important,\n root,\n },\n );\n // Without a compiler, no report says which files change, so each compilation reads the files\n // again.\n const entries = compiler\n ? await buildSourceEntries(compilerEntries(compiler), scope)\n : undefined;\n const watching = Boolean(compiler?.watchMode);\n const value: SharedProject = {\n loaded,\n compiler: new IntegrationSession(\n root,\n loaded.loader,\n config,\n false,\n mode,\n loaded.plugins,\n watching ? undefined : entries,\n watching ? entries : undefined,\n ),\n applied: new WeakSet(),\n outputs: new Map(),\n };\n return { value, inputs: await recorder.finish() };\n });\n const { applied, compiler: session } = lease.value;\n const compilation = context._compilation;\n if (compiler?.watchMode && compilation && !applied.has(compilation)) {\n applied.add(compilation);\n for (const file of compiler.removedFiles ?? []) {\n session.sourceChanged(file, true);\n }\n for (const file of compiler.modifiedFiles ?? []) {\n if (!/\\.(?:[cm]?[jt]sx?|json|astro|svelte|vue)$/.test(file)) {\n continue;\n }\n // The compiler reports added files as modified. An added file can change how an import\n // resolves, so a file that no prepared source holds counts as added.\n session.sourceChanged(file, !session.holdsSource(file));\n }\n }\n for (const file of lease.inputs.files.keys()) {\n context.addDependency(file);\n }\n for (const file of lease.inputs.missing) {\n context.addMissingDependency(file);\n }\n for (const directory of lease.inputs.directories) {\n context.addContextDependency(directory);\n }\n return lease;\n}\n","import type { BuildConfig } from \"@stillwind/config\";\nimport type { ResolvedIntegrationConfig } from \"@stillwind/config/node\";\nimport type { CssUpstreamMap } from \"@stillwind/host\";\n\nimport { compilationStyles } from \"./compilation-styles.ts\";\nimport { createCompilationHost, type ResolverHost } from \"./host.ts\";\nimport { useProject, type ProjectCompiler } from \"./project.ts\";\n\n/**\n * A producer and its captured dependencies stored in bundler metadata for CSS reconstruction.\n */\nexport interface ProducerInput {\n /** Source text received by the producer loader, before Stillwind compilation. */\n source: string;\n /** Producer identity. Query-qualified script dependencies retain their query suffix. */\n id: string;\n /** Absolute project root against which compiler module identities are resolved. */\n root: string;\n /** Compiler configuration shared by every producer in this compilation. */\n config: BuildConfig;\n /**\n * Whether this producer is excluded from automatic document CSS and supplies explicit CSS values.\n */\n manual: boolean;\n /** Map from loader input back to the original source, used when composing final CSS maps. */\n upstream?: CssUpstreamMap;\n /**\n * Transformed dependencies captured through the loader chain. Cached metadata retains them for\n * reconstruction.\n */\n dependencies?: {\n /** Complete resolver identity, including the query that selected the transformed dependency. */\n id: string;\n /** Source produced by the loaders that ran before Stillwind. */\n source: string;\n /**\n * Map from the captured source back to its original source, when the preceding loaders supplied\n * one.\n */\n upstream?: CssUpstreamMap;\n }[];\n}\n\n/**\n * Stores a producer in module build metadata so cached modules can participate in CSS\n * reconstruction.\n *\n * @param context - Loader context for a module in a compilation registered by `StillwindPlugin`.\n * @param input - Producer source, compiler configuration, and captured dependency sources.\n * @throws If the compilation has no registered emission hook or the loader context has no module.\n */\nexport function recordProducer<Module extends EmissionModule>(\n context: EmissionContext<Module>,\n input: ProducerInput,\n): void {\n requireEmission(context);\n if (!context._module) {\n throw new Error(incompleteGraphMessage);\n }\n context._module.buildInfo ??= {};\n context._module.buildInfo.stillwind = input;\n}\n\n/**\n * Bundler module metadata used to recover cached producer inputs and identify the shared document\n * CSS carrier.\n */\nexport interface EmissionModule {\n /** Resource path and query used to identify the shared document CSS carrier. */\n resource?: string;\n /** Build metadata retained by the bundler when a module is reused from cache. */\n buildInfo?: {\n /** Producer input reconstructed after the compilation graph is complete. */\n stillwind?: ProducerInput;\n /** Build fields owned by the bundler or other plugins, retained without interpretation. */\n [key: string]: unknown;\n };\n}\n\n/**\n * Compilation operations required to collect producers and rebuild document CSS carriers.\n */\nexport interface EmissionCompilation<Module extends EmissionModule = EmissionModule> {\n /** Parent compilation used by CSS extraction loaders that run a child compiler. */\n compiler?: {\n parentCompilation?: EmissionCompilation<Module>;\n };\n /** Settings evaluated by StillwindPlugin before the build run, reused by producer loaders. */\n __stillwindConfiguration?: ResolvedIntegrationConfig;\n /** Missing configuration candidates whose creation must trigger a watch rebuild. */\n missingDependencies: {\n /**\n * Registers a missing path so its creation invalidates this compilation.\n *\n * @param id - Absolute missing configuration candidate.\n * @returns The bundler collection's insertion result, which Stillwind ignores.\n */\n add(id: string): unknown;\n };\n /** Compilation lifecycle operations used to wait for the completed producer graph. */\n hooks: {\n /** Runs after ordinary module builds, before document carriers are rebuilt. */\n finishModules: {\n /**\n * Registers asynchronous CSS reconstruction for the completed modules.\n *\n * @param name - Plugin registration name.\n * @param callback - Operation receiving cached and newly built modules. Rejections fail compilation.\n */\n tapPromise(name: string, callback: (modules: Iterable<Module>) => Promise<void>): void;\n };\n };\n /** Files whose changes invalidate reconstructed CSS. */\n fileDependencies: {\n /**\n * Adds a compiler or source file to watch tracking.\n *\n * @param id - Absolute dependency path.\n * @returns The bundler collection's insertion result, which Stillwind ignores.\n */\n add(id: string): unknown;\n };\n /** Directories whose entry additions and removals invalidate reconstructed CSS. */\n contextDependencies: {\n /**\n * Adds a directory that a plugin lists to watch tracking.\n *\n * @param id - Absolute directory path.\n * @returns The bundler collection's insertion result, which Stillwind ignores.\n */\n add(id: string): unknown;\n };\n /** Bundler warning collection receiving compiler lint and rejected-name messages. */\n warnings: {\n /**\n * Appends a warning without failing reconstruction.\n *\n * @param error - Warning represented as an Error instance.\n * @returns The collection's append result, which Stillwind ignores.\n */\n push(error: Error): unknown;\n };\n /**\n * Reruns a document carrier after reconstructed CSS has been stored on the compilation.\n *\n * @param module - Carrier from the completed module graph.\n * @param callback - Completion handler receiving an error when rebuilding fails.\n */\n rebuildModule(module: Module, callback: (error?: Error | null) => void): void;\n /**\n * Reconstructed document CSS, optionally including an inline source map. Undefined before\n * reconstruction.\n */\n __stillwindCss?: string;\n}\n\n/**\n * Bundler context used to register emission and attach producer metadata to the current\n * compilation.\n */\nexport interface EmissionContext<\n Module extends EmissionModule = EmissionModule,\n> extends ResolverHost {\n /** Current compilation, required when recording producers or installing document CSS reconstruction. */\n _compilation?: EmissionCompilation<Module>;\n /** Compiler whose shared project document CSS reconstruction uses with the producer loaders. */\n _compiler?: ProjectCompiler;\n /** Current bundler module whose buildInfo retains producer metadata. */\n _module?: Module;\n /**\n * Bundler mode forwarded to CSS reconstruction. Only `development` selects development\n * compilation.\n */\n mode?: string;\n}\n\n/**\n * Registers CSS reconstruction after all modules in the compilation have finished.\n *\n * Registration is idempotent for a compilation. The hook collects cached and newly built producers,\n * stores document CSS, and rebuilds each carrier through the host CSS pipeline.\n *\n * @param context - Context with a compilation, filesystem, and resolver. Register it before\n * producer loaders run.\n * @throws If the context has no compilation with a `finishModules` hook.\n */\nexport function installEmission<Module extends EmissionModule>(\n context: EmissionContext<Module>,\n): void {\n const compilation = requireCompilation(context);\n if (installed.has(compilation)) {\n return;\n }\n installed.add(compilation);\n const io = createCompilationHost(context);\n compilation.hooks.finishModules.tapPromise(\"StillwindEmission\", async (modules) => {\n const completed = [...modules];\n const producers = completed\n .map((module) => module.buildInfo?.stillwind)\n .filter((input): input is ProducerInput => Boolean(input));\n const carriers = completed.filter((module) =>\n module.resource?.includes(\"stillwind-webpack.css?stillwind-document\"),\n );\n if (!carriers.length || !producers.length) {\n return;\n }\n const { config, root } = producers[0];\n const project = await useProject(\n {\n _compiler: context._compiler,\n _compilation: compilation,\n addDependency: (id) => compilation.fileDependencies.add(id),\n addMissingDependency: (id) => compilation.missingDependencies.add(id),\n addContextDependency: (id) => compilation.contextDependencies.add(id),\n },\n compilation.__stillwindConfiguration?.scope,\n config,\n root,\n context.mode === \"development\" ? \"development\" : \"release\",\n io,\n );\n try {\n compilation.__stillwindCss = await compilationStyles(\n producers,\n io,\n project.value,\n (id) => {\n compilation.fileDependencies.add(id);\n },\n (message) => {\n compilation.warnings.push(new Error(message));\n },\n );\n } finally {\n project.done();\n }\n for (const carrier of carriers) {\n await new Promise<void>((resolve, reject) =>\n compilation.rebuildModule(carrier, (error) => (error ? reject(error) : resolve())),\n );\n }\n });\n}\n\n/**\n * Compilations whose emission hooks have been registered. Membership is required before automatic\n * loaders record producers.\n */\nconst installed = new WeakSet<object>();\n\nconst incompleteGraphMessage =\n \"Automatic Stillwind CSS requires new StillwindPlugin(config) before compilation begins\";\n\n/**\n * Obtains the compilation operations needed to reconstruct document CSS.\n *\n * @param context - Bundler context that must expose a `finishModules` compilation hook.\n * @returns The compilation attached to the context.\n * @throws If the context cannot supply a completed compilation graph.\n */\nfunction requireCompilation<Module extends EmissionModule>(\n context: EmissionContext<Module>,\n): EmissionCompilation<Module> {\n const compilation = context._compilation;\n if (!compilation?.hooks?.finishModules) {\n throw new Error(incompleteGraphMessage);\n }\n return compilation;\n}\n\n/**\n * Rejects automatic CSS requests when the compilation has no registered emission hook.\n *\n * @param context - Loader context associated with a compilation registered by `StillwindPlugin`.\n * @returns The nearest registered compilation holding reconstructed document CSS.\n * @throws If the compilation is missing or its emission hook has not been registered.\n */\nexport function requireEmission<Module extends EmissionModule>(\n context: EmissionContext<Module>,\n): EmissionCompilation<Module> {\n let compilation = requireCompilation(context);\n while (!installed.has(compilation)) {\n const parent = compilation.compiler?.parentCompilation;\n if (!parent) {\n throw new Error(incompleteGraphMessage);\n }\n compilation = parent;\n }\n return compilation;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAaA,SAAgB,gBAAgB,QAA8B;CAC5D,OAAO,eAAe,WAAW,QAAQ,CAAC,CAAC,OAAO,KAAK,UAAU,MAAM,CAAC,CAAC,CAAC,OAAO,KAAK;AACxF;;;;;;;;;AAgCA,SAAgB,eAAe,QAAuC;CACpE,OAAO;EACL;GACE,MAAM;GACN,SAAS;GACT,SAAS;GACT,KAAK,CACH;IACE,QAAQ,cACN,IAAI,IAAI,eAAe,YAAY,QAAQ,gCAAgC,CAAC,CAC9E;IACA,SAAS;IACT,OAAO,gBAAgB,MAAM;GAC/B,CACF;EACF;EACA;GACE,MAAM;GACN,SAAS;GACT,SAAS;GACT,KAAK,CACH;IACE,QAAQ,cACN,IAAI,IAAI,eAAe,YAAY,QAAQ,gCAAgC,CAAC,CAC9E;IACA,SAAS;IACT,OAAO,gBAAgB,MAAM;GAC/B,CACF;EACF;EACA;GACE,MAAM;GACN,SAAS;GACT,KAAK,CACH,cACE,IAAI,IAAI,wBAAwB,YAAY,QAAQ,gCAAgC,CAAC,CACvF,CACF;EACF;EACA;GACE,MAAM;GACN,SAAS;GACT,KAAK,CACH,cACE,IAAI,IAAI,mBAAmB,YAAY,QAAQ,gCAAgC,CAAC,CAClF,CACF;EACF;EACA;GAEE,MAAM;GACN,SAAS;GACT,SAAS;GACT,KAAK,CACH,cACE,IAAI,IAAI,0BAA0B,YAAY,QAAQ,gCAAgC,CAAC,CACzF,CACF;EACF;CACF;AACF;;;;;;;;;;ACnEA,SAAgB,gBAAgB,cAAsB,gBAAgB,IAAqB;CACzF,MAAM,aAAa,4BAA4B,KAAK,aAAa;CACjE,MAAM,WAAW,kCAAkC,KA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;;;;AASA,SAAgB,gBACd,SAC6B;CAC7B,IAAI,cAAc,mBAAmB,OAAO;CAC5C,OAAO,CAAC,UAAU,IAAI,WAAW,GAAG;EAClC,MAAM,SAAS,YAAY,UAAU;EACrC,IAAI,CAAC,QACH,MAAM,IAAI,MAAM,sBAAsB;EAExC,cAAc;CAChB;CACA,OAAO;AACT"}
1
+ {"version":3,"file":"emission-Q6WeluCM.js","names":[],"sources":["../src/webpack/rules.ts","../src/webpack/requests.ts","../src/webpack/sources.ts","../src/webpack/compilation-styles.ts","../src/webpack/host.ts","../src/webpack/project.ts","../src/webpack/emission.ts"],"sourcesContent":["import { createHash } from \"node:crypto\";\nimport { fileURLToPath } from \"node:url\";\n\nimport type { InlineConfig } from \"@stillwind/config\";\n\n/**\n * Derives the webpack rule identifier used by inline SFC loader requests.\n *\n * @param config - The same configuration values registered on the loader rule. JSON serialization\n * omits callbacks, so namingRevision must distinguish changed naming implementations.\n * @returns A stillwind-prefixed SHA-256 hash of the serialized configuration.\n * @throws If the configuration cannot be serialized as JSON.\n */\nexport function loaderOptionsId(config: InlineConfig): string {\n return \"stillwind-\" + createHash(\"sha256\").update(JSON.stringify(config)).digest(\"hex\");\n}\n\n/** webpack-compatible producer and source-map rules, also consumed by Rspack. */\nexport interface StillwindRule {\n /** Matches resource paths, including synthetic component script suffixes where required. */\n test: RegExp;\n /** Optional exclusion applied before the loader chain, normally for node_modules. */\n exclude?: RegExp;\n /** Placement relative to ordinary loaders. Omission uses the normal loader phase. */\n enforce?: \"pre\" | \"post\";\n /** Loader entries in webpack rule order, executed according to the bundler's loader phases. */\n use: (\n | string\n | {\n /** Absolute installed loader path. */\n loader: string;\n /** Discovery and inline settings retained by the rule and evaluated by its producer loader. */\n options: InlineConfig;\n /** Registered rule identity referenced by requests that retain naming callbacks. */\n ident: string;\n }\n )[];\n}\n\n/**\n * Builds producer, document CSS, and SFC source-map loader rules without evaluating configuration.\n *\n * @param config - Discovery and inline settings shared by producer rules. The object is retained.\n * @returns Rules using absolute paths in the installed integration package. The host provides its\n * CSS pipeline and registers StillwindPlugin when automatic document CSS is required.\n * @throws If loader resolution or configuration serialization fails.\n */\nexport function stillwindRules(config: InlineConfig): StillwindRule[] {\n return [\n {\n test: /\\.[cm]?[jt]sx?$/,\n exclude: /node_modules/,\n enforce: \"pre\",\n use: [\n {\n loader: fileURLToPath(\n new URL(\"./loader.js\", import.meta.resolve(\"@stillwind/integration/webpack\")),\n ),\n options: config,\n ident: loaderOptionsId(config),\n },\n ],\n },\n {\n test: /\\.(?:astro|svelte|vue)$/,\n exclude: /node_modules/,\n enforce: \"pre\",\n use: [\n {\n loader: fileURLToPath(\n new URL(\"./loader.js\", import.meta.resolve(\"@stillwind/integration/webpack\")),\n ),\n options: config,\n ident: loaderOptionsId(config),\n },\n ],\n },\n {\n test: /stillwind-webpack\\.css$/,\n enforce: \"post\",\n use: [\n fileURLToPath(\n new URL(\"./document-loader.js\", import.meta.resolve(\"@stillwind/integration/webpack\")),\n ),\n ],\n },\n {\n test: /stillwind-webpack\\.css$/,\n enforce: \"pre\",\n use: [\n fileURLToPath(\n new URL(\"./css-loader.js\", import.meta.resolve(\"@stillwind/integration/webpack\")),\n ),\n ],\n },\n {\n // Vue inline match resources select script rules with a synthetic .vue.ts suffix.\n test: /\\.(?:astro|svelte|vue)(?:\\.[cm]?[jt]sx?)?$/,\n exclude: /node_modules/,\n enforce: \"post\",\n use: [\n fileURLToPath(\n new URL(\"./source-map-loader.js\", import.meta.resolve(\"@stillwind/integration/webpack\")),\n ),\n ],\n },\n ];\n}\n","import path from \"node:path\";\n\nimport type { BuildConfig, InlineConfig } from \"@stillwind/config\";\n\nimport { loaderOptionsId } from \"./rules.ts\";\n\n/** Compiler options carried by a loader rule or an encoded SFC subrequest. */\nexport type LoaderOptions = InlineConfig & {\n /**\n * Base64url-encoded JSON configuration for an SFC subrequest. Omit when the rule supplies options\n * directly.\n */\n stillwindOptions?: string;\n};\n\n/** Producer identity and flags that select compilation behavior for one loader request. */\nexport interface ProducerRequest {\n /** Whether `stillwind.css` requests document CSS without importing application JavaScript. */\n projection: boolean;\n /** Whether `stillwind-module-css` requests an explicit CSS value module. */\n cssValue: boolean;\n /** Whether the resource is an Astro, Svelte, or Vue file, including its generated blocks. */\n sfc: boolean;\n /**\n * Full script identity. SFC blocks, projections, CSS values, and export selections share the\n * original producer identity.\n */\n id: string;\n /** Whether a `raw` or `url` query requires the loader to leave the input unchanged. */\n passthrough: boolean;\n}\n\n/**\n * Classifies a resource request and chooses the producer identity used for compilation.\n *\n * @param resourcePath - Absolute resource path without its query.\n * @param resourceQuery - Query including its leading `?`, or an empty string.\n * @returns Request flags and a producer ID. SFC blocks, CSS values, and projections share the\n * original file identity. Export-selection queries do not change the producer identity.\n */\nexport function classifyRequest(resourcePath: string, resourceQuery = \"\"): ProducerRequest {\n const projection = /[?&]stillwind\\.css(?:&|$)/.test(resourceQuery);\n const cssValue = /[?&]stillwind-module-css(?:&|$)/.test(resourceQuery);\n const sfc = /\\.(?:astro|svelte|vue)$/.test(resourcePath);\n const parameters = new URLSearchParams(resourceQuery);\n let sourceQuery = resourceQuery;\n if (parameters.has(\"export\")) {\n parameters.delete(\"export\");\n const query = parameters.toString();\n sourceQuery = query ? `?${query}` : \"\";\n }\n\n return {\n projection,\n cssValue,\n sfc,\n // SFC integrations re-enter the loader for blocks compiled from the original producer.\n id: resourcePath + (projection || cssValue || sfc ? \"\" : sourceQuery),\n passthrough: /[?&](?:raw|url)(?:[=&]|$)/.test(resourceQuery),\n };\n}\n\n/**\n * Reads compiler options from a rule or an encoded SFC subrequest.\n *\n * @param supplied - Rule options, optionally containing `stillwindOptions` encoded as base64url\n * JSON.\n * @returns Decoded options when `stillwindOptions` is present, otherwise the supplied object.\n * @throws If encoded configuration is not valid JSON.\n */\nexport function requestOptions(supplied: LoaderOptions): InlineConfig {\n return supplied.stillwindOptions\n ? JSON.parse(Buffer.from(supplied.stillwindOptions, \"base64url\").toString(\"utf8\"))\n : supplied;\n}\n\n/**\n * Creates a module request with forward slashes, relative to the importer when possible.\n *\n * @param from - Absolute directory containing the importing module.\n * @param to - Absolute path of the requested resource.\n * @returns A relative request with `./` when needed, or an absolute path across Windows volumes.\n */\nexport function relativeRequest(from: string, to: string): string {\n const value = path.relative(from, to).replaceAll(\"\\\\\", \"/\");\n return path.isAbsolute(value) || value.startsWith(\".\") ? value : `./${value}`;\n}\n\n/**\n * Creates a CSS projection or CSS value request that retains the producer configuration.\n *\n * SFC requests bypass other loaders. Naming callbacks use a registered rule identifier because JSON\n * cannot encode functions.\n *\n * @param resourcePath - Absolute path of the original producer.\n * @param sfc - Whether the producer is an Astro, Svelte, or Vue file.\n * @param config - Compiler config used for the original producer.\n * @param loaderPath - Absolute path of the producer loader.\n * @param query - Stillwind query text without a leading `?`.\n * @param identityConfig - Original inline settings registered on the loader rule. When evaluated\n * config contains naming callbacks, this selects that rule instead of serializing callbacks.\n * Defaults to config when file evaluation has not changed the registered settings.\n * @returns A relative resource request for scripts, or an inline loader request for SFCs.\n * @throws If SFC settings cannot be serialized for their inline request.\n */\nexport function virtualRequest(\n resourcePath: string,\n sfc: boolean,\n config: BuildConfig,\n loaderPath: string,\n query: string,\n identityConfig: InlineConfig = config,\n): string {\n if (!sfc) {\n return `${relativeRequest(path.dirname(resourcePath), resourcePath)}?${query}`;\n }\n\n const configuration = config.naming\n ? \"??\" + loaderOptionsId(identityConfig)\n : \"?stillwindOptions=\" + Buffer.from(JSON.stringify(config)).toString(\"base64url\");\n return `!!${loaderPath.replaceAll(\"\\\\\", \"/\")}${configuration}!${resourcePath.replaceAll(\"\\\\\", \"/\")}?${query}`;\n}\n","import { createHash } from \"node:crypto\";\nimport path from \"node:path\";\n\nimport { cleanModuleId, fileModuleDescriptor } from \"@stillwind/host\";\n\n/**\n * Keeps each query-selected derivative's compiler, checker, and source-map identities distinct.\n *\n * @param root - Absolute project root used to derive compiler identities.\n * @param id - Full source identity, including any query or fragment selecting transformed source.\n * @returns Ordinary file metadata without a suffix, or distinct module/document identities and a hashed checker filename.\n */\nexport function sourceDescriptor(root: string, id: string) {\n const descriptor = fileModuleDescriptor(root, id);\n const file = cleanModuleId(id);\n const suffix = id.slice(file.length);\n if (!suffix) {\n return descriptor;\n }\n const extension = path.extname(file);\n const key = createHash(\"sha256\").update(id).digest(\"hex\");\n const checkerFileName = path.join(\n path.dirname(file),\n `.${path.basename(file, extension)}.stillwind-${key}${extension}`,\n );\n return {\n ...descriptor,\n moduleId: descriptor.moduleId + suffix,\n document: {\n ...descriptor.document,\n uri: descriptor.document.uri + suffix,\n },\n checkerFileName,\n projectionFileName: checkerFileName.replaceAll(\"\\\\\", \"/\"),\n };\n}\n","import { createHash } from \"node:crypto\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nimport {\n cleanModuleId,\n cssWithSourceMap,\n warnRejectedNames,\n type CssUpstreamMap,\n} from \"@stillwind/host\";\n\nimport { warnSkippedCss } from \"../session.ts\";\nimport type { ProducerInput } from \"./emission.ts\";\nimport type { CompilationHost } from \"./host.ts\";\nimport type { SharedProject } from \"./project.ts\";\nimport { relativeRequest } from \"./requests.ts\";\nimport { sourceDescriptor } from \"./sources.ts\";\n\n/**\n * Renders document CSS for a completed compilation from the producers that it recorded.\n *\n * A producer is compiled again only when the shared compiler holds no loader compilation of its\n * current source. Manual producers are compiled for dependency composition but are excluded from\n * the document selection.\n *\n * @param producers - Nonempty list of producers from the completed graph. Every producer must use\n * the same root and config.\n * @param io - Compilation host that reads captured dependency sources and resolves scripts and\n * assets.\n * @param project - Shared project of the producers' design system, which no producer loader uses\n * meanwhile.\n * @param watch - Registers a file as a compilation dependency.\n * @param warn - Reports compiler warnings and the CSS statements that loading skipped through the\n * bundler.\n * @returns Document CSS with asset requests and an inline source map composed with recorded\n * upstream maps.\n * @throws If producers use different design systems, a dependency source is missing, or\n * compilation fails.\n */\nexport async function compilationStyles(\n producers: readonly ProducerInput[],\n io: CompilationHost,\n project: SharedProject,\n watch: (id: string) => void,\n warn: (message: string) => void,\n): Promise<string> {\n const { config, root } = producers[0];\n const { compiler, loaded, outputs } = project;\n const readDependency = io.dependencyReader(producers);\n warnSkippedCss(loaded.skipped, warn);\n const selection: string[] = [];\n for (const input of producers) {\n if (input.root !== root || JSON.stringify(input.config) !== JSON.stringify(config)) {\n throw new Error(\"A compilation must use one Stillwind design system\");\n }\n const previous = outputs.get(input.id);\n if (previous?.source === input.source) {\n if (previous.moduleId !== undefined && !input.manual) {\n selection.push(previous.moduleId);\n }\n continue;\n }\n const output = await compiler.compile(\n input.source,\n input.id,\n {\n describe: (id) => sourceDescriptor(root, id),\n resolve: async (specifier, importer) => ({\n id: await io.resolveJs(specifier, importer),\n }),\n read: readDependency,\n watch: (id) => {\n watch(cleanModuleId(id));\n },\n warn,\n },\n {\n moduleCssImport: \"stillwind/module-css\",\n },\n );\n outputs.set(input.id, { source: input.source, moduleId: output?.moduleId });\n if (output && !input.manual) {\n selection.push(output.moduleId);\n }\n }\n const revision = createHash(\"sha256\")\n .update(producers.map((input) => `${input.source}\\0`).join(\"\"))\n .digest(\"hex\");\n const plan = compiler.native.planStylesheet({\n modules: selection,\n coverage: {\n kind: \"complete\",\n target: \"compilation\",\n revision,\n },\n placement: \"document\",\n });\n warnRejectedNames(plan.rejectedNames, warn);\n const replacements = new Map<string, string>();\n for (const resource of [...loaded.resources, ...plan.resources]) {\n const owner =\n \"moduleId\" in resource ? compiler.resolverId(resource.moduleId) : resource.sourceName;\n const file = await io.resolveAsset(resource.specifier, owner);\n watch(file);\n const request = relativeRequest(\n path.dirname(fileURLToPath(import.meta.resolve(\"@stillwind/integration/webpack\"))),\n file,\n );\n replacements.set(resource.placeholder, JSON.stringify(request).slice(1, -1));\n }\n return cssWithSourceMap(\n plan,\n replacements,\n producers.flatMap((input) =>\n [\n input.upstream,\n ...(input.dependencies ?? []).map((dependency) => dependency.upstream),\n ].filter((upstream): upstream is CssUpstreamMap => Boolean(upstream)),\n ),\n );\n}\n","import fs from \"node:fs\";\nimport { isBuiltin } from \"node:module\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nimport { cleanModuleId, type UpstreamSourceMap } from \"@stillwind/host\";\n\nimport { nativeBindingFiles } from \"../binding-files.ts\";\nimport type { ProducerInput } from \"./emission.ts\";\n\n/**\n * Resolver policies passed to webpack or Rspack for CSS, script, and asset imports.\n */\nexport interface ResolveSettings {\n /** Dependency category used to select bundler resolution behavior, such as `esm`. */\n dependencyType?: string;\n /** Package export conditions considered when resolving a request. */\n conditionNames?: string[];\n /** File extensions tested for extensionless requests, in resolution order. */\n extensions?: string[];\n /** Package metadata fields considered in resolution order. */\n mainFields?: string[];\n}\n\n/**\n * Completion handler for webpack or Rspack resolution.\n *\n * @param error - Resolution failure, or null or undefined when no error occurred.\n * @param id - Resolved resource identity. A missing or false ID declines the request.\n */\nexport type ResolveCallback = (error?: Error | null, id?: string | false) => void;\n\n/**\n * Resolver bound to the bundler's configured conditions, extensions, and package fields.\n *\n * @param directory - Absolute directory of the importing file.\n * @param specifier - Import or resource request text, including any query suffix.\n * @param callback - Receives the resolution failure or resulting resource identity.\n */\nexport type Resolver = (directory: string, specifier: string, callback: ResolveCallback) => void;\n\n/**\n * Bundler filesystem and resolver operations shared by producer loaders and CSS reconstruction.\n */\nexport interface ResolverHost {\n /** Bundler input filesystem. Reads may return UTF-8 text or bytes through the callback. */\n fs: {\n /**\n * Reads through the bundler filesystem rather than bypassing its virtual files.\n *\n * @param id - Filesystem identity without a resource query.\n * @param callback - Receives an error or file contents. Callers convert successful contents to text.\n */\n readFile(id: string, callback: (error?: Error | null, value?: string | Buffer) => void): void;\n };\n /**\n * Creates a callback resolver with the requested dependency policy.\n *\n * @param settings - Conditions, extensions, and package fields used for this resolver.\n * @returns A resolver accepting the importer directory, request text, and a completion callback.\n */\n getResolve(settings: ResolveSettings): Resolver;\n}\n\n/**\n * Loader operations required to resolve producers, capture transformed dependencies, and report\n * compilation inputs.\n */\ninterface LoaderHostContext extends ResolverHost {\n /**\n * Complete loader chain. Entries after `loaderIndex` run before Stillwind in the normal loader\n * phase.\n */\n loaders: readonly {\n /** Complete inline loader request, including its options, reused for dependency capture. */\n request: string;\n }[];\n /** Index of the currently executing Stillwind loader within `loaders`. */\n loaderIndex: number;\n /**\n * Evaluates a generated capture module through the specified loader chain.\n *\n * @param request - Inline request whose capture loader exports source and map instead of\n * executing application code.\n * @returns A promise for the generated capture module exports.\n */\n importModule(request: string): Promise<unknown>;\n /**\n * Registers a source or compiler file as a dependency of this loader result.\n *\n * @param id - Absolute filesystem path without a resource query.\n */\n addDependency(id: string): void;\n /**\n * Reports a compilation warning through the loader context.\n *\n * @param error - Warning represented as an Error instance.\n */\n emitWarning(error: Error): void;\n}\n\n/**\n * Source and map exported by the capture loader after preceding framework transforms.\n */\nexport interface CapturedDependency {\n /** Transformed source text consumed by the compiler, without executing its application code. */\n source: string;\n /** Upstream map supplied by preceding loaders, or null when none was supplied. */\n map: UpstreamSourceMap;\n}\n\n/**\n * Compiler operations and retained dependency captures for one producer loader invocation.\n */\nexport interface LoaderHost {\n /**\n * Reads a resource through the bundler input filesystem.\n *\n * @param id - Readable filesystem path without a query.\n * @returns A promise for the file contents converted to a string.\n */\n read: (id: string) => Promise<string>;\n /**\n * Reads ordinary files or captures query-qualified source through preceding loaders.\n *\n * @param dependency - Full resolver identity, including any query suffix.\n * @returns A promise for source text, rejecting if reading or capture fails.\n */\n readDependency: (dependency: string) => Promise<string>;\n /**\n * Pending transformed-source captures keyed by full resolver identity, retained for emission\n * metadata.\n */\n dependencySources: Map<string, Promise<CapturedDependency>>;\n /**\n * Resolves a CSS import using style export conditions and CSS extensions.\n *\n * @param specifier - CSS import text.\n * @param importer - Absolute path of the importing stylesheet.\n * @returns A promise for the resolved identity, or an empty string when the resolver declines it.\n */\n resolveCss: (specifier: string, importer: string) => Promise<string>;\n /**\n * Resolves an asset using the bundler's default resolution policy.\n *\n * @param specifier - Asset request text.\n * @param importer - Absolute identity of the resource owner.\n * @returns A promise for the resolved identity, or an empty string when the resolver declines it.\n */\n resolveAsset: (specifier: string, importer: string) => Promise<string>;\n /**\n * Resolves a script dependency and marks Node builtins as external.\n *\n * @param specifier - Script import text, optionally naming a Node builtin.\n * @param importer - Absolute identity of the importing producer.\n * @returns A promise for the resolved identity and optional external status, or null when the\n * resolver declines the request. Other resolution errors reject the promise.\n */\n resolve: (\n specifier: string,\n importer: string,\n ) => Promise<{\n /** Full resolved source identity or Node builtin name. */\n id: string;\n /** Whether semantic traversal must skip loading the dependency as source. */\n external?: boolean;\n } | null>;\n /**\n * Registers the underlying file of a resolver identity as a loader dependency.\n *\n * @param id - File identity, optionally including a resource query that is removed before\n * registration.\n */\n watch: (id: string) => void;\n /**\n * Reports a compiler warning through the loader context.\n *\n * @param message - Warning text converted to an Error instance for the bundler.\n */\n warn: (message: string) => void;\n}\n\n/**\n * Creates compiler operations from a producer loader context and tracks the loader itself as a\n * dependency.\n *\n * Ordinary dependencies are read from the filesystem. Query-qualified dependencies pass through\n * preceding loaders and the capture loader. Pending captures are reused by their full resolver\n * identity.\n *\n * @param context - Active loader context with a complete loader chain and an `importModule`\n * implementation for query-qualified dependencies.\n * @param loaderPath - Absolute path of the Stillwind loader to register as a dependency.\n * @returns A host that resolves imports, reads files, captures transformed dependencies, and\n * forwards warnings.\n */\nexport function createLoaderHost(context: LoaderHostContext, loaderPath: string): LoaderHost {\n const read = createReadFile(context.fs);\n const dependencySources = new Map<string, Promise<CapturedDependency>>();\n /**\n * Reads an ordinary dependency or captures transformed text through preceding loaders.\n *\n * @param dependency - Full resolver identity. A query or fragment requires a loader capture.\n * @returns File text or captured text. Capture promises, including failures, are retained by identity.\n * @throws If filesystem reading or the dependency's loader chain fails.\n */\n const readDependency = async (dependency: string) => {\n if (cleanModuleId(dependency) === dependency) {\n return read(dependency);\n }\n let pending = dependencySources.get(dependency);\n if (!pending) {\n const capture = fileURLToPath(\n new URL(\"./source-loader.js\", import.meta.resolve(\"@stillwind/integration/webpack\")),\n );\n const preceding = context.loaders\n .slice(context.loaderIndex + 1)\n .map((loader) => loader.request);\n pending = context.importModule(\n `!!${[capture, ...preceding, dependency].join(\"!\")}`,\n ) as Promise<CapturedDependency>;\n dependencySources.set(dependency, pending);\n }\n return (await pending).source;\n };\n /**\n * Adapts loader resolution to requests relative to a source file.\n *\n * @param settings - Resolution policy passed to the loader's resolver factory.\n * @returns An asynchronous resolver accepting a specifier and full importer identity. Resolver\n * errors reject its promise, and a missing result becomes an empty string.\n */\n const resolver = (settings: ResolveSettings) => {\n const resolve = context.getResolve(settings);\n return (specifier: string, importer: string) =>\n new Promise<string>((done, reject) =>\n resolve(path.dirname(cleanModuleId(importer)), specifier, (error, id) =>\n error ? reject(error) : done(id || \"\"),\n ),\n );\n };\n const resolveCss = resolver(cssResolveOptions);\n const resolveJs = resolver({\n dependencyType: \"esm\",\n extensions: [\".tsx\", \".ts\", \".jsx\", \".js\", \".mjs\", \".cjs\", \".json\"],\n });\n const resolveAsset = resolver({});\n /**\n * Registers a filesystem dependency for loader invalidation.\n *\n * @param id - Full resolver identity whose query and fragment are removed before registration.\n */\n const watch = (id: string) => context.addDependency(cleanModuleId(id));\n watch(loaderPath);\n return {\n read,\n readDependency,\n dependencySources,\n resolveCss,\n resolveAsset,\n resolve: async (specifier: string, importer: string) => {\n if (specifier.startsWith(\"node:\") && isBuiltin(specifier)) {\n return { id: specifier, external: true };\n }\n try {\n const id = await resolveJs(specifier, importer);\n return id ? { id } : null;\n } catch (error) {\n if (isBuiltin(specifier)) {\n return { id: specifier, external: true };\n }\n throw error;\n }\n },\n watch,\n warn: (message: string) => context.emitWarning(new Error(message)),\n };\n}\n\n/**\n * Registers compiler runtime files so changes invalidate cached loader results.\n *\n * The function includes native binding files and JavaScript files beside the published host\n * entrypoint.\n *\n * @param watch - Registers an absolute file path as a loader dependency.\n * @throws If the host runtime directory cannot be read.\n */\nexport function watchCompilerFiles(watch: (id: string) => void): void {\n for (const file of nativeBindingFiles()) {\n watch(file);\n }\n const directory = path.dirname(fileURLToPath(import.meta.resolve(\"@stillwind/host\")));\n for (const file of fs.readdirSync(directory)) {\n if (file.endsWith(\".js\")) {\n watch(path.join(directory, file));\n }\n }\n}\n\n/**\n * File and resolver operations used after producer modules have completed compilation.\n */\nexport interface CompilationHost {\n /**\n * Reads the underlying file through the bundler input filesystem.\n *\n * @param id - Resolver identity whose query suffix is removed before reading.\n * @returns A promise for the file contents converted to a string.\n */\n read: (id: string) => Promise<string>;\n /**\n * Creates a reader that prefers captured producer and dependency sources over filesystem reads.\n *\n * @param producers - Producer metadata collected from the completed compilation graph.\n * @returns A reader keyed by full resolver identity. Missing query-qualified captures reject.\n * Ordinary uncaptured files are read through the filesystem.\n */\n dependencyReader: (producers: readonly ProducerInput[]) => (id: string) => Promise<string>;\n /**\n * Resolves an import from the design-system CSS graph.\n *\n * @param specifier - CSS import text.\n * @param importer - Absolute path of the importing stylesheet.\n * @returns A promise for the resolver's file identity, rejecting on resolution errors.\n */\n resolveCss: (specifier: string, importer: string) => Promise<string>;\n /**\n * Resolves a producer dependency, including supported framework source extensions.\n *\n * @param specifier - Script or framework import text.\n * @param importer - Absolute identity of the importing producer.\n * @returns A promise for the resolver's identity, retaining resource queries.\n */\n resolveJs: (specifier: string, importer: string) => Promise<string>;\n /**\n * Resolves a stylesheet asset using the bundler's default resolution policy.\n *\n * @param specifier - Asset request text.\n * @param importer - Absolute identity of the stylesheet or producer that owns the resource.\n * @returns A promise for the resolver's identity, rejecting on resolution errors.\n */\n resolveAsset: (specifier: string, importer: string) => Promise<string>;\n}\n\n/**\n * Creates filesystem and resolution operations for reconstructing a completed compilation.\n *\n * Reconstruction resolves framework source files as well as scripts. Query-qualified dependency\n * reads require captured source from producer metadata.\n *\n * @param context - Bundler input filesystem and resolver factory operations.\n * @returns A host that reads files and builds dependency readers from retained producer metadata.\n */\nexport function createCompilationHost(context: ResolverHost): CompilationHost {\n const read = createReadFile(context.fs, cleanModuleId);\n /**\n * Adapts compilation resolution to requests relative to a source file.\n *\n * @param settings - Resolution policy passed to the bundler's resolver factory.\n * @returns An asynchronous resolver accepting a specifier and full importer identity. It forwards\n * successful resolver results without checking for an absent identity, and rejects resolver errors.\n */\n const resolver = (settings: ResolveSettings) => {\n const resolve = context.getResolve(settings);\n return (specifier: string, importer: string) =>\n new Promise<string>((done, reject) =>\n resolve(path.dirname(cleanModuleId(importer)), specifier, (error, id) =>\n error ? reject(error) : done(id as string),\n ),\n );\n };\n return {\n read,\n /**\n * Creates a reader using source captured by the completed module graph.\n *\n * @param producers - Producer and dependency records. Later records replace earlier text for the same identity.\n * @returns A reader that uses exact captured identities before falling back to ordinary filesystem reads.\n */\n dependencyReader(producers: readonly ProducerInput[]) {\n const sources = new Map<string, string>();\n for (const input of producers) {\n sources.set(input.id, input.source);\n for (const dependency of input.dependencies ?? []) {\n sources.set(dependency.id, dependency.source);\n }\n }\n return (id: string) => {\n if (sources.has(id)) {\n return Promise.resolve(sources.get(id)!);\n }\n if (cleanModuleId(id) !== id) {\n return Promise.reject(new Error(`No transformed source captured for ${id}`));\n }\n return read(id);\n };\n },\n resolveCss: resolver(cssResolveOptions),\n resolveJs: resolver({\n dependencyType: \"esm\",\n extensions: [\".tsx\", \".ts\", \".jsx\", \".js\", \".mjs\", \".cjs\", \".vue\", \".svelte\", \".astro\"],\n }),\n resolveAsset: resolver({}),\n };\n}\n\n/**\n * CSS resolution policy that prefers style exports and metadata fields before ordinary package\n * entrypoints.\n */\nconst cssResolveOptions = {\n conditionNames: [\"style\", \"import\", \"default\"],\n extensions: [\".css\"],\n mainFields: [\"style\", \"main\"],\n};\n\n/**\n * Adapts the bundler filesystem to asynchronous string reads.\n *\n * @param filesystem - Input filesystem that completes reads through a callback.\n * @param fileId - Maps resolver identities to readable paths. Defaults to keeping the identity\n * unchanged.\n * @returns A reader that resolves to the filesystem value converted to a string, or rejects on read\n * failure.\n */\nfunction createReadFile(filesystem: ResolverHost[\"fs\"], fileId = (id: string) => id) {\n return (id: string) =>\n new Promise<string>((resolve, reject) =>\n filesystem.readFile(fileId(id), (error, value) =>\n error ? reject(error) : resolve(String(value)),\n ),\n );\n}\n","/**\n * Shares one loaded design system and compiler session between the producer loader calls and the\n * document CSS reconstruction of a webpack or Rspack compiler.\n *\n * The main entry point is {@link useProject}.\n */\nimport path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\n\nimport type { BuildConfig } from \"@stillwind/config\";\nimport type { ProjectScope } from \"@stillwind/config/node\";\nimport { cssEntrypoint, loadCssGraph, nodePluginHost, type LoadedCssGraph } from \"@stillwind/host\";\n\nimport { LoaderCache, recordInputs, type InputReader } from \"../loader-cache.ts\";\nimport { buildCompilerOptions, IntegrationSession } from \"../session.ts\";\nimport { buildSourceEntries, isSourceEntry } from \"../source-entries.ts\";\n\n/**\n * Compiler operations of webpack and Rspack that a shared project uses.\n */\nexport interface ProjectCompiler {\n /** Top compiler of a child compiler. Child compilers use the projects of their top compiler. */\n root?: ProjectCompiler;\n /** Application directory against which relative entry requests resolve. */\n context?: string;\n /** Whether the compiler runs in watch mode, so that later compilations follow file changes. */\n watchMode?: boolean;\n /** Absolute paths that changed or were added since the previous compilation of a watch run. */\n modifiedFiles?: ReadonlySet<string>;\n /** Absolute paths that were removed since the previous compilation of a watch run. */\n removedFiles?: ReadonlySet<string>;\n /** Normalized entry settings. A function selects entries at compilation time. */\n options?: {\n /** Entry descriptions keyed by name, or a function. */\n entry?: unknown;\n };\n /** Hooks that end the compiler's use of its shared projects. */\n hooks: {\n /** Runs after each compilation finishes. */\n done: {\n /**\n * @param name - Plugin registration name.\n * @param callback - Operation run after the compilation.\n */\n tap(name: string, callback: () => void): void;\n };\n /** Runs when the compiler closes. Absent in compilers without a shutdown hook. */\n shutdown?: {\n /**\n * @param name - Plugin registration name.\n * @param callback - Operation run when the compiler closes.\n */\n tap(name: string, callback: () => void): void;\n };\n };\n}\n\n/**\n * Loader context operations that {@link useProject} uses.\n */\nexport interface ProjectContext {\n /** Compiler that runs the loader, or undefined outside a webpack or Rspack compilation. */\n _compiler?: ProjectCompiler;\n /** Compilation that runs the loader, used to apply each compilation's file changes once. */\n _compilation?: object;\n /**\n * Registers a file whose changes invalidate this loader result.\n *\n * @param id - Absolute file path.\n */\n addDependency(id: string): void;\n /**\n * Registers a missing file whose creation invalidates this loader result.\n *\n * @param id - Absolute file path.\n */\n addMissingDependency(id: string): void;\n /**\n * Registers a directory whose listing affects this loader result.\n *\n * @param id - Absolute directory path.\n */\n addContextDependency(id: string): void;\n}\n\n/** File operations of one loader call that loading the CSS graph uses. */\nexport interface ProjectHost {\n /**\n * Reads a file through the bundler filesystem.\n *\n * @param id - Absolute file path.\n * @returns A promise for the file text, rejecting when the file cannot be read.\n */\n read: (id: string) => Promise<string>;\n /**\n * Resolves a CSS import.\n *\n * @param specifier - CSS import text.\n * @param importer - Absolute path of the importing stylesheet.\n * @returns A promise for the resolved path, or an empty string when the resolver declines it.\n */\n resolveCss: (specifier: string, importer: string) => Promise<string>;\n}\n\n/**\n * Design system and compiler that loader calls with equal settings share.\n */\nexport interface SharedProject {\n /** Completed CSS graph and authored resources used by the compiler. */\n loaded: LoadedCssGraph;\n /** Compiler that concurrent loader calls use. The caller must not close it. */\n compiler: IntegrationSession;\n /** Compilations whose file changes the compiler has received. */\n applied: WeakSet<object>;\n /**\n * Last loader compilation of each producer, keyed by full resolver identity. Document CSS\n * reconstruction compiles a producer again only when its source differs.\n */\n outputs: Map<string, ProducerOutput>;\n}\n\n/**\n * Result of a producer loader compilation that the compiler session still holds.\n */\nexport interface ProducerOutput {\n /** Source text that the compilation received. */\n source: string;\n /** Compiler module ID, or undefined when the compilation produced no code. */\n moduleId?: string;\n}\n\n/**\n * Shared projects of each compiler, keyed by settings. A compiler's projects never serve another\n * compiler, because two compilers can resolve the same import differently.\n */\nconst projects = new WeakMap<object, LoaderCache<SharedProject>>();\n\n/** Shared projects of loader calls that run outside a compiler. */\nconst detachedProjects = new LoaderCache<SharedProject>(closeProject, 30_000);\n\n/**\n * Closes the checker of a shared project and discards its prepared sources. The project stays\n * usable, and a later compilation starts a new checker.\n *\n * @param project - Project whose checker to close.\n */\nfunction closeProject(project: SharedProject): void {\n project.compiler.close();\n}\n\n/**\n * Returns the project cache of a compiler, creating it on first use.\n *\n * A build closes idle checkers after each compilation, because no later compilation of the run\n * uses them. A watch run keeps them until the compiler closes or they stay idle for 30 seconds.\n *\n * @param compiler - Compiler that runs the loader.\n * @returns The compiler's cache.\n */\nfunction compilerProjects(compiler: ProjectCompiler): LoaderCache<SharedProject> {\n let cache = projects.get(compiler);\n if (!cache) {\n const created = new LoaderCache<SharedProject>(closeProject, 30_000);\n cache = created;\n projects.set(compiler, created);\n compiler.hooks.done.tap(\"StillwindProject\", () => {\n if (!compiler.watchMode) {\n created.closeIdle();\n }\n });\n compiler.hooks.shutdown?.tap(\"StillwindProject\", () => created.closeIdle());\n }\n return cache;\n}\n\n/**\n * Lists the entry files of a compiler that are local script or component files.\n *\n * @param compiler - Compiler whose normalized entry settings to read.\n * @returns Absolute paths of the relative and absolute entry requests. Package requests and\n * entries that a function selects are not listed.\n */\nfunction compilerEntries(compiler: ProjectCompiler): string[] {\n const entry = compiler.options?.entry;\n if (!entry || typeof entry !== \"object\") {\n return [];\n }\n const context = compiler.context ?? process.cwd();\n return Object.values(entry).flatMap((description: unknown) => {\n const requests = (description as { import?: unknown } | null)?.import;\n return (Array.isArray(requests) ? requests : []).flatMap((request: unknown) =>\n typeof request === \"string\" &&\n (request.startsWith(\".\") || path.isAbsolute(request)) &&\n isSourceEntry(request)\n ? [path.resolve(context, request)]\n : [],\n );\n });\n}\n\n/**\n * Loads the design system and compiler for a producer loader call, or reuses them.\n *\n * Calls of one compiler share them while the configuration and the CSS files stay unchanged. In a\n * build, the compiler loads the source files of the entries and of the selected project into one\n * checker before its first compilation. In a watch run, each compilation reports the files that\n * webpack or Rspack saw change to the compiler first. CSS dependencies are registered with the\n * loader context of every call.\n *\n * @param context - Loader context that supplies the compiler and dependency registration.\n * @param scope - Target globs of the selected project, or undefined when no configuration file\n * selects a project.\n * @param config - Evaluated compiler settings.\n * @param root - Absolute project root.\n * @param mode - Native compilation mode.\n * @param host - File reads and CSS resolution of this call. Later calls reuse only the loaded\n * graph, which does not read or resolve CSS again.\n * @returns A lease for the shared project. The caller must end it after its last use.\n * @throws If reading the recorded inputs fails, the CSS graph cannot be loaded, or compiler\n * initialization fails.\n */\nexport async function useProject(\n context: ProjectContext,\n scope: ProjectScope | undefined,\n config: BuildConfig,\n root: string,\n mode: string,\n host: ProjectHost,\n) {\n const compiler = context._compiler?.root ?? context._compiler;\n const cache = compiler ? compilerProjects(compiler) : detachedProjects;\n const probe: InputReader = (id) =>\n host.read(id).catch((error: NodeJS.ErrnoException) => {\n if (error.code === \"ENOENT\" || error.code === \"ENOTDIR\") {\n return undefined;\n }\n throw error;\n });\n const lease = await cache.use(JSON.stringify([config, root, mode]), probe, async () => {\n const recorder = recordInputs(probe);\n const loaded = await loadCssGraph(\n path.resolve(root, cssEntrypoint(config)),\n buildCompilerOptions(config),\n {\n resolve: host.resolveCss,\n read: recorder.read,\n documentUri: (id) => pathToFileURL(id).href,\n sourceMapSource: (id) => pathToFileURL(id).href,\n watch: recorder.watch,\n watchDirectory: recorder.watchDirectory,\n plugins: nodePluginHost,\n },\n undefined,\n undefined,\n {\n plugins: config.plugins,\n tailwind: config.tailwind,\n important: config.important,\n root,\n },\n );\n // Without a compiler, no report says which files change, so each compilation reads the files\n // again.\n const entries = compiler\n ? await buildSourceEntries(compilerEntries(compiler), scope)\n : undefined;\n const watching = Boolean(compiler?.watchMode);\n const value: SharedProject = {\n loaded,\n compiler: new IntegrationSession(\n root,\n loaded.loader,\n config,\n false,\n mode,\n loaded.plugins,\n watching ? undefined : entries,\n watching ? entries : undefined,\n ),\n applied: new WeakSet(),\n outputs: new Map(),\n };\n return { value, inputs: await recorder.finish() };\n });\n const { applied, compiler: session } = lease.value;\n const compilation = context._compilation;\n if (compiler?.watchMode && compilation && !applied.has(compilation)) {\n applied.add(compilation);\n for (const file of compiler.removedFiles ?? []) {\n session.sourceChanged(file, true);\n }\n for (const file of compiler.modifiedFiles ?? []) {\n if (!/\\.(?:[cm]?[jt]sx?|json|astro|svelte|vue)$/.test(file)) {\n continue;\n }\n // The compiler reports added files as modified. An added file can change how an import\n // resolves, so a file that no prepared source holds counts as added.\n session.sourceChanged(file, !session.holdsSource(file));\n }\n }\n for (const file of lease.inputs.files.keys()) {\n context.addDependency(file);\n }\n for (const file of lease.inputs.missing) {\n context.addMissingDependency(file);\n }\n for (const directory of lease.inputs.directories) {\n context.addContextDependency(directory);\n }\n return lease;\n}\n","import type { BuildConfig } from \"@stillwind/config\";\nimport type { ResolvedIntegrationConfig } from \"@stillwind/config/node\";\nimport type { CssUpstreamMap } from \"@stillwind/host\";\n\nimport { compilationStyles } from \"./compilation-styles.ts\";\nimport { createCompilationHost, type ResolverHost } from \"./host.ts\";\nimport { useProject, type ProjectCompiler } from \"./project.ts\";\n\n/**\n * A producer and its captured dependencies stored in bundler metadata for CSS reconstruction.\n */\nexport interface ProducerInput {\n /** Source text received by the producer loader, before Stillwind compilation. */\n source: string;\n /** Producer identity. Query-qualified script dependencies retain their query suffix. */\n id: string;\n /** Absolute project root against which compiler module identities are resolved. */\n root: string;\n /** Compiler configuration shared by every producer in this compilation. */\n config: BuildConfig;\n /**\n * Whether this producer is excluded from automatic document CSS and supplies explicit CSS values.\n */\n manual: boolean;\n /** Map from loader input back to the original source, used when composing final CSS maps. */\n upstream?: CssUpstreamMap;\n /**\n * Transformed dependencies captured through the loader chain. Cached metadata retains them for\n * reconstruction.\n */\n dependencies?: {\n /** Complete resolver identity, including the query that selected the transformed dependency. */\n id: string;\n /** Source produced by the loaders that ran before Stillwind. */\n source: string;\n /**\n * Map from the captured source back to its original source, when the preceding loaders supplied\n * one.\n */\n upstream?: CssUpstreamMap;\n }[];\n}\n\n/**\n * Stores a producer in module build metadata so cached modules can participate in CSS\n * reconstruction.\n *\n * @param context - Loader context for a module in a compilation registered by `StillwindPlugin`.\n * @param input - Producer source, compiler configuration, and captured dependency sources.\n * @throws If the compilation has no registered emission hook or the loader context has no module.\n */\nexport function recordProducer<Module extends EmissionModule>(\n context: EmissionContext<Module>,\n input: ProducerInput,\n): void {\n requireEmission(context);\n if (!context._module) {\n throw new Error(incompleteGraphMessage);\n }\n context._module.buildInfo ??= {};\n context._module.buildInfo.stillwind = input;\n}\n\n/**\n * Bundler module metadata used to recover cached producer inputs and identify the shared document\n * CSS carrier.\n */\nexport interface EmissionModule {\n /** Resource path and query used to identify the shared document CSS carrier. */\n resource?: string;\n /** Build metadata retained by the bundler when a module is reused from cache. */\n buildInfo?: {\n /** Producer input reconstructed after the compilation graph is complete. */\n stillwind?: ProducerInput;\n /** Build fields owned by the bundler or other plugins, retained without interpretation. */\n [key: string]: unknown;\n };\n}\n\n/**\n * Compilation operations required to collect producers and rebuild document CSS carriers.\n */\nexport interface EmissionCompilation<Module extends EmissionModule = EmissionModule> {\n /** Parent compilation used by CSS extraction loaders that run a child compiler. */\n compiler?: {\n parentCompilation?: EmissionCompilation<Module>;\n };\n /** Settings evaluated by StillwindPlugin before the build run, reused by producer loaders. */\n __stillwindConfiguration?: ResolvedIntegrationConfig;\n /** Missing configuration candidates whose creation must trigger a watch rebuild. */\n missingDependencies: {\n /**\n * Registers a missing path so its creation invalidates this compilation.\n *\n * @param id - Absolute missing configuration candidate.\n * @returns The bundler collection's insertion result, which Stillwind ignores.\n */\n add(id: string): unknown;\n };\n /** Cached and newly built modules. The graph is complete when `finishMake` runs. */\n modules: Iterable<Module>;\n /** Files whose changes invalidate reconstructed CSS. */\n fileDependencies: {\n /**\n * Adds a compiler or source file to watch tracking.\n *\n * @param id - Absolute dependency path.\n * @returns The bundler collection's insertion result, which Stillwind ignores.\n */\n add(id: string): unknown;\n };\n /** Directories whose entry additions and removals invalidate reconstructed CSS. */\n contextDependencies: {\n /**\n * Adds a directory that a plugin lists to watch tracking.\n *\n * @param id - Absolute directory path.\n * @returns The bundler collection's insertion result, which Stillwind ignores.\n */\n add(id: string): unknown;\n };\n /** Bundler warning collection receiving compiler lint and rejected-name messages. */\n warnings: {\n /**\n * Appends a warning without failing reconstruction.\n *\n * @param error - Warning represented as an Error instance.\n * @returns The collection's append result, which Stillwind ignores.\n */\n push(error: Error): unknown;\n };\n /**\n * Reruns a document carrier after reconstructed CSS has been stored on the compilation.\n *\n * @param module - Carrier from the completed module graph.\n * @param callback - Completion handler receiving an error when rebuilding fails.\n */\n rebuildModule(module: Module, callback: (error?: Error | null) => void): void;\n /**\n * Reconstructed document CSS, optionally including an inline source map. Undefined before\n * reconstruction.\n */\n __stillwindCss?: string;\n}\n\n/**\n * Bundler context used to register emission and attach producer metadata to the current\n * compilation.\n */\nexport interface EmissionContext<\n Module extends EmissionModule = EmissionModule,\n> extends ResolverHost {\n /** Current compilation, required when recording producers or installing document CSS reconstruction. */\n _compilation?: EmissionCompilation<Module>;\n /** Compiler whose shared project document CSS reconstruction uses with the producer loaders. */\n _compiler?: ProjectCompiler;\n /** Current bundler module whose buildInfo retains producer metadata. */\n _module?: Module;\n /**\n * Bundler mode forwarded to CSS reconstruction. Only `development` selects development\n * compilation.\n */\n mode?: string;\n}\n\n/**\n * Registers CSS reconstruction for a compilation, which `reconstructDocumentCss` later runs.\n *\n * Registration is idempotent for a compilation. Reconstruction collects cached and newly built\n * producers, stores document CSS, and rebuilds each carrier through the host CSS pipeline.\n *\n * @param context - Context with a compilation, filesystem, and resolver. Register it before\n * producer loaders run.\n * @throws If the context has no compilation with a module graph.\n */\nexport function installEmission<Module extends EmissionModule>(\n context: EmissionContext<Module>,\n): void {\n const compilation = requireCompilation(context);\n if (reconstructions.has(compilation)) {\n return;\n }\n const io = createCompilationHost(context);\n reconstructions.set(compilation, async () => {\n const completed = [...compilation.modules];\n const producers = completed\n .map((module) => module.buildInfo?.stillwind)\n .filter((input): input is ProducerInput => Boolean(input));\n const carriers = completed.filter((module) =>\n module.resource?.includes(\"stillwind-webpack.css?stillwind-document\"),\n );\n if (!carriers.length || !producers.length) {\n return;\n }\n const { config, root } = producers[0];\n const project = await useProject(\n {\n _compiler: context._compiler,\n _compilation: compilation,\n addDependency: (id) => compilation.fileDependencies.add(id),\n addMissingDependency: (id) => compilation.missingDependencies.add(id),\n addContextDependency: (id) => compilation.contextDependencies.add(id),\n },\n compilation.__stillwindConfiguration?.scope,\n config,\n root,\n context.mode === \"development\" ? \"development\" : \"release\",\n io,\n );\n try {\n compilation.__stillwindCss = await compilationStyles(\n producers,\n io,\n project.value,\n (id) => {\n compilation.fileDependencies.add(id);\n },\n (message) => {\n compilation.warnings.push(new Error(message));\n },\n );\n } finally {\n project.done();\n }\n for (const carrier of carriers) {\n await new Promise<void>((resolve, reject) =>\n compilation.rebuildModule(carrier, (error) => (error ? reject(error) : resolve())),\n );\n }\n });\n}\n\n/**\n * Rebuilds the document CSS carriers of a compilation registered by `installEmission`.\n *\n * Call it from the compiler's `finishMake` hook. Rspack rejects `rebuildModule()` in\n * `finishModules` and later hooks.\n *\n * @param compilation - Compilation whose module graph is complete. Unregistered compilations,\n * such as child compilations, are ignored.\n * @returns Completion after every carrier has been rebuilt.\n * @throws If configuration, CSS reconstruction, or a carrier rebuild fails.\n */\nexport async function reconstructDocumentCss(compilation: object): Promise<void> {\n await reconstructions.get(compilation)?.();\n}\n\n/**\n * Reconstruction operations of registered compilations. Membership is required before automatic\n * loaders record producers.\n */\nconst reconstructions = new WeakMap<object, () => Promise<void>>();\n\nconst incompleteGraphMessage =\n \"Automatic Stillwind CSS requires new StillwindPlugin(config) before compilation begins\";\n\n/**\n * Obtains the compilation operations needed to reconstruct document CSS.\n *\n * @param context - Bundler context that must expose a compilation module graph.\n * @returns The compilation attached to the context.\n * @throws If the context cannot supply a completed compilation graph.\n */\nfunction requireCompilation<Module extends EmissionModule>(\n context: EmissionContext<Module>,\n): EmissionCompilation<Module> {\n const compilation = context._compilation;\n if (!compilation?.modules) {\n throw new Error(incompleteGraphMessage);\n }\n return compilation;\n}\n\n/**\n * Rejects automatic CSS requests when the compilation has no registered emission hook.\n *\n * @param context - Loader context associated with a compilation registered by `StillwindPlugin`.\n * @returns The nearest registered compilation holding reconstructed document CSS.\n * @throws If the compilation is missing or its emission hook has not been registered.\n */\nexport function requireEmission<Module extends EmissionModule>(\n context: EmissionContext<Module>,\n): EmissionCompilation<Module> {\n let compilation = requireCompilation(context);\n while (!reconstructions.has(compilation)) {\n const parent = compilation.compiler?.parentCompilation;\n if (!parent) {\n throw new Error(incompleteGraphMessage);\n }\n compilation = parent;\n }\n return compilation;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAaA,SAAgB,gBAAgB,QAA8B;CAC5D,OAAO,eAAe,WAAW,QAAQ,CAAC,CAAC,OAAO,KAAK,UAAU,MAAM,CAAC,CAAC,CAAC,OAAO,KAAK;AACxF;;;;;;;;;AAgCA,SAAgB,eAAe,QAAuC;CACpE,OAAO;EACL;GACE,MAAM;GACN,SAAS;GACT,SAAS;GACT,KAAK,CACH;IACE,QAAQ,cACN,IAAI,IAAI,eAAe,YAAY,QAAQ,gCAAgC,CAAC,CAC9E;IACA,SAAS;IACT,OAAO,gBAAgB,MAAM;GAC/B,CACF;EACF;EACA;GACE,MAAM;GACN,SAAS;GACT,SAAS;GACT,KAAK,CACH;IACE,QAAQ,cACN,IAAI,IAAI,eAAe,YAAY,QAAQ,gCAAgC,CAAC,CAC9E;IACA,SAAS;IACT,OAAO,gBAAgB,MAAM;GAC/B,CACF;EACF;EACA;GACE,MAAM;GACN,SAAS;GACT,KAAK,CACH,cACE,IAAI,IAAI,wBAAwB,YAAY,QAAQ,gCAAgC,CAAC,CACvF,CACF;EACF;EACA;GACE,MAAM;GACN,SAAS;GACT,KAAK,CACH,cACE,IAAI,IAAI,mBAAmB,YAAY,QAAQ,gCAAgC,CAAC,CAClF,CACF;EACF;EACA;GAEE,MAAM;GACN,SAAS;GACT,SAAS;GACT,KAAK,CACH,cACE,IAAI,IAAI,0BAA0B,YAAY,QAAQ,gCAAgC,CAAC,CACzF,CACF;EACF;CACF;AAC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M,kCAAkB,IAAI,QAAqC;AAEjE,MAAM,yBACJ;;;;;;;;AASF,SAAS,mBACP,SAC6B;CAC7B,MAAM,cAAc,QAAQ;CAC5B,IAAI,CAAC,aAAa,SAChB,MAAM,IAAI,MAAM,sBAAsB;CAExC,OAAO;AACT;;;;;;;;AASA,SAAgB,gBACd,SAC6B;CAC7B,IAAI,cAAc,mBAAmB,OAAO;CAC5C,OAAO,CAAC,gBAAgB,IAAI,WAAW,GAAG;EACxC,MAAM,SAAS,YAAY,UAAU;EACrC,IAAI,CAAC,QACH,MAAM,IAAI,MAAM,sBAAsB;EAExC,cAAc;CAChB;CACA,OAAO;AACT"}
@@ -1,4 +1,4 @@
1
- import { r as createViteProject, t as createVitePlugins } from "../plugin-DiebeZNj.js";
1
+ import { r as createViteProject, t as createVitePlugins } from "../plugin-CXT0YnEQ.js";
2
2
  // src/fresh/manifest.ts
3
3
  /** Filters repeated static files for Fresh's move operation without changing the emitted manifest. */
4
4
  function registrationManifest(source) {
@@ -167,19 +167,19 @@ function encode(decoded) {
167
167
  }
168
168
  return writer.flush();
169
169
  }
170
- // ../../node_modules/.pnpm/@jridgewell+resolve-uri@3.1.2/node_modules/@jridgewell/resolve-uri/dist/resolve-uri.mjs
170
+ // ../../node_modules/.pnpm/@jridgewell+resolve-uri@3.1.3/node_modules/@jridgewell/resolve-uri/dist/resolve-uri.mjs
171
171
  const schemeRegex = /^[\w+.-]+:\/\//;
172
172
  /**
173
173
  * Matches the parts of a URL:
174
174
  * 1. Scheme, including ":", guaranteed.
175
175
  * 2. User/password, including "@", optional.
176
- * 3. Host, guaranteed.
176
+ * 3. Host, including brackets around IP literals, guaranteed.
177
177
  * 4. Port, including ":", optional.
178
178
  * 5. Path, including "/", optional.
179
179
  * 6. Query, including "?", optional.
180
180
  * 7. Hash, including "#", optional.
181
181
  */
182
- const urlRegex = /^([\w+.-]+:)\/\/([^@/#?]*@)?([^:/#?]*)(:\d+)?(\/[^#?]*)?(\?[^#]*)?(#.*)?/;
182
+ const urlRegex = /^([\w+.-]+:)\/\/([^@/#?]*@)?(\[[^\]]+\]|[^:/#?]*)(:\d+)?(\/[^#?]*)?(\?[^#]*)?(#.*)?/;
183
183
  /**
184
184
  * File URLs are weird. They dont' need the regular `//` in the scheme, they may or may not start
185
185
  * with a leading `/`, they can have a domain (but only if they don't start with a Windows drive).
@@ -556,4 +556,4 @@ function skipSource(line, index, sourcesIndex, sourceLine, sourceColumn, namesIn
556
556
  }
557
557
  export { eachMapping as a, TraceMap as i, addSegment as n, toEncodedMap as r, GenMapping as t };
558
558
 
559
- //# sourceMappingURL=gen-mapping-D7jFzOEh.js.map
559
+ //# sourceMappingURL=gen-mapping-BXbstwwZ.js.map