nitro 3.0.1-alpha.2 → 3.0.260311-beta

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 (255) hide show
  1. package/LICENSE +6 -0
  2. package/README.md +2 -2
  3. package/dist/THIRD-PARTY-LICENSES.md +1646 -0
  4. package/dist/_build/common.mjs +6977 -2556
  5. package/dist/_build/rolldown.mjs +32 -31
  6. package/dist/_build/rollup.mjs +28 -35
  7. package/dist/_build/vite.build.mjs +10 -8
  8. package/dist/_chunks/nitro.mjs +80 -112
  9. package/dist/_chunks/nitro2.mjs +8 -7
  10. package/dist/_chunks/nitro3.mjs +129 -0
  11. package/dist/_chunks/utils.mjs +42 -24
  12. package/dist/_common.mjs +14 -24
  13. package/dist/{_chunks/dev.mjs → _dev.mjs} +132 -320
  14. package/dist/_libs/_.mjs +3 -0
  15. package/dist/_libs/_2.mjs +2 -0
  16. package/dist/_libs/_3.mjs +3 -0
  17. package/dist/_libs/_4.mjs +2 -0
  18. package/dist/_libs/_5.mjs +3 -0
  19. package/dist/_libs/_6.mjs +4 -0
  20. package/dist/_libs/_7.mjs +5 -0
  21. package/dist/_libs/c12+rc9.mjs +812 -0
  22. package/dist/_libs/{c12+giget+readdirp+chokidar.d.mts → c12+readdirp+chokidar.d.mts} +52 -36
  23. package/dist/_libs/citty.mjs +10 -12
  24. package/dist/_libs/commondir+is-reference.mjs +60 -49
  25. package/dist/_libs/compatx.mjs +1 -2
  26. package/dist/_libs/esbuild.d.mts +1 -1
  27. package/dist/_libs/escape-string-regexp.mjs +1 -2
  28. package/dist/_libs/{pluginutils+plugin-commonjs.d.mts → estree+pluginutils.d.mts} +2 -2
  29. package/dist/_libs/estree-walker.mjs +1 -4
  30. package/dist/_libs/exsolve.d.mts +1 -0
  31. package/dist/_libs/hasown+resolve+deepmerge.mjs +146 -169
  32. package/dist/_libs/httpxy.d.mts +12 -9
  33. package/dist/_libs/httpxy.mjs +299 -43
  34. package/dist/_libs/js-tokens.d.mts +1 -0
  35. package/dist/_libs/klona.mjs +1 -2
  36. package/dist/_libs/mlly.d.mts +1 -1
  37. package/dist/_libs/nypm+tinyexec.mjs +845 -0
  38. package/dist/_libs/perfect-debounce.mjs +88 -0
  39. package/dist/_libs/plugin-alias.mjs +2 -4
  40. package/dist/_libs/plugin-inject.mjs +2 -6
  41. package/dist/_libs/plugin-json.mjs +2 -4
  42. package/dist/_libs/pluginutils.mjs +5 -11
  43. package/dist/_libs/readdirp+chokidar.mjs +187 -192
  44. package/dist/_libs/remapping.mjs +1 -3
  45. package/dist/_libs/resolve-uri+gen-mapping.mjs +15 -21
  46. package/dist/_libs/rou3.d.mts +3 -2
  47. package/dist/_libs/rou3.mjs +225 -51
  48. package/dist/_libs/std-env.d.mts +10 -2
  49. package/dist/_libs/strip-literal.d.mts +1 -0
  50. package/dist/_libs/tsconfck.mjs +21 -40
  51. package/dist/_libs/ultrahtml.mjs +3 -14
  52. package/dist/_libs/unimport+unplugin.mjs +250 -351
  53. package/dist/_libs/unplugin+unimport.d.mts +7 -10
  54. package/dist/_presets.mjs +389 -432
  55. package/dist/builder.d.mts +5 -4
  56. package/dist/builder.mjs +12 -6
  57. package/dist/cli/_chunks/build.mjs +22 -23
  58. package/dist/cli/_chunks/common.mjs +1 -2
  59. package/dist/cli/_chunks/deploy.mjs +40 -0
  60. package/dist/cli/_chunks/dev.mjs +9 -9
  61. package/dist/cli/_chunks/docs.mjs +30 -0
  62. package/dist/cli/_chunks/list.mjs +4 -6
  63. package/dist/cli/_chunks/prepare.mjs +2 -4
  64. package/dist/cli/_chunks/preview.mjs +51 -0
  65. package/dist/cli/_chunks/run.mjs +7 -9
  66. package/dist/cli/_chunks/task.mjs +1 -3
  67. package/dist/cli/index.mjs +5 -4
  68. package/dist/node_modules/@poppinss/dumper/build/formatters/html/main.js +8 -0
  69. package/dist/node_modules/@poppinss/dumper/package.json +1 -1
  70. package/dist/node_modules/croner/dist/croner.js +1 -1
  71. package/dist/node_modules/croner/package.json +11 -1
  72. package/dist/node_modules/youch/build/helpers-B9BQYaS6.js +23 -0
  73. package/dist/node_modules/youch/build/index.js +204 -351
  74. package/dist/node_modules/youch/build/public/error_info/script.js +1 -1
  75. package/dist/node_modules/youch/build/public_dir-C5bujZKB.js +25 -0
  76. package/dist/node_modules/youch/build/src/templates/error_cause/main.js +44 -0
  77. package/dist/node_modules/youch/build/src/templates/error_info/main.js +72 -0
  78. package/dist/node_modules/youch/build/src/templates/error_metadata/main.js +65 -0
  79. package/dist/node_modules/youch/build/src/templates/error_stack/main.js +152 -0
  80. package/dist/node_modules/youch/build/src/templates/error_stack_source/main.js +46 -0
  81. package/dist/node_modules/youch/build/src/templates/header/main.js +24 -0
  82. package/dist/node_modules/youch/build/src/templates/layout/main.js +27 -0
  83. package/dist/node_modules/youch/package.json +34 -31
  84. package/dist/presets/_nitro/runtime/nitro-dev.mjs +9 -56
  85. package/dist/presets/_nitro/runtime/nitro-prerenderer.mjs +1 -0
  86. package/dist/presets/_nitro/runtime/service-worker.mjs +0 -1
  87. package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.mjs +3 -1
  88. package/dist/presets/bun/runtime/bun.mjs +4 -3
  89. package/dist/presets/deno/runtime/deno-server.mjs +4 -3
  90. package/dist/presets/netlify/runtime/netlify-edge.mjs +0 -1
  91. package/dist/presets/netlify/runtime/netlify.mjs +1 -1
  92. package/dist/presets/node/runtime/node-cluster.mjs +3 -2
  93. package/dist/presets/node/runtime/node-server.mjs +3 -2
  94. package/dist/presets/stormkit/runtime/stormkit.mjs +0 -1
  95. package/dist/presets/vercel/runtime/cron-handler.mjs +25 -0
  96. package/dist/presets/vercel/runtime/vercel.web.mjs +2 -4
  97. package/dist/presets/zephyr/runtime/server.mjs +3 -0
  98. package/dist/runtime/internal/cache.d.mts +0 -4
  99. package/dist/runtime/internal/cache.mjs +32 -256
  100. package/dist/runtime/internal/context.d.mts +3 -1
  101. package/dist/runtime/internal/error/dev.d.mts +5 -4
  102. package/dist/runtime/internal/error/dev.mjs +38 -40
  103. package/dist/runtime/internal/error/hooks.d.mts +1 -1
  104. package/dist/runtime/internal/error/prod.d.mts +2 -5
  105. package/dist/runtime/internal/error/prod.mjs +19 -33
  106. package/dist/runtime/internal/error/utils.d.mts +4 -4
  107. package/dist/runtime/internal/meta.d.mts +1 -1
  108. package/dist/runtime/internal/plugin.d.mts +2 -2
  109. package/dist/runtime/internal/route-rules.d.mts +9 -4
  110. package/dist/runtime/internal/route-rules.mjs +9 -1
  111. package/dist/runtime/internal/routes/dev-tasks.d.mts +3 -2
  112. package/dist/runtime/internal/routes/dev-tasks.mjs +6 -2
  113. package/dist/runtime/internal/routes/renderer-template.d.mts +1 -1
  114. package/dist/runtime/internal/routes/renderer-template.dev.d.mts +2 -1
  115. package/dist/runtime/internal/runtime-config.d.mts +1 -1
  116. package/dist/runtime/internal/static.mjs +5 -4
  117. package/dist/runtime/internal/task.d.mts +3 -1
  118. package/dist/runtime/internal/task.mjs +2 -2
  119. package/dist/runtime/internal/vite/dev-entry.mjs +6 -3
  120. package/dist/runtime/internal/vite/dev-worker.mjs +264 -0
  121. package/dist/runtime/meta.mjs +1 -0
  122. package/dist/runtime/nitro.d.mts +2 -0
  123. package/dist/runtime/nitro.mjs +2 -0
  124. package/dist/runtime/virtual/error-handler.mjs +1 -1
  125. package/dist/runtime/virtual/server-assets.d.mts +2 -1
  126. package/dist/runtime/vite.d.mts +1 -1
  127. package/dist/types/index.d.mts +68 -117
  128. package/dist/types/index.mjs +1 -11
  129. package/dist/vite.d.mts +3 -3
  130. package/dist/vite.mjs +236 -233
  131. package/package.json +83 -68
  132. package/skills/nitro/SKILL.md +10 -0
  133. package/skills/nitro/docs/TOC.md +83 -0
  134. package/skills/nitro/docs/_navigation.json +679 -0
  135. package/skills/nitro/docs/config/index.md +1147 -0
  136. package/skills/nitro/docs/deploy/index.md +64 -0
  137. package/skills/nitro/docs/deploy/providers/alwaysdata.md +50 -0
  138. package/skills/nitro/docs/deploy/providers/aws-amplify.md +81 -0
  139. package/skills/nitro/docs/deploy/providers/aws.md +47 -0
  140. package/skills/nitro/docs/deploy/providers/azure.md +72 -0
  141. package/skills/nitro/docs/deploy/providers/cleavr.md +33 -0
  142. package/skills/nitro/docs/deploy/providers/cloudflare.md +375 -0
  143. package/skills/nitro/docs/deploy/providers/deno-deploy.md +66 -0
  144. package/skills/nitro/docs/deploy/providers/digitalocean.md +46 -0
  145. package/skills/nitro/docs/deploy/providers/firebase.md +32 -0
  146. package/skills/nitro/docs/deploy/providers/flightcontrol.md +67 -0
  147. package/skills/nitro/docs/deploy/providers/genezio.md +67 -0
  148. package/skills/nitro/docs/deploy/providers/github-pages.md +68 -0
  149. package/skills/nitro/docs/deploy/providers/gitlab-pages.md +37 -0
  150. package/skills/nitro/docs/deploy/providers/heroku.md +84 -0
  151. package/skills/nitro/docs/deploy/providers/iis.md +38 -0
  152. package/skills/nitro/docs/deploy/providers/koyeb.md +109 -0
  153. package/skills/nitro/docs/deploy/providers/netlify.md +47 -0
  154. package/skills/nitro/docs/deploy/providers/platform-sh.md +37 -0
  155. package/skills/nitro/docs/deploy/providers/render.md +37 -0
  156. package/skills/nitro/docs/deploy/providers/stormkit.md +24 -0
  157. package/skills/nitro/docs/deploy/providers/vercel.md +179 -0
  158. package/skills/nitro/docs/deploy/providers/zeabur.md +19 -0
  159. package/skills/nitro/docs/deploy/providers/zephyr.md +99 -0
  160. package/skills/nitro/docs/deploy/providers/zerops.md +102 -0
  161. package/skills/nitro/docs/deploy/runtimes/bun.md +15 -0
  162. package/skills/nitro/docs/deploy/runtimes/deno.md +19 -0
  163. package/skills/nitro/docs/deploy/runtimes/node.md +63 -0
  164. package/skills/nitro/docs/docs/assets.md +166 -0
  165. package/skills/nitro/docs/docs/cache.md +408 -0
  166. package/skills/nitro/docs/docs/configuration.md +256 -0
  167. package/skills/nitro/docs/docs/database.md +185 -0
  168. package/skills/nitro/docs/docs/index.md +56 -0
  169. package/skills/nitro/docs/docs/lifecycle.md +204 -0
  170. package/skills/nitro/docs/docs/migration.md +215 -0
  171. package/skills/nitro/docs/docs/nightly.md +31 -0
  172. package/skills/nitro/docs/docs/plugins.md +164 -0
  173. package/skills/nitro/docs/docs/quick-start.md +110 -0
  174. package/skills/nitro/docs/docs/renderer.md +322 -0
  175. package/skills/nitro/docs/docs/routing.md +711 -0
  176. package/skills/nitro/docs/docs/server-entry.md +239 -0
  177. package/skills/nitro/docs/docs/storage.md +261 -0
  178. package/skills/nitro/docs/docs/tasks.md +277 -0
  179. package/skills/nitro/docs/examples/api-routes.md +145 -0
  180. package/skills/nitro/docs/examples/auto-imports.md +93 -0
  181. package/skills/nitro/docs/examples/cached-handler.md +81 -0
  182. package/skills/nitro/docs/examples/custom-error-handler.md +98 -0
  183. package/skills/nitro/docs/examples/database.md +157 -0
  184. package/skills/nitro/docs/examples/elysia.md +70 -0
  185. package/skills/nitro/docs/examples/express.md +78 -0
  186. package/skills/nitro/docs/examples/fastify.md +79 -0
  187. package/skills/nitro/docs/examples/hello-world.md +68 -0
  188. package/skills/nitro/docs/examples/hono.md +74 -0
  189. package/skills/nitro/docs/examples/import-alias.md +100 -0
  190. package/skills/nitro/docs/examples/index.md +3 -0
  191. package/skills/nitro/docs/examples/middleware.md +91 -0
  192. package/skills/nitro/docs/examples/mono-jsx.md +68 -0
  193. package/skills/nitro/docs/examples/nano-jsx.md +70 -0
  194. package/skills/nitro/docs/examples/plugins.md +91 -0
  195. package/skills/nitro/docs/examples/renderer.md +113 -0
  196. package/skills/nitro/docs/examples/runtime-config.md +97 -0
  197. package/skills/nitro/docs/examples/server-fetch.md +87 -0
  198. package/skills/nitro/docs/examples/shiki.md +198 -0
  199. package/skills/nitro/docs/examples/virtual-routes.md +74 -0
  200. package/skills/nitro/docs/examples/vite-nitro-plugin.md +79 -0
  201. package/skills/nitro/docs/examples/vite-rsc.md +1041 -0
  202. package/skills/nitro/docs/examples/vite-ssr-html.md +217 -0
  203. package/skills/nitro/docs/examples/vite-ssr-preact.md +247 -0
  204. package/skills/nitro/docs/examples/vite-ssr-react.md +226 -0
  205. package/skills/nitro/docs/examples/vite-ssr-solid.md +256 -0
  206. package/skills/nitro/docs/examples/vite-ssr-tsr-react.md +442 -0
  207. package/skills/nitro/docs/examples/vite-ssr-tss-react.md +444 -0
  208. package/skills/nitro/docs/examples/vite-ssr-vue-router.md +616 -0
  209. package/skills/nitro/docs/examples/vite-trpc.md +335 -0
  210. package/skills/nitro/docs/examples/websocket.md +282 -0
  211. package/skills/nitro/docs/index.md +121 -0
  212. package/dist/_libs/confbox.mjs +0 -2509
  213. package/dist/_libs/nypm+giget+tinyexec.mjs +0 -3603
  214. package/dist/_libs/rc9+c12+dotenv.mjs +0 -972
  215. package/dist/node_modules/hookable/dist/index.mjs +0 -266
  216. package/dist/node_modules/hookable/package.json +0 -52
  217. package/dist/node_modules/youch/build/chunk-4L7RY2JA.js +0 -42
  218. package/dist/node_modules/youch/build/chunk-7QV3D5YX.js +0 -83
  219. package/dist/node_modules/youch/build/chunk-AUGPHE32.js +0 -39
  220. package/dist/node_modules/youch/build/chunk-CM7DWJNZ.js +0 -44
  221. package/dist/node_modules/youch/build/chunk-EJH674NB.js +0 -223
  222. package/dist/node_modules/youch/build/chunk-OIJ3WD7L.js +0 -81
  223. package/dist/node_modules/youch/build/chunk-P36L72PL.js +0 -87
  224. package/dist/node_modules/youch/build/chunk-PE3GG3TN.js +0 -65
  225. package/dist/node_modules/youch/build/chunk-X53OIOJH.js +0 -70
  226. package/dist/presets/_nitro/runtime/nitro-dev.d.mts +0 -2
  227. package/dist/presets/_nitro/runtime/nitro-prerenderer.d.mts +0 -3
  228. package/dist/presets/_nitro/runtime/service-worker.d.mts +0 -2
  229. package/dist/presets/aws-amplify/runtime/aws-amplify.d.mts +0 -2
  230. package/dist/presets/aws-lambda/runtime/_utils.d.mts +0 -8
  231. package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.d.mts +0 -2
  232. package/dist/presets/aws-lambda/runtime/aws-lambda.d.mts +0 -3
  233. package/dist/presets/azure/runtime/_utils.d.mts +0 -2
  234. package/dist/presets/azure/runtime/azure-swa.d.mts +0 -5
  235. package/dist/presets/bun/runtime/bun.d.mts +0 -3
  236. package/dist/presets/cloudflare/runtime/_module-handler.d.mts +0 -16
  237. package/dist/presets/cloudflare/runtime/cloudflare-durable.d.mts +0 -11
  238. package/dist/presets/cloudflare/runtime/cloudflare-module.d.mts +0 -3
  239. package/dist/presets/cloudflare/runtime/cloudflare-pages.d.mts +0 -20
  240. package/dist/presets/cloudflare/runtime/plugin.dev.d.mts +0 -3
  241. package/dist/presets/deno/runtime/deno-deploy.d.mts +0 -5
  242. package/dist/presets/deno/runtime/deno-server.d.mts +0 -3
  243. package/dist/presets/netlify/runtime/netlify-edge.d.mts +0 -3
  244. package/dist/presets/netlify/runtime/netlify.d.mts +0 -4
  245. package/dist/presets/node/runtime/node-cluster.d.mts +0 -3
  246. package/dist/presets/node/runtime/node-middleware.d.mts +0 -3
  247. package/dist/presets/node/runtime/node-server.d.mts +0 -3
  248. package/dist/presets/standard/runtime/server.d.mts +0 -3
  249. package/dist/presets/stormkit/runtime/stormkit.d.mts +0 -21
  250. package/dist/presets/vercel/runtime/isr.d.mts +0 -2
  251. package/dist/presets/vercel/runtime/vercel.node.d.mts +0 -3
  252. package/dist/presets/vercel/runtime/vercel.web.d.mts +0 -8
  253. package/dist/presets/winterjs/runtime/winterjs.d.mts +0 -2
  254. package/dist/presets/zeabur/runtime/zeabur.d.mts +0 -3
  255. package/dist/runtime/internal/vite/node-runner.mjs +0 -359
@@ -0,0 +1,72 @@
1
+ import { n as BaseComponent, t as publicDirURL } from "../../../public_dir-C5bujZKB.js";
2
+ import { i as wordWrap, n as htmlEscape, t as colors } from "../../../helpers-B9BQYaS6.js";
3
+ const ERROR_ICON_SVG = `<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="24" height="24" fill="none"><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 7v6m0 4.01.01-.011M12 22c5.523 0 10-4.477 10-10S17.523 2 12 2 2 6.477 2 12s4.477 10 10 10Z"/></svg>`;
4
+ const HINT_ICON_SVG = `<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="24" height="24" fill="none"><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="m21 2-1 1M3 2l1 1m17 13-1-1M3 16l1-1m5 3h6m-5 3h4M12 3C8 3 5.952 4.95 6 8c.023 1.487.5 2.5 1.5 3.5S9 13 9 15h6c0-2 .5-2.5 1.5-3.5h0c1-1 1.477-2.013 1.5-3.5.048-3.05-2-5-6-5Z"/></svg>`;
5
+ const COPY_ICON_SVG = `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M7 7m0 2.667a2.667 2.667 0 0 1 2.667 -2.667h8.666a2.667 2.667 0 0 1 2.667 2.667v8.666a2.667 2.667 0 0 1 -2.667 2.667h-8.666a2.667 2.667 0 0 1 -2.667 -2.667z" /><path d="M4.012 16.737a2.005 2.005 0 0 1 -1.012 -1.737v-10c0 -1.1 .9 -2 2 -2h10c.75 0 1.158 .385 1.5 1" /></svg>`;
6
+ function buildErrorWithStacktrace(error) {
7
+ const cwd = process.cwd();
8
+ const lines = [];
9
+ lines.push(`${error.name}: ${error.message}`);
10
+ if (error.hint) lines.push(`Hint: ${error.hint.replace(/(<([^>]+)>)/gi, "")}`);
11
+ if (error.frames.length > 0) {
12
+ lines.push("");
13
+ lines.push("Stack trace:");
14
+ for (const frame of error.frames) {
15
+ const fileName = frame.fileName?.replace(`${cwd}/`, "") || "<anonymous>";
16
+ const func = frame.functionName ? `at ${frame.functionName} ` : "at ";
17
+ lines.push(` ${func}(${fileName}:${frame.lineNumber}:${frame.columnNumber})`);
18
+ }
19
+ }
20
+ return lines.join("\n");
21
+ }
22
+ function htmlAttributeEscape(value) {
23
+ return value.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/'/g, "&#x27;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
24
+ }
25
+ var ErrorInfo = class extends BaseComponent {
26
+ cssFile = new URL("./error_info/style.css", publicDirURL);
27
+ scriptFile = new URL("./error_info/script.js", publicDirURL);
28
+ async toHTML(props) {
29
+ const stacktraceText = buildErrorWithStacktrace(props.error);
30
+ return `<section>
31
+ <h4 id="error-name">${htmlEscape(props.error.name)}</h4>
32
+ <h1 id="error-title">${htmlEscape(props.title)}</h1>
33
+ </section>
34
+ <section>
35
+ <div class="card">
36
+ <div class="card-body">
37
+ <h2 id="error-message">
38
+ <span>${ERROR_ICON_SVG}</span>
39
+ <span>${htmlEscape(props.error.message)}</span>
40
+ <button
41
+ id="copy-error-btn"
42
+ data-error-text="${htmlAttributeEscape(stacktraceText)}"
43
+ onclick="copyErrorMessage(this)"
44
+ title="Copy error with stack trace"
45
+ aria-label="Copy error with stack trace to clipboard"
46
+ >
47
+ ${COPY_ICON_SVG}
48
+ </button>
49
+ </h2>
50
+ ${props.error.hint ? `<div id="error-hint">
51
+ <span>${HINT_ICON_SVG}</span>
52
+ <span>${props.error.hint}</span>
53
+ </div>` : ""}
54
+ </div>
55
+ </div>
56
+ </section>`;
57
+ }
58
+ async toANSI(props) {
59
+ return `${colors.red(`ℹ ${wordWrap(`${props.error.name}: ${props.error.message}`, {
60
+ width: process.stdout.columns,
61
+ indent: " ",
62
+ newLine: "\n",
63
+ escape: (value) => value
64
+ })}`)}${props.error.hint ? `\n\n${colors.blue("◉")} ${colors.dim().italic(wordWrap(props.error.hint.replace(/(<([^>]+)>)/gi, ""), {
65
+ width: process.stdout.columns,
66
+ indent: " ",
67
+ newLine: "\n",
68
+ escape: (value) => value
69
+ }))}` : ""}`;
70
+ }
71
+ };
72
+ export { ErrorInfo };
@@ -0,0 +1,65 @@
1
+ import { n as BaseComponent, t as publicDirURL } from "../../../public_dir-C5bujZKB.js";
2
+ import { n as htmlEscape } from "../../../helpers-B9BQYaS6.js";
3
+ import { dump, themes } from "@poppinss/dumper/html";
4
+ var ErrorMetadata = class extends BaseComponent {
5
+ cssFile = new URL("./error_metadata/style.css", publicDirURL);
6
+ #primitives = [
7
+ "string",
8
+ "boolean",
9
+ "number",
10
+ "undefined"
11
+ ];
12
+ #formatRowValue(value, dumpValue, cspNonce) {
13
+ if (dumpValue === true) return dump(value, {
14
+ styles: themes.cssVariables,
15
+ cspNonce
16
+ });
17
+ if (this.#primitives.includes(typeof value) || value === null) return typeof value === "string" ? htmlEscape(value) : value;
18
+ return dump(value, {
19
+ styles: themes.cssVariables,
20
+ cspNonce
21
+ });
22
+ }
23
+ #renderRows(rows, cspNonce) {
24
+ return `<table class="card-table">
25
+ <tbody>
26
+ ${rows.map((row) => {
27
+ return `<tr>
28
+ <td class="table-key">${row.key}</td>
29
+ <td class="table-value">
30
+ ${this.#formatRowValue(row.value, row.dump, cspNonce)}
31
+ </td>
32
+ </tr>`;
33
+ }).join("\n")}
34
+ </tbody>
35
+ </table>`;
36
+ }
37
+ #renderSection(section, rows, cspNonce) {
38
+ return `<div>
39
+ <h4 class="card-subtitle">${section}</h4>
40
+ ${Array.isArray(rows) ? this.#renderRows(rows, cspNonce) : `<span>${this.#formatRowValue(rows.value, rows.dump, cspNonce)}</span>`}
41
+ </div>`;
42
+ }
43
+ #renderGroup(group, sections, cspNonce) {
44
+ return `<section class="metadata-group">
45
+ <div class="card">
46
+ <div class="card-heading">
47
+ <h3 class="card-title">${group}</h3>
48
+ </div>
49
+ <div class="card-body">
50
+ ${Object.keys(sections).map((section) => this.#renderSection(section, sections[section], cspNonce)).join("\n")}
51
+ </div>
52
+ </div>
53
+ </section>`;
54
+ }
55
+ async toHTML(props) {
56
+ const groups = props.metadata.toJSON();
57
+ const groupsNames = Object.keys(groups);
58
+ if (!groupsNames.length) return "";
59
+ return groupsNames.map((group) => this.#renderGroup(group, groups[group], props.cspNonce)).join("\n");
60
+ }
61
+ async toANSI() {
62
+ return "";
63
+ }
64
+ };
65
+ export { ErrorMetadata };
@@ -0,0 +1,152 @@
1
+ import { n as BaseComponent, t as publicDirURL } from "../../../public_dir-C5bujZKB.js";
2
+ import { n as htmlEscape, t as colors } from "../../../helpers-B9BQYaS6.js";
3
+ import { dump, themes } from "@poppinss/dumper/html";
4
+ import { dump as dump$1 } from "@poppinss/dumper/console";
5
+ const CHEVIRON = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" width="24" height="24" stroke-width="2">
6
+ <path d="M6 9l6 6l6 -6"></path>
7
+ </svg>`;
8
+ const EDITORS = {
9
+ textmate: "txmt://open?url=file://%f&line=%l",
10
+ macvim: "mvim://open?url=file://%f&line=%l",
11
+ emacs: "emacs://open?url=file://%f&line=%l",
12
+ sublime: "subl://open?url=file://%f&line=%l",
13
+ phpstorm: "phpstorm://open?file=%f&line=%l",
14
+ atom: "atom://core/open/file?filename=%f&line=%l",
15
+ vscode: "vscode://file/%f:%l"
16
+ };
17
+ var ErrorStack = class extends BaseComponent {
18
+ cssFile = new URL("./error_stack/style.css", publicDirURL);
19
+ scriptFile = new URL("./error_stack/script.js", publicDirURL);
20
+ #getRelativeFileName(filePath) {
21
+ return filePath.replace(`${process.cwd()}/`, "");
22
+ }
23
+ #getFirstExpandedFrameIndex(frames) {
24
+ let expandAtIndex = frames.findIndex((frame) => frame.type === "app");
25
+ if (expandAtIndex === -1) expandAtIndex = frames.findIndex((frame) => frame.type === "module");
26
+ return expandAtIndex;
27
+ }
28
+ #getEditorLink(ide, frame) {
29
+ const editorURL = EDITORS[ide] || ide;
30
+ if (!editorURL || frame.type === "native") return { text: this.#getRelativeFileName(frame.fileName) };
31
+ return {
32
+ href: editorURL.replace("%f", frame.fileName).replace("%l", String(frame.lineNumber)),
33
+ text: this.#getRelativeFileName(frame.fileName)
34
+ };
35
+ }
36
+ #renderFrameLocation(frame, ide) {
37
+ const { text, href } = this.#getEditorLink(ide, frame);
38
+ const fileName = `<a${href ? ` href="${href}"` : ""} class="stack-frame-filepath" title="${text}">
39
+ ${htmlEscape(text)}
40
+ </a>`;
41
+ const functionName = frame.functionName ? `<span>in <code title="${frame.functionName}">
42
+ ${htmlEscape(frame.functionName)}
43
+ </code></span>` : "";
44
+ const loc = `<span>at line <code>${frame.lineNumber}:${frame.columnNumber}</code></span>`;
45
+ if (frame.type !== "native" && frame.source) return `<button class="stack-frame-location">
46
+ ${fileName} ${functionName} ${loc}
47
+ </button>`;
48
+ return `<div class="stack-frame-location">
49
+ ${fileName} ${functionName} ${loc}
50
+ </div>`;
51
+ }
52
+ async #renderStackFrame(frame, index, expandAtIndex, props) {
53
+ const label = frame.type === "app" ? "<span class=\"frame-label\">In App</span>" : "";
54
+ const expandedClass = expandAtIndex === index ? " expanded" : "";
55
+ const toggleButton = frame.type !== "native" && frame.source ? `<button class="stack-frame-toggle-indicator">${CHEVIRON}</button>` : "";
56
+ return `<li class="stack-frame stack-frame-${frame.type}${expandedClass}">
57
+ <div class="stack-frame-contents">
58
+ ${this.#renderFrameLocation(frame, props.ide)}
59
+ <div class="stack-frame-extras">
60
+ ${label}
61
+ ${toggleButton}
62
+ </div>
63
+ </div>
64
+ <div class="stack-frame-source">
65
+ ${await props.sourceCodeRenderer(props.error, frame)}
66
+ </div>
67
+ </li>`;
68
+ }
69
+ async #printStackFrame(frame, index, expandAtIndex, props) {
70
+ const loc = `${this.#getRelativeFileName(frame.fileName)}:${frame.lineNumber}:${frame.columnNumber}`;
71
+ if (index === expandAtIndex) {
72
+ const functionName = frame.functionName ? `at ${frame.functionName} ` : "";
73
+ const codeSnippet = await props.sourceCodeRenderer(props.error, frame);
74
+ return ` ⁃ ${functionName}${colors.yellow(`(${loc})`)}${codeSnippet}`;
75
+ }
76
+ if (frame.type === "native") {
77
+ const functionName = frame.functionName ? `at ${colors.italic(frame.functionName)} ` : "";
78
+ return colors.dim(` ⁃ ${functionName}(${colors.italic(loc)})`);
79
+ }
80
+ return ` ⁃ ${frame.functionName ? `at ${frame.functionName} ` : ""}${colors.yellow(`(${loc})`)}`;
81
+ }
82
+ async toHTML(props) {
83
+ return `<section>
84
+ <div class="card">
85
+ <div class="card-heading">
86
+ <div>
87
+ <h3 class="card-title">
88
+ Stack Trace
89
+ </h3>
90
+ </div>
91
+ </div>
92
+ <div class="card-body">
93
+ <div id="stack-frames-wrapper">
94
+ <div id="stack-frames-header">
95
+ <div id="all-frames-toggle-wrapper">
96
+ <label id="all-frames-toggle">
97
+ <input type="checkbox" />
98
+ <span> View All Frames </span>
99
+ </label>
100
+ </div>
101
+
102
+ <div>
103
+ <div class="toggle-switch">
104
+ <button id="formatted-frames-toggle" class="active"> Pretty </button>
105
+ <button id="raw-frames-toggle"> Raw </button>
106
+ </div>
107
+ </div>
108
+ </div>
109
+
110
+ <div id="stack-frames-body">
111
+ <div id="stack-frames-formatted" class="visible">
112
+ <ul id="stack-frames">
113
+ ${(await Promise.all(props.error.frames.map((frame, index) => {
114
+ return this.#renderStackFrame(frame, index, this.#getFirstExpandedFrameIndex(props.error.frames), props);
115
+ }))).join("\n")}
116
+ </ul>
117
+ </div>
118
+ <div id="stack-frames-raw">
119
+ ${dump(props.error.raw, {
120
+ styles: themes.cssVariables,
121
+ expand: true,
122
+ cspNonce: props.cspNonce,
123
+ inspectObjectPrototype: false,
124
+ inspectStaticMembers: false,
125
+ inspectArrayPrototype: false
126
+ })}
127
+ </div>
128
+ </div>
129
+ <div>
130
+ </div>
131
+ </div>
132
+ </section>`;
133
+ }
134
+ async toANSI(props) {
135
+ const displayRaw = process.env.YOUCH_RAW;
136
+ if (displayRaw) {
137
+ const depth = Number.isNaN(Number(displayRaw)) ? 2 : Number(displayRaw);
138
+ return `\n\n${colors.red("[RAW]")}\n${dump$1(props.error.raw, {
139
+ depth,
140
+ inspectObjectPrototype: false,
141
+ inspectStaticMembers: false,
142
+ inspectArrayPrototype: false
143
+ })}`;
144
+ }
145
+ const frames = await Promise.all(props.error.frames.map((frame, index) => {
146
+ return this.#printStackFrame(frame, index, this.#getFirstExpandedFrameIndex(props.error.frames), props);
147
+ }));
148
+ if (frames.length) return `\n\n${frames.join("\n")}`;
149
+ return "";
150
+ }
151
+ };
152
+ export { ErrorStack };
@@ -0,0 +1,46 @@
1
+ import { n as BaseComponent, t as publicDirURL } from "../../../public_dir-C5bujZKB.js";
2
+ import { r as stripAnsi, t as colors } from "../../../helpers-B9BQYaS6.js";
3
+ import { extname } from "node:path";
4
+ import { highlightText } from "@speed-highlight/core";
5
+ import { highlightText as highlightText$1 } from "@speed-highlight/core/terminal";
6
+ const GUTTER = "┃";
7
+ const POINTER = "❯";
8
+ const LANGS_MAP = {
9
+ ".tsx": "ts",
10
+ ".jsx": "js",
11
+ ".js": "js",
12
+ ".ts": "ts",
13
+ ".css": "css",
14
+ ".json": "json",
15
+ ".html": "html",
16
+ ".astro": "ts",
17
+ ".vue": "ts"
18
+ };
19
+ var ErrorStackSource = class extends BaseComponent {
20
+ cssFile = new URL("./error_stack_source/style.css", publicDirURL);
21
+ async toHTML(props) {
22
+ const frame = props.frame;
23
+ if (frame.type === "native" || !frame.source || !frame.fileName) return "";
24
+ const language = LANGS_MAP[extname(frame.fileName)] ?? "plain";
25
+ const highlight = `<div class="line-highlight" style="margin-top: ${`${frame.source.findIndex((chunk) => {
26
+ return chunk.lineNumber === frame.lineNumber;
27
+ }) * 24}px`}"></div>`;
28
+ let code = await highlightText(frame.source.map((chunk) => chunk.chunk).join("\n"), language, true);
29
+ code = code.replace("<div class=\"shj-numbers\">", `<div class="shj-numbers" style="counter-set: line ${frame.source[0].lineNumber - 1}">`);
30
+ return `<pre><code class="shj-lang-js">${highlight}${code}</code></pre>`;
31
+ }
32
+ async toANSI(props) {
33
+ const frame = props.frame;
34
+ if (frame.type === "native" || !frame.source || !frame.fileName) return "";
35
+ const language = LANGS_MAP[extname(frame.fileName)] ?? "plain";
36
+ const largestLineNumber = Math.max(...frame.source.map(({ lineNumber }) => lineNumber));
37
+ const lineNumberCols = String(largestLineNumber).length;
38
+ return `\n\n${(await highlightText$1(frame.source.map(({ chunk }) => chunk).join("\n"), language)).split("\n").map((line, index) => {
39
+ const lineNumber = frame.source[index].lineNumber;
40
+ const alignedLineNumber = String(lineNumber).padStart(lineNumberCols, " ");
41
+ if (lineNumber === props.frame.lineNumber) return ` ${colors.bgRed(`${POINTER} ${alignedLineNumber} ${GUTTER} ${stripAnsi(line)}`)}`;
42
+ return ` ${colors.dim(alignedLineNumber)} ${colors.dim(GUTTER)} ${line}`;
43
+ }).join("\n")}\n`;
44
+ }
45
+ };
46
+ export { ErrorStackSource };
@@ -0,0 +1,24 @@
1
+ import { n as BaseComponent, t as publicDirURL } from "../../../public_dir-C5bujZKB.js";
2
+ const DARK_MODE_SVG = `<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="15" height="15" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path d="M0 0h24v24H0z" stroke="none"/><path d="M12 3h.393a7.5 7.5 0 0 0 7.92 12.446A9 9 0 1 1 12 2.992z"/></svg>`;
3
+ const LIGHT_MODE_SVG = `<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="15" height="15" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path d="M0 0h24v24H0z" stroke="none"/><circle cx="12" cy="12" r="4"/><path d="M3 12h1m8-9v1m8 8h1m-9 8v1M5.6 5.6l.7.7m12.1-.7-.7.7m0 11.4.7.7m-12.1-.7-.7.7"/></svg>`;
4
+ var Header = class extends BaseComponent {
5
+ cssFile = new URL("./header/style.css", publicDirURL);
6
+ scriptFile = new URL("./header/script.js", publicDirURL);
7
+ async toHTML() {
8
+ return `<header id="header">
9
+ <div id="header-actions">
10
+ <div id="toggle-theme-container">
11
+ <input type="checkbox" id="toggle-theme-checkbox" />
12
+ <label id="toggle-theme-label" for="toggle-theme-checkbox">
13
+ <span id="light-theme-indicator" title="Light mode">${LIGHT_MODE_SVG}</span>
14
+ <span id="dark-theme-indicator" title="Dark mode">${DARK_MODE_SVG}</span>
15
+ </label>
16
+ </div>
17
+ </div>
18
+ </header>`;
19
+ }
20
+ async toANSI() {
21
+ return "";
22
+ }
23
+ };
24
+ export { Header };
@@ -0,0 +1,27 @@
1
+ import { n as BaseComponent, t as publicDirURL } from "../../../public_dir-C5bujZKB.js";
2
+ var Layout = class extends BaseComponent {
3
+ cssFile = new URL("./layout/style.css", publicDirURL);
4
+ scriptFile = new URL("./layout/script.js", publicDirURL);
5
+ async toHTML(props) {
6
+ return `<!DOCTYPE html>
7
+ <html lang="en">
8
+ <head>
9
+ <meta charset="UTF-8" />
10
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
11
+ <title>${props.title}</title>
12
+ <!-- STYLES -->
13
+ <!-- GLOBAL SCRIPT -->
14
+ </head>
15
+ <body>
16
+ <div id="layout">
17
+ ${await props.children()}
18
+ </div>
19
+ <!-- SCRIPTS -->
20
+ </body>
21
+ </html>`;
22
+ }
23
+ async toANSI(props) {
24
+ return `\n${await props.children()}\n`;
25
+ }
26
+ };
27
+ export { Layout };
@@ -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.13",
4
+ "version": "4.1.0",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "build",
@@ -23,7 +23,7 @@
23
23
  "typecheck": "tsc --noEmit",
24
24
  "precompile": "npm run lint",
25
25
  "copy:assets": "copyfiles --up=1 src/public/**/* build",
26
- "compile": "tsup-node && tsc --emitDeclarationOnly --declaration",
26
+ "compile": "tsdown && tsc --emitDeclarationOnly --declaration",
27
27
  "build": "npm run compile && npm run copy:assets",
28
28
  "version": "npm run build",
29
29
  "prepublishOnly": "npm run build",
@@ -31,39 +31,39 @@
31
31
  "quick:test": "node --import=@poppinss/ts-exec --enable-source-maps bin/test.ts"
32
32
  },
33
33
  "devDependencies": {
34
- "@adonisjs/eslint-config": "^3.0.0-next.0",
34
+ "@adonisjs/eslint-config": "^3.0.0",
35
35
  "@adonisjs/prettier-config": "^1.4.5",
36
- "@adonisjs/tsconfig": "^2.0.0-next.0",
37
- "@aws-sdk/client-s3": "^3.922.0",
38
- "@aws-sdk/s3-request-presigner": "^3.922.0",
39
- "@japa/assert": "^4.1.1",
40
- "@japa/expect": "^3.0.6",
41
- "@japa/expect-type": "^2.0.3",
42
- "@japa/file-system": "^2.3.2",
43
- "@japa/runner": "^4.4.0",
44
- "@japa/snapshot": "^2.0.9",
45
- "@poppinss/exception": "^1.2.2",
46
- "@poppinss/ts-exec": "^1.4.1",
47
- "@release-it/conventional-changelog": "^10.0.1",
48
- "@types/jsdom": "^27.0.0",
49
- "@types/node": "^24.10.0",
50
- "@types/pg": "^8.15.6",
51
- "axios": "^1.13.1",
36
+ "@adonisjs/tsconfig": "^2.0.0",
37
+ "@aws-sdk/client-s3": "^3.996.0",
38
+ "@aws-sdk/s3-request-presigner": "^3.996.0",
39
+ "@japa/assert": "^4.2.0",
40
+ "@japa/expect": "^3.0.7",
41
+ "@japa/expect-type": "^2.0.4",
42
+ "@japa/file-system": "^3.0.0",
43
+ "@japa/runner": "^5.3.0",
44
+ "@japa/snapshot": "^2.0.10",
45
+ "@poppinss/exception": "^1.2.3",
46
+ "@poppinss/ts-exec": "^1.4.4",
47
+ "@release-it/conventional-changelog": "^10.0.5",
48
+ "@types/jsdom": "^28.0.0",
49
+ "@types/node": "^25.3.0",
50
+ "@types/pg": "^8.16.0",
51
+ "axios": "^1.13.5",
52
52
  "c8": "^10.1.3",
53
53
  "copyfiles": "^2.4.1",
54
- "eslint": "^9.39.0",
55
- "flydrive": "^1.3.0",
56
- "jsdom": "^27.1.0",
57
- "pg": "^8.16.3",
58
- "prettier": "^3.6.2",
59
- "release-it": "^19.0.5",
60
- "tsup": "^8.5.0",
54
+ "eslint": "^10.0.2",
55
+ "flydrive": "^2.0.0",
56
+ "jsdom": "^28.1.0",
57
+ "pg": "^8.18.0",
58
+ "prettier": "^3.8.1",
59
+ "release-it": "^19.2.4",
60
+ "tsdown": "^0.20.3",
61
61
  "typescript": "^5.9.3"
62
62
  },
63
63
  "dependencies": {
64
- "@poppinss/colors": "^4.1.5",
65
- "@poppinss/dumper": "^0.6.5",
66
- "@speed-highlight/core": "^1.2.9",
64
+ "@poppinss/colors": "^4.1.6",
65
+ "@poppinss/dumper": "^0.7.0",
66
+ "@speed-highlight/core": "^1.2.14",
67
67
  "cookie-es": "^2.0.0",
68
68
  "youch-core": "^0.3.3"
69
69
  },
@@ -82,7 +82,7 @@
82
82
  "access": "public",
83
83
  "provenance": true
84
84
  },
85
- "tsup": {
85
+ "tsdown": {
86
86
  "entry": [
87
87
  "index.ts",
88
88
  "src/types.ts",
@@ -91,8 +91,11 @@
91
91
  "outDir": "./build",
92
92
  "clean": true,
93
93
  "format": "esm",
94
+ "minify": "dce-only",
95
+ "fixedExtension": false,
94
96
  "dts": false,
95
- "sourcemap": false,
97
+ "treeshake": false,
98
+ "sourcemaps": false,
96
99
  "target": "esnext"
97
100
  },
98
101
  "release-it": {
@@ -1,67 +1,20 @@
1
1
  import "#nitro/virtual/polyfills";
2
- import { Server } from "node:http";
3
- import { parentPort, threadId } from "node:worker_threads";
4
- import wsAdapter from "crossws/adapters/node";
5
- import { toNodeHandler } from "srvx/node";
6
- import { getSocketAddress, isSocketSupported } from "get-port-please";
7
2
  import { useNitroApp, useNitroHooks } from "nitro/app";
8
3
  import { startScheduleRunner } from "#nitro/runtime/task";
9
4
  import { trapUnhandledErrors } from "#nitro/runtime/error/hooks";
10
5
  import { resolveWebsocketHooks } from "#nitro/runtime/app";
11
- // Listen for shutdown signal from runner
12
- parentPort?.on("message", (msg) => {
13
- if (msg && msg.event === "shutdown") {
14
- shutdown();
15
- }
16
- });
17
6
  const nitroApp = useNitroApp();
18
7
  const nitroHooks = useNitroHooks();
19
8
  trapUnhandledErrors();
20
- const server = new Server(toNodeHandler(nitroApp.fetch));
21
- let listener;
22
- listen().catch((error) => {
23
- console.error("Dev worker failed to listen:", error);
24
- return shutdown();
25
- });
26
- // https://crossws.unjs.io/adapters/node
27
- if (import.meta._websocket) {
28
- const { handleUpgrade } = wsAdapter({ resolve: resolveWebsocketHooks });
29
- server.on("upgrade", handleUpgrade);
30
- }
31
9
  // Scheduled tasks
32
10
  if (import.meta._tasks) {
33
- startScheduleRunner();
34
- }
35
- // --- utils ---
36
- async function listen() {
37
- const listenAddr = await isSocketSupported() ? getSocketAddress({
38
- name: `nitro-dev-${threadId}`,
39
- pid: true,
40
- random: true
41
- }) : {
42
- port: 0,
43
- host: "localhost"
44
- };
45
- return new Promise((resolve, reject) => {
46
- try {
47
- listener = server.listen(listenAddr, () => {
48
- const address = server.address();
49
- parentPort?.postMessage({
50
- event: "listen",
51
- address: typeof address === "string" ? { socketPath: address } : {
52
- host: "localhost",
53
- port: address?.port
54
- }
55
- });
56
- resolve();
57
- });
58
- } catch (error) {
59
- reject(error);
60
- }
61
- });
62
- }
63
- async function shutdown() {
64
- server.closeAllConnections?.();
65
- await Promise.all([new Promise((resolve) => listener?.close(resolve)), nitroHooks.callHook("close")]).catch(console.error);
66
- parentPort?.postMessage({ event: "exit" });
11
+ startScheduleRunner({});
67
12
  }
13
+ const ws = import.meta._websocket ? await import("crossws/adapters/node").then((m) => (m.default || m)({ resolve: resolveWebsocketHooks })) : undefined;
14
+ export default {
15
+ fetch: nitroApp.fetch,
16
+ upgrade: ws ? (context) => {
17
+ ws.handleUpgrade(context.node.req, context.node.socket, context.node.head);
18
+ } : undefined,
19
+ ipc: { onClose: () => nitroHooks.callHook("close") }
20
+ };
@@ -1,5 +1,6 @@
1
1
  import "#nitro/virtual/polyfills";
2
2
  import consola from "consola";
3
+ import { HTTPError } from "h3";
3
4
  import { useNitroApp, useNitroHooks } from "nitro/app";
4
5
  const nitroApp = useNitroApp();
5
6
  const nitroHooks = useNitroHooks();
@@ -11,7 +11,6 @@ addEventListener("fetch", (event) => {
11
11
  // srvx compatibility
12
12
  const req = event.request;
13
13
  req.runtime ??= { name: "service-worker" };
14
- // @ts-expect-error (add to srvx types)
15
14
  req.runtime.serviceWorker ??= { event };
16
15
  req.waitUntil = event.waitUntil.bind(event);
17
16
  event.respondWith(nitroApp.fetch(req));
@@ -5,11 +5,13 @@ const nitroApp = useNitroApp();
5
5
  export const handler = awslambda.streamifyResponse(async (event, responseStream, context) => {
6
6
  const request = awsRequest(event, context);
7
7
  const response = await nitroApp.fetch(request);
8
- response.headers.set("transfer-encoding", "chunked");
9
8
  const httpResponseMetadata = {
10
9
  statusCode: response.status,
11
10
  ...awsResponseHeaders(response)
12
11
  };
12
+ if (!httpResponseMetadata.headers["transfer-encoding"]) {
13
+ httpResponseMetadata.headers["transfer-encoding"] = "chunked";
14
+ }
13
15
  const body = response.body ?? new ReadableStream({ start(controller) {
14
16
  controller.enqueue("");
15
17
  controller.close();
@@ -5,7 +5,8 @@ import { useNitroApp } from "nitro/app";
5
5
  import { startScheduleRunner } from "#nitro/runtime/task";
6
6
  import { trapUnhandledErrors } from "#nitro/runtime/error/hooks";
7
7
  import { resolveWebsocketHooks } from "#nitro/runtime/app";
8
- const port = Number.parseInt(process.env.NITRO_PORT || process.env.PORT || "") || 3e3;
8
+ const _parsedPort = Number.parseInt(process.env.NITRO_PORT ?? process.env.PORT ?? "");
9
+ const port = Number.isNaN(_parsedPort) ? 3e3 : _parsedPort;
9
10
  const host = process.env.NITRO_HOST || process.env.HOST;
10
11
  const cert = process.env.NITRO_SSL_CERT;
11
12
  const key = process.env.NITRO_SSL_KEY;
@@ -21,7 +22,7 @@ if (import.meta._websocket) {
21
22
  return nitroApp.fetch(req);
22
23
  };
23
24
  }
24
- serve({
25
+ const server = serve({
25
26
  port,
26
27
  hostname: host,
27
28
  tls: cert && key ? {
@@ -34,6 +35,6 @@ serve({
34
35
  trapUnhandledErrors();
35
36
  // Scheduled tasks
36
37
  if (import.meta._tasks) {
37
- startScheduleRunner();
38
+ startScheduleRunner({ waitUntil: server.waitUntil });
38
39
  }
39
40
  export default {};
@@ -5,7 +5,8 @@ import { useNitroApp } from "nitro/app";
5
5
  import { startScheduleRunner } from "#nitro/runtime/task";
6
6
  import { trapUnhandledErrors } from "#nitro/runtime/error/hooks";
7
7
  import { resolveWebsocketHooks } from "#nitro/runtime/app";
8
- const port = Number.parseInt(process.env.NITRO_PORT || process.env.PORT || "") || 3e3;
8
+ const _parsedPort = Number.parseInt(process.env.NITRO_PORT ?? process.env.PORT ?? "");
9
+ const port = Number.isNaN(_parsedPort) ? 3e3 : _parsedPort;
9
10
  const host = process.env.NITRO_HOST || process.env.HOST;
10
11
  const cert = process.env.NITRO_SSL_CERT;
11
12
  const key = process.env.NITRO_SSL_KEY;
@@ -21,7 +22,7 @@ if (import.meta._websocket) {
21
22
  return nitroApp.fetch(req);
22
23
  };
23
24
  }
24
- serve({
25
+ const server = serve({
25
26
  port,
26
27
  hostname: host,
27
28
  tls: cert && key ? {
@@ -33,6 +34,6 @@ serve({
33
34
  trapUnhandledErrors();
34
35
  // Scheduled tasks
35
36
  if (import.meta._tasks) {
36
- startScheduleRunner();
37
+ startScheduleRunner({ waitUntil: server.waitUntil });
37
38
  }
38
39
  export default {};