@stillwind/integration 0.8.0 → 0.10.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 (80) hide show
  1. package/CHANGELOG.md +190 -0
  2. package/dist/astro/development.d.ts +2 -0
  3. package/dist/astro/development.js +2 -0
  4. package/dist/astro/development.js.map +1 -1
  5. package/dist/astro/index.d.ts +1 -1
  6. package/dist/astro/index.js +8 -2
  7. package/dist/astro/index.js.map +1 -1
  8. package/dist/{emission-BVi5aRbb.js → emission-BpaN4Z4m.js} +212 -69
  9. package/dist/emission-BpaN4Z4m.js.map +1 -0
  10. package/dist/fresh/index.d.ts +1 -1
  11. package/dist/fresh/index.js +1 -1
  12. package/dist/{index-DFfbZxNT.d.ts → index-B6EtrWus.d.ts} +2 -2
  13. package/dist/loader-cache-DfOGY8AJ.js +231 -0
  14. package/dist/loader-cache-DfOGY8AJ.js.map +1 -0
  15. package/dist/next/css-loader.d.ts +5 -2
  16. package/dist/next/css-loader.js +7 -2
  17. package/dist/next/css-loader.js.map +1 -1
  18. package/dist/next/index.js +2 -0
  19. package/dist/next/index.js.map +1 -1
  20. package/dist/{node-loader-D-3Ynpy1.d.ts → node-loader-Bqg7E5zq.d.ts} +6 -3
  21. package/dist/nuxt/index.d.ts +2 -2
  22. package/dist/nuxt/index.js +2 -1
  23. package/dist/nuxt/index.js.map +1 -1
  24. package/dist/{plugin-aV0zIIAe.d.ts → plugin-BAG0ZI1X.d.ts} +58 -6
  25. package/dist/{plugin-mPiBLdqa.js → plugin-D-45o54j.js} +5 -2
  26. package/dist/plugin-D-45o54j.js.map +1 -0
  27. package/dist/{plugin-ByYcpBcE.js → plugin-DQH8QlYh.js} +331 -36
  28. package/dist/plugin-DQH8QlYh.js.map +1 -0
  29. package/dist/{project-DUGu8g_L.d.ts → project-B_KFQist.d.ts} +2 -2
  30. package/dist/project-egWF2vWJ.js +428 -0
  31. package/dist/project-egWF2vWJ.js.map +1 -0
  32. package/dist/{project-BNw0nZBE.d.ts → project-mB7CODIs.d.ts} +46 -7
  33. package/dist/rsbuild/index.d.ts +4 -1
  34. package/dist/rsbuild/index.js +2 -2
  35. package/dist/rsbuild/index.js.map +1 -1
  36. package/dist/rspack/index.d.ts +1 -1
  37. package/dist/rspack/index.js +1 -1
  38. package/dist/session-Cxf4D6oQ.d.ts +163 -0
  39. package/dist/source-entries-J5azZ_-z.js +350 -0
  40. package/dist/source-entries-J5azZ_-z.js.map +1 -0
  41. package/dist/turbopack/css-loader.d.ts +5 -2
  42. package/dist/turbopack/css-loader.js +53 -17
  43. package/dist/turbopack/css-loader.js.map +1 -1
  44. package/dist/turbopack/index.d.ts +2 -2
  45. package/dist/turbopack/loader.d.ts +3 -2
  46. package/dist/turbopack/loader.js +10 -4
  47. package/dist/turbopack/loader.js.map +1 -1
  48. package/dist/turbopack/node-loader.d.ts +1 -1
  49. package/dist/turbopack/node-loader.js +1 -0
  50. package/dist/turbopack/node-loader.js.map +1 -1
  51. package/dist/vite/index.d.ts +2 -2
  52. package/dist/vite/index.js +1 -1
  53. package/dist/vite/runtime.d.ts +10 -3
  54. package/dist/vite/runtime.js +8 -1
  55. package/dist/vite/runtime.js.map +1 -1
  56. package/dist/webpack/css-loader.js +1 -1
  57. package/dist/webpack/document-loader.d.ts +4 -1
  58. package/dist/webpack/document-loader.js +5 -2
  59. package/dist/webpack/document-loader.js.map +1 -1
  60. package/dist/webpack/fragment-loader.d.ts +1 -0
  61. package/dist/webpack/fragment-loader.js +1 -0
  62. package/dist/webpack/fragment-loader.js.map +1 -1
  63. package/dist/webpack/index.d.ts +1 -1
  64. package/dist/webpack/index.js +1 -1
  65. package/dist/webpack/loader.js +15 -21
  66. package/dist/webpack/loader.js.map +1 -1
  67. package/dist/webpack/source-loader.d.ts +1 -0
  68. package/dist/webpack/source-loader.js +1 -0
  69. package/dist/webpack/source-loader.js.map +1 -1
  70. package/package.json +19 -17
  71. package/dist/binding-files-Ds5NpyVV.js +0 -45
  72. package/dist/binding-files-Ds5NpyVV.js.map +0 -1
  73. package/dist/emission-BVi5aRbb.js.map +0 -1
  74. package/dist/plugin-ByYcpBcE.js.map +0 -1
  75. package/dist/plugin-mPiBLdqa.js.map +0 -1
  76. package/dist/project-C3IH7geC.js +0 -182
  77. package/dist/project-C3IH7geC.js.map +0 -1
  78. package/dist/session-B9_rp9TH.d.ts +0 -72
  79. package/dist/session-DHUCQMG5.js +0 -117
  80. package/dist/session-DHUCQMG5.js.map +0 -1
@@ -0,0 +1,231 @@
1
+ import { createRequire } from "node:module";
2
+ import { createHash } from "node:crypto";
3
+ import { fileURLToPath } from "node:url";
4
+ import path from "node:path";
5
+ import { existsSync, readFileSync, readdirSync } from "node:fs";
6
+ // src/binding-files.ts
7
+ /**
8
+ * Returns existing runtime files from the generated loader and installed binding
9
+ * packages. Watching both locations covers napi-rs's local and packaged loading.
10
+ * Missing optional packages are skipped. Other filesystem and resolution errors
11
+ * propagate to the caller.
12
+ *
13
+ * @returns Distinct absolute runtime paths in discovery order, including the generated loader entry.
14
+ * @throws If metadata, filesystem access, or resolution fails beyond a missing optional package.
15
+ */
16
+ function nativeBindingFiles() {
17
+ const entry = fileURLToPath(import.meta.resolve("@stillwind/native"));
18
+ const require = createRequire(entry);
19
+ const files = /* @__PURE__ */ new Set([entry]);
20
+ /**
21
+ * Adds native and WASM runtime companions from an installed runtime directory.
22
+ *
23
+ * @param directory - Existing directory to enumerate. Matching filenames are added to files.
24
+ * @throws If enumeration fails.
25
+ */
26
+ const collect = (directory) => {
27
+ for (const name of readdirSync(directory)) if ((name.startsWith("stillwind_native.") || name.startsWith("wasi-worker")) && /\.(node|wasm|cjs|mjs|js)$/.test(name)) files.add(path.join(directory, name));
28
+ };
29
+ collect(path.dirname(entry));
30
+ const manifest = JSON.parse(readFileSync(new URL(import.meta.resolve("@stillwind/native/package.json")), "utf8"));
31
+ for (const name of Object.keys(manifest.optionalDependencies)) {
32
+ let runtime;
33
+ try {
34
+ runtime = require.resolve(name);
35
+ } catch (error) {
36
+ if (error.code === "MODULE_NOT_FOUND") continue;
37
+ throw error;
38
+ }
39
+ if (existsSync(runtime)) {
40
+ files.add(runtime);
41
+ collect(path.dirname(runtime));
42
+ }
43
+ }
44
+ return [...files];
45
+ }
46
+ // src/loader-cache.ts
47
+ /**
48
+ * Reuses values that bundler loaders rebuild from the same files in one process.
49
+ *
50
+ * webpack, Rspack, and Turbopack create a loader context for each module, and Turbopack runs loaders
51
+ * in worker processes that serve many modules. Evaluated configuration and a loaded design system
52
+ * with its compiler session can serve every call while the files that they read stay unchanged.
53
+ *
54
+ * The main entry points are {@link LoaderCache} and {@link recordInputs}.
55
+ */
56
+ /**
57
+ * Cache of values keyed by the settings that create them.
58
+ *
59
+ * Concurrent calls with the same key share one creation. A value is closed when a newer value
60
+ * replaces it and no lease uses it, and also after it has been idle for the configured time. A
61
+ * closed value must stay usable, because an idle value remains in the cache.
62
+ */
63
+ var LoaderCache = class {
64
+ #entries = /* @__PURE__ */ new Map();
65
+ #close;
66
+ #idleMs;
67
+ /**
68
+ * @param close - Releases resources of a value, such as a checker process. The value must stay
69
+ * usable after this call.
70
+ * @param idleMs - Milliseconds without leases after which a value is closed. The timer does not
71
+ * keep the process alive.
72
+ */
73
+ constructor(close = () => {}, idleMs = Number.POSITIVE_INFINITY) {
74
+ this.#close = close;
75
+ this.#idleMs = idleMs;
76
+ }
77
+ /**
78
+ * Returns the cached value for a key, or creates one when it is missing or its inputs changed.
79
+ *
80
+ * @param key - Serialized settings that fully determine the created value.
81
+ * @param read - Reader used to compare the recorded inputs with the current files.
82
+ * @param create - Creates the value and records the files that it depends on.
83
+ * @returns A lease for the value. The caller must end it after its last use.
84
+ * @throws If reading an input fails, or if creation fails. A failed creation is not cached.
85
+ */
86
+ async use(key, read, create) {
87
+ for (;;) {
88
+ const cached = this.#entries.get(key);
89
+ if (!cached) {
90
+ const created = create().then(({ value, inputs }) => ({
91
+ value,
92
+ inputs,
93
+ active: 0,
94
+ replaced: false
95
+ }));
96
+ this.#entries.set(key, created);
97
+ created.catch(() => {
98
+ if (this.#entries.get(key) === created) this.#entries.delete(key);
99
+ });
100
+ return this.#lease(await created);
101
+ }
102
+ const entry = await cached.catch(() => void 0);
103
+ if (!entry) continue;
104
+ const lease = this.#lease(entry);
105
+ if (await unchanged(entry.inputs, read).catch(() => false)) return lease;
106
+ if (this.#entries.get(key) === cached) {
107
+ this.#entries.delete(key);
108
+ entry.replaced = true;
109
+ }
110
+ lease.done();
111
+ }
112
+ }
113
+ /** Closes every value that no lease uses. Values in use close when their last lease ends. */
114
+ closeIdle() {
115
+ for (const pending of this.#entries.values()) pending.then((entry) => {
116
+ if (!entry.active) {
117
+ clearTimeout(entry.idle);
118
+ this.#close(entry.value);
119
+ }
120
+ }, () => {});
121
+ }
122
+ #lease(entry) {
123
+ clearTimeout(entry.idle);
124
+ entry.idle = void 0;
125
+ entry.active += 1;
126
+ let ended = false;
127
+ return {
128
+ value: entry.value,
129
+ inputs: entry.inputs,
130
+ done: () => {
131
+ if (ended) return;
132
+ ended = true;
133
+ entry.active -= 1;
134
+ if (entry.active) return;
135
+ if (entry.replaced) this.#close(entry.value);
136
+ else if (Number.isFinite(this.#idleMs)) {
137
+ entry.idle = setTimeout(() => {
138
+ entry.idle = void 0;
139
+ this.#close(entry.value);
140
+ }, this.#idleMs);
141
+ entry.idle.unref?.();
142
+ }
143
+ }
144
+ };
145
+ }
146
+ };
147
+ /**
148
+ * Checks whether recorded inputs still match the files.
149
+ *
150
+ * @param inputs - Inputs to compare. Files registered after creation receive their first digest.
151
+ * @param read - Reader for the current files.
152
+ * @returns A promise for true when every file has its recorded contents, every missing file is
153
+ * still missing, and no directory was recorded.
154
+ * @throws If reading a file fails for a reason other than its absence.
155
+ */
156
+ async function unchanged(inputs, read) {
157
+ if (inputs.directories.size) return false;
158
+ const files = await Promise.all([...inputs.files].map(async ([id, recorded]) => {
159
+ const text = await read(id);
160
+ if (text === void 0) return false;
161
+ if (recorded === void 0) {
162
+ inputs.files.set(id, digest(text));
163
+ return true;
164
+ }
165
+ return digest(text) === recorded;
166
+ }));
167
+ const missing = await Promise.all([...inputs.missing].map(async (id) => await read(id) === void 0));
168
+ return files.every(Boolean) && missing.every(Boolean);
169
+ }
170
+ /**
171
+ * Creates a recorder for the files that one value creation depends on.
172
+ *
173
+ * @param read - Reader through the bundler filesystem. It resolves undefined for a missing file.
174
+ * @returns A recorder whose reads reject for a missing file.
175
+ */
176
+ function recordInputs(read) {
177
+ const inputs = {
178
+ files: /* @__PURE__ */ new Map(),
179
+ missing: /* @__PURE__ */ new Set(),
180
+ directories: /* @__PURE__ */ new Set()
181
+ };
182
+ let finished = false;
183
+ const watched = /* @__PURE__ */ new Set();
184
+ return {
185
+ inputs,
186
+ async read(id) {
187
+ const text = await read(id);
188
+ if (text === void 0) throw Object.assign(/* @__PURE__ */ new Error(`ENOENT: no such file or directory, open '${id}'`), {
189
+ code: "ENOENT",
190
+ path: id
191
+ });
192
+ inputs.files.set(id, digest(text));
193
+ return text;
194
+ },
195
+ watch(id) {
196
+ if (finished) {
197
+ if (!inputs.files.has(id)) inputs.files.set(id, void 0);
198
+ return;
199
+ }
200
+ watched.add(id);
201
+ },
202
+ watchMissing(id) {
203
+ inputs.missing.add(id);
204
+ },
205
+ watchDirectory(id) {
206
+ inputs.directories.add(id);
207
+ },
208
+ async finish() {
209
+ await Promise.all([...watched].map(async (id) => {
210
+ if (inputs.files.has(id)) return;
211
+ const text = await read(id);
212
+ if (text === void 0) inputs.missing.add(id);
213
+ else inputs.files.set(id, digest(text));
214
+ }));
215
+ finished = true;
216
+ return inputs;
217
+ }
218
+ };
219
+ }
220
+ /**
221
+ * Hashes file text for input comparison.
222
+ *
223
+ * @param text - Exact file contents.
224
+ * @returns A SHA-256 digest encoded as hexadecimal.
225
+ */
226
+ function digest(text) {
227
+ return createHash("sha256").update(text).digest("hex");
228
+ }
229
+ export { recordInputs as n, nativeBindingFiles as r, LoaderCache as t };
230
+
231
+ //# sourceMappingURL=loader-cache-DfOGY8AJ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loader-cache-DfOGY8AJ.js","names":[],"sources":["../src/binding-files.ts","../src/loader-cache.ts"],"sourcesContent":["import { existsSync, readFileSync, readdirSync } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\n/**\n * Returns existing runtime files from the generated loader and installed binding\n * packages. Watching both locations covers napi-rs's local and packaged loading.\n * Missing optional packages are skipped. Other filesystem and resolution errors\n * propagate to the caller.\n *\n * @returns Distinct absolute runtime paths in discovery order, including the generated loader entry.\n * @throws If metadata, filesystem access, or resolution fails beyond a missing optional package.\n */\nexport function nativeBindingFiles(): string[] {\n const entry = fileURLToPath(import.meta.resolve(\"@stillwind/native\"));\n const require = createRequire(entry);\n const files = new Set([entry]);\n /**\n * Adds native and WASM runtime companions from an installed runtime directory.\n *\n * @param directory - Existing directory to enumerate. Matching filenames are added to files.\n * @throws If enumeration fails.\n */\n const collect = (directory: string) => {\n for (const name of readdirSync(directory)) {\n if (\n (name.startsWith(\"stillwind_native.\") || name.startsWith(\"wasi-worker\")) &&\n /\\.(node|wasm|cjs|mjs|js)$/.test(name)\n ) {\n files.add(path.join(directory, name));\n }\n }\n };\n collect(path.dirname(entry));\n const manifest = JSON.parse(\n readFileSync(new URL(import.meta.resolve(\"@stillwind/native/package.json\")), \"utf8\"),\n ) as {\n /** Optional binding package names mapped to their version requirements in generated metadata. */\n optionalDependencies: Record<string, string>;\n };\n for (const name of Object.keys(manifest.optionalDependencies)) {\n let runtime: string;\n try {\n runtime = require.resolve(name);\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === \"MODULE_NOT_FOUND\") {\n continue;\n }\n throw error;\n }\n if (existsSync(runtime)) {\n files.add(runtime);\n collect(path.dirname(runtime));\n }\n }\n return [...files];\n}\n","/**\n * Reuses values that bundler loaders rebuild from the same files in one process.\n *\n * webpack, Rspack, and Turbopack create a loader context for each module, and Turbopack runs loaders\n * in worker processes that serve many modules. Evaluated configuration and a loaded design system\n * with its compiler session can serve every call while the files that they read stay unchanged.\n *\n * The main entry points are {@link LoaderCache} and {@link recordInputs}.\n */\nimport { createHash } from \"node:crypto\";\n\n/**\n * Reads a file to check a cached value.\n *\n * @param id - Absolute file path.\n * @returns A promise for the file text, or undefined when the file does not exist.\n * @throws If reading fails for another reason.\n */\nexport type InputReader = (id: string) => Promise<string | undefined>;\n\n/** Files that the creation of a cached value read or registered as dependencies. */\nexport interface LoaderInputs {\n /**\n * SHA-256 digests of file contents, keyed by absolute path. Undefined marks a file that was\n * registered after creation, whose next check records its digest.\n */\n files: Map<string, string | undefined>;\n /** Absolute paths that did not exist. */\n missing: Set<string>;\n /** Directories whose listings affect the value. A value with directories is never reused. */\n directories: Set<string>;\n}\n\n/** Use of a cached value by one loader call. */\nexport interface LoaderLease<T> {\n /** Shared value. The caller must not use it after {@link LoaderLease.done}. */\n value: T;\n /** Files to register as dependencies of the loader result. */\n inputs: LoaderInputs;\n /** Ends this use. Calling it again has no effect. */\n done: () => void;\n}\n\n/** One cached value with its inputs and current uses. */\ninterface CacheEntry<T> {\n value: T;\n inputs: LoaderInputs;\n /** Number of leases that have not ended. */\n active: number;\n /** Whether a newer value replaced this one, so that the last lease closes it. */\n replaced: boolean;\n /** Timer that closes the value after the last lease ends, if it is still idle. */\n idle?: ReturnType<typeof setTimeout>;\n}\n\n/**\n * Cache of values keyed by the settings that create them.\n *\n * Concurrent calls with the same key share one creation. A value is closed when a newer value\n * replaces it and no lease uses it, and also after it has been idle for the configured time. A\n * closed value must stay usable, because an idle value remains in the cache.\n */\nexport class LoaderCache<T> {\n readonly #entries = new Map<string, Promise<CacheEntry<T>>>();\n readonly #close: (value: T) => void;\n readonly #idleMs: number;\n\n /**\n * @param close - Releases resources of a value, such as a checker process. The value must stay\n * usable after this call.\n * @param idleMs - Milliseconds without leases after which a value is closed. The timer does not\n * keep the process alive.\n */\n constructor(close: (value: T) => void = () => {}, idleMs = Number.POSITIVE_INFINITY) {\n this.#close = close;\n this.#idleMs = idleMs;\n }\n\n /**\n * Returns the cached value for a key, or creates one when it is missing or its inputs changed.\n *\n * @param key - Serialized settings that fully determine the created value.\n * @param read - Reader used to compare the recorded inputs with the current files.\n * @param create - Creates the value and records the files that it depends on.\n * @returns A lease for the value. The caller must end it after its last use.\n * @throws If reading an input fails, or if creation fails. A failed creation is not cached.\n */\n async use(\n key: string,\n read: InputReader,\n create: () => Promise<{ value: T; inputs: LoaderInputs }>,\n ): Promise<LoaderLease<T>> {\n for (;;) {\n const cached = this.#entries.get(key);\n if (!cached) {\n const created = create().then(({ value, inputs }) => ({\n value,\n inputs,\n active: 0,\n replaced: false,\n }));\n this.#entries.set(key, created);\n created.catch(() => {\n if (this.#entries.get(key) === created) {\n this.#entries.delete(key);\n }\n });\n return this.#lease(await created);\n }\n const entry = await cached.catch(() => undefined);\n if (!entry) {\n continue;\n }\n // Hold the entry while its inputs are read, so that a replacement does not close it early.\n const lease = this.#lease(entry);\n if (await unchanged(entry.inputs, read).catch(() => false)) {\n return lease;\n }\n if (this.#entries.get(key) === cached) {\n this.#entries.delete(key);\n entry.replaced = true;\n }\n lease.done();\n }\n }\n\n /** Closes every value that no lease uses. Values in use close when their last lease ends. */\n closeIdle(): void {\n for (const pending of this.#entries.values()) {\n void pending.then(\n (entry) => {\n if (!entry.active) {\n clearTimeout(entry.idle);\n this.#close(entry.value);\n }\n },\n () => {},\n );\n }\n }\n\n #lease(entry: CacheEntry<T>): LoaderLease<T> {\n clearTimeout(entry.idle);\n entry.idle = undefined;\n entry.active += 1;\n let ended = false;\n return {\n value: entry.value,\n inputs: entry.inputs,\n done: () => {\n if (ended) {\n return;\n }\n ended = true;\n entry.active -= 1;\n if (entry.active) {\n return;\n }\n if (entry.replaced) {\n this.#close(entry.value);\n } else if (Number.isFinite(this.#idleMs)) {\n entry.idle = setTimeout(() => {\n entry.idle = undefined;\n this.#close(entry.value);\n }, this.#idleMs);\n entry.idle.unref?.();\n }\n },\n };\n }\n}\n\n/**\n * Checks whether recorded inputs still match the files.\n *\n * @param inputs - Inputs to compare. Files registered after creation receive their first digest.\n * @param read - Reader for the current files.\n * @returns A promise for true when every file has its recorded contents, every missing file is\n * still missing, and no directory was recorded.\n * @throws If reading a file fails for a reason other than its absence.\n */\nasync function unchanged(inputs: LoaderInputs, read: InputReader): Promise<boolean> {\n if (inputs.directories.size) {\n return false;\n }\n const files = await Promise.all(\n [...inputs.files].map(async ([id, recorded]) => {\n const text = await read(id);\n if (text === undefined) {\n return false;\n }\n if (recorded === undefined) {\n inputs.files.set(id, digest(text));\n return true;\n }\n return digest(text) === recorded;\n }),\n );\n const missing = await Promise.all(\n [...inputs.missing].map(async (id) => (await read(id)) === undefined),\n );\n return files.every(Boolean) && missing.every(Boolean);\n}\n\n/** Recorder of the files that one value creation reads and registers. */\nexport interface InputRecorder {\n /** Recorded inputs. Registrations after {@link InputRecorder.finish} still add files. */\n inputs: LoaderInputs;\n /**\n * Reads a file and records its digest.\n *\n * @param id - Absolute file path.\n * @returns A promise for the file text.\n * @throws If the file cannot be read.\n */\n read: (id: string) => Promise<string>;\n /**\n * Records a file dependency. A file that creation did not read receives its digest in\n * {@link InputRecorder.finish}.\n *\n * @param id - Absolute file path.\n */\n watch: (id: string) => void;\n /**\n * Records a missing file dependency.\n *\n * @param id - Absolute file path.\n */\n watchMissing: (id: string) => void;\n /**\n * Records a directory dependency, which prevents reuse of the value.\n *\n * @param id - Absolute directory path.\n */\n watchDirectory: (id: string) => void;\n /**\n * Records digests of registered files that creation did not read.\n *\n * @returns A promise for the recorded inputs.\n * @throws If reading a file fails for a reason other than its absence.\n */\n finish: () => Promise<LoaderInputs>;\n}\n\n/**\n * Creates a recorder for the files that one value creation depends on.\n *\n * @param read - Reader through the bundler filesystem. It resolves undefined for a missing file.\n * @returns A recorder whose reads reject for a missing file.\n */\nexport function recordInputs(read: InputReader): InputRecorder {\n const inputs: LoaderInputs = {\n files: new Map(),\n missing: new Set(),\n directories: new Set(),\n };\n let finished = false;\n const watched = new Set<string>();\n return {\n inputs,\n async read(id) {\n const text = await read(id);\n if (text === undefined) {\n throw Object.assign(new Error(`ENOENT: no such file or directory, open '${id}'`), {\n code: \"ENOENT\",\n path: id,\n });\n }\n inputs.files.set(id, digest(text));\n return text;\n },\n watch(id) {\n if (finished) {\n if (!inputs.files.has(id)) {\n inputs.files.set(id, undefined);\n }\n return;\n }\n watched.add(id);\n },\n watchMissing(id) {\n inputs.missing.add(id);\n },\n watchDirectory(id) {\n inputs.directories.add(id);\n },\n async finish() {\n await Promise.all(\n [...watched].map(async (id) => {\n if (inputs.files.has(id)) {\n return;\n }\n const text = await read(id);\n if (text === undefined) {\n inputs.missing.add(id);\n } else {\n inputs.files.set(id, digest(text));\n }\n }),\n );\n finished = true;\n return inputs;\n },\n };\n}\n\n/**\n * Hashes file text for input comparison.\n *\n * @param text - Exact file contents.\n * @returns A SHA-256 digest encoded as hexadecimal.\n */\nfunction digest(text: string): string {\n return createHash(\"sha256\").update(text).digest(\"hex\");\n}\n"],"mappings":";;;;;;;;;;;;;;;AAcA,SAAgB,qBAA+B;CAC7C,MAAM,QAAQ,cAAc,YAAY,QAAQ,mBAAmB,CAAC;CACpE,MAAM,UAAU,cAAc,KAAK;CACnC,MAAM,wBAAQ,IAAI,IAAI,CAAC,KAAK,CAAC;;;;;;;CAO7B,MAAM,WAAW,cAAsB;EACrC,KAAK,MAAM,QAAQ,YAAY,SAAS,GACtC,KACG,KAAK,WAAW,mBAAmB,KAAK,KAAK,WAAW,aAAa,MACtE,4BAA4B,KAAK,IAAI,GAErC,MAAM,IAAI,KAAK,KAAK,WAAW,IAAI,CAAC;CAG1C;CACA,QAAQ,KAAK,QAAQ,KAAK,CAAC;CAC3B,MAAM,WAAW,KAAK,MACpB,aAAa,IAAI,IAAI,YAAY,QAAQ,gCAAgC,CAAC,GAAG,MAAM,CACrF;CAIA,KAAK,MAAM,QAAQ,OAAO,KAAK,SAAS,oBAAoB,GAAG;EAC7D,IAAI;EACJ,IAAI;GACF,UAAU,QAAQ,QAAQ,IAAI;EAChC,SAAS,OAAO;GACd,IAAK,MAAgC,SAAS,oBAC5C;GAEF,MAAM;EACR;EACA,IAAI,WAAW,OAAO,GAAG;GACvB,MAAM,IAAI,OAAO;GACjB,QAAQ,KAAK,QAAQ,OAAO,CAAC;EAC/B;CACF;CACA,OAAO,CAAC,GAAG,KAAK;AAClB;;;;;;;;;;;;;;;;;;ACKA,IAAa,cAAb,MAA4B;CAC1B,2BAAoB,IAAI,IAAoC;CAC5D;CACA;;;;;;;CAQA,YAAY,cAAkC,CAAC,GAAG,SAAS,OAAO,mBAAmB;EACnF,KAAK,SAAS;EACd,KAAK,UAAU;CACjB;;;;;;;;;;CAWA,MAAM,IACJ,KACA,MACA,QACyB;EACzB,SAAS;GACP,MAAM,SAAS,KAAK,SAAS,IAAI,GAAG;GACpC,IAAI,CAAC,QAAQ;IACX,MAAM,UAAU,OAAO,CAAC,CAAC,MAAM,EAAE,OAAO,cAAc;KACpD;KACA;KACA,QAAQ;KACR,UAAU;IACZ,EAAE;IACF,KAAK,SAAS,IAAI,KAAK,OAAO;IAC9B,QAAQ,YAAY;KAClB,IAAI,KAAK,SAAS,IAAI,GAAG,MAAM,SAC7B,KAAK,SAAS,OAAO,GAAG;IAE5B,CAAC;IACD,OAAO,KAAK,OAAO,MAAM,OAAO;GAClC;GACA,MAAM,QAAQ,MAAM,OAAO,YAAY,KAAA,CAAS;GAChD,IAAI,CAAC,OACH;GAGF,MAAM,QAAQ,KAAK,OAAO,KAAK;GAC/B,IAAI,MAAM,UAAU,MAAM,QAAQ,IAAI,CAAC,CAAC,YAAY,KAAK,GACvD,OAAO;GAET,IAAI,KAAK,SAAS,IAAI,GAAG,MAAM,QAAQ;IACrC,KAAK,SAAS,OAAO,GAAG;IACxB,MAAM,WAAW;GACnB;GACA,MAAM,KAAK;EACb;CACF;;CAGA,YAAkB;EAChB,KAAK,MAAM,WAAW,KAAK,SAAS,OAAO,GACzC,QAAa,MACV,UAAU;GACT,IAAI,CAAC,MAAM,QAAQ;IACjB,aAAa,MAAM,IAAI;IACvB,KAAK,OAAO,MAAM,KAAK;GACzB;EACF,SACM,CAAC,CACT;CAEJ;CAEA,OAAO,OAAsC;EAC3C,aAAa,MAAM,IAAI;EACvB,MAAM,OAAO,KAAA;EACb,MAAM,UAAU;EAChB,IAAI,QAAQ;EACZ,OAAO;GACL,OAAO,MAAM;GACb,QAAQ,MAAM;GACd,YAAY;IACV,IAAI,OACF;IAEF,QAAQ;IACR,MAAM,UAAU;IAChB,IAAI,MAAM,QACR;IAEF,IAAI,MAAM,UACR,KAAK,OAAO,MAAM,KAAK;SAClB,IAAI,OAAO,SAAS,KAAK,OAAO,GAAG;KACxC,MAAM,OAAO,iBAAiB;MAC5B,MAAM,OAAO,KAAA;MACb,KAAK,OAAO,MAAM,KAAK;KACzB,GAAG,KAAK,OAAO;KACf,MAAM,KAAK,QAAQ;IACrB;GACF;EACF;CACF;AACF;;;;;;;;;;AAWA,eAAe,UAAU,QAAsB,MAAqC;CAClF,IAAI,OAAO,YAAY,MACrB,OAAO;CAET,MAAM,QAAQ,MAAM,QAAQ,IAC1B,CAAC,GAAG,OAAO,KAAK,CAAC,CAAC,IAAI,OAAO,CAAC,IAAI,cAAc;EAC9C,MAAM,OAAO,MAAM,KAAK,EAAE;EAC1B,IAAI,SAAS,KAAA,GACX,OAAO;EAET,IAAI,aAAa,KAAA,GAAW;GAC1B,OAAO,MAAM,IAAI,IAAI,OAAO,IAAI,CAAC;GACjC,OAAO;EACT;EACA,OAAO,OAAO,IAAI,MAAM;CAC1B,CAAC,CACH;CACA,MAAM,UAAU,MAAM,QAAQ,IAC5B,CAAC,GAAG,OAAO,OAAO,CAAC,CAAC,IAAI,OAAO,OAAQ,MAAM,KAAK,EAAE,MAAO,KAAA,CAAS,CACtE;CACA,OAAO,MAAM,MAAM,OAAO,KAAK,QAAQ,MAAM,OAAO;AACtD;;;;;;;AAgDA,SAAgB,aAAa,MAAkC;CAC7D,MAAM,SAAuB;EAC3B,uBAAO,IAAI,IAAI;EACf,yBAAS,IAAI,IAAI;EACjB,6BAAa,IAAI,IAAI;CACvB;CACA,IAAI,WAAW;CACf,MAAM,0BAAU,IAAI,IAAY;CAChC,OAAO;EACL;EACA,MAAM,KAAK,IAAI;GACb,MAAM,OAAO,MAAM,KAAK,EAAE;GAC1B,IAAI,SAAS,KAAA,GACX,MAAM,OAAO,uBAAO,IAAI,MAAM,4CAA4C,GAAG,EAAE,GAAG;IAChF,MAAM;IACN,MAAM;GACR,CAAC;GAEH,OAAO,MAAM,IAAI,IAAI,OAAO,IAAI,CAAC;GACjC,OAAO;EACT;EACA,MAAM,IAAI;GACR,IAAI,UAAU;IACZ,IAAI,CAAC,OAAO,MAAM,IAAI,EAAE,GACtB,OAAO,MAAM,IAAI,IAAI,KAAA,CAAS;IAEhC;GACF;GACA,QAAQ,IAAI,EAAE;EAChB;EACA,aAAa,IAAI;GACf,OAAO,QAAQ,IAAI,EAAE;EACvB;EACA,eAAe,IAAI;GACjB,OAAO,YAAY,IAAI,EAAE;EAC3B;EACA,MAAM,SAAS;GACb,MAAM,QAAQ,IACZ,CAAC,GAAG,OAAO,CAAC,CAAC,IAAI,OAAO,OAAO;IAC7B,IAAI,OAAO,MAAM,IAAI,EAAE,GACrB;IAEF,MAAM,OAAO,MAAM,KAAK,EAAE;IAC1B,IAAI,SAAS,KAAA,GACX,OAAO,QAAQ,IAAI,EAAE;SAErB,OAAO,MAAM,IAAI,IAAI,OAAO,IAAI,CAAC;GAErC,CAAC,CACH;GACA,WAAW;GACX,OAAO;EACT;CACF;AACF;;;;;;;AAQA,SAAS,OAAO,MAAsB;CACpC,OAAO,WAAW,QAAQ,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,OAAO,KAAK;AACvD"}
@@ -1,12 +1,15 @@
1
- import { t as TurbopackLoaderOptions } from "../project-BNw0nZBE.js";
1
+ import { t as TurbopackLoaderOptions } from "../project-mB7CODIs.js";
2
2
  import { LoaderContext } from "webpack";
3
- /** Loader settings that reconstruct document CSS from Next app and pages routes. */
3
+ /**
4
+ * Loader settings that reconstruct document CSS from Next app and pages routes.
5
+ */
4
6
  interface NextLoaderOptions extends TurbopackLoaderOptions {
5
7
  /** Configured page extensions without a leading dot, matched case-sensitively. */
6
8
  extensions: string[];
7
9
  }
8
10
  /**
9
11
  * Reconstructs document CSS after discovering Next routes with evaluated project settings.
12
+ *
10
13
  * @param this - Loader context receiving route watches and asynchronous CSS/map completion or an error.
11
14
  */
12
15
  export default function nextCssLoader(this: LoaderContext<NextLoaderOptions>): void;
@@ -4,6 +4,7 @@ import { readdir } from "node:fs/promises";
4
4
  // src/next/entries.ts
5
5
  /**
6
6
  * Discovers route sources beneath app or src/app and pages or src/pages.
7
+ *
7
8
  * @param context - Loader context that receives visited directory and missing-directory dependencies.
8
9
  * @param options - Evaluated absolute project root and Next page extensions.
9
10
  * @returns Sorted absolute route paths. App traversal skips private directories and non-route filenames.
@@ -13,22 +14,25 @@ async function routeEntries(context, options) {
13
14
  const entries = [];
14
15
  /**
15
16
  * Traverses a route directory and appends matching files to entries.
17
+ *
16
18
  * @param directory - Absolute directory registered as a context dependency before reading.
17
19
  * @param app - Whether app-directory private folders and route filename constraints apply.
18
- * @returns Completion of recursive traversal.
20
+ * @returns Completion of recursive traversal. Subdirectories are traversed concurrently.
19
21
  * @throws If enumeration fails.
20
22
  */
21
23
  const visit = async (directory, app) => {
22
24
  context.addContextDependency(directory);
25
+ const directories = [];
23
26
  for (const entry of await readdir(directory, { withFileTypes: true })) {
24
27
  const file = path.join(directory, entry.name);
25
28
  if (entry.isDirectory()) {
26
- if (!app || !entry.name.startsWith("_")) await visit(file, app);
29
+ if (!app || !entry.name.startsWith("_")) directories.push(visit(file, app));
27
30
  } else if (entry.isFile() && options.extensions.some((extension) => entry.name.endsWith(`.${extension}`))) {
28
31
  const stem = entry.name.slice(0, entry.name.indexOf("."));
29
32
  if (!app || /^(page|layout|template|loading|error|global-error|not-found|default|forbidden|unauthorized)$/.test(stem)) entries.push(file);
30
33
  }
31
34
  }
35
+ await Promise.all(directories);
32
36
  };
33
37
  for (const name of ["app", "pages"]) for (const prefix of ["", "src"]) {
34
38
  const directory = path.join(options.root, prefix, name);
@@ -45,6 +49,7 @@ async function routeEntries(context, options) {
45
49
  // src/next/css-loader.ts
46
50
  /**
47
51
  * Reconstructs document CSS after discovering Next routes with evaluated project settings.
52
+ *
48
53
  * @param this - Loader context receiving route watches and asynchronous CSS/map completion or an error.
49
54
  */
50
55
  function nextCssLoader() {
@@ -1 +1 @@
1
- {"version":3,"file":"css-loader.js","names":[],"sources":["../../src/next/entries.ts","../../src/next/css-loader.ts"],"sourcesContent":["import { readdir } from \"node:fs/promises\";\nimport path from \"node:path\";\n\nimport type { LoaderContext } from \"webpack\";\n\nimport type { TurbopackLoaderOptions } from \"../turbopack/project.ts\";\n\n/** Loader settings that reconstruct document CSS from Next app and pages routes. */\nexport interface NextLoaderOptions extends TurbopackLoaderOptions {\n /** Configured page extensions without a leading dot, matched case-sensitively. */\n extensions: string[];\n}\n\n/**\n * Discovers route sources beneath app or src/app and pages or src/pages.\n * @param context - Loader context that receives visited directory and missing-directory dependencies.\n * @param options - Evaluated absolute project root and Next page extensions.\n * @returns Sorted absolute route paths. App traversal skips private directories and non-route filenames.\n * @throws If traversal fails for a reason other than a missing directory.\n */\nexport async function routeEntries(\n context: LoaderContext<NextLoaderOptions>,\n options: NextLoaderOptions,\n) {\n const entries: string[] = [];\n /**\n * Traverses a route directory and appends matching files to entries.\n * @param directory - Absolute directory registered as a context dependency before reading.\n * @param app - Whether app-directory private folders and route filename constraints apply.\n * @returns Completion of recursive traversal.\n * @throws If enumeration fails.\n */\n const visit = async (directory: string, app: boolean): Promise<void> => {\n context.addContextDependency(directory);\n for (const entry of await readdir(directory, { withFileTypes: true })) {\n const file = path.join(directory, entry.name);\n if (entry.isDirectory()) {\n if (!app || !entry.name.startsWith(\"_\")) {\n await visit(file, app);\n }\n } else if (\n entry.isFile() &&\n options.extensions.some((extension) => entry.name.endsWith(`.${extension}`))\n ) {\n const stem = entry.name.slice(0, entry.name.indexOf(\".\"));\n if (\n !app ||\n /^(page|layout|template|loading|error|global-error|not-found|default|forbidden|unauthorized)$/.test(\n stem,\n )\n ) {\n entries.push(file);\n }\n }\n }\n };\n for (const name of [\"app\", \"pages\"]) {\n for (const prefix of [\"\", \"src\"]) {\n const directory = path.join(options.root, prefix, name);\n try {\n await visit(directory, name === \"app\");\n break;\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== \"ENOENT\") {\n throw error;\n }\n context.addMissingDependency(directory);\n }\n }\n }\n return entries.sort();\n}\n","import type { LoaderContext } from \"webpack\";\n\nimport { emitStylesheet } from \"../turbopack/css-loader.ts\";\nimport { routeEntries, type NextLoaderOptions } from \"./entries.ts\";\n\n/**\n * Reconstructs document CSS after discovering Next routes with evaluated project settings.\n * @param this - Loader context receiving route watches and asynchronous CSS/map completion or an error.\n */\nexport default function nextCssLoader(this: LoaderContext<NextLoaderOptions>) {\n emitStylesheet(this, (options) =>\n routeEntries(this, {\n ...this.getOptions(),\n root: options.root,\n }),\n );\n}\n"],"mappings":";;;;;;;;;;;AAoBA,eAAsB,aACpB,SACA,SACA;CACA,MAAM,UAAoB,CAAC;;;;;;;;CAQ3B,MAAM,QAAQ,OAAO,WAAmB,QAAgC;EACtE,QAAQ,qBAAqB,SAAS;EACtC,KAAK,MAAM,SAAS,MAAM,QAAQ,WAAW,EAAE,eAAe,KAAK,CAAC,GAAG;GACrE,MAAM,OAAO,KAAK,KAAK,WAAW,MAAM,IAAI;GAC5C,IAAI,MAAM,YAAY,GAChB;QAAA,CAAC,OAAO,CAAC,MAAM,KAAK,WAAW,GAAG,GACpC,MAAM,MAAM,MAAM,GAAG;GAAA,OAElB,IACL,MAAM,OAAO,KACb,QAAQ,WAAW,MAAM,cAAc,MAAM,KAAK,SAAS,IAAI,WAAW,CAAC,GAC3E;IACA,MAAM,OAAO,MAAM,KAAK,MAAM,GAAG,MAAM,KAAK,QAAQ,GAAG,CAAC;IACxD,IACE,CAAC,OACD,+FAA+F,KAC7F,IACF,GAEA,QAAQ,KAAK,IAAI;GAErB;EACF;CACF;CACA,KAAK,MAAM,QAAQ,CAAC,OAAO,OAAO,GAChC,KAAK,MAAM,UAAU,CAAC,IAAI,KAAK,GAAG;EAChC,MAAM,YAAY,KAAK,KAAK,QAAQ,MAAM,QAAQ,IAAI;EACtD,IAAI;GACF,MAAM,MAAM,WAAW,SAAS,KAAK;GACrC;EACF,SAAS,OAAO;GACd,IAAK,MAAgC,SAAS,UAC5C,MAAM;GAER,QAAQ,qBAAqB,SAAS;EACxC;CACF;CAEF,OAAO,QAAQ,KAAK;AACtB;;;;;;AC9DA,SAAwB,gBAAsD;CAC5E,eAAe,OAAO,YACpB,aAAa,MAAM;EACjB,GAAG,KAAK,WAAW;EACnB,MAAM,QAAQ;CAChB,CAAC,CACH;AACF"}
1
+ {"version":3,"file":"css-loader.js","names":[],"sources":["../../src/next/entries.ts","../../src/next/css-loader.ts"],"sourcesContent":["import { readdir } from \"node:fs/promises\";\nimport path from \"node:path\";\n\nimport type { LoaderContext } from \"webpack\";\n\nimport type { TurbopackLoaderOptions } from \"../turbopack/project.ts\";\n\n/**\n * Loader settings that reconstruct document CSS from Next app and pages routes.\n */\nexport interface NextLoaderOptions extends TurbopackLoaderOptions {\n /** Configured page extensions without a leading dot, matched case-sensitively. */\n extensions: string[];\n}\n\n/**\n * Discovers route sources beneath app or src/app and pages or src/pages.\n *\n * @param context - Loader context that receives visited directory and missing-directory dependencies.\n * @param options - Evaluated absolute project root and Next page extensions.\n * @returns Sorted absolute route paths. App traversal skips private directories and non-route filenames.\n * @throws If traversal fails for a reason other than a missing directory.\n */\nexport async function routeEntries(\n context: LoaderContext<NextLoaderOptions>,\n options: NextLoaderOptions,\n) {\n const entries: string[] = [];\n /**\n * Traverses a route directory and appends matching files to entries.\n *\n * @param directory - Absolute directory registered as a context dependency before reading.\n * @param app - Whether app-directory private folders and route filename constraints apply.\n * @returns Completion of recursive traversal. Subdirectories are traversed concurrently.\n * @throws If enumeration fails.\n */\n const visit = async (directory: string, app: boolean): Promise<void> => {\n context.addContextDependency(directory);\n const directories: Promise<void>[] = [];\n for (const entry of await readdir(directory, { withFileTypes: true })) {\n const file = path.join(directory, entry.name);\n if (entry.isDirectory()) {\n if (!app || !entry.name.startsWith(\"_\")) {\n directories.push(visit(file, app));\n }\n } else if (\n entry.isFile() &&\n options.extensions.some((extension) => entry.name.endsWith(`.${extension}`))\n ) {\n const stem = entry.name.slice(0, entry.name.indexOf(\".\"));\n if (\n !app ||\n /^(page|layout|template|loading|error|global-error|not-found|default|forbidden|unauthorized)$/.test(\n stem,\n )\n ) {\n entries.push(file);\n }\n }\n }\n await Promise.all(directories);\n };\n for (const name of [\"app\", \"pages\"]) {\n for (const prefix of [\"\", \"src\"]) {\n const directory = path.join(options.root, prefix, name);\n try {\n await visit(directory, name === \"app\");\n break;\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== \"ENOENT\") {\n throw error;\n }\n context.addMissingDependency(directory);\n }\n }\n }\n return entries.sort();\n}\n","import type { LoaderContext } from \"webpack\";\n\nimport { emitStylesheet } from \"../turbopack/css-loader.ts\";\nimport { routeEntries, type NextLoaderOptions } from \"./entries.ts\";\n\n/**\n * Reconstructs document CSS after discovering Next routes with evaluated project settings.\n *\n * @param this - Loader context receiving route watches and asynchronous CSS/map completion or an error.\n */\nexport default function nextCssLoader(this: LoaderContext<NextLoaderOptions>) {\n emitStylesheet(this, (options) =>\n routeEntries(this, {\n ...this.getOptions(),\n root: options.root,\n }),\n );\n}\n"],"mappings":";;;;;;;;;;;;AAuBA,eAAsB,aACpB,SACA,SACA;CACA,MAAM,UAAoB,CAAC;;;;;;;;;CAS3B,MAAM,QAAQ,OAAO,WAAmB,QAAgC;EACtE,QAAQ,qBAAqB,SAAS;EACtC,MAAM,cAA+B,CAAC;EACtC,KAAK,MAAM,SAAS,MAAM,QAAQ,WAAW,EAAE,eAAe,KAAK,CAAC,GAAG;GACrE,MAAM,OAAO,KAAK,KAAK,WAAW,MAAM,IAAI;GAC5C,IAAI,MAAM,YAAY,GAChB;QAAA,CAAC,OAAO,CAAC,MAAM,KAAK,WAAW,GAAG,GACpC,YAAY,KAAK,MAAM,MAAM,GAAG,CAAC;GAAA,OAE9B,IACL,MAAM,OAAO,KACb,QAAQ,WAAW,MAAM,cAAc,MAAM,KAAK,SAAS,IAAI,WAAW,CAAC,GAC3E;IACA,MAAM,OAAO,MAAM,KAAK,MAAM,GAAG,MAAM,KAAK,QAAQ,GAAG,CAAC;IACxD,IACE,CAAC,OACD,+FAA+F,KAC7F,IACF,GAEA,QAAQ,KAAK,IAAI;GAErB;EACF;EACA,MAAM,QAAQ,IAAI,WAAW;CAC/B;CACA,KAAK,MAAM,QAAQ,CAAC,OAAO,OAAO,GAChC,KAAK,MAAM,UAAU,CAAC,IAAI,KAAK,GAAG;EAChC,MAAM,YAAY,KAAK,KAAK,QAAQ,MAAM,QAAQ,IAAI;EACtD,IAAI;GACF,MAAM,MAAM,WAAW,SAAS,KAAK;GACrC;EACF,SAAS,OAAO;GACd,IAAK,MAAgC,SAAS,UAC5C,MAAM;GAER,QAAQ,qBAAqB,SAAS;EACxC;CACF;CAEF,OAAO,QAAQ,KAAK;AACtB;;;;;;;ACnEA,SAAwB,gBAAsD;CAC5E,eAAe,OAAO,YACpB,aAAa,MAAM;EACjB,GAAG,KAAK,WAAW;EACnB,MAAM,QAAQ;CAChB,CAAC,CACH;AACF"}
@@ -5,6 +5,7 @@ const loader = loaderPath("loader.js");
5
5
  const cssLoader = fileURLToPath(new URL("./css-loader.js", import.meta.resolve("@stillwind/integration/next")));
6
6
  /**
7
7
  * Builds the Next wrapper while deferring project evaluation to isolated loaders.
8
+ *
8
9
  * @param nextConfig - Application settings. Omission uses an empty configuration.
9
10
  * @param config - Serializable discovery settings and compiler overrides.
10
11
  * @returns A copy that preserves existing rules and invokes the original webpack hook before adding Stillwind rules.
@@ -33,6 +34,7 @@ function withStillwind(nextConfig = {}, config = {}) {
33
34
  },
34
35
  /**
35
36
  * Runs the application hook, then appends source and document-carrier rules to its result.
37
+ *
36
38
  * @param webpackConfig - Mutable Next webpack configuration passed to the original hook.
37
39
  * @param context - Next's build context forwarded unchanged to that hook.
38
40
  * @returns The hook's configuration with Stillwind rules appended.
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../src/next/index.ts"],"sourcesContent":["import { fileURLToPath } from \"node:url\";\n\nimport type { SerializableInlineConfig } from \"@stillwind/config\";\nimport type { NextConfig } from \"next\";\nimport type { Configuration } from \"webpack\";\n\nimport { createLoaderOptions, createRules, loaderPath } from \"../turbopack/rules.ts\";\n\nexport type { SerializableInlineConfig as IntegrationConfig } from \"@stillwind/config\";\n\nconst loader = loaderPath(\"loader.js\");\n\nconst cssLoader = fileURLToPath(\n new URL(\"./css-loader.js\", import.meta.resolve(\"@stillwind/integration/next\")),\n);\n\n/**\n * Adds Stillwind rules while preserving the application's Next configuration and webpack hook.\n *\n * @param nextConfig - Existing Next configuration, including optional Turbopack rules and webpack hook.\n * @param config - Configuration discovery and inline compiler overrides. Inline values must be\n * serializable; callbacks can be declared in the configuration file.\n * @returns A copy with Stillwind rules appended to both bundler configurations. The original\n * webpack hook runs before Stillwind appends its rules.\n * @throws If inline naming callbacks cannot be serialized. Loaders report configuration errors\n * when the bundler evaluates the settings.\n */\nexport function withStillwind<T extends object>(\n nextConfig: T,\n config?: SerializableInlineConfig,\n): T;\n\n/**\n * Builds the Next wrapper while deferring project evaluation to isolated loaders.\n * @param nextConfig - Application settings. Omission uses an empty configuration.\n * @param config - Serializable discovery settings and compiler overrides.\n * @returns A copy that preserves existing rules and invokes the original webpack hook before adding Stillwind rules.\n * @throws If inline settings cannot be cloned or installed loader paths cannot be resolved.\n */\nexport function withStillwind(nextConfig: NextConfig = {}, config: SerializableInlineConfig = {}) {\n const loaderOptions = {\n ...createLoaderOptions(config, []),\n extensions: nextConfig.pageExtensions ?? [\"tsx\", \"ts\", \"jsx\", \"js\"],\n };\n const rules = { ...nextConfig.turbopack?.rules };\n for (const [pattern, rule] of Object.entries(createRules(loaderOptions, cssLoader))) {\n const previous = rules[pattern];\n rules[pattern] = previous ? [...(Array.isArray(previous) ? previous : [previous]), rule] : rule;\n }\n return {\n ...nextConfig,\n turbopack: {\n ...nextConfig.turbopack,\n rules,\n },\n /**\n * Runs the application hook, then appends source and document-carrier rules to its result.\n * @param webpackConfig - Mutable Next webpack configuration passed to the original hook.\n * @param context - Next's build context forwarded unchanged to that hook.\n * @returns The hook's configuration with Stillwind rules appended.\n * @throws If the application hook fails.\n */\n webpack(\n webpackConfig: Configuration,\n context: Parameters<NonNullable<NextConfig[\"webpack\"]>>[1],\n ) {\n const result: Configuration = nextConfig.webpack\n ? nextConfig.webpack(webpackConfig, context)\n : webpackConfig;\n result.module ??= {};\n result.module.rules ??= [];\n result.module.rules.push(\n {\n test: /\\.[cm]?[jt]sx?$/,\n exclude: /node_modules/,\n enforce: \"pre\",\n use: [\n {\n loader,\n options: loaderOptions,\n },\n ],\n },\n {\n test: /stillwind-turbopack\\.css$/,\n use: [\n {\n loader: cssLoader,\n options: loaderOptions,\n },\n ],\n },\n );\n return result;\n },\n };\n}\n"],"mappings":";;;AAUA,MAAM,SAAS,WAAW,WAAW;AAErC,MAAM,YAAY,cAChB,IAAI,IAAI,mBAAmB,YAAY,QAAQ,6BAA6B,CAAC,CAC/E;;;;;;;;AAyBA,SAAgB,cAAc,aAAyB,CAAC,GAAG,SAAmC,CAAC,GAAG;CAChG,MAAM,gBAAgB;EACpB,GAAG,oBAAoB,QAAQ,CAAC,CAAC;EACjC,YAAY,WAAW,kBAAkB;GAAC;GAAO;GAAM;GAAO;EAAI;CACpE;CACA,MAAM,QAAQ,EAAE,GAAG,WAAW,WAAW,MAAM;CAC/C,KAAK,MAAM,CAAC,SAAS,SAAS,OAAO,QAAQ,YAAY,eAAe,SAAS,CAAC,GAAG;EACnF,MAAM,WAAW,MAAM;EACvB,MAAM,WAAW,WAAW,CAAC,GAAI,MAAM,QAAQ,QAAQ,IAAI,WAAW,CAAC,QAAQ,GAAI,IAAI,IAAI;CAC7F;CACA,OAAO;EACL,GAAG;EACH,WAAW;GACT,GAAG,WAAW;GACd;EACF;;;;;;;;EAQA,QACE,eACA,SACA;GACA,MAAM,SAAwB,WAAW,UACrC,WAAW,QAAQ,eAAe,OAAO,IACzC;GACJ,OAAO,WAAW,CAAC;GACnB,OAAO,OAAO,UAAU,CAAC;GACzB,OAAO,OAAO,MAAM,KAClB;IACE,MAAM;IACN,SAAS;IACT,SAAS;IACT,KAAK,CACH;KACE;KACA,SAAS;IACX,CACF;GACF,GACA;IACE,MAAM;IACN,KAAK,CACH;KACE,QAAQ;KACR,SAAS;IACX,CACF;GACF,CACF;GACA,OAAO;EACT;CACF;AACF"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/next/index.ts"],"sourcesContent":["import { fileURLToPath } from \"node:url\";\n\nimport type { SerializableInlineConfig } from \"@stillwind/config\";\nimport type { NextConfig } from \"next\";\nimport type { Configuration } from \"webpack\";\n\nimport { createLoaderOptions, createRules, loaderPath } from \"../turbopack/rules.ts\";\n\nexport type { SerializableInlineConfig as IntegrationConfig } from \"@stillwind/config\";\n\nconst loader = loaderPath(\"loader.js\");\n\nconst cssLoader = fileURLToPath(\n new URL(\"./css-loader.js\", import.meta.resolve(\"@stillwind/integration/next\")),\n);\n\n/**\n * Adds Stillwind rules while preserving the application's Next configuration and webpack hook.\n *\n * @param nextConfig - Existing Next configuration, including optional Turbopack rules and webpack hook.\n * @param config - Configuration discovery and inline compiler overrides. Inline values must be\n * serializable; callbacks can be declared in the configuration file.\n * @returns A copy with Stillwind rules appended to both bundler configurations. The original\n * webpack hook runs before Stillwind appends its rules.\n * @throws If inline naming callbacks cannot be serialized. Loaders report configuration errors\n * when the bundler evaluates the settings.\n */\nexport function withStillwind<T extends object>(\n nextConfig: T,\n config?: SerializableInlineConfig,\n): T;\n\n/**\n * Builds the Next wrapper while deferring project evaluation to isolated loaders.\n *\n * @param nextConfig - Application settings. Omission uses an empty configuration.\n * @param config - Serializable discovery settings and compiler overrides.\n * @returns A copy that preserves existing rules and invokes the original webpack hook before adding Stillwind rules.\n * @throws If inline settings cannot be cloned or installed loader paths cannot be resolved.\n */\nexport function withStillwind(nextConfig: NextConfig = {}, config: SerializableInlineConfig = {}) {\n const loaderOptions = {\n ...createLoaderOptions(config, []),\n extensions: nextConfig.pageExtensions ?? [\"tsx\", \"ts\", \"jsx\", \"js\"],\n };\n const rules = { ...nextConfig.turbopack?.rules };\n for (const [pattern, rule] of Object.entries(createRules(loaderOptions, cssLoader))) {\n const previous = rules[pattern];\n rules[pattern] = previous ? [...(Array.isArray(previous) ? previous : [previous]), rule] : rule;\n }\n return {\n ...nextConfig,\n turbopack: {\n ...nextConfig.turbopack,\n rules,\n },\n /**\n * Runs the application hook, then appends source and document-carrier rules to its result.\n *\n * @param webpackConfig - Mutable Next webpack configuration passed to the original hook.\n * @param context - Next's build context forwarded unchanged to that hook.\n * @returns The hook's configuration with Stillwind rules appended.\n * @throws If the application hook fails.\n */\n webpack(\n webpackConfig: Configuration,\n context: Parameters<NonNullable<NextConfig[\"webpack\"]>>[1],\n ) {\n const result: Configuration = nextConfig.webpack\n ? nextConfig.webpack(webpackConfig, context)\n : webpackConfig;\n result.module ??= {};\n result.module.rules ??= [];\n result.module.rules.push(\n {\n test: /\\.[cm]?[jt]sx?$/,\n exclude: /node_modules/,\n enforce: \"pre\",\n use: [\n {\n loader,\n options: loaderOptions,\n },\n ],\n },\n {\n test: /stillwind-turbopack\\.css$/,\n use: [\n {\n loader: cssLoader,\n options: loaderOptions,\n },\n ],\n },\n );\n return result;\n },\n };\n}\n"],"mappings":";;;AAUA,MAAM,SAAS,WAAW,WAAW;AAErC,MAAM,YAAY,cAChB,IAAI,IAAI,mBAAmB,YAAY,QAAQ,6BAA6B,CAAC,CAC/E;;;;;;;;;AA0BA,SAAgB,cAAc,aAAyB,CAAC,GAAG,SAAmC,CAAC,GAAG;CAChG,MAAM,gBAAgB;EACpB,GAAG,oBAAoB,QAAQ,CAAC,CAAC;EACjC,YAAY,WAAW,kBAAkB;GAAC;GAAO;GAAM;GAAO;EAAI;CACpE;CACA,MAAM,QAAQ,EAAE,GAAG,WAAW,WAAW,MAAM;CAC/C,KAAK,MAAM,CAAC,SAAS,SAAS,OAAO,QAAQ,YAAY,eAAe,SAAS,CAAC,GAAG;EACnF,MAAM,WAAW,MAAM;EACvB,MAAM,WAAW,WAAW,CAAC,GAAI,MAAM,QAAQ,QAAQ,IAAI,WAAW,CAAC,QAAQ,GAAI,IAAI,IAAI;CAC7F;CACA,OAAO;EACL,GAAG;EACH,WAAW;GACT,GAAG,WAAW;GACd;EACF;;;;;;;;;EASA,QACE,eACA,SACA;GACA,MAAM,SAAwB,WAAW,UACrC,WAAW,QAAQ,eAAe,OAAO,IACzC;GACJ,OAAO,WAAW,CAAC;GACnB,OAAO,OAAO,UAAU,CAAC;GACzB,OAAO,OAAO,MAAM,KAClB;IACE,MAAM;IACN,SAAS;IACT,SAAS;IACT,KAAK,CACH;KACE;KACA,SAAS;IACX,CACF;GACF,GACA;IACE,MAAM;IACN,KAAK,CACH;KACE,QAAQ;KACR,SAAS;IACX,CACF;GACF,CACF;GACA,OAAO;EACT;CACF;AACF"}
@@ -1,13 +1,16 @@
1
- import { t as TurbopackLoaderOptions } from "./project-BNw0nZBE.js";
1
+ import { t as TurbopackLoaderOptions } from "./project-mB7CODIs.js";
2
2
  import { UpstreamSourceMap } from "@stillwind/host";
3
3
  import { LoaderContext } from "webpack";
4
- /** Settings for a compiler loader that executes in Node. */
4
+ /**
5
+ * Settings for a compiler loader that executes in Node.
6
+ */
5
7
  type NodeLoaderOptions = TurbopackLoaderOptions & {
6
8
  /** Absolute path to the compiled loader implementation. */
7
9
  implementation: string;
8
10
  };
9
11
  /**
10
12
  * Loads the compiler in Node without exposing its dependencies to Turbopack's loader tracing.
13
+ *
11
14
  * @param this - Loader context with an absolute implementation path and asynchronous completion.
12
15
  * @param source - Original source text forwarded to the implementation.
13
16
  * @param inputMap - Upstream source map forwarded unchanged.
@@ -16,4 +19,4 @@ type NodeLoaderOptions = TurbopackLoaderOptions & {
16
19
  */
17
20
  declare function nodeLoader(this: LoaderContext<NodeLoaderOptions>, source: string, inputMap: UpstreamSourceMap): void;
18
21
  export { nodeLoader as n, NodeLoaderOptions as t };
19
- //# sourceMappingURL=node-loader-D-3Ynpy1.d.ts.map
22
+ //# sourceMappingURL=node-loader-Bqg7E5zq.d.ts.map
@@ -1,5 +1,5 @@
1
- import { t as IntegrationConfig } from "../project-DUGu8g_L.js";
2
- import "../index-DFfbZxNT.js";
1
+ import { t as IntegrationConfig } from "../project-B_KFQist.js";
2
+ import "../index-B6EtrWus.js";
3
3
  import { NuxtModule } from "nuxt/schema";
4
4
  /**
5
5
  * Adds the Vite compiler and development SSR stylesheet transport to a Nuxt application.
@@ -1,4 +1,4 @@
1
- import { r as createViteProject, t as createVitePlugins } from "../plugin-ByYcpBcE.js";
1
+ import { r as createViteProject, t as createVitePlugins } from "../plugin-DQH8QlYh.js";
2
2
  import { addPluginTemplate, defineNuxtModule } from "nuxt/kit";
3
3
  // src/nuxt/index.ts
4
4
  /**
@@ -13,6 +13,7 @@ function stillwind(config = {}) {
13
13
  meta: { name: "@stillwind/integration" },
14
14
  /**
15
15
  * Installs compiler plugins and connects the client development server to SSR stylesheet delivery.
16
+ *
16
17
  * @param _ - Nuxt module options. Stillwind settings are captured by the factory instead.
17
18
  * @param nuxt - Application whose Vite hooks and development plugin template are registered.
18
19
  */
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../src/nuxt/index.ts"],"sourcesContent":["import { addPluginTemplate, defineNuxtModule } from \"nuxt/kit\";\nimport type { NuxtModule } from \"nuxt/schema\";\nimport type { UserConfig, ViteDevServer } from \"vite\";\n\nimport type { IntegrationConfig } from \"../vite/index.ts\";\nimport { createVitePlugins } from \"../vite/plugin.ts\";\nimport { createViteProject } from \"../vite/project.ts\";\n\nexport type { IntegrationConfig } from \"../vite/index.ts\";\n\n/**\n * Adds the Vite compiler and development SSR stylesheet transport to a Nuxt application.\n *\n * @param config - File discovery, project selection, inline compiler overrides, and CSS emission.\n * Omission reads stillwind.config.* relative to Nuxt's application root during Vite configuration.\n * @returns A Nuxt module that registers the Vite plugins and client stylesheet handling.\n */\nexport function stillwind(config: IntegrationConfig = {}): NuxtModule {\n return defineNuxtModule({\n meta: {\n name: \"@stillwind/integration\",\n },\n /**\n * Installs compiler plugins and connects the client development server to SSR stylesheet delivery.\n * @param _ - Nuxt module options. Stillwind settings are captured by the factory instead.\n * @param nuxt - Application whose Vite hooks and development plugin template are registered.\n */\n setup(_, nuxt) {\n let ssr: ViteDevServer | undefined;\n\n nuxt.hook(\"vite:extendConfig\", (viteConfig) => {\n const vite = viteConfig as UserConfig;\n vite.plugins ??= [];\n vite.plugins.unshift(\n createVitePlugins(createViteProject(config, () => nuxt.options.rootDir)),\n );\n });\n\n nuxt.hook(\"vite:serverCreated\", (server, { isClient }) => {\n if (!isClient) {\n ssr = server;\n return;\n }\n server.middlewares.use(\n nuxt.options.app.baseURL + \"__stillwind/nuxt.css\",\n (request, response, next) => {\n if (!ssr) {\n return next();\n }\n request.url = \"/__stillwind/style.css?environment=ssr\";\n ssr.middlewares(request, response, next);\n },\n );\n });\n\n if (nuxt.options.dev) {\n addPluginTemplate({\n filename: \"stillwind-ssr.ts\",\n getContents: () =>\n `\nimport { defineNuxtPlugin, useHead } from \"#app\";\n\nexport default defineNuxtPlugin((nuxt) => {\n const head = useHead({\n link: [\n {\n key: \"stillwind-ssr\",\n rel: \"stylesheet\",\n href: ${JSON.stringify(nuxt.options.app.baseURL + \"__stillwind/nuxt.css\")},\n },\n ],\n });\n\n nuxt.hook(\"app:mounted\", () => {\n head.dispose();\n });\n});\n`.trimStart(),\n });\n }\n },\n });\n}\n"],"mappings":";;;;;;;;;;AAiBA,SAAgB,UAAU,SAA4B,CAAC,GAAe;CACpE,OAAO,iBAAiB;EACtB,MAAM,EACJ,MAAM,yBACR;;;;;;EAMA,MAAM,GAAG,MAAM;GACb,IAAI;GAEJ,KAAK,KAAK,sBAAsB,eAAe;IAC7C,MAAM,OAAO;IACb,KAAK,YAAY,CAAC;IAClB,KAAK,QAAQ,QACX,kBAAkB,kBAAkB,cAAc,KAAK,QAAQ,OAAO,CAAC,CACzE;GACF,CAAC;GAED,KAAK,KAAK,uBAAuB,QAAQ,EAAE,eAAe;IACxD,IAAI,CAAC,UAAU;KACb,MAAM;KACN;IACF;IACA,OAAO,YAAY,IACjB,KAAK,QAAQ,IAAI,UAAU,yBAC1B,SAAS,UAAU,SAAS;KAC3B,IAAI,CAAC,KACH,OAAO,KAAK;KAEd,QAAQ,MAAM;KACd,IAAI,YAAY,SAAS,UAAU,IAAI;IACzC,CACF;GACF,CAAC;GAED,IAAI,KAAK,QAAQ,KACf,kBAAkB;IAChB,UAAU;IACV,mBACE;;;;;;;;;gBASI,KAAK,UAAU,KAAK,QAAQ,IAAI,UAAU,sBAAsB,EAAE;;;;;;;;;EAShF,UAAU;GACJ,CAAC;EAEL;CACF,CAAC;AACH"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/nuxt/index.ts"],"sourcesContent":["import { addPluginTemplate, defineNuxtModule } from \"nuxt/kit\";\nimport type { NuxtModule } from \"nuxt/schema\";\nimport type { UserConfig, ViteDevServer } from \"vite\";\n\nimport type { IntegrationConfig } from \"../vite/index.ts\";\nimport { createVitePlugins } from \"../vite/plugin.ts\";\nimport { createViteProject } from \"../vite/project.ts\";\n\nexport type { IntegrationConfig } from \"../vite/index.ts\";\n\n/**\n * Adds the Vite compiler and development SSR stylesheet transport to a Nuxt application.\n *\n * @param config - File discovery, project selection, inline compiler overrides, and CSS emission.\n * Omission reads stillwind.config.* relative to Nuxt's application root during Vite configuration.\n * @returns A Nuxt module that registers the Vite plugins and client stylesheet handling.\n */\nexport function stillwind(config: IntegrationConfig = {}): NuxtModule {\n return defineNuxtModule({\n meta: {\n name: \"@stillwind/integration\",\n },\n /**\n * Installs compiler plugins and connects the client development server to SSR stylesheet delivery.\n *\n * @param _ - Nuxt module options. Stillwind settings are captured by the factory instead.\n * @param nuxt - Application whose Vite hooks and development plugin template are registered.\n */\n setup(_, nuxt) {\n let ssr: ViteDevServer | undefined;\n\n nuxt.hook(\"vite:extendConfig\", (viteConfig) => {\n const vite = viteConfig as UserConfig;\n vite.plugins ??= [];\n vite.plugins.unshift(\n createVitePlugins(createViteProject(config, () => nuxt.options.rootDir)),\n );\n });\n\n nuxt.hook(\"vite:serverCreated\", (server, { isClient }) => {\n if (!isClient) {\n ssr = server;\n return;\n }\n server.middlewares.use(\n nuxt.options.app.baseURL + \"__stillwind/nuxt.css\",\n (request, response, next) => {\n if (!ssr) {\n return next();\n }\n request.url = \"/__stillwind/style.css?environment=ssr\";\n ssr.middlewares(request, response, next);\n },\n );\n });\n\n if (nuxt.options.dev) {\n addPluginTemplate({\n filename: \"stillwind-ssr.ts\",\n getContents: () =>\n `\nimport { defineNuxtPlugin, useHead } from \"#app\";\n\nexport default defineNuxtPlugin((nuxt) => {\n const head = useHead({\n link: [\n {\n key: \"stillwind-ssr\",\n rel: \"stylesheet\",\n href: ${JSON.stringify(nuxt.options.app.baseURL + \"__stillwind/nuxt.css\")},\n },\n ],\n });\n\n nuxt.hook(\"app:mounted\", () => {\n head.dispose();\n });\n});\n`.trimStart(),\n });\n }\n },\n });\n}\n"],"mappings":";;;;;;;;;;AAiBA,SAAgB,UAAU,SAA4B,CAAC,GAAe;CACpE,OAAO,iBAAiB;EACtB,MAAM,EACJ,MAAM,yBACR;;;;;;;EAOA,MAAM,GAAG,MAAM;GACb,IAAI;GAEJ,KAAK,KAAK,sBAAsB,eAAe;IAC7C,MAAM,OAAO;IACb,KAAK,YAAY,CAAC;IAClB,KAAK,QAAQ,QACX,kBAAkB,kBAAkB,cAAc,KAAK,QAAQ,OAAO,CAAC,CACzE;GACF,CAAC;GAED,KAAK,KAAK,uBAAuB,QAAQ,EAAE,eAAe;IACxD,IAAI,CAAC,UAAU;KACb,MAAM;KACN;IACF;IACA,OAAO,YAAY,IACjB,KAAK,QAAQ,IAAI,UAAU,yBAC1B,SAAS,UAAU,SAAS;KAC3B,IAAI,CAAC,KACH,OAAO,KAAK;KAEd,QAAQ,MAAM;KACd,IAAI,YAAY,SAAS,UAAU,IAAI;IACzC,CACF;GACF,CAAC;GAED,IAAI,KAAK,QAAQ,KACf,kBAAkB;IAChB,UAAU;IACV,mBACE;;;;;;;;;gBASI,KAAK,UAAU,KAAK,QAAQ,IAAI,UAAU,sBAAsB,EAAE;;;;;;;;;EAShF,UAAU;GACJ,CAAC;EAEL;CACF,CAAC;AACH"}
@@ -1,7 +1,10 @@
1
- import { CssUpstreamMap, UpstreamSourceMap } from "@stillwind/host";
1
+ import "./session-Cxf4D6oQ.js";
2
+ import { CssUpstreamMap, LoadedCssGraph, UpstreamSourceMap } from "@stillwind/host";
2
3
  import { ResolvedIntegrationConfig } from "@stillwind/config/node";
3
4
  import { BuildConfig, InlineConfig } from "@stillwind/config";
4
- /** Resolver policies passed to webpack or Rspack for CSS, script, and asset imports. */
5
+ /**
6
+ * Resolver policies passed to webpack or Rspack for CSS, script, and asset imports.
7
+ */
5
8
  interface ResolveSettings {
6
9
  /** Dependency category used to select bundler resolution behavior, such as `esm`. */
7
10
  dependencyType?: string;
@@ -27,12 +30,15 @@ type ResolveCallback = (error?: Error | null, id?: string | false) => void;
27
30
  * @param callback - Receives the resolution failure or resulting resource identity.
28
31
  */
29
32
  type Resolver = (directory: string, specifier: string, callback: ResolveCallback) => void;
30
- /** Bundler filesystem and resolver operations shared by producer loaders and CSS reconstruction. */
33
+ /**
34
+ * Bundler filesystem and resolver operations shared by producer loaders and CSS reconstruction.
35
+ */
31
36
  interface ResolverHost {
32
37
  /** Bundler input filesystem. Reads may return UTF-8 text or bytes through the callback. */
33
38
  fs: {
34
39
  /**
35
40
  * Reads through the bundler filesystem rather than bypassing its virtual files.
41
+ *
36
42
  * @param id - Filesystem identity without a resource query.
37
43
  * @param callback - Receives an error or file contents. Callers convert successful contents to text.
38
44
  */
@@ -46,6 +52,45 @@ interface ResolverHost {
46
52
  */
47
53
  getResolve(settings: ResolveSettings): Resolver;
48
54
  }
55
+ /**
56
+ * Compiler operations of webpack and Rspack that a shared project uses.
57
+ */
58
+ interface ProjectCompiler {
59
+ /** Top compiler of a child compiler. Child compilers use the projects of their top compiler. */
60
+ root?: ProjectCompiler;
61
+ /** Application directory against which relative entry requests resolve. */
62
+ context?: string;
63
+ /** Whether the compiler runs in watch mode, so that later compilations follow file changes. */
64
+ watchMode?: boolean;
65
+ /** Absolute paths that changed or were added since the previous compilation of a watch run. */
66
+ modifiedFiles?: ReadonlySet<string>;
67
+ /** Absolute paths that were removed since the previous compilation of a watch run. */
68
+ removedFiles?: ReadonlySet<string>;
69
+ /** Normalized entry settings. A function selects entries at compilation time. */
70
+ options?: {
71
+ /** Entry descriptions keyed by name, or a function. */
72
+ entry?: unknown;
73
+ };
74
+ /** Hooks that end the compiler's use of its shared projects. */
75
+ hooks: {
76
+ /** Runs after each compilation finishes. */
77
+ done: {
78
+ /**
79
+ * @param name - Plugin registration name.
80
+ * @param callback - Operation run after the compilation.
81
+ */
82
+ tap(name: string, callback: () => void): void;
83
+ };
84
+ /** Runs when the compiler closes. Absent in compilers without a shutdown hook. */
85
+ shutdown?: {
86
+ /**
87
+ * @param name - Plugin registration name.
88
+ * @param callback - Operation run when the compiler closes.
89
+ */
90
+ tap(name: string, callback: () => void): void;
91
+ };
92
+ };
93
+ }
49
94
  /**
50
95
  * A producer and its captured dependencies stored in bundler metadata for CSS reconstruction.
51
96
  */
@@ -208,13 +253,14 @@ declare class StillwindPlugin {
208
253
  * Compiler operations shared by webpack and Rspack for installing rules and registering each
209
254
  * compilation.
210
255
  */
211
- interface EmissionCompiler<Module extends EmissionModule> {
256
+ interface EmissionCompiler<Module extends EmissionModule> extends ProjectCompiler {
212
257
  /** Run and compilation hooks used to evaluate configuration before registering emission. */
213
- hooks: {
258
+ hooks: ProjectCompiler["hooks"] & {
214
259
  /** Normal build hook that initializes settings before thisCompilation. */
215
260
  beforeRun: {
216
261
  /**
217
262
  * Registers asynchronous work before a normal build run.
263
+ *
218
264
  * @param name - Plugin registration name.
219
265
  * @param callback - Configuration initializer whose rejection fails the run.
220
266
  */
@@ -224,6 +270,7 @@ interface EmissionCompiler<Module extends EmissionModule> {
224
270
  watchRun: {
225
271
  /**
226
272
  * Registers asynchronous work before a watch build run.
273
+ *
227
274
  * @param name - Plugin registration name.
228
275
  * @param callback - Configuration initializer whose rejection fails the run.
229
276
  */
@@ -233,6 +280,7 @@ interface EmissionCompiler<Module extends EmissionModule> {
233
280
  thisCompilation: {
234
281
  /**
235
282
  * Registers settings, dependency watches, and emission on a new compilation.
283
+ *
236
284
  * @param name - Plugin registration name.
237
285
  * @param callback - Operation receiving the current compilation.
238
286
  */
@@ -245,6 +293,8 @@ interface EmissionCompiler<Module extends EmissionModule> {
245
293
  options: {
246
294
  /** Application directory for configuration discovery. Omission uses process.cwd(). */
247
295
  context?: string;
296
+ /** Normalized entry settings, from which the shared project selects local entry files. */
297
+ entry?: unknown;
248
298
  /** Bundler mode forwarded to reconstruction. Only development selects development compilation. */
249
299
  mode?: string;
250
300
  /** Module rule configuration, initialized by apply when absent. */
@@ -257,6 +307,7 @@ interface EmissionCompiler<Module extends EmissionModule> {
257
307
  resolverFactory: {
258
308
  /**
259
309
  * Obtains a bundler resolver with a selected policy.
310
+ *
260
311
  * @param type - Resolver category. Stillwind requests normal.
261
312
  * @param settings - Import conditions, extensions, and package fields.
262
313
  * @returns Resolver that reports completion through its callback.
@@ -264,6 +315,7 @@ interface EmissionCompiler<Module extends EmissionModule> {
264
315
  get(type: string, settings: ResolveSettings): {
265
316
  /**
266
317
  * Resolves a request without changing compiler state.
318
+ *
267
319
  * @param context - Bundler request metadata. Stillwind passes an empty object.
268
320
  * @param directory - Absolute importer directory.
269
321
  * @param specifier - Authored import or resource request.
@@ -275,4 +327,4 @@ interface EmissionCompiler<Module extends EmissionModule> {
275
327
  };
276
328
  }
277
329
  export { StillwindPlugin as t };
278
- //# sourceMappingURL=plugin-aV0zIIAe.d.ts.map
330
+ //# sourceMappingURL=plugin-BAG0ZI1X.d.ts.map
@@ -1,4 +1,4 @@
1
- import { d as stillwindRules, t as installEmission } from "./emission-BVi5aRbb.js";
1
+ import { f as stillwindRules, t as installEmission } from "./emission-BpaN4Z4m.js";
2
2
  import { resolveIntegrationConfig } from "@stillwind/config/node";
3
3
  import process from "node:process";
4
4
  // src/webpack/plugin.ts
@@ -44,6 +44,7 @@ var StillwindPlugin = class {
44
44
  let configuration;
45
45
  /**
46
46
  * Evaluates current configuration before a normal or watch build run.
47
+ *
47
48
  * @returns Completion after the settings shared by subsequent compilations have been replaced.
48
49
  * @throws If configuration discovery, evaluation, or project selection fails.
49
50
  */
@@ -59,10 +60,12 @@ var StillwindPlugin = class {
59
60
  for (const file of configuration.missing) compilation.missingDependencies.add(file);
60
61
  installEmission({
61
62
  _compilation: compilation,
63
+ _compiler: compiler,
62
64
  fs: compiler.inputFileSystem,
63
65
  mode: compiler.options.mode,
64
66
  /**
65
67
  * Adapts the compiler's normal resolver for document CSS reconstruction.
68
+ *
66
69
  * @param settings - Requested dependency conditions, extensions, and metadata fields.
67
70
  * @returns A callback resolver using the compiler's configured input filesystem.
68
71
  */
@@ -76,4 +79,4 @@ var StillwindPlugin = class {
76
79
  };
77
80
  export { StillwindPlugin as t };
78
81
 
79
- //# sourceMappingURL=plugin-mPiBLdqa.js.map
82
+ //# sourceMappingURL=plugin-D-45o54j.js.map