nitro-nightly 3.0.1-20260120-140218-d2383f00 → 3.0.1-20260121-180512-722efdcf

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.
@@ -17370,566 +17370,659 @@ async function runParallel(inputs, cb, opts) {
17370
17370
  }
17371
17371
 
17372
17372
  //#endregion
17373
- //#region node_modules/.pnpm/estree-walker@2.0.2/node_modules/estree-walker/dist/esm/estree-walker.js
17374
- /** @typedef { import('estree').BaseNode} BaseNode */
17375
- /** @typedef {{
17376
- skip: () => void;
17377
- remove: () => void;
17378
- replace: (node: BaseNode) => void;
17379
- }} WalkerContext */
17380
- var WalkerBase = class {
17381
- constructor() {
17382
- /** @type {boolean} */
17383
- this.should_skip = false;
17384
- /** @type {boolean} */
17385
- this.should_remove = false;
17386
- /** @type {BaseNode | null} */
17387
- this.replacement = null;
17388
- /** @type {WalkerContext} */
17389
- this.context = {
17390
- skip: () => this.should_skip = true,
17391
- remove: () => this.should_remove = true,
17392
- replace: (node) => this.replacement = node
17393
- };
17394
- }
17395
- /**
17396
- *
17397
- * @param {any} parent
17398
- * @param {string} prop
17399
- * @param {number} index
17400
- * @param {BaseNode} node
17401
- */
17402
- replace(parent, prop, index, node) {
17403
- if (parent) if (index !== null) parent[prop][index] = node;
17404
- else parent[prop] = node;
17405
- }
17406
- /**
17407
- *
17408
- * @param {any} parent
17409
- * @param {string} prop
17410
- * @param {number} index
17411
- */
17412
- remove(parent, prop, index) {
17413
- if (parent) if (index !== null) parent[prop].splice(index, 1);
17414
- else delete parent[prop];
17415
- }
17416
- };
17417
- /** @typedef { import('estree').BaseNode} BaseNode */
17418
- /** @typedef { import('./walker.js').WalkerContext} WalkerContext */
17419
- /** @typedef {(
17420
- * this: WalkerContext,
17421
- * node: BaseNode,
17422
- * parent: BaseNode,
17423
- * key: string,
17424
- * index: number
17425
- * ) => void} SyncHandler */
17426
- var SyncWalker = class extends WalkerBase {
17427
- /**
17428
- *
17429
- * @param {SyncHandler} enter
17430
- * @param {SyncHandler} leave
17431
- */
17432
- constructor(enter, leave) {
17433
- super();
17434
- /** @type {SyncHandler} */
17435
- this.enter = enter;
17436
- /** @type {SyncHandler} */
17437
- this.leave = leave;
17438
- }
17439
- /**
17440
- *
17441
- * @param {BaseNode} node
17442
- * @param {BaseNode} parent
17443
- * @param {string} [prop]
17444
- * @param {number} [index]
17445
- * @returns {BaseNode}
17446
- */
17447
- visit(node, parent, prop, index) {
17448
- if (node) {
17449
- if (this.enter) {
17450
- const _should_skip = this.should_skip;
17451
- const _should_remove = this.should_remove;
17452
- const _replacement = this.replacement;
17453
- this.should_skip = false;
17454
- this.should_remove = false;
17455
- this.replacement = null;
17456
- this.enter.call(this.context, node, parent, prop, index);
17457
- if (this.replacement) {
17458
- node = this.replacement;
17459
- this.replace(parent, prop, index, node);
17460
- }
17461
- if (this.should_remove) this.remove(parent, prop, index);
17462
- const skipped = this.should_skip;
17463
- const removed = this.should_remove;
17464
- this.should_skip = _should_skip;
17465
- this.should_remove = _should_remove;
17466
- this.replacement = _replacement;
17467
- if (skipped) return node;
17468
- if (removed) return null;
17469
- }
17470
- for (const key in node) {
17471
- const value = node[key];
17472
- if (typeof value !== "object") continue;
17473
- else if (Array.isArray(value)) {
17474
- for (let i$2 = 0; i$2 < value.length; i$2 += 1) if (value[i$2] !== null && typeof value[i$2].type === "string") {
17475
- if (!this.visit(value[i$2], node, key, i$2)) i$2--;
17476
- }
17477
- } else if (value !== null && typeof value.type === "string") this.visit(value, node, key, null);
17478
- }
17479
- if (this.leave) {
17480
- const _replacement = this.replacement;
17481
- const _should_remove = this.should_remove;
17482
- this.replacement = null;
17483
- this.should_remove = false;
17484
- this.leave.call(this.context, node, parent, prop, index);
17485
- if (this.replacement) {
17486
- node = this.replacement;
17487
- this.replace(parent, prop, index, node);
17488
- }
17489
- if (this.should_remove) this.remove(parent, prop, index);
17490
- const removed = this.should_remove;
17491
- this.replacement = _replacement;
17492
- this.should_remove = _should_remove;
17493
- if (removed) return null;
17494
- }
17495
- }
17496
- return node;
17497
- }
17498
- };
17499
- /** @typedef { import('estree').BaseNode} BaseNode */
17500
- /** @typedef { import('./sync.js').SyncHandler} SyncHandler */
17501
- /** @typedef { import('./async.js').AsyncHandler} AsyncHandler */
17502
- /**
17503
- *
17504
- * @param {BaseNode} ast
17505
- * @param {{
17506
- * enter?: SyncHandler
17507
- * leave?: SyncHandler
17508
- * }} walker
17509
- * @returns {BaseNode}
17510
- */
17511
- function walk(ast, { enter, leave }) {
17512
- return new SyncWalker(enter, leave).visit(ast, null);
17373
+ //#region src/utils/regex.ts
17374
+ function escapeRegExp$1(string) {
17375
+ return string.replace(/[-\\^$*+?.()|[\]{}]/g, String.raw`\$&`);
17376
+ }
17377
+ function pathRegExp(string) {
17378
+ if (A) string = string.replace(/\\/g, "/");
17379
+ let escaped = escapeRegExp$1(string);
17380
+ if (A) escaped = escaped.replace(/\//g, String.raw`[/\\]`);
17381
+ return escaped;
17382
+ }
17383
+ function toPathRegExp(input) {
17384
+ if (input instanceof RegExp) return input;
17385
+ if (typeof input === "string") return new RegExp(pathRegExp(input));
17386
+ throw new TypeError("Expected a string or RegExp", { cause: input });
17513
17387
  }
17514
17388
 
17515
17389
  //#endregion
17516
- //#region node_modules/.pnpm/@rollup+pluginutils@5.3.0_rollup@4.55.2/node_modules/@rollup/pluginutils/dist/es/index.js
17517
- const extractors = {
17518
- ArrayPattern(names, param) {
17519
- for (const element of param.elements) if (element) extractors[element.type](names, element);
17520
- },
17521
- AssignmentPattern(names, param) {
17522
- extractors[param.left.type](names, param.left);
17523
- },
17524
- Identifier(names, param) {
17525
- names.push(param.name);
17526
- },
17527
- MemberExpression() {},
17528
- ObjectPattern(names, param) {
17529
- for (const prop of param.properties) if (prop.type === "RestElement") extractors.RestElement(names, prop);
17530
- else extractors[prop.value.type](names, prop.value);
17531
- },
17532
- RestElement(names, param) {
17533
- extractors[param.argument.type](names, param.argument);
17390
+ //#region src/build/config.ts
17391
+ function baseBuildConfig(nitro) {
17392
+ const extensions = [
17393
+ ".ts",
17394
+ ".mjs",
17395
+ ".js",
17396
+ ".json",
17397
+ ".node",
17398
+ ".tsx",
17399
+ ".jsx"
17400
+ ];
17401
+ const isNodeless = nitro.options.node === false;
17402
+ const importMetaInjections = {
17403
+ dev: nitro.options.dev,
17404
+ preset: nitro.options.preset,
17405
+ prerender: nitro.options.preset === "nitro-prerender",
17406
+ nitro: true,
17407
+ server: true,
17408
+ client: false,
17409
+ baseURL: nitro.options.baseURL,
17410
+ _asyncContext: nitro.options.experimental.asyncContext,
17411
+ _tasks: nitro.options.experimental.tasks
17412
+ };
17413
+ const replacements = {
17414
+ ...Object.fromEntries(Object.entries(importMetaInjections).map(([key, val]) => [`import.meta.${key}`, JSON.stringify(val)])),
17415
+ ...nitro.options.replace
17416
+ };
17417
+ const { env } = defineEnv({
17418
+ nodeCompat: isNodeless,
17419
+ resolve: true,
17420
+ presets: nitro.options.unenv,
17421
+ overrides: { alias: nitro.options.alias }
17422
+ });
17423
+ return {
17424
+ extensions,
17425
+ isNodeless,
17426
+ replacements,
17427
+ env,
17428
+ aliases: resolveAliases({ ...env.alias }),
17429
+ noExternal: getNoExternals(nitro),
17430
+ ignoreWarningCodes: new Set([
17431
+ "EVAL",
17432
+ "CIRCULAR_DEPENDENCY",
17433
+ "THIS_IS_UNDEFINED",
17434
+ "EMPTY_BUNDLE"
17435
+ ])
17436
+ };
17437
+ }
17438
+ function getNoExternals(nitro) {
17439
+ const noExternal = [
17440
+ /\.[mc]?tsx?$/,
17441
+ /^(?:[\0#~.]|virtual:)/,
17442
+ /* @__PURE__ */ new RegExp("^" + pathRegExp(pkgDir) + "(?!.*node_modules)"),
17443
+ ...[nitro.options.rootDir, ...nitro.options.scanDirs.filter((dir) => dir.includes("node_modules") || !dir.startsWith(nitro.options.rootDir))].map((dir) => /* @__PURE__ */ new RegExp("^" + pathRegExp(dir) + "(?!.*node_modules)"))
17444
+ ];
17445
+ if (nitro.options.wasm !== false) noExternal.push(/\.wasm$/);
17446
+ if (Array.isArray(nitro.options.noExternals)) noExternal.push(...nitro.options.noExternals.filter(Boolean).map((item) => toPathRegExp(item)));
17447
+ return noExternal.sort((a$1, b$2) => a$1.source.length - b$2.source.length);
17448
+ }
17449
+ function resolveAliases(_aliases) {
17450
+ const aliases = Object.fromEntries(Object.entries(_aliases).sort(([a$1], [b$2]) => b$2.split("/").length - a$1.split("/").length || b$2.length - a$1.length));
17451
+ for (const key in aliases) for (const alias in aliases) {
17452
+ if (![
17453
+ "~",
17454
+ "@",
17455
+ "#"
17456
+ ].includes(alias[0])) continue;
17457
+ if (alias === "@" && !aliases[key].startsWith("@/")) continue;
17458
+ if (aliases[key].startsWith(alias)) aliases[key] = aliases[alias] + aliases[key].slice(alias.length);
17534
17459
  }
17535
- };
17536
- const extractAssignedNames = function extractAssignedNames(param) {
17537
- const names = [];
17538
- extractors[param.type](names, param);
17539
- return names;
17540
- };
17541
- const blockDeclarations = {
17542
- const: true,
17543
- let: true
17544
- };
17545
- var Scope = class {
17546
- constructor(options = {}) {
17547
- this.parent = options.parent;
17548
- this.isBlockScope = !!options.block;
17549
- this.declarations = Object.create(null);
17550
- if (options.params) options.params.forEach((param) => {
17551
- extractAssignedNames(param).forEach((name) => {
17552
- this.declarations[name] = true;
17553
- });
17554
- });
17460
+ return aliases;
17461
+ }
17462
+
17463
+ //#endregion
17464
+ //#region src/build/chunks.ts
17465
+ const virtualRe = /^(?:\0|#|virtual:)/;
17466
+ const NODE_MODULES_RE$1 = /node_modules[/\\][^.]/;
17467
+ function libChunkName(id) {
17468
+ return `_libs/${id.match(/.*(?:[/\\])node_modules(?:[/\\])(?<package>@[^/\\]+[/\\][^/\\]+|[^/\\.][^/\\]*)/)?.groups?.package || "common"}`;
17469
+ }
17470
+ function getChunkName(chunk, nitro) {
17471
+ if (chunk.name === "rolldown-runtime") return "_runtime.mjs";
17472
+ if (chunk.moduleIds.every((id) => id.includes("node_modules"))) {
17473
+ const pkgNames = [...new Set(chunk.moduleIds.map((id) => id.match(/.*[/\\]node_modules[/\\](?<package>@[^/\\]+[/\\][^/\\]+|[^/\\]+)/)?.groups?.package).filter(Boolean).map((name) => name.split(/[/\\]/).pop()).filter(Boolean))].sort((a$1, b$2) => a$1.length - b$2.length);
17474
+ let chunkName = "";
17475
+ for (const name of pkgNames) {
17476
+ const separator = chunkName ? "+" : "";
17477
+ if ((chunkName + separator + name).length > 30) return `_libs/_[hash].mjs`;
17478
+ chunkName += separator + name;
17479
+ }
17480
+ return `_libs/${chunkName || "_"}.mjs`;
17555
17481
  }
17556
- addDeclaration(node, isBlockDeclaration, isVar) {
17557
- if (!isBlockDeclaration && this.isBlockScope) this.parent.addDeclaration(node, isBlockDeclaration, isVar);
17558
- else if (node.id) extractAssignedNames(node.id).forEach((name) => {
17559
- this.declarations[name] = true;
17560
- });
17482
+ if (chunk.moduleIds.length === 0) return `_chunks/${chunk.name}.mjs`;
17483
+ const ids = chunk.moduleIds.filter((id) => !virtualRe.test(id));
17484
+ if (ids.length === 0) {
17485
+ if (chunk.moduleIds.every((id) => id.includes("virtual:raw"))) return `_raw/[name].mjs`;
17486
+ return `_virtual/[name].mjs`;
17561
17487
  }
17562
- contains(name) {
17563
- return this.declarations[name] || (this.parent ? this.parent.contains(name) : false);
17488
+ if (ids.every((id) => id.endsWith(".wasm"))) return `_wasm/[name].mjs`;
17489
+ if (ids.every((id) => id.includes("vite/services"))) return `_ssr/[name].mjs`;
17490
+ if (ids.every((id) => id.startsWith(nitro.options.buildDir))) return `_build/[name].mjs`;
17491
+ if (ids.every((id) => id.startsWith(runtimeDir) || id.startsWith(presetsDir))) return `_nitro/[name].mjs`;
17492
+ const mainId = ids.at(-1);
17493
+ if (mainId) {
17494
+ const routeHandler = nitro.routing.routes.routes.flatMap((h$4) => h$4.data).find((h$4) => h$4.handler === mainId);
17495
+ if (routeHandler?.route) return `_routes/${routeToFsPath(routeHandler.route)}.mjs`;
17496
+ if (Object.entries(nitro.options.tasks).find(([_$2, task]) => task.handler === mainId)) return `_tasks/[name].mjs`;
17564
17497
  }
17498
+ return `_chunks/[name].mjs`;
17499
+ }
17500
+ function routeToFsPath(route) {
17501
+ return route.split("/").slice(1).map((s) => `${s.replace(/[:*]+/g, "$").replace(/[^$a-zA-Z0-9_.[\]/]/g, "_")}`).join("/") || "index";
17502
+ }
17503
+
17504
+ //#endregion
17505
+ //#region src/build/virtual/database.ts
17506
+ function database(nitro) {
17507
+ return {
17508
+ id: "#nitro/virtual/database",
17509
+ template: () => {
17510
+ if (!nitro.options.experimental.database) return `export const connectionConfigs = {};`;
17511
+ const dbConfigs = nitro.options.dev && nitro.options.devDatabase || nitro.options.database;
17512
+ const connectorsNames = [...new Set(Object.values(dbConfigs || {}).map((config) => config?.connector))].filter(Boolean);
17513
+ for (const name of connectorsNames) if (!connectors[name]) throw new Error(`Database connector "${name}" is invalid.`);
17514
+ return `
17515
+ ${connectorsNames.map((name) => `import ${camelCase(name)}Connector from "${connectors[name]}";`).join("\n")}
17516
+
17517
+ export const connectionConfigs = {
17518
+ ${Object.entries(dbConfigs || {}).filter(([, config]) => !!config?.connector).map(([name, { connector, options }]) => `${name}: {
17519
+ connector: ${camelCase(connector)}Connector,
17520
+ options: ${JSON.stringify(options)}
17521
+ }`).join(",\n")}
17565
17522
  };
17566
- const attachScopes = function attachScopes(ast, propertyName = "scope") {
17567
- let scope = new Scope();
17568
- walk(ast, {
17569
- enter(n$2, parent) {
17570
- const node = n$2;
17571
- if (/(?:Function|Class)Declaration/.test(node.type)) scope.addDeclaration(node, false, false);
17572
- if (node.type === "VariableDeclaration") {
17573
- const { kind } = node;
17574
- const isBlockDeclaration = blockDeclarations[kind];
17575
- node.declarations.forEach((declaration) => {
17576
- scope.addDeclaration(declaration, isBlockDeclaration, true);
17577
- });
17578
- }
17579
- let newScope;
17580
- if (node.type.includes("Function")) {
17581
- const func = node;
17582
- newScope = new Scope({
17583
- parent: scope,
17584
- block: false,
17585
- params: func.params
17586
- });
17587
- if (func.type === "FunctionExpression" && func.id) newScope.addDeclaration(func, false, false);
17588
- }
17589
- if (/For(?:In|Of)?Statement/.test(node.type)) newScope = new Scope({
17590
- parent: scope,
17591
- block: true
17592
- });
17593
- if (node.type === "BlockStatement" && !parent.type.includes("Function")) newScope = new Scope({
17594
- parent: scope,
17595
- block: true
17596
- });
17597
- if (node.type === "CatchClause") newScope = new Scope({
17598
- parent: scope,
17599
- params: node.param ? [node.param] : [],
17600
- block: true
17601
- });
17602
- if (newScope) {
17603
- Object.defineProperty(node, propertyName, {
17604
- value: newScope,
17605
- configurable: true
17606
- });
17607
- scope = newScope;
17608
- }
17609
- },
17610
- leave(n$2) {
17611
- if (n$2[propertyName]) scope = scope.parent;
17523
+ `;
17612
17524
  }
17613
- });
17614
- return scope;
17615
- };
17616
- function isArray(arg) {
17617
- return Array.isArray(arg);
17525
+ };
17618
17526
  }
17619
- function ensureArray(thing) {
17620
- if (isArray(thing)) return thing;
17621
- if (thing == null) return [];
17622
- return [thing];
17527
+
17528
+ //#endregion
17529
+ //#region src/build/virtual/error-handler.ts
17530
+ function errorHandler(nitro) {
17531
+ return {
17532
+ id: "#nitro/virtual/error-handler",
17533
+ template: () => {
17534
+ const errorHandlers = Array.isArray(nitro.options.errorHandler) ? nitro.options.errorHandler : [nitro.options.errorHandler];
17535
+ const builtinHandler = join$2(runtimeDir, `internal/error/${nitro.options.dev ? "dev" : "prod"}`);
17536
+ return `
17537
+ ${errorHandlers.map((h$4, i$2) => `import errorHandler$${i$2} from "${h$4}";`).join("\n")}
17538
+
17539
+ const errorHandlers = [${errorHandlers.map((_$2, i$2) => `errorHandler$${i$2}`).join(", ")}];
17540
+
17541
+ import { defaultHandler } from "${builtinHandler}";
17542
+
17543
+ export default async function(error, event) {
17544
+ for (const handler of errorHandlers) {
17545
+ try {
17546
+ const response = await handler(error, event, { defaultHandler });
17547
+ if (response) {
17548
+ return response;
17549
+ }
17550
+ } catch(error) {
17551
+ // Handler itself thrown, log and continue
17552
+ console.error(error);
17553
+ }
17554
+ }
17555
+ // H3 will handle fallback
17623
17556
  }
17624
- const normalizePathRegExp = new RegExp(`\\${win32.sep}`, "g");
17625
- const normalizePath = function normalizePath(filename) {
17626
- return filename.replace(normalizePathRegExp, posix.sep);
17627
- };
17628
- function getMatcherString(id, resolutionBase) {
17629
- if (resolutionBase === false || isAbsolute(id) || id.startsWith("**")) return normalizePath(id);
17630
- const basePath = normalizePath(resolve(resolutionBase || "")).replace(/[-^$*+?.()|[\]{}]/g, "\\$&");
17631
- return posix.join(basePath, normalizePath(id));
17557
+ `;
17558
+ }
17559
+ };
17632
17560
  }
17633
- const createFilter = function createFilter(include, exclude, options) {
17634
- const resolutionBase = options && options.resolve;
17635
- const getMatcher = (id) => id instanceof RegExp ? id : { test: (what) => {
17636
- return (0, import_picomatch.default)(getMatcherString(id, resolutionBase), { dot: true })(what);
17637
- } };
17638
- const includeMatchers = ensureArray(include).map(getMatcher);
17639
- const excludeMatchers = ensureArray(exclude).map(getMatcher);
17640
- if (!includeMatchers.length && !excludeMatchers.length) return (id) => typeof id === "string" && !id.includes("\0");
17641
- return function result(id) {
17642
- if (typeof id !== "string") return false;
17643
- if (id.includes("\0")) return false;
17644
- const pathId = normalizePath(id);
17645
- for (let i$2 = 0; i$2 < excludeMatchers.length; ++i$2) {
17646
- const matcher = excludeMatchers[i$2];
17647
- if (matcher instanceof RegExp) matcher.lastIndex = 0;
17648
- if (matcher.test(pathId)) return false;
17561
+
17562
+ //#endregion
17563
+ //#region src/build/virtual/feature-flags.ts
17564
+ function featureFlags(nitro) {
17565
+ return {
17566
+ id: "#nitro/virtual/feature-flags",
17567
+ template: () => {
17568
+ const featureFlags = {
17569
+ hasRoutes: nitro.routing.routes.hasRoutes(),
17570
+ hasRouteRules: nitro.routing.routeRules.hasRoutes(),
17571
+ hasRoutedMiddleware: nitro.routing.routedMiddleware.hasRoutes(),
17572
+ hasGlobalMiddleware: nitro.routing.globalMiddleware.length > 0,
17573
+ hasPlugins: nitro.options.plugins.length > 0,
17574
+ hasHooks: nitro.options.features?.runtimeHooks ?? nitro.options.plugins.length > 0,
17575
+ hasWebSocket: nitro.options.features?.websocket ?? nitro.options.experimental.websocket ?? false
17576
+ };
17577
+ return Object.entries(featureFlags).map(([key, value]) => `export const ${key} = ${Boolean(value)};`).join("\n");
17649
17578
  }
17650
- for (let i$2 = 0; i$2 < includeMatchers.length; ++i$2) {
17651
- const matcher = includeMatchers[i$2];
17652
- if (matcher instanceof RegExp) matcher.lastIndex = 0;
17653
- if (matcher.test(pathId)) return true;
17579
+ };
17580
+ }
17581
+
17582
+ //#endregion
17583
+ //#region src/build/virtual/plugins.ts
17584
+ function plugins(nitro) {
17585
+ return {
17586
+ id: "#nitro/virtual/plugins",
17587
+ template: () => {
17588
+ const nitroPlugins = [...new Set(nitro.options.plugins)];
17589
+ return `
17590
+ ${nitroPlugins.map((plugin) => `import _${hash(plugin).replace(/-/g, "")} from "${plugin}";`).join("\n")}
17591
+
17592
+ export const plugins = [
17593
+ ${nitroPlugins.map((plugin) => `_${hash(plugin).replace(/-/g, "")}`).join(",\n")}
17594
+ ]
17595
+ `;
17654
17596
  }
17655
- return !includeMatchers.length;
17656
17597
  };
17657
- };
17658
- const forbiddenIdentifiers = new Set(`break case class catch const continue debugger default delete do else export extends finally for function if import in instanceof let new return super switch this throw try typeof var void while with yield enum await implements package protected static interface private public arguments Infinity NaN undefined null true false eval uneval isFinite isNaN parseFloat parseInt decodeURI decodeURIComponent encodeURI encodeURIComponent escape unescape Object Function Boolean Symbol Error EvalError InternalError RangeError ReferenceError SyntaxError TypeError URIError Number Math Date String RegExp Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array Map Set WeakMap WeakSet SIMD ArrayBuffer DataView JSON Promise Generator GeneratorFunction Reflect Proxy Intl`.split(" "));
17659
- forbiddenIdentifiers.add("");
17660
- const makeLegalIdentifier = function makeLegalIdentifier(str) {
17661
- let identifier = str.replace(/-(\w)/g, (_$2, letter) => letter.toUpperCase()).replace(/[^$_a-zA-Z0-9]/g, "_");
17662
- if (/\d/.test(identifier[0]) || forbiddenIdentifiers.has(identifier)) identifier = `_${identifier}`;
17663
- return identifier || "_";
17664
- };
17665
- function stringify(obj) {
17666
- return (JSON.stringify(obj) || "undefined").replace(/[\u2028\u2029]/g, (char) => `\\u${`000${char.charCodeAt(0).toString(16)}`.slice(-4)}`);
17667
17598
  }
17668
- function serializeArray(arr, indent, baseIndent) {
17669
- let output = "[";
17670
- const separator = indent ? `\n${baseIndent}${indent}` : "";
17671
- for (let i$2 = 0; i$2 < arr.length; i$2++) {
17672
- const key = arr[i$2];
17673
- output += `${i$2 > 0 ? "," : ""}${separator}${serialize(key, indent, baseIndent + indent)}`;
17674
- }
17675
- return `${output}${indent ? `\n${baseIndent}` : ""}]`;
17599
+
17600
+ //#endregion
17601
+ //#region src/build/virtual/polyfills.ts
17602
+ function polyfills(_nitro, polyfills) {
17603
+ return {
17604
+ id: "#nitro/virtual/polyfills",
17605
+ moduleSideEffects: true,
17606
+ template: () => {
17607
+ return polyfills.map((p$1) => `import '${p$1}';`).join("\n") || `/* No polyfills */`;
17608
+ }
17609
+ };
17676
17610
  }
17677
- function serializeObject(obj, indent, baseIndent) {
17678
- let output = "{";
17679
- const separator = indent ? `\n${baseIndent}${indent}` : "";
17680
- const entries = Object.entries(obj);
17681
- for (let i$2 = 0; i$2 < entries.length; i$2++) {
17682
- const [key, value] = entries[i$2];
17683
- const stringKey = makeLegalIdentifier(key) === key ? key : stringify(key);
17684
- output += `${i$2 > 0 ? "," : ""}${separator}${stringKey}:${indent ? " " : ""}${serialize(value, indent, baseIndent + indent)}`;
17611
+
17612
+ //#endregion
17613
+ //#region node_modules/.pnpm/etag@1.8.1/node_modules/etag/index.js
17614
+ /*!
17615
+ * etag
17616
+ * Copyright(c) 2014-2016 Douglas Christopher Wilson
17617
+ * MIT Licensed
17618
+ */
17619
+ var require_etag = /* @__PURE__ */ __commonJSMin(((exports, module) => {
17620
+ /**
17621
+ * Module exports.
17622
+ * @public
17623
+ */
17624
+ module.exports = etag;
17625
+ /**
17626
+ * Module dependencies.
17627
+ * @private
17628
+ */
17629
+ var crypto = __require$1("crypto");
17630
+ var Stats$1 = __require$1("fs").Stats;
17631
+ /**
17632
+ * Module variables.
17633
+ * @private
17634
+ */
17635
+ var toString = Object.prototype.toString;
17636
+ /**
17637
+ * Generate an entity tag.
17638
+ *
17639
+ * @param {Buffer|string} entity
17640
+ * @return {string}
17641
+ * @private
17642
+ */
17643
+ function entitytag(entity) {
17644
+ if (entity.length === 0) return "\"0-2jmj7l5rSw0yVb/vlWAYkK/YBwk\"";
17645
+ var hash$1 = crypto.createHash("sha1").update(entity, "utf8").digest("base64").substring(0, 27);
17646
+ return "\"" + (typeof entity === "string" ? Buffer.byteLength(entity, "utf8") : entity.length).toString(16) + "-" + hash$1 + "\"";
17685
17647
  }
17686
- return `${output}${indent ? `\n${baseIndent}` : ""}}`;
17687
- }
17688
- function serialize(obj, indent, baseIndent) {
17689
- if (typeof obj === "object" && obj !== null) {
17690
- if (Array.isArray(obj)) return serializeArray(obj, indent, baseIndent);
17691
- if (obj instanceof Date) return `new Date(${obj.getTime()})`;
17692
- if (obj instanceof RegExp) return obj.toString();
17693
- return serializeObject(obj, indent, baseIndent);
17648
+ /**
17649
+ * Create a simple ETag.
17650
+ *
17651
+ * @param {string|Buffer|Stats} entity
17652
+ * @param {object} [options]
17653
+ * @param {boolean} [options.weak]
17654
+ * @return {String}
17655
+ * @public
17656
+ */
17657
+ function etag(entity, options) {
17658
+ if (entity == null) throw new TypeError("argument entity is required");
17659
+ var isStats = isstats(entity);
17660
+ var weak = options && typeof options.weak === "boolean" ? options.weak : isStats;
17661
+ if (!isStats && typeof entity !== "string" && !Buffer.isBuffer(entity)) throw new TypeError("argument entity must be string, Buffer, or fs.Stats");
17662
+ var tag = isStats ? stattag(entity) : entitytag(entity);
17663
+ return weak ? "W/" + tag : tag;
17694
17664
  }
17695
- if (typeof obj === "number") {
17696
- if (obj === Infinity) return "Infinity";
17697
- if (obj === -Infinity) return "-Infinity";
17698
- if (obj === 0) return 1 / obj === Infinity ? "0" : "-0";
17699
- if (obj !== obj) return "NaN";
17665
+ /**
17666
+ * Determine if object is a Stats object.
17667
+ *
17668
+ * @param {object} obj
17669
+ * @return {boolean}
17670
+ * @api private
17671
+ */
17672
+ function isstats(obj) {
17673
+ if (typeof Stats$1 === "function" && obj instanceof Stats$1) return true;
17674
+ return obj && typeof obj === "object" && "ctime" in obj && toString.call(obj.ctime) === "[object Date]" && "mtime" in obj && toString.call(obj.mtime) === "[object Date]" && "ino" in obj && typeof obj.ino === "number" && "size" in obj && typeof obj.size === "number";
17700
17675
  }
17701
- if (typeof obj === "symbol") {
17702
- const key = Symbol.keyFor(obj);
17703
- if (key !== void 0) return `Symbol.for(${stringify(key)})`;
17676
+ /**
17677
+ * Generate a tag for a stat.
17678
+ *
17679
+ * @param {object} stat
17680
+ * @return {string}
17681
+ * @private
17682
+ */
17683
+ function stattag(stat$2) {
17684
+ var mtime = stat$2.mtime.getTime().toString(16);
17685
+ return "\"" + stat$2.size.toString(16) + "-" + mtime + "\"";
17704
17686
  }
17705
- if (typeof obj === "bigint") return `${obj}n`;
17706
- return stringify(obj);
17687
+ }));
17688
+
17689
+ //#endregion
17690
+ //#region src/build/virtual/public-assets.ts
17691
+ var import_etag = /* @__PURE__ */ __toESM$1(require_etag(), 1);
17692
+ const readAssetHandler = {
17693
+ true: "node",
17694
+ node: "node",
17695
+ false: "null",
17696
+ deno: "deno",
17697
+ inline: "inline"
17698
+ };
17699
+ function publicAssets(nitro) {
17700
+ return [
17701
+ {
17702
+ id: "#nitro/virtual/public-assets-data",
17703
+ template: async () => {
17704
+ const assets = {};
17705
+ const files = await glob("**", {
17706
+ cwd: nitro.options.output.publicDir,
17707
+ absolute: false,
17708
+ dot: true
17709
+ });
17710
+ const { errors } = await runParallel(new Set(files), async (id) => {
17711
+ let mimeType = src_default.getType(id.replace(/\.(gz|br)$/, "")) || "text/plain";
17712
+ if (mimeType.startsWith("text")) mimeType += "; charset=utf-8";
17713
+ const fullPath = resolve$3(nitro.options.output.publicDir, id);
17714
+ const [assetData, stat$2] = await Promise.all([promises.readFile(fullPath), promises.stat(fullPath)]);
17715
+ const etag = (0, import_etag.default)(assetData);
17716
+ const assetId = joinURL(nitro.options.baseURL, decodeURIComponent(id));
17717
+ let encoding;
17718
+ if (id.endsWith(".gz")) encoding = "gzip";
17719
+ else if (id.endsWith(".br")) encoding = "br";
17720
+ assets[assetId] = {
17721
+ type: nitro._prerenderMeta?.[assetId]?.contentType || mimeType,
17722
+ encoding,
17723
+ etag,
17724
+ mtime: stat$2.mtime.toJSON(),
17725
+ size: stat$2.size,
17726
+ path: relative$2(nitro.options.output.serverDir, fullPath),
17727
+ data: nitro.options.serveStatic === "inline" ? assetData.toString("base64") : void 0
17728
+ };
17729
+ }, { concurrency: 25 });
17730
+ if (errors.length > 0) throw new Error(`Failed to process public assets:\n${errors.join("\n")}`, { cause: errors });
17731
+ return `export default ${JSON.stringify(assets, null, 2)};`;
17732
+ }
17733
+ },
17734
+ {
17735
+ id: "#nitro/virtual/public-assets",
17736
+ template: () => {
17737
+ const publicAssetBases = Object.fromEntries(nitro.options.publicAssets.filter((dir) => !dir.fallthrough && dir.baseURL !== "/").map((dir) => [withTrailingSlash(joinURL(nitro.options.baseURL, dir.baseURL || "/")), { maxAge: dir.maxAge }]));
17738
+ return `
17739
+ import assets from '#nitro/virtual/public-assets-data'
17740
+ export { readAsset } from "${`#nitro/virtual/public-assets-${readAssetHandler[nitro.options.serveStatic] || "null"}`}"
17741
+ export const publicAssetBases = ${JSON.stringify(publicAssetBases)}
17742
+
17743
+ export function isPublicAssetURL(id = '') {
17744
+ if (assets[id]) {
17745
+ return true
17746
+ }
17747
+ for (const base in publicAssetBases) {
17748
+ if (id.startsWith(base)) { return true }
17749
+ }
17750
+ return false
17707
17751
  }
17708
- const hasStringIsWellFormed = "isWellFormed" in String.prototype;
17709
- function isWellFormedString(input) {
17710
- if (hasStringIsWellFormed) return input.isWellFormed();
17711
- return !/\p{Surrogate}/u.test(input);
17752
+
17753
+ export function getPublicAssetMeta(id = '') {
17754
+ for (const base in publicAssetBases) {
17755
+ if (id.startsWith(base)) { return publicAssetBases[base] }
17756
+ }
17757
+ return {}
17712
17758
  }
17713
- const dataToEsm = function dataToEsm(data$1, options = {}) {
17714
- var _a, _b;
17715
- const t$1 = options.compact ? "" : "indent" in options ? options.indent : " ";
17716
- const _$2 = options.compact ? "" : " ";
17717
- const n$2 = options.compact ? "" : "\n";
17718
- const declarationType = options.preferConst ? "const" : "var";
17719
- if (options.namedExports === false || typeof data$1 !== "object" || Array.isArray(data$1) || data$1 instanceof Date || data$1 instanceof RegExp || data$1 === null) {
17720
- const code = serialize(data$1, options.compact ? null : t$1, "");
17721
- return `export default${_$2 || (/^[{[\-\/]/.test(code) ? "" : " ")}${code};`;
17722
- }
17723
- let maxUnderbarPrefixLength = 0;
17724
- for (const key of Object.keys(data$1)) {
17725
- const underbarPrefixLength = (_b = (_a = /^(_+)/.exec(key)) === null || _a === void 0 ? void 0 : _a[0].length) !== null && _b !== void 0 ? _b : 0;
17726
- if (underbarPrefixLength > maxUnderbarPrefixLength) maxUnderbarPrefixLength = underbarPrefixLength;
17727
- }
17728
- const arbitraryNamePrefix = `${"_".repeat(maxUnderbarPrefixLength + 1)}arbitrary`;
17729
- let namedExportCode = "";
17730
- const defaultExportRows = [];
17731
- const arbitraryNameExportRows = [];
17732
- for (const [key, value] of Object.entries(data$1)) if (key === makeLegalIdentifier(key)) {
17733
- if (options.objectShorthand) defaultExportRows.push(key);
17734
- else defaultExportRows.push(`${key}:${_$2}${key}`);
17735
- namedExportCode += `export ${declarationType} ${key}${_$2}=${_$2}${serialize(value, options.compact ? null : t$1, "")};${n$2}`;
17736
- } else {
17737
- defaultExportRows.push(`${stringify(key)}:${_$2}${serialize(value, options.compact ? null : t$1, "")}`);
17738
- if (options.includeArbitraryNames && isWellFormedString(key)) {
17739
- const variableName = `${arbitraryNamePrefix}${arbitraryNameExportRows.length}`;
17740
- namedExportCode += `${declarationType} ${variableName}${_$2}=${_$2}${serialize(value, options.compact ? null : t$1, "")};${n$2}`;
17741
- arbitraryNameExportRows.push(`${variableName} as ${JSON.stringify(key)}`);
17759
+
17760
+ export function getAsset (id) {
17761
+ return assets[id]
17762
+ }
17763
+ `;
17764
+ }
17765
+ },
17766
+ {
17767
+ id: "#nitro/virtual/public-assets-node",
17768
+ template: () => {
17769
+ return `
17770
+ import { promises as fsp } from 'node:fs'
17771
+ import { fileURLToPath } from 'node:url'
17772
+ import { resolve, dirname } from 'node:path'
17773
+ import assets from '#nitro/virtual/public-assets-data'
17774
+ export function readAsset (id) {
17775
+ const serverDir = dirname(fileURLToPath(globalThis.__nitro_main__))
17776
+ return fsp.readFile(resolve(serverDir, assets[id].path))
17777
+ }`;
17778
+ }
17779
+ },
17780
+ {
17781
+ id: "#nitro/virtual/public-assets-deno",
17782
+ template: () => {
17783
+ return `
17784
+ import assets from '#nitro/virtual/public-assets-data'
17785
+ export function readAsset (id) {
17786
+ // https://deno.com/deploy/docs/serve-static-assets
17787
+ const path = '.' + decodeURIComponent(new URL(\`../public\${id}\`, 'file://').pathname)
17788
+ return Deno.readFile(path);
17789
+ }`;
17790
+ }
17791
+ },
17792
+ {
17793
+ id: "#nitro/virtual/public-assets-null",
17794
+ template: () => {
17795
+ return `
17796
+ export function readAsset (id) {
17797
+ return Promise.resolve(null);
17798
+ }`;
17799
+ }
17800
+ },
17801
+ {
17802
+ id: "#nitro/virtual/public-assets-inline",
17803
+ template: () => {
17804
+ return `
17805
+ import assets from '#nitro/virtual/public-assets-data'
17806
+ export function readAsset (id) {
17807
+ if (!assets[id]) { return undefined }
17808
+ if (assets[id]._data) { return assets[id]._data }
17809
+ if (!assets[id].data) { return assets[id].data }
17810
+ assets[id]._data = Uint8Array.from(atob(assets[id].data), (c) => c.charCodeAt(0))
17811
+ return assets[id]._data
17812
+ }`;
17813
+ }
17742
17814
  }
17743
- }
17744
- const arbitraryExportCode = arbitraryNameExportRows.length > 0 ? `export${_$2}{${n$2}${t$1}${arbitraryNameExportRows.join(`,${n$2}${t$1}`)}${n$2}};${n$2}` : "";
17745
- const defaultExportCode = `export default${_$2}{${n$2}${t$1}${defaultExportRows.join(`,${n$2}${t$1}`)}${n$2}};${n$2}`;
17746
- return `${namedExportCode}${arbitraryExportCode}${defaultExportCode}`;
17747
- };
17815
+ ];
17816
+ }
17748
17817
 
17749
17818
  //#endregion
17750
- //#region src/utils/regex.ts
17751
- function escapeRegExp$1(string) {
17752
- return string.replace(/[-\\^$*+?.()|[\]{}]/g, String.raw`\$&`);
17753
- }
17754
- function pathRegExp(string) {
17755
- if (A) string = string.replace(/\\/g, "/");
17756
- let escaped = escapeRegExp$1(string);
17757
- if (A) escaped = escaped.replace(/\//g, String.raw`[/\\]`);
17758
- return escaped;
17759
- }
17760
- function toPathRegExp(input) {
17761
- if (input instanceof RegExp) return input;
17762
- if (typeof input === "string") return new RegExp(pathRegExp(input));
17763
- throw new TypeError("Expected a string or RegExp", { cause: input });
17819
+ //#region src/build/virtual/renderer-template.ts
17820
+ function rendererTemplate(nitro) {
17821
+ return {
17822
+ id: "#nitro/virtual/renderer-template",
17823
+ template: async () => {
17824
+ const template = nitro.options.renderer?.template;
17825
+ if (typeof template !== "string") return `
17826
+ export const rendererTemplate = () => '<!-- renderer.template is not set -->';
17827
+ export const rendererTemplateFile = undefined;
17828
+ export const isStaticTemplate = true;`;
17829
+ if (nitro.options.dev) return `
17830
+ import { readFile } from 'node:fs/promises';
17831
+ export const rendererTemplate = () => readFile(${JSON.stringify(template)}, "utf8");
17832
+ export const rendererTemplateFile = ${JSON.stringify(template)};
17833
+ export const isStaticTemplate = ${JSON.stringify(nitro.options.renderer?.static)};
17834
+ `;
17835
+ else {
17836
+ const html = await readFile(template, "utf8");
17837
+ if (nitro.options.renderer?.static ?? !hasTemplateSyntax(html)) return `
17838
+ import { HTTPResponse } from "h3";
17839
+ export const rendererTemplate = () => new HTTPResponse(${JSON.stringify(html)}, { headers: { "content-type": "text/html; charset=utf-8" } });
17840
+ `;
17841
+ else return `
17842
+ import { renderToResponse } from 'rendu'
17843
+ import { serverFetch } from 'nitro/app'
17844
+ const template = ${compileTemplateToString(html, { contextKeys: [...RENDER_CONTEXT_KEYS] })};
17845
+ export const rendererTemplate = (request) => renderToResponse(template, { request, context: { serverFetch } })
17846
+ `;
17847
+ }
17848
+ }
17849
+ };
17764
17850
  }
17765
17851
 
17766
17852
  //#endregion
17767
- //#region src/build/config.ts
17768
- function baseBuildConfig(nitro) {
17769
- const extensions = [
17770
- ".ts",
17771
- ".mjs",
17772
- ".js",
17773
- ".json",
17774
- ".node",
17775
- ".tsx",
17776
- ".jsx"
17777
- ];
17778
- const isNodeless = nitro.options.node === false;
17779
- const importMetaInjections = {
17780
- dev: nitro.options.dev,
17781
- preset: nitro.options.preset,
17782
- prerender: nitro.options.preset === "nitro-prerender",
17783
- nitro: true,
17784
- server: true,
17785
- client: false,
17786
- baseURL: nitro.options.baseURL,
17787
- _asyncContext: nitro.options.experimental.asyncContext,
17788
- _tasks: nitro.options.experimental.tasks
17789
- };
17790
- const replacements = {
17791
- ...Object.fromEntries(Object.entries(importMetaInjections).map(([key, val]) => [`import.meta.${key}`, JSON.stringify(val)])),
17792
- ...nitro.options.replace
17793
- };
17794
- const { env } = defineEnv({
17795
- nodeCompat: isNodeless,
17796
- resolve: true,
17797
- presets: nitro.options.unenv,
17798
- overrides: { alias: nitro.options.alias }
17799
- });
17853
+ //#region src/build/virtual/routing-meta.ts
17854
+ function routingMeta(nitro) {
17800
17855
  return {
17801
- extensions,
17802
- isNodeless,
17803
- replacements,
17804
- env,
17805
- aliases: resolveAliases({ ...env.alias }),
17806
- noExternal: getNoExternals(nitro),
17807
- ignoreWarningCodes: new Set([
17808
- "EVAL",
17809
- "CIRCULAR_DEPENDENCY",
17810
- "THIS_IS_UNDEFINED",
17811
- "EMPTY_BUNDLE"
17812
- ])
17856
+ id: "#nitro/virtual/routing-meta",
17857
+ template: () => {
17858
+ const routeHandlers = uniqueBy$1(Object.values(nitro.routing.routes.routes).flatMap((h$4) => h$4.data), "_importHash");
17859
+ return `
17860
+ ${routeHandlers.map((h$4) => `import ${h$4._importHash}Meta from "${h$4.handler}?meta";`).join("\n")}
17861
+ export const handlersMeta = [
17862
+ ${routeHandlers.map((h$4) => `{ route: ${JSON.stringify(h$4.route)}, method: ${JSON.stringify(h$4.method?.toLowerCase())}, meta: ${h$4._importHash}Meta }`).join(",\n")}
17863
+ ];
17864
+ `.trim();
17865
+ }
17813
17866
  };
17814
17867
  }
17815
- function getNoExternals(nitro) {
17816
- const noExternal = [
17817
- /\.[mc]?tsx?$/,
17818
- /^(?:[\0#~.]|virtual:)/,
17819
- /* @__PURE__ */ new RegExp("^" + pathRegExp(pkgDir) + "(?!.*node_modules)"),
17820
- ...[nitro.options.rootDir, ...nitro.options.scanDirs.filter((dir) => dir.includes("node_modules") || !dir.startsWith(nitro.options.rootDir))].map((dir) => /* @__PURE__ */ new RegExp("^" + pathRegExp(dir) + "(?!.*node_modules)"))
17821
- ];
17822
- if (nitro.options.wasm !== false) noExternal.push(/\.wasm$/);
17823
- if (Array.isArray(nitro.options.noExternals)) noExternal.push(...nitro.options.noExternals.filter(Boolean).map((item) => toPathRegExp(item)));
17824
- return noExternal.sort((a$1, b$2) => a$1.source.length - b$2.source.length);
17825
- }
17826
- function resolveAliases(_aliases) {
17827
- const aliases = Object.fromEntries(Object.entries(_aliases).sort(([a$1], [b$2]) => b$2.split("/").length - a$1.split("/").length || b$2.length - a$1.length));
17828
- for (const key in aliases) for (const alias in aliases) {
17829
- if (![
17830
- "~",
17831
- "@",
17832
- "#"
17833
- ].includes(alias[0])) continue;
17834
- if (alias === "@" && !aliases[key].startsWith("@/")) continue;
17835
- if (aliases[key].startsWith(alias)) aliases[key] = aliases[alias] + aliases[key].slice(alias.length);
17836
- }
17837
- return aliases;
17868
+ function uniqueBy$1(arr, key) {
17869
+ return [...new Map(arr.map((item) => [item[key], item])).values()];
17838
17870
  }
17839
17871
 
17840
17872
  //#endregion
17841
- //#region src/build/chunks.ts
17842
- const virtualRe = /^(?:\0|#|virtual:)/;
17843
- const NODE_MODULES_RE$1 = /node_modules[/\\][^.]/;
17844
- function libChunkName(id) {
17845
- return `_libs/${id.match(/.*(?:[/\\])node_modules(?:[/\\])(?<package>@[^/\\]+[/\\][^/\\]+|[^/\\.][^/\\]*)/)?.groups?.package || "common"}`;
17873
+ //#region src/build/virtual/routing.ts
17874
+ const RuntimeRouteRules = [
17875
+ "headers",
17876
+ "redirect",
17877
+ "proxy",
17878
+ "cache"
17879
+ ];
17880
+ function routing(nitro) {
17881
+ return {
17882
+ id: "#nitro/virtual/routing",
17883
+ template: () => {
17884
+ const allHandlers = uniqueBy([
17885
+ ...Object.values(nitro.routing.routes.routes).flatMap((h$4) => h$4.data),
17886
+ ...Object.values(nitro.routing.routedMiddleware.routes).map((h$4) => h$4.data),
17887
+ ...nitro.routing.globalMiddleware
17888
+ ], "_importHash");
17889
+ return `
17890
+ import * as __routeRules__ from "#nitro/runtime/route-rules";
17891
+ import * as srvxNode from "srvx/node"
17892
+ import * as h3 from "h3";
17893
+
17894
+ export const findRouteRules = ${nitro.routing.routeRules.compileToString({
17895
+ serialize: serializeRouteRule,
17896
+ matchAll: true
17897
+ })}
17898
+
17899
+ const multiHandler = (...handlers) => {
17900
+ const final = handlers.pop()
17901
+ const middleware = handlers.filter(Boolean).map(h => h3.toMiddleware(h));
17902
+ return (ev) => h3.callMiddleware(ev, middleware, final);
17846
17903
  }
17847
- function getChunkName(chunk, nitro) {
17848
- if (chunk.name === "rolldown-runtime") return "_runtime.mjs";
17849
- if (chunk.moduleIds.every((id) => id.includes("node_modules"))) {
17850
- const pkgNames = [...new Set(chunk.moduleIds.map((id) => id.match(/.*[/\\]node_modules[/\\](?<package>@[^/\\]+[/\\][^/\\]+|[^/\\]+)/)?.groups?.package).filter(Boolean).map((name) => name.split(/[/\\]/).pop()).filter(Boolean))].sort((a$1, b$2) => a$1.length - b$2.length);
17851
- let chunkName = "";
17852
- for (const name of pkgNames) {
17853
- const separator = chunkName ? "+" : "";
17854
- if ((chunkName + separator + name).length > 30) return `_libs/_[hash].mjs`;
17855
- chunkName += separator + name;
17904
+
17905
+ ${allHandlers.filter((h$4) => !h$4.lazy).map((h$4) => `import ${h$4._importHash} from "${h$4.handler}";`).join("\n")}
17906
+
17907
+ ${allHandlers.filter((h$4) => h$4.lazy).map((h$4) => `const ${h$4._importHash} = h3.defineLazyEventHandler(() => import("${h$4.handler}")${h$4.format === "node" ? ".then(m => srvxNode.toFetchHandler(m.default))" : ""});`).join("\n")}
17908
+
17909
+ export const findRoute = ${nitro.routing.routes.compileToString({ serialize: serializeHandler })}
17910
+
17911
+ export const findRoutedMiddleware = ${nitro.routing.routedMiddleware.compileToString({
17912
+ serialize: serializeHandler,
17913
+ matchAll: true
17914
+ })};
17915
+
17916
+ export const globalMiddleware = [
17917
+ ${nitro.routing.globalMiddleware.map((h$4) => h$4.lazy ? h$4._importHash : `h3.toEventHandler(${h$4._importHash})`).join(",")}
17918
+ ].filter(Boolean);
17919
+ `;
17856
17920
  }
17857
- return `_libs/${chunkName || "_"}.mjs`;
17858
- }
17859
- if (chunk.moduleIds.length === 0) return `_chunks/${chunk.name}.mjs`;
17860
- const ids = chunk.moduleIds.filter((id) => !virtualRe.test(id));
17861
- if (ids.length === 0) {
17862
- if (chunk.moduleIds.every((id) => id.includes("virtual:raw"))) return `_raw/[name].mjs`;
17863
- return `_virtual/[name].mjs`;
17864
- }
17865
- if (ids.every((id) => id.endsWith(".wasm"))) return `_wasm/[name].mjs`;
17866
- if (ids.every((id) => id.includes("vite/services"))) return `_ssr/[name].mjs`;
17867
- if (ids.every((id) => id.startsWith(nitro.options.buildDir))) return `_build/[name].mjs`;
17868
- if (ids.every((id) => id.startsWith(runtimeDir) || id.startsWith(presetsDir))) return `_nitro/[name].mjs`;
17869
- const mainId = ids.at(-1);
17870
- if (mainId) {
17871
- const routeHandler = nitro.routing.routes.routes.flatMap((h$4) => h$4.data).find((h$4) => h$4.handler === mainId);
17872
- if (routeHandler?.route) return `_routes/${routeToFsPath(routeHandler.route)}.mjs`;
17873
- if (Object.entries(nitro.options.tasks).find(([_$2, task]) => task.handler === mainId)) return `_tasks/[name].mjs`;
17921
+ };
17922
+ }
17923
+ function uniqueBy(arr, key) {
17924
+ return [...new Map(arr.map((item) => [item[key], item])).values()];
17925
+ }
17926
+ function serializeHandler(h$4) {
17927
+ const meta = Array.isArray(h$4) ? h$4[0] : h$4;
17928
+ return `{${[
17929
+ `route:${JSON.stringify(meta.route)}`,
17930
+ meta.method && `method:${JSON.stringify(meta.method)}`,
17931
+ meta.meta && `meta:${JSON.stringify(meta.meta)}`,
17932
+ `handler:${Array.isArray(h$4) ? `multiHandler(${h$4.map((handler) => serializeHandlerFn(handler)).join(",")})` : serializeHandlerFn(h$4)}`
17933
+ ].filter(Boolean).join(",")}}`;
17934
+ }
17935
+ function serializeHandlerFn(h$4) {
17936
+ let code = h$4._importHash;
17937
+ if (!h$4.lazy) {
17938
+ if (h$4.format === "node") code = `srvxNode.toFetchHandler(${code})`;
17939
+ code = `h3.toEventHandler(${code})`;
17874
17940
  }
17875
- return `_chunks/[name].mjs`;
17941
+ return code;
17876
17942
  }
17877
- function routeToFsPath(route) {
17878
- return route.split("/").slice(1).map((s) => `${s.replace(/[:*]+/g, "$").replace(/[^$a-zA-Z0-9_.[\]/]/g, "_")}`).join("/") || "index";
17943
+ function serializeRouteRule(h$4) {
17944
+ return `[${Object.entries(h$4).filter(([name, options]) => options !== void 0 && name[0] !== "_").map(([name, options]) => {
17945
+ return `{${[
17946
+ `name:${JSON.stringify(name)}`,
17947
+ `route:${JSON.stringify(h$4._route)}`,
17948
+ h$4._method && `method:${JSON.stringify(h$4._method)}`,
17949
+ RuntimeRouteRules.includes(name) && `handler:__routeRules__.${name}`,
17950
+ `options:${JSON.stringify(options)}`
17951
+ ].filter(Boolean).join(",")}}`;
17952
+ }).join(",")}]`;
17879
17953
  }
17880
17954
 
17881
17955
  //#endregion
17882
- //#region src/build/virtual/database.ts
17883
- function database(nitro) {
17956
+ //#region src/build/virtual/runtime-config.ts
17957
+ function runtimeConfig(nitro) {
17884
17958
  return {
17885
- id: "#nitro/virtual/database",
17959
+ id: "#nitro/virtual/runtime-config",
17886
17960
  template: () => {
17887
- if (!nitro.options.experimental.database) return `export const connectionConfigs = {};`;
17888
- const dbConfigs = nitro.options.dev && nitro.options.devDatabase || nitro.options.database;
17889
- const connectorsNames = [...new Set(Object.values(dbConfigs || {}).map((config) => config?.connector))].filter(Boolean);
17890
- for (const name of connectorsNames) if (!connectors[name]) throw new Error(`Database connector "${name}" is invalid.`);
17891
- return `
17892
- ${connectorsNames.map((name) => `import ${camelCase(name)}Connector from "${connectors[name]}";`).join("\n")}
17893
-
17894
- export const connectionConfigs = {
17895
- ${Object.entries(dbConfigs || {}).filter(([, config]) => !!config?.connector).map(([name, { connector, options }]) => `${name}: {
17896
- connector: ${camelCase(connector)}Connector,
17897
- options: ${JSON.stringify(options)}
17898
- }`).join(",\n")}
17899
- };
17900
- `;
17961
+ return `export const runtimeConfig = ${JSON.stringify(nitro.options.runtimeConfig || {})};`;
17901
17962
  }
17902
17963
  };
17903
17964
  }
17904
17965
 
17905
17966
  //#endregion
17906
- //#region src/build/virtual/error-handler.ts
17907
- function errorHandler(nitro) {
17967
+ //#region src/build/virtual/server-assets.ts
17968
+ function serverAssets(nitro) {
17908
17969
  return {
17909
- id: "#nitro/virtual/error-handler",
17910
- template: () => {
17911
- const errorHandlers = Array.isArray(nitro.options.errorHandler) ? nitro.options.errorHandler : [nitro.options.errorHandler];
17912
- const builtinHandler = join$2(runtimeDir, `internal/error/${nitro.options.dev ? "dev" : "prod"}`);
17970
+ id: "#nitro/virtual/server-assets",
17971
+ template: async () => {
17972
+ if (nitro.options.dev || nitro.options.preset === "nitro-prerender") return `
17973
+ import { createStorage } from 'unstorage'
17974
+ import fsDriver from 'unstorage/drivers/fs'
17975
+ const serverAssets = ${JSON.stringify(nitro.options.serverAssets)}
17976
+ export const assets = createStorage()
17977
+ for (const asset of serverAssets) {
17978
+ assets.mount(asset.baseName, fsDriver({ base: asset.dir, ignore: (asset?.ignore || []) }))
17979
+ }`;
17980
+ const assets = {};
17981
+ for (const asset of nitro.options.serverAssets) {
17982
+ const files = await glob(asset.pattern || "**/*", {
17983
+ cwd: asset.dir,
17984
+ absolute: false,
17985
+ ignore: asset.ignore
17986
+ });
17987
+ for (const _id of files) {
17988
+ const fsPath = resolve$3(asset.dir, _id);
17989
+ const id = asset.baseName + "/" + _id;
17990
+ assets[id] = {
17991
+ fsPath,
17992
+ meta: {}
17993
+ };
17994
+ let type$1 = src_default.getType(id) || "text/plain";
17995
+ if (type$1.startsWith("text")) type$1 += "; charset=utf-8";
17996
+ const etag = (0, import_etag.default)(await promises.readFile(fsPath));
17997
+ const mtime = await promises.stat(fsPath).then((s) => s.mtime.toJSON());
17998
+ assets[id].meta = {
17999
+ type: type$1,
18000
+ etag,
18001
+ mtime
18002
+ };
18003
+ }
18004
+ }
17913
18005
  return `
17914
- ${errorHandlers.map((h$4, i$2) => `import errorHandler$${i$2} from "${h$4}";`).join("\n")}
17915
-
17916
- const errorHandlers = [${errorHandlers.map((_$2, i$2) => `errorHandler$${i$2}`).join(", ")}];
18006
+ const _assets = {\n${Object.entries(assets).map(([id, asset]) => ` [${JSON.stringify(normalizeKey(id))}]: {\n import: () => import(${JSON.stringify("raw:" + asset.fsPath)}).then(r => r.default || r),\n meta: ${JSON.stringify(asset.meta)}\n }`).join(",\n")}\n}
17917
18007
 
17918
- import { defaultHandler } from "${builtinHandler}";
18008
+ const normalizeKey = ${normalizeKey.toString()}
17919
18009
 
17920
- export default async function(error, event) {
17921
- for (const handler of errorHandlers) {
17922
- try {
17923
- const response = await handler(error, event, { defaultHandler });
17924
- if (response) {
17925
- return response;
17926
- }
17927
- } catch(error) {
17928
- // Handler itself thrown, log and continue
17929
- console.error(error);
17930
- }
18010
+ export const assets = {
18011
+ getKeys() {
18012
+ return Promise.resolve(Object.keys(_assets))
18013
+ },
18014
+ hasItem (id) {
18015
+ id = normalizeKey(id)
18016
+ return Promise.resolve(id in _assets)
18017
+ },
18018
+ getItem (id) {
18019
+ id = normalizeKey(id)
18020
+ return Promise.resolve(_assets[id] ? _assets[id].import() : null)
18021
+ },
18022
+ getMeta (id) {
18023
+ id = normalizeKey(id)
18024
+ return Promise.resolve(_assets[id] ? _assets[id].meta : {})
17931
18025
  }
17932
- // H3 will handle fallback
17933
18026
  }
17934
18027
  `;
17935
18028
  }
@@ -17937,569 +18030,476 @@ export default async function(error, event) {
17937
18030
  }
17938
18031
 
17939
18032
  //#endregion
17940
- //#region src/build/virtual/feature-flags.ts
17941
- function featureFlags(nitro) {
18033
+ //#region src/build/virtual/storage.ts
18034
+ function storage(nitro) {
17942
18035
  return {
17943
- id: "#nitro/virtual/feature-flags",
18036
+ id: "#nitro/virtual/storage",
17944
18037
  template: () => {
17945
- const featureFlags = {
17946
- hasRoutes: nitro.routing.routes.hasRoutes(),
17947
- hasRouteRules: nitro.routing.routeRules.hasRoutes(),
17948
- hasRoutedMiddleware: nitro.routing.routedMiddleware.hasRoutes(),
17949
- hasGlobalMiddleware: nitro.routing.globalMiddleware.length > 0,
17950
- hasPlugins: nitro.options.plugins.length > 0,
17951
- hasHooks: nitro.options.features?.runtimeHooks ?? nitro.options.plugins.length > 0,
17952
- hasWebSocket: nitro.options.features?.websocket ?? nitro.options.experimental.websocket ?? false
17953
- };
17954
- return Object.entries(featureFlags).map(([key, value]) => `export const ${key} = ${Boolean(value)};`).join("\n");
18038
+ const mounts = [];
18039
+ const storageMounts = nitro.options.dev || nitro.options.preset === "nitro-prerender" ? {
18040
+ ...nitro.options.storage,
18041
+ ...nitro.options.devStorage
18042
+ } : nitro.options.storage;
18043
+ for (const path$2 in storageMounts) {
18044
+ const { driver: driverName, ...driverOpts } = storageMounts[path$2];
18045
+ mounts.push({
18046
+ path: path$2,
18047
+ driver: builtinDrivers[driverName] || driverName,
18048
+ opts: driverOpts
18049
+ });
18050
+ }
18051
+ return `
18052
+ import { createStorage } from 'unstorage'
18053
+ import { assets } from '#nitro/virtual/server-assets'
18054
+
18055
+ ${[...new Set(mounts.map((m$3) => m$3.driver))].map((i$2) => genImport(i$2, genSafeVariableName(i$2))).join("\n")}
18056
+
18057
+ export function initStorage() {
18058
+ const storage = createStorage({})
18059
+ storage.mount('/assets', assets)
18060
+ ${mounts.map((m$3) => `storage.mount('${m$3.path}', ${genSafeVariableName(m$3.driver)}(${JSON.stringify(m$3.opts)}))`).join("\n")}
18061
+ return storage
18062
+ }
18063
+ `;
17955
18064
  }
17956
18065
  };
17957
18066
  }
17958
18067
 
17959
18068
  //#endregion
17960
- //#region src/build/virtual/plugins.ts
17961
- function plugins(nitro) {
18069
+ //#region src/build/virtual/tasks.ts
18070
+ function tasks(nitro) {
17962
18071
  return {
17963
- id: "#nitro/virtual/plugins",
18072
+ id: "#nitro/virtual/tasks",
17964
18073
  template: () => {
17965
- const nitroPlugins = [...new Set(nitro.options.plugins)];
18074
+ const _scheduledTasks = Object.entries(nitro.options.scheduledTasks || {}).map(([cron, _tasks]) => {
18075
+ return {
18076
+ cron,
18077
+ tasks: (Array.isArray(_tasks) ? _tasks : [_tasks]).filter((name) => {
18078
+ if (!nitro.options.tasks[name]) {
18079
+ nitro.logger.warn(`Scheduled task \`${name}\` is not defined!`);
18080
+ return false;
18081
+ }
18082
+ return true;
18083
+ })
18084
+ };
18085
+ }).filter((e) => e.tasks.length > 0);
18086
+ const scheduledTasks = _scheduledTasks.length > 0 ? _scheduledTasks : false;
17966
18087
  return `
17967
- ${nitroPlugins.map((plugin) => `import _${hash(plugin).replace(/-/g, "")} from "${plugin}";`).join("\n")}
18088
+ export const scheduledTasks = ${JSON.stringify(scheduledTasks)};
17968
18089
 
17969
- export const plugins = [
17970
- ${nitroPlugins.map((plugin) => `_${hash(plugin).replace(/-/g, "")}`).join(",\n")}
17971
- ]
17972
- `;
18090
+ export const tasks = {
18091
+ ${Object.entries(nitro.options.tasks).map(([name, task]) => `"${name}": {
18092
+ meta: {
18093
+ description: ${JSON.stringify(task.description)},
18094
+ },
18095
+ resolve: ${task.handler ? `() => import("${normalize$2(task.handler)}").then(r => r.default || r)` : "undefined"},
18096
+ }`).join(",\n")}
18097
+ };`;
17973
18098
  }
17974
18099
  };
17975
18100
  }
17976
18101
 
17977
18102
  //#endregion
17978
- //#region src/build/virtual/polyfills.ts
17979
- function polyfills(_nitro, polyfills) {
17980
- return {
17981
- id: "#nitro/virtual/polyfills",
17982
- moduleSideEffects: true,
17983
- template: () => {
17984
- return polyfills.map((p$1) => `import '${p$1}';`).join("\n") || `/* No polyfills */`;
17985
- }
17986
- };
18103
+ //#region src/build/virtual/_all.ts
18104
+ function virtualTemplates(nitro, _polyfills) {
18105
+ const nitroTemplates = [
18106
+ database,
18107
+ errorHandler,
18108
+ featureFlags,
18109
+ plugins,
18110
+ polyfills,
18111
+ publicAssets,
18112
+ rendererTemplate,
18113
+ routingMeta,
18114
+ routing,
18115
+ runtimeConfig,
18116
+ serverAssets,
18117
+ storage,
18118
+ tasks
18119
+ ].flatMap((t$1) => t$1(nitro, _polyfills));
18120
+ const customTemplates = Object.entries(nitro.options.virtual).map(([id, template]) => ({
18121
+ id,
18122
+ template
18123
+ }));
18124
+ return [...nitroTemplates, ...customTemplates];
17987
18125
  }
17988
18126
 
17989
18127
  //#endregion
17990
- //#region node_modules/.pnpm/etag@1.8.1/node_modules/etag/index.js
17991
- /*!
17992
- * etag
17993
- * Copyright(c) 2014-2016 Douglas Christopher Wilson
17994
- * MIT Licensed
17995
- */
17996
- var require_etag = /* @__PURE__ */ __commonJSMin(((exports, module) => {
17997
- /**
17998
- * Module exports.
17999
- * @public
18000
- */
18001
- module.exports = etag;
18002
- /**
18003
- * Module dependencies.
18004
- * @private
18005
- */
18006
- var crypto = __require$1("crypto");
18007
- var Stats$1 = __require$1("fs").Stats;
18008
- /**
18009
- * Module variables.
18010
- * @private
18011
- */
18012
- var toString = Object.prototype.toString;
18128
+ //#region node_modules/.pnpm/estree-walker@2.0.2/node_modules/estree-walker/dist/esm/estree-walker.js
18129
+ /** @typedef { import('estree').BaseNode} BaseNode */
18130
+ /** @typedef {{
18131
+ skip: () => void;
18132
+ remove: () => void;
18133
+ replace: (node: BaseNode) => void;
18134
+ }} WalkerContext */
18135
+ var WalkerBase = class {
18136
+ constructor() {
18137
+ /** @type {boolean} */
18138
+ this.should_skip = false;
18139
+ /** @type {boolean} */
18140
+ this.should_remove = false;
18141
+ /** @type {BaseNode | null} */
18142
+ this.replacement = null;
18143
+ /** @type {WalkerContext} */
18144
+ this.context = {
18145
+ skip: () => this.should_skip = true,
18146
+ remove: () => this.should_remove = true,
18147
+ replace: (node) => this.replacement = node
18148
+ };
18149
+ }
18013
18150
  /**
18014
- * Generate an entity tag.
18015
18151
  *
18016
- * @param {Buffer|string} entity
18017
- * @return {string}
18018
- * @private
18019
- */
18020
- function entitytag(entity) {
18021
- if (entity.length === 0) return "\"0-2jmj7l5rSw0yVb/vlWAYkK/YBwk\"";
18022
- var hash$1 = crypto.createHash("sha1").update(entity, "utf8").digest("base64").substring(0, 27);
18023
- return "\"" + (typeof entity === "string" ? Buffer.byteLength(entity, "utf8") : entity.length).toString(16) + "-" + hash$1 + "\"";
18152
+ * @param {any} parent
18153
+ * @param {string} prop
18154
+ * @param {number} index
18155
+ * @param {BaseNode} node
18156
+ */
18157
+ replace(parent, prop, index, node) {
18158
+ if (parent) if (index !== null) parent[prop][index] = node;
18159
+ else parent[prop] = node;
18024
18160
  }
18025
18161
  /**
18026
- * Create a simple ETag.
18027
18162
  *
18028
- * @param {string|Buffer|Stats} entity
18029
- * @param {object} [options]
18030
- * @param {boolean} [options.weak]
18031
- * @return {String}
18032
- * @public
18163
+ * @param {any} parent
18164
+ * @param {string} prop
18165
+ * @param {number} index
18033
18166
  */
18034
- function etag(entity, options) {
18035
- if (entity == null) throw new TypeError("argument entity is required");
18036
- var isStats = isstats(entity);
18037
- var weak = options && typeof options.weak === "boolean" ? options.weak : isStats;
18038
- if (!isStats && typeof entity !== "string" && !Buffer.isBuffer(entity)) throw new TypeError("argument entity must be string, Buffer, or fs.Stats");
18039
- var tag = isStats ? stattag(entity) : entitytag(entity);
18040
- return weak ? "W/" + tag : tag;
18167
+ remove(parent, prop, index) {
18168
+ if (parent) if (index !== null) parent[prop].splice(index, 1);
18169
+ else delete parent[prop];
18041
18170
  }
18171
+ };
18172
+ /** @typedef { import('estree').BaseNode} BaseNode */
18173
+ /** @typedef { import('./walker.js').WalkerContext} WalkerContext */
18174
+ /** @typedef {(
18175
+ * this: WalkerContext,
18176
+ * node: BaseNode,
18177
+ * parent: BaseNode,
18178
+ * key: string,
18179
+ * index: number
18180
+ * ) => void} SyncHandler */
18181
+ var SyncWalker = class extends WalkerBase {
18042
18182
  /**
18043
- * Determine if object is a Stats object.
18044
18183
  *
18045
- * @param {object} obj
18046
- * @return {boolean}
18047
- * @api private
18184
+ * @param {SyncHandler} enter
18185
+ * @param {SyncHandler} leave
18048
18186
  */
18049
- function isstats(obj) {
18050
- if (typeof Stats$1 === "function" && obj instanceof Stats$1) return true;
18051
- return obj && typeof obj === "object" && "ctime" in obj && toString.call(obj.ctime) === "[object Date]" && "mtime" in obj && toString.call(obj.mtime) === "[object Date]" && "ino" in obj && typeof obj.ino === "number" && "size" in obj && typeof obj.size === "number";
18187
+ constructor(enter, leave) {
18188
+ super();
18189
+ /** @type {SyncHandler} */
18190
+ this.enter = enter;
18191
+ /** @type {SyncHandler} */
18192
+ this.leave = leave;
18052
18193
  }
18053
18194
  /**
18054
- * Generate a tag for a stat.
18055
18195
  *
18056
- * @param {object} stat
18057
- * @return {string}
18058
- * @private
18196
+ * @param {BaseNode} node
18197
+ * @param {BaseNode} parent
18198
+ * @param {string} [prop]
18199
+ * @param {number} [index]
18200
+ * @returns {BaseNode}
18059
18201
  */
18060
- function stattag(stat$2) {
18061
- var mtime = stat$2.mtime.getTime().toString(16);
18062
- return "\"" + stat$2.size.toString(16) + "-" + mtime + "\"";
18063
- }
18064
- }));
18065
-
18066
- //#endregion
18067
- //#region src/build/virtual/public-assets.ts
18068
- var import_etag = /* @__PURE__ */ __toESM$1(require_etag(), 1);
18069
- const readAssetHandler = {
18070
- true: "node",
18071
- node: "node",
18072
- false: "null",
18073
- deno: "deno",
18074
- inline: "inline"
18075
- };
18076
- function publicAssets(nitro) {
18077
- return [
18078
- {
18079
- id: "#nitro/virtual/public-assets-data",
18080
- template: async () => {
18081
- const assets = {};
18082
- const files = await glob("**", {
18083
- cwd: nitro.options.output.publicDir,
18084
- absolute: false,
18085
- dot: true
18086
- });
18087
- const { errors } = await runParallel(new Set(files), async (id) => {
18088
- let mimeType = src_default.getType(id.replace(/\.(gz|br)$/, "")) || "text/plain";
18089
- if (mimeType.startsWith("text")) mimeType += "; charset=utf-8";
18090
- const fullPath = resolve$3(nitro.options.output.publicDir, id);
18091
- const [assetData, stat$2] = await Promise.all([promises.readFile(fullPath), promises.stat(fullPath)]);
18092
- const etag = (0, import_etag.default)(assetData);
18093
- const assetId = joinURL(nitro.options.baseURL, decodeURIComponent(id));
18094
- let encoding;
18095
- if (id.endsWith(".gz")) encoding = "gzip";
18096
- else if (id.endsWith(".br")) encoding = "br";
18097
- assets[assetId] = {
18098
- type: nitro._prerenderMeta?.[assetId]?.contentType || mimeType,
18099
- encoding,
18100
- etag,
18101
- mtime: stat$2.mtime.toJSON(),
18102
- size: stat$2.size,
18103
- path: relative$2(nitro.options.output.serverDir, fullPath),
18104
- data: nitro.options.serveStatic === "inline" ? assetData.toString("base64") : void 0
18105
- };
18106
- }, { concurrency: 25 });
18107
- if (errors.length > 0) throw new Error(`Failed to process public assets:\n${errors.join("\n")}`, { cause: errors });
18108
- return `export default ${JSON.stringify(assets, null, 2)};`;
18109
- }
18110
- },
18111
- {
18112
- id: "#nitro/virtual/public-assets",
18113
- template: () => {
18114
- const publicAssetBases = Object.fromEntries(nitro.options.publicAssets.filter((dir) => !dir.fallthrough && dir.baseURL !== "/").map((dir) => [withTrailingSlash(joinURL(nitro.options.baseURL, dir.baseURL || "/")), { maxAge: dir.maxAge }]));
18115
- return `
18116
- import assets from '#nitro/virtual/public-assets-data'
18117
- export { readAsset } from "${`#nitro/virtual/public-assets-${readAssetHandler[nitro.options.serveStatic] || "null"}`}"
18118
- export const publicAssetBases = ${JSON.stringify(publicAssetBases)}
18119
-
18120
- export function isPublicAssetURL(id = '') {
18121
- if (assets[id]) {
18122
- return true
18123
- }
18124
- for (const base in publicAssetBases) {
18125
- if (id.startsWith(base)) { return true }
18126
- }
18127
- return false
18128
- }
18129
-
18130
- export function getPublicAssetMeta(id = '') {
18131
- for (const base in publicAssetBases) {
18132
- if (id.startsWith(base)) { return publicAssetBases[base] }
18133
- }
18134
- return {}
18135
- }
18136
-
18137
- export function getAsset (id) {
18138
- return assets[id]
18139
- }
18140
- `;
18141
- }
18142
- },
18143
- {
18144
- id: "#nitro/virtual/public-assets-node",
18145
- template: () => {
18146
- return `
18147
- import { promises as fsp } from 'node:fs'
18148
- import { fileURLToPath } from 'node:url'
18149
- import { resolve, dirname } from 'node:path'
18150
- import assets from '#nitro/virtual/public-assets-data'
18151
- export function readAsset (id) {
18152
- const serverDir = dirname(fileURLToPath(globalThis.__nitro_main__))
18153
- return fsp.readFile(resolve(serverDir, assets[id].path))
18154
- }`;
18155
- }
18156
- },
18157
- {
18158
- id: "#nitro/virtual/public-assets-deno",
18159
- template: () => {
18160
- return `
18161
- import assets from '#nitro/virtual/public-assets-data'
18162
- export function readAsset (id) {
18163
- // https://deno.com/deploy/docs/serve-static-assets
18164
- const path = '.' + decodeURIComponent(new URL(\`../public\${id}\`, 'file://').pathname)
18165
- return Deno.readFile(path);
18166
- }`;
18167
- }
18168
- },
18169
- {
18170
- id: "#nitro/virtual/public-assets-null",
18171
- template: () => {
18172
- return `
18173
- export function readAsset (id) {
18174
- return Promise.resolve(null);
18175
- }`;
18202
+ visit(node, parent, prop, index) {
18203
+ if (node) {
18204
+ if (this.enter) {
18205
+ const _should_skip = this.should_skip;
18206
+ const _should_remove = this.should_remove;
18207
+ const _replacement = this.replacement;
18208
+ this.should_skip = false;
18209
+ this.should_remove = false;
18210
+ this.replacement = null;
18211
+ this.enter.call(this.context, node, parent, prop, index);
18212
+ if (this.replacement) {
18213
+ node = this.replacement;
18214
+ this.replace(parent, prop, index, node);
18215
+ }
18216
+ if (this.should_remove) this.remove(parent, prop, index);
18217
+ const skipped = this.should_skip;
18218
+ const removed = this.should_remove;
18219
+ this.should_skip = _should_skip;
18220
+ this.should_remove = _should_remove;
18221
+ this.replacement = _replacement;
18222
+ if (skipped) return node;
18223
+ if (removed) return null;
18176
18224
  }
18177
- },
18178
- {
18179
- id: "#nitro/virtual/public-assets-inline",
18180
- template: () => {
18181
- return `
18182
- import assets from '#nitro/virtual/public-assets-data'
18183
- export function readAsset (id) {
18184
- if (!assets[id]) { return undefined }
18185
- if (assets[id]._data) { return assets[id]._data }
18186
- if (!assets[id].data) { return assets[id].data }
18187
- assets[id]._data = Uint8Array.from(atob(assets[id].data), (c) => c.charCodeAt(0))
18188
- return assets[id]._data
18189
- }`;
18225
+ for (const key in node) {
18226
+ const value = node[key];
18227
+ if (typeof value !== "object") continue;
18228
+ else if (Array.isArray(value)) {
18229
+ for (let i$2 = 0; i$2 < value.length; i$2 += 1) if (value[i$2] !== null && typeof value[i$2].type === "string") {
18230
+ if (!this.visit(value[i$2], node, key, i$2)) i$2--;
18231
+ }
18232
+ } else if (value !== null && typeof value.type === "string") this.visit(value, node, key, null);
18190
18233
  }
18191
- }
18192
- ];
18193
- }
18194
-
18195
- //#endregion
18196
- //#region src/build/virtual/renderer-template.ts
18197
- function rendererTemplate(nitro) {
18198
- return {
18199
- id: "#nitro/virtual/renderer-template",
18200
- template: async () => {
18201
- const template = nitro.options.renderer?.template;
18202
- if (typeof template !== "string") return `
18203
- export const rendererTemplate = () => '<!-- renderer.template is not set -->';
18204
- export const rendererTemplateFile = undefined;
18205
- export const isStaticTemplate = true;`;
18206
- if (nitro.options.dev) return `
18207
- import { readFile } from 'node:fs/promises';
18208
- export const rendererTemplate = () => readFile(${JSON.stringify(template)}, "utf8");
18209
- export const rendererTemplateFile = ${JSON.stringify(template)};
18210
- export const isStaticTemplate = ${JSON.stringify(nitro.options.renderer?.static)};
18211
- `;
18212
- else {
18213
- const html = await readFile(template, "utf8");
18214
- if (nitro.options.renderer?.static ?? !hasTemplateSyntax(html)) return `
18215
- import { HTTPResponse } from "h3";
18216
- export const rendererTemplate = () => new HTTPResponse(${JSON.stringify(html)}, { headers: { "content-type": "text/html; charset=utf-8" } });
18217
- `;
18218
- else return `
18219
- import { renderToResponse } from 'rendu'
18220
- import { serverFetch } from 'nitro/app'
18221
- const template = ${compileTemplateToString(html, { contextKeys: [...RENDER_CONTEXT_KEYS] })};
18222
- export const rendererTemplate = (request) => renderToResponse(template, { request, context: { serverFetch } })
18223
- `;
18234
+ if (this.leave) {
18235
+ const _replacement = this.replacement;
18236
+ const _should_remove = this.should_remove;
18237
+ this.replacement = null;
18238
+ this.should_remove = false;
18239
+ this.leave.call(this.context, node, parent, prop, index);
18240
+ if (this.replacement) {
18241
+ node = this.replacement;
18242
+ this.replace(parent, prop, index, node);
18243
+ }
18244
+ if (this.should_remove) this.remove(parent, prop, index);
18245
+ const removed = this.should_remove;
18246
+ this.replacement = _replacement;
18247
+ this.should_remove = _should_remove;
18248
+ if (removed) return null;
18224
18249
  }
18225
18250
  }
18226
- };
18227
- }
18228
-
18229
- //#endregion
18230
- //#region src/build/virtual/routing-meta.ts
18231
- function routingMeta(nitro) {
18232
- return {
18233
- id: "#nitro/virtual/routing-meta",
18234
- template: () => {
18235
- const routeHandlers = uniqueBy$1(Object.values(nitro.routing.routes.routes).flatMap((h$4) => h$4.data), "_importHash");
18236
- return `
18237
- ${routeHandlers.map((h$4) => `import ${h$4._importHash}Meta from "${h$4.handler}?meta";`).join("\n")}
18238
- export const handlersMeta = [
18239
- ${routeHandlers.map((h$4) => `{ route: ${JSON.stringify(h$4.route)}, method: ${JSON.stringify(h$4.method?.toLowerCase())}, meta: ${h$4._importHash}Meta }`).join(",\n")}
18240
- ];
18241
- `.trim();
18242
- }
18243
- };
18244
- }
18245
- function uniqueBy$1(arr, key) {
18246
- return [...new Map(arr.map((item) => [item[key], item])).values()];
18247
- }
18248
-
18249
- //#endregion
18250
- //#region src/build/virtual/routing.ts
18251
- const RuntimeRouteRules = [
18252
- "headers",
18253
- "redirect",
18254
- "proxy",
18255
- "cache"
18256
- ];
18257
- function routing(nitro) {
18258
- return {
18259
- id: "#nitro/virtual/routing",
18260
- template: () => {
18261
- const allHandlers = uniqueBy([
18262
- ...Object.values(nitro.routing.routes.routes).flatMap((h$4) => h$4.data),
18263
- ...Object.values(nitro.routing.routedMiddleware.routes).map((h$4) => h$4.data),
18264
- ...nitro.routing.globalMiddleware
18265
- ], "_importHash");
18266
- return `
18267
- import * as __routeRules__ from "#nitro/runtime/route-rules";
18268
- import * as srvxNode from "srvx/node"
18269
- import * as h3 from "h3";
18270
-
18271
- export const findRouteRules = ${nitro.routing.routeRules.compileToString({
18272
- serialize: serializeRouteRule,
18273
- matchAll: true
18274
- })}
18275
-
18276
- const multiHandler = (...handlers) => {
18277
- const final = handlers.pop()
18278
- const middleware = handlers.filter(Boolean).map(h => h3.toMiddleware(h));
18279
- return (ev) => h3.callMiddleware(ev, middleware, final);
18280
- }
18281
-
18282
- ${allHandlers.filter((h$4) => !h$4.lazy).map((h$4) => `import ${h$4._importHash} from "${h$4.handler}";`).join("\n")}
18283
-
18284
- ${allHandlers.filter((h$4) => h$4.lazy).map((h$4) => `const ${h$4._importHash} = h3.defineLazyEventHandler(() => import("${h$4.handler}")${h$4.format === "node" ? ".then(m => srvxNode.toFetchHandler(m.default))" : ""});`).join("\n")}
18285
-
18286
- export const findRoute = ${nitro.routing.routes.compileToString({ serialize: serializeHandler })}
18287
-
18288
- export const findRoutedMiddleware = ${nitro.routing.routedMiddleware.compileToString({
18289
- serialize: serializeHandler,
18290
- matchAll: true
18291
- })};
18292
-
18293
- export const globalMiddleware = [
18294
- ${nitro.routing.globalMiddleware.map((h$4) => h$4.lazy ? h$4._importHash : `h3.toEventHandler(${h$4._importHash})`).join(",")}
18295
- ].filter(Boolean);
18296
- `;
18297
- }
18298
- };
18299
- }
18300
- function uniqueBy(arr, key) {
18301
- return [...new Map(arr.map((item) => [item[key], item])).values()];
18302
- }
18303
- function serializeHandler(h$4) {
18304
- const meta = Array.isArray(h$4) ? h$4[0] : h$4;
18305
- return `{${[
18306
- `route:${JSON.stringify(meta.route)}`,
18307
- meta.method && `method:${JSON.stringify(meta.method)}`,
18308
- meta.meta && `meta:${JSON.stringify(meta.meta)}`,
18309
- `handler:${Array.isArray(h$4) ? `multiHandler(${h$4.map((handler) => serializeHandlerFn(handler)).join(",")})` : serializeHandlerFn(h$4)}`
18310
- ].filter(Boolean).join(",")}}`;
18311
- }
18312
- function serializeHandlerFn(h$4) {
18313
- let code = h$4._importHash;
18314
- if (!h$4.lazy) {
18315
- if (h$4.format === "node") code = `srvxNode.toFetchHandler(${code})`;
18316
- code = `h3.toEventHandler(${code})`;
18251
+ return node;
18317
18252
  }
18318
- return code;
18319
- }
18320
- function serializeRouteRule(h$4) {
18321
- return `[${Object.entries(h$4).filter(([name, options]) => options !== void 0 && name[0] !== "_").map(([name, options]) => {
18322
- return `{${[
18323
- `name:${JSON.stringify(name)}`,
18324
- `route:${JSON.stringify(h$4._route)}`,
18325
- h$4._method && `method:${JSON.stringify(h$4._method)}`,
18326
- RuntimeRouteRules.includes(name) && `handler:__routeRules__.${name}`,
18327
- `options:${JSON.stringify(options)}`
18328
- ].filter(Boolean).join(",")}}`;
18329
- }).join(",")}]`;
18330
- }
18331
-
18332
- //#endregion
18333
- //#region src/build/virtual/runtime-config.ts
18334
- function runtimeConfig(nitro) {
18335
- return {
18336
- id: "#nitro/virtual/runtime-config",
18337
- template: () => {
18338
- return `export const runtimeConfig = ${JSON.stringify(nitro.options.runtimeConfig || {})};`;
18339
- }
18340
- };
18253
+ };
18254
+ /** @typedef { import('estree').BaseNode} BaseNode */
18255
+ /** @typedef { import('./sync.js').SyncHandler} SyncHandler */
18256
+ /** @typedef { import('./async.js').AsyncHandler} AsyncHandler */
18257
+ /**
18258
+ *
18259
+ * @param {BaseNode} ast
18260
+ * @param {{
18261
+ * enter?: SyncHandler
18262
+ * leave?: SyncHandler
18263
+ * }} walker
18264
+ * @returns {BaseNode}
18265
+ */
18266
+ function walk(ast, { enter, leave }) {
18267
+ return new SyncWalker(enter, leave).visit(ast, null);
18341
18268
  }
18342
18269
 
18343
18270
  //#endregion
18344
- //#region src/build/virtual/server-assets.ts
18345
- function serverAssets(nitro) {
18346
- return {
18347
- id: "#nitro/virtual/server-assets",
18348
- template: async () => {
18349
- if (nitro.options.dev || nitro.options.preset === "nitro-prerender") return `
18350
- import { createStorage } from 'unstorage'
18351
- import fsDriver from 'unstorage/drivers/fs'
18352
- const serverAssets = ${JSON.stringify(nitro.options.serverAssets)}
18353
- export const assets = createStorage()
18354
- for (const asset of serverAssets) {
18355
- assets.mount(asset.baseName, fsDriver({ base: asset.dir, ignore: (asset?.ignore || []) }))
18356
- }`;
18357
- const assets = {};
18358
- for (const asset of nitro.options.serverAssets) {
18359
- const files = await glob(asset.pattern || "**/*", {
18360
- cwd: asset.dir,
18361
- absolute: false,
18362
- ignore: asset.ignore
18271
+ //#region node_modules/.pnpm/@rollup+pluginutils@5.3.0_rollup@4.55.2/node_modules/@rollup/pluginutils/dist/es/index.js
18272
+ const extractors = {
18273
+ ArrayPattern(names, param) {
18274
+ for (const element of param.elements) if (element) extractors[element.type](names, element);
18275
+ },
18276
+ AssignmentPattern(names, param) {
18277
+ extractors[param.left.type](names, param.left);
18278
+ },
18279
+ Identifier(names, param) {
18280
+ names.push(param.name);
18281
+ },
18282
+ MemberExpression() {},
18283
+ ObjectPattern(names, param) {
18284
+ for (const prop of param.properties) if (prop.type === "RestElement") extractors.RestElement(names, prop);
18285
+ else extractors[prop.value.type](names, prop.value);
18286
+ },
18287
+ RestElement(names, param) {
18288
+ extractors[param.argument.type](names, param.argument);
18289
+ }
18290
+ };
18291
+ const extractAssignedNames = function extractAssignedNames(param) {
18292
+ const names = [];
18293
+ extractors[param.type](names, param);
18294
+ return names;
18295
+ };
18296
+ const blockDeclarations = {
18297
+ const: true,
18298
+ let: true
18299
+ };
18300
+ var Scope = class {
18301
+ constructor(options = {}) {
18302
+ this.parent = options.parent;
18303
+ this.isBlockScope = !!options.block;
18304
+ this.declarations = Object.create(null);
18305
+ if (options.params) options.params.forEach((param) => {
18306
+ extractAssignedNames(param).forEach((name) => {
18307
+ this.declarations[name] = true;
18308
+ });
18309
+ });
18310
+ }
18311
+ addDeclaration(node, isBlockDeclaration, isVar) {
18312
+ if (!isBlockDeclaration && this.isBlockScope) this.parent.addDeclaration(node, isBlockDeclaration, isVar);
18313
+ else if (node.id) extractAssignedNames(node.id).forEach((name) => {
18314
+ this.declarations[name] = true;
18315
+ });
18316
+ }
18317
+ contains(name) {
18318
+ return this.declarations[name] || (this.parent ? this.parent.contains(name) : false);
18319
+ }
18320
+ };
18321
+ const attachScopes = function attachScopes(ast, propertyName = "scope") {
18322
+ let scope = new Scope();
18323
+ walk(ast, {
18324
+ enter(n$2, parent) {
18325
+ const node = n$2;
18326
+ if (/(?:Function|Class)Declaration/.test(node.type)) scope.addDeclaration(node, false, false);
18327
+ if (node.type === "VariableDeclaration") {
18328
+ const { kind } = node;
18329
+ const isBlockDeclaration = blockDeclarations[kind];
18330
+ node.declarations.forEach((declaration) => {
18331
+ scope.addDeclaration(declaration, isBlockDeclaration, true);
18363
18332
  });
18364
- for (const _id of files) {
18365
- const fsPath = resolve$3(asset.dir, _id);
18366
- const id = asset.baseName + "/" + _id;
18367
- assets[id] = {
18368
- fsPath,
18369
- meta: {}
18370
- };
18371
- let type$1 = src_default.getType(id) || "text/plain";
18372
- if (type$1.startsWith("text")) type$1 += "; charset=utf-8";
18373
- const etag = (0, import_etag.default)(await promises.readFile(fsPath));
18374
- const mtime = await promises.stat(fsPath).then((s) => s.mtime.toJSON());
18375
- assets[id].meta = {
18376
- type: type$1,
18377
- etag,
18378
- mtime
18379
- };
18380
- }
18381
18333
  }
18382
- return `
18383
- const _assets = {\n${Object.entries(assets).map(([id, asset]) => ` [${JSON.stringify(normalizeKey(id))}]: {\n import: () => import(${JSON.stringify("raw:" + asset.fsPath)}).then(r => r.default || r),\n meta: ${JSON.stringify(asset.meta)}\n }`).join(",\n")}\n}
18384
-
18385
- const normalizeKey = ${normalizeKey.toString()}
18386
-
18387
- export const assets = {
18388
- getKeys() {
18389
- return Promise.resolve(Object.keys(_assets))
18390
- },
18391
- hasItem (id) {
18392
- id = normalizeKey(id)
18393
- return Promise.resolve(id in _assets)
18394
- },
18395
- getItem (id) {
18396
- id = normalizeKey(id)
18397
- return Promise.resolve(_assets[id] ? _assets[id].import() : null)
18398
- },
18399
- getMeta (id) {
18400
- id = normalizeKey(id)
18401
- return Promise.resolve(_assets[id] ? _assets[id].meta : {})
18402
- }
18403
- }
18404
- `;
18334
+ let newScope;
18335
+ if (node.type.includes("Function")) {
18336
+ const func = node;
18337
+ newScope = new Scope({
18338
+ parent: scope,
18339
+ block: false,
18340
+ params: func.params
18341
+ });
18342
+ if (func.type === "FunctionExpression" && func.id) newScope.addDeclaration(func, false, false);
18343
+ }
18344
+ if (/For(?:In|Of)?Statement/.test(node.type)) newScope = new Scope({
18345
+ parent: scope,
18346
+ block: true
18347
+ });
18348
+ if (node.type === "BlockStatement" && !parent.type.includes("Function")) newScope = new Scope({
18349
+ parent: scope,
18350
+ block: true
18351
+ });
18352
+ if (node.type === "CatchClause") newScope = new Scope({
18353
+ parent: scope,
18354
+ params: node.param ? [node.param] : [],
18355
+ block: true
18356
+ });
18357
+ if (newScope) {
18358
+ Object.defineProperty(node, propertyName, {
18359
+ value: newScope,
18360
+ configurable: true
18361
+ });
18362
+ scope = newScope;
18363
+ }
18364
+ },
18365
+ leave(n$2) {
18366
+ if (n$2[propertyName]) scope = scope.parent;
18405
18367
  }
18406
- };
18368
+ });
18369
+ return scope;
18370
+ };
18371
+ function isArray(arg) {
18372
+ return Array.isArray(arg);
18407
18373
  }
18408
-
18409
- //#endregion
18410
- //#region src/build/virtual/storage.ts
18411
- function storage(nitro) {
18412
- return {
18413
- id: "#nitro/virtual/storage",
18414
- template: () => {
18415
- const mounts = [];
18416
- const storageMounts = nitro.options.dev || nitro.options.preset === "nitro-prerender" ? {
18417
- ...nitro.options.storage,
18418
- ...nitro.options.devStorage
18419
- } : nitro.options.storage;
18420
- for (const path$2 in storageMounts) {
18421
- const { driver: driverName, ...driverOpts } = storageMounts[path$2];
18422
- mounts.push({
18423
- path: path$2,
18424
- driver: builtinDrivers[driverName] || driverName,
18425
- opts: driverOpts
18426
- });
18427
- }
18428
- return `
18429
- import { createStorage } from 'unstorage'
18430
- import { assets } from '#nitro/virtual/server-assets'
18431
-
18432
- ${[...new Set(mounts.map((m$3) => m$3.driver))].map((i$2) => genImport(i$2, genSafeVariableName(i$2))).join("\n")}
18433
-
18434
- export function initStorage() {
18435
- const storage = createStorage({})
18436
- storage.mount('/assets', assets)
18437
- ${mounts.map((m$3) => `storage.mount('${m$3.path}', ${genSafeVariableName(m$3.driver)}(${JSON.stringify(m$3.opts)}))`).join("\n")}
18438
- return storage
18374
+ function ensureArray(thing) {
18375
+ if (isArray(thing)) return thing;
18376
+ if (thing == null) return [];
18377
+ return [thing];
18439
18378
  }
18440
- `;
18441
- }
18442
- };
18379
+ const normalizePathRegExp = new RegExp(`\\${win32.sep}`, "g");
18380
+ const normalizePath = function normalizePath(filename) {
18381
+ return filename.replace(normalizePathRegExp, posix.sep);
18382
+ };
18383
+ function getMatcherString(id, resolutionBase) {
18384
+ if (resolutionBase === false || isAbsolute(id) || id.startsWith("**")) return normalizePath(id);
18385
+ const basePath = normalizePath(resolve(resolutionBase || "")).replace(/[-^$*+?.()|[\]{}]/g, "\\$&");
18386
+ return posix.join(basePath, normalizePath(id));
18443
18387
  }
18444
-
18445
- //#endregion
18446
- //#region src/build/virtual/tasks.ts
18447
- function tasks(nitro) {
18448
- return {
18449
- id: "#nitro/virtual/tasks",
18450
- template: () => {
18451
- const _scheduledTasks = Object.entries(nitro.options.scheduledTasks || {}).map(([cron, _tasks]) => {
18452
- return {
18453
- cron,
18454
- tasks: (Array.isArray(_tasks) ? _tasks : [_tasks]).filter((name) => {
18455
- if (!nitro.options.tasks[name]) {
18456
- nitro.logger.warn(`Scheduled task \`${name}\` is not defined!`);
18457
- return false;
18458
- }
18459
- return true;
18460
- })
18461
- };
18462
- }).filter((e) => e.tasks.length > 0);
18463
- const scheduledTasks = _scheduledTasks.length > 0 ? _scheduledTasks : false;
18464
- return `
18465
- export const scheduledTasks = ${JSON.stringify(scheduledTasks)};
18466
-
18467
- export const tasks = {
18468
- ${Object.entries(nitro.options.tasks).map(([name, task]) => `"${name}": {
18469
- meta: {
18470
- description: ${JSON.stringify(task.description)},
18471
- },
18472
- resolve: ${task.handler ? `() => import("${normalize$2(task.handler)}").then(r => r.default || r)` : "undefined"},
18473
- }`).join(",\n")}
18474
- };`;
18388
+ const createFilter = function createFilter(include, exclude, options) {
18389
+ const resolutionBase = options && options.resolve;
18390
+ const getMatcher = (id) => id instanceof RegExp ? id : { test: (what) => {
18391
+ return (0, import_picomatch.default)(getMatcherString(id, resolutionBase), { dot: true })(what);
18392
+ } };
18393
+ const includeMatchers = ensureArray(include).map(getMatcher);
18394
+ const excludeMatchers = ensureArray(exclude).map(getMatcher);
18395
+ if (!includeMatchers.length && !excludeMatchers.length) return (id) => typeof id === "string" && !id.includes("\0");
18396
+ return function result(id) {
18397
+ if (typeof id !== "string") return false;
18398
+ if (id.includes("\0")) return false;
18399
+ const pathId = normalizePath(id);
18400
+ for (let i$2 = 0; i$2 < excludeMatchers.length; ++i$2) {
18401
+ const matcher = excludeMatchers[i$2];
18402
+ if (matcher instanceof RegExp) matcher.lastIndex = 0;
18403
+ if (matcher.test(pathId)) return false;
18404
+ }
18405
+ for (let i$2 = 0; i$2 < includeMatchers.length; ++i$2) {
18406
+ const matcher = includeMatchers[i$2];
18407
+ if (matcher instanceof RegExp) matcher.lastIndex = 0;
18408
+ if (matcher.test(pathId)) return true;
18475
18409
  }
18410
+ return !includeMatchers.length;
18476
18411
  };
18412
+ };
18413
+ const forbiddenIdentifiers = new Set(`break case class catch const continue debugger default delete do else export extends finally for function if import in instanceof let new return super switch this throw try typeof var void while with yield enum await implements package protected static interface private public arguments Infinity NaN undefined null true false eval uneval isFinite isNaN parseFloat parseInt decodeURI decodeURIComponent encodeURI encodeURIComponent escape unescape Object Function Boolean Symbol Error EvalError InternalError RangeError ReferenceError SyntaxError TypeError URIError Number Math Date String RegExp Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array Map Set WeakMap WeakSet SIMD ArrayBuffer DataView JSON Promise Generator GeneratorFunction Reflect Proxy Intl`.split(" "));
18414
+ forbiddenIdentifiers.add("");
18415
+ const makeLegalIdentifier = function makeLegalIdentifier(str) {
18416
+ let identifier = str.replace(/-(\w)/g, (_$2, letter) => letter.toUpperCase()).replace(/[^$_a-zA-Z0-9]/g, "_");
18417
+ if (/\d/.test(identifier[0]) || forbiddenIdentifiers.has(identifier)) identifier = `_${identifier}`;
18418
+ return identifier || "_";
18419
+ };
18420
+ function stringify(obj) {
18421
+ return (JSON.stringify(obj) || "undefined").replace(/[\u2028\u2029]/g, (char) => `\\u${`000${char.charCodeAt(0).toString(16)}`.slice(-4)}`);
18477
18422
  }
18478
-
18479
- //#endregion
18480
- //#region src/build/virtual/_all.ts
18481
- function virtualTemplates(nitro, _polyfills) {
18482
- const nitroTemplates = [
18483
- database,
18484
- errorHandler,
18485
- featureFlags,
18486
- plugins,
18487
- polyfills,
18488
- publicAssets,
18489
- rendererTemplate,
18490
- routingMeta,
18491
- routing,
18492
- runtimeConfig,
18493
- serverAssets,
18494
- storage,
18495
- tasks
18496
- ].flatMap((t$1) => t$1(nitro, _polyfills));
18497
- const customTemplates = Object.entries(nitro.options.virtual).map(([id, template]) => ({
18498
- id,
18499
- template
18500
- }));
18501
- return [...nitroTemplates, ...customTemplates];
18423
+ function serializeArray(arr, indent, baseIndent) {
18424
+ let output = "[";
18425
+ const separator = indent ? `\n${baseIndent}${indent}` : "";
18426
+ for (let i$2 = 0; i$2 < arr.length; i$2++) {
18427
+ const key = arr[i$2];
18428
+ output += `${i$2 > 0 ? "," : ""}${separator}${serialize(key, indent, baseIndent + indent)}`;
18429
+ }
18430
+ return `${output}${indent ? `\n${baseIndent}` : ""}]`;
18431
+ }
18432
+ function serializeObject(obj, indent, baseIndent) {
18433
+ let output = "{";
18434
+ const separator = indent ? `\n${baseIndent}${indent}` : "";
18435
+ const entries = Object.entries(obj);
18436
+ for (let i$2 = 0; i$2 < entries.length; i$2++) {
18437
+ const [key, value] = entries[i$2];
18438
+ const stringKey = makeLegalIdentifier(key) === key ? key : stringify(key);
18439
+ output += `${i$2 > 0 ? "," : ""}${separator}${stringKey}:${indent ? " " : ""}${serialize(value, indent, baseIndent + indent)}`;
18440
+ }
18441
+ return `${output}${indent ? `\n${baseIndent}` : ""}}`;
18442
+ }
18443
+ function serialize(obj, indent, baseIndent) {
18444
+ if (typeof obj === "object" && obj !== null) {
18445
+ if (Array.isArray(obj)) return serializeArray(obj, indent, baseIndent);
18446
+ if (obj instanceof Date) return `new Date(${obj.getTime()})`;
18447
+ if (obj instanceof RegExp) return obj.toString();
18448
+ return serializeObject(obj, indent, baseIndent);
18449
+ }
18450
+ if (typeof obj === "number") {
18451
+ if (obj === Infinity) return "Infinity";
18452
+ if (obj === -Infinity) return "-Infinity";
18453
+ if (obj === 0) return 1 / obj === Infinity ? "0" : "-0";
18454
+ if (obj !== obj) return "NaN";
18455
+ }
18456
+ if (typeof obj === "symbol") {
18457
+ const key = Symbol.keyFor(obj);
18458
+ if (key !== void 0) return `Symbol.for(${stringify(key)})`;
18459
+ }
18460
+ if (typeof obj === "bigint") return `${obj}n`;
18461
+ return stringify(obj);
18502
18462
  }
18463
+ const hasStringIsWellFormed = "isWellFormed" in String.prototype;
18464
+ function isWellFormedString(input) {
18465
+ if (hasStringIsWellFormed) return input.isWellFormed();
18466
+ return !/\p{Surrogate}/u.test(input);
18467
+ }
18468
+ const dataToEsm = function dataToEsm(data$1, options = {}) {
18469
+ var _a, _b;
18470
+ const t$1 = options.compact ? "" : "indent" in options ? options.indent : " ";
18471
+ const _$2 = options.compact ? "" : " ";
18472
+ const n$2 = options.compact ? "" : "\n";
18473
+ const declarationType = options.preferConst ? "const" : "var";
18474
+ if (options.namedExports === false || typeof data$1 !== "object" || Array.isArray(data$1) || data$1 instanceof Date || data$1 instanceof RegExp || data$1 === null) {
18475
+ const code = serialize(data$1, options.compact ? null : t$1, "");
18476
+ return `export default${_$2 || (/^[{[\-\/]/.test(code) ? "" : " ")}${code};`;
18477
+ }
18478
+ let maxUnderbarPrefixLength = 0;
18479
+ for (const key of Object.keys(data$1)) {
18480
+ const underbarPrefixLength = (_b = (_a = /^(_+)/.exec(key)) === null || _a === void 0 ? void 0 : _a[0].length) !== null && _b !== void 0 ? _b : 0;
18481
+ if (underbarPrefixLength > maxUnderbarPrefixLength) maxUnderbarPrefixLength = underbarPrefixLength;
18482
+ }
18483
+ const arbitraryNamePrefix = `${"_".repeat(maxUnderbarPrefixLength + 1)}arbitrary`;
18484
+ let namedExportCode = "";
18485
+ const defaultExportRows = [];
18486
+ const arbitraryNameExportRows = [];
18487
+ for (const [key, value] of Object.entries(data$1)) if (key === makeLegalIdentifier(key)) {
18488
+ if (options.objectShorthand) defaultExportRows.push(key);
18489
+ else defaultExportRows.push(`${key}:${_$2}${key}`);
18490
+ namedExportCode += `export ${declarationType} ${key}${_$2}=${_$2}${serialize(value, options.compact ? null : t$1, "")};${n$2}`;
18491
+ } else {
18492
+ defaultExportRows.push(`${stringify(key)}:${_$2}${serialize(value, options.compact ? null : t$1, "")}`);
18493
+ if (options.includeArbitraryNames && isWellFormedString(key)) {
18494
+ const variableName = `${arbitraryNamePrefix}${arbitraryNameExportRows.length}`;
18495
+ namedExportCode += `${declarationType} ${variableName}${_$2}=${_$2}${serialize(value, options.compact ? null : t$1, "")};${n$2}`;
18496
+ arbitraryNameExportRows.push(`${variableName} as ${JSON.stringify(key)}`);
18497
+ }
18498
+ }
18499
+ const arbitraryExportCode = arbitraryNameExportRows.length > 0 ? `export${_$2}{${n$2}${t$1}${arbitraryNameExportRows.join(`,${n$2}${t$1}`)}${n$2}};${n$2}` : "";
18500
+ const defaultExportCode = `export default${_$2}{${n$2}${t$1}${defaultExportRows.join(`,${n$2}${t$1}`)}${n$2}};${n$2}`;
18501
+ return `${namedExportCode}${arbitraryExportCode}${defaultExportCode}`;
18502
+ };
18503
18503
 
18504
18504
  //#endregion
18505
18505
  //#region node_modules/.pnpm/@rollup+plugin-replace@6.0.3_rollup@4.55.2/node_modules/@rollup/plugin-replace/dist/es/index.js
@@ -24937,4 +24937,4 @@ function oxc(options) {
24937
24937
  }
24938
24938
 
24939
24939
  //#endregion
24940
- export { resolveModulePath as $, compressPublicAssets as A, T as B, decode as C, prepare as D, parse as E, Builder as F, findFile$1 as G, d as H, prettyPath as I, readGitConfig as J, findNearestFile$1 as K, resolveNitroPath as L, build as M, glob as N, copyPublicAssets as O, require_picomatch as P, N$4 as Q, writeFile$1 as R, MagicString as S, Parser as T, p as U, a as V, dist_exports$1 as W, h$2 as X, readPackageJSON$1 as Y, C$1 as Z, writeTypes as _, libChunkName as a, join$2 as at, getMagicString as b, createFilter as c, resolve$3 as ct, makeLegalIdentifier as d, resolveModuleURL as et, walk as f, writeDevBuildInfo as g, writeBuildInfo as h, getChunkName as i, isAbsolute$2 as it, src_default as j, scanUnprefixedPublicAssets as k, dataToEsm as l, getBuildInfo as m, baseBuildPlugins as n, dirname$2 as nt, baseBuildConfig as o, normalize$2 as ot, runParallel as p, findWorkspaceDir as q, NODE_MODULES_RE$1 as r, extname$4 as rt, attachScopes as s, relative$2 as st, oxc as t, basename$2 as tt, extractAssignedNames as u, dist_exports as v, encode as w, stripLiteral as x, createUnimport as y, K$1 as z };
24940
+ export { resolveModulePath as $, compressPublicAssets as A, T as B, decode as C, prepare as D, parse as E, Builder as F, findFile$1 as G, d as H, prettyPath as I, readGitConfig as J, findNearestFile$1 as K, resolveNitroPath as L, build as M, glob as N, copyPublicAssets as O, require_picomatch as P, N$4 as Q, writeFile$1 as R, MagicString as S, Parser as T, p as U, a as V, dist_exports$1 as W, h$2 as X, readPackageJSON$1 as Y, C$1 as Z, writeTypes as _, dataToEsm as a, join$2 as at, getMagicString as b, walk as c, resolve$3 as ct, libChunkName as d, resolveModuleURL as et, baseBuildConfig as f, writeDevBuildInfo as g, writeBuildInfo as h, createFilter as i, isAbsolute$2 as it, src_default as j, scanUnprefixedPublicAssets as k, NODE_MODULES_RE$1 as l, getBuildInfo as m, baseBuildPlugins as n, dirname$2 as nt, extractAssignedNames as o, normalize$2 as ot, runParallel as p, findWorkspaceDir as q, attachScopes as r, extname$4 as rt, makeLegalIdentifier as s, relative$2 as st, oxc as t, basename$2 as tt, getChunkName as u, dist_exports as v, encode as w, stripLiteral as x, createUnimport as y, K$1 as z };