nitro-nightly 3.0.1-20260120-134104-795e774f → 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.
- package/dist/_build/common.mjs +1021 -1012
- package/dist/_build/rolldown.mjs +2 -2
- package/dist/_build/rollup.mjs +2 -2
- package/dist/_libs/commondir+is-reference.mjs +1 -1
- package/dist/_libs/hasown+resolve+deepmerge.mjs +1 -1
- package/dist/_libs/plugin-alias.mjs +3 -1
- package/dist/_libs/plugin-inject.mjs +4 -2
- package/dist/_libs/plugin-json.mjs +1 -1
- package/dist/types/index.d.mts +9 -17
- package/dist/vite.mjs +42 -32
- package/package.json +1 -1
package/dist/_build/common.mjs
CHANGED
|
@@ -17370,557 +17370,659 @@ async function runParallel(inputs, cb, opts) {
|
|
|
17370
17370
|
}
|
|
17371
17371
|
|
|
17372
17372
|
//#endregion
|
|
17373
|
-
//#region
|
|
17374
|
-
|
|
17375
|
-
|
|
17376
|
-
|
|
17377
|
-
|
|
17378
|
-
|
|
17379
|
-
|
|
17380
|
-
|
|
17381
|
-
|
|
17382
|
-
|
|
17383
|
-
|
|
17384
|
-
|
|
17385
|
-
|
|
17386
|
-
|
|
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
|
|
17517
|
-
|
|
17518
|
-
|
|
17519
|
-
|
|
17520
|
-
|
|
17521
|
-
|
|
17522
|
-
|
|
17523
|
-
|
|
17524
|
-
|
|
17525
|
-
|
|
17526
|
-
|
|
17527
|
-
|
|
17528
|
-
|
|
17529
|
-
|
|
17530
|
-
|
|
17531
|
-
|
|
17532
|
-
|
|
17533
|
-
|
|
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
|
-
|
|
17537
|
-
|
|
17538
|
-
|
|
17539
|
-
|
|
17540
|
-
|
|
17541
|
-
const
|
|
17542
|
-
|
|
17543
|
-
|
|
17544
|
-
}
|
|
17545
|
-
|
|
17546
|
-
|
|
17547
|
-
|
|
17548
|
-
|
|
17549
|
-
|
|
17550
|
-
|
|
17551
|
-
|
|
17552
|
-
|
|
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
|
-
|
|
17557
|
-
|
|
17558
|
-
|
|
17559
|
-
|
|
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
|
-
|
|
17563
|
-
|
|
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
|
}
|
|
17565
|
-
|
|
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;
|
|
17612
|
-
}
|
|
17613
|
-
});
|
|
17614
|
-
return scope;
|
|
17615
|
-
};
|
|
17616
|
-
function isArray(arg) {
|
|
17617
|
-
return Array.isArray(arg);
|
|
17498
|
+
return `_chunks/[name].mjs`;
|
|
17618
17499
|
}
|
|
17619
|
-
function
|
|
17620
|
-
|
|
17621
|
-
if (thing == null) return [];
|
|
17622
|
-
return [thing];
|
|
17500
|
+
function routeToFsPath(route) {
|
|
17501
|
+
return route.split("/").slice(1).map((s) => `${s.replace(/[:*]+/g, "$").replace(/[^$a-zA-Z0-9_.[\]/]/g, "_")}`).join("/") || "index";
|
|
17623
17502
|
}
|
|
17624
|
-
|
|
17625
|
-
|
|
17626
|
-
|
|
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")}
|
|
17627
17522
|
};
|
|
17628
|
-
|
|
17629
|
-
|
|
17630
|
-
|
|
17631
|
-
return posix.join(basePath, normalizePath(id));
|
|
17523
|
+
`;
|
|
17524
|
+
}
|
|
17525
|
+
};
|
|
17632
17526
|
}
|
|
17633
|
-
|
|
17634
|
-
|
|
17635
|
-
|
|
17636
|
-
|
|
17637
|
-
|
|
17638
|
-
|
|
17639
|
-
|
|
17640
|
-
|
|
17641
|
-
|
|
17642
|
-
|
|
17643
|
-
|
|
17644
|
-
|
|
17645
|
-
|
|
17646
|
-
|
|
17647
|
-
|
|
17648
|
-
|
|
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
|
|
17556
|
+
}
|
|
17557
|
+
`;
|
|
17649
17558
|
}
|
|
17650
|
-
|
|
17651
|
-
|
|
17652
|
-
|
|
17653
|
-
|
|
17559
|
+
};
|
|
17560
|
+
}
|
|
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");
|
|
17654
17578
|
}
|
|
17655
|
-
return !includeMatchers.length;
|
|
17656
17579
|
};
|
|
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
17580
|
}
|
|
17668
|
-
|
|
17669
|
-
|
|
17670
|
-
|
|
17671
|
-
|
|
17672
|
-
|
|
17673
|
-
|
|
17674
|
-
|
|
17675
|
-
|
|
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
|
+
`;
|
|
17596
|
+
}
|
|
17597
|
+
};
|
|
17676
17598
|
}
|
|
17677
|
-
|
|
17678
|
-
|
|
17679
|
-
|
|
17680
|
-
|
|
17681
|
-
|
|
17682
|
-
|
|
17683
|
-
|
|
17684
|
-
|
|
17685
|
-
|
|
17686
|
-
|
|
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
|
+
};
|
|
17687
17610
|
}
|
|
17688
|
-
|
|
17689
|
-
|
|
17690
|
-
|
|
17691
|
-
|
|
17692
|
-
|
|
17693
|
-
|
|
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 + "\"";
|
|
17694
17647
|
}
|
|
17695
|
-
|
|
17696
|
-
|
|
17697
|
-
|
|
17698
|
-
|
|
17699
|
-
|
|
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;
|
|
17700
17664
|
}
|
|
17701
|
-
|
|
17702
|
-
|
|
17703
|
-
|
|
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";
|
|
17704
17675
|
}
|
|
17705
|
-
|
|
17706
|
-
|
|
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 + "\"";
|
|
17686
|
+
}
|
|
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
|
-
|
|
17709
|
-
function
|
|
17710
|
-
|
|
17711
|
-
|
|
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
|
-
|
|
17714
|
-
|
|
17715
|
-
|
|
17716
|
-
|
|
17717
|
-
|
|
17718
|
-
|
|
17719
|
-
|
|
17720
|
-
|
|
17721
|
-
|
|
17722
|
-
|
|
17723
|
-
|
|
17724
|
-
|
|
17725
|
-
|
|
17726
|
-
|
|
17727
|
-
|
|
17728
|
-
|
|
17729
|
-
|
|
17730
|
-
|
|
17731
|
-
|
|
17732
|
-
|
|
17733
|
-
|
|
17734
|
-
|
|
17735
|
-
|
|
17736
|
-
|
|
17737
|
-
|
|
17738
|
-
|
|
17739
|
-
|
|
17740
|
-
|
|
17741
|
-
|
|
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
|
-
|
|
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/
|
|
17751
|
-
function
|
|
17752
|
-
return
|
|
17753
|
-
|
|
17754
|
-
|
|
17755
|
-
|
|
17756
|
-
|
|
17757
|
-
|
|
17758
|
-
|
|
17759
|
-
|
|
17760
|
-
|
|
17761
|
-
|
|
17762
|
-
|
|
17763
|
-
|
|
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/
|
|
17768
|
-
function
|
|
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
|
-
|
|
17802
|
-
|
|
17803
|
-
|
|
17804
|
-
|
|
17805
|
-
|
|
17806
|
-
|
|
17807
|
-
|
|
17808
|
-
|
|
17809
|
-
|
|
17810
|
-
|
|
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
|
|
17816
|
-
|
|
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/
|
|
17842
|
-
const
|
|
17843
|
-
|
|
17844
|
-
|
|
17845
|
-
|
|
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
|
-
|
|
17848
|
-
|
|
17849
|
-
|
|
17850
|
-
|
|
17851
|
-
|
|
17852
|
-
|
|
17853
|
-
|
|
17854
|
-
|
|
17855
|
-
|
|
17856
|
-
|
|
17857
|
-
|
|
17858
|
-
|
|
17859
|
-
|
|
17860
|
-
|
|
17861
|
-
|
|
17862
|
-
|
|
17863
|
-
|
|
17864
|
-
|
|
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
|
+
`;
|
|
17920
|
+
}
|
|
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})`;
|
|
17865
17940
|
}
|
|
17866
|
-
return
|
|
17941
|
+
return code;
|
|
17867
17942
|
}
|
|
17868
|
-
function
|
|
17869
|
-
return
|
|
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(",")}]`;
|
|
17870
17953
|
}
|
|
17871
17954
|
|
|
17872
17955
|
//#endregion
|
|
17873
|
-
//#region src/build/virtual/
|
|
17874
|
-
function
|
|
17956
|
+
//#region src/build/virtual/runtime-config.ts
|
|
17957
|
+
function runtimeConfig(nitro) {
|
|
17875
17958
|
return {
|
|
17876
|
-
id: "#nitro/virtual/
|
|
17959
|
+
id: "#nitro/virtual/runtime-config",
|
|
17877
17960
|
template: () => {
|
|
17878
|
-
|
|
17879
|
-
const dbConfigs = nitro.options.dev && nitro.options.devDatabase || nitro.options.database;
|
|
17880
|
-
const connectorsNames = [...new Set(Object.values(dbConfigs || {}).map((config) => config?.connector))].filter(Boolean);
|
|
17881
|
-
for (const name of connectorsNames) if (!connectors[name]) throw new Error(`Database connector "${name}" is invalid.`);
|
|
17882
|
-
return `
|
|
17883
|
-
${connectorsNames.map((name) => `import ${camelCase(name)}Connector from "${connectors[name]}";`).join("\n")}
|
|
17884
|
-
|
|
17885
|
-
export const connectionConfigs = {
|
|
17886
|
-
${Object.entries(dbConfigs || {}).filter(([, config]) => !!config?.connector).map(([name, { connector, options }]) => `${name}: {
|
|
17887
|
-
connector: ${camelCase(connector)}Connector,
|
|
17888
|
-
options: ${JSON.stringify(options)}
|
|
17889
|
-
}`).join(",\n")}
|
|
17890
|
-
};
|
|
17891
|
-
`;
|
|
17961
|
+
return `export const runtimeConfig = ${JSON.stringify(nitro.options.runtimeConfig || {})};`;
|
|
17892
17962
|
}
|
|
17893
17963
|
};
|
|
17894
17964
|
}
|
|
17895
17965
|
|
|
17896
17966
|
//#endregion
|
|
17897
|
-
//#region src/build/virtual/
|
|
17898
|
-
function
|
|
17967
|
+
//#region src/build/virtual/server-assets.ts
|
|
17968
|
+
function serverAssets(nitro) {
|
|
17899
17969
|
return {
|
|
17900
|
-
id: "#nitro/virtual/
|
|
17901
|
-
template: () => {
|
|
17902
|
-
|
|
17903
|
-
|
|
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
|
+
}
|
|
17904
18005
|
return `
|
|
17905
|
-
${
|
|
17906
|
-
|
|
17907
|
-
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}
|
|
17908
18007
|
|
|
17909
|
-
|
|
18008
|
+
const normalizeKey = ${normalizeKey.toString()}
|
|
17910
18009
|
|
|
17911
|
-
export
|
|
17912
|
-
|
|
17913
|
-
|
|
17914
|
-
|
|
17915
|
-
|
|
17916
|
-
|
|
17917
|
-
|
|
17918
|
-
|
|
17919
|
-
|
|
17920
|
-
|
|
17921
|
-
|
|
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 : {})
|
|
17922
18025
|
}
|
|
17923
|
-
// H3 will handle fallback
|
|
17924
18026
|
}
|
|
17925
18027
|
`;
|
|
17926
18028
|
}
|
|
@@ -17928,569 +18030,476 @@ export default async function(error, event) {
|
|
|
17928
18030
|
}
|
|
17929
18031
|
|
|
17930
18032
|
//#endregion
|
|
17931
|
-
//#region src/build/virtual/
|
|
17932
|
-
function
|
|
18033
|
+
//#region src/build/virtual/storage.ts
|
|
18034
|
+
function storage(nitro) {
|
|
17933
18035
|
return {
|
|
17934
|
-
id: "#nitro/virtual/
|
|
18036
|
+
id: "#nitro/virtual/storage",
|
|
17935
18037
|
template: () => {
|
|
17936
|
-
const
|
|
17937
|
-
|
|
17938
|
-
|
|
17939
|
-
|
|
17940
|
-
|
|
17941
|
-
|
|
17942
|
-
|
|
17943
|
-
|
|
17944
|
-
|
|
17945
|
-
|
|
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
|
+
`;
|
|
17946
18064
|
}
|
|
17947
18065
|
};
|
|
17948
18066
|
}
|
|
17949
18067
|
|
|
17950
18068
|
//#endregion
|
|
17951
|
-
//#region src/build/virtual/
|
|
17952
|
-
function
|
|
18069
|
+
//#region src/build/virtual/tasks.ts
|
|
18070
|
+
function tasks(nitro) {
|
|
17953
18071
|
return {
|
|
17954
|
-
id: "#nitro/virtual/
|
|
18072
|
+
id: "#nitro/virtual/tasks",
|
|
17955
18073
|
template: () => {
|
|
17956
|
-
const
|
|
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;
|
|
17957
18087
|
return `
|
|
17958
|
-
|
|
18088
|
+
export const scheduledTasks = ${JSON.stringify(scheduledTasks)};
|
|
17959
18089
|
|
|
17960
|
-
|
|
17961
|
-
|
|
17962
|
-
|
|
17963
|
-
|
|
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
|
+
};`;
|
|
17964
18098
|
}
|
|
17965
18099
|
};
|
|
17966
18100
|
}
|
|
17967
18101
|
|
|
17968
18102
|
//#endregion
|
|
17969
|
-
//#region src/build/virtual/
|
|
17970
|
-
function
|
|
17971
|
-
|
|
17972
|
-
|
|
17973
|
-
|
|
17974
|
-
|
|
17975
|
-
|
|
17976
|
-
|
|
17977
|
-
|
|
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];
|
|
17978
18125
|
}
|
|
17979
18126
|
|
|
17980
18127
|
//#endregion
|
|
17981
|
-
//#region node_modules/.pnpm/
|
|
17982
|
-
|
|
17983
|
-
|
|
17984
|
-
|
|
17985
|
-
|
|
17986
|
-
|
|
17987
|
-
|
|
17988
|
-
|
|
17989
|
-
|
|
17990
|
-
|
|
17991
|
-
|
|
17992
|
-
|
|
17993
|
-
|
|
17994
|
-
|
|
17995
|
-
|
|
17996
|
-
|
|
17997
|
-
|
|
17998
|
-
|
|
17999
|
-
|
|
18000
|
-
|
|
18001
|
-
|
|
18002
|
-
|
|
18003
|
-
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
|
+
}
|
|
18004
18150
|
/**
|
|
18005
|
-
* Generate an entity tag.
|
|
18006
18151
|
*
|
|
18007
|
-
* @param {
|
|
18008
|
-
* @
|
|
18009
|
-
* @
|
|
18010
|
-
|
|
18011
|
-
|
|
18012
|
-
|
|
18013
|
-
|
|
18014
|
-
|
|
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;
|
|
18015
18160
|
}
|
|
18016
18161
|
/**
|
|
18017
|
-
* Create a simple ETag.
|
|
18018
18162
|
*
|
|
18019
|
-
* @param {
|
|
18020
|
-
* @param {
|
|
18021
|
-
* @param {
|
|
18022
|
-
* @return {String}
|
|
18023
|
-
* @public
|
|
18163
|
+
* @param {any} parent
|
|
18164
|
+
* @param {string} prop
|
|
18165
|
+
* @param {number} index
|
|
18024
18166
|
*/
|
|
18025
|
-
|
|
18026
|
-
if (
|
|
18027
|
-
|
|
18028
|
-
var weak = options && typeof options.weak === "boolean" ? options.weak : isStats;
|
|
18029
|
-
if (!isStats && typeof entity !== "string" && !Buffer.isBuffer(entity)) throw new TypeError("argument entity must be string, Buffer, or fs.Stats");
|
|
18030
|
-
var tag = isStats ? stattag(entity) : entitytag(entity);
|
|
18031
|
-
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];
|
|
18032
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 {
|
|
18033
18182
|
/**
|
|
18034
|
-
* Determine if object is a Stats object.
|
|
18035
18183
|
*
|
|
18036
|
-
* @param {
|
|
18037
|
-
* @
|
|
18038
|
-
* @api private
|
|
18184
|
+
* @param {SyncHandler} enter
|
|
18185
|
+
* @param {SyncHandler} leave
|
|
18039
18186
|
*/
|
|
18040
|
-
|
|
18041
|
-
|
|
18042
|
-
|
|
18187
|
+
constructor(enter, leave) {
|
|
18188
|
+
super();
|
|
18189
|
+
/** @type {SyncHandler} */
|
|
18190
|
+
this.enter = enter;
|
|
18191
|
+
/** @type {SyncHandler} */
|
|
18192
|
+
this.leave = leave;
|
|
18043
18193
|
}
|
|
18044
18194
|
/**
|
|
18045
|
-
* Generate a tag for a stat.
|
|
18046
18195
|
*
|
|
18047
|
-
* @param {
|
|
18048
|
-
* @
|
|
18049
|
-
* @
|
|
18196
|
+
* @param {BaseNode} node
|
|
18197
|
+
* @param {BaseNode} parent
|
|
18198
|
+
* @param {string} [prop]
|
|
18199
|
+
* @param {number} [index]
|
|
18200
|
+
* @returns {BaseNode}
|
|
18050
18201
|
*/
|
|
18051
|
-
|
|
18052
|
-
|
|
18053
|
-
|
|
18054
|
-
|
|
18055
|
-
|
|
18056
|
-
|
|
18057
|
-
|
|
18058
|
-
|
|
18059
|
-
|
|
18060
|
-
|
|
18061
|
-
|
|
18062
|
-
|
|
18063
|
-
|
|
18064
|
-
|
|
18065
|
-
|
|
18066
|
-
|
|
18067
|
-
|
|
18068
|
-
|
|
18069
|
-
|
|
18070
|
-
|
|
18071
|
-
|
|
18072
|
-
|
|
18073
|
-
const files = await glob("**", {
|
|
18074
|
-
cwd: nitro.options.output.publicDir,
|
|
18075
|
-
absolute: false,
|
|
18076
|
-
dot: true
|
|
18077
|
-
});
|
|
18078
|
-
const { errors } = await runParallel(new Set(files), async (id) => {
|
|
18079
|
-
let mimeType = src_default.getType(id.replace(/\.(gz|br)$/, "")) || "text/plain";
|
|
18080
|
-
if (mimeType.startsWith("text")) mimeType += "; charset=utf-8";
|
|
18081
|
-
const fullPath = resolve$3(nitro.options.output.publicDir, id);
|
|
18082
|
-
const [assetData, stat$2] = await Promise.all([promises.readFile(fullPath), promises.stat(fullPath)]);
|
|
18083
|
-
const etag = (0, import_etag.default)(assetData);
|
|
18084
|
-
const assetId = joinURL(nitro.options.baseURL, decodeURIComponent(id));
|
|
18085
|
-
let encoding;
|
|
18086
|
-
if (id.endsWith(".gz")) encoding = "gzip";
|
|
18087
|
-
else if (id.endsWith(".br")) encoding = "br";
|
|
18088
|
-
assets[assetId] = {
|
|
18089
|
-
type: nitro._prerenderMeta?.[assetId]?.contentType || mimeType,
|
|
18090
|
-
encoding,
|
|
18091
|
-
etag,
|
|
18092
|
-
mtime: stat$2.mtime.toJSON(),
|
|
18093
|
-
size: stat$2.size,
|
|
18094
|
-
path: relative$2(nitro.options.output.serverDir, fullPath),
|
|
18095
|
-
data: nitro.options.serveStatic === "inline" ? assetData.toString("base64") : void 0
|
|
18096
|
-
};
|
|
18097
|
-
}, { concurrency: 25 });
|
|
18098
|
-
if (errors.length > 0) throw new Error(`Failed to process public assets:\n${errors.join("\n")}`, { cause: errors });
|
|
18099
|
-
return `export default ${JSON.stringify(assets, null, 2)};`;
|
|
18100
|
-
}
|
|
18101
|
-
},
|
|
18102
|
-
{
|
|
18103
|
-
id: "#nitro/virtual/public-assets",
|
|
18104
|
-
template: () => {
|
|
18105
|
-
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 }]));
|
|
18106
|
-
return `
|
|
18107
|
-
import assets from '#nitro/virtual/public-assets-data'
|
|
18108
|
-
export { readAsset } from "${`#nitro/virtual/public-assets-${readAssetHandler[nitro.options.serveStatic] || "null"}`}"
|
|
18109
|
-
export const publicAssetBases = ${JSON.stringify(publicAssetBases)}
|
|
18110
|
-
|
|
18111
|
-
export function isPublicAssetURL(id = '') {
|
|
18112
|
-
if (assets[id]) {
|
|
18113
|
-
return true
|
|
18114
|
-
}
|
|
18115
|
-
for (const base in publicAssetBases) {
|
|
18116
|
-
if (id.startsWith(base)) { return true }
|
|
18117
|
-
}
|
|
18118
|
-
return false
|
|
18119
|
-
}
|
|
18120
|
-
|
|
18121
|
-
export function getPublicAssetMeta(id = '') {
|
|
18122
|
-
for (const base in publicAssetBases) {
|
|
18123
|
-
if (id.startsWith(base)) { return publicAssetBases[base] }
|
|
18124
|
-
}
|
|
18125
|
-
return {}
|
|
18126
|
-
}
|
|
18127
|
-
|
|
18128
|
-
export function getAsset (id) {
|
|
18129
|
-
return assets[id]
|
|
18130
|
-
}
|
|
18131
|
-
`;
|
|
18132
|
-
}
|
|
18133
|
-
},
|
|
18134
|
-
{
|
|
18135
|
-
id: "#nitro/virtual/public-assets-node",
|
|
18136
|
-
template: () => {
|
|
18137
|
-
return `
|
|
18138
|
-
import { promises as fsp } from 'node:fs'
|
|
18139
|
-
import { fileURLToPath } from 'node:url'
|
|
18140
|
-
import { resolve, dirname } from 'node:path'
|
|
18141
|
-
import assets from '#nitro/virtual/public-assets-data'
|
|
18142
|
-
export function readAsset (id) {
|
|
18143
|
-
const serverDir = dirname(fileURLToPath(globalThis.__nitro_main__))
|
|
18144
|
-
return fsp.readFile(resolve(serverDir, assets[id].path))
|
|
18145
|
-
}`;
|
|
18146
|
-
}
|
|
18147
|
-
},
|
|
18148
|
-
{
|
|
18149
|
-
id: "#nitro/virtual/public-assets-deno",
|
|
18150
|
-
template: () => {
|
|
18151
|
-
return `
|
|
18152
|
-
import assets from '#nitro/virtual/public-assets-data'
|
|
18153
|
-
export function readAsset (id) {
|
|
18154
|
-
// https://deno.com/deploy/docs/serve-static-assets
|
|
18155
|
-
const path = '.' + decodeURIComponent(new URL(\`../public\${id}\`, 'file://').pathname)
|
|
18156
|
-
return Deno.readFile(path);
|
|
18157
|
-
}`;
|
|
18158
|
-
}
|
|
18159
|
-
},
|
|
18160
|
-
{
|
|
18161
|
-
id: "#nitro/virtual/public-assets-null",
|
|
18162
|
-
template: () => {
|
|
18163
|
-
return `
|
|
18164
|
-
export function readAsset (id) {
|
|
18165
|
-
return Promise.resolve(null);
|
|
18166
|
-
}`;
|
|
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;
|
|
18167
18224
|
}
|
|
18168
|
-
|
|
18169
|
-
|
|
18170
|
-
|
|
18171
|
-
|
|
18172
|
-
|
|
18173
|
-
|
|
18174
|
-
|
|
18175
|
-
|
|
18176
|
-
if (assets[id]._data) { return assets[id]._data }
|
|
18177
|
-
if (!assets[id].data) { return assets[id].data }
|
|
18178
|
-
assets[id]._data = Uint8Array.from(atob(assets[id].data), (c) => c.charCodeAt(0))
|
|
18179
|
-
return assets[id]._data
|
|
18180
|
-
}`;
|
|
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);
|
|
18181
18233
|
}
|
|
18182
|
-
|
|
18183
|
-
|
|
18184
|
-
|
|
18185
|
-
|
|
18186
|
-
|
|
18187
|
-
|
|
18188
|
-
|
|
18189
|
-
|
|
18190
|
-
|
|
18191
|
-
|
|
18192
|
-
|
|
18193
|
-
|
|
18194
|
-
|
|
18195
|
-
|
|
18196
|
-
|
|
18197
|
-
if (nitro.options.dev) return `
|
|
18198
|
-
import { readFile } from 'node:fs/promises';
|
|
18199
|
-
export const rendererTemplate = () => readFile(${JSON.stringify(template)}, "utf8");
|
|
18200
|
-
export const rendererTemplateFile = ${JSON.stringify(template)};
|
|
18201
|
-
export const isStaticTemplate = ${JSON.stringify(nitro.options.renderer?.static)};
|
|
18202
|
-
`;
|
|
18203
|
-
else {
|
|
18204
|
-
const html = await readFile(template, "utf8");
|
|
18205
|
-
if (nitro.options.renderer?.static ?? !hasTemplateSyntax(html)) return `
|
|
18206
|
-
import { HTTPResponse } from "h3";
|
|
18207
|
-
export const rendererTemplate = () => new HTTPResponse(${JSON.stringify(html)}, { headers: { "content-type": "text/html; charset=utf-8" } });
|
|
18208
|
-
`;
|
|
18209
|
-
else return `
|
|
18210
|
-
import { renderToResponse } from 'rendu'
|
|
18211
|
-
import { serverFetch } from 'nitro/app'
|
|
18212
|
-
const template = ${compileTemplateToString(html, { contextKeys: [...RENDER_CONTEXT_KEYS] })};
|
|
18213
|
-
export const rendererTemplate = (request) => renderToResponse(template, { request, context: { serverFetch } })
|
|
18214
|
-
`;
|
|
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;
|
|
18215
18249
|
}
|
|
18216
18250
|
}
|
|
18217
|
-
|
|
18218
|
-
}
|
|
18219
|
-
|
|
18220
|
-
//#endregion
|
|
18221
|
-
//#region src/build/virtual/routing-meta.ts
|
|
18222
|
-
function routingMeta(nitro) {
|
|
18223
|
-
return {
|
|
18224
|
-
id: "#nitro/virtual/routing-meta",
|
|
18225
|
-
template: () => {
|
|
18226
|
-
const routeHandlers = uniqueBy$1(Object.values(nitro.routing.routes.routes).flatMap((h$4) => h$4.data), "_importHash");
|
|
18227
|
-
return `
|
|
18228
|
-
${routeHandlers.map((h$4) => `import ${h$4._importHash}Meta from "${h$4.handler}?meta";`).join("\n")}
|
|
18229
|
-
export const handlersMeta = [
|
|
18230
|
-
${routeHandlers.map((h$4) => `{ route: ${JSON.stringify(h$4.route)}, method: ${JSON.stringify(h$4.method?.toLowerCase())}, meta: ${h$4._importHash}Meta }`).join(",\n")}
|
|
18231
|
-
];
|
|
18232
|
-
`.trim();
|
|
18233
|
-
}
|
|
18234
|
-
};
|
|
18235
|
-
}
|
|
18236
|
-
function uniqueBy$1(arr, key) {
|
|
18237
|
-
return [...new Map(arr.map((item) => [item[key], item])).values()];
|
|
18238
|
-
}
|
|
18239
|
-
|
|
18240
|
-
//#endregion
|
|
18241
|
-
//#region src/build/virtual/routing.ts
|
|
18242
|
-
const RuntimeRouteRules = [
|
|
18243
|
-
"headers",
|
|
18244
|
-
"redirect",
|
|
18245
|
-
"proxy",
|
|
18246
|
-
"cache"
|
|
18247
|
-
];
|
|
18248
|
-
function routing(nitro) {
|
|
18249
|
-
return {
|
|
18250
|
-
id: "#nitro/virtual/routing",
|
|
18251
|
-
template: () => {
|
|
18252
|
-
const allHandlers = uniqueBy([
|
|
18253
|
-
...Object.values(nitro.routing.routes.routes).flatMap((h$4) => h$4.data),
|
|
18254
|
-
...Object.values(nitro.routing.routedMiddleware.routes).map((h$4) => h$4.data),
|
|
18255
|
-
...nitro.routing.globalMiddleware
|
|
18256
|
-
], "_importHash");
|
|
18257
|
-
return `
|
|
18258
|
-
import * as __routeRules__ from "#nitro/runtime/route-rules";
|
|
18259
|
-
import * as srvxNode from "srvx/node"
|
|
18260
|
-
import * as h3 from "h3";
|
|
18261
|
-
|
|
18262
|
-
export const findRouteRules = ${nitro.routing.routeRules.compileToString({
|
|
18263
|
-
serialize: serializeRouteRule,
|
|
18264
|
-
matchAll: true
|
|
18265
|
-
})}
|
|
18266
|
-
|
|
18267
|
-
const multiHandler = (...handlers) => {
|
|
18268
|
-
const final = handlers.pop()
|
|
18269
|
-
const middleware = handlers.filter(Boolean).map(h => h3.toMiddleware(h));
|
|
18270
|
-
return (ev) => h3.callMiddleware(ev, middleware, final);
|
|
18271
|
-
}
|
|
18272
|
-
|
|
18273
|
-
${allHandlers.filter((h$4) => !h$4.lazy).map((h$4) => `import ${h$4._importHash} from "${h$4.handler}";`).join("\n")}
|
|
18274
|
-
|
|
18275
|
-
${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")}
|
|
18276
|
-
|
|
18277
|
-
export const findRoute = ${nitro.routing.routes.compileToString({ serialize: serializeHandler })}
|
|
18278
|
-
|
|
18279
|
-
export const findRoutedMiddleware = ${nitro.routing.routedMiddleware.compileToString({
|
|
18280
|
-
serialize: serializeHandler,
|
|
18281
|
-
matchAll: true
|
|
18282
|
-
})};
|
|
18283
|
-
|
|
18284
|
-
export const globalMiddleware = [
|
|
18285
|
-
${nitro.routing.globalMiddleware.map((h$4) => h$4.lazy ? h$4._importHash : `h3.toEventHandler(${h$4._importHash})`).join(",")}
|
|
18286
|
-
].filter(Boolean);
|
|
18287
|
-
`;
|
|
18288
|
-
}
|
|
18289
|
-
};
|
|
18290
|
-
}
|
|
18291
|
-
function uniqueBy(arr, key) {
|
|
18292
|
-
return [...new Map(arr.map((item) => [item[key], item])).values()];
|
|
18293
|
-
}
|
|
18294
|
-
function serializeHandler(h$4) {
|
|
18295
|
-
const meta = Array.isArray(h$4) ? h$4[0] : h$4;
|
|
18296
|
-
return `{${[
|
|
18297
|
-
`route:${JSON.stringify(meta.route)}`,
|
|
18298
|
-
meta.method && `method:${JSON.stringify(meta.method)}`,
|
|
18299
|
-
meta.meta && `meta:${JSON.stringify(meta.meta)}`,
|
|
18300
|
-
`handler:${Array.isArray(h$4) ? `multiHandler(${h$4.map((handler) => serializeHandlerFn(handler)).join(",")})` : serializeHandlerFn(h$4)}`
|
|
18301
|
-
].filter(Boolean).join(",")}}`;
|
|
18302
|
-
}
|
|
18303
|
-
function serializeHandlerFn(h$4) {
|
|
18304
|
-
let code = h$4._importHash;
|
|
18305
|
-
if (!h$4.lazy) {
|
|
18306
|
-
if (h$4.format === "node") code = `srvxNode.toFetchHandler(${code})`;
|
|
18307
|
-
code = `h3.toEventHandler(${code})`;
|
|
18251
|
+
return node;
|
|
18308
18252
|
}
|
|
18309
|
-
|
|
18310
|
-
}
|
|
18311
|
-
|
|
18312
|
-
|
|
18313
|
-
|
|
18314
|
-
|
|
18315
|
-
|
|
18316
|
-
|
|
18317
|
-
|
|
18318
|
-
|
|
18319
|
-
|
|
18320
|
-
|
|
18321
|
-
|
|
18322
|
-
|
|
18323
|
-
|
|
18324
|
-
//#region src/build/virtual/runtime-config.ts
|
|
18325
|
-
function runtimeConfig(nitro) {
|
|
18326
|
-
return {
|
|
18327
|
-
id: "#nitro/virtual/runtime-config",
|
|
18328
|
-
template: () => {
|
|
18329
|
-
return `export const runtimeConfig = ${JSON.stringify(nitro.options.runtimeConfig || {})};`;
|
|
18330
|
-
}
|
|
18331
|
-
};
|
|
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);
|
|
18332
18268
|
}
|
|
18333
18269
|
|
|
18334
18270
|
//#endregion
|
|
18335
|
-
//#region
|
|
18336
|
-
|
|
18337
|
-
|
|
18338
|
-
|
|
18339
|
-
|
|
18340
|
-
|
|
18341
|
-
|
|
18342
|
-
|
|
18343
|
-
|
|
18344
|
-
|
|
18345
|
-
|
|
18346
|
-
|
|
18347
|
-
|
|
18348
|
-
|
|
18349
|
-
|
|
18350
|
-
|
|
18351
|
-
|
|
18352
|
-
|
|
18353
|
-
|
|
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);
|
|
18354
18332
|
});
|
|
18355
|
-
for (const _id of files) {
|
|
18356
|
-
const fsPath = resolve$3(asset.dir, _id);
|
|
18357
|
-
const id = asset.baseName + "/" + _id;
|
|
18358
|
-
assets[id] = {
|
|
18359
|
-
fsPath,
|
|
18360
|
-
meta: {}
|
|
18361
|
-
};
|
|
18362
|
-
let type$1 = src_default.getType(id) || "text/plain";
|
|
18363
|
-
if (type$1.startsWith("text")) type$1 += "; charset=utf-8";
|
|
18364
|
-
const etag = (0, import_etag.default)(await promises.readFile(fsPath));
|
|
18365
|
-
const mtime = await promises.stat(fsPath).then((s) => s.mtime.toJSON());
|
|
18366
|
-
assets[id].meta = {
|
|
18367
|
-
type: type$1,
|
|
18368
|
-
etag,
|
|
18369
|
-
mtime
|
|
18370
|
-
};
|
|
18371
|
-
}
|
|
18372
18333
|
}
|
|
18373
|
-
|
|
18374
|
-
|
|
18375
|
-
|
|
18376
|
-
|
|
18377
|
-
|
|
18378
|
-
|
|
18379
|
-
|
|
18380
|
-
|
|
18381
|
-
|
|
18382
|
-
|
|
18383
|
-
|
|
18384
|
-
|
|
18385
|
-
|
|
18386
|
-
|
|
18387
|
-
|
|
18388
|
-
|
|
18389
|
-
|
|
18390
|
-
|
|
18391
|
-
|
|
18392
|
-
|
|
18393
|
-
|
|
18394
|
-
|
|
18395
|
-
|
|
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;
|
|
18396
18367
|
}
|
|
18397
|
-
};
|
|
18368
|
+
});
|
|
18369
|
+
return scope;
|
|
18370
|
+
};
|
|
18371
|
+
function isArray(arg) {
|
|
18372
|
+
return Array.isArray(arg);
|
|
18398
18373
|
}
|
|
18399
|
-
|
|
18400
|
-
|
|
18401
|
-
|
|
18402
|
-
|
|
18403
|
-
return {
|
|
18404
|
-
id: "#nitro/virtual/storage",
|
|
18405
|
-
template: () => {
|
|
18406
|
-
const mounts = [];
|
|
18407
|
-
const storageMounts = nitro.options.dev || nitro.options.preset === "nitro-prerender" ? {
|
|
18408
|
-
...nitro.options.storage,
|
|
18409
|
-
...nitro.options.devStorage
|
|
18410
|
-
} : nitro.options.storage;
|
|
18411
|
-
for (const path$2 in storageMounts) {
|
|
18412
|
-
const { driver: driverName, ...driverOpts } = storageMounts[path$2];
|
|
18413
|
-
mounts.push({
|
|
18414
|
-
path: path$2,
|
|
18415
|
-
driver: builtinDrivers[driverName] || driverName,
|
|
18416
|
-
opts: driverOpts
|
|
18417
|
-
});
|
|
18418
|
-
}
|
|
18419
|
-
return `
|
|
18420
|
-
import { createStorage } from 'unstorage'
|
|
18421
|
-
import { assets } from '#nitro/virtual/server-assets'
|
|
18422
|
-
|
|
18423
|
-
${[...new Set(mounts.map((m$3) => m$3.driver))].map((i$2) => genImport(i$2, genSafeVariableName(i$2))).join("\n")}
|
|
18424
|
-
|
|
18425
|
-
export function initStorage() {
|
|
18426
|
-
const storage = createStorage({})
|
|
18427
|
-
storage.mount('/assets', assets)
|
|
18428
|
-
${mounts.map((m$3) => `storage.mount('${m$3.path}', ${genSafeVariableName(m$3.driver)}(${JSON.stringify(m$3.opts)}))`).join("\n")}
|
|
18429
|
-
return storage
|
|
18374
|
+
function ensureArray(thing) {
|
|
18375
|
+
if (isArray(thing)) return thing;
|
|
18376
|
+
if (thing == null) return [];
|
|
18377
|
+
return [thing];
|
|
18430
18378
|
}
|
|
18431
|
-
|
|
18432
|
-
|
|
18433
|
-
|
|
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));
|
|
18434
18387
|
}
|
|
18435
|
-
|
|
18436
|
-
|
|
18437
|
-
|
|
18438
|
-
|
|
18439
|
-
|
|
18440
|
-
|
|
18441
|
-
|
|
18442
|
-
|
|
18443
|
-
|
|
18444
|
-
|
|
18445
|
-
|
|
18446
|
-
|
|
18447
|
-
|
|
18448
|
-
|
|
18449
|
-
|
|
18450
|
-
|
|
18451
|
-
|
|
18452
|
-
|
|
18453
|
-
|
|
18454
|
-
|
|
18455
|
-
return
|
|
18456
|
-
export const scheduledTasks = ${JSON.stringify(scheduledTasks)};
|
|
18457
|
-
|
|
18458
|
-
export const tasks = {
|
|
18459
|
-
${Object.entries(nitro.options.tasks).map(([name, task]) => `"${name}": {
|
|
18460
|
-
meta: {
|
|
18461
|
-
description: ${JSON.stringify(task.description)},
|
|
18462
|
-
},
|
|
18463
|
-
resolve: ${task.handler ? `() => import("${normalize$2(task.handler)}").then(r => r.default || r)` : "undefined"},
|
|
18464
|
-
}`).join(",\n")}
|
|
18465
|
-
};`;
|
|
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;
|
|
18466
18409
|
}
|
|
18410
|
+
return !includeMatchers.length;
|
|
18467
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)}`);
|
|
18468
18422
|
}
|
|
18469
|
-
|
|
18470
|
-
|
|
18471
|
-
|
|
18472
|
-
|
|
18473
|
-
|
|
18474
|
-
|
|
18475
|
-
|
|
18476
|
-
|
|
18477
|
-
|
|
18478
|
-
|
|
18479
|
-
|
|
18480
|
-
|
|
18481
|
-
|
|
18482
|
-
|
|
18483
|
-
|
|
18484
|
-
|
|
18485
|
-
|
|
18486
|
-
|
|
18487
|
-
|
|
18488
|
-
|
|
18489
|
-
|
|
18490
|
-
|
|
18491
|
-
|
|
18492
|
-
|
|
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);
|
|
18493
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
|
+
};
|
|
18494
18503
|
|
|
18495
18504
|
//#endregion
|
|
18496
18505
|
//#region node_modules/.pnpm/@rollup+plugin-replace@6.0.3_rollup@4.55.2/node_modules/@rollup/plugin-replace/dist/es/index.js
|
|
@@ -24928,4 +24937,4 @@ function oxc(options) {
|
|
|
24928
24937
|
}
|
|
24929
24938
|
|
|
24930
24939
|
//#endregion
|
|
24931
|
-
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 _,
|
|
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 };
|