nitro-nightly 3.0.1-20260120-020848-6786d069 → 3.0.1-20260120-133205-cbfce96c

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 (92) 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/@hiogawa/vite-plugin-fullstack.mjs +652 -0
  11. package/dist/_libs/@jridgewell/gen-mapping.mjs +448 -0
  12. package/dist/_libs/@jridgewell/remapping.mjs +117 -0
  13. package/dist/_libs/@rollup/plugin-alias.mjs +64 -0
  14. package/dist/_libs/@rollup/plugin-commonjs.d.mts +241 -0
  15. package/dist/_libs/@rollup/plugin-commonjs.mjs +1300 -0
  16. package/dist/_libs/{plugin-alias+plugin-inject.mjs → @rollup/plugin-inject.mjs} +2 -65
  17. package/dist/_libs/@rollup/plugin-json.mjs +36 -0
  18. package/dist/_libs/@rollup/plugin-node-resolve.mjs +1972 -0
  19. package/dist/_libs/c12.d.mts +214 -0
  20. package/dist/_libs/{c12+dotenv+rc9.mjs → c12.mjs} +105 -12
  21. package/dist/_libs/{chokidar+readdirp.mjs → chokidar.mjs} +8 -1
  22. package/dist/_libs/compatx.d.mts +47 -0
  23. package/dist/_libs/confbox.mjs +2488 -70
  24. package/dist/_libs/esbuild.d.mts +20 -0
  25. package/dist/_libs/escape-string-regexp.mjs +8 -0
  26. package/dist/_libs/estree-walker.mjs +187 -0
  27. package/dist/_libs/giget.mjs +3550 -0
  28. package/dist/_libs/httpxy.d.mts +79 -0
  29. package/dist/_libs/httpxy.mjs +6 -1
  30. package/dist/_libs/klona.mjs +38 -0
  31. package/dist/_libs/magic-string.d.mts +220 -0
  32. package/dist/_libs/mlly.d.mts +57 -0
  33. package/dist/_libs/pkg-types.d.mts +23 -0
  34. package/dist/_libs/rou3.d.mts +43 -0
  35. package/dist/_libs/rou3.mjs +322 -0
  36. package/dist/_libs/std-env.d.mts +4 -0
  37. package/dist/_libs/tsconfck.mjs +832 -0
  38. package/dist/_libs/ultrahtml.mjs +138 -0
  39. package/dist/_libs/unimport.d.mts +426 -0
  40. package/dist/_libs/unimport.mjs +1781 -5
  41. package/dist/_libs/unwasm.d.mts +29 -0
  42. package/dist/_presets.mjs +3 -8
  43. package/dist/builder.mjs +6 -8
  44. package/dist/cli/_chunks/build.mjs +1 -1
  45. package/dist/cli/_chunks/dev.mjs +2 -3
  46. package/dist/cli/_chunks/list.mjs +1 -1
  47. package/dist/cli/_chunks/prepare.mjs +1 -1
  48. package/dist/cli/_chunks/run.mjs +1 -1
  49. package/dist/cli/_chunks/task.mjs +16 -0
  50. package/dist/cli/index.mjs +1 -1
  51. package/dist/presets/aws-lambda/runtime/_utils.d.mts +0 -5
  52. package/dist/presets/netlify/runtime/netlify-edge.d.mts +0 -1
  53. package/dist/presets/winterjs/runtime/winterjs.d.mts +0 -1
  54. package/dist/runtime/internal/error/dev.d.mts +0 -1
  55. package/dist/runtime/internal/route-rules.d.mts +0 -4
  56. package/dist/runtime/internal/routes/openapi.d.mts +0 -1
  57. package/dist/runtime/internal/routes/scalar.d.mts +0 -1
  58. package/dist/runtime/internal/routes/swagger.d.mts +0 -1
  59. package/dist/runtime/internal/runtime-config.d.mts +0 -1
  60. package/dist/runtime/nitro.d.mts +0 -3
  61. package/dist/runtime/virtual/renderer-template.d.mts +0 -1
  62. package/dist/types/index.d.mts +36 -1405
  63. package/dist/vite.mjs +18 -641
  64. package/package.json +2 -2
  65. package/dist/_chunks/nitro3.mjs +0 -2696
  66. package/dist/_chunks/nitro4.mjs +0 -176
  67. package/dist/_chunks/nitro5.mjs +0 -733
  68. package/dist/_chunks/nitro6.mjs +0 -1458
  69. package/dist/_chunks/nitro7.mjs +0 -7561
  70. package/dist/_chunks/nitro8.mjs +0 -3524
  71. package/dist/_chunks/nitro9.mjs +0 -1729
  72. package/dist/_libs/_.mjs +0 -3
  73. package/dist/_libs/_2.mjs +0 -3
  74. package/dist/_libs/_3.mjs +0 -4
  75. package/dist/_libs/_4.mjs +0 -6
  76. package/dist/_libs/_5.mjs +0 -3
  77. package/dist/_libs/_6.mjs +0 -3
  78. package/dist/_libs/acorn+confbox+js-tokens+magic-string+mlly+pkg-types+sourcemap-codec+strip-literal+unimport.mjs +0 -8900
  79. package/dist/_libs/confbox+exsolve+pkg-types.mjs +0 -1249
  80. package/dist/_libs/confbox2.mjs +0 -786
  81. package/dist/_libs/confbox3.mjs +0 -404
  82. package/dist/_libs/confbox4.mjs +0 -3
  83. package/dist/_libs/estree-walker+unimport.mjs +0 -378
  84. package/dist/_libs/fdir+picomatch+tinyglobby.mjs +0 -2471
  85. package/dist/_libs/gen-mapping+remapping+resolve-uri+trace-mapping+unimport+unplugin+unplugin-utils+webpack-virtual-modules.mjs +0 -2150
  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/vite-plugin-fullstack.mjs +0 -26
package/dist/vite.mjs CHANGED
@@ -1,34 +1,26 @@
1
- import "./_chunks/nitro.mjs";
2
- import { a as join$1, i as isAbsolute$1, l as relative$1, n as dirname$1, t as basename$1, u as resolve$1 } from "./_libs/pathe.mjs";
3
- import "./_libs/c12+dotenv+rc9.mjs";
4
- import { l as resolveModulePath } from "./_libs/confbox+exsolve+pkg-types.mjs";
5
- import { t as debounce } from "./_libs/perfect-debounce.mjs";
1
+ import "./_common.mjs";
2
+ import { $ as resolveModulePath, B as T, D as prepare, I as prettyPath, O as copyPublicAssets, V as a, a as libChunkName, at as join$1, ct as resolve$1, h as writeBuildInfo, i as getChunkName, it as isAbsolute$1, m as getBuildInfo, n as baseBuildPlugins, nt as dirname$1, o as baseBuildConfig, r as NODE_MODULES_RE, st as relative$1, tt as basename$1 } from "./_build/common.mjs";
3
+ import { i as debounce } from "./_libs/c12.mjs";
6
4
  import { t as formatCompatibilityDate } from "./_libs/compatx.mjs";
7
- import { a as copyPublicAssets, i as prepare, s as createNitro } from "./_chunks/nitro3.mjs";
8
- import { i as a, r as T } from "./_libs/std-env.mjs";
9
- import { n as prettyPath } from "./_chunks/nitro4.mjs";
10
- import "./_libs/fdir+picomatch+tinyglobby.mjs";
11
- import { c as scanHandlers } from "./_chunks/nitro5.mjs";
12
- import { n as writeBuildInfo, t as getBuildInfo } from "./_chunks/nitro6.mjs";
13
- import { S as MagicString, x as stripLiteral } from "./_libs/acorn+confbox+js-tokens+magic-string+mlly+pkg-types+sourcemap-codec+strip-literal+unimport.mjs";
5
+ import { i as createNitro } from "./_chunks/nitro.mjs";
6
+ import "./_libs/tsconfck.mjs";
7
+ import { n as scanHandlers } from "./_chunks/nitro2.mjs";
14
8
  import { i as NodeEnvRunner, r as NitroDevApp } from "./_chunks/dev.mjs";
15
- import { i as watch$1 } from "./_libs/chokidar+readdirp.mjs";
16
- import { n as alias, t as inject } from "./_libs/plugin-alias+plugin-inject.mjs";
17
- import { a as baseBuildConfig, i as libChunkName, n as NODE_MODULES_RE, r as getChunkName, t as baseBuildPlugins } from "./_chunks/nitro7.mjs";
9
+ import { n as watch$1 } from "./_libs/chokidar.mjs";
10
+ import { t as alias } from "./_libs/@rollup/plugin-alias.mjs";
11
+ import { t as inject } from "./_libs/@rollup/plugin-inject.mjs";
12
+ import { n as assetsPlugin } from "./_libs/@hiogawa/vite-plugin-fullstack.mjs";
18
13
  import consola$1 from "consola";
19
- import fs, { existsSync, watch } from "node:fs";
14
+ import { existsSync, watch } from "node:fs";
20
15
  import { mkdir, readFile, rm, writeFile } from "node:fs/promises";
21
- import { fileURLToPath } from "node:url";
22
- import path, { join, resolve } from "node:path";
23
- import assert from "node:assert";
16
+ import { join, resolve } from "node:path";
24
17
  import { defu } from "defu";
25
18
  import { runtimeDependencies, runtimeDir } from "nitro/meta";
26
19
  import { colors } from "consola/utils";
20
+ import { IncomingMessage } from "node:http";
27
21
  import { NodeRequest, sendNodeResponse } from "srvx/node";
28
- import { createHash } from "node:crypto";
29
- import { DevEnvironment, isCSSRequest, normalizePath } from "vite";
22
+ import { DevEnvironment } from "vite";
30
23
  import { spawn } from "node:child_process";
31
- import assert$1 from "node:assert/strict";
32
24
 
33
25
  //#region src/build/vite/rollup.ts
34
26
  const getViteRollupConfig = async (ctx) => {
@@ -436,7 +428,7 @@ function nitroPreviewPlugin(ctx) {
436
428
  child.once("exit", (code) => {
437
429
  if (code && code !== 0) consola$1.error(`[nitro] Preview server exited with code ${code}`);
438
430
  });
439
- const { createProxyServer } = await import("./_libs/_5.mjs");
431
+ const { createProxyServer } = await import("./_libs/httpxy.mjs").then((n) => n.n);
440
432
  const proxy = createProxyServer({ target: `http://localhost:${randomPort}` });
441
433
  server.middlewares.use((req, res, next) => {
442
434
  if (child && !child.killed) proxy.web(req, res).catch(next);
@@ -450,7 +442,7 @@ function nitroPreviewPlugin(ctx) {
450
442
  };
451
443
  }
452
444
  async function loadPreviewDotEnv(root) {
453
- const { loadDotenv } = await import("./_libs/_3.mjs");
445
+ const { loadDotenv } = await import("./_libs/c12.mjs").then((n) => n.t);
454
446
  const env = await loadDotenv({
455
447
  cwd: root,
456
448
  fileName: [
@@ -462,621 +454,6 @@ async function loadPreviewDotEnv(root) {
462
454
  return Object.entries(env).filter(([_key, val]) => val);
463
455
  }
464
456
 
465
- //#endregion
466
- //#region node_modules/.pnpm/@rolldown+pluginutils@1.0.0-beta.55/node_modules/@rolldown/pluginutils/dist/simple-filters.js
467
- /**
468
- * Constructs a RegExp that matches the exact string specified.
469
- *
470
- * This is useful for plugin hook filters.
471
- *
472
- * @param str the string to match.
473
- * @param flags flags for the RegExp.
474
- *
475
- * @example
476
- * ```ts
477
- * import { exactRegex } from '@rolldown/pluginutils';
478
- * const plugin = {
479
- * name: 'plugin',
480
- * resolveId: {
481
- * filter: { id: exactRegex('foo') },
482
- * handler(id) {} // will only be called for `foo`
483
- * }
484
- * }
485
- * ```
486
- */
487
- function exactRegex(str, flags) {
488
- return new RegExp(`^${escapeRegex(str)}$`, flags);
489
- }
490
- const escapeRegexRE = /[-/\\^$*+?.()|[\]{}]/g;
491
- function escapeRegex(str) {
492
- return str.replace(escapeRegexRE, "\\$&");
493
- }
494
-
495
- //#endregion
496
- //#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
497
- function parseIdQuery(id) {
498
- if (!id.includes("?")) return {
499
- filename: id,
500
- query: {}
501
- };
502
- const [filename, rawQuery] = id.split(`?`, 2);
503
- return {
504
- filename,
505
- query: Object.fromEntries(new URLSearchParams(rawQuery))
506
- };
507
- }
508
- function toAssetsVirtual(options) {
509
- return `virtual:fullstack/assets?${new URLSearchParams(options)}&lang.js`;
510
- }
511
- function parseAssetsVirtual(id) {
512
- if (id.startsWith("\0virtual:fullstack/assets?")) return parseIdQuery(id).query;
513
- }
514
- function createVirtualPlugin(name, load) {
515
- name = "virtual:" + name;
516
- return {
517
- name: `fullstack:virtual-${name}`,
518
- resolveId: {
519
- filter: { id: exactRegex(name) },
520
- handler(source, _importer, _options) {
521
- return source === name ? "\0" + name : void 0;
522
- }
523
- },
524
- load: {
525
- filter: { id: exactRegex("\0" + name) },
526
- handler(id, options) {
527
- return load.apply(this, [id, options]);
528
- }
529
- }
530
- };
531
- }
532
- function normalizeRelativePath(s) {
533
- s = normalizePath(s);
534
- return s[0] === "." ? s : "./" + s;
535
- }
536
- function hashString(v) {
537
- return createHash("sha256").update(v).digest().toString("hex").slice(0, 12);
538
- }
539
- const VALID_ID_PREFIX = `/@id/`;
540
- const NULL_BYTE_PLACEHOLDER = `__x00__`;
541
- const FS_PREFIX = `/@fs/`;
542
- function wrapId(id) {
543
- return id.startsWith(VALID_ID_PREFIX) ? id : VALID_ID_PREFIX + id.replace("\0", NULL_BYTE_PLACEHOLDER);
544
- }
545
- function withTrailingSlash(path$1) {
546
- if (path$1[path$1.length - 1] !== "/") return `${path$1}/`;
547
- return path$1;
548
- }
549
- const postfixRE = /[?#].*$/;
550
- function cleanUrl(url) {
551
- return url.replace(postfixRE, "");
552
- }
553
- function splitFileAndPostfix(path$1) {
554
- const file = cleanUrl(path$1);
555
- return {
556
- file,
557
- postfix: path$1.slice(file.length)
558
- };
559
- }
560
- const windowsSlashRE = /\\/g;
561
- function slash(p) {
562
- return p.replace(windowsSlashRE, "/");
563
- }
564
- const isWindows = typeof process !== "undefined" && process.platform === "win32";
565
- function injectQuery(url, queryToInject) {
566
- const { file, postfix } = splitFileAndPostfix(url);
567
- return `${isWindows ? slash(file) : file}?${queryToInject}${postfix[0] === "?" ? `&${postfix.slice(1)}` : postfix}`;
568
- }
569
- function normalizeResolvedIdToUrl(environment, url, resolved) {
570
- const root = environment.config.root;
571
- const depsOptimizer = environment.depsOptimizer;
572
- if (resolved.id.startsWith(withTrailingSlash(root))) url = resolved.id.slice(root.length);
573
- 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);
574
- else url = resolved.id;
575
- if (url[0] !== "." && url[0] !== "/") url = wrapId(resolved.id);
576
- return url;
577
- }
578
- function normalizeViteImportAnalysisUrl(environment, id) {
579
- let url = normalizeResolvedIdToUrl(environment, id, { id });
580
- if (environment.config.consumer === "client") {
581
- const mod = environment.moduleGraph.getModuleById(id);
582
- if (mod && mod.lastHMRTimestamp > 0) url = injectQuery(url, `t=${mod.lastHMRTimestamp}`);
583
- }
584
- return url;
585
- }
586
- function evalValue(rawValue) {
587
- return new Function(`
588
- var console, exports, global, module, process, require
589
- return (\n${rawValue}\n)
590
- `)();
591
- }
592
- const directRequestRE = /(\?|&)direct=?(?:&|$)/;
593
- function assetsPlugin(pluginOpts) {
594
- let server;
595
- let resolvedConfig;
596
- const importAssetsMetaMap = {};
597
- const bundleMap = {};
598
- async function processAssetsImport(ctx, id, options) {
599
- if (ctx.environment.mode === "dev") {
600
- const result = {
601
- entry: void 0,
602
- js: [],
603
- css: []
604
- };
605
- const environment = server.environments[options.environment];
606
- assert$1(environment, `Unknown environment: ${options.environment}`);
607
- if (options.environment === "client") result.entry = assetsURLDev(normalizeViteImportAnalysisUrl(environment, id).slice(1), resolvedConfig);
608
- if (environment.name !== "client") {
609
- const collected = await collectCss(environment, id, { eager: pluginOpts?.experimental?.devEagerTransform ?? true });
610
- result.css = collected.hrefs.map((href, i) => ({
611
- href: assetsURLDev(href.slice(1), resolvedConfig),
612
- "data-vite-dev-id": collected.ids[i]
613
- }));
614
- }
615
- return JSON.stringify(result);
616
- } else {
617
- const map = importAssetsMetaMap[options.environment] ??= {};
618
- const meta = {
619
- id,
620
- key: path.relative(resolvedConfig.root, id),
621
- importerEnvironment: ctx.environment.name,
622
- isEntry: !!(map[id]?.isEntry || options.isEntry)
623
- };
624
- map[id] = meta;
625
- return `__assets_manifest[${JSON.stringify(options.environment)}][${JSON.stringify(meta.key)}]`;
626
- }
627
- }
628
- let writeAssetsManifestCalled = false;
629
- async function writeAssetsManifest(builder) {
630
- if (writeAssetsManifestCalled) return;
631
- writeAssetsManifestCalled = true;
632
- const manifest = {};
633
- for (const [environmentName, metas] of Object.entries(importAssetsMetaMap)) {
634
- const bundle = bundleMap[environmentName];
635
- const assetDepsMap = collectAssetDeps(bundle);
636
- for (const [id, meta] of Object.entries(metas)) {
637
- const found = assetDepsMap[id];
638
- if (!found) {
639
- builder.config.logger.error(`[vite-plugin-fullstack] failed to find built chunk for ${meta.id} imported by ${meta.importerEnvironment} environment`);
640
- return;
641
- }
642
- const result = {
643
- js: [],
644
- css: []
645
- };
646
- const { chunk, deps } = found;
647
- if (environmentName === "client") {
648
- result.entry = assetsURL(chunk.fileName, builder.config);
649
- result.js = deps.js.map((fileName) => ({ href: assetsURL(fileName, builder.config) }));
650
- }
651
- result.css = deps.css.map((fileName) => ({ href: assetsURL(fileName, builder.config) }));
652
- if (!builder.environments[environmentName].config.build.cssCodeSplit) {
653
- const singleCss = Object.values(bundle).find((v) => v.type === "asset" && v.originalFileNames.includes("style.css"));
654
- if (singleCss) result.css.push({ href: assetsURL(singleCss.fileName, builder.config) });
655
- }
656
- (manifest[environmentName] ??= {})[meta.key] = result;
657
- }
658
- }
659
- const importerEnvironments = new Set(Object.values(importAssetsMetaMap).flatMap((metas) => Object.values(metas)).flatMap((meta) => meta.importerEnvironment));
660
- for (const environmentName of importerEnvironments) {
661
- const outDir = builder.environments[environmentName].config.build.outDir;
662
- fs.writeFileSync(path.join(outDir, BUILD_ASSETS_MANIFEST_NAME), `export default ${serializeValueWithRuntime(manifest)};`);
663
- const clientOutDir = builder.environments["client"].config.build.outDir;
664
- for (const asset of Object.values(bundleMap[environmentName])) if (asset.type === "asset") {
665
- const srcFile = path.join(outDir, asset.fileName);
666
- const destFile = path.join(clientOutDir, asset.fileName);
667
- fs.mkdirSync(path.dirname(destFile), { recursive: true });
668
- fs.copyFileSync(srcFile, destFile);
669
- }
670
- }
671
- }
672
- return [
673
- {
674
- name: "fullstack:assets",
675
- sharedDuringBuild: true,
676
- configureServer(server_) {
677
- server = server_;
678
- },
679
- configResolved(config) {
680
- resolvedConfig = config;
681
- },
682
- configEnvironment(name) {
683
- if ((pluginOpts?.serverEnvironments ?? ["ssr"]).includes(name)) return { build: { emitAssets: true } };
684
- },
685
- transform: {
686
- filter: { code: /import\.meta\.vite\.assets\(/ },
687
- async handler(code, id, _options) {
688
- const output = new MagicString(code);
689
- const strippedCode = stripLiteral(code);
690
- const newImports = /* @__PURE__ */ new Set();
691
- for (const match of code.matchAll(/import\.meta\.vite\.assets\(([\s\S]*?)\)/dg)) {
692
- const [start, end] = match.indices[0];
693
- if (!strippedCode.slice(start, end).includes("import.meta.vite.assets")) continue;
694
- if (this.environment.name === "client") {
695
- const replacement$1 = `(${JSON.stringify(EMPTY_ASSETS)})`;
696
- output.update(start, end, replacement$1);
697
- continue;
698
- }
699
- const argCode = match[1].trim();
700
- const options = {
701
- import: id,
702
- environment: void 0,
703
- asEntry: false
704
- };
705
- if (argCode) {
706
- const argValue = evalValue(argCode);
707
- Object.assign(options, argValue);
708
- }
709
- const environments = options.environment ? [options.environment] : ["client", this.environment.name];
710
- const importedNames = [];
711
- for (const environment of environments) {
712
- const importSource = toAssetsVirtual({
713
- import: options.import,
714
- importer: id,
715
- environment,
716
- entry: options.asEntry ? "1" : ""
717
- });
718
- const importedName = `__assets_${hashString(importSource)}`;
719
- newImports.add(`;import ${importedName} from ${JSON.stringify(importSource)};\n`);
720
- importedNames.push(importedName);
721
- }
722
- let replacement = importedNames[0];
723
- if (importedNames.length > 1) {
724
- newImports.add(`;import * as __assets_runtime from "virtual:fullstack/runtime";\n`);
725
- replacement = `__assets_runtime.mergeAssets(${importedNames.join(", ")})`;
726
- }
727
- output.update(start, end, `(${replacement})`);
728
- }
729
- if (output.hasChanged()) {
730
- for (const newImport of newImports) output.append(newImport);
731
- return {
732
- code: output.toString(),
733
- map: output.generateMap({ hires: "boundary" })
734
- };
735
- }
736
- }
737
- },
738
- resolveId: {
739
- filter: { id: /^virtual:fullstack\// },
740
- handler(source) {
741
- if (source === "virtual:fullstack/runtime") return "\0" + source;
742
- if (source.startsWith("virtual:fullstack/assets?")) return "\0" + source;
743
- if (source === "virtual:fullstack/assets-manifest") {
744
- assert$1.notEqual(this.environment.name, "client");
745
- assert$1.equal(this.environment.mode, "build");
746
- return {
747
- id: source,
748
- external: true
749
- };
750
- }
751
- }
752
- },
753
- load: {
754
- filter: { id: /^\0virtual:fullstack\// },
755
- async handler(id) {
756
- if (id === "\0virtual:fullstack/runtime") return `export const mergeAssets = ${(await import("./_libs/vite-plugin-fullstack.mjs")).mergeAssets.toString()};`;
757
- const parsed = parseAssetsVirtual(id);
758
- if (!parsed) return;
759
- assert$1.notEqual(this.environment.name, "client");
760
- const resolved = await this.resolve(parsed.import, parsed.importer);
761
- assert$1(resolved, `Failed to resolve: ${parsed.import}`);
762
- const s = new MagicString("");
763
- const code = await processAssetsImport(this, resolved.id, {
764
- environment: parsed.environment,
765
- isEntry: !!parsed.entry
766
- });
767
- s.append(`export default ${code};\n`);
768
- if (this.environment.mode === "build") s.prepend(`import __assets_manifest from "virtual:fullstack/assets-manifest";\n`);
769
- return s.toString();
770
- }
771
- },
772
- renderChunk(code, chunk) {
773
- if (code.includes("virtual:fullstack/assets-manifest")) {
774
- const replacement = normalizeRelativePath(path.relative(path.join(chunk.fileName, ".."), BUILD_ASSETS_MANIFEST_NAME));
775
- code = code.replaceAll("virtual:fullstack/assets-manifest", () => replacement);
776
- return { code };
777
- }
778
- },
779
- writeBundle(_options, bundle) {
780
- bundleMap[this.environment.name] = bundle;
781
- },
782
- buildStart() {
783
- if (this.environment.mode == "build" && this.environment.name === "client") {
784
- if (importAssetsMetaMap["client"]) {
785
- for (const meta of Object.values(importAssetsMetaMap["client"])) if (meta.isEntry) this.emitFile({
786
- type: "chunk",
787
- id: meta.id,
788
- preserveSignature: "exports-only"
789
- });
790
- }
791
- }
792
- },
793
- buildApp: {
794
- order: "pre",
795
- async handler(builder) {
796
- builder.writeAssetsManifest = async () => {
797
- await writeAssetsManifest(builder);
798
- };
799
- }
800
- }
801
- },
802
- {
803
- name: "fullstack:write-assets-manifest-post",
804
- buildApp: {
805
- order: "post",
806
- async handler(builder) {
807
- await builder.writeAssetsManifest();
808
- }
809
- }
810
- },
811
- {
812
- name: "fullstack:assets-query",
813
- sharedDuringBuild: true,
814
- resolveId: {
815
- order: "pre",
816
- filter: { id: /[?&]assets/ },
817
- handler(source) {
818
- const { query } = parseIdQuery(source);
819
- if (typeof query["assets"] !== "undefined") {
820
- if (this.environment.name === "client") return `\0virtual:fullstack/empty-assets`;
821
- }
822
- }
823
- },
824
- load: {
825
- filter: { id: [/^\0virtual:fullstack\/empty-assets$/, /[?&]assets/] },
826
- async handler(id) {
827
- if (id === "\0virtual:fullstack/empty-assets") return `export default ${JSON.stringify(EMPTY_ASSETS)}`;
828
- const { filename, query } = parseIdQuery(id);
829
- const value = query["assets"];
830
- if (typeof value !== "undefined") {
831
- const s = new MagicString("");
832
- const codes = [];
833
- if (value) {
834
- const code = await processAssetsImport(this, filename, {
835
- environment: value,
836
- isEntry: value === "client"
837
- });
838
- codes.push(code);
839
- } else {
840
- const code1 = await processAssetsImport(this, filename, {
841
- environment: "client",
842
- isEntry: false
843
- });
844
- const code2 = await processAssetsImport(this, filename, {
845
- environment: this.environment.name,
846
- isEntry: false
847
- });
848
- codes.push(code1, code2);
849
- }
850
- s.append(`
851
- import * as __assets_runtime from "virtual:fullstack/runtime";\n
852
- export default __assets_runtime.mergeAssets(${codes.join(", ")});
853
- `);
854
- if (this.environment.mode === "build") s.prepend(`import __assets_manifest from "virtual:fullstack/assets-manifest";\n`);
855
- return {
856
- code: s.toString(),
857
- moduleSideEffects: false
858
- };
859
- }
860
- }
861
- },
862
- hotUpdate(ctx) {
863
- if (this.environment.name === "rsc") {
864
- const mods = collectModuleDependents(ctx.modules);
865
- for (const mod of mods) if (mod.id) {
866
- const ids = [
867
- `${mod.id}?assets`,
868
- `${mod.id}?assets=client`,
869
- `${mod.id}?assets=${this.environment.name}`
870
- ];
871
- for (const id of ids) invalidteModuleById(this.environment, id);
872
- }
873
- }
874
- }
875
- },
876
- {
877
- ...createVirtualPlugin("fullstack/client-fallback", () => "export {}"),
878
- configEnvironment: {
879
- order: "post",
880
- handler(name, config, _env) {
881
- if (name === "client") {
882
- if ((pluginOpts?.experimental?.clientBuildFallback ?? true) && !config.build?.rollupOptions?.input) return { build: { rollupOptions: { input: { __fallback: "virtual:fullstack/client-fallback" } } } };
883
- }
884
- }
885
- },
886
- generateBundle(_optoins, bundle) {
887
- if (this.environment.name !== "client") return;
888
- for (const [k, v] of Object.entries(bundle)) if (v.type === "chunk" && v.name === "__fallback") delete bundle[k];
889
- }
890
- },
891
- patchViteClientPlugin(),
892
- patchVueScopeCssHmr(),
893
- patchCssLinkSelfAccept()
894
- ];
895
- }
896
- const EMPTY_ASSETS = {
897
- js: [],
898
- css: []
899
- };
900
- const BUILD_ASSETS_MANIFEST_NAME = "__fullstack_assets_manifest.js";
901
- async function collectCss(environment, entryId, options) {
902
- const visited = /* @__PURE__ */ new Set();
903
- const cssIds = /* @__PURE__ */ new Set();
904
- async function recurse(id) {
905
- if (visited.has(id) || parseAssetsVirtual(id) || "assets" in parseIdQuery(id).query) return;
906
- visited.add(id);
907
- const mod = environment.moduleGraph.getModuleById(id);
908
- if (!mod) return;
909
- if (options.eager && !mod?.transformResult) try {
910
- await environment.transformRequest(id);
911
- } catch (e) {
912
- console.error(`[collectCss] Failed to transform '${id}'`, e);
913
- }
914
- for (const next of mod?.importedModules ?? []) if (next.id) if (isCSSRequest(next.id)) {
915
- if (hasSpecialCssQuery(next.id)) continue;
916
- cssIds.add(next.id);
917
- } else await recurse(next.id);
918
- }
919
- await recurse(entryId);
920
- const hrefs = [...cssIds].map((id) => normalizeViteImportAnalysisUrl(environment, id));
921
- return {
922
- ids: [...cssIds],
923
- hrefs
924
- };
925
- }
926
- function invalidteModuleById(environment, id) {
927
- const mod = environment.moduleGraph.getModuleById(id);
928
- if (mod) environment.moduleGraph.invalidateModule(mod);
929
- return mod;
930
- }
931
- function collectModuleDependents(mods) {
932
- const visited = /* @__PURE__ */ new Set();
933
- function recurse(mod) {
934
- if (visited.has(mod)) return;
935
- visited.add(mod);
936
- for (const importer of mod.importers) recurse(importer);
937
- }
938
- for (const mod of mods) recurse(mod);
939
- return [...visited];
940
- }
941
- function hasSpecialCssQuery(id) {
942
- return /[?&](url|inline|raw)(\b|=|&|$)/.test(id);
943
- }
944
- function collectAssetDeps(bundle) {
945
- const chunkToDeps = /* @__PURE__ */ new Map();
946
- for (const chunk of Object.values(bundle)) if (chunk.type === "chunk") chunkToDeps.set(chunk, collectAssetDepsInner(chunk.fileName, bundle));
947
- const idToDeps = {};
948
- for (const [chunk, deps] of chunkToDeps.entries()) for (const id of chunk.moduleIds) idToDeps[id] = {
949
- chunk,
950
- deps
951
- };
952
- return idToDeps;
953
- }
954
- function collectAssetDepsInner(fileName, bundle) {
955
- const visited = /* @__PURE__ */ new Set();
956
- const css = [];
957
- function recurse(k) {
958
- if (visited.has(k)) return;
959
- visited.add(k);
960
- const v = bundle[k];
961
- assert$1(v, `Not found '${k}' in the bundle`);
962
- if (v.type === "chunk") {
963
- css.push(...v.viteMetadata?.importedCss ?? []);
964
- for (const k2 of v.imports) if (k2 in bundle) recurse(k2);
965
- }
966
- }
967
- recurse(fileName);
968
- return {
969
- js: [...visited],
970
- css: [...new Set(css)]
971
- };
972
- }
973
- function patchViteClientPlugin() {
974
- const viteClientPath = normalizePath(fileURLToPath(import.meta.resolve("vite/dist/client/client.mjs")));
975
- function endIndexOf(code, searchValue) {
976
- const i = code.lastIndexOf(searchValue);
977
- return i === -1 ? i : i + searchValue.length;
978
- }
979
- return {
980
- name: "fullstack:patch-vite-client",
981
- transform: {
982
- filter: { id: exactRegex(viteClientPath) },
983
- handler(code, id) {
984
- if (id === viteClientPath) {
985
- if (code.includes("linkSheetsMap")) return;
986
- const s = new MagicString(code);
987
- s.prependLeft(code.indexOf("const sheetsMap"), `\
988
- const linkSheetsMap = new Map();
989
- document
990
- .querySelectorAll('link[rel="stylesheet"][data-vite-dev-id]')
991
- .forEach((el) => {
992
- linkSheetsMap.set(el.getAttribute('data-vite-dev-id'), el)
993
- });
994
- `);
995
- s.appendLeft(endIndexOf(code, `function updateStyle(id, content) {`), `if (linkSheetsMap.has(id)) { return }`);
996
- s.appendLeft(endIndexOf(code, `function removeStyle(id) {`), `
997
- const link = linkSheetsMap.get(id);
998
- if (link) {
999
- document
1000
- .querySelectorAll(
1001
- 'link[rel="stylesheet"][data-vite-dev-id]',
1002
- )
1003
- .forEach((el) => {
1004
- if (el.getAttribute('data-vite-dev-id') === id) {
1005
- el.remove()
1006
- }
1007
- })
1008
- linkSheetsMap.delete(id)
1009
- }
1010
- `);
1011
- return s.toString();
1012
- }
1013
- }
1014
- }
1015
- };
1016
- }
1017
- function patchVueScopeCssHmr() {
1018
- return {
1019
- name: "fullstack:patch-vue-scoped-css-hmr",
1020
- configureServer(server) {
1021
- server.middlewares.use((req, _res, next) => {
1022
- if (req.headers.accept?.includes("text/css") && req.url?.includes("&lang.css=")) req.url = req.url.replace("&lang.css=", "?lang.css");
1023
- next();
1024
- });
1025
- }
1026
- };
1027
- }
1028
- function patchCssLinkSelfAccept() {
1029
- return {
1030
- name: "fullstack:patch-css-link-self-accept",
1031
- apply: "serve",
1032
- transform: {
1033
- order: "post",
1034
- handler(_code, id, _options) {
1035
- if (this.environment.name === "client" && this.environment.mode === "dev" && isCSSRequest(id) && directRequestRE.test(id)) {
1036
- const mod = this.environment.moduleGraph.getModuleById(id);
1037
- if (mod && !mod.isSelfAccepting) mod.isSelfAccepting = true;
1038
- }
1039
- }
1040
- }
1041
- };
1042
- }
1043
- var BuildAssetsURLWithRuntime = class {
1044
- constructor(runtime) {
1045
- this.runtime = runtime;
1046
- }
1047
- };
1048
- function serializeValueWithRuntime(value) {
1049
- const replacements = [];
1050
- let result = JSON.stringify(value, (_key, value$1) => {
1051
- if (value$1 instanceof BuildAssetsURLWithRuntime) {
1052
- const placeholder = `__runtime_placeholder_${replacements.length}__`;
1053
- replacements.push([placeholder, value$1.runtime]);
1054
- return placeholder;
1055
- }
1056
- return value$1;
1057
- }, 2);
1058
- for (const [placeholder, runtime] of replacements) result = result.replace(`"${placeholder}"`, runtime);
1059
- return result;
1060
- }
1061
- function assetsURL(url, config) {
1062
- if (config.command === "build" && typeof config.experimental?.renderBuiltUrl === "function") {
1063
- const result = config.experimental.renderBuiltUrl(url, {
1064
- type: "asset",
1065
- hostType: "js",
1066
- ssr: true,
1067
- hostId: ""
1068
- });
1069
- if (typeof result === "object") {
1070
- if (result.runtime) return new BuildAssetsURLWithRuntime(result.runtime);
1071
- assert$1(!result.relative, "\"result.relative\" not supported on renderBuiltUrl() for fullstack plugin");
1072
- } else if (result) return result;
1073
- }
1074
- return config.base + url;
1075
- }
1076
- function assetsURLDev(url, config) {
1077
- return config.base + url;
1078
- }
1079
-
1080
457
  //#endregion
1081
458
  //#region src/build/vite/plugin.ts
1082
459
  const DEFAULT_EXTENSIONS = [
@@ -1236,8 +613,8 @@ function nitroPrepare(ctx) {
1236
613
  order: "pre",
1237
614
  async handler() {
1238
615
  debug("[prepare] Preparing output directory");
1239
- const nitro$1 = ctx.nitro;
1240
- await prepare(nitro$1);
616
+ const nitro = ctx.nitro;
617
+ await prepare(nitro);
1241
618
  }
1242
619
  }
1243
620
  };