@stillwind/integration 0.0.0-stage → 0.1.0-rc.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.
Files changed (103) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +67 -2
  3. package/dist/NPM-THIRD-PARTY-LICENSES +52 -0
  4. package/dist/astro/development.d.ts +15 -0
  5. package/dist/astro/development.js +34 -0
  6. package/dist/astro/development.js.map +1 -0
  7. package/dist/astro/index.d.ts +17 -0
  8. package/dist/astro/index.js +194 -0
  9. package/dist/astro/index.js.map +1 -0
  10. package/dist/astro/middleware.d.ts +2 -0
  11. package/dist/astro/middleware.js +64 -0
  12. package/dist/astro/middleware.js.map +1 -0
  13. package/dist/binding-files-Ds5NpyVV.js +45 -0
  14. package/dist/binding-files-Ds5NpyVV.js.map +1 -0
  15. package/dist/emission-BVi5aRbb.js +520 -0
  16. package/dist/emission-BVi5aRbb.js.map +1 -0
  17. package/dist/fresh/index.d.ts +10 -0
  18. package/dist/fresh/index.js +55 -0
  19. package/dist/fresh/index.js.map +1 -0
  20. package/dist/gen-mapping-D7jFzOEh.js +559 -0
  21. package/dist/gen-mapping-D7jFzOEh.js.map +1 -0
  22. package/dist/index-DFfbZxNT.d.ts +12 -0
  23. package/dist/next/css-loader.d.ts +14 -0
  24. package/dist/next/css-loader.js +58 -0
  25. package/dist/next/css-loader.js.map +1 -0
  26. package/dist/next/index.d.ts +15 -0
  27. package/dist/next/index.js +66 -0
  28. package/dist/next/index.js.map +1 -0
  29. package/dist/node-loader-D-3Ynpy1.d.ts +19 -0
  30. package/dist/nuxt/index.d.ts +13 -0
  31. package/dist/nuxt/index.js +64 -0
  32. package/dist/nuxt/index.js.map +1 -0
  33. package/dist/plugin-C_ZFfzo2.js +2572 -0
  34. package/dist/plugin-C_ZFfzo2.js.map +1 -0
  35. package/dist/plugin-aV0zIIAe.d.ts +278 -0
  36. package/dist/plugin-mPiBLdqa.js +79 -0
  37. package/dist/plugin-mPiBLdqa.js.map +1 -0
  38. package/dist/project-BNw0nZBE.d.ts +58 -0
  39. package/dist/project-C3IH7geC.js +182 -0
  40. package/dist/project-C3IH7geC.js.map +1 -0
  41. package/dist/project-DUGu8g_L.d.ts +15 -0
  42. package/dist/rsbuild/index.d.ts +28 -0
  43. package/dist/rsbuild/index.js +77 -0
  44. package/dist/rsbuild/index.js.map +1 -0
  45. package/dist/rspack/index.d.ts +3 -0
  46. package/dist/rspack/index.js +1 -0
  47. package/dist/rules-BvKsL2at.js +91 -0
  48. package/dist/rules-BvKsL2at.js.map +1 -0
  49. package/dist/session-B9_rp9TH.d.ts +72 -0
  50. package/dist/session-DHUCQMG5.js +117 -0
  51. package/dist/session-DHUCQMG5.js.map +1 -0
  52. package/dist/source-map-loader-CBLiYaBI.d.ts +128 -0
  53. package/dist/sveltekit/handle.d.ts +13 -0
  54. package/dist/sveltekit/handle.js +16 -0
  55. package/dist/sveltekit/handle.js.map +1 -0
  56. package/dist/trace-mapping-DV_eP3r7.d.ts +58 -0
  57. package/dist/turbopack/css-loader.d.ts +15 -0
  58. package/dist/turbopack/css-loader.js +44 -0
  59. package/dist/turbopack/css-loader.js.map +1 -0
  60. package/dist/turbopack/index.d.ts +54 -0
  61. package/dist/turbopack/index.js +1 -0
  62. package/dist/turbopack/loader.d.ts +13 -0
  63. package/dist/turbopack/loader.js +70 -0
  64. package/dist/turbopack/loader.js.map +1 -0
  65. package/dist/turbopack/node-loader.d.ts +2 -0
  66. package/dist/turbopack/node-loader.js +20 -0
  67. package/dist/turbopack/node-loader.js.map +1 -0
  68. package/dist/turbopack/stillwind-turbopack.css +0 -0
  69. package/dist/vite/index.d.ts +3 -0
  70. package/dist/vite/index.js +1 -0
  71. package/dist/vite/runtime-source-map.d.ts +19 -0
  72. package/dist/vite/runtime-source-map.js +106 -0
  73. package/dist/vite/runtime-source-map.js.map +1 -0
  74. package/dist/vite/runtime.d.ts +58 -0
  75. package/dist/vite/runtime.js +90 -0
  76. package/dist/vite/runtime.js.map +1 -0
  77. package/dist/webpack/css-loader.d.ts +17 -0
  78. package/dist/webpack/css-loader.js +36 -0
  79. package/dist/webpack/css-loader.js.map +1 -0
  80. package/dist/webpack/css-map-loader.d.ts +24 -0
  81. package/dist/webpack/css-map-loader.js +43 -0
  82. package/dist/webpack/css-map-loader.js.map +1 -0
  83. package/dist/webpack/document-loader.d.ts +12 -0
  84. package/dist/webpack/document-loader.js +19 -0
  85. package/dist/webpack/document-loader.js.map +1 -0
  86. package/dist/webpack/fragment-loader.d.ts +9 -0
  87. package/dist/webpack/fragment-loader.js +23 -0
  88. package/dist/webpack/fragment-loader.js.map +1 -0
  89. package/dist/webpack/index.d.ts +3 -0
  90. package/dist/webpack/index.js +1 -0
  91. package/dist/webpack/loader.d.ts +35 -0
  92. package/dist/webpack/loader.js +199 -0
  93. package/dist/webpack/loader.js.map +1 -0
  94. package/dist/webpack/source-loader.d.ts +11 -0
  95. package/dist/webpack/source-loader.js +17 -0
  96. package/dist/webpack/source-loader.js.map +1 -0
  97. package/dist/webpack/source-map-loader.d.ts +2 -0
  98. package/dist/webpack/source-map-loader.js +35 -0
  99. package/dist/webpack/source-map-loader.js.map +1 -0
  100. package/dist/webpack/stillwind-fragment.d.ts +1 -0
  101. package/dist/webpack/stillwind-fragment.js +1 -0
  102. package/dist/webpack/stillwind-webpack.css +1 -0
  103. package/package.json +133 -3
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime.js","names":[],"sources":["../../src/vite/runtime.ts"],"sourcesContent":["import type { EncodedSourceMap } from \"@jridgewell/trace-mapping\";\nimport { cssText } from \"stillwind/css\";\n\ntype StylesheetSourceMap = Readonly<\n Omit<EncodedSourceMap, \"names\" | \"sources\" | \"sourcesContent\" | \"ignoreList\">\n> & {\n readonly names: readonly string[];\n readonly sources: readonly (string | null)[];\n readonly sourcesContent?: readonly (string | null)[];\n readonly ignoreList?: readonly number[];\n};\n\n/** Ordered CSS partition activated by its producers or included unconditionally. */\nexport interface StylesheetPart {\n /** Preserved notices required by this part. */\n readonly banners?: readonly string[];\n /** CSS with resources already resolved for the browser. */\n readonly css: string;\n /** Compiler module ids that need this part; an empty list keeps it active unconditionally. */\n readonly producers: readonly string[];\n /** Map for this part. Null or omission means that no map is available. */\n readonly map?: StylesheetSourceMap | null;\n}\n\n/** Complete stylesheet and composition state published for one adapter revision. */\nexport interface StylesheetSnapshot {\n /** Monotonic revision within the adapter environment. */\n readonly revision: number;\n /** Partitions in stylesheet order, retained when filtering for active producers. */\n readonly parts: readonly StylesheetPart[];\n /** Composition dependencies keyed by compiler module id. */\n readonly dependencies: Readonly<Record<string, readonly string[]>>;\n}\n\ndeclare module \"vite\" {\n /** Extends Vite's typed HMR events with complete Stillwind stylesheet snapshots. */\n interface CustomEventMap {\n /** Stylesheet revision, ordered parts, and composition dependencies published by Stillwind. */\n \"stillwind:css\": StylesheetSnapshot;\n }\n}\n\n/** Mutable stylesheet state shared by runtime instances in the current global document context. */\ninterface DocumentState {\n /** Latest accepted revision. -1 identifies state before its first snapshot. */\n revision: number;\n /** Owned style element, recreated when it is no longer connected to the document. */\n style?: HTMLStyleElement;\n /** Registered compiler producer identities. Composition dependencies are expanded during rendering. */\n active: Set<string>;\n /** Owned complete snapshot fixed when its revision was accepted. */\n snapshot?: StylesheetSnapshot;\n /** Fetch-and-apply operation shared by overlapping synchronization requests. */\n pending?: Promise<void>;\n}\n\nconst documentKey = Symbol.for(\"stillwind.document\");\n\n/**\n * Reuses document state across runtime instances and applies the initial snapshot.\n * `endpoint` supplies snapshots for this environment. `renderCss`, when supplied,\n * must return CSS for the selected parts in their existing order.\n * Returns operations for producer registration, snapshot updates and synchronization.\n * Snapshots older than the shared document revision are ignored.\n * @param options - Initial snapshot, snapshot endpoint, and optional renderer. Accepted snapshots are captured.\n * @returns Operations that update shared producer state and the owned style element.\n */\nexport function createDevelopmentRuntime(options: {\n /** Initial complete snapshot applied unless its revision is older than shared document state. */\n snapshot: StylesheetSnapshot;\n /** URL returning a JSON snapshot for this compiler environment. */\n endpoint: string;\n /** Optional renderer receiving selected parts in stylesheet order and returning their combined CSS. */\n renderCss?: (parts: readonly StylesheetPart[]) => string;\n}) {\n const endpoint = options.endpoint;\n const renderCss = options.renderCss?.bind(options);\n const globals = globalThis as typeof globalThis & {\n /** State shared through Symbol.for across runtime module replacements. */\n [documentKey]?: DocumentState;\n };\n const state = (globals[documentKey] ??= {\n revision: -1,\n active: new Set(),\n });\n\n /** Expands composition dependencies and writes active partitions into the shared style element. */\n function render() {\n if (!state.snapshot || typeof document === \"undefined\") {\n return;\n }\n const active = new Set(state.active);\n for (const module of active) {\n for (const dependency of state.snapshot.dependencies[module] ?? []) {\n active.add(dependency);\n }\n }\n const parts = state.snapshot.parts.filter(\n (part) => !part.producers.length || part.producers.some((producer) => active.has(producer)),\n );\n if (!state.style?.isConnected) {\n state.style = document.createElement(\"style\");\n state.style.dataset.stillwind = \"\";\n document.head.append(state.style);\n }\n state.style.textContent = renderCss ? renderCss(parts) : cssText(parts);\n }\n\n /**\n * Activates a producer and rerenders its CSS and composition dependencies.\n * @param id - Compiler module identity. Repeated registration has no additional ownership count.\n */\n function register(id: string) {\n state.active.add(id);\n render();\n }\n\n /**\n * Removes a producer registration and rerenders the remaining active CSS.\n * @param id - Compiler module identity. Unknown identities have no effect on the set.\n */\n function unregister(id: string) {\n state.active.delete(id);\n render();\n }\n\n /**\n * Fetches the current snapshot, sharing pending requests between producers.\n * Resolves after the document reaches `revision`; rejects on fetch or response\n * failures. Does not fetch when no document exists.\n * @param revision - Minimum adapter revision required before completion.\n * @returns Completion after a fetched snapshot reaches the requested revision, or immediately without a document.\n * @throws If fetching, decoding, or applying a snapshot fails.\n */\n async function synchronize(revision: number) {\n if (typeof document === \"undefined\") {\n return;\n }\n do {\n state.pending ??= fetch(endpoint)\n .then((response) => {\n if (!response.ok) {\n throw new Error(\"Stillwind stylesheet synchronization failed\");\n }\n return response.json() as Promise<StylesheetSnapshot>;\n })\n .then(apply)\n .finally(() => {\n state.pending = undefined;\n });\n await state.pending;\n } while (state.revision < revision);\n }\n\n /**\n * Accepts a current or newer snapshot and rerenders shared document styles.\n * @param update - Complete snapshot to capture. Older revisions are ignored, and equal revisions are accepted.\n */\n function apply(update: StylesheetSnapshot) {\n if (update.revision < state.revision) {\n return;\n }\n state.snapshot = structuredClone(update);\n state.revision = state.snapshot.revision;\n render();\n }\n\n apply(options.snapshot);\n return {\n register,\n unregister,\n synchronize,\n apply,\n };\n}\n"],"mappings":";;AAwDA,MAAM,cAAc,OAAO,IAAI,oBAAoB;;;;;;;;;;AAWnD,SAAgB,yBAAyB,SAOtC;CACD,MAAM,WAAW,QAAQ;CACzB,MAAM,YAAY,QAAQ,WAAW,KAAK,OAAO;CACjD,MAAM,UAAU;CAIhB,MAAM,QAAS,QAAQ,iBAAiB;EACtC,UAAU;EACV,wBAAQ,IAAI,IAAI;CAClB;;CAGA,SAAS,SAAS;EAChB,IAAI,CAAC,MAAM,YAAY,OAAO,aAAa,aACzC;EAEF,MAAM,SAAS,IAAI,IAAI,MAAM,MAAM;EACnC,KAAK,MAAM,UAAU,QACnB,KAAK,MAAM,cAAc,MAAM,SAAS,aAAa,WAAW,CAAC,GAC/D,OAAO,IAAI,UAAU;EAGzB,MAAM,QAAQ,MAAM,SAAS,MAAM,QAChC,SAAS,CAAC,KAAK,UAAU,UAAU,KAAK,UAAU,MAAM,aAAa,OAAO,IAAI,QAAQ,CAAC,CAC5F;EACA,IAAI,CAAC,MAAM,OAAO,aAAa;GAC7B,MAAM,QAAQ,SAAS,cAAc,OAAO;GAC5C,MAAM,MAAM,QAAQ,YAAY;GAChC,SAAS,KAAK,OAAO,MAAM,KAAK;EAClC;EACA,MAAM,MAAM,cAAc,YAAY,UAAU,KAAK,IAAI,QAAQ,KAAK;CACxE;;;;;CAMA,SAAS,SAAS,IAAY;EAC5B,MAAM,OAAO,IAAI,EAAE;EACnB,OAAO;CACT;;;;;CAMA,SAAS,WAAW,IAAY;EAC9B,MAAM,OAAO,OAAO,EAAE;EACtB,OAAO;CACT;;;;;;;;;CAUA,eAAe,YAAY,UAAkB;EAC3C,IAAI,OAAO,aAAa,aACtB;EAEF,GAAG;GACD,MAAM,YAAY,MAAM,QAAQ,CAAC,CAC9B,MAAM,aAAa;IAClB,IAAI,CAAC,SAAS,IACZ,MAAM,IAAI,MAAM,6CAA6C;IAE/D,OAAO,SAAS,KAAK;GACvB,CAAC,CAAC,CACD,KAAK,KAAK,CAAC,CACX,cAAc;IACb,MAAM,UAAU,KAAA;GAClB,CAAC;GACH,MAAM,MAAM;EACd,SAAS,MAAM,WAAW;CAC5B;;;;;CAMA,SAAS,MAAM,QAA4B;EACzC,IAAI,OAAO,WAAW,MAAM,UAC1B;EAEF,MAAM,WAAW,gBAAgB,MAAM;EACvC,MAAM,WAAW,MAAM,SAAS;EAChC,OAAO;CACT;CAEA,MAAM,QAAQ,QAAQ;CACtB,OAAO;EACL;EACA;EACA;EACA;CACF;AACF"}
@@ -0,0 +1,17 @@
1
+ import { LoaderContext } from "webpack";
2
+ /**
3
+ * Supplies reconstructed document CSS to the host CSS pipeline through the asynchronous
4
+ * loader callback.
5
+ *
6
+ * The loader context must identify a `stillwind-document` request in a compilation
7
+ * registered by `StillwindPlugin`. The loader disables caching because the carrier is
8
+ * rebuilt after graph linking. The first pass supplies empty CSS until reconstruction
9
+ * has stored the completed stylesheet.
10
+ *
11
+ * @param this - Document carrier context with registered emission state and
12
+ * asynchronous completion.
13
+ * @throws If the request is not a document carrier or the compilation has no registered
14
+ * emission hook.
15
+ */
16
+ export default function webpackCssLoader(this: LoaderContext<unknown>): void;
17
+ //# sourceMappingURL=css-loader.d.ts.map
@@ -0,0 +1,36 @@
1
+ import { loaderCompletion } from "./source-map-loader.js";
2
+ import { r as requireEmission } from "../emission-BVi5aRbb.js";
3
+ import { fileURLToPath } from "node:url";
4
+ import { decodeCssSourceMap } from "@stillwind/host";
5
+ // src/webpack/css-loader.ts
6
+ /**
7
+ * Supplies reconstructed document CSS to the host CSS pipeline through the asynchronous
8
+ * loader callback.
9
+ *
10
+ * The loader context must identify a `stillwind-document` request in a compilation
11
+ * registered by `StillwindPlugin`. The loader disables caching because the carrier is
12
+ * rebuilt after graph linking. The first pass supplies empty CSS until reconstruction
13
+ * has stored the completed stylesheet.
14
+ *
15
+ * @param this - Document carrier context with registered emission state and
16
+ * asynchronous completion.
17
+ * @throws If the request is not a document carrier or the compilation has no registered
18
+ * emission hook.
19
+ */
20
+ function webpackCssLoader() {
21
+ this.addDependency(import.meta.filename);
22
+ if (!new URLSearchParams(this.resourceQuery).has("stillwind-document")) throw new Error("Unknown Stillwind stylesheet request");
23
+ this.cacheable(false);
24
+ const css = requireEmission(this).__stillwindCss ?? "";
25
+ const callback = loaderCompletion(this);
26
+ try {
27
+ const output = decodeCssSourceMap(css);
28
+ if (output.map) output.map.sources = output.map.sources.map((source) => source.startsWith("file:") ? fileURLToPath(source).replaceAll("\\", "/") : source);
29
+ callback(null, output.code, output.map);
30
+ } catch (error) {
31
+ callback(error);
32
+ }
33
+ }
34
+ export { webpackCssLoader as default };
35
+
36
+ //# sourceMappingURL=css-loader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"css-loader.js","names":[],"sources":["../../src/webpack/css-loader.ts"],"sourcesContent":["import { fileURLToPath } from \"node:url\";\n\nimport { decodeCssSourceMap } from \"@stillwind/host\";\nimport type { LoaderContext } from \"webpack\";\n\nimport { requireEmission } from \"./emission.ts\";\nimport { loaderCompletion } from \"./source-map-loader.ts\";\n\n/**\n * Supplies reconstructed document CSS to the host CSS pipeline through the asynchronous\n * loader callback.\n *\n * The loader context must identify a `stillwind-document` request in a compilation\n * registered by `StillwindPlugin`. The loader disables caching because the carrier is\n * rebuilt after graph linking. The first pass supplies empty CSS until reconstruction\n * has stored the completed stylesheet.\n *\n * @param this - Document carrier context with registered emission state and\n * asynchronous completion.\n * @throws If the request is not a document carrier or the compilation has no registered\n * emission hook.\n */\nexport default function webpackCssLoader(this: LoaderContext<unknown>) {\n this.addDependency(import.meta.filename);\n const document = new URLSearchParams(this.resourceQuery).has(\"stillwind-document\");\n if (!document) {\n throw new Error(\"Unknown Stillwind stylesheet request\");\n }\n this.cacheable(false);\n const css = requireEmission(this).__stillwindCss ?? \"\";\n const callback = loaderCompletion(this);\n try {\n const output = decodeCssSourceMap(css);\n if (output.map) {\n output.map.sources = output.map.sources.map((source: string) =>\n source.startsWith(\"file:\") ? fileURLToPath(source).replaceAll(\"\\\\\", \"/\") : source,\n );\n }\n callback(null, output.code, output.map);\n } catch (error) {\n callback(error);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAsBA,SAAwB,mBAA+C;CACrE,KAAK,cAAc,YAAY,QAAQ;CAEvC,IAAI,CADa,IAAI,gBAAgB,KAAK,aAAa,CAAC,CAAC,IAAI,oBACjD,GACV,MAAM,IAAI,MAAM,sCAAsC;CAExD,KAAK,UAAU,KAAK;CACpB,MAAM,MAAM,gBAAgB,IAAI,CAAC,CAAC,kBAAkB;CACpD,MAAM,WAAW,iBAAiB,IAAI;CACtC,IAAI;EACF,MAAM,SAAS,mBAAmB,GAAG;EACrC,IAAI,OAAO,KACT,OAAO,IAAI,UAAU,OAAO,IAAI,QAAQ,KAAK,WAC3C,OAAO,WAAW,OAAO,IAAI,cAAc,MAAM,CAAC,CAAC,WAAW,MAAM,GAAG,IAAI,MAC7E;EAEF,SAAS,MAAM,OAAO,MAAM,OAAO,GAAG;CACxC,SAAS,OAAO;EACd,SAAS,KAAK;CAChB;AACF"}
@@ -0,0 +1,24 @@
1
+ import { r as SourceMapInput } from "../trace-mapping-DV_eP3r7.js";
2
+ import { LoaderContext } from "webpack";
3
+ /**
4
+ * Composes remaining CSS carrier references in the host pipeline's output map.
5
+ *
6
+ * Lightning CSS can retain a carrier source outside `rootContext`. Only sources
7
+ * resolving to this loader's absolute resource path are composed. Already composed
8
+ * sources stay outside this step. The original CSS and its inline map are decoded from
9
+ * the `stillwind` query payload.
10
+ *
11
+ * A payload used for composition must contain CSS with a trailing inline map recognized
12
+ * by `decodeCssSourceMap`.
13
+ *
14
+ * @param this - Loader context with the resource path, query, dependency registration,
15
+ * and synchronous and asynchronous completion callbacks.
16
+ * @param source - CSS text produced by the preceding loaders. This loader returns it
17
+ * unchanged.
18
+ * @param inputMap - Output map from the host CSS pipeline. Without a map or payload, it
19
+ * is passed through unchanged.
20
+ * @returns The loader callback's result for passthrough, or undefined after composition
21
+ * completes. Decoding and composition failures are delivered to the callback.
22
+ */
23
+ export default function webpackCssMapLoader(this: LoaderContext<unknown>, source: string, inputMap: SourceMapInput | SourceMapInput[] | null | undefined): void;
24
+ //# sourceMappingURL=css-map-loader.d.ts.map
@@ -0,0 +1,43 @@
1
+ import { loaderCompletion } from "./source-map-loader.js";
2
+ import { fileURLToPath } from "node:url";
3
+ import { composeCarrierSourceMap, decodeCssSourceMap } from "@stillwind/host";
4
+ import path from "node:path";
5
+ // src/webpack/css-map-loader.ts
6
+ /**
7
+ * Composes remaining CSS carrier references in the host pipeline's output map.
8
+ *
9
+ * Lightning CSS can retain a carrier source outside `rootContext`. Only sources
10
+ * resolving to this loader's absolute resource path are composed. Already composed
11
+ * sources stay outside this step. The original CSS and its inline map are decoded from
12
+ * the `stillwind` query payload.
13
+ *
14
+ * A payload used for composition must contain CSS with a trailing inline map recognized
15
+ * by `decodeCssSourceMap`.
16
+ *
17
+ * @param this - Loader context with the resource path, query, dependency registration,
18
+ * and synchronous and asynchronous completion callbacks.
19
+ * @param source - CSS text produced by the preceding loaders. This loader returns it
20
+ * unchanged.
21
+ * @param inputMap - Output map from the host CSS pipeline. Without a map or payload, it
22
+ * is passed through unchanged.
23
+ * @returns The loader callback's result for passthrough, or undefined after composition
24
+ * completes. Decoding and composition failures are delivered to the callback.
25
+ */
26
+ function webpackCssMapLoader(source, inputMap) {
27
+ this.addDependency(import.meta.filename);
28
+ const payload = new URLSearchParams(this.resourceQuery).get("stillwind");
29
+ if (!payload || !inputMap) return this.callback(null, source, inputMap);
30
+ const callback = loaderCompletion(this);
31
+ const resource = path.resolve(this.resourcePath).replaceAll("\\", "/");
32
+ try {
33
+ const original = decodeCssSourceMap(Buffer.from(payload, "base64url").toString("utf8"));
34
+ const result = composeCarrierSourceMap(inputMap, original.map, resource);
35
+ result.sources = result.sources.map((source) => source?.startsWith("file:") ? fileURLToPath(source).replaceAll("\\", "/") : source);
36
+ callback(null, source, result);
37
+ } catch (error) {
38
+ callback(error);
39
+ }
40
+ }
41
+ export { webpackCssMapLoader as default };
42
+
43
+ //# sourceMappingURL=css-map-loader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"css-map-loader.js","names":[],"sources":["../../src/webpack/css-map-loader.ts"],"sourcesContent":["import path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nimport type { SourceMapInput } from \"@jridgewell/trace-mapping\";\nimport { composeCarrierSourceMap, decodeCssSourceMap } from \"@stillwind/host\";\nimport type { LoaderContext } from \"webpack\";\n\nimport { loaderCompletion, type LoaderCompletion } from \"./source-map-loader.ts\";\n\n/**\n * Composes remaining CSS carrier references in the host pipeline's output map.\n *\n * Lightning CSS can retain a carrier source outside `rootContext`. Only sources\n * resolving to this loader's absolute resource path are composed. Already composed\n * sources stay outside this step. The original CSS and its inline map are decoded from\n * the `stillwind` query payload.\n *\n * A payload used for composition must contain CSS with a trailing inline map recognized\n * by `decodeCssSourceMap`.\n *\n * @param this - Loader context with the resource path, query, dependency registration,\n * and synchronous and asynchronous completion callbacks.\n * @param source - CSS text produced by the preceding loaders. This loader returns it\n * unchanged.\n * @param inputMap - Output map from the host CSS pipeline. Without a map or payload, it\n * is passed through unchanged.\n * @returns The loader callback's result for passthrough, or undefined after composition\n * completes. Decoding and composition failures are delivered to the callback.\n */\nexport default function webpackCssMapLoader(\n this: LoaderContext<unknown>,\n source: string,\n inputMap: SourceMapInput | SourceMapInput[] | null | undefined,\n) {\n this.addDependency(import.meta.filename);\n const payload = new URLSearchParams(this.resourceQuery).get(\"stillwind\");\n if (!payload || !inputMap) {\n return (this.callback as LoaderCompletion)(null, source, inputMap);\n }\n const callback = loaderCompletion(this);\n const resource = path.resolve(this.resourcePath).replaceAll(\"\\\\\", \"/\");\n try {\n const original = decodeCssSourceMap(Buffer.from(payload, \"base64url\").toString(\"utf8\"));\n const result = composeCarrierSourceMap(inputMap, original.map!, resource);\n result.sources = result.sources.map((source) =>\n source?.startsWith(\"file:\") ? fileURLToPath(source).replaceAll(\"\\\\\", \"/\") : source,\n );\n callback(null, source, result);\n } catch (error) {\n callback(error);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,SAAwB,oBAEtB,QACA,UACA;CACA,KAAK,cAAc,YAAY,QAAQ;CACvC,MAAM,UAAU,IAAI,gBAAgB,KAAK,aAAa,CAAC,CAAC,IAAI,WAAW;CACvE,IAAI,CAAC,WAAW,CAAC,UACf,OAAQ,KAAK,SAA8B,MAAM,QAAQ,QAAQ;CAEnE,MAAM,WAAW,iBAAiB,IAAI;CACtC,MAAM,WAAW,KAAK,QAAQ,KAAK,YAAY,CAAC,CAAC,WAAW,MAAM,GAAG;CACrE,IAAI;EACF,MAAM,WAAW,mBAAmB,OAAO,KAAK,SAAS,WAAW,CAAC,CAAC,SAAS,MAAM,CAAC;EACtF,MAAM,SAAS,wBAAwB,UAAU,SAAS,KAAM,QAAQ;EACxE,OAAO,UAAU,OAAO,QAAQ,KAAK,WACnC,QAAQ,WAAW,OAAO,IAAI,cAAc,MAAM,CAAC,CAAC,WAAW,MAAM,GAAG,IAAI,MAC9E;EACA,SAAS,MAAM,QAAQ,MAAM;CAC/B,SAAS,OAAO;EACd,SAAS,KAAK;CAChB;AACF"}
@@ -0,0 +1,12 @@
1
+ import { r as SourceMapInput } from "../trace-mapping-DV_eP3r7.js";
2
+ import { t as LoaderAdditionalData } from "../source-map-loader-CBLiYaBI.js";
3
+ import { LoaderContext } from "webpack";
4
+ /**
5
+ * Skips CSS extraction until the completed graph supplies document CSS. Extracting
6
+ * empty CSS first would retain an empty module in mini-css-extract-plugin's graph.
7
+ * @returns Empty source before reconstruction, otherwise leaves the loader chain active.
8
+ */
9
+ export declare function pitch(this: LoaderContext<unknown>): string | undefined;
10
+ /** Preserves the host CSS pipeline's output and source map after reconstruction. */
11
+ export default function documentLoader(this: LoaderContext<unknown>, source: string, map: SourceMapInput | null | undefined, additionalData?: LoaderAdditionalData): void;
12
+ //# sourceMappingURL=document-loader.d.ts.map
@@ -0,0 +1,19 @@
1
+ import { loaderCompletion } from "./source-map-loader.js";
2
+ import { r as requireEmission } from "../emission-BVi5aRbb.js";
3
+ // src/webpack/document-loader.ts
4
+ /**
5
+ * Skips CSS extraction until the completed graph supplies document CSS. Extracting
6
+ * empty CSS first would retain an empty module in mini-css-extract-plugin's graph.
7
+ * @returns Empty source before reconstruction, otherwise leaves the loader chain active.
8
+ */
9
+ function pitch() {
10
+ this.cacheable(false);
11
+ if (requireEmission(this).__stillwindCss === void 0) return "";
12
+ }
13
+ /** Preserves the host CSS pipeline's output and source map after reconstruction. */
14
+ function documentLoader(source, map, additionalData) {
15
+ loaderCompletion(this)(null, source, map, additionalData);
16
+ }
17
+ export { documentLoader as default, pitch };
18
+
19
+ //# sourceMappingURL=document-loader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"document-loader.js","names":[],"sources":["../../src/webpack/document-loader.ts"],"sourcesContent":["import type { SourceMapInput } from \"@jridgewell/trace-mapping\";\nimport type { LoaderContext } from \"webpack\";\n\nimport { requireEmission } from \"./emission.ts\";\nimport { loaderCompletion, type LoaderAdditionalData } from \"./source-map-loader.ts\";\n\n/**\n * Skips CSS extraction until the completed graph supplies document CSS. Extracting\n * empty CSS first would retain an empty module in mini-css-extract-plugin's graph.\n * @returns Empty source before reconstruction, otherwise leaves the loader chain active.\n */\nexport function pitch(this: LoaderContext<unknown>): string | undefined {\n this.cacheable(false);\n if (requireEmission(this).__stillwindCss === undefined) {\n return \"\";\n }\n return undefined;\n}\n\n/** Preserves the host CSS pipeline's output and source map after reconstruction. */\nexport default function documentLoader(\n this: LoaderContext<unknown>,\n source: string,\n map: SourceMapInput | null | undefined,\n additionalData?: LoaderAdditionalData,\n): void {\n loaderCompletion(this)(null, source, map, additionalData);\n}\n"],"mappings":";;;;;;;;AAWA,SAAgB,QAAwD;CACtE,KAAK,UAAU,KAAK;CACpB,IAAI,gBAAgB,IAAI,CAAC,CAAC,mBAAmB,KAAA,GAC3C,OAAO;AAGX;;AAGA,SAAwB,eAEtB,QACA,KACA,gBACM;CACN,iBAAiB,IAAI,CAAC,CAAC,MAAM,QAAQ,KAAK,cAAc;AAC1D"}
@@ -0,0 +1,9 @@
1
+ import { LoaderContext } from "webpack";
2
+ /**
3
+ * Decodes an immutable CSS fragment into a module that substitutes bundler-resolved asset URLs.
4
+ * @param this - Loader context whose css query contains base64url-encoded UTF-8 fragment JSON.
5
+ * @returns JavaScript importing referenced assets and exporting the fragment's CSS.
6
+ * @throws If the css query is absent or its decoded JSON is invalid.
7
+ */
8
+ export default function webpackFragmentLoader(this: LoaderContext<unknown>): string;
9
+ //# sourceMappingURL=fragment-loader.d.ts.map
@@ -0,0 +1,23 @@
1
+ // src/webpack/fragment-loader.ts
2
+ /**
3
+ * Decodes an immutable CSS fragment into a module that substitutes bundler-resolved asset URLs.
4
+ * @param this - Loader context whose css query contains base64url-encoded UTF-8 fragment JSON.
5
+ * @returns JavaScript importing referenced assets and exporting the fragment's CSS.
6
+ * @throws If the css query is absent or its decoded JSON is invalid.
7
+ */
8
+ function webpackFragmentLoader() {
9
+ const encoded = new URLSearchParams(this.resourceQuery).get("css");
10
+ if (!encoded) throw new Error("Missing Stillwind CSS fragment");
11
+ const { css, resources } = JSON.parse(Buffer.from(encoded, "base64url").toString("utf8"));
12
+ const imports = resources.map((resource, index) => `import asset${index} from ${JSON.stringify(resource.id)};\n`);
13
+ const replacements = resources.map((resource, index) => `.replaceAll(${JSON.stringify(resource.placeholder)}, JSON.stringify(typeof asset${index} === "string" ? asset${index} : asset${index}.src).slice(1, -1))`).join("");
14
+ return [
15
+ "// Stillwind CSS fragment (webpack)\n",
16
+ ...imports,
17
+ "\n",
18
+ `export const css = ${JSON.stringify(css)}${replacements};\n`
19
+ ].join("");
20
+ }
21
+ export { webpackFragmentLoader as default };
22
+
23
+ //# sourceMappingURL=fragment-loader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fragment-loader.js","names":[],"sources":["../../src/webpack/fragment-loader.ts"],"sourcesContent":["import type { LoaderContext } from \"webpack\";\n\nimport type { CssFragment } from \"./css-value.ts\";\n\n/**\n * Decodes an immutable CSS fragment into a module that substitutes bundler-resolved asset URLs.\n * @param this - Loader context whose css query contains base64url-encoded UTF-8 fragment JSON.\n * @returns JavaScript importing referenced assets and exporting the fragment's CSS.\n * @throws If the css query is absent or its decoded JSON is invalid.\n */\nexport default function webpackFragmentLoader(this: LoaderContext<unknown>): string {\n const encoded = new URLSearchParams(this.resourceQuery).get(\"css\");\n if (!encoded) {\n throw new Error(\"Missing Stillwind CSS fragment\");\n }\n const { css, resources } = JSON.parse(\n Buffer.from(encoded, \"base64url\").toString(\"utf8\"),\n ) as CssFragment;\n const imports = resources.map(\n (resource, index) => `import asset${index} from ${JSON.stringify(resource.id)};\\n`,\n );\n const replacements = resources\n .map(\n (resource, index) =>\n `.replaceAll(${JSON.stringify(resource.placeholder)}, JSON.stringify(typeof asset${index} === \"string\" ? asset${index} : asset${index}.src).slice(1, -1))`,\n )\n .join(\"\");\n return [\n \"// Stillwind CSS fragment (webpack)\\n\",\n ...imports,\n \"\\n\",\n `export const css = ${JSON.stringify(css)}${replacements};\\n`,\n ].join(\"\");\n}\n"],"mappings":";;;;;;;AAUA,SAAwB,wBAA4D;CAClF,MAAM,UAAU,IAAI,gBAAgB,KAAK,aAAa,CAAC,CAAC,IAAI,KAAK;CACjE,IAAI,CAAC,SACH,MAAM,IAAI,MAAM,gCAAgC;CAElD,MAAM,EAAE,KAAK,cAAc,KAAK,MAC9B,OAAO,KAAK,SAAS,WAAW,CAAC,CAAC,SAAS,MAAM,CACnD;CACA,MAAM,UAAU,UAAU,KACvB,UAAU,UAAU,eAAe,MAAM,QAAQ,KAAK,UAAU,SAAS,EAAE,EAAE,IAChF;CACA,MAAM,eAAe,UAClB,KACE,UAAU,UACT,eAAe,KAAK,UAAU,SAAS,WAAW,EAAE,+BAA+B,MAAM,uBAAuB,MAAM,UAAU,MAAM,oBAC1I,CAAC,CACA,KAAK,EAAE;CACV,OAAO;EACL;EACA,GAAG;EACH;EACA,sBAAsB,KAAK,UAAU,GAAG,IAAI,aAAa;CAC3D,CAAC,CAAC,KAAK,EAAE;AACX"}
@@ -0,0 +1,3 @@
1
+ import { t as StillwindPlugin } from "../plugin-aV0zIIAe.js";
2
+ import { InlineConfig as IntegrationConfig } from "@stillwind/config";
3
+ export { type IntegrationConfig, StillwindPlugin };
@@ -0,0 +1 @@
1
+ export { t as StillwindPlugin } from "../plugin-mPiBLdqa.js";
@@ -0,0 +1,35 @@
1
+ import { i as SourceTransformContext, t as LoaderAdditionalData } from "../source-map-loader-CBLiYaBI.js";
2
+ import { UpstreamSourceMap } from "@stillwind/host";
3
+ import { BuildConfig, InlineConfig } from "@stillwind/config";
4
+ /** Compiler options carried by a loader rule or an encoded SFC subrequest. */
5
+ type LoaderOptions = InlineConfig & {
6
+ /**
7
+ * Base64url-encoded JSON configuration for an SFC subrequest. Omit when the rule supplies options
8
+ * directly.
9
+ */
10
+ stillwindOptions?: string;
11
+ };
12
+ /**
13
+ * Compiles a producer, CSS projection, or explicit CSS value through the webpack loader protocol.
14
+ *
15
+ * The loader context supplies resolution, file dependencies, options, and an asynchronous callback.
16
+ * Automatic document CSS and projections require `StillwindPlugin` to be installed before
17
+ * compilation. Results and failures are delivered through the callback. SFC transforms also store
18
+ * their code and map in `this.data` for framework map composition.
19
+ *
20
+ * @param this - Active loader context whose data and module metadata retain successful producer transforms.
21
+ * @param source - Source supplied by the preceding loaders. CSS subrequests read the original
22
+ * resource instead.
23
+ * @param inputMap - Map from the supplied source to its original source, when available.
24
+ * @param additionalData - Metadata from preceding loaders, including a prior Stillwind transform
25
+ * fingerprint.
26
+ * @returns No synchronous source. Pass-through and asynchronous results use the loader callback.
27
+ */
28
+ export default function webpackLoader(this: SourceTransformContext<LoaderOptions>, source: string, inputMap: UpstreamSourceMap, additionalData?: LoaderAdditionalData): void;
29
+ /**
30
+ * Keeps webpack pitch data available for sharing transformed SFC code and maps with framework
31
+ * loaders.
32
+ */
33
+ export declare function pitch(): void;
34
+ export {};
35
+ //# sourceMappingURL=loader.d.ts.map
@@ -0,0 +1,199 @@
1
+ import { n as buildCompilerOptions, t as IntegrationSession } from "../session-DHUCQMG5.js";
2
+ import { loaderCompletion } from "./source-map-loader.js";
3
+ import { a as watchCompilerFiles, c as relativeRequest, i as createLoaderHost, l as requestOptions, n as recordProducer, o as sourceDescriptor, s as classifyRequest, u as virtualRequest } from "../emission-BVi5aRbb.js";
4
+ import { createHash } from "node:crypto";
5
+ import { fileURLToPath, pathToFileURL } from "node:url";
6
+ import { cleanModuleId, composeModuleSourceMap, cssEntrypoint, finalizeModuleWithMap, loadCssGraph, moduleSourceMap, nodePluginHost, warnRejectedNames } from "@stillwind/host";
7
+ import path from "node:path";
8
+ import { resolveIntegrationConfig } from "@stillwind/config/node";
9
+ // src/webpack/css-value.ts
10
+ /**
11
+ * Generates a module that imports CSS fragments and exports their ordered values.
12
+ *
13
+ * Each fragment request encodes its CSS and referenced assets. Equal payloads produce equal
14
+ * requests, while the value retains occurrence order.
15
+ *
16
+ * @param parts - Stylesheet occurrences in cascade order. Repeated occurrences keep their
17
+ * positions.
18
+ * @param resources - Resolved assets whose placeholders may occur in the parts.
19
+ * @returns JavaScript exporting `parts`, the joined `css` string, and the same string as its
20
+ * default export.
21
+ */
22
+ function cssValueModule(parts, resources) {
23
+ const imports = parts.map((part, index) => {
24
+ const payload = Buffer.from(JSON.stringify({
25
+ css: part.css,
26
+ resources: resources.filter((resource) => part.css.includes(resource.placeholder))
27
+ })).toString("base64url");
28
+ const request = `!!${fileURLToPath(new URL("./fragment-loader.js", import.meta.resolve("@stillwind/integration/webpack")))}!${fileURLToPath(new URL("./stillwind-fragment.js", import.meta.resolve("@stillwind/integration/webpack")))}?css=${payload}`;
29
+ return `import { css as p${index} } from ${JSON.stringify(request)};\n`;
30
+ });
31
+ const entries = parts.map((part, index) => ` { key: ${JSON.stringify(part.key)}, banners: ${JSON.stringify(part.banners)}, css: p${index} },\n`);
32
+ return [
33
+ "// Stillwind CSS value (webpack)\n",
34
+ "import { cssText } from \"stillwind/css\";\n",
35
+ ...imports,
36
+ "\n",
37
+ "export const parts = [\n",
38
+ ...entries,
39
+ "];\n",
40
+ "export const css = cssText(parts);\n",
41
+ "export default css;\n"
42
+ ].join("");
43
+ }
44
+ // src/webpack/loader.ts
45
+ /**
46
+ * Hashes transformed text to recognize a repeated pass through the same resource.
47
+ *
48
+ * @param source - Exact source text received or produced by the loader.
49
+ * @returns A SHA-256 fingerprint encoded as hexadecimal.
50
+ */
51
+ const fingerprint = (source) => createHash("sha256").update(source).digest("hex");
52
+ /**
53
+ * Compiles a producer, CSS projection, or explicit CSS value through the webpack loader protocol.
54
+ *
55
+ * The loader context supplies resolution, file dependencies, options, and an asynchronous callback.
56
+ * Automatic document CSS and projections require `StillwindPlugin` to be installed before
57
+ * compilation. Results and failures are delivered through the callback. SFC transforms also store
58
+ * their code and map in `this.data` for framework map composition.
59
+ *
60
+ * @param this - Active loader context whose data and module metadata retain successful producer transforms.
61
+ * @param source - Source supplied by the preceding loaders. CSS subrequests read the original
62
+ * resource instead.
63
+ * @param inputMap - Map from the supplied source to its original source, when available.
64
+ * @param additionalData - Metadata from preceding loaders, including a prior Stillwind transform
65
+ * fingerprint.
66
+ * @returns No synchronous source. Pass-through and asynchronous results use the loader callback.
67
+ */
68
+ function webpackLoader(source, inputMap, additionalData) {
69
+ const callback = loaderCompletion(this);
70
+ const text = String(source);
71
+ const { projection, cssValue, sfc, id, passthrough } = classifyRequest(this.resourcePath, this.resourceQuery);
72
+ const prior = additionalData?.stillwind?.sourceTransform;
73
+ if (prior?.resource === id && prior.fingerprint === fingerprint(text)) return callback(null, source, inputMap, additionalData);
74
+ if (passthrough) return callback(null, source, inputMap);
75
+ if (!projection && !cssValue && !/stillwind\/(?:alpine|astro|lit|preact|qwik|react|solid|svelte|vanilla|vue|module-css)/.test(text)) return callback(null, source, inputMap);
76
+ const supplied = requestOptions(this.getOptions());
77
+ let compiler;
78
+ const { read, readDependency, dependencySources, resolveCss, resolveAsset, resolve, watch, warn } = createLoaderHost(this, import.meta.filename);
79
+ (async () => {
80
+ const configuration = this._compilation?.__stillwindConfiguration ?? await resolveIntegrationConfig(supplied, this.rootContext);
81
+ for (const file of configuration.dependencies) this.addDependency(file);
82
+ for (const file of configuration.missing) this.addMissingDependency(file);
83
+ const { config } = configuration;
84
+ if (config.naming) this.cacheable(false);
85
+ /**
86
+ * Creates a virtual module request using this source file's framework and compiler settings.
87
+ * @param query - Stillwind virtual query selecting the requested CSS or value module.
88
+ * @returns An inline loader request retaining the resource path and resolved configuration.
89
+ */
90
+ const request = (query) => virtualRequest(this.resourcePath, sfc, config, import.meta.filename, query, supplied);
91
+ watchCompilerFiles(watch);
92
+ const root = path.resolve(this.rootContext, config.root ?? ".");
93
+ const css = path.resolve(root, cssEntrypoint(config));
94
+ const loaded = await loadCssGraph(css, buildCompilerOptions(config), {
95
+ resolve: resolveCss,
96
+ read,
97
+ documentUri: (id) => pathToFileURL(id).href,
98
+ sourceMapSource: (id) => pathToFileURL(id).href,
99
+ watch,
100
+ watchDirectory: (id) => this.addContextDependency(id),
101
+ plugins: nodePluginHost
102
+ }, void 0, void 0, {
103
+ plugins: config.plugins,
104
+ tailwind: config.tailwind,
105
+ important: config.important,
106
+ root
107
+ });
108
+ compiler = new IntegrationSession(root, loaded.loader, config, false, this.mode === "development" ? "development" : "release", loaded.plugins);
109
+ const session = compiler.native;
110
+ const output = await compiler.compile(projection || cssValue ? await read(this.resourcePath) : text, projection || cssValue ? this.resourcePath : id, {
111
+ describe: (id) => sourceDescriptor(root, id),
112
+ resolve,
113
+ read: readDependency,
114
+ watch,
115
+ warn
116
+ }, {
117
+ stylesheetImports: sfc && !projection && !cssValue && config.automatic !== false ? [request("stillwind.css")] : void 0,
118
+ moduleCssImport: request("stillwind-module-css")
119
+ });
120
+ if (!output?.code) return callback(null, projection ? "" : source, projection ? null : inputMap);
121
+ const plan = session.planStylesheet({
122
+ modules: [output.moduleId],
123
+ coverage: { kind: "observed" },
124
+ placement: "document"
125
+ });
126
+ warnRejectedNames(plan.rejectedNames, warn);
127
+ const valueResources = [];
128
+ for (const resource of [...loaded.resources, ...plan.resources]) {
129
+ const owner = "moduleId" in resource ? compiler.resolverId(resource.moduleId) : resource.sourceName;
130
+ const resolved = await resolveAsset(resource.specifier, owner);
131
+ if (!resolved) throw new Error(`Cannot resolve Stillwind resource ${resource.specifier} from ${owner}`);
132
+ watch(cleanModuleId(resolved));
133
+ if (plan.css.includes(resource.placeholder)) valueResources.push({
134
+ placeholder: resource.placeholder,
135
+ id: resolved,
136
+ request: relativeRequest(path.dirname(this.resourcePath), resolved)
137
+ });
138
+ }
139
+ const carrier = relativeRequest(path.dirname(this.resourcePath), fileURLToPath(new URL("./stillwind-webpack.css", import.meta.resolve("@stillwind/integration/webpack"))));
140
+ if (cssValue) return callback(null, cssValueModule(plan.parts, valueResources), null);
141
+ const automatic = !output.hasModuleCssImport && config.automatic !== false || projection;
142
+ if (automatic) recordProducer(this, {
143
+ source: text,
144
+ id,
145
+ root,
146
+ config,
147
+ manual: false,
148
+ upstream: inputMap ? {
149
+ id: this.resourcePath,
150
+ sourceMapSource: sourceDescriptor(root, id).document.uri,
151
+ map: typeof inputMap === "string" ? inputMap : JSON.stringify(inputMap)
152
+ } : void 0,
153
+ dependencies: await Promise.all([...dependencySources].map(async ([id, pending]) => {
154
+ const { source, map } = await pending;
155
+ return {
156
+ id,
157
+ source,
158
+ upstream: map ? {
159
+ id: cleanModuleId(id),
160
+ sourceMapSource: sourceDescriptor(root, id).document.uri,
161
+ map: typeof map === "string" ? map : JSON.stringify(map)
162
+ } : void 0
163
+ };
164
+ }))
165
+ });
166
+ const cssImport = `import ${JSON.stringify(carrier + "?stillwind-document")};\n`;
167
+ if (projection) return callback(null, cssImport);
168
+ const finalized = finalizeModuleWithMap(output.code);
169
+ const code = sfc || !automatic ? finalized.code : finalized.code.slice(finalized.prefix.length) + "\n" + finalized.prefix + cssImport;
170
+ const map = moduleSourceMap(text, output.code, this.resourcePath, output.mappings, finalized.removed, "");
171
+ const composedMap = composeModuleSourceMap(map, inputMap);
172
+ if (sfc && this.data) this.data.stillwindSourceTransform = {
173
+ code,
174
+ map: composedMap,
175
+ resource: id
176
+ };
177
+ const metadata = {
178
+ ...additionalData,
179
+ stillwind: {
180
+ coverage: plan.coverage,
181
+ designSystem: plan.designSystem,
182
+ producers: plan.producers,
183
+ sourceTransform: {
184
+ resource: id,
185
+ fingerprint: fingerprint(code)
186
+ }
187
+ }
188
+ };
189
+ callback(null, code, composedMap, metadata);
190
+ })().catch((error) => callback(error)).finally(() => compiler?.close());
191
+ }
192
+ /**
193
+ * Keeps webpack pitch data available for sharing transformed SFC code and maps with framework
194
+ * loaders.
195
+ */
196
+ function pitch() {}
197
+ export { webpackLoader as default, pitch };
198
+
199
+ //# sourceMappingURL=loader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loader.js","names":[],"sources":["../../src/webpack/css-value.ts","../../src/webpack/loader.ts"],"sourcesContent":["import { fileURLToPath } from \"node:url\";\n\nimport type { NativeStylesheetPart } from \"@stillwind/native\";\n\n/** An asset referenced by CSS returned through an explicit module value. */\nexport interface CssValueResource {\n /** Token in the CSS text that the fragment loader replaces with an asset URL. */\n placeholder: string;\n /** Resolver identity of the asset, including any resource query. */\n id: string;\n /** Module request relative to the producer directory, stored in the fragment payload. */\n request: string;\n}\n\n/** CSS and asset references encoded in the query of an isolated fragment loader request. */\nexport interface CssFragment {\n /** CSS text for one stylesheet occurrence. */\n css: string;\n /** Resolved assets whose placeholders occur in this fragment. */\n resources: CssValueResource[];\n}\n\n/**\n * Generates a module that imports CSS fragments and exports their ordered values.\n *\n * Each fragment request encodes its CSS and referenced assets. Equal payloads produce equal\n * requests, while the value retains occurrence order.\n *\n * @param parts - Stylesheet occurrences in cascade order. Repeated occurrences keep their\n * positions.\n * @param resources - Resolved assets whose placeholders may occur in the parts.\n * @returns JavaScript exporting `parts`, the joined `css` string, and the same string as its\n * default export.\n */\nexport function cssValueModule(\n parts: readonly NativeStylesheetPart[],\n resources: readonly CssValueResource[],\n): string {\n const imports = parts.map((part, index) => {\n const payload = Buffer.from(\n JSON.stringify({\n css: part.css,\n resources: resources.filter((resource) => part.css.includes(resource.placeholder)),\n } satisfies CssFragment),\n ).toString(\"base64url\");\n const request = `!!${fileURLToPath(\n new URL(\"./fragment-loader.js\", import.meta.resolve(\"@stillwind/integration/webpack\")),\n )}!${fileURLToPath(\n new URL(\"./stillwind-fragment.js\", import.meta.resolve(\"@stillwind/integration/webpack\")),\n )}?css=${payload}`;\n return `import { css as p${index} } from ${JSON.stringify(request)};\\n`;\n });\n const entries = parts.map(\n (part, index) =>\n ` { key: ${JSON.stringify(part.key)}, banners: ${JSON.stringify(part.banners)}, css: p${index} },\\n`,\n );\n return [\n \"// Stillwind CSS value (webpack)\\n\",\n 'import { cssText } from \"stillwind/css\";\\n',\n ...imports,\n \"\\n\",\n \"export const parts = [\\n\",\n ...entries,\n \"];\\n\",\n \"export const css = cssText(parts);\\n\",\n \"export default css;\\n\",\n ].join(\"\");\n}\n","import { createHash } from \"node:crypto\";\nimport path from \"node:path\";\nimport { fileURLToPath, pathToFileURL } from \"node:url\";\n\nimport { resolveIntegrationConfig } from \"@stillwind/config/node\";\nimport {\n cleanModuleId,\n composeModuleSourceMap,\n cssEntrypoint,\n finalizeModuleWithMap,\n loadCssGraph,\n moduleSourceMap,\n nodePluginHost,\n warnRejectedNames,\n type UpstreamSourceMap,\n} from \"@stillwind/host\";\n\nimport { buildCompilerOptions, IntegrationSession } from \"../session.ts\";\nimport { cssValueModule, type CssValueResource } from \"./css-value.ts\";\nimport { recordProducer } from \"./emission.ts\";\nimport { createLoaderHost, watchCompilerFiles } from \"./host.ts\";\nimport {\n classifyRequest,\n relativeRequest,\n requestOptions,\n virtualRequest,\n type LoaderOptions,\n} from \"./requests.ts\";\nimport {\n loaderCompletion,\n type LoaderAdditionalData,\n type SourceTransformContext,\n} from \"./source-map-loader.ts\";\nimport { sourceDescriptor } from \"./sources.ts\";\n\n/**\n * Hashes transformed text to recognize a repeated pass through the same resource.\n *\n * @param source - Exact source text received or produced by the loader.\n * @returns A SHA-256 fingerprint encoded as hexadecimal.\n */\nconst fingerprint = (source: string) => createHash(\"sha256\").update(source).digest(\"hex\");\n\n/**\n * Compiles a producer, CSS projection, or explicit CSS value through the webpack loader protocol.\n *\n * The loader context supplies resolution, file dependencies, options, and an asynchronous callback.\n * Automatic document CSS and projections require `StillwindPlugin` to be installed before\n * compilation. Results and failures are delivered through the callback. SFC transforms also store\n * their code and map in `this.data` for framework map composition.\n *\n * @param this - Active loader context whose data and module metadata retain successful producer transforms.\n * @param source - Source supplied by the preceding loaders. CSS subrequests read the original\n * resource instead.\n * @param inputMap - Map from the supplied source to its original source, when available.\n * @param additionalData - Metadata from preceding loaders, including a prior Stillwind transform\n * fingerprint.\n * @returns No synchronous source. Pass-through and asynchronous results use the loader callback.\n */\nexport default function webpackLoader(\n this: SourceTransformContext<LoaderOptions>,\n source: string,\n inputMap: UpstreamSourceMap,\n additionalData?: LoaderAdditionalData,\n) {\n const callback = loaderCompletion(this);\n const text = String(source);\n const { projection, cssValue, sfc, id, passthrough } = classifyRequest(\n this.resourcePath,\n this.resourceQuery,\n );\n const prior = additionalData?.stillwind?.sourceTransform;\n // Framework loaders can clone the same rule into a subrequest's chain.\n // Skip only an identical output already produced for this resource.\n if (prior?.resource === id && prior.fingerprint === fingerprint(text)) {\n return callback(null, source, inputMap, additionalData);\n }\n if (passthrough) {\n return callback(null, source, inputMap);\n }\n if (\n !projection &&\n !cssValue &&\n !/stillwind\\/(?:alpine|astro|lit|preact|qwik|react|solid|svelte|vanilla|vue|module-css)/.test(\n text,\n )\n ) {\n return callback(null, source, inputMap);\n }\n const supplied = requestOptions(this.getOptions());\n let compiler: IntegrationSession | undefined;\n const {\n read,\n readDependency,\n dependencySources,\n resolveCss,\n resolveAsset,\n resolve,\n watch,\n warn,\n } = createLoaderHost(this, import.meta.filename);\n void (async () => {\n const configuration =\n this._compilation?.__stillwindConfiguration ??\n (await resolveIntegrationConfig(supplied, this.rootContext));\n for (const file of configuration.dependencies) {\n this.addDependency(file);\n }\n for (const file of configuration.missing) {\n this.addMissingDependency(file);\n }\n const { config } = configuration;\n if (config.naming) {\n this.cacheable(false);\n }\n /**\n * Creates a virtual module request using this source file's framework and compiler settings.\n * @param query - Stillwind virtual query selecting the requested CSS or value module.\n * @returns An inline loader request retaining the resource path and resolved configuration.\n */\n const request = (query: string) =>\n virtualRequest(this.resourcePath, sfc, config, import.meta.filename, query, supplied);\n watchCompilerFiles(watch);\n const root = path.resolve(this.rootContext, config.root ?? \".\");\n const css = path.resolve(root, cssEntrypoint(config));\n const loaded = await loadCssGraph(\n css,\n buildCompilerOptions(config),\n {\n resolve: resolveCss,\n read,\n documentUri: (id) => pathToFileURL(id).href,\n sourceMapSource: (id) => pathToFileURL(id).href,\n watch,\n watchDirectory: (id) => this.addContextDependency(id),\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 compiler = new IntegrationSession(\n root,\n loaded.loader,\n config,\n false,\n this.mode === \"development\" ? \"development\" : \"release\",\n loaded.plugins,\n );\n const session = compiler.native;\n const output = await compiler.compile(\n projection || cssValue ? await read(this.resourcePath) : text,\n projection || cssValue ? this.resourcePath : id,\n {\n describe: (id) => sourceDescriptor(root, id),\n resolve,\n read: readDependency,\n watch,\n warn,\n },\n {\n stylesheetImports:\n sfc && !projection && !cssValue && config.automatic !== false\n ? [request(\"stillwind.css\")]\n : undefined,\n moduleCssImport: request(\"stillwind-module-css\"),\n },\n );\n if (!output?.code) {\n return callback(null, projection ? \"\" : source, projection ? null : inputMap);\n }\n const plan = session.planStylesheet({\n modules: [output.moduleId],\n coverage: { kind: \"observed\" },\n placement: \"document\",\n });\n warnRejectedNames(plan.rejectedNames, warn);\n\n const valueResources: CssValueResource[] = [];\n for (const resource of [...loaded.resources, ...plan.resources]) {\n const owner =\n \"moduleId\" in resource ? compiler.resolverId(resource.moduleId) : resource.sourceName;\n const resolved = await resolveAsset(resource.specifier, owner);\n if (!resolved) {\n throw new Error(`Cannot resolve Stillwind resource ${resource.specifier} from ${owner}`);\n }\n watch(cleanModuleId(resolved));\n if (plan.css.includes(resource.placeholder)) {\n valueResources.push({\n placeholder: resource.placeholder,\n id: resolved,\n request: relativeRequest(path.dirname(this.resourcePath), resolved),\n });\n }\n }\n const carrier = relativeRequest(\n path.dirname(this.resourcePath),\n fileURLToPath(\n new URL(\"./stillwind-webpack.css\", import.meta.resolve(\"@stillwind/integration/webpack\")),\n ),\n );\n if (cssValue) {\n return callback(null, cssValueModule(plan.parts, valueResources), null);\n }\n const automatic = (!output.hasModuleCssImport && config.automatic !== false) || projection;\n if (automatic) {\n recordProducer(this, {\n source: text,\n id,\n root,\n config: config,\n manual: false,\n upstream: inputMap\n ? {\n id: this.resourcePath,\n sourceMapSource: sourceDescriptor(root, id).document.uri,\n map: typeof inputMap === \"string\" ? inputMap : JSON.stringify(inputMap),\n }\n : undefined,\n dependencies: await Promise.all(\n [...dependencySources].map(async ([id, pending]) => {\n const { source, map } = await pending;\n return {\n id,\n source,\n upstream: map\n ? {\n id: cleanModuleId(id),\n sourceMapSource: sourceDescriptor(root, id).document.uri,\n map: typeof map === \"string\" ? map : JSON.stringify(map),\n }\n : undefined,\n };\n }),\n ),\n });\n }\n const cssImport = `import ${JSON.stringify(carrier + \"?stillwind-document\")};\\n`;\n if (projection) {\n return callback(null, cssImport);\n }\n const finalized = finalizeModuleWithMap(output.code);\n // Append synthetic imports so RSC directives remain the first statements.\n const code =\n sfc || !automatic\n ? finalized.code\n : finalized.code.slice(finalized.prefix.length) + \"\\n\" + finalized.prefix + cssImport;\n const map = moduleSourceMap(\n text,\n output.code,\n this.resourcePath,\n output.mappings,\n finalized.removed,\n \"\",\n );\n const composedMap = composeModuleSourceMap(map, inputMap);\n if (sfc && this.data) {\n this.data.stillwindSourceTransform = {\n code,\n map: composedMap,\n resource: id,\n };\n }\n const metadata: LoaderAdditionalData = {\n ...additionalData,\n stillwind: {\n coverage: plan.coverage,\n designSystem: plan.designSystem,\n producers: plan.producers,\n sourceTransform: {\n resource: id,\n fingerprint: fingerprint(code),\n },\n },\n };\n callback(null, code, composedMap, metadata);\n })()\n .catch((error) => callback(error))\n .finally(() => compiler?.close());\n}\n\n/**\n * Keeps webpack pitch data available for sharing transformed SFC code and maps with framework\n * loaders.\n */\nexport function pitch() {}\n"],"mappings":"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"}
@@ -0,0 +1,11 @@
1
+ import { UpstreamSourceMap } from "@stillwind/host";
2
+ import { LoaderContext } from "webpack";
3
+ /**
4
+ * Returns source text as a module value so importModule never executes application code.
5
+ * @param this - Loader context retained for compatibility with the bundler loader protocol.
6
+ * @param source - Source produced by preceding loaders, serialized as a string literal.
7
+ * @param map - Optional upstream map serialized as a module export. Omission exports null.
8
+ * @returns JavaScript exporting captured source and its map without evaluating that source.
9
+ */
10
+ export default function webpackSourceLoader(this: LoaderContext<unknown>, source: string, map: UpstreamSourceMap): string;
11
+ //# sourceMappingURL=source-loader.d.ts.map
@@ -0,0 +1,17 @@
1
+ // src/webpack/source-loader.ts
2
+ /**
3
+ * Returns source text as a module value so importModule never executes application code.
4
+ * @param this - Loader context retained for compatibility with the bundler loader protocol.
5
+ * @param source - Source produced by preceding loaders, serialized as a string literal.
6
+ * @param map - Optional upstream map serialized as a module export. Omission exports null.
7
+ * @returns JavaScript exporting captured source and its map without evaluating that source.
8
+ */
9
+ function webpackSourceLoader(source, map) {
10
+ return `// Stillwind source loader (webpack)
11
+ export const source = ${JSON.stringify(String(source))};
12
+ export const map = ${JSON.stringify(map ?? null)};
13
+ `;
14
+ }
15
+ export { webpackSourceLoader as default };
16
+
17
+ //# sourceMappingURL=source-loader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"source-loader.js","names":[],"sources":["../../src/webpack/source-loader.ts"],"sourcesContent":["import type { UpstreamSourceMap } from \"@stillwind/host\";\nimport type { LoaderContext } from \"webpack\";\n\n/**\n * Returns source text as a module value so importModule never executes application code.\n * @param this - Loader context retained for compatibility with the bundler loader protocol.\n * @param source - Source produced by preceding loaders, serialized as a string literal.\n * @param map - Optional upstream map serialized as a module export. Omission exports null.\n * @returns JavaScript exporting captured source and its map without evaluating that source.\n */\nexport default function webpackSourceLoader(\n this: LoaderContext<unknown>,\n source: string,\n map: UpstreamSourceMap,\n) {\n return `// Stillwind source loader (webpack)\nexport const source = ${JSON.stringify(String(source))};\nexport const map = ${JSON.stringify(map ?? null)};\n`;\n}\n"],"mappings":";;;;;;;;AAUA,SAAwB,oBAEtB,QACA,KACA;CACA,OAAO;wBACe,KAAK,UAAU,OAAO,MAAM,CAAC,EAAE;qBAClC,KAAK,UAAU,OAAO,IAAI,EAAE;;AAEjD"}
@@ -0,0 +1,2 @@
1
+ import { a as SourceTransformData, i as SourceTransformContext, n as LoaderCompletion, o as loaderCompletion, r as SourceTransform, s as webpackSourceMapLoader, t as LoaderAdditionalData } from "../source-map-loader-CBLiYaBI.js";
2
+ export { LoaderAdditionalData, LoaderCompletion, SourceTransform, SourceTransformContext, SourceTransformData, webpackSourceMapLoader as default, loaderCompletion };
@@ -0,0 +1,35 @@
1
+ import { composeFrameworkSourceMap } from "@stillwind/host";
2
+ // src/webpack/source-map-loader.ts
3
+ /**
4
+ * Obtains an asynchronous completion callback for the shared loader protocol.
5
+ *
6
+ * @param context - webpack-compatible loader context for the current invocation.
7
+ * @returns The runner's callback. Stillwind metadata does not require a `webpackAST` field, and
8
+ * composed maps can contain nullable source content allowed by the source-map library.
9
+ */
10
+ function loaderCompletion(context) {
11
+ return context.async();
12
+ }
13
+ /**
14
+ * Composes a framework's output map through the Stillwind transform stored in pitch data.
15
+ *
16
+ * @param this - Loader context whose chain exposes the preceding Stillwind transform.
17
+ * @param source - Framework output forwarded unchanged.
18
+ * @param inputMap - Framework map, when available.
19
+ * @param additionalData - Additional loader data forwarded unchanged.
20
+ * @returns Undefined after completing the loader callback.
21
+ */
22
+ function webpackSourceMapLoader(source, inputMap, additionalData) {
23
+ const callback = loaderCompletion(this);
24
+ if (this.mode !== "production" && this._module?.matchResource && /[?&]vue&type=script(?:&|$)/.test(this.resourceQuery ?? "")) return callback(null, source, inputMap, additionalData);
25
+ const transform = this.loaders.map((loader) => (loader.data ?? loader.loaderItem?.data)?.stillwindSourceTransform).find((entry) => entry?.resource === this.resourcePath);
26
+ if (!inputMap || !transform) return callback(null, source, inputMap, additionalData);
27
+ try {
28
+ callback(null, source, composeFrameworkSourceMap(inputMap, JSON.stringify(transform.map), transform.code), additionalData);
29
+ } catch (error) {
30
+ callback(error);
31
+ }
32
+ }
33
+ export { webpackSourceMapLoader as default, loaderCompletion };
34
+
35
+ //# sourceMappingURL=source-map-loader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"source-map-loader.js","names":[],"sources":["../../src/webpack/source-map-loader.ts"],"sourcesContent":["import type { EncodedSourceMap } from \"@jridgewell/gen-mapping\";\nimport type { SourceMap } from \"@jridgewell/remapping\";\nimport type { SourceMapInput } from \"@jridgewell/trace-mapping\";\nimport { composeFrameworkSourceMap, type UpstreamSourceMap } from \"@stillwind/host\";\nimport type { NativeStylesheetPlan } from \"@stillwind/native\";\nimport type { LoaderContext } from \"webpack\";\n\n/** Stillwind metadata passed between loaders while preserving other plugins' additional fields. */\nexport interface LoaderAdditionalData {\n /** AST supplied by a preceding webpack loader, when available. */\n webpackAST?: object;\n /** Compiler output and identity of a source already transformed by Stillwind. */\n stillwind?: Partial<Pick<NativeStylesheetPlan, \"coverage\" | \"designSystem\" | \"producers\">> & {\n /** Resource identity and digest used to avoid compiling an identical transform twice. */\n sourceTransform?: {\n /** Resource path and query that selected the source. */\n resource: string;\n /** SHA-256 hex digest of the transformed source. */\n fingerprint: string;\n };\n };\n /** Data owned by other loaders, forwarded without interpretation. */\n [key: string]: unknown;\n}\n\n/** Transformed SFC text and its map shared through the pitch data of one loader. */\nexport interface SourceTransform {\n /** Source after Stillwind compilation and finalization. */\n code: string;\n /** Map from transformed code back to the original component. */\n map: EncodedSourceMap | SourceMap;\n /** Resource identity that must match the source-map bridge's resource path. */\n resource: string;\n}\n\n/** Pitch data retained for source-map composition after framework loaders have run. */\nexport interface SourceTransformData {\n /** Stillwind transform for this loader invocation, when an SFC was compiled. */\n stillwindSourceTransform?: SourceTransform;\n}\n\n/** Loader context with typed pitch data for both webpack and Rspack's loader runner. */\nexport type SourceTransformContext<Options> = Omit<LoaderContext<Options>, \"data\" | \"loaders\"> & {\n /** Data shared by this loader's pitch and normal phases. */\n data: SourceTransformData;\n /** Loader chain whose entries expose pitch data in either runner's representation. */\n loaders: (Omit<LoaderContext<Options>[\"loaders\"][number], \"data\"> & {\n /** Pitch data exposed directly by webpack. */\n data?: SourceTransformData;\n /** Pitch data exposed through Rspack 2's loader item. */\n loaderItem?: {\n /** Optional per-loader pitch data containing the preceding Stillwind transform. */\n data?: SourceTransformData;\n };\n })[];\n};\n\n/**\n * Completes a loader invocation with maps and optional metadata accepted by the loader runners.\n *\n * @param error - Failure, or null or undefined for successful completion.\n * @param source - Generated or unchanged source text.\n * @param map - Upstream map or map chain supplied by loaders, when available.\n * @param data - Additional data forwarded to the next loader, when available.\n */\nexport type LoaderCompletion = (\n error?: unknown,\n source?: string | Buffer,\n map?: UpstreamSourceMap | EncodedSourceMap | SourceMap,\n data?: LoaderAdditionalData,\n) => void;\n\n/**\n * Obtains an asynchronous completion callback for the shared loader protocol.\n *\n * @param context - webpack-compatible loader context for the current invocation.\n * @returns The runner's callback. Stillwind metadata does not require a `webpackAST` field, and\n * composed maps can contain nullable source content allowed by the source-map library.\n */\nexport function loaderCompletion(context: Pick<LoaderContext<unknown>, \"async\">): LoaderCompletion {\n return context.async() as LoaderCompletion;\n}\n\n/**\n * Composes a framework's output map through the Stillwind transform stored in pitch data.\n *\n * @param this - Loader context whose chain exposes the preceding Stillwind transform.\n * @param source - Framework output forwarded unchanged.\n * @param inputMap - Framework map, when available.\n * @param additionalData - Additional loader data forwarded unchanged.\n * @returns Undefined after completing the loader callback.\n */\nexport default function webpackSourceMapLoader(\n this: SourceTransformContext<unknown>,\n source: string,\n inputMap: SourceMapInput | null | undefined,\n additionalData?: LoaderAdditionalData,\n) {\n const callback = loaderCompletion(this);\n\n // Vue development script maps include the template. Replacing their embedded source\n // changes script hashes on template edits and makes Vue remount the component.\n if (\n this.mode !== \"production\" &&\n this._module?.matchResource &&\n /[?&]vue&type=script(?:&|$)/.test(this.resourceQuery ?? \"\")\n ) {\n return callback(null, source, inputMap, additionalData);\n }\n\n // Rspack 2 stores chain data on loaderItem; webpack exposes it directly.\n // Keep this compatibility boundary local and cover both official runners.\n const transform = this.loaders\n .map((loader) => (loader.data ?? loader.loaderItem?.data)?.stillwindSourceTransform)\n .find((entry) => entry?.resource === this.resourcePath);\n if (!inputMap || !transform) {\n return callback(null, source, inputMap, additionalData);\n }\n\n try {\n const map = composeFrameworkSourceMap(inputMap, JSON.stringify(transform.map), transform.code);\n callback(null, source, map, additionalData);\n } catch (error) {\n callback(error);\n }\n}\n"],"mappings":";;;;;;;;;AA+EA,SAAgB,iBAAiB,SAAkE;CACjG,OAAO,QAAQ,MAAM;AACvB;;;;;;;;;;AAWA,SAAwB,uBAEtB,QACA,UACA,gBACA;CACA,MAAM,WAAW,iBAAiB,IAAI;CAItC,IACE,KAAK,SAAS,gBACd,KAAK,SAAS,iBACd,6BAA6B,KAAK,KAAK,iBAAiB,EAAE,GAE1D,OAAO,SAAS,MAAM,QAAQ,UAAU,cAAc;CAKxD,MAAM,YAAY,KAAK,QACpB,KAAK,YAAY,OAAO,QAAQ,OAAO,YAAY,KAAA,EAAO,wBAAwB,CAAC,CACnF,MAAM,UAAU,OAAO,aAAa,KAAK,YAAY;CACxD,IAAI,CAAC,YAAY,CAAC,WAChB,OAAO,SAAS,MAAM,QAAQ,UAAU,cAAc;CAGxD,IAAI;EAEF,SAAS,MAAM,QADH,0BAA0B,UAAU,KAAK,UAAU,UAAU,GAAG,GAAG,UAAU,IAChE,GAAG,cAAc;CAC5C,SAAS,OAAO;EACd,SAAS,KAAK;CAChB;AACF"}