nitro-nightly 3.0.1-alpha.1 → 3.0.1-alpha.2

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 (246) hide show
  1. package/README.md +2 -0
  2. package/dist/_build/common.mjs +24924 -52
  3. package/dist/_build/rolldown.mjs +29 -63
  4. package/dist/_build/rollup.mjs +22 -110
  5. package/dist/_build/vite.build.mjs +3 -43
  6. package/dist/{_dev.mjs → _chunks/dev.mjs} +45 -43
  7. package/dist/_chunks/{B-D1JOIz.mjs → nitro.mjs} +144 -308
  8. package/dist/_chunks/nitro2.mjs +101 -0
  9. package/dist/_chunks/utils.mjs +254 -0
  10. package/dist/{_chunks/Bqks5huO.mjs → _common.mjs} +24 -10
  11. package/dist/_libs/c12+giget+readdirp+chokidar.d.mts +214 -0
  12. package/dist/_libs/citty.mjs +140 -110
  13. package/dist/_libs/{plugin-commonjs.mjs → commondir+is-reference.mjs} +59 -250
  14. package/dist/_libs/compatx.d.mts +47 -0
  15. package/dist/_libs/confbox.mjs +388 -799
  16. package/dist/_libs/esbuild.d.mts +20 -0
  17. package/dist/_libs/estree-walker.mjs +1 -144
  18. package/dist/_libs/{plugin-node-resolve.mjs → hasown+resolve+deepmerge.mjs} +497 -78
  19. package/dist/_libs/httpxy.d.mts +79 -0
  20. package/dist/_libs/httpxy.mjs +6 -1
  21. package/dist/_libs/magic-string.d.mts +220 -0
  22. package/dist/_libs/mlly.d.mts +57 -0
  23. package/dist/_libs/nypm+giget+tinyexec.mjs +3603 -0
  24. package/dist/_libs/pkg-types.d.mts +23 -0
  25. package/dist/_libs/plugin-alias.mjs +4 -2
  26. package/dist/_libs/plugin-inject.mjs +5 -5
  27. package/dist/_libs/plugin-json.mjs +2 -2
  28. package/dist/_libs/pluginutils+plugin-commonjs.d.mts +241 -0
  29. package/dist/_libs/{vite-plugin-fullstack.mjs → pluginutils.mjs} +244 -153
  30. package/dist/_libs/rc9+c12+dotenv.mjs +972 -0
  31. package/dist/_libs/{chokidar.mjs → readdirp+chokidar.mjs} +237 -187
  32. package/dist/_libs/remapping.mjs +1 -1
  33. package/dist/_libs/{gen-mapping.mjs → resolve-uri+gen-mapping.mjs} +2 -166
  34. package/dist/_libs/rou3.d.mts +43 -0
  35. package/dist/_libs/rou3.mjs +9 -6
  36. package/dist/_libs/std-env.d.mts +4 -0
  37. package/dist/_libs/tsconfck.mjs +3 -3
  38. package/dist/_libs/{unimport.mjs → unimport+unplugin.mjs} +226 -1961
  39. package/dist/_libs/unplugin+unimport.d.mts +426 -0
  40. package/dist/_libs/unwasm.d.mts +29 -0
  41. package/dist/_presets.mjs +130 -80
  42. package/dist/builder.d.mts +4 -4
  43. package/dist/builder.mjs +6 -30
  44. package/dist/cli/_chunks/build.mjs +1 -1
  45. package/dist/cli/_chunks/dev.mjs +5 -11
  46. package/dist/cli/_chunks/list.mjs +1 -1
  47. package/dist/cli/_chunks/prepare.mjs +1 -1
  48. package/dist/cli/_chunks/run.mjs +1 -1
  49. package/dist/node_modules/@poppinss/colors/build/index.js +130 -160
  50. package/dist/node_modules/@poppinss/colors/package.json +20 -18
  51. package/dist/node_modules/@poppinss/exception/build/index.js +36 -55
  52. package/dist/node_modules/@poppinss/exception/package.json +19 -16
  53. package/dist/node_modules/@sindresorhus/is/distribution/index.js +46 -5
  54. package/dist/node_modules/@sindresorhus/is/package.json +1 -1
  55. package/dist/node_modules/@speed-highlight/core/dist/index.js +1 -1
  56. package/dist/node_modules/@speed-highlight/core/dist/terminal.js +1 -1
  57. package/dist/node_modules/@speed-highlight/core/package.json +2 -2
  58. package/dist/node_modules/hookable/dist/index.mjs +5 -6
  59. package/dist/node_modules/hookable/package.json +13 -13
  60. package/dist/node_modules/ufo/dist/index.mjs +16 -9
  61. package/dist/node_modules/ufo/package.json +15 -14
  62. package/dist/node_modules/unctx/package.json +16 -16
  63. package/dist/node_modules/youch/build/{chunk-4XB2BYKC.js → chunk-7QV3D5YX.js} +2 -4
  64. package/dist/node_modules/youch/build/{chunk-PUHGL6HA.js → chunk-AUGPHE32.js} +2 -4
  65. package/dist/node_modules/youch/build/{chunk-F4I6KX4R.js → chunk-CM7DWJNZ.js} +2 -4
  66. package/dist/node_modules/youch/build/{chunk-YYEJ3AGB.js → chunk-EJH674NB.js} +2 -4
  67. package/dist/node_modules/youch/build/{chunk-EUJBVOYB.js → chunk-OIJ3WD7L.js} +2 -4
  68. package/dist/node_modules/youch/build/{chunk-HFSXRSKS.js → chunk-P36L72PL.js} +5 -3
  69. package/dist/node_modules/youch/build/{chunk-4YEN7HVQ.js → chunk-PE3GG3TN.js} +5 -1
  70. package/dist/node_modules/youch/build/{chunk-PINJDICN.js → chunk-X53OIOJH.js} +2 -4
  71. package/dist/node_modules/youch/build/index.js +8 -9
  72. package/dist/node_modules/youch/build/public/error_info/style.css +1 -0
  73. package/dist/node_modules/youch/build/public/error_metadata/style.css +3 -0
  74. package/dist/node_modules/youch/build/public/error_stack/style.css +2 -3
  75. package/dist/node_modules/youch/package.json +1 -1
  76. package/dist/presets/_nitro/runtime/nitro-dev.d.mts +1 -1
  77. package/dist/presets/_nitro/runtime/nitro-dev.mjs +5 -6
  78. package/dist/presets/_nitro/runtime/nitro-prerenderer.d.mts +1 -1
  79. package/dist/presets/_nitro/runtime/nitro-prerenderer.mjs +1 -1
  80. package/dist/presets/_nitro/runtime/service-worker.d.mts +1 -1
  81. package/dist/presets/_nitro/runtime/service-worker.mjs +2 -2
  82. package/dist/presets/aws-amplify/runtime/aws-amplify.d.mts +1 -1
  83. package/dist/presets/aws-amplify/runtime/aws-amplify.mjs +1 -1
  84. package/dist/presets/aws-lambda/runtime/_utils.d.mts +0 -5
  85. package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.d.mts +1 -1
  86. package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.mjs +9 -11
  87. package/dist/presets/aws-lambda/runtime/aws-lambda.d.mts +1 -1
  88. package/dist/presets/aws-lambda/runtime/aws-lambda.mjs +1 -1
  89. package/dist/presets/azure/runtime/azure-swa.d.mts +1 -1
  90. package/dist/presets/azure/runtime/azure-swa.mjs +1 -1
  91. package/dist/presets/bun/runtime/bun.d.mts +1 -1
  92. package/dist/presets/bun/runtime/bun.mjs +7 -8
  93. package/dist/presets/cloudflare/runtime/_module-handler.d.mts +3 -3
  94. package/dist/presets/cloudflare/runtime/_module-handler.mjs +19 -17
  95. package/dist/presets/cloudflare/runtime/cloudflare-durable.d.mts +1 -1
  96. package/dist/presets/cloudflare/runtime/cloudflare-durable.mjs +17 -16
  97. package/dist/presets/cloudflare/runtime/cloudflare-module.d.mts +1 -1
  98. package/dist/presets/cloudflare/runtime/cloudflare-module.mjs +8 -9
  99. package/dist/presets/cloudflare/runtime/cloudflare-pages.d.mts +1 -1
  100. package/dist/presets/cloudflare/runtime/cloudflare-pages.mjs +12 -18
  101. package/dist/presets/deno/runtime/deno-deploy.d.mts +1 -1
  102. package/dist/presets/deno/runtime/deno-deploy.mjs +4 -5
  103. package/dist/presets/deno/runtime/deno-server.d.mts +1 -1
  104. package/dist/presets/deno/runtime/deno-server.mjs +5 -6
  105. package/dist/presets/netlify/runtime/netlify-edge.d.mts +1 -2
  106. package/dist/presets/netlify/runtime/netlify-edge.mjs +3 -2
  107. package/dist/presets/netlify/runtime/netlify.d.mts +3 -2
  108. package/dist/presets/netlify/runtime/netlify.mjs +3 -1
  109. package/dist/presets/node/runtime/node-cluster.d.mts +1 -1
  110. package/dist/presets/node/runtime/node-cluster.mjs +5 -6
  111. package/dist/presets/node/runtime/node-middleware.d.mts +1 -1
  112. package/dist/presets/node/runtime/node-middleware.mjs +4 -5
  113. package/dist/presets/node/runtime/node-server.d.mts +1 -1
  114. package/dist/presets/node/runtime/node-server.mjs +5 -6
  115. package/dist/presets/standard/runtime/server.d.mts +1 -1
  116. package/dist/presets/standard/runtime/server.mjs +1 -1
  117. package/dist/presets/stormkit/runtime/stormkit.d.mts +1 -1
  118. package/dist/presets/stormkit/runtime/stormkit.mjs +1 -1
  119. package/dist/presets/vercel/runtime/isr.d.mts +2 -0
  120. package/dist/presets/vercel/runtime/isr.mjs +19 -0
  121. package/dist/presets/vercel/runtime/vercel.node.d.mts +1 -1
  122. package/dist/presets/vercel/runtime/vercel.node.mjs +16 -7
  123. package/dist/presets/vercel/runtime/vercel.web.d.mts +1 -1
  124. package/dist/presets/vercel/runtime/vercel.web.mjs +18 -13
  125. package/dist/presets/winterjs/runtime/winterjs.d.mts +1 -2
  126. package/dist/presets/winterjs/runtime/winterjs.mjs +1 -1
  127. package/dist/presets/zeabur/runtime/zeabur.d.mts +1 -1
  128. package/dist/presets/zeabur/runtime/zeabur.mjs +1 -1
  129. package/dist/runtime/app.d.mts +1 -1
  130. package/dist/runtime/app.mjs +1 -1
  131. package/dist/runtime/internal/app.d.mts +7 -3
  132. package/dist/runtime/internal/app.mjs +29 -22
  133. package/dist/runtime/internal/database.mjs +1 -1
  134. package/dist/runtime/internal/error/dev.d.mts +0 -1
  135. package/dist/runtime/internal/error/dev.mjs +1 -1
  136. package/dist/runtime/internal/route-rules.d.mts +0 -4
  137. package/dist/runtime/internal/routes/dev-tasks.mjs +1 -1
  138. package/dist/runtime/internal/routes/openapi.d.mts +0 -1
  139. package/dist/runtime/internal/routes/openapi.mjs +3 -3
  140. package/dist/runtime/internal/routes/renderer-template.dev.mjs +1 -1
  141. package/dist/runtime/internal/routes/renderer-template.mjs +1 -1
  142. package/dist/runtime/internal/routes/scalar.d.mts +0 -1
  143. package/dist/runtime/internal/routes/scalar.mjs +4 -4
  144. package/dist/runtime/internal/routes/swagger.d.mts +0 -1
  145. package/dist/runtime/internal/routes/swagger.mjs +3 -3
  146. package/dist/runtime/internal/runtime-config.mjs +8 -8
  147. package/dist/runtime/internal/static.mjs +1 -1
  148. package/dist/runtime/internal/storage.mjs +1 -1
  149. package/dist/runtime/internal/task.mjs +1 -1
  150. package/dist/runtime/internal/vite/dev-entry.mjs +3 -4
  151. package/dist/runtime/internal/vite/{dev-worker.mjs → node-runner.mjs} +51 -6
  152. package/dist/runtime/meta.d.mts +1 -1
  153. package/dist/runtime/meta.mjs +1 -1
  154. package/dist/runtime/nitro.d.mts +0 -3
  155. package/dist/runtime/nitro.mjs +1 -1
  156. package/dist/runtime/virtual/_runtime_warn.d.mts +1 -0
  157. package/dist/runtime/virtual/_runtime_warn.mjs +5 -0
  158. package/dist/runtime/virtual/database.d.mts +8 -0
  159. package/dist/runtime/virtual/database.mjs +2 -0
  160. package/dist/runtime/virtual/error-handler.d.mts +6 -0
  161. package/dist/runtime/virtual/error-handler.mjs +9 -0
  162. package/dist/runtime/virtual/feature-flags.d.mts +7 -0
  163. package/dist/runtime/virtual/feature-flags.mjs +7 -0
  164. package/dist/runtime/virtual/plugins.d.mts +3 -0
  165. package/dist/runtime/virtual/plugins.mjs +2 -0
  166. package/dist/runtime/virtual/polyfills.d.mts +3 -0
  167. package/dist/runtime/virtual/polyfills.mjs +2 -0
  168. package/dist/runtime/virtual/public-assets.d.mts +9 -0
  169. package/dist/runtime/virtual/public-assets.mjs +8 -0
  170. package/dist/runtime/virtual/renderer-template.d.mts +4 -0
  171. package/dist/runtime/virtual/renderer-template.mjs +7 -0
  172. package/dist/runtime/virtual/routing-meta.d.mts +7 -0
  173. package/dist/runtime/virtual/routing-meta.mjs +2 -0
  174. package/dist/runtime/virtual/routing.d.mts +8 -0
  175. package/dist/runtime/virtual/routing.mjs +11 -0
  176. package/dist/runtime/virtual/runtime-config.d.mts +3 -0
  177. package/dist/runtime/virtual/runtime-config.mjs +5 -0
  178. package/dist/runtime/virtual/server-assets.d.mts +6 -0
  179. package/dist/runtime/virtual/server-assets.mjs +12 -0
  180. package/dist/runtime/virtual/storage.d.mts +3 -0
  181. package/dist/runtime/virtual/storage.mjs +5 -0
  182. package/dist/runtime/virtual/tasks.d.mts +10 -0
  183. package/dist/runtime/virtual/tasks.mjs +3 -0
  184. package/dist/types/index.d.mts +292 -371
  185. package/dist/types/index.mjs +10 -0
  186. package/dist/vite.d.mts +7 -12
  187. package/dist/vite.mjs +734 -41
  188. package/lib/vite.types.d.mts +26 -0
  189. package/lib/vite.types.mjs +2 -0
  190. package/package.json +82 -53
  191. package/dist/_build/common2.mjs +0 -772
  192. package/dist/_build/vite.plugin.mjs +0 -768
  193. package/dist/_chunks/ANM1K1bE.mjs +0 -304
  194. package/dist/_chunks/BX9-zVkM.mjs +0 -59
  195. package/dist/_chunks/C7CbzoI1.mjs +0 -39
  196. package/dist/_libs/acorn.mjs +0 -5034
  197. package/dist/_libs/c12.mjs +0 -2858
  198. package/dist/_libs/commondir.mjs +0 -22
  199. package/dist/_libs/deepmerge.mjs +0 -86
  200. package/dist/_libs/dot-prop.mjs +0 -138
  201. package/dist/_libs/duplexer.mjs +0 -71
  202. package/dist/_libs/etag.mjs +0 -80
  203. package/dist/_libs/fdir.mjs +0 -514
  204. package/dist/_libs/function-bind.mjs +0 -63
  205. package/dist/_libs/giget.mjs +0 -19289
  206. package/dist/_libs/gzip-size.mjs +0 -21
  207. package/dist/_libs/hasown.mjs +0 -14
  208. package/dist/_libs/is-core-module.mjs +0 -220
  209. package/dist/_libs/is-module.mjs +0 -13
  210. package/dist/_libs/is-reference.mjs +0 -32
  211. package/dist/_libs/js-tokens.mjs +0 -382
  212. package/dist/_libs/knitwork.mjs +0 -124
  213. package/dist/_libs/local-pkg.mjs +0 -1686
  214. package/dist/_libs/magic-string.mjs +0 -939
  215. package/dist/_libs/mime.mjs +0 -1391
  216. package/dist/_libs/node-fetch-native.mjs +0 -173
  217. package/dist/_libs/path-parse.mjs +0 -47
  218. package/dist/_libs/pathe.mjs +0 -41
  219. package/dist/_libs/picomatch.mjs +0 -1673
  220. package/dist/_libs/plugin-replace.mjs +0 -104
  221. package/dist/_libs/pretty-bytes.mjs +0 -116
  222. package/dist/_libs/std-env.mjs +0 -158
  223. package/dist/_libs/strip-literal.mjs +0 -51
  224. package/dist/_libs/tinyglobby.mjs +0 -292
  225. package/dist/_libs/untyped.mjs +0 -271
  226. package/dist/_libs/unwasm.mjs +0 -5836
  227. package/dist/cli/_chunks/detect-acorn.mjs +0 -12
  228. package/dist/cli/_chunks/dist.mjs +0 -3
  229. package/dist/cli/_chunks/dist2.mjs +0 -3
  230. package/dist/cli/_chunks/dist3.mjs +0 -3
  231. package/dist/cli/_chunks/dist4.mjs +0 -4
  232. package/dist/cli/_chunks/dist5.mjs +0 -4
  233. package/dist/cli/_chunks/esm.mjs +0 -3
  234. package/dist/cli/_chunks/json5.mjs +0 -4
  235. package/dist/cli/_chunks/jsonc.mjs +0 -4
  236. package/dist/cli/_chunks/multipart-parser.mjs +0 -6
  237. package/dist/cli/_chunks/toml.mjs +0 -4
  238. package/dist/cli/_chunks/yaml.mjs +0 -4
  239. package/dist/node_modules/kleur/index.js +0 -110
  240. package/dist/node_modules/youch/build/chunk-OSUFJZHZ.js +0 -6
  241. package/lib/deps/ofetch.mjs +0 -1
  242. package/lib/deps/ofetch.mts +0 -1
  243. /package/dist/runtime/{vite-runtime.d.mts → vite.d.mts} +0 -0
  244. /package/dist/runtime/{vite-runtime.mjs → vite.mjs} +0 -0
  245. /package/lib/{deps/h3.d.mts → h3.d.mts} +0 -0
  246. /package/lib/{deps/h3.mjs → h3.mjs} +0 -0
@@ -1,29 +1,28 @@
1
1
  import {
2
2
  Layout
3
- } from "./chunk-F4I6KX4R.js";
3
+ } from "./chunk-CM7DWJNZ.js";
4
4
  import {
5
5
  ErrorCause
6
- } from "./chunk-PINJDICN.js";
6
+ } from "./chunk-X53OIOJH.js";
7
7
  import {
8
8
  ErrorInfo
9
- } from "./chunk-EUJBVOYB.js";
9
+ } from "./chunk-OIJ3WD7L.js";
10
10
  import {
11
11
  ErrorMetadata
12
- } from "./chunk-HFSXRSKS.js";
12
+ } from "./chunk-P36L72PL.js";
13
13
  import {
14
14
  ErrorStack
15
- } from "./chunk-YYEJ3AGB.js";
15
+ } from "./chunk-EJH674NB.js";
16
16
  import {
17
17
  ErrorStackSource
18
- } from "./chunk-4XB2BYKC.js";
18
+ } from "./chunk-7QV3D5YX.js";
19
19
  import "./chunk-4L7RY2JA.js";
20
20
  import {
21
21
  Header
22
- } from "./chunk-PUHGL6HA.js";
23
- import "./chunk-OSUFJZHZ.js";
22
+ } from "./chunk-AUGPHE32.js";
24
23
  import {
25
24
  BaseComponent
26
- } from "./chunk-4YEN7HVQ.js";
25
+ } from "./chunk-PE3GG3TN.js";
27
26
 
28
27
  // src/youch.ts
29
28
  import { parse } from "cookie-es";
@@ -38,6 +38,7 @@ html.dark {
38
38
  -webkit-font-smoothing: antialiased;
39
39
  -moz-osx-font-smoothing: grayscale;
40
40
  position: relative;
41
+ word-break: break-word;
41
42
  }
42
43
  #error-message svg {
43
44
  margin-top: 1.5px;
@@ -0,0 +1,3 @@
1
+ .metadata-group .card-subtitle + span {
2
+ word-break: break-word;
3
+ }
@@ -75,6 +75,7 @@ html.dark {
75
75
 
76
76
  .stack-frame-filepath {
77
77
  max-width: 100%;
78
+ word-wrap: break-word;
78
79
  }
79
80
 
80
81
  .stack-frame-location {
@@ -93,9 +94,7 @@ html.dark {
93
94
 
94
95
  .stack-frame-location a {
95
96
  text-decoration: none;
96
- white-space: nowrap;
97
- overflow: hidden;
98
- text-overflow: ellipsis;
97
+ text-align: left;
99
98
  }
100
99
  .stack-frame-location span {
101
100
  white-space: nowrap;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "youch",
3
3
  "description": "Pretty print JavaScript errors on the Web and the Terminal",
4
- "version": "4.1.0-beta.12",
4
+ "version": "4.1.0-beta.13",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "build",
@@ -1,2 +1,2 @@
1
- import "#nitro-internal-pollyfills";
1
+ import "#nitro/virtual/polyfills";
2
2
  export {};
@@ -1,14 +1,13 @@
1
- import "#nitro-internal-pollyfills";
1
+ import "#nitro/virtual/polyfills";
2
2
  import { Server } from "node:http";
3
3
  import { parentPort, threadId } from "node:worker_threads";
4
4
  import wsAdapter from "crossws/adapters/node";
5
5
  import { toNodeHandler } from "srvx/node";
6
6
  import { getSocketAddress, isSocketSupported } from "get-port-please";
7
7
  import { useNitroApp, useNitroHooks } from "nitro/app";
8
- import { startScheduleRunner } from "nitro/~internal/runtime/task";
9
- import { trapUnhandledErrors } from "nitro/~internal/runtime/error/hooks";
10
- import { resolveWebsocketHooks } from "nitro/~internal/runtime/app";
11
- import { hasWebSocket } from "#nitro-internal-virtual/feature-flags";
8
+ import { startScheduleRunner } from "#nitro/runtime/task";
9
+ import { trapUnhandledErrors } from "#nitro/runtime/error/hooks";
10
+ import { resolveWebsocketHooks } from "#nitro/runtime/app";
12
11
  // Listen for shutdown signal from runner
13
12
  parentPort?.on("message", (msg) => {
14
13
  if (msg && msg.event === "shutdown") {
@@ -25,7 +24,7 @@ listen().catch((error) => {
25
24
  return shutdown();
26
25
  });
27
26
  // https://crossws.unjs.io/adapters/node
28
- if (hasWebSocket) {
27
+ if (import.meta._websocket) {
29
28
  const { handleUpgrade } = wsAdapter({ resolve: resolveWebsocketHooks });
30
29
  server.on("upgrade", handleUpgrade);
31
30
  }
@@ -1,3 +1,3 @@
1
- import "#nitro-internal-pollyfills";
1
+ import "#nitro/virtual/polyfills";
2
2
  declare const _default: {};
3
3
  export default _default;
@@ -1,4 +1,4 @@
1
- import "#nitro-internal-pollyfills";
1
+ import "#nitro/virtual/polyfills";
2
2
  import consola from "consola";
3
3
  import { useNitroApp, useNitroHooks } from "nitro/app";
4
4
  const nitroApp = useNitroApp();
@@ -1,2 +1,2 @@
1
- import "#nitro-internal-pollyfills";
1
+ import "#nitro/virtual/polyfills";
2
2
  export {};
@@ -1,6 +1,6 @@
1
- import "#nitro-internal-pollyfills";
1
+ import "#nitro/virtual/polyfills";
2
2
  import { useNitroApp } from "nitro/app";
3
- import { isPublicAssetURL } from "#nitro-internal-virtual/public-assets";
3
+ import { isPublicAssetURL } from "#nitro/virtual/public-assets";
4
4
  const nitroApp = useNitroApp();
5
5
  // @ts-expect-error
6
6
  addEventListener("fetch", (event) => {
@@ -1,2 +1,2 @@
1
- import "#nitro-internal-pollyfills";
1
+ import "#nitro/virtual/polyfills";
2
2
  export {};
@@ -1,4 +1,4 @@
1
- import "#nitro-internal-pollyfills";
1
+ import "#nitro/virtual/polyfills";
2
2
  import { useNitroApp } from "nitro/app";
3
3
  import { Server } from "node:http";
4
4
  import { toNodeHandler } from "srvx/node";
@@ -1,12 +1,7 @@
1
1
  import type { APIGatewayProxyEvent, APIGatewayProxyEventV2 } from "aws-lambda";
2
2
  import type { ServerRequest } from "srvx";
3
- // Incoming (AWS => Web)
4
3
  export declare function awsRequest(event: APIGatewayProxyEvent | APIGatewayProxyEventV2, context: unknown): ServerRequest;
5
- // Outgoing (Web => AWS)
6
4
  export declare function awsResponseHeaders(response: Response);
7
- // AWS Lambda proxy integrations requires base64 encoded buffers
8
- // binaryMediaTypes should be */*
9
- // see https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-payload-encodings.html
10
5
  export declare function awsResponseBody(response: Response): Promise<{
11
6
  body: string;
12
7
  isBase64Encoded?: boolean;
@@ -1,2 +1,2 @@
1
- import "#nitro-internal-pollyfills";
1
+ import "#nitro/virtual/polyfills";
2
2
  export declare const handler: unknown;
@@ -1,4 +1,4 @@
1
- import "#nitro-internal-pollyfills";
1
+ import "#nitro/virtual/polyfills";
2
2
  import { useNitroApp } from "nitro/app";
3
3
  import { awsRequest, awsResponseHeaders } from "./_utils.mjs";
4
4
  const nitroApp = useNitroApp();
@@ -10,16 +10,14 @@ export const handler = awslambda.streamifyResponse(async (event, responseStream,
10
10
  statusCode: response.status,
11
11
  ...awsResponseHeaders(response)
12
12
  };
13
- if (response.body) {
14
- const writer = awslambda.HttpResponseStream.from(
15
- // @ts-expect-error TODO: IMPORTANT! It should be a Writable according to the aws-lambda types
16
- responseStream,
17
- httpResponseMetadata
18
- );
19
- const reader = response.body.getReader();
20
- await streamToNodeStream(reader, responseStream);
21
- writer.end();
22
- }
13
+ const body = response.body ?? new ReadableStream({ start(controller) {
14
+ controller.enqueue("");
15
+ controller.close();
16
+ } });
17
+ const writer = awslambda.HttpResponseStream.from(responseStream, httpResponseMetadata);
18
+ const reader = body.getReader();
19
+ await streamToNodeStream(reader, responseStream);
20
+ writer.end();
23
21
  });
24
22
  async function streamToNodeStream(reader, writer) {
25
23
  let readResult = await reader.read();
@@ -1,3 +1,3 @@
1
- import "#nitro-internal-pollyfills";
1
+ import "#nitro/virtual/polyfills";
2
2
  import type { APIGatewayProxyEvent, APIGatewayProxyEventV2, APIGatewayProxyResult, APIGatewayProxyResultV2, Context } from "aws-lambda";
3
3
  export declare function handler(event: APIGatewayProxyEvent | APIGatewayProxyEventV2, context: Context): Promise<APIGatewayProxyResult | APIGatewayProxyResultV2>;
@@ -1,4 +1,4 @@
1
- import "#nitro-internal-pollyfills";
1
+ import "#nitro/virtual/polyfills";
2
2
  import { useNitroApp } from "nitro/app";
3
3
  import { awsRequest, awsResponseHeaders, awsResponseBody } from "./_utils.mjs";
4
4
  const nitroApp = useNitroApp();
@@ -1,4 +1,4 @@
1
- import "#nitro-internal-pollyfills";
1
+ import "#nitro/virtual/polyfills";
2
2
  import type { HttpRequest, HttpResponse } from "@azure/functions";
3
3
  export declare function handle(context: {
4
4
  res: HttpResponse;
@@ -1,4 +1,4 @@
1
- import "#nitro-internal-pollyfills";
1
+ import "#nitro/virtual/polyfills";
2
2
  import { parseURL } from "ufo";
3
3
  import { useNitroApp } from "nitro/app";
4
4
  import { getAzureParsedCookiesFromHeaders } from "./_utils.mjs";
@@ -1,3 +1,3 @@
1
- import "#nitro-internal-pollyfills";
1
+ import "#nitro/virtual/polyfills";
2
2
  declare const _default: {};
3
3
  export default _default;
@@ -1,11 +1,10 @@
1
- import "#nitro-internal-pollyfills";
1
+ import "#nitro/virtual/polyfills";
2
2
  import { serve } from "srvx/bun";
3
3
  import wsAdapter from "crossws/adapters/bun";
4
4
  import { useNitroApp } from "nitro/app";
5
- import { startScheduleRunner } from "nitro/~internal/runtime/task";
6
- import { trapUnhandledErrors } from "nitro/~internal/runtime/error/hooks";
7
- import { resolveWebsocketHooks } from "nitro/~internal/runtime/app";
8
- import { hasWebSocket } from "#nitro-internal-virtual/feature-flags";
5
+ import { startScheduleRunner } from "#nitro/runtime/task";
6
+ import { trapUnhandledErrors } from "#nitro/runtime/error/hooks";
7
+ import { resolveWebsocketHooks } from "#nitro/runtime/app";
9
8
  const port = Number.parseInt(process.env.NITRO_PORT || process.env.PORT || "") || 3e3;
10
9
  const host = process.env.NITRO_HOST || process.env.HOST;
11
10
  const cert = process.env.NITRO_SSL_CERT;
@@ -13,8 +12,8 @@ const key = process.env.NITRO_SSL_KEY;
13
12
  // const socketPath = process.env.NITRO_UNIX_SOCKET; // TODO
14
13
  const nitroApp = useNitroApp();
15
14
  let _fetch = nitroApp.fetch;
16
- const ws = hasWebSocket ? wsAdapter({ resolve: resolveWebsocketHooks }) : undefined;
17
- if (hasWebSocket) {
15
+ const ws = import.meta._websocket ? wsAdapter({ resolve: resolveWebsocketHooks }) : undefined;
16
+ if (import.meta._websocket) {
18
17
  _fetch = (req) => {
19
18
  if (req.headers.get("upgrade") === "websocket") {
20
19
  return ws.handleUpgrade(req, req.runtime.bun.server);
@@ -30,7 +29,7 @@ serve({
30
29
  key
31
30
  } : undefined,
32
31
  fetch: _fetch,
33
- bun: { websocket: hasWebSocket ? ws?.websocket : undefined }
32
+ bun: { websocket: import.meta._websocket ? ws?.websocket : undefined }
34
33
  });
35
34
  trapUnhandledErrors();
36
35
  // Scheduled tasks
@@ -1,6 +1,6 @@
1
- import "#nitro-internal-pollyfills";
1
+ import "#nitro/virtual/polyfills";
2
2
  import type * as CF from "@cloudflare/workers-types";
3
- import type { ExportedHandler } from "@cloudflare/workers-types";
3
+ import type { ServerRuntimeContext } from "srvx";
4
4
  type MaybePromise<T> = T | Promise<T>;
5
5
  export declare function createHandler<Env>(hooks: {
6
6
  fetch: (...params: [...Parameters<NonNullable<ExportedHandler<Env>["fetch"]>>, url: URL, cfContextExtras: any]) => MaybePromise<Response | CF.Response | undefined>;
@@ -12,5 +12,5 @@ export declare function createHandler<Env>(hooks: {
12
12
  tail(traces, env, context);
13
13
  trace(traces, env, context);
14
14
  };
15
- export declare function fetchHandler(cfReq: Request | CF.Request, env: unknown, context: CF.ExecutionContext | DurableObjectState, url: URL, nitroApp, ctxExt: any);
15
+ export declare function augmentReq(cfReq: Request | CF.Request, ctx: NonNullable<ServerRuntimeContext["cloudflare"]>);
16
16
  export {};
@@ -1,11 +1,16 @@
1
- import "#nitro-internal-pollyfills";
2
- import { runCronTasks } from "nitro/~internal/runtime/task";
1
+ import "#nitro/virtual/polyfills";
2
+ import { runCronTasks } from "#nitro/runtime/task";
3
3
  import { useNitroApp, useNitroHooks } from "nitro/app";
4
4
  export function createHandler(hooks) {
5
5
  const nitroApp = useNitroApp();
6
6
  const nitroHooks = useNitroHooks();
7
7
  return {
8
8
  async fetch(request, env, context) {
9
+ globalThis.__env__ = env;
10
+ augmentReq(request, {
11
+ env,
12
+ context
13
+ });
9
14
  const ctxExt = {};
10
15
  const url = new URL(request.url);
11
16
  // Preset-specific logic
@@ -15,7 +20,7 @@ export function createHandler(hooks) {
15
20
  return res;
16
21
  }
17
22
  }
18
- return fetchHandler(request, env, context, url, nitroApp, ctxExt);
23
+ return await nitroApp.fetch(request);
19
24
  },
20
25
  scheduled(controller, env, context) {
21
26
  globalThis.__env__ = env;
@@ -23,7 +28,7 @@ export function createHandler(hooks) {
23
28
  controller,
24
29
  env,
25
30
  context
26
- }));
31
+ }) || Promise.resolve());
27
32
  if (import.meta._tasks) {
28
33
  context.waitUntil(runCronTasks(controller.cron, {
29
34
  context: { cloudflare: {
@@ -41,7 +46,7 @@ export function createHandler(hooks) {
41
46
  event: message,
42
47
  env,
43
48
  context
44
- }));
49
+ }) || Promise.resolve());
45
50
  },
46
51
  queue(batch, env, context) {
47
52
  globalThis.__env__ = env;
@@ -50,7 +55,7 @@ export function createHandler(hooks) {
50
55
  event: batch,
51
56
  env,
52
57
  context
53
- }));
58
+ }) || Promise.resolve());
54
59
  },
55
60
  tail(traces, env, context) {
56
61
  globalThis.__env__ = env;
@@ -58,7 +63,7 @@ export function createHandler(hooks) {
58
63
  traces,
59
64
  env,
60
65
  context
61
- }));
66
+ }) || Promise.resolve());
62
67
  },
63
68
  trace(traces, env, context) {
64
69
  globalThis.__env__ = env;
@@ -66,20 +71,17 @@ export function createHandler(hooks) {
66
71
  traces,
67
72
  env,
68
73
  context
69
- }));
74
+ }) || Promise.resolve());
70
75
  }
71
76
  };
72
77
  }
73
- export async function fetchHandler(cfReq, env, context, url = new URL(cfReq.url), nitroApp = useNitroApp(), ctxExt) {
74
- // Expose latest env to the global context
75
- globalThis.__env__ = env;
76
- // srvx compatibility
78
+ export function augmentReq(cfReq, ctx) {
77
79
  const req = cfReq;
80
+ req.ip = cfReq.headers.get("cf-connecting-ip") || undefined;
78
81
  req.runtime ??= { name: "cloudflare" };
79
- req.runtime.cloudflare ??= {
80
- context,
81
- env
82
+ req.runtime.cloudflare = {
83
+ ...req.runtime.cloudflare,
84
+ ...ctx
82
85
  };
83
- req.waitUntil = context.waitUntil.bind(context);
84
- return nitroApp.fetch(req);
86
+ req.waitUntil = ctx.context?.waitUntil.bind(ctx.context);
85
87
  }
@@ -1,4 +1,4 @@
1
- import "#nitro-internal-pollyfills";
1
+ import "#nitro/virtual/polyfills";
2
2
  import { DurableObject } from "cloudflare:workers";
3
3
  declare const _default;
4
4
  export default _default;
@@ -1,11 +1,10 @@
1
- import "#nitro-internal-pollyfills";
1
+ import "#nitro/virtual/polyfills";
2
2
  import { DurableObject } from "cloudflare:workers";
3
3
  import wsAdapter from "crossws/adapters/cloudflare";
4
- import { createHandler, fetchHandler } from "./_module-handler.mjs";
4
+ import { createHandler, augmentReq } from "./_module-handler.mjs";
5
5
  import { useNitroApp, useNitroHooks } from "nitro/app";
6
- import { isPublicAssetURL } from "#nitro-internal-virtual/public-assets";
7
- import { resolveWebsocketHooks } from "nitro/~internal/runtime/app";
8
- import { hasWebSocket } from "#nitro-internal-virtual/feature-flags";
6
+ import { isPublicAssetURL } from "#nitro/virtual/public-assets";
7
+ import { resolveWebsocketHooks } from "#nitro/runtime/app";
9
8
  const DURABLE_BINDING = "$DurableObject";
10
9
  const DURABLE_INSTANCE = "server";
11
10
  const nitroApp = useNitroApp();
@@ -18,7 +17,7 @@ const getDurableStub = (env) => {
18
17
  const id = binding.idFromName(DURABLE_INSTANCE);
19
18
  return binding.get(id);
20
19
  };
21
- const ws = hasWebSocket ? wsAdapter({
20
+ const ws = import.meta._websocket ? wsAdapter({
22
21
  resolve: resolveWebsocketHooks,
23
22
  instanceName: DURABLE_INSTANCE,
24
23
  bindingName: DURABLE_BINDING
@@ -32,7 +31,7 @@ export default createHandler({ fetch(request, env, context, url, ctxExt) {
32
31
  ctxExt.durableFetch = (req = request) => getDurableStub(env).fetch(req);
33
32
  // Websocket upgrade
34
33
  // https://crossws.unjs.io/adapters/cloudflare#durable-objects
35
- if (hasWebSocket && request.headers.get("upgrade") === "websocket") {
34
+ if (import.meta._websocket && request.headers.get("upgrade") === "websocket") {
36
35
  return ws.handleUpgrade(request, env, context);
37
36
  }
38
37
  } });
@@ -42,29 +41,31 @@ export class $DurableObject extends DurableObject {
42
41
  state.waitUntil(nitroHooks.callHook("cloudflare:durable:init", this, {
43
42
  state,
44
43
  env
45
- }));
46
- if (hasWebSocket) {
44
+ }) || Promise.resolve());
45
+ if (import.meta._websocket) {
47
46
  ws.handleDurableInit(this, state, env);
48
47
  }
49
48
  }
50
49
  fetch(request) {
51
- if (hasWebSocket && request.headers.get("upgrade") === "websocket") {
50
+ augmentReq(request, {
51
+ env: this.env,
52
+ context: this.ctx
53
+ });
54
+ if (import.meta._websocket && request.headers.get("upgrade") === "websocket") {
52
55
  return ws.handleDurableUpgrade(this, request);
53
56
  }
54
- // Main handler
55
- const url = new URL(request.url);
56
- return fetchHandler(request, this.env, this.ctx, url, nitroApp, { durable: this });
57
+ return nitroApp.fetch(request);
57
58
  }
58
59
  alarm() {
59
- this.ctx.waitUntil(nitroHooks.callHook("cloudflare:durable:alarm", this));
60
+ this.ctx.waitUntil(nitroHooks.callHook("cloudflare:durable:alarm", this) || Promise.resolve());
60
61
  }
61
62
  async webSocketMessage(client, message) {
62
- if (hasWebSocket) {
63
+ if (import.meta._websocket) {
63
64
  return ws.handleDurableMessage(this, client, message);
64
65
  }
65
66
  }
66
67
  async webSocketClose(client, code, reason, wasClean) {
67
- if (hasWebSocket) {
68
+ if (import.meta._websocket) {
68
69
  return ws.handleDurableClose(this, client, code, reason, wasClean);
69
70
  }
70
71
  }
@@ -1,3 +1,3 @@
1
- import "#nitro-internal-pollyfills";
1
+ import "#nitro/virtual/polyfills";
2
2
  declare const _default;
3
3
  export default _default;
@@ -1,18 +1,17 @@
1
- import "#nitro-internal-pollyfills";
1
+ import "#nitro/virtual/polyfills";
2
2
  import wsAdapter from "crossws/adapters/cloudflare";
3
- import { isPublicAssetURL } from "#nitro-internal-virtual/public-assets";
3
+ import { isPublicAssetURL } from "#nitro/virtual/public-assets";
4
4
  import { createHandler } from "./_module-handler.mjs";
5
- import { resolveWebsocketHooks } from "nitro/~internal/runtime/app";
6
- import { hasWebSocket } from "#nitro-internal-virtual/feature-flags";
7
- const ws = hasWebSocket ? wsAdapter({ resolve: resolveWebsocketHooks }) : undefined;
8
- export default createHandler({ fetch(request, env, context, url) {
5
+ import { resolveWebsocketHooks } from "#nitro/runtime/app";
6
+ const ws = import.meta._websocket ? wsAdapter({ resolve: resolveWebsocketHooks }) : undefined;
7
+ export default createHandler({ fetch(cfRequest, env, context, url) {
9
8
  // Static assets fallback (optional binding)
10
9
  if (env.ASSETS && isPublicAssetURL(url.pathname)) {
11
- return env.ASSETS.fetch(request);
10
+ return env.ASSETS.fetch(cfRequest);
12
11
  }
13
12
  // Websocket upgrade
14
13
  // https://crossws.unjs.io/adapters/cloudflare
15
- if (hasWebSocket && request.headers.get("upgrade") === "websocket") {
16
- return ws.handleUpgrade(request, env, context);
14
+ if (import.meta._websocket && cfRequest.headers.get("upgrade") === "websocket") {
15
+ return ws.handleUpgrade(cfRequest, env, context);
17
16
  }
18
17
  } });
@@ -1,4 +1,4 @@
1
- import "#nitro-internal-pollyfills";
1
+ import "#nitro/virtual/polyfills";
2
2
  import type { Request as CFRequest, EventContext, ExecutionContext } from "@cloudflare/workers-types";
3
3
  /**
4
4
  * Reference: https://developers.cloudflare.com/workers/runtime-apis/fetch-event/#parameters
@@ -1,34 +1,28 @@
1
- import "#nitro-internal-pollyfills";
1
+ import "#nitro/virtual/polyfills";
2
2
  import wsAdapter from "crossws/adapters/cloudflare";
3
3
  import { useNitroApp } from "nitro/app";
4
- import { isPublicAssetURL } from "#nitro-internal-virtual/public-assets";
5
- import { runCronTasks } from "nitro/~internal/runtime/task";
6
- import { resolveWebsocketHooks } from "nitro/~internal/runtime/app";
7
- import { hasWebSocket } from "#nitro-internal-virtual/feature-flags";
4
+ import { isPublicAssetURL } from "#nitro/virtual/public-assets";
5
+ import { runCronTasks } from "#nitro/runtime/task";
6
+ import { resolveWebsocketHooks } from "#nitro/runtime/app";
7
+ import { augmentReq } from "./_module-handler.mjs";
8
8
  const nitroApp = useNitroApp();
9
- const ws = hasWebSocket ? wsAdapter({ resolve: resolveWebsocketHooks }) : undefined;
9
+ const ws = import.meta._websocket ? wsAdapter({ resolve: resolveWebsocketHooks }) : undefined;
10
10
  export default {
11
11
  async fetch(cfReq, env, context) {
12
- // srvx compatibility
13
- const req = cfReq;
14
- req.runtime ??= { name: "cloudflare" };
15
- req.runtime.cloudflare ??= {
16
- context,
17
- env
18
- };
19
- req.waitUntil = context.waitUntil.bind(context);
12
+ augmentReq(cfReq, {
13
+ env,
14
+ context
15
+ });
20
16
  // Websocket upgrade
21
17
  // https://crossws.unjs.io/adapters/cloudflare
22
- if (hasWebSocket && cfReq.headers.get("upgrade") === "websocket") {
18
+ if (import.meta._websocket && cfReq.headers.get("upgrade") === "websocket") {
23
19
  return ws.handleUpgrade(cfReq, env, context);
24
20
  }
25
21
  const url = new URL(cfReq.url);
26
22
  if (env.ASSETS && isPublicAssetURL(url.pathname)) {
27
23
  return env.ASSETS.fetch(cfReq);
28
24
  }
29
- // Expose latest env to the global context
30
- globalThis.__env__ = env;
31
- return nitroApp.fetch(req);
25
+ return nitroApp.fetch(cfReq);
32
26
  },
33
27
  scheduled(event, env, context) {
34
28
  if (import.meta._tasks) {
@@ -1,4 +1,4 @@
1
- import "#nitro-internal-pollyfills";
1
+ import "#nitro/virtual/polyfills";
2
2
  import type { Deno as _Deno } from "@deno/types";
3
3
  declare global {
4
4
  var Deno: typeof _Deno;
@@ -1,10 +1,9 @@
1
- import "#nitro-internal-pollyfills";
1
+ import "#nitro/virtual/polyfills";
2
2
  import wsAdapter from "crossws/adapters/deno";
3
3
  import { useNitroApp } from "nitro/app";
4
- import { resolveWebsocketHooks } from "nitro/~internal/runtime/app";
5
- import { hasWebSocket } from "#nitro-internal-virtual/feature-flags";
4
+ import { resolveWebsocketHooks } from "#nitro/runtime/app";
6
5
  const nitroApp = useNitroApp();
7
- const ws = hasWebSocket ? wsAdapter({ resolve: resolveWebsocketHooks }) : undefined;
6
+ const ws = import.meta._websocket ? wsAdapter({ resolve: resolveWebsocketHooks }) : undefined;
8
7
  // TODO: Migrate to srvx to provide request IP
9
8
  Deno.serve((denoReq, info) => {
10
9
  // srvx compatibility
@@ -13,7 +12,7 @@ Deno.serve((denoReq, info) => {
13
12
  req.runtime.deno ??= { info };
14
13
  // TODO: Support remoteAddr
15
14
  // https://crossws.unjs.io/adapters/deno
16
- if (hasWebSocket && req.headers.get("upgrade") === "websocket") {
15
+ if (import.meta._websocket && req.headers.get("upgrade") === "websocket") {
17
16
  return ws.handleUpgrade(req, info);
18
17
  }
19
18
  return nitroApp.fetch(req);
@@ -1,3 +1,3 @@
1
- import "#nitro-internal-pollyfills";
1
+ import "#nitro/virtual/polyfills";
2
2
  declare const _default: {};
3
3
  export default _default;
@@ -1,11 +1,10 @@
1
- import "#nitro-internal-pollyfills";
1
+ import "#nitro/virtual/polyfills";
2
2
  import { serve } from "srvx/deno";
3
3
  import wsAdapter from "crossws/adapters/deno";
4
4
  import { useNitroApp } from "nitro/app";
5
- import { startScheduleRunner } from "nitro/~internal/runtime/task";
6
- import { trapUnhandledErrors } from "nitro/~internal/runtime/error/hooks";
7
- import { resolveWebsocketHooks } from "nitro/~internal/runtime/app";
8
- import { hasWebSocket } from "#nitro-internal-virtual/feature-flags";
5
+ import { startScheduleRunner } from "#nitro/runtime/task";
6
+ import { trapUnhandledErrors } from "#nitro/runtime/error/hooks";
7
+ import { resolveWebsocketHooks } from "#nitro/runtime/app";
9
8
  const port = Number.parseInt(process.env.NITRO_PORT || process.env.PORT || "") || 3e3;
10
9
  const host = process.env.NITRO_HOST || process.env.HOST;
11
10
  const cert = process.env.NITRO_SSL_CERT;
@@ -13,7 +12,7 @@ const key = process.env.NITRO_SSL_KEY;
13
12
  // const socketPath = process.env.NITRO_UNIX_SOCKET; // TODO
14
13
  const nitroApp = useNitroApp();
15
14
  let _fetch = nitroApp.fetch;
16
- if (hasWebSocket) {
15
+ if (import.meta._websocket) {
17
16
  const { handleUpgrade } = wsAdapter({ resolve: resolveWebsocketHooks });
18
17
  _fetch = (req) => {
19
18
  if (req.headers.get("upgrade") === "websocket") {
@@ -1,4 +1,3 @@
1
- import "#nitro-internal-pollyfills";
1
+ import "#nitro/virtual/polyfills";
2
2
  import type { Context } from "@netlify/edge-functions";
3
- // https://docs.netlify.com/edge-functions/api/
4
3
  export default function netlifyEdge(netlifyReq: Request, context: Context);