nitro 3.0.1-alpha.2 → 3.0.260415-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 (297) 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 +7261 -3812
  5. package/dist/_build/rolldown.mjs +32 -42
  6. package/dist/_build/rollup.mjs +28 -48
  7. package/dist/_build/vite.build.mjs +10 -10
  8. package/dist/_chunks/nitro.mjs +102 -327
  9. package/dist/_chunks/nitro2.mjs +8 -9
  10. package/dist/_chunks/nitro3.mjs +136 -0
  11. package/dist/_chunks/nitro4.mjs +127 -0
  12. package/dist/_chunks/utils.mjs +40 -29
  13. package/dist/_common.mjs +13 -25
  14. package/dist/_dev.d.mts +0 -3
  15. package/dist/{_chunks/dev.mjs → _dev.mjs} +132 -330
  16. package/dist/_libs/_.mjs +2 -0
  17. package/dist/_libs/_2.mjs +2 -0
  18. package/dist/_libs/_3.mjs +2 -0
  19. package/dist/_libs/_4.mjs +2 -0
  20. package/dist/_libs/_5.mjs +2 -0
  21. package/dist/_libs/_6.mjs +2 -0
  22. package/dist/_libs/_7.mjs +2 -0
  23. package/dist/_libs/c12+rc9.mjs +814 -0
  24. package/dist/_libs/{c12+giget+readdirp+chokidar.d.mts → c12+readdirp+chokidar.d.mts} +49 -40
  25. package/dist/_libs/citty.mjs +142 -41
  26. package/dist/_libs/commondir+is-reference.mjs +60 -56
  27. package/dist/_libs/compatx.d.mts +0 -2
  28. package/dist/_libs/compatx.mjs +1 -4
  29. package/dist/_libs/esbuild.d.mts +0 -1
  30. package/dist/_libs/escape-string-regexp.mjs +1 -4
  31. package/dist/_libs/{pluginutils+plugin-commonjs.d.mts → estree+pluginutils.d.mts} +0 -5
  32. package/dist/_libs/estree-walker.mjs +4 -92
  33. package/dist/_libs/exsolve.d.mts +1 -0
  34. package/dist/_libs/hasown+resolve+deepmerge.mjs +160 -246
  35. package/dist/_libs/httpxy.d.mts +20 -13
  36. package/dist/_libs/httpxy.mjs +519 -95
  37. package/dist/_libs/js-tokens.d.mts +1 -0
  38. package/dist/_libs/klona.mjs +1 -4
  39. package/dist/_libs/magic-string.d.mts +0 -2
  40. package/dist/_libs/mlly.d.mts +0 -2
  41. package/dist/_libs/nypm+tinyexec.mjs +822 -0
  42. package/dist/_libs/perfect-debounce.mjs +68 -0
  43. package/dist/_libs/pkg-types.d.mts +0 -3
  44. package/dist/_libs/plugin-alias.mjs +1 -5
  45. package/dist/_libs/plugin-inject.mjs +1 -7
  46. package/dist/_libs/plugin-json.mjs +1 -5
  47. package/dist/_libs/pluginutils.mjs +3 -35
  48. package/dist/_libs/readdirp+chokidar.mjs +187 -365
  49. package/dist/_libs/remapping.mjs +1 -5
  50. package/dist/_libs/resolve-uri+gen-mapping.mjs +15 -53
  51. package/dist/_libs/rou3.d.mts +1 -4
  52. package/dist/_libs/rou3.mjs +223 -78
  53. package/dist/_libs/std-env.d.mts +8 -2
  54. package/dist/_libs/strip-literal.d.mts +1 -0
  55. package/dist/_libs/tsconfck.mjs +21 -334
  56. package/dist/_libs/ultrahtml.mjs +3 -16
  57. package/dist/_libs/unimport+unplugin.mjs +244 -388
  58. package/dist/_libs/unplugin+unimport.d.mts +5 -15
  59. package/dist/_libs/unwasm.d.mts +0 -3
  60. package/dist/_presets.mjs +576 -488
  61. package/dist/builder.d.mts +5 -25
  62. package/dist/builder.mjs +3 -8
  63. package/dist/cli/_chunks/build.mjs +22 -25
  64. package/dist/cli/_chunks/common.mjs +1 -4
  65. package/dist/cli/_chunks/deploy.mjs +37 -0
  66. package/dist/cli/_chunks/dev.mjs +6 -11
  67. package/dist/cli/_chunks/docs.mjs +28 -0
  68. package/dist/cli/_chunks/list.mjs +4 -8
  69. package/dist/cli/_chunks/prepare.mjs +2 -6
  70. package/dist/cli/_chunks/preview.mjs +48 -0
  71. package/dist/cli/_chunks/run.mjs +7 -11
  72. package/dist/cli/_chunks/task.mjs +1 -5
  73. package/dist/cli/index.mjs +5 -6
  74. package/dist/docs/0.docs/0.index/index.md +56 -0
  75. package/dist/docs/0.docs/1.quick-start.md +110 -0
  76. package/dist/docs/0.docs/10.lifecycle.md +204 -0
  77. package/dist/docs/0.docs/11.openapi.md +291 -0
  78. package/dist/docs/0.docs/12.plugins.md +164 -0
  79. package/dist/docs/0.docs/13.tasks.md +277 -0
  80. package/dist/docs/0.docs/14.websocket.md +386 -0
  81. package/dist/docs/0.docs/15.migration.md +213 -0
  82. package/dist/docs/0.docs/16.nightly.md +31 -0
  83. package/dist/docs/0.docs/2.renderer.md +322 -0
  84. package/dist/docs/0.docs/3.routing.md +711 -0
  85. package/dist/docs/0.docs/4.server-entry.md +239 -0
  86. package/dist/docs/0.docs/5.cache.md +408 -0
  87. package/dist/docs/0.docs/6.storage.md +261 -0
  88. package/dist/docs/0.docs/7.assets.md +166 -0
  89. package/dist/docs/0.docs/8.configuration.md +256 -0
  90. package/dist/docs/0.docs/9.database.md +185 -0
  91. package/dist/docs/1.deploy/0.index/index.md +64 -0
  92. package/dist/docs/1.deploy/1.runtimes/0.node.md +63 -0
  93. package/dist/docs/1.deploy/1.runtimes/1.bun.md +15 -0
  94. package/dist/docs/1.deploy/1.runtimes/2.deno.md +19 -0
  95. package/dist/docs/1.deploy/2.providers/0.alwaysdata.md +50 -0
  96. package/dist/docs/1.deploy/2.providers/1.aws.md +47 -0
  97. package/dist/docs/1.deploy/2.providers/10.flightcontrol.md +67 -0
  98. package/dist/docs/1.deploy/2.providers/11.genezio.md +67 -0
  99. package/dist/docs/1.deploy/2.providers/12.github-pages.md +68 -0
  100. package/dist/docs/1.deploy/2.providers/13.gitlab-pages.md +37 -0
  101. package/dist/docs/1.deploy/2.providers/14.heroku.md +84 -0
  102. package/dist/docs/1.deploy/2.providers/15.iis.md +38 -0
  103. package/dist/docs/1.deploy/2.providers/16.koyeb.md +109 -0
  104. package/dist/docs/1.deploy/2.providers/17.netlify.md +47 -0
  105. package/dist/docs/1.deploy/2.providers/18.platform-sh.md +37 -0
  106. package/dist/docs/1.deploy/2.providers/19.render.md +37 -0
  107. package/dist/docs/1.deploy/2.providers/2.aws-amplify.md +81 -0
  108. package/dist/docs/1.deploy/2.providers/20.stormkit.md +24 -0
  109. package/dist/docs/1.deploy/2.providers/21.vercel.md +270 -0
  110. package/dist/docs/1.deploy/2.providers/22.zeabur.md +19 -0
  111. package/dist/docs/1.deploy/2.providers/23.zephyr.md +99 -0
  112. package/dist/docs/1.deploy/2.providers/24.zerops.md +102 -0
  113. package/dist/docs/1.deploy/2.providers/3.azure.md +72 -0
  114. package/dist/docs/1.deploy/2.providers/4.cleavr.md +33 -0
  115. package/dist/docs/1.deploy/2.providers/5.cloudflare.md +369 -0
  116. package/dist/docs/1.deploy/2.providers/6.deno-deploy.md +66 -0
  117. package/dist/docs/1.deploy/2.providers/7.digitalocean.md +46 -0
  118. package/dist/docs/1.deploy/2.providers/8.edgeone.md +20 -0
  119. package/dist/docs/1.deploy/2.providers/9.firebase.md +32 -0
  120. package/dist/docs/2.config/0.index/index.md +1221 -0
  121. package/dist/docs/3.examples/0.index/index.md +3 -0
  122. package/dist/docs/3.examples/1.api-routes.md +145 -0
  123. package/dist/docs/3.examples/10.hono.md +74 -0
  124. package/dist/docs/3.examples/11.import-alias.md +97 -0
  125. package/dist/docs/3.examples/12.middleware.md +91 -0
  126. package/dist/docs/3.examples/13.mono-jsx.md +68 -0
  127. package/dist/docs/3.examples/14.nano-jsx.md +70 -0
  128. package/dist/docs/3.examples/15.plugins.md +91 -0
  129. package/dist/docs/3.examples/16.renderer.md +113 -0
  130. package/dist/docs/3.examples/17.runtime-config.md +97 -0
  131. package/dist/docs/3.examples/18.server-fetch.md +87 -0
  132. package/dist/docs/3.examples/19.shiki.md +198 -0
  133. package/dist/docs/3.examples/2.auto-imports.md +92 -0
  134. package/dist/docs/3.examples/20.virtual-routes.md +74 -0
  135. package/dist/docs/3.examples/21.vite-nitro-plugin.md +79 -0
  136. package/dist/docs/3.examples/22.vite-rsc.md +1041 -0
  137. package/dist/docs/3.examples/23.vite-ssr-html.md +217 -0
  138. package/dist/docs/3.examples/24.vite-ssr-preact.md +247 -0
  139. package/dist/docs/3.examples/25.vite-ssr-react.md +226 -0
  140. package/dist/docs/3.examples/26.vite-ssr-solid.md +256 -0
  141. package/dist/docs/3.examples/27.vite-ssr-tsr-react.md +442 -0
  142. package/dist/docs/3.examples/28.vite-ssr-tss-react.md +444 -0
  143. package/dist/docs/3.examples/29.vite-ssr-vue-router.md +617 -0
  144. package/dist/docs/3.examples/3.cached-handler.md +81 -0
  145. package/dist/docs/3.examples/30.vite-trpc.md +335 -0
  146. package/dist/docs/3.examples/31.websocket.md +282 -0
  147. package/dist/docs/3.examples/4.custom-error-handler.md +98 -0
  148. package/dist/docs/3.examples/5.database.md +157 -0
  149. package/dist/docs/3.examples/6.elysia.md +70 -0
  150. package/dist/docs/3.examples/7.express.md +78 -0
  151. package/dist/docs/3.examples/8.fastify.md +79 -0
  152. package/dist/docs/3.examples/9.hello-world.md +68 -0
  153. package/dist/docs/README.md +86 -0
  154. package/dist/docs/index.md +121 -0
  155. package/dist/node_modules/@poppinss/dumper/build/formatters/html/main.js +8 -0
  156. package/dist/node_modules/@poppinss/dumper/package.json +1 -1
  157. package/dist/node_modules/@speed-highlight/core/dist/index.js +4 -4
  158. package/dist/node_modules/@speed-highlight/core/dist/terminal.js +2 -2
  159. package/dist/node_modules/@speed-highlight/core/package.json +1 -1
  160. package/dist/node_modules/cookie-es/dist/index.mjs +299 -250
  161. package/dist/node_modules/cookie-es/package.json +26 -23
  162. package/dist/node_modules/croner/dist/croner.js +1 -1
  163. package/dist/node_modules/croner/package.json +11 -1
  164. package/dist/node_modules/defu/dist/defu.mjs +2 -2
  165. package/dist/node_modules/defu/package.json +33 -28
  166. package/dist/node_modules/rendu/dist/_chunks/libs/cookie-es.mjs +151 -0
  167. package/dist/node_modules/rendu/dist/index.mjs +5 -112
  168. package/dist/node_modules/rendu/package.json +25 -24
  169. package/dist/node_modules/youch/build/helpers-B9BQYaS6.js +23 -0
  170. package/dist/node_modules/youch/build/index.js +204 -351
  171. package/dist/node_modules/youch/build/public/error_info/script.js +1 -1
  172. package/dist/node_modules/youch/build/public_dir-C5bujZKB.js +25 -0
  173. package/dist/node_modules/youch/build/src/templates/error_cause/main.js +44 -0
  174. package/dist/node_modules/youch/build/src/templates/error_info/main.js +72 -0
  175. package/dist/node_modules/youch/build/src/templates/error_metadata/main.js +65 -0
  176. package/dist/node_modules/youch/build/src/templates/error_stack/main.js +152 -0
  177. package/dist/node_modules/youch/build/src/templates/error_stack_source/main.js +46 -0
  178. package/dist/node_modules/youch/build/src/templates/header/main.js +24 -0
  179. package/dist/node_modules/youch/build/src/templates/layout/main.js +27 -0
  180. package/dist/node_modules/youch/package.json +35 -32
  181. package/dist/presets/_nitro/runtime/nitro-dev.mjs +12 -57
  182. package/dist/presets/_nitro/runtime/nitro-prerenderer.mjs +1 -0
  183. package/dist/presets/_nitro/runtime/service-worker.mjs +1 -2
  184. package/dist/presets/aws-lambda/runtime/_utils.mjs +6 -6
  185. package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.mjs +3 -1
  186. package/dist/presets/azure/runtime/_utils.mjs +5 -5
  187. package/dist/presets/azure/runtime/azure-swa.mjs +5 -5
  188. package/dist/presets/bun/runtime/bun.mjs +9 -6
  189. package/dist/presets/cloudflare/runtime/_module-handler.mjs +1 -1
  190. package/dist/presets/cloudflare/runtime/cloudflare-durable.mjs +4 -4
  191. package/dist/presets/cloudflare/runtime/cloudflare-module.mjs +3 -3
  192. package/dist/presets/cloudflare/runtime/cloudflare-pages.mjs +2 -2
  193. package/dist/presets/cloudflare/runtime/plugin.dev.mjs +10 -21
  194. package/dist/presets/deno/runtime/deno-deploy.mjs +4 -4
  195. package/dist/presets/deno/runtime/deno-server.mjs +9 -6
  196. package/dist/presets/edgeone/runtime/edgeone.mjs +10 -0
  197. package/dist/presets/netlify/runtime/netlify-edge.mjs +2 -3
  198. package/dist/presets/netlify/runtime/netlify.mjs +1 -1
  199. package/dist/presets/node/runtime/node-cluster.mjs +5 -4
  200. package/dist/presets/node/runtime/node-middleware.mjs +1 -1
  201. package/dist/presets/node/runtime/node-server.mjs +8 -5
  202. package/dist/presets/stormkit/runtime/stormkit.mjs +1 -2
  203. package/dist/presets/vercel/runtime/cron-handler.mjs +25 -0
  204. package/dist/presets/vercel/runtime/queue-handler.mjs +21 -0
  205. package/dist/presets/vercel/runtime/vercel.node.mjs +3 -3
  206. package/dist/presets/vercel/runtime/vercel.web.mjs +3 -5
  207. package/dist/presets/winterjs/runtime/winterjs.mjs +10 -10
  208. package/dist/presets/zephyr/runtime/server.mjs +3 -0
  209. package/dist/runtime/internal/app.mjs +12 -11
  210. package/dist/runtime/internal/cache.d.mts +0 -4
  211. package/dist/runtime/internal/cache.mjs +32 -256
  212. package/dist/runtime/internal/context.d.mts +3 -1
  213. package/dist/runtime/internal/context.mjs +1 -9
  214. package/dist/runtime/internal/error/dev.d.mts +5 -4
  215. package/dist/runtime/internal/error/dev.mjs +47 -49
  216. package/dist/runtime/internal/error/hooks.d.mts +1 -1
  217. package/dist/runtime/internal/error/prod.d.mts +2 -5
  218. package/dist/runtime/internal/error/prod.mjs +19 -33
  219. package/dist/runtime/internal/error/utils.d.mts +4 -4
  220. package/dist/runtime/internal/meta.d.mts +1 -1
  221. package/dist/runtime/internal/plugin.d.mts +2 -2
  222. package/dist/runtime/internal/route-rules.d.mts +11 -4
  223. package/dist/runtime/internal/route-rules.mjs +15 -5
  224. package/dist/runtime/internal/routes/dev-tasks.d.mts +3 -2
  225. package/dist/runtime/internal/routes/dev-tasks.mjs +15 -10
  226. package/dist/runtime/internal/routes/openapi.mjs +2 -2
  227. package/dist/runtime/internal/routes/renderer-template.d.mts +1 -1
  228. package/dist/runtime/internal/routes/renderer-template.dev.d.mts +2 -1
  229. package/dist/runtime/internal/routes/scalar.mjs +3 -3
  230. package/dist/runtime/internal/routes/swagger.mjs +7 -4
  231. package/dist/runtime/internal/runtime-config.d.mts +1 -1
  232. package/dist/runtime/internal/runtime-config.mjs +2 -2
  233. package/dist/runtime/internal/static.mjs +5 -4
  234. package/dist/runtime/internal/task.d.mts +3 -1
  235. package/dist/runtime/internal/task.mjs +7 -7
  236. package/dist/runtime/internal/vite/dev-entry.mjs +6 -3
  237. package/dist/runtime/internal/vite/dev-worker.mjs +264 -0
  238. package/dist/runtime/meta.d.mts +1 -0
  239. package/dist/runtime/meta.mjs +2 -0
  240. package/dist/runtime/nitro.d.mts +2 -0
  241. package/dist/runtime/nitro.mjs +4 -2
  242. package/dist/runtime/virtual/error-handler.mjs +1 -1
  243. package/dist/runtime/virtual/renderer-template.mjs +1 -1
  244. package/dist/runtime/virtual/server-assets.d.mts +2 -1
  245. package/dist/runtime/virtual/tracing.d.mts +5 -0
  246. package/dist/runtime/virtual/tracing.mjs +1 -0
  247. package/dist/runtime/vite.d.mts +1 -1
  248. package/dist/types/index.d.mts +215 -195
  249. package/dist/types/index.mjs +1 -11
  250. package/dist/vite.d.mts +3 -8
  251. package/dist/vite.mjs +285 -253
  252. package/lib/tsconfig.json +3 -5
  253. package/package.json +97 -80
  254. package/dist/_libs/confbox.mjs +0 -2509
  255. package/dist/_libs/nypm+giget+tinyexec.mjs +0 -3603
  256. package/dist/_libs/rc9+c12+dotenv.mjs +0 -972
  257. package/dist/node_modules/hookable/dist/index.mjs +0 -266
  258. package/dist/node_modules/hookable/package.json +0 -52
  259. package/dist/node_modules/youch/build/chunk-4L7RY2JA.js +0 -42
  260. package/dist/node_modules/youch/build/chunk-7QV3D5YX.js +0 -83
  261. package/dist/node_modules/youch/build/chunk-AUGPHE32.js +0 -39
  262. package/dist/node_modules/youch/build/chunk-CM7DWJNZ.js +0 -44
  263. package/dist/node_modules/youch/build/chunk-EJH674NB.js +0 -223
  264. package/dist/node_modules/youch/build/chunk-OIJ3WD7L.js +0 -81
  265. package/dist/node_modules/youch/build/chunk-P36L72PL.js +0 -87
  266. package/dist/node_modules/youch/build/chunk-PE3GG3TN.js +0 -65
  267. package/dist/node_modules/youch/build/chunk-X53OIOJH.js +0 -70
  268. package/dist/presets/_nitro/runtime/nitro-dev.d.mts +0 -2
  269. package/dist/presets/_nitro/runtime/nitro-prerenderer.d.mts +0 -3
  270. package/dist/presets/_nitro/runtime/service-worker.d.mts +0 -2
  271. package/dist/presets/aws-amplify/runtime/aws-amplify.d.mts +0 -2
  272. package/dist/presets/aws-lambda/runtime/_utils.d.mts +0 -8
  273. package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.d.mts +0 -2
  274. package/dist/presets/aws-lambda/runtime/aws-lambda.d.mts +0 -3
  275. package/dist/presets/azure/runtime/_utils.d.mts +0 -2
  276. package/dist/presets/azure/runtime/azure-swa.d.mts +0 -5
  277. package/dist/presets/bun/runtime/bun.d.mts +0 -3
  278. package/dist/presets/cloudflare/runtime/_module-handler.d.mts +0 -16
  279. package/dist/presets/cloudflare/runtime/cloudflare-durable.d.mts +0 -11
  280. package/dist/presets/cloudflare/runtime/cloudflare-module.d.mts +0 -3
  281. package/dist/presets/cloudflare/runtime/cloudflare-pages.d.mts +0 -20
  282. package/dist/presets/cloudflare/runtime/plugin.dev.d.mts +0 -3
  283. package/dist/presets/deno/runtime/deno-deploy.d.mts +0 -5
  284. package/dist/presets/deno/runtime/deno-server.d.mts +0 -3
  285. package/dist/presets/netlify/runtime/netlify-edge.d.mts +0 -3
  286. package/dist/presets/netlify/runtime/netlify.d.mts +0 -4
  287. package/dist/presets/node/runtime/node-cluster.d.mts +0 -3
  288. package/dist/presets/node/runtime/node-middleware.d.mts +0 -3
  289. package/dist/presets/node/runtime/node-server.d.mts +0 -3
  290. package/dist/presets/standard/runtime/server.d.mts +0 -3
  291. package/dist/presets/stormkit/runtime/stormkit.d.mts +0 -21
  292. package/dist/presets/vercel/runtime/isr.d.mts +0 -2
  293. package/dist/presets/vercel/runtime/vercel.node.d.mts +0 -3
  294. package/dist/presets/vercel/runtime/vercel.web.d.mts +0 -8
  295. package/dist/presets/winterjs/runtime/winterjs.d.mts +0 -2
  296. package/dist/presets/zeabur/runtime/zeabur.d.mts +0 -3
  297. package/dist/runtime/internal/vite/node-runner.mjs +0 -359
@@ -1,359 +1,212 @@
1
- import {
2
- Layout
3
- } from "./chunk-CM7DWJNZ.js";
4
- import {
5
- ErrorCause
6
- } from "./chunk-X53OIOJH.js";
7
- import {
8
- ErrorInfo
9
- } from "./chunk-OIJ3WD7L.js";
10
- import {
11
- ErrorMetadata
12
- } from "./chunk-P36L72PL.js";
13
- import {
14
- ErrorStack
15
- } from "./chunk-EJH674NB.js";
16
- import {
17
- ErrorStackSource
18
- } from "./chunk-7QV3D5YX.js";
19
- import "./chunk-4L7RY2JA.js";
20
- import {
21
- Header
22
- } from "./chunk-AUGPHE32.js";
23
- import {
24
- BaseComponent
25
- } from "./chunk-PE3GG3TN.js";
26
-
27
- // src/youch.ts
1
+ import { n as BaseComponent } from "./public_dir-C5bujZKB.js";
2
+ import { Header } from "./src/templates/header/main.js";
3
+ import { Layout } from "./src/templates/layout/main.js";
4
+ import "./helpers-B9BQYaS6.js";
5
+ import { ErrorInfo } from "./src/templates/error_info/main.js";
6
+ import { ErrorCause } from "./src/templates/error_cause/main.js";
7
+ import { ErrorStack } from "./src/templates/error_stack/main.js";
8
+ import { ErrorMetadata } from "./src/templates/error_metadata/main.js";
9
+ import { ErrorStackSource } from "./src/templates/error_stack_source/main.js";
28
10
  import { parse } from "cookie-es";
29
11
  import { ErrorParser } from "youch-core";
30
-
31
- // src/metadata.ts
12
+ import { createScript, createStyleSheet } from "@poppinss/dumper/html";
32
13
  var Metadata = class {
33
- #groups = {};
34
- /**
35
- * Converts value to an array (if not an array already)
36
- */
37
- #toArray(value) {
38
- return Array.isArray(value) ? value : [value];
39
- }
40
- /**
41
- * Define a group, its sections and their rows. In case of
42
- * existing groups/sections, the new data will be merged
43
- * with the existing data
44
- */
45
- group(name, sections) {
46
- this.#groups[name] = this.#groups[name] ?? {};
47
- Object.keys(sections).forEach((section) => {
48
- if (!this.#groups[name][section]) {
49
- this.#groups[name][section] = sections[section];
50
- } else {
51
- this.#groups[name][section] = this.#toArray(this.#groups[name][section]);
52
- this.#groups[name][section].push(...this.#toArray(sections[section]));
53
- }
54
- });
55
- return this;
56
- }
57
- /**
58
- * Returns the existing metadata groups, sections and
59
- * rows.
60
- */
61
- toJSON() {
62
- return this.#groups;
63
- }
14
+ #groups = {};
15
+ #toArray(value) {
16
+ return Array.isArray(value) ? value : [value];
17
+ }
18
+ group(name, sections) {
19
+ this.#groups[name] = this.#groups[name] ?? {};
20
+ Object.keys(sections).forEach((section) => {
21
+ if (!this.#groups[name][section]) this.#groups[name][section] = sections[section];
22
+ else {
23
+ this.#groups[name][section] = this.#toArray(this.#groups[name][section]);
24
+ this.#groups[name][section].push(...this.#toArray(sections[section]));
25
+ }
26
+ });
27
+ return this;
28
+ }
29
+ toJSON() {
30
+ return this.#groups;
31
+ }
64
32
  };
65
-
66
- // src/templates.ts
67
- import { createScript, createStyleSheet } from "@poppinss/dumper/html";
68
33
  var Templates = class {
69
- constructor(devMode) {
70
- this.devMode = devMode;
71
- this.#knownTemplates = {
72
- layout: new Layout(devMode),
73
- header: new Header(devMode),
74
- errorInfo: new ErrorInfo(devMode),
75
- errorStack: new ErrorStack(devMode),
76
- errorStackSource: new ErrorStackSource(devMode),
77
- errorCause: new ErrorCause(devMode),
78
- errorMetadata: new ErrorMetadata(devMode)
79
- };
80
- }
81
- #knownTemplates;
82
- #styles = /* @__PURE__ */ new Map([["global", createStyleSheet()]]);
83
- #scripts = /* @__PURE__ */ new Map([["global", createScript()]]);
84
- /**
85
- * Returns a collection of style and script tags to dump
86
- * inside the document HEAD.
87
- */
88
- #getStylesAndScripts(cspNonce) {
89
- let customInjectedStyles = "";
90
- let globalScript = "";
91
- const styles = [];
92
- const scripts = [];
93
- const cspNonceAttr = cspNonce ? ` nonce="${cspNonce}"` : "";
94
- this.#styles.forEach((bucket, name) => {
95
- if (name === "injected") {
96
- customInjectedStyles = `<style id="${name}-styles"${cspNonceAttr}>${bucket}</style>`;
97
- } else {
98
- styles.push(`<style id="${name}-styles"${cspNonceAttr}>${bucket}</style>`);
99
- }
100
- });
101
- this.#scripts.forEach((bucket, name) => {
102
- if (name === "global") {
103
- globalScript = `<script id="${name}-script"${cspNonceAttr}>${bucket}</script>`;
104
- }
105
- scripts.push(`<script id="${name}-script"${cspNonceAttr}>${bucket}</script>`);
106
- });
107
- return {
108
- styles: `${styles.join("\n")}
109
- ${customInjectedStyles}`,
110
- scripts: scripts.join("\n"),
111
- globalScript
112
- };
113
- }
114
- /**
115
- * Collects styles and scripts for components as we render
116
- * them.
117
- */
118
- async #collectStylesAndScripts(templateName) {
119
- if (!this.#styles.has(templateName)) {
120
- const styles = await this.#knownTemplates[templateName].getStyles();
121
- if (styles) {
122
- this.#styles.set(templateName, styles);
123
- }
124
- }
125
- if (!this.#scripts.has(templateName)) {
126
- const script = await this.#knownTemplates[templateName].getScript();
127
- if (script) {
128
- this.#scripts.set(templateName, script);
129
- }
130
- }
131
- }
132
- /**
133
- * Returns the HTML for a given template
134
- */
135
- async #tmplToHTML(templateName, props) {
136
- const component = this.#knownTemplates[templateName];
137
- if (!component) {
138
- throw new Error(`Invalid template "${templateName}"`);
139
- }
140
- await this.#collectStylesAndScripts(templateName);
141
- return component.toHTML(props);
142
- }
143
- /**
144
- * Returns the ANSI output for a given template
145
- */
146
- async #tmplToANSI(templateName, props) {
147
- const component = this.#knownTemplates[templateName];
148
- if (!component) {
149
- throw new Error(`Invalid template "${templateName}"`);
150
- }
151
- return component.toANSI(props);
152
- }
153
- /**
154
- * Define a custom component to be used in place of the default component.
155
- * Overriding components allows you control the HTML layout, styles and
156
- * the frontend scripts of an HTML fragment.
157
- */
158
- use(templateName, component) {
159
- this.#knownTemplates[templateName] = component;
160
- return this;
161
- }
162
- /**
163
- * Inject custom styles to the document. Injected styles are
164
- * always placed after the global and the components style
165
- * tags.
166
- */
167
- injectStyles(cssFragment) {
168
- let injectedStyles = this.#styles.get("injected") ?? "";
169
- injectedStyles += `
170
- ${cssFragment}`;
171
- this.#styles.set("injected", injectedStyles);
172
- return this;
173
- }
174
- /**
175
- * Returns the HTML output for the given parsed error
176
- */
177
- async toHTML(props) {
178
- const html = await this.#tmplToHTML("layout", {
179
- title: props.title,
180
- ide: props.ide,
181
- cspNonce: props.cspNonce,
182
- children: async () => {
183
- const header = await this.#tmplToHTML("header", props);
184
- const info = await this.#tmplToHTML("errorInfo", props);
185
- const stackTrace = await this.#tmplToHTML("errorStack", {
186
- ide: process.env.EDITOR ?? "vscode",
187
- sourceCodeRenderer: (error, frame) => {
188
- return this.#tmplToHTML("errorStackSource", {
189
- error,
190
- frame,
191
- ide: props.ide,
192
- cspNonce: props.cspNonce
193
- });
194
- },
195
- ...props
196
- });
197
- const cause = await this.#tmplToHTML("errorCause", props);
198
- const metadata = await this.#tmplToHTML("errorMetadata", props);
199
- return `${header}${info}${stackTrace}${cause}${metadata}`;
200
- }
201
- });
202
- const { globalScript, scripts, styles } = this.#getStylesAndScripts(props.cspNonce);
203
- return html.replace("<!-- STYLES -->", styles).replace("<!-- SCRIPTS -->", scripts).replace("<!-- GLOBAL SCRIPT -->", globalScript);
204
- }
205
- /**
206
- * Returns the ANSI output to be printed on the terminal
207
- */
208
- async toANSI(props) {
209
- const ansiOutput = await this.#tmplToANSI("layout", {
210
- title: props.title,
211
- children: async () => {
212
- const header = await this.#tmplToANSI("header", {});
213
- const info = await this.#tmplToANSI("errorInfo", props);
214
- const stackTrace = await this.#tmplToANSI("errorStack", {
215
- ide: process.env.EDITOR ?? "vscode",
216
- sourceCodeRenderer: (error, frame) => {
217
- return this.#tmplToANSI("errorStackSource", {
218
- error,
219
- frame
220
- });
221
- },
222
- ...props
223
- });
224
- const cause = await this.#tmplToANSI("errorCause", props);
225
- const metadata = await this.#tmplToANSI("errorMetadata", props);
226
- return `${header}${info}${stackTrace}${cause}${metadata}`;
227
- }
228
- });
229
- return ansiOutput;
230
- }
34
+ #knownTemplates;
35
+ #styles = new Map([["global", createStyleSheet()]]);
36
+ #scripts = new Map([["global", createScript()]]);
37
+ constructor(devMode) {
38
+ this.devMode = devMode;
39
+ this.#knownTemplates = {
40
+ layout: new Layout(devMode),
41
+ header: new Header(devMode),
42
+ errorInfo: new ErrorInfo(devMode),
43
+ errorStack: new ErrorStack(devMode),
44
+ errorStackSource: new ErrorStackSource(devMode),
45
+ errorCause: new ErrorCause(devMode),
46
+ errorMetadata: new ErrorMetadata(devMode)
47
+ };
48
+ }
49
+ #getStylesAndScripts(cspNonce) {
50
+ let customInjectedStyles = "";
51
+ let globalScript = "";
52
+ const styles = [];
53
+ const scripts = [];
54
+ const cspNonceAttr = cspNonce ? ` nonce="${cspNonce}"` : "";
55
+ this.#styles.forEach((bucket, name) => {
56
+ if (name === "injected") customInjectedStyles = `<style id="${name}-styles"${cspNonceAttr}>${bucket}</style>`;
57
+ else styles.push(`<style id="${name}-styles"${cspNonceAttr}>${bucket}</style>`);
58
+ });
59
+ this.#scripts.forEach((bucket, name) => {
60
+ if (name === "global") globalScript = `<script id="${name}-script"${cspNonceAttr}>${bucket}<\/script>`;
61
+ scripts.push(`<script id="${name}-script"${cspNonceAttr}>${bucket}<\/script>`);
62
+ });
63
+ return {
64
+ styles: `${styles.join("\n")}\n${customInjectedStyles}`,
65
+ scripts: scripts.join("\n"),
66
+ globalScript
67
+ };
68
+ }
69
+ async #collectStylesAndScripts(templateName) {
70
+ if (!this.#styles.has(templateName)) {
71
+ const styles = await this.#knownTemplates[templateName].getStyles();
72
+ if (styles) this.#styles.set(templateName, styles);
73
+ }
74
+ if (!this.#scripts.has(templateName)) {
75
+ const script = await this.#knownTemplates[templateName].getScript();
76
+ if (script) this.#scripts.set(templateName, script);
77
+ }
78
+ }
79
+ async #tmplToHTML(templateName, props) {
80
+ const component = this.#knownTemplates[templateName];
81
+ if (!component) throw new Error(`Invalid template "${templateName}"`);
82
+ await this.#collectStylesAndScripts(templateName);
83
+ return component.toHTML(props);
84
+ }
85
+ async #tmplToANSI(templateName, props) {
86
+ const component = this.#knownTemplates[templateName];
87
+ if (!component) throw new Error(`Invalid template "${templateName}"`);
88
+ return component.toANSI(props);
89
+ }
90
+ use(templateName, component) {
91
+ this.#knownTemplates[templateName] = component;
92
+ return this;
93
+ }
94
+ injectStyles(cssFragment) {
95
+ let injectedStyles = this.#styles.get("injected") ?? "";
96
+ injectedStyles += `\n${cssFragment}`;
97
+ this.#styles.set("injected", injectedStyles);
98
+ return this;
99
+ }
100
+ async toHTML(props) {
101
+ const html = await this.#tmplToHTML("layout", {
102
+ title: props.title,
103
+ ide: props.ide,
104
+ cspNonce: props.cspNonce,
105
+ children: async () => {
106
+ return `${await this.#tmplToHTML("header", props)}${await this.#tmplToHTML("errorInfo", props)}${await this.#tmplToHTML("errorStack", {
107
+ ide: process.env.EDITOR ?? "vscode",
108
+ sourceCodeRenderer: (error, frame) => {
109
+ return this.#tmplToHTML("errorStackSource", {
110
+ error,
111
+ frame,
112
+ ide: props.ide,
113
+ cspNonce: props.cspNonce
114
+ });
115
+ },
116
+ ...props
117
+ })}${await this.#tmplToHTML("errorCause", props)}${await this.#tmplToHTML("errorMetadata", props)}`;
118
+ }
119
+ });
120
+ const { globalScript, scripts, styles } = this.#getStylesAndScripts(props.cspNonce);
121
+ return html.replace("<!-- STYLES -->", styles).replace("<!-- SCRIPTS -->", scripts).replace("<!-- GLOBAL SCRIPT -->", globalScript);
122
+ }
123
+ async toANSI(props) {
124
+ return await this.#tmplToANSI("layout", {
125
+ title: props.title,
126
+ children: async () => {
127
+ return `${await this.#tmplToANSI("header", {})}${await this.#tmplToANSI("errorInfo", props)}${await this.#tmplToANSI("errorStack", {
128
+ ide: process.env.EDITOR ?? "vscode",
129
+ sourceCodeRenderer: (error, frame) => {
130
+ return this.#tmplToANSI("errorStackSource", {
131
+ error,
132
+ frame
133
+ });
134
+ },
135
+ ...props
136
+ })}${await this.#tmplToANSI("errorCause", props)}${await this.#tmplToANSI("errorMetadata", props)}`;
137
+ }
138
+ });
139
+ }
231
140
  };
232
-
233
- // src/youch.ts
234
141
  var Youch = class {
235
- /**
236
- * Properties to be shared with the Error parser
237
- */
238
- #sourceLoader;
239
- #parsers = [];
240
- #transformers = [];
241
- /**
242
- * Manage templates used for converting error to the HTML
243
- * output
244
- */
245
- templates = new Templates(false);
246
- /**
247
- * Define metadata to be displayed alongside the error output
248
- */
249
- metadata = new Metadata();
250
- /**
251
- * Creates an instance of the ErrorParser and applies the
252
- * source loader, parsers and transformers on it
253
- */
254
- #createErrorParser(options) {
255
- const errorParser = new ErrorParser(options);
256
- if (this.#sourceLoader) {
257
- errorParser.defineSourceLoader(this.#sourceLoader);
258
- }
259
- this.#parsers.forEach((parser) => errorParser.useParser(parser));
260
- this.#transformers.forEach((transformer) => errorParser.useTransformer(transformer));
261
- return errorParser;
262
- }
263
- /**
264
- * Defines the request properties as a metadata group
265
- */
266
- #defineRequestMetadataGroup(request) {
267
- if (!request || Object.keys(request).length === 0) {
268
- return;
269
- }
270
- this.metadata.group("Request", {
271
- ...request.url ? {
272
- url: {
273
- key: "URL",
274
- value: request.url
275
- }
276
- } : {},
277
- ...request.method ? {
278
- method: {
279
- key: "Method",
280
- value: request.method
281
- }
282
- } : {},
283
- ...request.headers ? {
284
- headers: Object.keys(request.headers).map((key) => {
285
- const value = request.headers[key];
286
- return {
287
- key,
288
- value: key === "cookie" ? { ...parse(value) } : value
289
- };
290
- })
291
- } : {}
292
- });
293
- }
294
- /**
295
- * Define custom implementation for loading the source code
296
- * of a stack frame.
297
- */
298
- defineSourceLoader(loader) {
299
- this.#sourceLoader = loader;
300
- return this;
301
- }
302
- /**
303
- * Define a custom parser. Parsers are executed before the
304
- * error gets parsed and provides you with an option to
305
- * modify the error
306
- */
307
- useParser(parser) {
308
- this.#parsers.push(parser);
309
- return this;
310
- }
311
- /**
312
- * Define a custom transformer. Transformers are executed
313
- * after the error has been parsed and can mutate the
314
- * properties of the parsed error.
315
- */
316
- useTransformer(transformer) {
317
- this.#transformers.push(transformer);
318
- return this;
319
- }
320
- /**
321
- * Parses error to JSON
322
- */
323
- async toJSON(error, options) {
324
- options = { ...options };
325
- return this.#createErrorParser({ offset: options.offset }).parse(error);
326
- }
327
- /**
328
- * Render error to HTML
329
- */
330
- async toHTML(error, options) {
331
- options = { ...options };
332
- this.#defineRequestMetadataGroup(options.request);
333
- const parsedError = await this.#createErrorParser({ offset: options.offset }).parse(error);
334
- return this.templates.toHTML({
335
- title: options.title ?? "An error has occurred",
336
- ide: options.ide ?? process.env.IDE ?? "vscode",
337
- cspNonce: options.cspNonce,
338
- error: parsedError,
339
- metadata: this.metadata
340
- });
341
- }
342
- /**
343
- * Render error to ANSI output
344
- */
345
- async toANSI(error, options) {
346
- options = { ...options };
347
- const parsedError = await this.#createErrorParser({ offset: options.offset }).parse(error);
348
- return this.templates.toANSI({
349
- title: "",
350
- error: parsedError,
351
- metadata: this.metadata
352
- });
353
- }
354
- };
355
- export {
356
- BaseComponent,
357
- Metadata,
358
- Youch
142
+ #sourceLoader;
143
+ #parsers = [];
144
+ #transformers = [];
145
+ templates = new Templates(false);
146
+ metadata = new Metadata();
147
+ #createErrorParser(options) {
148
+ const errorParser = new ErrorParser(options);
149
+ if (this.#sourceLoader) errorParser.defineSourceLoader(this.#sourceLoader);
150
+ this.#parsers.forEach((parser) => errorParser.useParser(parser));
151
+ this.#transformers.forEach((transformer) => errorParser.useTransformer(transformer));
152
+ return errorParser;
153
+ }
154
+ #defineRequestMetadataGroup(request) {
155
+ if (!request || Object.keys(request).length === 0) return;
156
+ this.metadata.group("Request", {
157
+ ...request.url ? { url: {
158
+ key: "URL",
159
+ value: request.url
160
+ } } : {},
161
+ ...request.method ? { method: {
162
+ key: "Method",
163
+ value: request.method
164
+ } } : {},
165
+ ...request.headers ? { headers: Object.keys(request.headers).map((key) => {
166
+ const value = request.headers[key];
167
+ return {
168
+ key,
169
+ value: key === "cookie" ? { ...parse(value) } : value
170
+ };
171
+ }) } : {}
172
+ });
173
+ }
174
+ defineSourceLoader(loader) {
175
+ this.#sourceLoader = loader;
176
+ return this;
177
+ }
178
+ useParser(parser) {
179
+ this.#parsers.push(parser);
180
+ return this;
181
+ }
182
+ useTransformer(transformer) {
183
+ this.#transformers.push(transformer);
184
+ return this;
185
+ }
186
+ async toJSON(error, options) {
187
+ options = { ...options };
188
+ return this.#createErrorParser({ offset: options.offset }).parse(error);
189
+ }
190
+ async toHTML(error, options) {
191
+ options = { ...options };
192
+ this.#defineRequestMetadataGroup(options.request);
193
+ const parsedError = await this.#createErrorParser({ offset: options.offset }).parse(error);
194
+ return this.templates.toHTML({
195
+ title: options.title ?? "An error has occurred",
196
+ ide: options.ide ?? process.env.IDE ?? "vscode",
197
+ cspNonce: options.cspNonce,
198
+ error: parsedError,
199
+ metadata: this.metadata
200
+ });
201
+ }
202
+ async toANSI(error, options) {
203
+ options = { ...options };
204
+ const parsedError = await this.#createErrorParser({ offset: options.offset }).parse(error);
205
+ return this.templates.toANSI({
206
+ title: "",
207
+ error: parsedError,
208
+ metadata: this.metadata
209
+ });
210
+ }
359
211
  };
212
+ export { BaseComponent, Metadata, Youch };
@@ -1,6 +1,6 @@
1
1
  function copyErrorMessage(button) {
2
2
  const errorText = button.dataset.errorText;
3
-
3
+
4
4
  navigator.clipboard.writeText(errorText)
5
5
  .then(() => {
6
6
  button.classList.add('copied');
@@ -0,0 +1,25 @@
1
+ import { readFile } from "node:fs/promises";
2
+ var BaseComponent = class {
3
+ #cachedStyles;
4
+ #cachedScript;
5
+ #inDevMode;
6
+ scriptFile;
7
+ cssFile;
8
+ constructor(devMode) {
9
+ this.#inDevMode = devMode;
10
+ }
11
+ async getStyles() {
12
+ if (!this.cssFile) return null;
13
+ if (this.#inDevMode) return await readFile(this.cssFile, "utf-8");
14
+ this.#cachedStyles = this.#cachedStyles ?? await readFile(this.cssFile, "utf-8");
15
+ return this.#cachedStyles;
16
+ }
17
+ async getScript() {
18
+ if (!this.scriptFile) return null;
19
+ if (this.#inDevMode) return await readFile(this.scriptFile, "utf-8");
20
+ this.#cachedScript = this.#cachedScript ?? await readFile(this.scriptFile, "utf-8");
21
+ return this.#cachedScript;
22
+ }
23
+ };
24
+ const publicDirURL = new URL("./public/", import.meta.url);
25
+ export { BaseComponent as n, publicDirURL as t };
@@ -0,0 +1,44 @@
1
+ import { n as BaseComponent, t as publicDirURL } from "../../../public_dir-C5bujZKB.js";
2
+ import { 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
+ var ErrorCause = class extends BaseComponent {
6
+ cssFile = new URL("./error_cause/style.css", publicDirURL);
7
+ async toHTML(props) {
8
+ if (!props.error.cause) return "";
9
+ return `<section>
10
+ <div class="card">
11
+ <div class="card-heading">
12
+ <div>
13
+ <h3 class="card-title">
14
+ Error Cause
15
+ </h3>
16
+ </div>
17
+ </div>
18
+ <div class="card-body">
19
+ <div id="error-cause">
20
+ ${dump(props.error.cause, {
21
+ cspNonce: props.cspNonce,
22
+ styles: themes.cssVariables,
23
+ inspectObjectPrototype: false,
24
+ inspectStaticMembers: false,
25
+ inspectArrayPrototype: false
26
+ })}
27
+ </div>
28
+ </div>
29
+ </div>
30
+ </section>`;
31
+ }
32
+ async toANSI(props) {
33
+ if (!props.error.cause) return "";
34
+ let depth = process.env.YOUCH_CAUSE ? Number(process.env.YOUCH_CAUSE) : 2;
35
+ if (Number.isNaN(depth)) depth = 2;
36
+ return `\n\n${colors.red("[CAUSE]")}\n${dump$1(props.error.cause, {
37
+ depth,
38
+ inspectObjectPrototype: false,
39
+ inspectStaticMembers: false,
40
+ inspectArrayPrototype: false
41
+ })}`;
42
+ }
43
+ };
44
+ export { ErrorCause };