nitro-nightly 3.0.1-20260120-020848-6786d069 → 3.0.1-20260120-133849-ca1a9dee

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 (93) hide show
  1. package/dist/_build/common.mjs +24931 -0
  2. package/dist/_build/rolldown.mjs +6 -11
  3. package/dist/_build/rollup.mjs +201 -0
  4. package/dist/_build/vite.build.mjs +1 -1
  5. package/dist/_chunks/dev.mjs +4 -6
  6. package/dist/_chunks/nitro.mjs +1183 -24
  7. package/dist/_chunks/nitro2.mjs +91 -248
  8. package/dist/_chunks/utils.mjs +254 -0
  9. package/dist/_common.mjs +45 -0
  10. package/dist/_libs/c12+giget+readdirp+chokidar.d.mts +214 -0
  11. package/dist/_libs/citty.mjs +140 -110
  12. package/dist/_libs/commondir+is-reference.mjs +1300 -0
  13. package/dist/_libs/compatx.d.mts +47 -0
  14. package/dist/_libs/confbox.mjs +2488 -70
  15. package/dist/_libs/esbuild.d.mts +20 -0
  16. package/dist/_libs/escape-string-regexp.mjs +8 -0
  17. package/dist/_libs/estree-walker.mjs +187 -0
  18. package/dist/_libs/hasown+resolve+deepmerge.mjs +1972 -0
  19. package/dist/_libs/httpxy.d.mts +79 -0
  20. package/dist/_libs/httpxy.mjs +6 -1
  21. package/dist/_libs/klona.mjs +38 -0
  22. package/dist/_libs/magic-string.d.mts +220 -0
  23. package/dist/_libs/mlly.d.mts +57 -0
  24. package/dist/_libs/nypm+giget+tinyexec.mjs +3603 -0
  25. package/dist/_libs/pkg-types.d.mts +23 -0
  26. package/dist/_libs/plugin-alias.mjs +64 -0
  27. package/dist/_libs/{plugin-alias+plugin-inject.mjs → plugin-inject.mjs} +2 -65
  28. package/dist/_libs/plugin-json.mjs +36 -0
  29. package/dist/_libs/pluginutils+plugin-commonjs.d.mts +241 -0
  30. package/dist/_libs/pluginutils.mjs +652 -0
  31. package/dist/_libs/{c12+dotenv+rc9.mjs → rc9+c12+dotenv.mjs} +105 -12
  32. package/dist/_libs/{chokidar+readdirp.mjs → readdirp+chokidar.mjs} +8 -1
  33. package/dist/_libs/remapping.mjs +117 -0
  34. package/dist/_libs/resolve-uri+gen-mapping.mjs +448 -0
  35. package/dist/_libs/rou3.d.mts +43 -0
  36. package/dist/_libs/rou3.mjs +322 -0
  37. package/dist/_libs/std-env.d.mts +4 -0
  38. package/dist/_libs/tsconfck.mjs +832 -0
  39. package/dist/_libs/ultrahtml.mjs +138 -0
  40. package/dist/_libs/{gen-mapping+remapping+resolve-uri+trace-mapping+unimport+unplugin+unplugin-utils+webpack-virtual-modules.mjs → unimport+unplugin.mjs} +228 -593
  41. package/dist/_libs/unplugin+unimport.d.mts +426 -0
  42. package/dist/_libs/unwasm.d.mts +29 -0
  43. package/dist/_presets.mjs +3 -8
  44. package/dist/builder.mjs +6 -8
  45. package/dist/cli/_chunks/build.mjs +1 -1
  46. package/dist/cli/_chunks/dev.mjs +2 -3
  47. package/dist/cli/_chunks/list.mjs +1 -1
  48. package/dist/cli/_chunks/prepare.mjs +1 -1
  49. package/dist/cli/_chunks/run.mjs +1 -1
  50. package/dist/cli/_chunks/task.mjs +16 -0
  51. package/dist/cli/index.mjs +1 -1
  52. package/dist/presets/aws-lambda/runtime/_utils.d.mts +0 -5
  53. package/dist/presets/netlify/runtime/netlify-edge.d.mts +0 -1
  54. package/dist/presets/winterjs/runtime/winterjs.d.mts +0 -1
  55. package/dist/runtime/internal/error/dev.d.mts +0 -1
  56. package/dist/runtime/internal/route-rules.d.mts +0 -4
  57. package/dist/runtime/internal/routes/openapi.d.mts +0 -1
  58. package/dist/runtime/internal/routes/scalar.d.mts +0 -1
  59. package/dist/runtime/internal/routes/swagger.d.mts +0 -1
  60. package/dist/runtime/internal/runtime-config.d.mts +0 -1
  61. package/dist/runtime/nitro.d.mts +0 -3
  62. package/dist/runtime/virtual/renderer-template.d.mts +0 -1
  63. package/dist/types/index.d.mts +25 -1394
  64. package/dist/vite.mjs +18 -641
  65. package/package.json +5 -5
  66. package/dist/_chunks/nitro3.mjs +0 -2696
  67. package/dist/_chunks/nitro4.mjs +0 -176
  68. package/dist/_chunks/nitro5.mjs +0 -733
  69. package/dist/_chunks/nitro6.mjs +0 -1458
  70. package/dist/_chunks/nitro7.mjs +0 -7561
  71. package/dist/_chunks/nitro8.mjs +0 -3524
  72. package/dist/_chunks/nitro9.mjs +0 -1729
  73. package/dist/_libs/_.mjs +0 -3
  74. package/dist/_libs/_2.mjs +0 -3
  75. package/dist/_libs/_3.mjs +0 -4
  76. package/dist/_libs/_4.mjs +0 -6
  77. package/dist/_libs/_5.mjs +0 -3
  78. package/dist/_libs/_6.mjs +0 -3
  79. package/dist/_libs/acorn+confbox+js-tokens+magic-string+mlly+pkg-types+sourcemap-codec+strip-literal+unimport.mjs +0 -8900
  80. package/dist/_libs/confbox+exsolve+pkg-types.mjs +0 -1249
  81. package/dist/_libs/confbox2.mjs +0 -786
  82. package/dist/_libs/confbox3.mjs +0 -404
  83. package/dist/_libs/confbox4.mjs +0 -3
  84. package/dist/_libs/estree-walker+unimport.mjs +0 -378
  85. package/dist/_libs/fdir+picomatch+tinyglobby.mjs +0 -2471
  86. package/dist/_libs/giget+node-fetch-native.mjs +0 -2692
  87. package/dist/_libs/local-pkg+quansync+unimport.mjs +0 -1526
  88. package/dist/_libs/nypm+tinyexec.mjs +0 -858
  89. package/dist/_libs/pathe.mjs +0 -164
  90. package/dist/_libs/perfect-debounce.mjs +0 -89
  91. package/dist/_libs/std-env.mjs +0 -158
  92. package/dist/_libs/unimport.mjs +0 -9
  93. package/dist/_libs/vite-plugin-fullstack.mjs +0 -26
@@ -0,0 +1,652 @@
1
+ import { n as __exportAll } from "../_common.mjs";
2
+ import { S as MagicString, x as stripLiteral } from "../_build/common.mjs";
3
+ import fs from "node:fs";
4
+ import { fileURLToPath } from "node:url";
5
+ import path from "node:path";
6
+ import assert from "node:assert";
7
+ import { createHash } from "node:crypto";
8
+ import { isCSSRequest, normalizePath } from "vite";
9
+ import assert$1 from "node:assert/strict";
10
+
11
+ //#region node_modules/.pnpm/@rolldown+pluginutils@1.0.0-beta.55/node_modules/@rolldown/pluginutils/dist/simple-filters.js
12
+ /**
13
+ * Constructs a RegExp that matches the exact string specified.
14
+ *
15
+ * This is useful for plugin hook filters.
16
+ *
17
+ * @param str the string to match.
18
+ * @param flags flags for the RegExp.
19
+ *
20
+ * @example
21
+ * ```ts
22
+ * import { exactRegex } from '@rolldown/pluginutils';
23
+ * const plugin = {
24
+ * name: 'plugin',
25
+ * resolveId: {
26
+ * filter: { id: exactRegex('foo') },
27
+ * handler(id) {} // will only be called for `foo`
28
+ * }
29
+ * }
30
+ * ```
31
+ */
32
+ function exactRegex(str, flags) {
33
+ return new RegExp(`^${escapeRegex(str)}$`, flags);
34
+ }
35
+ const escapeRegexRE = /[-/\\^$*+?.()|[\]{}]/g;
36
+ function escapeRegex(str) {
37
+ return str.replace(escapeRegexRE, "\\$&");
38
+ }
39
+
40
+ //#endregion
41
+ //#region node_modules/.pnpm/@hiogawa+vite-plugin-fullstack@0.0.11_vite@8.0.0-beta.8_@types+node@25.0.9_esbuild@0.27_577572ae8fc6296e77b8a4205393d7c0/node_modules/@hiogawa/vite-plugin-fullstack/dist/plugin-B4MlD0Bd.js
42
+ function parseIdQuery(id) {
43
+ if (!id.includes("?")) return {
44
+ filename: id,
45
+ query: {}
46
+ };
47
+ const [filename, rawQuery] = id.split(`?`, 2);
48
+ return {
49
+ filename,
50
+ query: Object.fromEntries(new URLSearchParams(rawQuery))
51
+ };
52
+ }
53
+ function toAssetsVirtual(options) {
54
+ return `virtual:fullstack/assets?${new URLSearchParams(options)}&lang.js`;
55
+ }
56
+ function parseAssetsVirtual(id) {
57
+ if (id.startsWith("\0virtual:fullstack/assets?")) return parseIdQuery(id).query;
58
+ }
59
+ function createVirtualPlugin(name, load) {
60
+ name = "virtual:" + name;
61
+ return {
62
+ name: `fullstack:virtual-${name}`,
63
+ resolveId: {
64
+ filter: { id: exactRegex(name) },
65
+ handler(source, _importer, _options) {
66
+ return source === name ? "\0" + name : void 0;
67
+ }
68
+ },
69
+ load: {
70
+ filter: { id: exactRegex("\0" + name) },
71
+ handler(id, options) {
72
+ return load.apply(this, [id, options]);
73
+ }
74
+ }
75
+ };
76
+ }
77
+ function normalizeRelativePath(s) {
78
+ s = normalizePath(s);
79
+ return s[0] === "." ? s : "./" + s;
80
+ }
81
+ function hashString(v) {
82
+ return createHash("sha256").update(v).digest().toString("hex").slice(0, 12);
83
+ }
84
+ const VALID_ID_PREFIX = `/@id/`;
85
+ const NULL_BYTE_PLACEHOLDER = `__x00__`;
86
+ const FS_PREFIX = `/@fs/`;
87
+ function wrapId(id) {
88
+ return id.startsWith(VALID_ID_PREFIX) ? id : VALID_ID_PREFIX + id.replace("\0", NULL_BYTE_PLACEHOLDER);
89
+ }
90
+ function withTrailingSlash(path$1) {
91
+ if (path$1[path$1.length - 1] !== "/") return `${path$1}/`;
92
+ return path$1;
93
+ }
94
+ const postfixRE = /[?#].*$/;
95
+ function cleanUrl(url) {
96
+ return url.replace(postfixRE, "");
97
+ }
98
+ function splitFileAndPostfix(path$1) {
99
+ const file = cleanUrl(path$1);
100
+ return {
101
+ file,
102
+ postfix: path$1.slice(file.length)
103
+ };
104
+ }
105
+ const windowsSlashRE = /\\/g;
106
+ function slash(p) {
107
+ return p.replace(windowsSlashRE, "/");
108
+ }
109
+ const isWindows = typeof process !== "undefined" && process.platform === "win32";
110
+ function injectQuery(url, queryToInject) {
111
+ const { file, postfix } = splitFileAndPostfix(url);
112
+ return `${isWindows ? slash(file) : file}?${queryToInject}${postfix[0] === "?" ? `&${postfix.slice(1)}` : postfix}`;
113
+ }
114
+ function normalizeResolvedIdToUrl(environment, url, resolved) {
115
+ const root = environment.config.root;
116
+ const depsOptimizer = environment.depsOptimizer;
117
+ if (resolved.id.startsWith(withTrailingSlash(root))) url = resolved.id.slice(root.length);
118
+ else if (depsOptimizer?.isOptimizedDepFile(resolved.id) || resolved.id !== "/@react-refresh" && path.isAbsolute(resolved.id) && fs.existsSync(cleanUrl(resolved.id))) url = path.posix.join(FS_PREFIX, resolved.id);
119
+ else url = resolved.id;
120
+ if (url[0] !== "." && url[0] !== "/") url = wrapId(resolved.id);
121
+ return url;
122
+ }
123
+ function normalizeViteImportAnalysisUrl(environment, id) {
124
+ let url = normalizeResolvedIdToUrl(environment, id, { id });
125
+ if (environment.config.consumer === "client") {
126
+ const mod = environment.moduleGraph.getModuleById(id);
127
+ if (mod && mod.lastHMRTimestamp > 0) url = injectQuery(url, `t=${mod.lastHMRTimestamp}`);
128
+ }
129
+ return url;
130
+ }
131
+ function evalValue(rawValue) {
132
+ return new Function(`
133
+ var console, exports, global, module, process, require
134
+ return (\n${rawValue}\n)
135
+ `)();
136
+ }
137
+ const directRequestRE = /(\?|&)direct=?(?:&|$)/;
138
+ function assetsPlugin(pluginOpts) {
139
+ let server;
140
+ let resolvedConfig;
141
+ const importAssetsMetaMap = {};
142
+ const bundleMap = {};
143
+ async function processAssetsImport(ctx, id, options) {
144
+ if (ctx.environment.mode === "dev") {
145
+ const result = {
146
+ entry: void 0,
147
+ js: [],
148
+ css: []
149
+ };
150
+ const environment = server.environments[options.environment];
151
+ assert$1(environment, `Unknown environment: ${options.environment}`);
152
+ if (options.environment === "client") result.entry = assetsURLDev(normalizeViteImportAnalysisUrl(environment, id).slice(1), resolvedConfig);
153
+ if (environment.name !== "client") {
154
+ const collected = await collectCss(environment, id, { eager: pluginOpts?.experimental?.devEagerTransform ?? true });
155
+ result.css = collected.hrefs.map((href, i) => ({
156
+ href: assetsURLDev(href.slice(1), resolvedConfig),
157
+ "data-vite-dev-id": collected.ids[i]
158
+ }));
159
+ }
160
+ return JSON.stringify(result);
161
+ } else {
162
+ const map = importAssetsMetaMap[options.environment] ??= {};
163
+ const meta = {
164
+ id,
165
+ key: path.relative(resolvedConfig.root, id),
166
+ importerEnvironment: ctx.environment.name,
167
+ isEntry: !!(map[id]?.isEntry || options.isEntry)
168
+ };
169
+ map[id] = meta;
170
+ return `__assets_manifest[${JSON.stringify(options.environment)}][${JSON.stringify(meta.key)}]`;
171
+ }
172
+ }
173
+ let writeAssetsManifestCalled = false;
174
+ async function writeAssetsManifest(builder) {
175
+ if (writeAssetsManifestCalled) return;
176
+ writeAssetsManifestCalled = true;
177
+ const manifest = {};
178
+ for (const [environmentName, metas] of Object.entries(importAssetsMetaMap)) {
179
+ const bundle = bundleMap[environmentName];
180
+ const assetDepsMap = collectAssetDeps(bundle);
181
+ for (const [id, meta] of Object.entries(metas)) {
182
+ const found = assetDepsMap[id];
183
+ if (!found) {
184
+ builder.config.logger.error(`[vite-plugin-fullstack] failed to find built chunk for ${meta.id} imported by ${meta.importerEnvironment} environment`);
185
+ return;
186
+ }
187
+ const result = {
188
+ js: [],
189
+ css: []
190
+ };
191
+ const { chunk, deps } = found;
192
+ if (environmentName === "client") {
193
+ result.entry = assetsURL(chunk.fileName, builder.config);
194
+ result.js = deps.js.map((fileName) => ({ href: assetsURL(fileName, builder.config) }));
195
+ }
196
+ result.css = deps.css.map((fileName) => ({ href: assetsURL(fileName, builder.config) }));
197
+ if (!builder.environments[environmentName].config.build.cssCodeSplit) {
198
+ const singleCss = Object.values(bundle).find((v) => v.type === "asset" && v.originalFileNames.includes("style.css"));
199
+ if (singleCss) result.css.push({ href: assetsURL(singleCss.fileName, builder.config) });
200
+ }
201
+ (manifest[environmentName] ??= {})[meta.key] = result;
202
+ }
203
+ }
204
+ const importerEnvironments = new Set(Object.values(importAssetsMetaMap).flatMap((metas) => Object.values(metas)).flatMap((meta) => meta.importerEnvironment));
205
+ for (const environmentName of importerEnvironments) {
206
+ const outDir = builder.environments[environmentName].config.build.outDir;
207
+ fs.writeFileSync(path.join(outDir, BUILD_ASSETS_MANIFEST_NAME), `export default ${serializeValueWithRuntime(manifest)};`);
208
+ const clientOutDir = builder.environments["client"].config.build.outDir;
209
+ for (const asset of Object.values(bundleMap[environmentName])) if (asset.type === "asset") {
210
+ const srcFile = path.join(outDir, asset.fileName);
211
+ const destFile = path.join(clientOutDir, asset.fileName);
212
+ fs.mkdirSync(path.dirname(destFile), { recursive: true });
213
+ fs.copyFileSync(srcFile, destFile);
214
+ }
215
+ }
216
+ }
217
+ return [
218
+ {
219
+ name: "fullstack:assets",
220
+ sharedDuringBuild: true,
221
+ configureServer(server_) {
222
+ server = server_;
223
+ },
224
+ configResolved(config) {
225
+ resolvedConfig = config;
226
+ },
227
+ configEnvironment(name) {
228
+ if ((pluginOpts?.serverEnvironments ?? ["ssr"]).includes(name)) return { build: { emitAssets: true } };
229
+ },
230
+ transform: {
231
+ filter: { code: /import\.meta\.vite\.assets\(/ },
232
+ async handler(code, id, _options) {
233
+ const output = new MagicString(code);
234
+ const strippedCode = stripLiteral(code);
235
+ const newImports = /* @__PURE__ */ new Set();
236
+ for (const match of code.matchAll(/import\.meta\.vite\.assets\(([\s\S]*?)\)/dg)) {
237
+ const [start, end] = match.indices[0];
238
+ if (!strippedCode.slice(start, end).includes("import.meta.vite.assets")) continue;
239
+ if (this.environment.name === "client") {
240
+ const replacement$1 = `(${JSON.stringify(EMPTY_ASSETS)})`;
241
+ output.update(start, end, replacement$1);
242
+ continue;
243
+ }
244
+ const argCode = match[1].trim();
245
+ const options = {
246
+ import: id,
247
+ environment: void 0,
248
+ asEntry: false
249
+ };
250
+ if (argCode) {
251
+ const argValue = evalValue(argCode);
252
+ Object.assign(options, argValue);
253
+ }
254
+ const environments = options.environment ? [options.environment] : ["client", this.environment.name];
255
+ const importedNames = [];
256
+ for (const environment of environments) {
257
+ const importSource = toAssetsVirtual({
258
+ import: options.import,
259
+ importer: id,
260
+ environment,
261
+ entry: options.asEntry ? "1" : ""
262
+ });
263
+ const importedName = `__assets_${hashString(importSource)}`;
264
+ newImports.add(`;import ${importedName} from ${JSON.stringify(importSource)};\n`);
265
+ importedNames.push(importedName);
266
+ }
267
+ let replacement = importedNames[0];
268
+ if (importedNames.length > 1) {
269
+ newImports.add(`;import * as __assets_runtime from "virtual:fullstack/runtime";\n`);
270
+ replacement = `__assets_runtime.mergeAssets(${importedNames.join(", ")})`;
271
+ }
272
+ output.update(start, end, `(${replacement})`);
273
+ }
274
+ if (output.hasChanged()) {
275
+ for (const newImport of newImports) output.append(newImport);
276
+ return {
277
+ code: output.toString(),
278
+ map: output.generateMap({ hires: "boundary" })
279
+ };
280
+ }
281
+ }
282
+ },
283
+ resolveId: {
284
+ filter: { id: /^virtual:fullstack\// },
285
+ handler(source) {
286
+ if (source === "virtual:fullstack/runtime") return "\0" + source;
287
+ if (source.startsWith("virtual:fullstack/assets?")) return "\0" + source;
288
+ if (source === "virtual:fullstack/assets-manifest") {
289
+ assert$1.notEqual(this.environment.name, "client");
290
+ assert$1.equal(this.environment.mode, "build");
291
+ return {
292
+ id: source,
293
+ external: true
294
+ };
295
+ }
296
+ }
297
+ },
298
+ load: {
299
+ filter: { id: /^\0virtual:fullstack\// },
300
+ async handler(id) {
301
+ if (id === "\0virtual:fullstack/runtime") return `export const mergeAssets = ${(await Promise.resolve().then(() => runtime_exports)).mergeAssets.toString()};`;
302
+ const parsed = parseAssetsVirtual(id);
303
+ if (!parsed) return;
304
+ assert$1.notEqual(this.environment.name, "client");
305
+ const resolved = await this.resolve(parsed.import, parsed.importer);
306
+ assert$1(resolved, `Failed to resolve: ${parsed.import}`);
307
+ const s = new MagicString("");
308
+ const code = await processAssetsImport(this, resolved.id, {
309
+ environment: parsed.environment,
310
+ isEntry: !!parsed.entry
311
+ });
312
+ s.append(`export default ${code};\n`);
313
+ if (this.environment.mode === "build") s.prepend(`import __assets_manifest from "virtual:fullstack/assets-manifest";\n`);
314
+ return s.toString();
315
+ }
316
+ },
317
+ renderChunk(code, chunk) {
318
+ if (code.includes("virtual:fullstack/assets-manifest")) {
319
+ const replacement = normalizeRelativePath(path.relative(path.join(chunk.fileName, ".."), BUILD_ASSETS_MANIFEST_NAME));
320
+ code = code.replaceAll("virtual:fullstack/assets-manifest", () => replacement);
321
+ return { code };
322
+ }
323
+ },
324
+ writeBundle(_options, bundle) {
325
+ bundleMap[this.environment.name] = bundle;
326
+ },
327
+ buildStart() {
328
+ if (this.environment.mode == "build" && this.environment.name === "client") {
329
+ if (importAssetsMetaMap["client"]) {
330
+ for (const meta of Object.values(importAssetsMetaMap["client"])) if (meta.isEntry) this.emitFile({
331
+ type: "chunk",
332
+ id: meta.id,
333
+ preserveSignature: "exports-only"
334
+ });
335
+ }
336
+ }
337
+ },
338
+ buildApp: {
339
+ order: "pre",
340
+ async handler(builder) {
341
+ builder.writeAssetsManifest = async () => {
342
+ await writeAssetsManifest(builder);
343
+ };
344
+ }
345
+ }
346
+ },
347
+ {
348
+ name: "fullstack:write-assets-manifest-post",
349
+ buildApp: {
350
+ order: "post",
351
+ async handler(builder) {
352
+ await builder.writeAssetsManifest();
353
+ }
354
+ }
355
+ },
356
+ {
357
+ name: "fullstack:assets-query",
358
+ sharedDuringBuild: true,
359
+ resolveId: {
360
+ order: "pre",
361
+ filter: { id: /[?&]assets/ },
362
+ handler(source) {
363
+ const { query } = parseIdQuery(source);
364
+ if (typeof query["assets"] !== "undefined") {
365
+ if (this.environment.name === "client") return `\0virtual:fullstack/empty-assets`;
366
+ }
367
+ }
368
+ },
369
+ load: {
370
+ filter: { id: [/^\0virtual:fullstack\/empty-assets$/, /[?&]assets/] },
371
+ async handler(id) {
372
+ if (id === "\0virtual:fullstack/empty-assets") return `export default ${JSON.stringify(EMPTY_ASSETS)}`;
373
+ const { filename, query } = parseIdQuery(id);
374
+ const value = query["assets"];
375
+ if (typeof value !== "undefined") {
376
+ const s = new MagicString("");
377
+ const codes = [];
378
+ if (value) {
379
+ const code = await processAssetsImport(this, filename, {
380
+ environment: value,
381
+ isEntry: value === "client"
382
+ });
383
+ codes.push(code);
384
+ } else {
385
+ const code1 = await processAssetsImport(this, filename, {
386
+ environment: "client",
387
+ isEntry: false
388
+ });
389
+ const code2 = await processAssetsImport(this, filename, {
390
+ environment: this.environment.name,
391
+ isEntry: false
392
+ });
393
+ codes.push(code1, code2);
394
+ }
395
+ s.append(`
396
+ import * as __assets_runtime from "virtual:fullstack/runtime";\n
397
+ export default __assets_runtime.mergeAssets(${codes.join(", ")});
398
+ `);
399
+ if (this.environment.mode === "build") s.prepend(`import __assets_manifest from "virtual:fullstack/assets-manifest";\n`);
400
+ return {
401
+ code: s.toString(),
402
+ moduleSideEffects: false
403
+ };
404
+ }
405
+ }
406
+ },
407
+ hotUpdate(ctx) {
408
+ if (this.environment.name === "rsc") {
409
+ const mods = collectModuleDependents(ctx.modules);
410
+ for (const mod of mods) if (mod.id) {
411
+ const ids = [
412
+ `${mod.id}?assets`,
413
+ `${mod.id}?assets=client`,
414
+ `${mod.id}?assets=${this.environment.name}`
415
+ ];
416
+ for (const id of ids) invalidteModuleById(this.environment, id);
417
+ }
418
+ }
419
+ }
420
+ },
421
+ {
422
+ ...createVirtualPlugin("fullstack/client-fallback", () => "export {}"),
423
+ configEnvironment: {
424
+ order: "post",
425
+ handler(name, config, _env) {
426
+ if (name === "client") {
427
+ if ((pluginOpts?.experimental?.clientBuildFallback ?? true) && !config.build?.rollupOptions?.input) return { build: { rollupOptions: { input: { __fallback: "virtual:fullstack/client-fallback" } } } };
428
+ }
429
+ }
430
+ },
431
+ generateBundle(_optoins, bundle) {
432
+ if (this.environment.name !== "client") return;
433
+ for (const [k, v] of Object.entries(bundle)) if (v.type === "chunk" && v.name === "__fallback") delete bundle[k];
434
+ }
435
+ },
436
+ patchViteClientPlugin(),
437
+ patchVueScopeCssHmr(),
438
+ patchCssLinkSelfAccept()
439
+ ];
440
+ }
441
+ const EMPTY_ASSETS = {
442
+ js: [],
443
+ css: []
444
+ };
445
+ const BUILD_ASSETS_MANIFEST_NAME = "__fullstack_assets_manifest.js";
446
+ async function collectCss(environment, entryId, options) {
447
+ const visited = /* @__PURE__ */ new Set();
448
+ const cssIds = /* @__PURE__ */ new Set();
449
+ async function recurse(id) {
450
+ if (visited.has(id) || parseAssetsVirtual(id) || "assets" in parseIdQuery(id).query) return;
451
+ visited.add(id);
452
+ const mod = environment.moduleGraph.getModuleById(id);
453
+ if (!mod) return;
454
+ if (options.eager && !mod?.transformResult) try {
455
+ await environment.transformRequest(id);
456
+ } catch (e) {
457
+ console.error(`[collectCss] Failed to transform '${id}'`, e);
458
+ }
459
+ for (const next of mod?.importedModules ?? []) if (next.id) if (isCSSRequest(next.id)) {
460
+ if (hasSpecialCssQuery(next.id)) continue;
461
+ cssIds.add(next.id);
462
+ } else await recurse(next.id);
463
+ }
464
+ await recurse(entryId);
465
+ const hrefs = [...cssIds].map((id) => normalizeViteImportAnalysisUrl(environment, id));
466
+ return {
467
+ ids: [...cssIds],
468
+ hrefs
469
+ };
470
+ }
471
+ function invalidteModuleById(environment, id) {
472
+ const mod = environment.moduleGraph.getModuleById(id);
473
+ if (mod) environment.moduleGraph.invalidateModule(mod);
474
+ return mod;
475
+ }
476
+ function collectModuleDependents(mods) {
477
+ const visited = /* @__PURE__ */ new Set();
478
+ function recurse(mod) {
479
+ if (visited.has(mod)) return;
480
+ visited.add(mod);
481
+ for (const importer of mod.importers) recurse(importer);
482
+ }
483
+ for (const mod of mods) recurse(mod);
484
+ return [...visited];
485
+ }
486
+ function hasSpecialCssQuery(id) {
487
+ return /[?&](url|inline|raw)(\b|=|&|$)/.test(id);
488
+ }
489
+ function collectAssetDeps(bundle) {
490
+ const chunkToDeps = /* @__PURE__ */ new Map();
491
+ for (const chunk of Object.values(bundle)) if (chunk.type === "chunk") chunkToDeps.set(chunk, collectAssetDepsInner(chunk.fileName, bundle));
492
+ const idToDeps = {};
493
+ for (const [chunk, deps] of chunkToDeps.entries()) for (const id of chunk.moduleIds) idToDeps[id] = {
494
+ chunk,
495
+ deps
496
+ };
497
+ return idToDeps;
498
+ }
499
+ function collectAssetDepsInner(fileName, bundle) {
500
+ const visited = /* @__PURE__ */ new Set();
501
+ const css = [];
502
+ function recurse(k) {
503
+ if (visited.has(k)) return;
504
+ visited.add(k);
505
+ const v = bundle[k];
506
+ assert$1(v, `Not found '${k}' in the bundle`);
507
+ if (v.type === "chunk") {
508
+ css.push(...v.viteMetadata?.importedCss ?? []);
509
+ for (const k2 of v.imports) if (k2 in bundle) recurse(k2);
510
+ }
511
+ }
512
+ recurse(fileName);
513
+ return {
514
+ js: [...visited],
515
+ css: [...new Set(css)]
516
+ };
517
+ }
518
+ function patchViteClientPlugin() {
519
+ const viteClientPath = normalizePath(fileURLToPath(import.meta.resolve("vite/dist/client/client.mjs")));
520
+ function endIndexOf(code, searchValue) {
521
+ const i = code.lastIndexOf(searchValue);
522
+ return i === -1 ? i : i + searchValue.length;
523
+ }
524
+ return {
525
+ name: "fullstack:patch-vite-client",
526
+ transform: {
527
+ filter: { id: exactRegex(viteClientPath) },
528
+ handler(code, id) {
529
+ if (id === viteClientPath) {
530
+ if (code.includes("linkSheetsMap")) return;
531
+ const s = new MagicString(code);
532
+ s.prependLeft(code.indexOf("const sheetsMap"), `\
533
+ const linkSheetsMap = new Map();
534
+ document
535
+ .querySelectorAll('link[rel="stylesheet"][data-vite-dev-id]')
536
+ .forEach((el) => {
537
+ linkSheetsMap.set(el.getAttribute('data-vite-dev-id'), el)
538
+ });
539
+ `);
540
+ s.appendLeft(endIndexOf(code, `function updateStyle(id, content) {`), `if (linkSheetsMap.has(id)) { return }`);
541
+ s.appendLeft(endIndexOf(code, `function removeStyle(id) {`), `
542
+ const link = linkSheetsMap.get(id);
543
+ if (link) {
544
+ document
545
+ .querySelectorAll(
546
+ 'link[rel="stylesheet"][data-vite-dev-id]',
547
+ )
548
+ .forEach((el) => {
549
+ if (el.getAttribute('data-vite-dev-id') === id) {
550
+ el.remove()
551
+ }
552
+ })
553
+ linkSheetsMap.delete(id)
554
+ }
555
+ `);
556
+ return s.toString();
557
+ }
558
+ }
559
+ }
560
+ };
561
+ }
562
+ function patchVueScopeCssHmr() {
563
+ return {
564
+ name: "fullstack:patch-vue-scoped-css-hmr",
565
+ configureServer(server) {
566
+ server.middlewares.use((req, _res, next) => {
567
+ if (req.headers.accept?.includes("text/css") && req.url?.includes("&lang.css=")) req.url = req.url.replace("&lang.css=", "?lang.css");
568
+ next();
569
+ });
570
+ }
571
+ };
572
+ }
573
+ function patchCssLinkSelfAccept() {
574
+ return {
575
+ name: "fullstack:patch-css-link-self-accept",
576
+ apply: "serve",
577
+ transform: {
578
+ order: "post",
579
+ handler(_code, id, _options) {
580
+ if (this.environment.name === "client" && this.environment.mode === "dev" && isCSSRequest(id) && directRequestRE.test(id)) {
581
+ const mod = this.environment.moduleGraph.getModuleById(id);
582
+ if (mod && !mod.isSelfAccepting) mod.isSelfAccepting = true;
583
+ }
584
+ }
585
+ }
586
+ };
587
+ }
588
+ var BuildAssetsURLWithRuntime = class {
589
+ constructor(runtime) {
590
+ this.runtime = runtime;
591
+ }
592
+ };
593
+ function serializeValueWithRuntime(value) {
594
+ const replacements = [];
595
+ let result = JSON.stringify(value, (_key, value$1) => {
596
+ if (value$1 instanceof BuildAssetsURLWithRuntime) {
597
+ const placeholder = `__runtime_placeholder_${replacements.length}__`;
598
+ replacements.push([placeholder, value$1.runtime]);
599
+ return placeholder;
600
+ }
601
+ return value$1;
602
+ }, 2);
603
+ for (const [placeholder, runtime] of replacements) result = result.replace(`"${placeholder}"`, runtime);
604
+ return result;
605
+ }
606
+ function assetsURL(url, config) {
607
+ if (config.command === "build" && typeof config.experimental?.renderBuiltUrl === "function") {
608
+ const result = config.experimental.renderBuiltUrl(url, {
609
+ type: "asset",
610
+ hostType: "js",
611
+ ssr: true,
612
+ hostId: ""
613
+ });
614
+ if (typeof result === "object") {
615
+ if (result.runtime) return new BuildAssetsURLWithRuntime(result.runtime);
616
+ assert$1(!result.relative, "\"result.relative\" not supported on renderBuiltUrl() for fullstack plugin");
617
+ } else if (result) return result;
618
+ }
619
+ return config.base + url;
620
+ }
621
+ function assetsURLDev(url, config) {
622
+ return config.base + url;
623
+ }
624
+
625
+ //#endregion
626
+ //#region node_modules/.pnpm/@hiogawa+vite-plugin-fullstack@0.0.11_vite@8.0.0-beta.8_@types+node@25.0.9_esbuild@0.27_577572ae8fc6296e77b8a4205393d7c0/node_modules/@hiogawa/vite-plugin-fullstack/dist/runtime.js
627
+ var runtime_exports = /* @__PURE__ */ __exportAll({ mergeAssets: () => mergeAssets });
628
+ function mergeAssets(...args) {
629
+ const js = uniqBy(args.flatMap((h) => h.js), (a) => a.href);
630
+ const css = uniqBy(args.flatMap((h) => h.css), (a) => a.href);
631
+ const raw = {
632
+ entry: args.filter((arg) => arg.entry)?.[0]?.entry,
633
+ js,
634
+ css
635
+ };
636
+ return {
637
+ ...raw,
638
+ merge: (...args$1) => mergeAssets(raw, ...args$1)
639
+ };
640
+ function uniqBy(array, key) {
641
+ const seen = /* @__PURE__ */ new Set();
642
+ return array.filter((item) => {
643
+ const k = key(item);
644
+ if (seen.has(k)) return false;
645
+ seen.add(k);
646
+ return true;
647
+ });
648
+ }
649
+ }
650
+
651
+ //#endregion
652
+ export { assetsPlugin as n, runtime_exports as t };