nitro-nightly 4.0.0-20251010-091516-7cafddba → 4.0.0-20251030-091344-d4418b98

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (195) hide show
  1. package/dist/{_chunks/build2.mjs → _build/build.mjs} +108 -58
  2. package/dist/_build/build2.mjs +556 -0
  3. package/dist/_build/info.mjs +1002 -0
  4. package/dist/_build/prepare.mjs +1511 -0
  5. package/dist/_build/snapshot.mjs +185 -0
  6. package/dist/{_chunks/plugin.mjs → _build/vite.mjs} +295 -296
  7. package/dist/_build/vite2.mjs +149 -0
  8. package/dist/_chunks/_deps/@jridgewell/gen-mapping.mjs +189 -0
  9. package/dist/_chunks/_deps/@jridgewell/remapping.mjs +137 -0
  10. package/dist/_chunks/_deps/@jridgewell/resolve-uri.mjs +231 -0
  11. package/dist/_chunks/_deps/@jridgewell/sourcemap-codec.mjs +173 -0
  12. package/dist/_chunks/_deps/@jridgewell/trace-mapping.mjs +170 -0
  13. package/dist/_chunks/_deps/@pi0/vite-plugin-fullstack.mjs +575 -0
  14. package/dist/_chunks/_deps/@rollup/plugin-alias.mjs +89 -0
  15. package/dist/_chunks/_deps/@rollup/plugin-commonjs.mjs +2376 -0
  16. package/dist/_chunks/{index2.mjs → _deps/@rollup/plugin-inject.mjs} +5 -90
  17. package/dist/_chunks/_deps/@rollup/plugin-json.mjs +37 -0
  18. package/dist/_chunks/_deps/@rollup/plugin-node-resolve.mjs +1386 -0
  19. package/dist/_chunks/_deps/@rollup/plugin-replace.mjs +133 -0
  20. package/dist/_chunks/_deps/@rollup/pluginutils.mjs +346 -0
  21. package/dist/_chunks/_deps/acorn.mjs +6225 -0
  22. package/dist/_chunks/_deps/c12.mjs +510 -0
  23. package/dist/_chunks/_deps/chokidar.mjs +1428 -0
  24. package/dist/_chunks/_deps/citty.mjs +460 -0
  25. package/dist/_chunks/_deps/commondir.mjs +77 -0
  26. package/dist/_chunks/_deps/compatx.mjs +76 -0
  27. package/dist/_chunks/_deps/confbox.mjs +300 -0
  28. package/dist/_chunks/_deps/debug.mjs +885 -0
  29. package/dist/_chunks/_deps/deepmerge.mjs +147 -0
  30. package/dist/_chunks/_deps/depd.mjs +550 -0
  31. package/dist/_chunks/_deps/dot-prop.mjs +282 -0
  32. package/dist/_chunks/_deps/dotenv.mjs +555 -0
  33. package/dist/_chunks/_deps/duplexer.mjs +1 -0
  34. package/dist/_chunks/_deps/ee-first.mjs +104 -0
  35. package/dist/_chunks/_deps/encodeurl.mjs +69 -0
  36. package/dist/_chunks/_deps/escape-html.mjs +87 -0
  37. package/dist/_chunks/_deps/escape-string-regexp.mjs +13 -0
  38. package/dist/_chunks/_deps/estree-walker.mjs +433 -0
  39. package/dist/_chunks/_deps/etag.mjs +147 -0
  40. package/dist/_chunks/_deps/exsolve.mjs +1416 -0
  41. package/dist/_chunks/_deps/fdir.mjs +569 -0
  42. package/dist/_chunks/_deps/fresh.mjs +145 -0
  43. package/dist/_chunks/_deps/function-bind.mjs +106 -0
  44. package/dist/_chunks/{index4.mjs → _deps/giget.mjs} +21 -776
  45. package/dist/_chunks/_deps/gzip-size.mjs +19 -0
  46. package/dist/_chunks/_deps/hasown.mjs +19 -0
  47. package/dist/_chunks/_deps/http-errors.mjs +307 -0
  48. package/dist/_chunks/_deps/httpxy.mjs +580 -0
  49. package/dist/_chunks/_deps/inherits.mjs +57 -0
  50. package/dist/_chunks/_deps/is-core-module.mjs +596 -0
  51. package/dist/_chunks/_deps/is-module.mjs +25 -0
  52. package/dist/_chunks/_deps/is-reference.mjs +31 -0
  53. package/dist/_chunks/_deps/js-tokens.mjs +411 -0
  54. package/dist/_chunks/_deps/klona.mjs +137 -0
  55. package/dist/_chunks/_deps/knitwork.mjs +172 -0
  56. package/dist/_chunks/_deps/local-pkg.mjs +163 -0
  57. package/dist/_chunks/_deps/magic-string.mjs +1296 -0
  58. package/dist/_chunks/_deps/mime-db.mjs +11685 -0
  59. package/dist/_chunks/_deps/mime-types.mjs +287 -0
  60. package/dist/_chunks/_deps/mime.mjs +1172 -0
  61. package/dist/_chunks/_deps/mlly.mjs +2413 -0
  62. package/dist/_chunks/_deps/ms.mjs +172 -0
  63. package/dist/_chunks/_deps/node-fetch-native.mjs +3 -0
  64. package/dist/_chunks/_deps/nypm.mjs +219 -0
  65. package/dist/_chunks/_deps/on-finished.mjs +246 -0
  66. package/dist/_chunks/_deps/parseurl.mjs +168 -0
  67. package/dist/_chunks/_deps/path-parse.mjs +85 -0
  68. package/dist/_chunks/{pathe.M-eThtNZ.mjs → _deps/pathe.mjs} +48 -1
  69. package/dist/_chunks/_deps/perfect-debounce.mjs +88 -0
  70. package/dist/_chunks/_deps/picomatch.mjs +2144 -0
  71. package/dist/_chunks/_deps/pkg-types.mjs +247 -0
  72. package/dist/_chunks/{snapshot.mjs → _deps/pretty-bytes.mjs} +1 -105
  73. package/dist/_chunks/_deps/quansync.mjs +99 -0
  74. package/dist/_chunks/_deps/range-parser.mjs +171 -0
  75. package/dist/_chunks/_deps/rc9.mjs +219 -0
  76. package/dist/_chunks/_deps/readdirp.mjs +245 -0
  77. package/dist/_chunks/_deps/resolve.mjs +1260 -0
  78. package/dist/_chunks/_deps/rou3.mjs +326 -0
  79. package/dist/_chunks/_deps/send.mjs +1022 -0
  80. package/dist/_chunks/_deps/serve-static.mjs +228 -0
  81. package/dist/_chunks/_deps/setprototypeof.mjs +26 -0
  82. package/dist/_chunks/_deps/statuses.mjs +457 -0
  83. package/dist/_chunks/_deps/std-env.mjs +3 -0
  84. package/dist/_chunks/_deps/strip-literal.mjs +67 -0
  85. package/dist/_chunks/_deps/supports-color.mjs +44 -0
  86. package/dist/_chunks/_deps/tinyexec.mjs +552 -0
  87. package/dist/_chunks/_deps/tinyglobby.mjs +293 -0
  88. package/dist/_chunks/_deps/toidentifier.mjs +41 -0
  89. package/dist/_chunks/_deps/ultrahtml.mjs +3 -0
  90. package/dist/_chunks/_deps/unimport.mjs +2267 -0
  91. package/dist/_chunks/_deps/unplugin-utils.mjs +65 -0
  92. package/dist/_chunks/_deps/unplugin.mjs +1294 -0
  93. package/dist/_chunks/_deps/untyped.mjs +375 -0
  94. package/dist/_chunks/{info.mjs → _deps/unwasm.mjs} +8 -4206
  95. package/dist/_chunks/_deps/webpack-virtual-modules.mjs +360 -0
  96. package/dist/_chunks/_presets/_all.mjs +59 -0
  97. package/dist/_chunks/_presets/_nitro.mjs +74 -0
  98. package/dist/_chunks/_presets/_resolve.mjs +64 -0
  99. package/dist/_chunks/_presets/_static.mjs +69 -0
  100. package/dist/_chunks/_presets/_types.mjs +3 -0
  101. package/dist/_chunks/_presets/_utils.mjs +31 -0
  102. package/dist/_chunks/_presets/alwaysdata.mjs +17 -0
  103. package/dist/_chunks/_presets/aws-amplify.mjs +111 -0
  104. package/dist/_chunks/_presets/aws-lambda.mjs +23 -0
  105. package/dist/_chunks/_presets/azure.mjs +162 -0
  106. package/dist/_chunks/_presets/bun.mjs +19 -0
  107. package/dist/_chunks/_presets/cleavr.mjs +15 -0
  108. package/dist/_chunks/_presets/cloudflare.mjs +608 -0
  109. package/dist/_chunks/_presets/deno.mjs +196 -0
  110. package/dist/_chunks/_presets/digitalocean.mjs +14 -0
  111. package/dist/_chunks/_presets/firebase.mjs +47 -0
  112. package/dist/_chunks/_presets/flightcontrol.mjs +14 -0
  113. package/dist/_chunks/_presets/genezio.mjs +13 -0
  114. package/dist/_chunks/_presets/heroku.mjs +14 -0
  115. package/dist/_chunks/_presets/iis.mjs +194 -0
  116. package/dist/_chunks/_presets/index.mjs +62 -0
  117. package/dist/_chunks/_presets/koyeb.mjs +14 -0
  118. package/dist/_chunks/_presets/netlify.mjs +241 -0
  119. package/dist/_chunks/_presets/node.mjs +54 -0
  120. package/dist/_chunks/_presets/platform.mjs +14 -0
  121. package/dist/_chunks/_presets/render.mjs +14 -0
  122. package/dist/_chunks/_presets/standard.mjs +23 -0
  123. package/dist/_chunks/_presets/stormkit.mjs +18 -0
  124. package/dist/_chunks/_presets/vercel.mjs +375 -0
  125. package/dist/_chunks/_presets/winterjs.mjs +22 -0
  126. package/dist/_chunks/_presets/zeabur.mjs +69 -0
  127. package/dist/_chunks/_presets/zerops.mjs +27 -0
  128. package/dist/_chunks/app.mjs +9 -19206
  129. package/dist/_chunks/{index3.mjs → builder.mjs} +560 -970
  130. package/dist/_chunks/server.mjs +6 -4
  131. package/dist/{cli → _cli}/build.mjs +3 -8
  132. package/dist/{cli → _cli}/dev.mjs +38 -12
  133. package/dist/{cli/index2.mjs → _cli/index.mjs} +1 -2
  134. package/dist/{cli → _cli}/list.mjs +3 -4
  135. package/dist/{cli → _cli}/prepare.mjs +3 -4
  136. package/dist/{cli → _cli}/run.mjs +3 -4
  137. package/dist/{index.d.mts → builder.d.mts} +11 -11
  138. package/dist/builder.mjs +117 -0
  139. package/dist/cli/index.mjs +7 -464
  140. package/dist/node_modules/@speed-highlight/core/dist/index.js +1 -1
  141. package/dist/node_modules/@speed-highlight/core/dist/terminal.js +1 -1
  142. package/dist/node_modules/@speed-highlight/core/package.json +7 -3
  143. package/dist/node_modules/cookie-es/dist/index.mjs +262 -0
  144. package/dist/node_modules/cookie-es/package.json +37 -0
  145. package/dist/node_modules/hookable/dist/index.mjs +243 -266
  146. package/dist/node_modules/hookable/package.json +29 -26
  147. package/dist/node_modules/rendu/dist/index.mjs +380 -0
  148. package/dist/node_modules/rendu/package.json +47 -0
  149. package/dist/presets/_nitro/runtime/nitro-dev.mjs +4 -7
  150. package/dist/presets/_nitro/runtime/nitro-prerenderer.mjs +5 -4
  151. package/dist/presets/azure/runtime/azure-swa.mjs +1 -1
  152. package/dist/presets/cloudflare/runtime/_module-handler.mjs +7 -6
  153. package/dist/presets/cloudflare/runtime/cloudflare-durable.mjs +4 -5
  154. package/dist/presets/cloudflare/runtime/plugin.dev.mjs +7 -10
  155. package/dist/presets/cloudflare/runtime/shims/workers.dev.d.mts +21 -0
  156. package/dist/presets/cloudflare/runtime/shims/workers.dev.mjs +27 -0
  157. package/dist/presets/node/runtime/node-server.mjs +1 -1
  158. package/dist/runtime/index.d.mts +1 -1
  159. package/dist/runtime/index.mjs +1 -1
  160. package/dist/runtime/internal/app.d.mts +3 -1
  161. package/dist/runtime/internal/app.mjs +90 -64
  162. package/dist/runtime/internal/error/prod.d.mts +3 -2
  163. package/dist/runtime/internal/error/prod.mjs +9 -13
  164. package/dist/runtime/internal/renderer.mjs +4 -4
  165. package/dist/runtime/internal/routes/dev-tasks.d.mts +30 -2
  166. package/dist/runtime/internal/shutdown.d.mts +1 -2
  167. package/dist/runtime/internal/shutdown.mjs +3 -2
  168. package/dist/runtime/internal/task.mjs +1 -2
  169. package/dist/types/index.d.mts +1603 -10
  170. package/dist/vite.d.mts +5 -0
  171. package/dist/vite.mjs +94 -30
  172. package/lib/index.mjs +1 -0
  173. package/lib/indexd.mts +1 -0
  174. package/lib/runtime/meta.mjs +35 -0
  175. package/package.json +40 -41
  176. package/dist/_chunks/build.mjs +0 -84
  177. package/dist/_chunks/build3.mjs +0 -6452
  178. package/dist/_chunks/detect-acorn.mjs +0 -503
  179. package/dist/_chunks/index.mjs +0 -22242
  180. package/dist/_chunks/json5.mjs +0 -68
  181. package/dist/_chunks/jsonc.mjs +0 -51
  182. package/dist/_chunks/toml.mjs +0 -259
  183. package/dist/_chunks/yaml.mjs +0 -86
  184. package/dist/index.mjs +0 -55
  185. package/dist/node_modules/klona/dist/index.mjs +0 -81
  186. package/dist/node_modules/klona/full/index.mjs +0 -53
  187. package/dist/node_modules/klona/package.json +0 -74
  188. package/dist/node_modules/std-env/dist/index.mjs +0 -1
  189. package/dist/node_modules/std-env/package.json +0 -46
  190. package/dist/presets.mjs +0 -2460
  191. package/dist/runtime/internal/debug.d.mts +0 -2
  192. package/dist/runtime/internal/debug.mjs +0 -5
  193. package/lib/runtime-meta.mjs +0 -38
  194. /package/dist/{cli → _cli}/common.mjs +0 -0
  195. /package/lib/{runtime-meta.d.mts → runtime/meta.d.mts} +0 -0
@@ -0,0 +1,247 @@
1
+ import { promises, statSync } from 'node:fs';
2
+ import { a as resolvePath } from './mlly.mjs';
3
+ import { x, h, a as x$1, b as h$1, S } from './confbox.mjs';
4
+ import { i as isAbsolute, r as resolve, j as join, n as normalize, d as dirname } from './pathe.mjs';
5
+ import { r as resolveModulePath } from './exsolve.mjs';
6
+ import { fileURLToPath } from 'node:url';
7
+ import { readFile } from 'node:fs/promises';
8
+
9
+ const defaultFindOptions$1 = {
10
+ startingFrom: ".",
11
+ rootPattern: /^node_modules$/,
12
+ reverse: false,
13
+ test: (filePath) => {
14
+ try {
15
+ if (statSync(filePath).isFile()) {
16
+ return true;
17
+ }
18
+ } catch {
19
+ }
20
+ }
21
+ };
22
+ async function findFile$1(filename, _options = {}) {
23
+ const filenames = Array.isArray(filename) ? filename : [filename];
24
+ const options = { ...defaultFindOptions$1, ..._options };
25
+ const basePath = resolve(options.startingFrom);
26
+ const leadingSlash = basePath[0] === "/";
27
+ const segments = basePath.split("/").filter(Boolean);
28
+ if (leadingSlash) {
29
+ segments[0] = "/" + segments[0];
30
+ }
31
+ let root = segments.findIndex((r) => r.match(options.rootPattern));
32
+ if (root === -1) {
33
+ root = 0;
34
+ }
35
+ if (options.reverse) {
36
+ for (let index = root + 1; index <= segments.length; index++) {
37
+ for (const filename2 of filenames) {
38
+ const filePath = join(...segments.slice(0, index), filename2);
39
+ if (await options.test(filePath)) {
40
+ return filePath;
41
+ }
42
+ }
43
+ }
44
+ } else {
45
+ for (let index = segments.length; index > root; index--) {
46
+ for (const filename2 of filenames) {
47
+ const filePath = join(...segments.slice(0, index), filename2);
48
+ if (await options.test(filePath)) {
49
+ return filePath;
50
+ }
51
+ }
52
+ }
53
+ }
54
+ throw new Error(
55
+ `Cannot find matching ${filename} in ${options.startingFrom} or parent directories`
56
+ );
57
+ }
58
+ function findNearestFile$1(filename, _options = {}) {
59
+ return findFile$1(filename, _options);
60
+ }
61
+ const FileCache$1 = /* @__PURE__ */ new Map();
62
+ async function readPackageJSON$1(id, options = {}) {
63
+ const resolvedPath = await resolvePackageJSON$1(id, options);
64
+ const cache = options.cache && typeof options.cache !== "boolean" ? options.cache : FileCache$1;
65
+ if (options.cache && cache.has(resolvedPath)) {
66
+ return cache.get(resolvedPath);
67
+ }
68
+ const blob = await promises.readFile(resolvedPath, "utf8");
69
+ let parsed;
70
+ try {
71
+ parsed = x(blob);
72
+ } catch {
73
+ parsed = h(blob);
74
+ }
75
+ cache.set(resolvedPath, parsed);
76
+ return parsed;
77
+ }
78
+ async function resolvePackageJSON$1(id = process.cwd(), options = {}) {
79
+ const resolvedPath = isAbsolute(id) ? id : await resolvePath(id, options);
80
+ return findNearestFile$1("package.json", {
81
+ startingFrom: resolvedPath,
82
+ ...options
83
+ });
84
+ }
85
+
86
+ const defaultFindOptions = {
87
+ startingFrom: ".",
88
+ rootPattern: /^node_modules$/,
89
+ reverse: false,
90
+ test: (filePath) => {
91
+ try {
92
+ if (statSync(filePath).isFile()) {
93
+ return true;
94
+ }
95
+ } catch {
96
+ }
97
+ }
98
+ };
99
+ async function findFile(filename, _options = {}) {
100
+ const filenames = Array.isArray(filename) ? filename : [filename];
101
+ const options = { ...defaultFindOptions, ..._options };
102
+ const basePath = resolve(options.startingFrom);
103
+ const leadingSlash = basePath[0] === "/";
104
+ const segments = basePath.split("/").filter(Boolean);
105
+ if (filenames.includes(segments.at(-1)) && await options.test(basePath)) {
106
+ return basePath;
107
+ }
108
+ if (leadingSlash) {
109
+ segments[0] = "/" + segments[0];
110
+ }
111
+ let root = segments.findIndex((r) => r.match(options.rootPattern));
112
+ if (root === -1) {
113
+ root = 0;
114
+ }
115
+ if (options.reverse) {
116
+ for (let index = root + 1; index <= segments.length; index++) {
117
+ for (const filename2 of filenames) {
118
+ const filePath = join(...segments.slice(0, index), filename2);
119
+ if (await options.test(filePath)) {
120
+ return filePath;
121
+ }
122
+ }
123
+ }
124
+ } else {
125
+ for (let index = segments.length; index > root; index--) {
126
+ for (const filename2 of filenames) {
127
+ const filePath = join(...segments.slice(0, index), filename2);
128
+ if (await options.test(filePath)) {
129
+ return filePath;
130
+ }
131
+ }
132
+ }
133
+ }
134
+ throw new Error(
135
+ `Cannot find matching ${filename} in ${options.startingFrom} or parent directories`
136
+ );
137
+ }
138
+ function findNearestFile(filename, options = {}) {
139
+ return findFile(filename, options);
140
+ }
141
+
142
+ function _resolvePath(id, opts = {}) {
143
+ if (id instanceof URL || id.startsWith("file://")) {
144
+ return normalize(fileURLToPath(id));
145
+ }
146
+ if (isAbsolute(id)) {
147
+ return normalize(id);
148
+ }
149
+ return resolveModulePath(id, {
150
+ ...opts,
151
+ from: opts.from || opts.parent || opts.url
152
+ });
153
+ }
154
+
155
+ const lockFiles = [
156
+ "yarn.lock",
157
+ "package-lock.json",
158
+ "pnpm-lock.yaml",
159
+ "npm-shrinkwrap.json",
160
+ "bun.lockb",
161
+ "bun.lock",
162
+ "deno.lock"
163
+ ];
164
+ const packageFiles = ["package.json", "package.json5", "package.yaml"];
165
+ const workspaceFiles = [
166
+ "pnpm-workspace.yaml",
167
+ "lerna.json",
168
+ "turbo.json",
169
+ "rush.json",
170
+ "deno.json",
171
+ "deno.jsonc"
172
+ ];
173
+ const FileCache = /* @__PURE__ */ new Map();
174
+ async function readPackageJSON(id, options = {}) {
175
+ const resolvedPath = await resolvePackageJSON(id, options);
176
+ const cache = options.cache && typeof options.cache !== "boolean" ? options.cache : FileCache;
177
+ if (options.cache && cache.has(resolvedPath)) {
178
+ return cache.get(resolvedPath);
179
+ }
180
+ const blob = await promises.readFile(resolvedPath, "utf8");
181
+ let parsed;
182
+ try {
183
+ parsed = x$1(blob);
184
+ } catch {
185
+ parsed = h$1(blob);
186
+ }
187
+ cache.set(resolvedPath, parsed);
188
+ return parsed;
189
+ }
190
+ async function resolvePackageJSON(id = process.cwd(), options = {}) {
191
+ return findNearestFile("package.json", {
192
+ ...options,
193
+ startingFrom: _resolvePath(id, options)
194
+ });
195
+ }
196
+ const workspaceTests = {
197
+ workspaceFile: (opts) => findFile(workspaceFiles, opts).then((r) => dirname(r)),
198
+ gitConfig: (opts) => findFile(".git/config", opts).then((r) => resolve(r, "../..")),
199
+ lockFile: (opts) => findFile(lockFiles, opts).then((r) => dirname(r)),
200
+ packageJson: (opts) => findFile(packageFiles, opts).then((r) => dirname(r))
201
+ };
202
+ async function findWorkspaceDir(id = process.cwd(), options = {}) {
203
+ const startingFrom = _resolvePath(id, options);
204
+ const tests = options.tests || ["workspaceFile", "gitConfig", "lockFile", "packageJson"];
205
+ for (const testName of tests) {
206
+ const test = workspaceTests[testName];
207
+ if (options[testName] === false || !test) {
208
+ continue;
209
+ }
210
+ const direction = options[testName] || (testName === "gitConfig" ? "closest" : "furthest");
211
+ const detected = await test({
212
+ ...options,
213
+ startingFrom,
214
+ reverse: direction === "furthest"
215
+ }).catch(() => {
216
+ });
217
+ if (detected) {
218
+ return detected;
219
+ }
220
+ }
221
+ throw new Error(`Cannot detect workspace root from ${id}`);
222
+ }
223
+ async function resolveGitConfig(dir, opts) {
224
+ return findNearestFile(".git/config", { ...opts, startingFrom: dir });
225
+ }
226
+ async function readGitConfig(dir, opts) {
227
+ const path = await resolveGitConfig(dir, opts);
228
+ const ini = await readFile(path, "utf8");
229
+ return parseGitConfig(ini);
230
+ }
231
+ function parseGitConfig(ini) {
232
+ return S(ini.replaceAll(/^\[(\w+) "(.+)"\]$/gm, "[$1.$2]"));
233
+ }
234
+
235
+ const index = {
236
+ __proto__: null,
237
+ findFile: findFile,
238
+ findNearestFile: findNearestFile,
239
+ findWorkspaceDir: findWorkspaceDir,
240
+ parseGitConfig: parseGitConfig,
241
+ readGitConfig: readGitConfig,
242
+ readPackageJSON: readPackageJSON,
243
+ resolveGitConfig: resolveGitConfig,
244
+ resolvePackageJSON: resolvePackageJSON
245
+ };
246
+
247
+ export { readPackageJSON$1 as a, resolvePackageJSON as b, findNearestFile as c, readGitConfig as d, findFile as e, findWorkspaceDir as f, index as i, readPackageJSON as r };
@@ -1,32 +1,3 @@
1
- import { upperFirst } from 'scule';
2
- import { promises } from 'node:fs';
3
- import { colors } from 'consola/utils';
4
- import { b as glob, c as snapshotStorage } from './index.mjs';
5
- import 'node:stream';
6
- import zlib from 'node:zlib';
7
- import { promisify } from 'node:util';
8
- import 'stream';
9
- import { isTest } from 'std-env';
10
- import { r as runParallel } from './index3.mjs';
11
- import { r as resolve, d as dirname, a as relative, j as join } from './pathe.M-eThtNZ.mjs';
12
- import { mkdir, writeFile } from 'node:fs/promises';
13
-
14
- function nitroServerName(nitro) {
15
- return nitro.options.framework.name === "nitro" ? "Nitro Server" : `${upperFirst(nitro.options.framework.name)} Nitro server`;
16
- }
17
-
18
- const getOptions = options => ({level: 9, ...options});
19
- const gzip = promisify(zlib.gzip);
20
-
21
- async function gzipSize(input, options) {
22
- if (!input) {
23
- return 0;
24
- }
25
-
26
- const data = await gzip(input, getOptions(options));
27
- return data.length;
28
- }
29
-
30
1
  const BYTE_UNITS = [
31
2
  'B',
32
3
  'kB',
@@ -206,79 +177,4 @@ function prettyBytes(number, options) {
206
177
  return applyFixedWidth(result, options.fixedWidth);
207
178
  }
208
179
 
209
- async function generateFSTree(dir, options = {}) {
210
- if (isTest) {
211
- return;
212
- }
213
- const files = await glob("**/*.*", { cwd: dir, ignore: ["*.map"] });
214
- const items = [];
215
- await runParallel(
216
- new Set(files),
217
- async (file) => {
218
- const path = resolve(dir, file);
219
- const src = await promises.readFile(path);
220
- const size = src.byteLength;
221
- const gzip = options.compressedSizes ? await gzipSize(src) : 0;
222
- items.push({ file, path, size, gzip });
223
- },
224
- { concurrency: 10 }
225
- );
226
- items.sort((a, b) => a.path.localeCompare(b.path));
227
- let totalSize = 0;
228
- let totalGzip = 0;
229
- let totalNodeModulesSize = 0;
230
- let totalNodeModulesGzip = 0;
231
- let treeText = "";
232
- for (const [index, item] of items.entries()) {
233
- dirname(item.file);
234
- const rpath = relative(process.cwd(), item.path);
235
- const treeChar = index === items.length - 1 ? "\u2514\u2500" : "\u251C\u2500";
236
- const isNodeModules = item.file.includes("node_modules");
237
- if (isNodeModules) {
238
- totalNodeModulesSize += item.size;
239
- totalNodeModulesGzip += item.gzip;
240
- continue;
241
- }
242
- treeText += colors.gray(
243
- ` ${treeChar} ${rpath} (${prettyBytes(item.size)})`
244
- );
245
- if (options.compressedSizes) {
246
- treeText += colors.gray(` (${prettyBytes(item.gzip)} gzip)`);
247
- }
248
- treeText += "\n";
249
- totalSize += item.size;
250
- totalGzip += item.gzip;
251
- }
252
- treeText += `${colors.cyan("\u03A3 Total size:")} ${prettyBytes(
253
- totalSize + totalNodeModulesSize
254
- )}`;
255
- if (options.compressedSizes) {
256
- treeText += ` (${prettyBytes(totalGzip + totalNodeModulesGzip)} gzip)`;
257
- }
258
- treeText += "\n";
259
- return treeText;
260
- }
261
-
262
- async function snapshot(nitro) {
263
- if (nitro.options.bundledStorage.length === 0 || nitro.options.preset === "nitro-prerender") {
264
- return;
265
- }
266
- const storageDir = resolve(nitro.options.buildDir, "snapshot");
267
- nitro.options.serverAssets.push({
268
- baseName: "nitro:bundled",
269
- dir: storageDir
270
- });
271
- const data = await snapshotStorage(nitro);
272
- await Promise.all(
273
- Object.entries(data).map(async ([path, contents]) => {
274
- if (typeof contents !== "string") {
275
- contents = JSON.stringify(contents);
276
- }
277
- const fsPath = join(storageDir, path.replace(/:/g, "/"));
278
- await mkdir(dirname(fsPath), { recursive: true });
279
- await writeFile(fsPath, contents, "utf8");
280
- })
281
- );
282
- }
283
-
284
- export { generateFSTree as g, nitroServerName as n, snapshot as s };
180
+ export { prettyBytes as p };
@@ -0,0 +1,99 @@
1
+ const GET_IS_ASYNC = Symbol.for("quansync.getIsAsync");
2
+ class QuansyncError extends Error {
3
+ constructor(message = "Unexpected promise in sync context") {
4
+ super(message);
5
+ this.name = "QuansyncError";
6
+ }
7
+ }
8
+ function isThenable(value) {
9
+ return value && typeof value === "object" && typeof value.then === "function";
10
+ }
11
+ function isQuansyncGenerator(value) {
12
+ return value && typeof value === "object" && typeof value[Symbol.iterator] === "function" && "__quansync" in value;
13
+ }
14
+ function fromObject(options) {
15
+ const generator = function* (...args) {
16
+ const isAsync = yield GET_IS_ASYNC;
17
+ if (isAsync)
18
+ return yield options.async.apply(this, args);
19
+ return options.sync.apply(this, args);
20
+ };
21
+ function fn(...args) {
22
+ const iter = generator.apply(this, args);
23
+ iter.then = (...thenArgs) => options.async.apply(this, args).then(...thenArgs);
24
+ iter.__quansync = true;
25
+ return iter;
26
+ }
27
+ fn.sync = options.sync;
28
+ fn.async = options.async;
29
+ return fn;
30
+ }
31
+ function fromPromise(promise) {
32
+ return fromObject({
33
+ async: () => Promise.resolve(promise),
34
+ sync: () => {
35
+ if (isThenable(promise))
36
+ throw new QuansyncError();
37
+ return promise;
38
+ }
39
+ });
40
+ }
41
+ function unwrapYield(value, isAsync) {
42
+ if (value === GET_IS_ASYNC)
43
+ return isAsync;
44
+ if (isQuansyncGenerator(value))
45
+ return isAsync ? iterateAsync(value) : iterateSync(value);
46
+ if (!isAsync && isThenable(value))
47
+ throw new QuansyncError();
48
+ return value;
49
+ }
50
+ const DEFAULT_ON_YIELD = (value) => value;
51
+ function iterateSync(generator, onYield = DEFAULT_ON_YIELD) {
52
+ let current = generator.next();
53
+ while (!current.done) {
54
+ try {
55
+ current = generator.next(unwrapYield(onYield(current.value, false)));
56
+ } catch (err) {
57
+ current = generator.throw(err);
58
+ }
59
+ }
60
+ return unwrapYield(current.value);
61
+ }
62
+ async function iterateAsync(generator, onYield = DEFAULT_ON_YIELD) {
63
+ let current = generator.next();
64
+ while (!current.done) {
65
+ try {
66
+ current = generator.next(await unwrapYield(onYield(current.value, true), true));
67
+ } catch (err) {
68
+ current = generator.throw(err);
69
+ }
70
+ }
71
+ return current.value;
72
+ }
73
+ function fromGeneratorFn(generatorFn, options) {
74
+ return fromObject({
75
+ name: generatorFn.name,
76
+ async(...args) {
77
+ return iterateAsync(generatorFn.apply(this, args), options?.onYield);
78
+ },
79
+ sync(...args) {
80
+ return iterateSync(generatorFn.apply(this, args), options?.onYield);
81
+ }
82
+ });
83
+ }
84
+ function quansync$1(input, options) {
85
+ if (isThenable(input))
86
+ return fromPromise(input);
87
+ if (typeof input === "function")
88
+ return fromGeneratorFn(input, options);
89
+ else
90
+ return fromObject(input);
91
+ }
92
+ quansync$1({
93
+ async: () => Promise.resolve(true),
94
+ sync: () => false
95
+ });
96
+
97
+ const quansync = quansync$1;
98
+
99
+ export { quansync as q };
@@ -0,0 +1,171 @@
1
+ /*!
2
+ * range-parser
3
+ * Copyright(c) 2012-2014 TJ Holowaychuk
4
+ * Copyright(c) 2015-2016 Douglas Christopher Wilson
5
+ * MIT Licensed
6
+ */
7
+
8
+ var rangeParser_1;
9
+ var hasRequiredRangeParser;
10
+
11
+ function requireRangeParser () {
12
+ if (hasRequiredRangeParser) return rangeParser_1;
13
+ hasRequiredRangeParser = 1;
14
+
15
+ /**
16
+ * Module exports.
17
+ * @public
18
+ */
19
+
20
+ rangeParser_1 = rangeParser;
21
+
22
+ /**
23
+ * Parse "Range" header `str` relative to the given file `size`.
24
+ *
25
+ * @param {Number} size
26
+ * @param {String} str
27
+ * @param {Object} [options]
28
+ * @return {Array}
29
+ * @public
30
+ */
31
+
32
+ function rangeParser (size, str, options) {
33
+ if (typeof str !== 'string') {
34
+ throw new TypeError('argument str must be a string')
35
+ }
36
+
37
+ var index = str.indexOf('=');
38
+
39
+ if (index === -1) {
40
+ return -2
41
+ }
42
+
43
+ // split the range string
44
+ var arr = str.slice(index + 1).split(',');
45
+ var ranges = [];
46
+
47
+ // add ranges type
48
+ ranges.type = str.slice(0, index);
49
+
50
+ // parse all ranges
51
+ for (var i = 0; i < arr.length; i++) {
52
+ var range = arr[i].split('-');
53
+ var start = parseInt(range[0], 10);
54
+ var end = parseInt(range[1], 10);
55
+
56
+ // -nnn
57
+ if (isNaN(start)) {
58
+ start = size - end;
59
+ end = size - 1;
60
+ // nnn-
61
+ } else if (isNaN(end)) {
62
+ end = size - 1;
63
+ }
64
+
65
+ // limit last-byte-pos to current length
66
+ if (end > size - 1) {
67
+ end = size - 1;
68
+ }
69
+
70
+ // invalid or unsatisifiable
71
+ if (isNaN(start) || isNaN(end) || start > end || start < 0) {
72
+ continue
73
+ }
74
+
75
+ // add range
76
+ ranges.push({
77
+ start: start,
78
+ end: end
79
+ });
80
+ }
81
+
82
+ if (ranges.length < 1) {
83
+ // unsatisifiable
84
+ return -1
85
+ }
86
+
87
+ return options && options.combine
88
+ ? combineRanges(ranges)
89
+ : ranges
90
+ }
91
+
92
+ /**
93
+ * Combine overlapping & adjacent ranges.
94
+ * @private
95
+ */
96
+
97
+ function combineRanges (ranges) {
98
+ var ordered = ranges.map(mapWithIndex).sort(sortByRangeStart);
99
+
100
+ for (var j = 0, i = 1; i < ordered.length; i++) {
101
+ var range = ordered[i];
102
+ var current = ordered[j];
103
+
104
+ if (range.start > current.end + 1) {
105
+ // next range
106
+ ordered[++j] = range;
107
+ } else if (range.end > current.end) {
108
+ // extend range
109
+ current.end = range.end;
110
+ current.index = Math.min(current.index, range.index);
111
+ }
112
+ }
113
+
114
+ // trim ordered array
115
+ ordered.length = j + 1;
116
+
117
+ // generate combined range
118
+ var combined = ordered.sort(sortByRangeIndex).map(mapWithoutIndex);
119
+
120
+ // copy ranges type
121
+ combined.type = ranges.type;
122
+
123
+ return combined
124
+ }
125
+
126
+ /**
127
+ * Map function to add index value to ranges.
128
+ * @private
129
+ */
130
+
131
+ function mapWithIndex (range, index) {
132
+ return {
133
+ start: range.start,
134
+ end: range.end,
135
+ index: index
136
+ }
137
+ }
138
+
139
+ /**
140
+ * Map function to remove index value from ranges.
141
+ * @private
142
+ */
143
+
144
+ function mapWithoutIndex (range) {
145
+ return {
146
+ start: range.start,
147
+ end: range.end
148
+ }
149
+ }
150
+
151
+ /**
152
+ * Sort function to sort ranges by index.
153
+ * @private
154
+ */
155
+
156
+ function sortByRangeIndex (a, b) {
157
+ return a.index - b.index
158
+ }
159
+
160
+ /**
161
+ * Sort function to sort ranges by start position.
162
+ * @private
163
+ */
164
+
165
+ function sortByRangeStart (a, b) {
166
+ return a.start - b.start
167
+ }
168
+ return rangeParser_1;
169
+ }
170
+
171
+ export { requireRangeParser as r };