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,268 @@
|
|
|
1
|
+
import { existsSync, promises } from 'node:fs';
|
|
2
|
+
import { defu } from 'defu';
|
|
3
|
+
import { p as parseNodeModulePath, l as lookupNodeModuleSubpath } from '../_deps/mlly.mjs';
|
|
4
|
+
import { r as resolveModulePath } from '../_deps/exsolve.mjs';
|
|
5
|
+
import { r as resolveNitroPath, i as isDirectory, w as writeFile } from './assets.mjs';
|
|
6
|
+
import { runtimeDir } from 'nitro/runtime/meta';
|
|
7
|
+
import { a as resolve, r as relative, b as resolveAlias, i as isAbsolute, j as join, d as dirname } from '../_deps/pathe.mjs';
|
|
8
|
+
import { g as generateTypes, r as resolveSchema } from '../_deps/untyped.mjs';
|
|
9
|
+
import { t as toExports } from '../_deps/unimport.mjs';
|
|
10
|
+
|
|
11
|
+
async function writeTypes(nitro) {
|
|
12
|
+
const types = {
|
|
13
|
+
routes: {}
|
|
14
|
+
};
|
|
15
|
+
const typesDir = resolve(nitro.options.buildDir, "types");
|
|
16
|
+
const middleware = [...nitro.scannedHandlers, ...nitro.options.handlers];
|
|
17
|
+
for (const mw of middleware) {
|
|
18
|
+
if (typeof mw.handler !== "string" || !mw.route) {
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
const relativePath = relative(
|
|
22
|
+
typesDir,
|
|
23
|
+
resolveNitroPath(mw.handler, nitro.options)
|
|
24
|
+
).replace(/\.(js|mjs|cjs|ts|mts|cts|tsx|jsx)$/, "");
|
|
25
|
+
const method = mw.method || "default";
|
|
26
|
+
types.routes[mw.route] ??= {};
|
|
27
|
+
types.routes[mw.route][method] ??= [];
|
|
28
|
+
types.routes[mw.route][method].push(
|
|
29
|
+
`Simplify<Serialize<Awaited<ReturnType<typeof import('${relativePath}').default>>>>`
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
let autoImportedTypes = [];
|
|
33
|
+
let autoImportExports = "";
|
|
34
|
+
if (nitro.unimport) {
|
|
35
|
+
await nitro.unimport.init();
|
|
36
|
+
const allImports = await nitro.unimport.getImports();
|
|
37
|
+
autoImportExports = toExports(allImports).replace(
|
|
38
|
+
/#internal\/nitro/g,
|
|
39
|
+
relative(typesDir, runtimeDir)
|
|
40
|
+
);
|
|
41
|
+
const resolvedImportPathMap = /* @__PURE__ */ new Map();
|
|
42
|
+
for (const i of allImports) {
|
|
43
|
+
const from = i.typeFrom || i.from;
|
|
44
|
+
if (resolvedImportPathMap.has(from)) {
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
let path = resolveAlias(from, nitro.options.alias);
|
|
48
|
+
if (!isAbsolute(path)) {
|
|
49
|
+
const resolvedPath = resolveModulePath(from, {
|
|
50
|
+
try: true,
|
|
51
|
+
from: nitro.options.nodeModulesDirs,
|
|
52
|
+
conditions: ["type", "node", "import"],
|
|
53
|
+
suffixes: ["", "/index"],
|
|
54
|
+
extensions: [".mjs", ".cjs", ".js", ".mts", ".cts", ".ts"]
|
|
55
|
+
});
|
|
56
|
+
if (resolvedPath) {
|
|
57
|
+
const { dir, name } = parseNodeModulePath(resolvedPath);
|
|
58
|
+
if (!dir || !name) {
|
|
59
|
+
path = resolvedPath;
|
|
60
|
+
} else {
|
|
61
|
+
const subpath = await lookupNodeModuleSubpath(resolvedPath);
|
|
62
|
+
path = join(dir, name, subpath || "");
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if (existsSync(path) && !await isDirectory(path)) {
|
|
67
|
+
path = path.replace(/\.[a-z]+$/, "");
|
|
68
|
+
}
|
|
69
|
+
if (isAbsolute(path)) {
|
|
70
|
+
path = relative(typesDir, path);
|
|
71
|
+
}
|
|
72
|
+
resolvedImportPathMap.set(from, path);
|
|
73
|
+
}
|
|
74
|
+
autoImportedTypes = [
|
|
75
|
+
nitro.options.imports && nitro.options.imports.autoImport !== false ? (await nitro.unimport.generateTypeDeclarations({
|
|
76
|
+
exportHelper: false,
|
|
77
|
+
resolvePath: (i) => {
|
|
78
|
+
const from = i.typeFrom || i.from;
|
|
79
|
+
return resolvedImportPathMap.get(from) ?? from;
|
|
80
|
+
}
|
|
81
|
+
})).trim() : ""
|
|
82
|
+
];
|
|
83
|
+
}
|
|
84
|
+
const generateRoutes = () => [
|
|
85
|
+
"// Generated by nitro",
|
|
86
|
+
'import type { Serialize, Simplify } from "nitro/types";',
|
|
87
|
+
'declare module "nitro/types" {',
|
|
88
|
+
" type Awaited<T> = T extends PromiseLike<infer U> ? Awaited<U> : T",
|
|
89
|
+
" interface InternalApi {",
|
|
90
|
+
...Object.entries(types.routes).map(
|
|
91
|
+
([path, methods]) => [
|
|
92
|
+
` '${path}': {`,
|
|
93
|
+
...Object.entries(methods).map(
|
|
94
|
+
([method, types2]) => ` '${method}': ${types2.join(" | ")}`
|
|
95
|
+
),
|
|
96
|
+
" }"
|
|
97
|
+
].join("\n")
|
|
98
|
+
),
|
|
99
|
+
" }",
|
|
100
|
+
"}",
|
|
101
|
+
// Makes this a module for augmentation purposes
|
|
102
|
+
"export {}"
|
|
103
|
+
];
|
|
104
|
+
const config = [
|
|
105
|
+
"// Generated by nitro",
|
|
106
|
+
/* ts */
|
|
107
|
+
`declare module "nitro/types" {`,
|
|
108
|
+
nitro.options.typescript.generateRuntimeConfigTypes ? generateTypes(
|
|
109
|
+
await resolveSchema(
|
|
110
|
+
Object.fromEntries(
|
|
111
|
+
Object.entries(nitro.options.runtimeConfig).filter(
|
|
112
|
+
([key]) => !["app", "nitro"].includes(key)
|
|
113
|
+
)
|
|
114
|
+
)
|
|
115
|
+
),
|
|
116
|
+
{
|
|
117
|
+
interfaceName: "NitroRuntimeConfig",
|
|
118
|
+
addExport: false,
|
|
119
|
+
addDefaults: false,
|
|
120
|
+
allowExtraKeys: false,
|
|
121
|
+
indentation: 2
|
|
122
|
+
}
|
|
123
|
+
) : "",
|
|
124
|
+
`}`,
|
|
125
|
+
// Makes this a module for augmentation purposes
|
|
126
|
+
"export {}"
|
|
127
|
+
];
|
|
128
|
+
const declarations = [
|
|
129
|
+
// local nitropack augmentations
|
|
130
|
+
'/// <reference path="./nitro-routes.d.ts" />',
|
|
131
|
+
'/// <reference path="./nitro-config.d.ts" />',
|
|
132
|
+
// global server auto-imports
|
|
133
|
+
'/// <reference path="./nitro-imports.d.ts" />'
|
|
134
|
+
];
|
|
135
|
+
const buildFiles = [];
|
|
136
|
+
buildFiles.push({
|
|
137
|
+
path: join(typesDir, "nitro-routes.d.ts"),
|
|
138
|
+
contents: () => generateRoutes().join("\n")
|
|
139
|
+
});
|
|
140
|
+
buildFiles.push({
|
|
141
|
+
path: join(typesDir, "nitro-config.d.ts"),
|
|
142
|
+
contents: config.join("\n")
|
|
143
|
+
});
|
|
144
|
+
buildFiles.push({
|
|
145
|
+
path: join(typesDir, "nitro-imports.d.ts"),
|
|
146
|
+
contents: [...autoImportedTypes, autoImportExports || "export {}"].join(
|
|
147
|
+
"\n"
|
|
148
|
+
)
|
|
149
|
+
});
|
|
150
|
+
buildFiles.push({
|
|
151
|
+
path: join(typesDir, "nitro.d.ts"),
|
|
152
|
+
contents: declarations.join("\n")
|
|
153
|
+
});
|
|
154
|
+
if (nitro.options.typescript.generateTsConfig) {
|
|
155
|
+
const tsConfigPath = resolve(
|
|
156
|
+
nitro.options.buildDir,
|
|
157
|
+
nitro.options.typescript.tsconfigPath
|
|
158
|
+
);
|
|
159
|
+
const tsconfigDir = dirname(tsConfigPath);
|
|
160
|
+
const tsConfig = defu(nitro.options.typescript.tsConfig, {
|
|
161
|
+
compilerOptions: {
|
|
162
|
+
/* Base options: */
|
|
163
|
+
esModuleInterop: true,
|
|
164
|
+
allowSyntheticDefaultImports: true,
|
|
165
|
+
skipLibCheck: true,
|
|
166
|
+
target: "ESNext",
|
|
167
|
+
allowJs: true,
|
|
168
|
+
resolveJsonModule: true,
|
|
169
|
+
moduleDetection: "force",
|
|
170
|
+
isolatedModules: true,
|
|
171
|
+
verbatimModuleSyntax: true,
|
|
172
|
+
allowImportingTsExtensions: true,
|
|
173
|
+
/* Strictness */
|
|
174
|
+
strict: nitro.options.typescript.strict,
|
|
175
|
+
noUncheckedIndexedAccess: true,
|
|
176
|
+
noImplicitOverride: true,
|
|
177
|
+
forceConsistentCasingInFileNames: true,
|
|
178
|
+
/* If NOT transpiling with TypeScript: */
|
|
179
|
+
module: "Preserve",
|
|
180
|
+
jsx: "preserve",
|
|
181
|
+
jsxFactory: "h",
|
|
182
|
+
jsxFragmentFactory: "Fragment",
|
|
183
|
+
paths: {
|
|
184
|
+
"#imports": [
|
|
185
|
+
relativeWithDot(tsconfigDir, join(typesDir, "nitro-imports"))
|
|
186
|
+
],
|
|
187
|
+
...nitro.options.typescript.internalPaths ? {
|
|
188
|
+
"nitro/runtime": [
|
|
189
|
+
relativeWithDot(tsconfigDir, join(runtimeDir, "index"))
|
|
190
|
+
],
|
|
191
|
+
"#internal/nitro": [
|
|
192
|
+
relativeWithDot(tsconfigDir, join(runtimeDir, "index"))
|
|
193
|
+
],
|
|
194
|
+
"nitro/runtime/*": [
|
|
195
|
+
relativeWithDot(tsconfigDir, join(runtimeDir, "*"))
|
|
196
|
+
],
|
|
197
|
+
"#internal/nitro/*": [
|
|
198
|
+
relativeWithDot(tsconfigDir, join(runtimeDir, "*"))
|
|
199
|
+
]
|
|
200
|
+
} : {}
|
|
201
|
+
}
|
|
202
|
+
},
|
|
203
|
+
include: [
|
|
204
|
+
relativeWithDot(tsconfigDir, join(typesDir, "nitro.d.ts")).replace(
|
|
205
|
+
/^(?=[^.])/,
|
|
206
|
+
"./"
|
|
207
|
+
),
|
|
208
|
+
join(relativeWithDot(tsconfigDir, nitro.options.rootDir), "**/*"),
|
|
209
|
+
...nitro.options.srcDir === nitro.options.rootDir ? [] : [join(relativeWithDot(tsconfigDir, nitro.options.srcDir), "**/*")]
|
|
210
|
+
]
|
|
211
|
+
});
|
|
212
|
+
for (const alias in tsConfig.compilerOptions.paths) {
|
|
213
|
+
const paths = await Promise.all(
|
|
214
|
+
tsConfig.compilerOptions.paths[alias].map(async (path) => {
|
|
215
|
+
if (!isAbsolute(path)) {
|
|
216
|
+
return path;
|
|
217
|
+
}
|
|
218
|
+
const stats = await promises.stat(path).catch(
|
|
219
|
+
() => null
|
|
220
|
+
/* file does not exist */
|
|
221
|
+
);
|
|
222
|
+
return relativeWithDot(
|
|
223
|
+
tsconfigDir,
|
|
224
|
+
stats?.isFile() ? path.replace(/(?<=\w)\.\w+$/g, "") : path
|
|
225
|
+
);
|
|
226
|
+
})
|
|
227
|
+
);
|
|
228
|
+
tsConfig.compilerOptions.paths[alias] = [...new Set(paths)];
|
|
229
|
+
}
|
|
230
|
+
tsConfig.include = [
|
|
231
|
+
...new Set(
|
|
232
|
+
tsConfig.include.map(
|
|
233
|
+
(p) => isAbsolute(p) ? relativeWithDot(tsconfigDir, p) : p
|
|
234
|
+
)
|
|
235
|
+
)
|
|
236
|
+
];
|
|
237
|
+
if (tsConfig.exclude) {
|
|
238
|
+
tsConfig.exclude = [
|
|
239
|
+
...new Set(
|
|
240
|
+
tsConfig.exclude.map(
|
|
241
|
+
(p) => isAbsolute(p) ? relativeWithDot(tsconfigDir, p) : p
|
|
242
|
+
)
|
|
243
|
+
)
|
|
244
|
+
];
|
|
245
|
+
}
|
|
246
|
+
types.tsConfig = tsConfig;
|
|
247
|
+
buildFiles.push({
|
|
248
|
+
path: tsConfigPath,
|
|
249
|
+
contents: () => JSON.stringify(tsConfig, null, 2)
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
await nitro.hooks.callHook("types:extend", types);
|
|
253
|
+
await Promise.all(
|
|
254
|
+
buildFiles.map(async (file) => {
|
|
255
|
+
await writeFile(
|
|
256
|
+
resolve(nitro.options.buildDir, file.path),
|
|
257
|
+
typeof file.contents === "string" ? file.contents : file.contents()
|
|
258
|
+
);
|
|
259
|
+
})
|
|
260
|
+
);
|
|
261
|
+
}
|
|
262
|
+
const RELATIVE_RE = /^\.{1,2}\//;
|
|
263
|
+
function relativeWithDot(from, to) {
|
|
264
|
+
const rel = relative(from, to);
|
|
265
|
+
return RELATIVE_RE.test(rel) ? rel : "./" + rel;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
export { writeTypes as w };
|