nitro-nightly 3.1.0-20251028-004953-57503e42 → 3.1.0-20251028-110430-e607b753
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/assets.mjs +235 -0
- package/dist/_build/build.mjs +21 -0
- package/dist/_build/config.mjs +124 -0
- package/dist/_build/info.mjs +39 -0
- package/dist/_build/plugins.mjs +1041 -0
- package/dist/_build/prepare.mjs +17 -0
- package/dist/{_chunks/build2.mjs → _build/rolldown.mjs} +238 -64
- package/dist/_build/rollup.mjs +404 -0
- package/dist/_build/snapshot.mjs +61 -0
- package/dist/_build/types.mjs +268 -0
- package/dist/_build/vite.mjs +3266 -0
- package/dist/{cli → _cli}/build.mjs +2 -3
- package/dist/_cli/dev.mjs +205 -0
- package/dist/{cli/index2.mjs → _cli/index.mjs} +1 -2
- package/dist/{cli → _cli}/list.mjs +2 -3
- package/dist/{cli → _cli}/prepare.mjs +2 -3
- package/dist/{cli → _cli}/run.mjs +2 -3
- package/dist/_deps/@jridgewell/gen-mapping.mjs +189 -0
- package/dist/_deps/@jridgewell/remapping.mjs +137 -0
- package/dist/_deps/@jridgewell/resolve-uri.mjs +231 -0
- package/dist/_deps/@jridgewell/sourcemap-codec.mjs +173 -0
- package/dist/_deps/@jridgewell/trace-mapping.mjs +170 -0
- package/dist/_deps/@pi0/vite-plugin-fullstack.mjs +575 -0
- package/dist/_deps/@rollup/plugin-alias.mjs +89 -0
- package/dist/_deps/@rollup/plugin-commonjs.mjs +2376 -0
- package/dist/{_chunks/index2.mjs → _deps/@rollup/plugin-inject.mjs} +5 -90
- package/dist/_deps/@rollup/plugin-json.mjs +37 -0
- package/dist/_deps/@rollup/plugin-node-resolve.mjs +1386 -0
- package/dist/_deps/@rollup/plugin-replace.mjs +133 -0
- package/dist/_deps/@rollup/pluginutils.mjs +346 -0
- package/dist/_deps/acorn.mjs +6225 -0
- package/dist/_deps/c12.mjs +510 -0
- package/dist/_deps/chokidar.mjs +1428 -0
- package/dist/_deps/citty.mjs +460 -0
- package/dist/_deps/commondir.mjs +77 -0
- package/dist/_deps/compatx.mjs +76 -0
- package/dist/_deps/confbox.mjs +300 -0
- package/dist/_deps/debug.mjs +885 -0
- package/dist/_deps/deepmerge.mjs +147 -0
- package/dist/_deps/depd.mjs +550 -0
- package/dist/_deps/dot-prop.mjs +282 -0
- package/dist/_deps/dotenv.mjs +555 -0
- package/dist/_deps/duplexer.mjs +1 -0
- package/dist/_deps/ee-first.mjs +104 -0
- package/dist/_deps/encodeurl.mjs +69 -0
- package/dist/_deps/escape-html.mjs +87 -0
- package/dist/_deps/escape-string-regexp.mjs +13 -0
- package/dist/_deps/estree-walker.mjs +433 -0
- package/dist/_deps/etag.mjs +147 -0
- package/dist/_deps/exsolve.mjs +1416 -0
- package/dist/_deps/fdir.mjs +569 -0
- package/dist/_deps/fresh.mjs +145 -0
- package/dist/_deps/function-bind.mjs +106 -0
- package/dist/{_chunks/index4.mjs → _deps/giget.mjs} +21 -776
- package/dist/_deps/gzip-size.mjs +19 -0
- package/dist/_deps/hasown.mjs +19 -0
- package/dist/_deps/http-errors.mjs +307 -0
- package/dist/_deps/httpxy.mjs +580 -0
- package/dist/_deps/inherits.mjs +57 -0
- package/dist/_deps/is-core-module.mjs +596 -0
- package/dist/_deps/is-module.mjs +25 -0
- package/dist/_deps/is-reference.mjs +31 -0
- package/dist/_deps/js-tokens.mjs +411 -0
- package/dist/_deps/knitwork.mjs +172 -0
- package/dist/_deps/local-pkg.mjs +163 -0
- package/dist/_deps/magic-string.mjs +1296 -0
- package/dist/_deps/mime-db.mjs +11685 -0
- package/dist/_deps/mime-types.mjs +287 -0
- package/dist/_deps/mime.mjs +1172 -0
- package/dist/_deps/mlly.mjs +2413 -0
- package/dist/_deps/ms.mjs +172 -0
- package/dist/_deps/node-fetch-native.mjs +3 -0
- package/dist/_deps/nypm.mjs +219 -0
- package/dist/_deps/on-finished.mjs +246 -0
- package/dist/_deps/parseurl.mjs +168 -0
- package/dist/_deps/path-parse.mjs +85 -0
- package/dist/{_chunks/pathe.M-eThtNZ.mjs → _deps/pathe.mjs} +48 -1
- package/dist/_deps/perfect-debounce.mjs +88 -0
- package/dist/_deps/picomatch.mjs +2144 -0
- package/dist/_deps/pkg-types.mjs +247 -0
- package/dist/_deps/pretty-bytes.mjs +180 -0
- package/dist/_deps/quansync.mjs +99 -0
- package/dist/_deps/range-parser.mjs +171 -0
- package/dist/_deps/rc9.mjs +219 -0
- package/dist/_deps/readdirp.mjs +245 -0
- package/dist/_deps/resolve.mjs +1260 -0
- package/dist/_deps/rou3.mjs +326 -0
- package/dist/_deps/send.mjs +1022 -0
- package/dist/_deps/serve-static.mjs +228 -0
- package/dist/_deps/setprototypeof.mjs +26 -0
- package/dist/_deps/statuses.mjs +457 -0
- package/dist/_deps/strip-literal.mjs +67 -0
- package/dist/_deps/supports-color.mjs +44 -0
- package/dist/_deps/tinyexec.mjs +552 -0
- package/dist/_deps/tinyglobby.mjs +293 -0
- package/dist/_deps/toidentifier.mjs +41 -0
- package/dist/_deps/ultrahtml.mjs +3 -0
- package/dist/_deps/unimport.mjs +2267 -0
- package/dist/_deps/unplugin-utils.mjs +65 -0
- package/dist/_deps/unplugin.mjs +1294 -0
- package/dist/_deps/untyped.mjs +375 -0
- package/dist/{_chunks/info.mjs → _deps/unwasm.mjs} +8 -4122
- package/dist/_deps/webpack-virtual-modules.mjs +360 -0
- package/dist/_presets/_all.mjs +59 -0
- package/dist/_presets/_nitro.mjs +74 -0
- package/dist/_presets/_resolve.mjs +64 -0
- package/dist/_presets/_static.mjs +69 -0
- package/dist/_presets/_types.mjs +3 -0
- package/dist/_presets/_utils.mjs +31 -0
- package/dist/_presets/alwaysdata.mjs +17 -0
- package/dist/_presets/aws-amplify.mjs +111 -0
- package/dist/_presets/aws-lambda.mjs +23 -0
- package/dist/_presets/azure.mjs +162 -0
- package/dist/_presets/bun.mjs +19 -0
- package/dist/_presets/cleavr.mjs +15 -0
- package/dist/_presets/cloudflare.mjs +608 -0
- package/dist/_presets/deno.mjs +196 -0
- package/dist/_presets/digitalocean.mjs +14 -0
- package/dist/_presets/firebase.mjs +47 -0
- package/dist/_presets/flightcontrol.mjs +14 -0
- package/dist/_presets/genezio.mjs +13 -0
- package/dist/_presets/heroku.mjs +14 -0
- package/dist/_presets/iis.mjs +194 -0
- package/dist/_presets/index.mjs +62 -0
- package/dist/_presets/koyeb.mjs +14 -0
- package/dist/_presets/netlify.mjs +241 -0
- package/dist/_presets/node.mjs +54 -0
- package/dist/_presets/platform.mjs +14 -0
- package/dist/_presets/render.mjs +14 -0
- package/dist/_presets/standard.mjs +23 -0
- package/dist/_presets/stormkit.mjs +18 -0
- package/dist/_presets/vercel.mjs +365 -0
- package/dist/_presets/winterjs.mjs +22 -0
- package/dist/_presets/zeabur.mjs +69 -0
- package/dist/_presets/zerops.mjs +27 -0
- package/dist/cli/index.mjs +7 -464
- package/dist/index.mjs +122 -34
- package/dist/vite.mjs +118 -44
- package/package.json +1 -1
- package/dist/_chunks/app.mjs +0 -19797
- package/dist/_chunks/build.mjs +0 -86
- package/dist/_chunks/build3.mjs +0 -6538
- package/dist/_chunks/detect-acorn.mjs +0 -503
- package/dist/_chunks/index.mjs +0 -22256
- package/dist/_chunks/index3.mjs +0 -1062
- package/dist/_chunks/json5.mjs +0 -68
- package/dist/_chunks/jsonc.mjs +0 -51
- package/dist/_chunks/plugin.mjs +0 -1560
- package/dist/_chunks/server.mjs +0 -254
- package/dist/_chunks/snapshot.mjs +0 -376
- package/dist/_chunks/toml.mjs +0 -259
- package/dist/_chunks/yaml.mjs +0 -86
- package/dist/cli/dev.mjs +0 -95
- package/dist/presets.mjs +0 -2494
- /package/dist/{cli → _cli}/common.mjs +0 -0
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
import { w as writeFile, d as defineNitroPreset } from './_utils.mjs';
|
|
2
|
+
import fsp from 'node:fs/promises';
|
|
3
|
+
import { defu } from 'defu';
|
|
4
|
+
import { joinURL, withoutLeadingSlash, withLeadingSlash } from 'ufo';
|
|
5
|
+
import { isTest } from 'std-env';
|
|
6
|
+
import { a as resolve, d as dirname, r as relative } from '../_deps/pathe.mjs';
|
|
7
|
+
|
|
8
|
+
const SUPPORTED_NODE_VERSIONS = [20, 22];
|
|
9
|
+
const FALLBACK_ROUTE = "/__fallback";
|
|
10
|
+
const ISR_SUFFIX = "-isr";
|
|
11
|
+
const SAFE_FS_CHAR_RE = /[^a-zA-Z0-9_.[\]/]/g;
|
|
12
|
+
function getSystemNodeVersion() {
|
|
13
|
+
const systemNodeVersion = Number.parseInt(
|
|
14
|
+
process.versions.node.split(".")[0]
|
|
15
|
+
);
|
|
16
|
+
return Number.isNaN(systemNodeVersion) ? 22 : systemNodeVersion;
|
|
17
|
+
}
|
|
18
|
+
async function generateFunctionFiles(nitro) {
|
|
19
|
+
const o11Routes = getObservabilityRoutes(nitro);
|
|
20
|
+
const buildConfigPath = resolve(nitro.options.output.dir, "config.json");
|
|
21
|
+
const buildConfig = generateBuildConfig(nitro, o11Routes);
|
|
22
|
+
await writeFile(buildConfigPath, JSON.stringify(buildConfig, null, 2));
|
|
23
|
+
let runtime = nitro.options.vercel?.functions?.runtime;
|
|
24
|
+
if (!runtime) {
|
|
25
|
+
const vercelConfig = await readVercelConfig(nitro.options.rootDir);
|
|
26
|
+
if (vercelConfig.bunVersion || "Bun" in globalThis) {
|
|
27
|
+
runtime = `bun${vercelConfig.bunVersion || "1.x"}`;
|
|
28
|
+
} else {
|
|
29
|
+
const systemNodeVersion = getSystemNodeVersion();
|
|
30
|
+
const usedNodeVersion = SUPPORTED_NODE_VERSIONS.find(
|
|
31
|
+
(version) => version >= systemNodeVersion
|
|
32
|
+
) ?? SUPPORTED_NODE_VERSIONS.at(-1);
|
|
33
|
+
runtime = `nodejs${usedNodeVersion}.x`;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
const functionConfigPath = resolve(
|
|
37
|
+
nitro.options.output.serverDir,
|
|
38
|
+
".vc-config.json"
|
|
39
|
+
);
|
|
40
|
+
const functionConfig = {
|
|
41
|
+
runtime,
|
|
42
|
+
...nitro.options.vercel?.functions,
|
|
43
|
+
handler: "index.mjs",
|
|
44
|
+
launcherType: "Nodejs",
|
|
45
|
+
shouldAddHelpers: false,
|
|
46
|
+
supportsResponseStreaming: true
|
|
47
|
+
};
|
|
48
|
+
await writeFile(functionConfigPath, JSON.stringify(functionConfig, null, 2));
|
|
49
|
+
for (const [key, value] of Object.entries(nitro.options.routeRules)) {
|
|
50
|
+
if (!value.isr) {
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
const funcPrefix = resolve(
|
|
54
|
+
nitro.options.output.serverDir,
|
|
55
|
+
"..",
|
|
56
|
+
normalizeRouteDest(key) + ISR_SUFFIX
|
|
57
|
+
);
|
|
58
|
+
await fsp.mkdir(dirname(funcPrefix), { recursive: true });
|
|
59
|
+
await fsp.symlink(
|
|
60
|
+
"./" + relative(dirname(funcPrefix), nitro.options.output.serverDir),
|
|
61
|
+
funcPrefix + ".func",
|
|
62
|
+
"junction"
|
|
63
|
+
);
|
|
64
|
+
await writePrerenderConfig(
|
|
65
|
+
funcPrefix + ".prerender-config.json",
|
|
66
|
+
value.isr,
|
|
67
|
+
nitro.options.vercel?.config?.bypassToken
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
if (o11Routes.length === 0) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
const _getRouteRules = (path) => defu(
|
|
74
|
+
{},
|
|
75
|
+
...nitro.routing.routeRules.matchAll("", path).reverse()
|
|
76
|
+
);
|
|
77
|
+
for (const route of o11Routes) {
|
|
78
|
+
const routeRules = _getRouteRules(route.src);
|
|
79
|
+
if (routeRules.isr) {
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
const funcPrefix = resolve(
|
|
83
|
+
nitro.options.output.serverDir,
|
|
84
|
+
"..",
|
|
85
|
+
route.dest
|
|
86
|
+
);
|
|
87
|
+
await fsp.mkdir(dirname(funcPrefix), { recursive: true });
|
|
88
|
+
await fsp.symlink(
|
|
89
|
+
"./" + relative(dirname(funcPrefix), nitro.options.output.serverDir),
|
|
90
|
+
funcPrefix + ".func",
|
|
91
|
+
"junction"
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
async function generateStaticFiles(nitro) {
|
|
96
|
+
const buildConfigPath = resolve(nitro.options.output.dir, "config.json");
|
|
97
|
+
const buildConfig = generateBuildConfig(nitro);
|
|
98
|
+
await writeFile(buildConfigPath, JSON.stringify(buildConfig, null, 2));
|
|
99
|
+
}
|
|
100
|
+
function generateBuildConfig(nitro, o11Routes) {
|
|
101
|
+
const rules = Object.entries(nitro.options.routeRules).sort(
|
|
102
|
+
(a, b) => b[0].split(/\/(?!\*)/).length - a[0].split(/\/(?!\*)/).length
|
|
103
|
+
);
|
|
104
|
+
const config = defu(nitro.options.vercel?.config, {
|
|
105
|
+
version: 3,
|
|
106
|
+
overrides: {
|
|
107
|
+
// Nitro static prerendered route overrides
|
|
108
|
+
...Object.fromEntries(
|
|
109
|
+
(nitro._prerenderedRoutes?.filter((r) => r.fileName !== r.route) || []).map(({ route, fileName }) => [
|
|
110
|
+
withoutLeadingSlash(fileName),
|
|
111
|
+
{ path: route.replace(/^\//, "") }
|
|
112
|
+
])
|
|
113
|
+
)
|
|
114
|
+
},
|
|
115
|
+
routes: [
|
|
116
|
+
// Redirect and header rules
|
|
117
|
+
...rules.filter(([_, routeRules]) => routeRules.redirect || routeRules.headers).map(([path, routeRules]) => {
|
|
118
|
+
let route = {
|
|
119
|
+
src: path.replace("/**", "/(.*)")
|
|
120
|
+
};
|
|
121
|
+
if (routeRules.redirect) {
|
|
122
|
+
route = defu(route, {
|
|
123
|
+
status: routeRules.redirect.status,
|
|
124
|
+
headers: {
|
|
125
|
+
Location: routeRules.redirect.to.replace("/**", "/$1")
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
if (routeRules.headers) {
|
|
130
|
+
route = defu(route, { headers: routeRules.headers });
|
|
131
|
+
}
|
|
132
|
+
return route;
|
|
133
|
+
}),
|
|
134
|
+
// Public asset rules
|
|
135
|
+
...nitro.options.publicAssets.filter((asset) => !asset.fallthrough).map((asset) => joinURL(nitro.options.baseURL, asset.baseURL || "/")).map((baseURL) => ({
|
|
136
|
+
src: baseURL + "(.*)",
|
|
137
|
+
headers: {
|
|
138
|
+
"cache-control": "public,max-age=31536000,immutable"
|
|
139
|
+
},
|
|
140
|
+
continue: true
|
|
141
|
+
})),
|
|
142
|
+
{ handle: "filesystem" }
|
|
143
|
+
]
|
|
144
|
+
});
|
|
145
|
+
if (nitro.options.static) {
|
|
146
|
+
return config;
|
|
147
|
+
}
|
|
148
|
+
config.routes.push(
|
|
149
|
+
...nitro.options.routeRules["/"]?.isr ? [
|
|
150
|
+
{
|
|
151
|
+
src: "(?<url>/)",
|
|
152
|
+
dest: `/index${ISR_SUFFIX}?url=$url`
|
|
153
|
+
}
|
|
154
|
+
] : [],
|
|
155
|
+
...rules.filter(([key, value]) => value.isr !== void 0 && key !== "/").map(([key, value]) => {
|
|
156
|
+
const src = key.replace(/^(.*)\/\*\*/, "(?<url>$1/.*)");
|
|
157
|
+
if (value.isr === false) {
|
|
158
|
+
return {
|
|
159
|
+
src,
|
|
160
|
+
dest: FALLBACK_ROUTE
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
return {
|
|
164
|
+
src,
|
|
165
|
+
dest: withLeadingSlash(
|
|
166
|
+
normalizeRouteDest(key) + ISR_SUFFIX + "?url=$url"
|
|
167
|
+
)
|
|
168
|
+
};
|
|
169
|
+
}),
|
|
170
|
+
...(o11Routes || []).map((route) => ({
|
|
171
|
+
src: joinURL(nitro.options.baseURL, route.src),
|
|
172
|
+
dest: withLeadingSlash(route.dest)
|
|
173
|
+
})),
|
|
174
|
+
...nitro.options.routeRules["/**"]?.isr ? [] : [
|
|
175
|
+
{
|
|
176
|
+
src: "/(.*)",
|
|
177
|
+
dest: FALLBACK_ROUTE
|
|
178
|
+
}
|
|
179
|
+
]
|
|
180
|
+
);
|
|
181
|
+
return config;
|
|
182
|
+
}
|
|
183
|
+
function deprecateSWR(nitro) {
|
|
184
|
+
if (nitro.options.future.nativeSWR) {
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
let hasLegacyOptions = false;
|
|
188
|
+
for (const [key, value] of Object.entries(nitro.options.routeRules)) {
|
|
189
|
+
if (_hasProp(value, "isr")) {
|
|
190
|
+
continue;
|
|
191
|
+
}
|
|
192
|
+
if (value.cache === false) {
|
|
193
|
+
value.isr = false;
|
|
194
|
+
}
|
|
195
|
+
if (_hasProp(value, "static")) {
|
|
196
|
+
value.isr = !value.static;
|
|
197
|
+
hasLegacyOptions = true;
|
|
198
|
+
}
|
|
199
|
+
if (value.cache && _hasProp(value.cache, "swr")) {
|
|
200
|
+
value.isr = value.cache.swr;
|
|
201
|
+
hasLegacyOptions = true;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
if (hasLegacyOptions && !isTest) {
|
|
205
|
+
nitro.logger.warn(
|
|
206
|
+
"Nitro now uses `isr` option to configure ISR behavior on Vercel. Backwards-compatible support for `static` and `swr` options within the Vercel Build Options API will be removed in the future versions. Set `future.nativeSWR: true` nitro config disable this warning."
|
|
207
|
+
);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
async function readVercelConfig(rootDir) {
|
|
211
|
+
const vercelConfigPath = resolve(rootDir, "vercel.json");
|
|
212
|
+
const vercelConfig = await fsp.readFile(vercelConfigPath).then((config) => JSON.parse(config.toString())).catch(() => ({}));
|
|
213
|
+
return vercelConfig;
|
|
214
|
+
}
|
|
215
|
+
function _hasProp(obj, prop) {
|
|
216
|
+
return obj && typeof obj === "object" && prop in obj;
|
|
217
|
+
}
|
|
218
|
+
function getObservabilityRoutes(nitro) {
|
|
219
|
+
const compatDate = nitro.options.compatibilityDate.vercel || nitro.options.compatibilityDate.default;
|
|
220
|
+
if (compatDate < "2025-07-15") {
|
|
221
|
+
return [];
|
|
222
|
+
}
|
|
223
|
+
const routePatterns = [
|
|
224
|
+
.../* @__PURE__ */ new Set([
|
|
225
|
+
...nitro.options.ssrRoutes || [],
|
|
226
|
+
...[...nitro.scannedHandlers, ...nitro.options.handlers].filter((h) => !h.middleware && h.route).map((h) => h.route)
|
|
227
|
+
])
|
|
228
|
+
];
|
|
229
|
+
const staticRoutes = [];
|
|
230
|
+
const dynamicRoutes = [];
|
|
231
|
+
const catchAllRoutes = [];
|
|
232
|
+
for (const route of routePatterns) {
|
|
233
|
+
if (route.includes("**")) {
|
|
234
|
+
catchAllRoutes.push(route);
|
|
235
|
+
} else if (route.includes(":") || route.includes("*")) {
|
|
236
|
+
dynamicRoutes.push(route);
|
|
237
|
+
} else {
|
|
238
|
+
staticRoutes.push(route);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
return [
|
|
242
|
+
...normalizeRoutes(staticRoutes),
|
|
243
|
+
...normalizeRoutes(dynamicRoutes),
|
|
244
|
+
...normalizeRoutes(catchAllRoutes)
|
|
245
|
+
];
|
|
246
|
+
}
|
|
247
|
+
function normalizeRoutes(routes) {
|
|
248
|
+
return routes.sort(
|
|
249
|
+
(a, b) => (
|
|
250
|
+
// a.split("/").length - b.split("/").length ||
|
|
251
|
+
b.localeCompare(a)
|
|
252
|
+
)
|
|
253
|
+
).map((route) => ({
|
|
254
|
+
src: normalizeRouteSrc(route),
|
|
255
|
+
dest: normalizeRouteDest(route)
|
|
256
|
+
}));
|
|
257
|
+
}
|
|
258
|
+
function normalizeRouteSrc(route) {
|
|
259
|
+
let idCtr = 0;
|
|
260
|
+
return route.split("/").map((segment) => {
|
|
261
|
+
if (segment.startsWith("**")) {
|
|
262
|
+
return segment === "**" ? "(?:.*)" : `?(?<${namedGroup(segment.slice(3))}>.+)`;
|
|
263
|
+
}
|
|
264
|
+
if (segment === "*") {
|
|
265
|
+
return `(?<_${idCtr++}>[^/]*)`;
|
|
266
|
+
}
|
|
267
|
+
if (segment.includes(":")) {
|
|
268
|
+
return segment.replace(/:(\w+)/g, (_, id) => `(?<${namedGroup(id)}>[^/]+)`).replace(/\./g, String.raw`\.`);
|
|
269
|
+
}
|
|
270
|
+
return segment;
|
|
271
|
+
}).join("/");
|
|
272
|
+
}
|
|
273
|
+
function namedGroup(input = "") {
|
|
274
|
+
if (/\d/.test(input[0])) {
|
|
275
|
+
input = `_${input}`;
|
|
276
|
+
}
|
|
277
|
+
return input.replace(/[^a-zA-Z0-9_]/g, "") || "_";
|
|
278
|
+
}
|
|
279
|
+
function normalizeRouteDest(route) {
|
|
280
|
+
return route.split("/").slice(1).map((segment) => {
|
|
281
|
+
if (segment.startsWith("**")) {
|
|
282
|
+
return `[...${segment.replace(/[*:]/g, "")}]`;
|
|
283
|
+
}
|
|
284
|
+
if (segment === "*") {
|
|
285
|
+
return "[-]";
|
|
286
|
+
}
|
|
287
|
+
if (segment.startsWith(":")) {
|
|
288
|
+
return `[${segment.slice(1)}]`;
|
|
289
|
+
}
|
|
290
|
+
if (segment.includes(":")) {
|
|
291
|
+
return `[${segment.replace(/:/g, "_")}]`;
|
|
292
|
+
}
|
|
293
|
+
return segment;
|
|
294
|
+
}).map((segment) => segment.replace(SAFE_FS_CHAR_RE, "-")).join("/") || "index";
|
|
295
|
+
}
|
|
296
|
+
async function writePrerenderConfig(filename, isrConfig, bypassToken) {
|
|
297
|
+
if (typeof isrConfig === "number") {
|
|
298
|
+
isrConfig = { expiration: isrConfig };
|
|
299
|
+
} else if (isrConfig === true) {
|
|
300
|
+
isrConfig = { expiration: false };
|
|
301
|
+
} else {
|
|
302
|
+
isrConfig = { ...isrConfig };
|
|
303
|
+
}
|
|
304
|
+
const prerenderConfig = {
|
|
305
|
+
expiration: isrConfig.expiration ?? false,
|
|
306
|
+
bypassToken,
|
|
307
|
+
...isrConfig
|
|
308
|
+
};
|
|
309
|
+
await writeFile(filename, JSON.stringify(prerenderConfig, null, 2));
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
const vercel = defineNitroPreset(
|
|
313
|
+
{
|
|
314
|
+
entry: "./vercel/runtime/vercel",
|
|
315
|
+
output: {
|
|
316
|
+
dir: "{{ rootDir }}/.vercel/output",
|
|
317
|
+
serverDir: "{{ output.dir }}/functions/__fallback.func",
|
|
318
|
+
publicDir: "{{ output.dir }}/static/{{ baseURL }}"
|
|
319
|
+
},
|
|
320
|
+
commands: {
|
|
321
|
+
deploy: "",
|
|
322
|
+
preview: ""
|
|
323
|
+
},
|
|
324
|
+
hooks: {
|
|
325
|
+
"rollup:before": (nitro) => {
|
|
326
|
+
deprecateSWR(nitro);
|
|
327
|
+
},
|
|
328
|
+
async compiled(nitro) {
|
|
329
|
+
await generateFunctionFiles(nitro);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
},
|
|
333
|
+
{
|
|
334
|
+
name: "vercel",
|
|
335
|
+
stdName: "vercel"
|
|
336
|
+
}
|
|
337
|
+
);
|
|
338
|
+
const vercelStatic = defineNitroPreset(
|
|
339
|
+
{
|
|
340
|
+
extends: "static",
|
|
341
|
+
output: {
|
|
342
|
+
dir: "{{ rootDir }}/.vercel/output",
|
|
343
|
+
publicDir: "{{ output.dir }}/static/{{ baseURL }}"
|
|
344
|
+
},
|
|
345
|
+
commands: {
|
|
346
|
+
preview: "npx serve ./static"
|
|
347
|
+
},
|
|
348
|
+
hooks: {
|
|
349
|
+
"rollup:before": (nitro) => {
|
|
350
|
+
deprecateSWR(nitro);
|
|
351
|
+
},
|
|
352
|
+
async compiled(nitro) {
|
|
353
|
+
await generateStaticFiles(nitro);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
},
|
|
357
|
+
{
|
|
358
|
+
name: "vercel-static",
|
|
359
|
+
stdName: "vercel",
|
|
360
|
+
static: true
|
|
361
|
+
}
|
|
362
|
+
);
|
|
363
|
+
const _vercel = [vercel, vercelStatic];
|
|
364
|
+
|
|
365
|
+
export { _vercel as _ };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { d as defineNitroPreset } from './_utils.mjs';
|
|
2
|
+
|
|
3
|
+
const winterjs = defineNitroPreset(
|
|
4
|
+
{
|
|
5
|
+
extends: "base-worker",
|
|
6
|
+
entry: "./winterjs/runtime/winterjs",
|
|
7
|
+
minify: false,
|
|
8
|
+
serveStatic: "inline",
|
|
9
|
+
wasm: {
|
|
10
|
+
lazy: true
|
|
11
|
+
},
|
|
12
|
+
commands: {
|
|
13
|
+
preview: "wasmer run wasmer/winterjs --forward-host-env --net --mapdir app:./ app/server/index.mjs"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
name: "winterjs"
|
|
18
|
+
}
|
|
19
|
+
);
|
|
20
|
+
const _winterjs = [winterjs];
|
|
21
|
+
|
|
22
|
+
export { _winterjs as _ };
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import fsp from 'node:fs/promises';
|
|
2
|
+
import { d as defineNitroPreset, w as writeFile } from './_utils.mjs';
|
|
3
|
+
import { a as resolve, d as dirname, r as relative } from '../_deps/pathe.mjs';
|
|
4
|
+
|
|
5
|
+
const zeabur = defineNitroPreset(
|
|
6
|
+
{
|
|
7
|
+
entry: "./zeabur/runtime/zeabur",
|
|
8
|
+
output: {
|
|
9
|
+
dir: "{{ rootDir }}/.zeabur/output",
|
|
10
|
+
serverDir: "{{ output.dir }}/functions/__nitro.func",
|
|
11
|
+
publicDir: "{{ output.dir }}/static"
|
|
12
|
+
},
|
|
13
|
+
hooks: {
|
|
14
|
+
async compiled(nitro) {
|
|
15
|
+
const buildConfigPath = resolve(
|
|
16
|
+
nitro.options.output.dir,
|
|
17
|
+
"config.json"
|
|
18
|
+
);
|
|
19
|
+
const cfg = {
|
|
20
|
+
containerized: false,
|
|
21
|
+
routes: [{ src: ".*", dest: "/__nitro" }]
|
|
22
|
+
};
|
|
23
|
+
await writeFile(buildConfigPath, JSON.stringify(cfg, null, 2));
|
|
24
|
+
for (const [key, value] of Object.entries(nitro.options.routeRules)) {
|
|
25
|
+
if (!value.isr) {
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
const funcPrefix = resolve(
|
|
29
|
+
nitro.options.output.serverDir,
|
|
30
|
+
".." + key
|
|
31
|
+
);
|
|
32
|
+
await fsp.mkdir(dirname(funcPrefix), { recursive: true });
|
|
33
|
+
await fsp.symlink(
|
|
34
|
+
"./" + relative(dirname(funcPrefix), nitro.options.output.serverDir),
|
|
35
|
+
funcPrefix + ".func",
|
|
36
|
+
"junction"
|
|
37
|
+
);
|
|
38
|
+
await writeFile(
|
|
39
|
+
funcPrefix + ".prerender-config.json",
|
|
40
|
+
JSON.stringify({ type: "Prerender" })
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
name: "zeabur",
|
|
48
|
+
stdName: "zeabur"
|
|
49
|
+
}
|
|
50
|
+
);
|
|
51
|
+
const zeaburStatic = defineNitroPreset(
|
|
52
|
+
{
|
|
53
|
+
extends: "static",
|
|
54
|
+
output: {
|
|
55
|
+
dir: "{{ rootDir }}/.zeabur/output",
|
|
56
|
+
publicDir: "{{ output.dir }}/static"
|
|
57
|
+
},
|
|
58
|
+
commands: {
|
|
59
|
+
preview: "npx serve ./static"
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
name: "zeabur-static",
|
|
64
|
+
static: true
|
|
65
|
+
}
|
|
66
|
+
);
|
|
67
|
+
const _zeabur = [zeabur, zeaburStatic];
|
|
68
|
+
|
|
69
|
+
export { _zeabur as _ };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { d as defineNitroPreset } from './_utils.mjs';
|
|
2
|
+
|
|
3
|
+
const zerops = defineNitroPreset(
|
|
4
|
+
{
|
|
5
|
+
extends: "node-server",
|
|
6
|
+
serveStatic: true
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
name: "zerops"
|
|
10
|
+
}
|
|
11
|
+
);
|
|
12
|
+
const zeropsStatic = defineNitroPreset(
|
|
13
|
+
{
|
|
14
|
+
extends: "static",
|
|
15
|
+
output: {
|
|
16
|
+
dir: "{{ rootDir }}/.zerops/output",
|
|
17
|
+
publicDir: "{{ output.dir }}/static"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
name: "zerops-static",
|
|
22
|
+
static: true
|
|
23
|
+
}
|
|
24
|
+
);
|
|
25
|
+
const _zerops = [zerops, zeropsStatic];
|
|
26
|
+
|
|
27
|
+
export { _zerops as _ };
|