@depup/nitro 3.0.260311-beta-depup.0

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 (370) hide show
  1. package/LICENSE +27 -0
  2. package/README.md +32 -0
  3. package/changes.json +14 -0
  4. package/dist/THIRD-PARTY-LICENSES.md +1646 -0
  5. package/dist/_build/common.mjs +29361 -0
  6. package/dist/_build/rolldown.mjs +173 -0
  7. package/dist/_build/rollup.mjs +194 -0
  8. package/dist/_build/vite.build.mjs +18 -0
  9. package/dist/_chunks/nitro.mjs +1159 -0
  10. package/dist/_chunks/nitro2.mjs +102 -0
  11. package/dist/_chunks/nitro3.mjs +129 -0
  12. package/dist/_chunks/utils.mjs +272 -0
  13. package/dist/_common.mjs +35 -0
  14. package/dist/_dev.d.mts +12 -0
  15. package/dist/_dev.mjs +519 -0
  16. package/dist/_libs/_.mjs +3 -0
  17. package/dist/_libs/_2.mjs +2 -0
  18. package/dist/_libs/_3.mjs +3 -0
  19. package/dist/_libs/_4.mjs +2 -0
  20. package/dist/_libs/_5.mjs +3 -0
  21. package/dist/_libs/_6.mjs +4 -0
  22. package/dist/_libs/_7.mjs +5 -0
  23. package/dist/_libs/c12+rc9.mjs +812 -0
  24. package/dist/_libs/c12+readdirp+chokidar.d.mts +230 -0
  25. package/dist/_libs/citty.mjs +361 -0
  26. package/dist/_libs/commondir+is-reference.mjs +1311 -0
  27. package/dist/_libs/compatx.d.mts +47 -0
  28. package/dist/_libs/compatx.mjs +45 -0
  29. package/dist/_libs/esbuild.d.mts +20 -0
  30. package/dist/_libs/escape-string-regexp.mjs +7 -0
  31. package/dist/_libs/estree+pluginutils.d.mts +241 -0
  32. package/dist/_libs/estree-walker.mjs +184 -0
  33. package/dist/_libs/exsolve.d.mts +1 -0
  34. package/dist/_libs/hasown+resolve+deepmerge.mjs +1949 -0
  35. package/dist/_libs/httpxy.d.mts +82 -0
  36. package/dist/_libs/httpxy.mjs +671 -0
  37. package/dist/_libs/js-tokens.d.mts +1 -0
  38. package/dist/_libs/klona.mjs +37 -0
  39. package/dist/_libs/magic-string.d.mts +220 -0
  40. package/dist/_libs/mlly.d.mts +57 -0
  41. package/dist/_libs/nypm+tinyexec.mjs +845 -0
  42. package/dist/_libs/perfect-debounce.mjs +88 -0
  43. package/dist/_libs/pkg-types.d.mts +23 -0
  44. package/dist/_libs/plugin-alias.mjs +64 -0
  45. package/dist/_libs/plugin-inject.mjs +131 -0
  46. package/dist/_libs/plugin-json.mjs +34 -0
  47. package/dist/_libs/pluginutils.mjs +646 -0
  48. package/dist/_libs/readdirp+chokidar.mjs +1606 -0
  49. package/dist/_libs/remapping.mjs +115 -0
  50. package/dist/_libs/resolve-uri+gen-mapping.mjs +442 -0
  51. package/dist/_libs/rou3.d.mts +44 -0
  52. package/dist/_libs/rou3.mjs +496 -0
  53. package/dist/_libs/std-env.d.mts +12 -0
  54. package/dist/_libs/strip-literal.d.mts +1 -0
  55. package/dist/_libs/tsconfck.mjs +813 -0
  56. package/dist/_libs/ultrahtml.mjs +127 -0
  57. package/dist/_libs/unimport+unplugin.mjs +1684 -0
  58. package/dist/_libs/unplugin+unimport.d.mts +423 -0
  59. package/dist/_libs/unwasm.d.mts +29 -0
  60. package/dist/_presets.mjs +1759 -0
  61. package/dist/builder.d.mts +64 -0
  62. package/dist/builder.mjs +15 -0
  63. package/dist/cli/_chunks/build.mjs +47 -0
  64. package/dist/cli/_chunks/common.mjs +14 -0
  65. package/dist/cli/_chunks/deploy.mjs +40 -0
  66. package/dist/cli/_chunks/dev.mjs +62 -0
  67. package/dist/cli/_chunks/docs.mjs +30 -0
  68. package/dist/cli/_chunks/list.mjs +25 -0
  69. package/dist/cli/_chunks/prepare.mjs +17 -0
  70. package/dist/cli/_chunks/preview.mjs +51 -0
  71. package/dist/cli/_chunks/run.mjs +53 -0
  72. package/dist/cli/_chunks/task.mjs +14 -0
  73. package/dist/cli/index.d.mts +1 -0
  74. package/dist/cli/index.mjs +22 -0
  75. package/dist/node_modules/@poppinss/colors/build/index.js +139 -0
  76. package/dist/node_modules/@poppinss/colors/package.json +118 -0
  77. package/dist/node_modules/@poppinss/dumper/build/chunk-26HALFTP.js +602 -0
  78. package/dist/node_modules/@poppinss/dumper/build/formatters/console/main.js +441 -0
  79. package/dist/node_modules/@poppinss/dumper/build/formatters/html/main.js +725 -0
  80. package/dist/node_modules/@poppinss/dumper/package.json +122 -0
  81. package/dist/node_modules/@poppinss/exception/build/index.js +44 -0
  82. package/dist/node_modules/@poppinss/exception/package.json +109 -0
  83. package/dist/node_modules/@sindresorhus/is/distribution/index.js +1354 -0
  84. package/dist/node_modules/@sindresorhus/is/distribution/utilities.js +3 -0
  85. package/dist/node_modules/@sindresorhus/is/package.json +81 -0
  86. package/dist/node_modules/@speed-highlight/core/dist/index.js +4 -0
  87. package/dist/node_modules/@speed-highlight/core/dist/terminal.js +2 -0
  88. package/dist/node_modules/@speed-highlight/core/package.json +94 -0
  89. package/dist/node_modules/cookie-es/dist/index.mjs +262 -0
  90. package/dist/node_modules/cookie-es/package.json +37 -0
  91. package/dist/node_modules/croner/dist/croner.js +1 -0
  92. package/dist/node_modules/croner/package.json +73 -0
  93. package/dist/node_modules/defu/dist/defu.mjs +69 -0
  94. package/dist/node_modules/defu/package.json +43 -0
  95. package/dist/node_modules/destr/dist/index.mjs +72 -0
  96. package/dist/node_modules/destr/package.json +47 -0
  97. package/dist/node_modules/error-stack-parser-es/dist/index.mjs +38 -0
  98. package/dist/node_modules/error-stack-parser-es/dist/lite.mjs +167 -0
  99. package/dist/node_modules/error-stack-parser-es/package.json +83 -0
  100. package/dist/node_modules/get-port-please/dist/index.mjs +430 -0
  101. package/dist/node_modules/get-port-please/package.json +39 -0
  102. package/dist/node_modules/kleur/index.mjs +110 -0
  103. package/dist/node_modules/kleur/package.json +51 -0
  104. package/dist/node_modules/rendu/dist/index.mjs +380 -0
  105. package/dist/node_modules/rendu/package.json +47 -0
  106. package/dist/node_modules/scule/dist/index.mjs +80 -0
  107. package/dist/node_modules/scule/package.json +43 -0
  108. package/dist/node_modules/source-map/lib/array-set.js +100 -0
  109. package/dist/node_modules/source-map/lib/base64-vlq.js +94 -0
  110. package/dist/node_modules/source-map/lib/base64.js +19 -0
  111. package/dist/node_modules/source-map/lib/binary-search.js +113 -0
  112. package/dist/node_modules/source-map/lib/mapping-list.js +83 -0
  113. package/dist/node_modules/source-map/lib/mappings.wasm +0 -0
  114. package/dist/node_modules/source-map/lib/read-wasm.js +27 -0
  115. package/dist/node_modules/source-map/lib/source-map-consumer.js +1081 -0
  116. package/dist/node_modules/source-map/lib/source-map-generator.js +439 -0
  117. package/dist/node_modules/source-map/lib/source-node.js +430 -0
  118. package/dist/node_modules/source-map/lib/url.js +13 -0
  119. package/dist/node_modules/source-map/lib/util.js +444 -0
  120. package/dist/node_modules/source-map/lib/wasm.js +138 -0
  121. package/dist/node_modules/source-map/package.json +79 -0
  122. package/dist/node_modules/source-map/source-map.js +10 -0
  123. package/dist/node_modules/supports-color/index.js +202 -0
  124. package/dist/node_modules/supports-color/package.json +64 -0
  125. package/dist/node_modules/ufo/dist/index.mjs +645 -0
  126. package/dist/node_modules/ufo/package.json +48 -0
  127. package/dist/node_modules/unctx/dist/index.mjs +131 -0
  128. package/dist/node_modules/unctx/package.json +67 -0
  129. package/dist/node_modules/youch/build/helpers-B9BQYaS6.js +23 -0
  130. package/dist/node_modules/youch/build/index.js +212 -0
  131. package/dist/node_modules/youch/build/public/error_cause/style.css +5 -0
  132. package/dist/node_modules/youch/build/public/error_info/script.js +13 -0
  133. package/dist/node_modules/youch/build/public/error_info/style.css +145 -0
  134. package/dist/node_modules/youch/build/public/error_metadata/style.css +3 -0
  135. package/dist/node_modules/youch/build/public/error_stack/script.js +72 -0
  136. package/dist/node_modules/youch/build/public/error_stack/style.css +219 -0
  137. package/dist/node_modules/youch/build/public/error_stack_source/style.css +123 -0
  138. package/dist/node_modules/youch/build/public/header/script.js +14 -0
  139. package/dist/node_modules/youch/build/public/header/style.css +56 -0
  140. package/dist/node_modules/youch/build/public/layout/script.js +12 -0
  141. package/dist/node_modules/youch/build/public/layout/style.css +435 -0
  142. package/dist/node_modules/youch/build/public_dir-C5bujZKB.js +25 -0
  143. package/dist/node_modules/youch/build/src/templates/error_cause/main.js +44 -0
  144. package/dist/node_modules/youch/build/src/templates/error_info/main.js +72 -0
  145. package/dist/node_modules/youch/build/src/templates/error_metadata/main.js +65 -0
  146. package/dist/node_modules/youch/build/src/templates/error_stack/main.js +152 -0
  147. package/dist/node_modules/youch/build/src/templates/error_stack_source/main.js +46 -0
  148. package/dist/node_modules/youch/build/src/templates/header/main.js +24 -0
  149. package/dist/node_modules/youch/build/src/templates/layout/main.js +27 -0
  150. package/dist/node_modules/youch/package.json +135 -0
  151. package/dist/node_modules/youch-core/build/index.js +316 -0
  152. package/dist/node_modules/youch-core/package.json +124 -0
  153. package/dist/presets/_nitro/runtime/nitro-dev.mjs +20 -0
  154. package/dist/presets/_nitro/runtime/nitro-prerenderer.mjs +15 -0
  155. package/dist/presets/_nitro/runtime/service-worker.mjs +23 -0
  156. package/dist/presets/aws-amplify/runtime/aws-amplify.mjs +14 -0
  157. package/dist/presets/aws-lambda/runtime/_utils.mjs +116 -0
  158. package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.mjs +31 -0
  159. package/dist/presets/aws-lambda/runtime/aws-lambda.mjs +13 -0
  160. package/dist/presets/azure/runtime/_utils.mjs +50 -0
  161. package/dist/presets/azure/runtime/azure-swa.mjs +30 -0
  162. package/dist/presets/bun/runtime/bun.mjs +40 -0
  163. package/dist/presets/cloudflare/runtime/_module-handler.mjs +87 -0
  164. package/dist/presets/cloudflare/runtime/cloudflare-durable.mjs +72 -0
  165. package/dist/presets/cloudflare/runtime/cloudflare-module.mjs +17 -0
  166. package/dist/presets/cloudflare/runtime/cloudflare-pages.mjs +39 -0
  167. package/dist/presets/cloudflare/runtime/plugin.dev.mjs +96 -0
  168. package/dist/presets/cloudflare/runtime/shims/workers.dev.mjs +27 -0
  169. package/dist/presets/deno/runtime/deno-deploy.mjs +19 -0
  170. package/dist/presets/deno/runtime/deno-server.mjs +39 -0
  171. package/dist/presets/netlify/runtime/netlify-edge.mjs +20 -0
  172. package/dist/presets/netlify/runtime/netlify.mjs +20 -0
  173. package/dist/presets/node/runtime/node-cluster.mjs +54 -0
  174. package/dist/presets/node/runtime/node-middleware.mjs +14 -0
  175. package/dist/presets/node/runtime/node-server.mjs +47 -0
  176. package/dist/presets/standard/runtime/server.mjs +4 -0
  177. package/dist/presets/stormkit/runtime/stormkit.mjs +27 -0
  178. package/dist/presets/vercel/runtime/cron-handler.mjs +25 -0
  179. package/dist/presets/vercel/runtime/isr.mjs +19 -0
  180. package/dist/presets/vercel/runtime/vercel.node.mjs +24 -0
  181. package/dist/presets/vercel/runtime/vercel.web.mjs +23 -0
  182. package/dist/presets/winterjs/runtime/winterjs.mjs +91 -0
  183. package/dist/presets/zeabur/runtime/zeabur.mjs +4 -0
  184. package/dist/presets/zephyr/runtime/server.mjs +3 -0
  185. package/dist/runtime/app.d.mts +1 -0
  186. package/dist/runtime/app.mjs +1 -0
  187. package/dist/runtime/cache.d.mts +1 -0
  188. package/dist/runtime/cache.mjs +1 -0
  189. package/dist/runtime/config.d.mts +3 -0
  190. package/dist/runtime/config.mjs +4 -0
  191. package/dist/runtime/context.d.mts +1 -0
  192. package/dist/runtime/context.mjs +1 -0
  193. package/dist/runtime/database.d.mts +1 -0
  194. package/dist/runtime/database.mjs +1 -0
  195. package/dist/runtime/internal/app.d.mts +16 -0
  196. package/dist/runtime/internal/app.mjs +208 -0
  197. package/dist/runtime/internal/cache.d.mts +7 -0
  198. package/dist/runtime/internal/cache.mjs +41 -0
  199. package/dist/runtime/internal/context.d.mts +14 -0
  200. package/dist/runtime/internal/context.mjs +24 -0
  201. package/dist/runtime/internal/database.d.mts +2 -0
  202. package/dist/runtime/internal/database.mjs +12 -0
  203. package/dist/runtime/internal/empty.mjs +0 -0
  204. package/dist/runtime/internal/error/dev.d.mts +10 -0
  205. package/dist/runtime/internal/error/dev.mjs +121 -0
  206. package/dist/runtime/internal/error/hooks.d.mts +1 -0
  207. package/dist/runtime/internal/error/hooks.mjs +9 -0
  208. package/dist/runtime/internal/error/prod.d.mts +6 -0
  209. package/dist/runtime/internal/error/prod.mjs +40 -0
  210. package/dist/runtime/internal/error/utils.d.mts +8 -0
  211. package/dist/runtime/internal/error/utils.mjs +3 -0
  212. package/dist/runtime/internal/meta.d.mts +2 -0
  213. package/dist/runtime/internal/meta.mjs +3 -0
  214. package/dist/runtime/internal/plugin.d.mts +3 -0
  215. package/dist/runtime/internal/plugin.mjs +4 -0
  216. package/dist/runtime/internal/route-rules.d.mts +9 -0
  217. package/dist/runtime/internal/route-rules.mjs +72 -0
  218. package/dist/runtime/internal/routes/dev-tasks.d.mts +3 -0
  219. package/dist/runtime/internal/routes/dev-tasks.mjs +25 -0
  220. package/dist/runtime/internal/routes/openapi.d.mts +3 -0
  221. package/dist/runtime/internal/routes/openapi.mjs +94 -0
  222. package/dist/runtime/internal/routes/renderer-template.d.mts +2 -0
  223. package/dist/runtime/internal/routes/renderer-template.dev.d.mts +3 -0
  224. package/dist/runtime/internal/routes/renderer-template.dev.mjs +19 -0
  225. package/dist/runtime/internal/routes/renderer-template.mjs +4 -0
  226. package/dist/runtime/internal/routes/scalar.d.mts +3 -0
  227. package/dist/runtime/internal/routes/scalar.mjs +193 -0
  228. package/dist/runtime/internal/routes/swagger.d.mts +3 -0
  229. package/dist/runtime/internal/routes/swagger.mjs +42 -0
  230. package/dist/runtime/internal/runtime-config.d.mts +9 -0
  231. package/dist/runtime/internal/runtime-config.mjs +54 -0
  232. package/dist/runtime/internal/static.d.mts +3 -0
  233. package/dist/runtime/internal/static.mjs +67 -0
  234. package/dist/runtime/internal/storage.d.mts +2 -0
  235. package/dist/runtime/internal/storage.mjs +6 -0
  236. package/dist/runtime/internal/task.d.mts +19 -0
  237. package/dist/runtime/internal/task.mjs +69 -0
  238. package/dist/runtime/internal/vite/dev-entry.mjs +18 -0
  239. package/dist/runtime/internal/vite/dev-worker.mjs +264 -0
  240. package/dist/runtime/internal/vite/ssr-renderer.mjs +6 -0
  241. package/dist/runtime/meta.d.mts +5 -0
  242. package/dist/runtime/meta.mjs +27 -0
  243. package/dist/runtime/nitro.d.mts +11 -0
  244. package/dist/runtime/nitro.mjs +34 -0
  245. package/dist/runtime/runtime-config.d.mts +1 -0
  246. package/dist/runtime/runtime-config.mjs +1 -0
  247. package/dist/runtime/storage.d.mts +1 -0
  248. package/dist/runtime/storage.mjs +1 -0
  249. package/dist/runtime/task.d.mts +1 -0
  250. package/dist/runtime/task.mjs +1 -0
  251. package/dist/runtime/virtual/_runtime_warn.d.mts +1 -0
  252. package/dist/runtime/virtual/_runtime_warn.mjs +5 -0
  253. package/dist/runtime/virtual/database.d.mts +8 -0
  254. package/dist/runtime/virtual/database.mjs +2 -0
  255. package/dist/runtime/virtual/error-handler.d.mts +6 -0
  256. package/dist/runtime/virtual/error-handler.mjs +9 -0
  257. package/dist/runtime/virtual/feature-flags.d.mts +7 -0
  258. package/dist/runtime/virtual/feature-flags.mjs +7 -0
  259. package/dist/runtime/virtual/plugins.d.mts +3 -0
  260. package/dist/runtime/virtual/plugins.mjs +2 -0
  261. package/dist/runtime/virtual/polyfills.d.mts +3 -0
  262. package/dist/runtime/virtual/polyfills.mjs +2 -0
  263. package/dist/runtime/virtual/public-assets.d.mts +9 -0
  264. package/dist/runtime/virtual/public-assets.mjs +8 -0
  265. package/dist/runtime/virtual/renderer-template.d.mts +4 -0
  266. package/dist/runtime/virtual/renderer-template.mjs +7 -0
  267. package/dist/runtime/virtual/routing-meta.d.mts +7 -0
  268. package/dist/runtime/virtual/routing-meta.mjs +2 -0
  269. package/dist/runtime/virtual/routing.d.mts +8 -0
  270. package/dist/runtime/virtual/routing.mjs +11 -0
  271. package/dist/runtime/virtual/runtime-config.d.mts +3 -0
  272. package/dist/runtime/virtual/runtime-config.mjs +5 -0
  273. package/dist/runtime/virtual/server-assets.d.mts +7 -0
  274. package/dist/runtime/virtual/server-assets.mjs +12 -0
  275. package/dist/runtime/virtual/storage.d.mts +3 -0
  276. package/dist/runtime/virtual/storage.mjs +5 -0
  277. package/dist/runtime/virtual/tasks.d.mts +10 -0
  278. package/dist/runtime/virtual/tasks.mjs +3 -0
  279. package/dist/runtime/vite.d.mts +8 -0
  280. package/dist/runtime/vite.mjs +9 -0
  281. package/dist/types/index.d.mts +3010 -0
  282. package/dist/types/index.mjs +1 -0
  283. package/dist/vite.d.mts +52 -0
  284. package/dist/vite.mjs +740 -0
  285. package/lib/h3.d.mts +1 -0
  286. package/lib/h3.mjs +1 -0
  287. package/lib/tsconfig.json +27 -0
  288. package/lib/vite.types.d.mts +26 -0
  289. package/lib/vite.types.mjs +2 -0
  290. package/package.json +256 -0
  291. package/skills/nitro/SKILL.md +10 -0
  292. package/skills/nitro/docs/TOC.md +83 -0
  293. package/skills/nitro/docs/_navigation.json +679 -0
  294. package/skills/nitro/docs/config/index.md +1147 -0
  295. package/skills/nitro/docs/deploy/index.md +64 -0
  296. package/skills/nitro/docs/deploy/providers/alwaysdata.md +50 -0
  297. package/skills/nitro/docs/deploy/providers/aws-amplify.md +81 -0
  298. package/skills/nitro/docs/deploy/providers/aws.md +47 -0
  299. package/skills/nitro/docs/deploy/providers/azure.md +72 -0
  300. package/skills/nitro/docs/deploy/providers/cleavr.md +33 -0
  301. package/skills/nitro/docs/deploy/providers/cloudflare.md +375 -0
  302. package/skills/nitro/docs/deploy/providers/deno-deploy.md +66 -0
  303. package/skills/nitro/docs/deploy/providers/digitalocean.md +46 -0
  304. package/skills/nitro/docs/deploy/providers/firebase.md +32 -0
  305. package/skills/nitro/docs/deploy/providers/flightcontrol.md +67 -0
  306. package/skills/nitro/docs/deploy/providers/genezio.md +67 -0
  307. package/skills/nitro/docs/deploy/providers/github-pages.md +68 -0
  308. package/skills/nitro/docs/deploy/providers/gitlab-pages.md +37 -0
  309. package/skills/nitro/docs/deploy/providers/heroku.md +84 -0
  310. package/skills/nitro/docs/deploy/providers/iis.md +38 -0
  311. package/skills/nitro/docs/deploy/providers/koyeb.md +109 -0
  312. package/skills/nitro/docs/deploy/providers/netlify.md +47 -0
  313. package/skills/nitro/docs/deploy/providers/platform-sh.md +37 -0
  314. package/skills/nitro/docs/deploy/providers/render.md +37 -0
  315. package/skills/nitro/docs/deploy/providers/stormkit.md +24 -0
  316. package/skills/nitro/docs/deploy/providers/vercel.md +179 -0
  317. package/skills/nitro/docs/deploy/providers/zeabur.md +19 -0
  318. package/skills/nitro/docs/deploy/providers/zephyr.md +99 -0
  319. package/skills/nitro/docs/deploy/providers/zerops.md +102 -0
  320. package/skills/nitro/docs/deploy/runtimes/bun.md +15 -0
  321. package/skills/nitro/docs/deploy/runtimes/deno.md +19 -0
  322. package/skills/nitro/docs/deploy/runtimes/node.md +63 -0
  323. package/skills/nitro/docs/docs/assets.md +166 -0
  324. package/skills/nitro/docs/docs/cache.md +408 -0
  325. package/skills/nitro/docs/docs/configuration.md +256 -0
  326. package/skills/nitro/docs/docs/database.md +185 -0
  327. package/skills/nitro/docs/docs/index.md +56 -0
  328. package/skills/nitro/docs/docs/lifecycle.md +204 -0
  329. package/skills/nitro/docs/docs/migration.md +215 -0
  330. package/skills/nitro/docs/docs/nightly.md +31 -0
  331. package/skills/nitro/docs/docs/plugins.md +164 -0
  332. package/skills/nitro/docs/docs/quick-start.md +110 -0
  333. package/skills/nitro/docs/docs/renderer.md +322 -0
  334. package/skills/nitro/docs/docs/routing.md +711 -0
  335. package/skills/nitro/docs/docs/server-entry.md +239 -0
  336. package/skills/nitro/docs/docs/storage.md +261 -0
  337. package/skills/nitro/docs/docs/tasks.md +277 -0
  338. package/skills/nitro/docs/examples/api-routes.md +145 -0
  339. package/skills/nitro/docs/examples/auto-imports.md +93 -0
  340. package/skills/nitro/docs/examples/cached-handler.md +81 -0
  341. package/skills/nitro/docs/examples/custom-error-handler.md +98 -0
  342. package/skills/nitro/docs/examples/database.md +157 -0
  343. package/skills/nitro/docs/examples/elysia.md +70 -0
  344. package/skills/nitro/docs/examples/express.md +78 -0
  345. package/skills/nitro/docs/examples/fastify.md +79 -0
  346. package/skills/nitro/docs/examples/hello-world.md +68 -0
  347. package/skills/nitro/docs/examples/hono.md +74 -0
  348. package/skills/nitro/docs/examples/import-alias.md +100 -0
  349. package/skills/nitro/docs/examples/index.md +3 -0
  350. package/skills/nitro/docs/examples/middleware.md +91 -0
  351. package/skills/nitro/docs/examples/mono-jsx.md +68 -0
  352. package/skills/nitro/docs/examples/nano-jsx.md +70 -0
  353. package/skills/nitro/docs/examples/plugins.md +91 -0
  354. package/skills/nitro/docs/examples/renderer.md +113 -0
  355. package/skills/nitro/docs/examples/runtime-config.md +97 -0
  356. package/skills/nitro/docs/examples/server-fetch.md +87 -0
  357. package/skills/nitro/docs/examples/shiki.md +198 -0
  358. package/skills/nitro/docs/examples/virtual-routes.md +74 -0
  359. package/skills/nitro/docs/examples/vite-nitro-plugin.md +79 -0
  360. package/skills/nitro/docs/examples/vite-rsc.md +1041 -0
  361. package/skills/nitro/docs/examples/vite-ssr-html.md +217 -0
  362. package/skills/nitro/docs/examples/vite-ssr-preact.md +247 -0
  363. package/skills/nitro/docs/examples/vite-ssr-react.md +226 -0
  364. package/skills/nitro/docs/examples/vite-ssr-solid.md +256 -0
  365. package/skills/nitro/docs/examples/vite-ssr-tsr-react.md +442 -0
  366. package/skills/nitro/docs/examples/vite-ssr-tss-react.md +444 -0
  367. package/skills/nitro/docs/examples/vite-ssr-vue-router.md +616 -0
  368. package/skills/nitro/docs/examples/vite-trpc.md +335 -0
  369. package/skills/nitro/docs/examples/websocket.md +282 -0
  370. package/skills/nitro/docs/index.md +121 -0
@@ -0,0 +1,335 @@
1
+ # Vite + tRPC
2
+
3
+ > End-to-end typesafe APIs with tRPC in Nitro using Vite.
4
+
5
+ <code-tree>
6
+
7
+ ```html [index.html]
8
+ <!doctype html>
9
+ <html lang="en">
10
+ <head>
11
+ <meta charset="UTF-8" />
12
+ <title>tRPC Counter</title>
13
+ <style>
14
+ body {
15
+ font-family: system-ui, sans-serif;
16
+ background: #0f1115;
17
+ color: #e5e7eb;
18
+ display: grid;
19
+ place-items: center;
20
+ height: 100vh;
21
+ margin: 0;
22
+ }
23
+
24
+ .box {
25
+ background: #181b22;
26
+ padding: 24px 32px;
27
+ border-radius: 10px;
28
+ text-align: center;
29
+ min-width: 200px;
30
+ }
31
+
32
+ button {
33
+ background: #2563eb;
34
+ border: none;
35
+ color: white;
36
+ padding: 8px 14px;
37
+ border-radius: 6px;
38
+ cursor: pointer;
39
+ margin-top: 12px;
40
+ font-size: 14px;
41
+ }
42
+
43
+ button:hover {
44
+ background: #1d4ed8;
45
+ }
46
+
47
+ .value {
48
+ font-size: 36px;
49
+ margin: 12px 0;
50
+ }
51
+ </style>
52
+ </head>
53
+ <body>
54
+ <div class="box">
55
+ <div>Counter</div>
56
+ <div class="value" id="value">
57
+ <script server>
58
+ // Server-side Rendering
59
+ const { result } = await serverFetch("/trpc/get").then(r => r.json())
60
+ echo(result?.data?.value)
61
+ </script>
62
+ </div>
63
+ <button id="inc">Increment</button>
64
+ </div>
65
+
66
+ <script setup>
67
+ const valueEl = document.getElementById("value");
68
+ const incBtn = document.getElementById("inc");
69
+
70
+ async function call(path, body) {
71
+ const res = await fetch(`/trpc/${path}`, {
72
+ method: body ? "POST" : "GET",
73
+ headers: { "content-type": "application/json" },
74
+ body: body ? JSON.stringify(body) : undefined,
75
+ });
76
+
77
+ const json = await res.json();
78
+ return json.result.data;
79
+ }
80
+
81
+ async function refresh() {
82
+ const data = await call("get");
83
+ valueEl.textContent = data.value;
84
+ }
85
+
86
+ incBtn.onclick = async () => {
87
+ const data = await call("inc", {});
88
+ valueEl.textContent = data.value;
89
+ };
90
+
91
+ refresh();
92
+ </script>
93
+ </body>
94
+ </html>
95
+ ```
96
+
97
+ ```json [package.json]
98
+ {
99
+ "type": "module",
100
+ "scripts": {
101
+ "dev": "vite",
102
+ "build": "vite build",
103
+ "preview": "vite preview"
104
+ },
105
+ "devDependencies": {
106
+ "@trpc/client": "^11.9.0",
107
+ "@trpc/server": "^11.9.0",
108
+ "nitro": "latest",
109
+ "vite": "beta",
110
+ "zod": "^4.3.6"
111
+ }
112
+ }
113
+ ```
114
+
115
+ ```json [tsconfig.json]
116
+ {
117
+ "extends": "nitro/tsconfig",
118
+ "compilerOptions": {}
119
+ }
120
+ ```
121
+
122
+ ```ts [vite.config.ts]
123
+ import { defineConfig } from "vite";
124
+ import { nitro } from "nitro/vite";
125
+
126
+ export default defineConfig({
127
+ plugins: [
128
+ nitro({
129
+ routes: {
130
+ "/trpc/**": "./server/trpc.ts",
131
+ },
132
+ }),
133
+ ],
134
+ });
135
+ ```
136
+
137
+ ```ts [server/trpc.ts]
138
+ import { initTRPC } from "@trpc/server";
139
+ import { fetchRequestHandler } from "@trpc/server/adapters/fetch";
140
+
141
+ let counter = 0;
142
+
143
+ const t = initTRPC.create();
144
+
145
+ export const appRouter = t.router({
146
+ get: t.procedure.query(() => {
147
+ return { value: counter };
148
+ }),
149
+
150
+ inc: t.procedure.mutation(() => {
151
+ counter++;
152
+ return { value: counter };
153
+ }),
154
+ });
155
+
156
+ export type AppRouter = typeof appRouter;
157
+
158
+ export default {
159
+ async fetch(request: Request): Promise<Response> {
160
+ return fetchRequestHandler({
161
+ endpoint: "/trpc",
162
+ req: request,
163
+ router: appRouter,
164
+ });
165
+ },
166
+ };
167
+ ```
168
+ </code-tree>
169
+
170
+ Set up tRPC with Vite and Nitro for end-to-end typesafe APIs without code generation. This example builds a counter with server-side rendering for the initial value and client-side updates.
171
+
172
+ ## Overview
173
+
174
+ 1. Configure Vite with the Nitro plugin and route tRPC requests
175
+ 2. Create a tRPC router with procedures
176
+ 3. Create an HTML page with server-side rendering and client interactivity
177
+
178
+ ## 1. Configure Vite
179
+ Add the Nitro plugin and configure the `/trpc/**` route to point to your tRPC handler:
180
+
181
+ ```ts [vite.config.ts]
182
+ import { defineConfig } from "vite";
183
+ import { nitro } from "nitro/vite";
184
+
185
+ export default defineConfig({
186
+ plugins: [
187
+ nitro({
188
+ routes: {
189
+ "/trpc/**": "./server/trpc.ts",
190
+ },
191
+ }),
192
+ ],
193
+ });
194
+ ```
195
+
196
+ The `routes` option maps URL patterns to handler files. All requests to `/trpc/*` are handled by the tRPC router.
197
+
198
+ ## 2. Create the tRPC Router
199
+
200
+ Define your tRPC router with procedures and export it as a fetch handler:
201
+
202
+ ```ts [server/trpc.ts]
203
+ import { initTRPC } from "@trpc/server";
204
+ import { fetchRequestHandler } from "@trpc/server/adapters/fetch";
205
+
206
+ let counter = 0;
207
+
208
+ const t = initTRPC.create();
209
+
210
+ export const appRouter = t.router({
211
+ get: t.procedure.query(() => {
212
+ return { value: counter };
213
+ }),
214
+
215
+ inc: t.procedure.mutation(() => {
216
+ counter++;
217
+ return { value: counter };
218
+ }),
219
+ });
220
+
221
+ export type AppRouter = typeof appRouter;
222
+
223
+ export default {
224
+ async fetch(request: Request): Promise<Response> {
225
+ return fetchRequestHandler({
226
+ endpoint: "/trpc",
227
+ req: request,
228
+ router: appRouter,
229
+ });
230
+ },
231
+ };
232
+ ```
233
+
234
+ Define procedures using `t.procedure.query()` for read operations and `t.procedure.mutation()` for write operations. Export the `AppRouter` type so clients get full type inference. The default export uses tRPC's fetch adapter to handle incoming requests.
235
+
236
+ ## 3. Create the HTML Page
237
+
238
+ Create an HTML page with server-side rendering and client-side interactivity:
239
+
240
+ ```html [index.html]
241
+ <!doctype html>
242
+ <html lang="en">
243
+ <head>
244
+ <meta charset="UTF-8" />
245
+ <title>tRPC Counter</title>
246
+ <style>
247
+ body {
248
+ font-family: system-ui, sans-serif;
249
+ background: #0f1115;
250
+ color: #e5e7eb;
251
+ display: grid;
252
+ place-items: center;
253
+ height: 100vh;
254
+ margin: 0;
255
+ }
256
+
257
+ .box {
258
+ background: #181b22;
259
+ padding: 24px 32px;
260
+ border-radius: 10px;
261
+ text-align: center;
262
+ min-width: 200px;
263
+ }
264
+
265
+ button {
266
+ background: #2563eb;
267
+ border: none;
268
+ color: white;
269
+ padding: 8px 14px;
270
+ border-radius: 6px;
271
+ cursor: pointer;
272
+ margin-top: 12px;
273
+ font-size: 14px;
274
+ }
275
+
276
+ button:hover {
277
+ background: #1d4ed8;
278
+ }
279
+
280
+ .value {
281
+ font-size: 36px;
282
+ margin: 12px 0;
283
+ }
284
+ </style>
285
+ </head>
286
+ <body>
287
+ <div class="box">
288
+ <div>Counter</div>
289
+ <div class="value" id="value">
290
+ <script server>
291
+ // Server-side Rendering
292
+ const { result } = await serverFetch("/trpc/get").then(r => r.json())
293
+ echo(result?.data?.value)
294
+ </script>
295
+ </div>
296
+ <button id="inc">Increment</button>
297
+ </div>
298
+
299
+ <script setup>
300
+ const valueEl = document.getElementById("value");
301
+ const incBtn = document.getElementById("inc");
302
+
303
+ async function call(path, body) {
304
+ const res = await fetch(`/trpc/${path}`, {
305
+ method: body ? "POST" : "GET",
306
+ headers: { "content-type": "application/json" },
307
+ body: body ? JSON.stringify(body) : undefined,
308
+ });
309
+
310
+ const json = await res.json();
311
+ return json.result.data;
312
+ }
313
+
314
+ async function refresh() {
315
+ const data = await call("get");
316
+ valueEl.textContent = data.value;
317
+ }
318
+
319
+ incBtn.onclick = async () => {
320
+ const data = await call("inc", {});
321
+ valueEl.textContent = data.value;
322
+ };
323
+
324
+ refresh();
325
+ </script>
326
+ </body>
327
+ </html>
328
+ ```
329
+
330
+ The `<script server>` block runs on the server before sending the response, fetching the initial counter value via `serverFetch`. The `<script setup>` block runs in the browser and handles the increment button click.
331
+
332
+ ## Learn More
333
+
334
+ - [tRPC](https://trpc.io/)
335
+ - [Routing](/docs/routing)
@@ -0,0 +1,282 @@
1
+ # WebSocket
2
+
3
+ > Real-time bidirectional communication with WebSocket support.
4
+
5
+ <code-tree>
6
+
7
+ ```html [index.html]
8
+ <html lang="en" data-theme="dark">
9
+ <head>
10
+ <title>CrossWS Test Page</title>
11
+ <script src="https://cdn.tailwindcss.com"></script>
12
+ <style>
13
+ body {
14
+ background-color: #1a1a1a;
15
+ }
16
+ </style>
17
+ <script type="module">
18
+ import { createApp, reactive, nextTick } from "https://esm.sh/petite-vue@0.4.1";
19
+
20
+ let ws;
21
+
22
+ const store = reactive({
23
+ message: "",
24
+ messages: [],
25
+ });
26
+
27
+ const scroll = () => {
28
+ nextTick(() => {
29
+ const el = document.querySelector("#messages");
30
+ el.scrollTop = el.scrollHeight;
31
+ el.scrollTo({
32
+ top: el.scrollHeight,
33
+ behavior: "smooth",
34
+ });
35
+ });
36
+ };
37
+
38
+ const format = async () => {
39
+ for (const message of store.messages) {
40
+ if (!message._fmt && message.text.startsWith("{")) {
41
+ message._fmt = true;
42
+ const { codeToHtml } = await import("https://esm.sh/shiki@1.0.0");
43
+ const str = JSON.stringify(JSON.parse(message.text), null, 2);
44
+ message.formattedText = await codeToHtml(str, {
45
+ lang: "json",
46
+ theme: "dark-plus",
47
+ });
48
+ }
49
+ }
50
+ };
51
+
52
+ const log = (user, ...args) => {
53
+ console.log("[ws]", user, ...args);
54
+ store.messages.push({
55
+ text: args.join(" "),
56
+ formattedText: "",
57
+ user: user,
58
+ date: new Date().toLocaleString(),
59
+ });
60
+ scroll();
61
+ format();
62
+ };
63
+
64
+ const connect = async () => {
65
+ const isSecure = location.protocol === "https:";
66
+ const url = (isSecure ? "wss://" : "ws://") + location.host + "/_ws";
67
+ if (ws) {
68
+ log("ws", "Closing previous connection before reconnecting...");
69
+ ws.close();
70
+ clear();
71
+ }
72
+
73
+ log("ws", "Connecting to", url, "...");
74
+ ws = new WebSocket(url);
75
+
76
+ ws.addEventListener("message", async (event) => {
77
+ let data = typeof event.data === "string" ? event.data : await event.data.text();
78
+ const { user = "system", message = "" } = data.startsWith("{")
79
+ ? JSON.parse(data)
80
+ : { message: data };
81
+ log(user, typeof message === "string" ? message : JSON.stringify(message));
82
+ });
83
+
84
+ await new Promise((resolve) => ws.addEventListener("open", resolve));
85
+ log("ws", "Connected!");
86
+ };
87
+
88
+ const clear = () => {
89
+ store.messages.splice(0, store.messages.length);
90
+ log("system", "previous messages cleared");
91
+ };
92
+
93
+ const send = () => {
94
+ console.log("sending message...");
95
+ if (store.message) {
96
+ ws.send(store.message);
97
+ }
98
+ store.message = "";
99
+ };
100
+
101
+ const ping = () => {
102
+ log("ws", "Sending ping");
103
+ ws.send("ping");
104
+ };
105
+
106
+ createApp({
107
+ store,
108
+ send,
109
+ ping,
110
+ clear,
111
+ connect,
112
+ rand: Math.random(),
113
+ }).mount();
114
+
115
+ await connect();
116
+ </script>
117
+ </head>
118
+ <body class="h-screen flex flex-col justify-between">
119
+ <main v-scope="{}">
120
+ <!-- Messages -->
121
+ <div id="messages" class="flex-grow flex flex-col justify-end px-4 py-8">
122
+ <div class="flex items-center mb-4" v-for="message in store.messages">
123
+ <div class="flex flex-col">
124
+ <p class="text-gray-500 mb-1 text-xs ml-10">{{ message.user }}</p>
125
+ <div class="flex items-center">
126
+ <img
127
+ :src="'https://www.gravatar.com/avatar/' + encodeURIComponent(message.user + rand) + '?s=512&d=monsterid'"
128
+ alt="Avatar"
129
+ class="w-8 h-8 rounded-full"
130
+ />
131
+ <div class="ml-2 bg-gray-800 rounded-lg p-2">
132
+ <p
133
+ v-if="message.formattedText"
134
+ class="overflow-x-scroll"
135
+ v-html="message.formattedText"
136
+ ></p>
137
+ <p v-else class="text-white">{{ message.text }}</p>
138
+ </div>
139
+ </div>
140
+ <p class="text-gray-500 mt-1 text-xs ml-10">{{ message.date }}</p>
141
+ </div>
142
+ </div>
143
+ </div>
144
+
145
+ <!-- Chatbox -->
146
+ <div class="bg-gray-800 px-4 py-2 flex items-center justify-between fixed bottom-0 w-full">
147
+ <div class="w-full min-w-6">
148
+ <input
149
+ type="text"
150
+ placeholder="Type your message..."
151
+ class="w-full rounded-l-lg px-4 py-2 bg-gray-700 text-white focus:outline-none focus:ring focus:border-blue-300"
152
+ @keydown.enter="send"
153
+ v-model="store.message"
154
+ />
155
+ </div>
156
+ <div class="flex">
157
+ <button class="bg-blue-500 hover:bg-blue-600 text-white py-2 px-4" @click="send">
158
+ Send
159
+ </button>
160
+ <button class="bg-blue-500 hover:bg-blue-600 text-white py-2 px-4" @click="ping">
161
+ Ping
162
+ </button>
163
+ <button class="bg-blue-500 hover:bg-blue-600 text-white py-2 px-4" @click="connect">
164
+ Reconnect
165
+ </button>
166
+ <button
167
+ class="bg-blue-500 hover:bg-blue-600 text-white py-2 px-4 rounded-r-lg"
168
+ @click="clear"
169
+ >
170
+ Clear
171
+ </button>
172
+ </div>
173
+ </div>
174
+ </main>
175
+ </body>
176
+ </html>
177
+ `
178
+ ```
179
+
180
+ ```ts [nitro.config.ts]
181
+ import { defineConfig } from "nitro";
182
+
183
+ export default defineConfig({
184
+ serverDir: "./",
185
+ renderer: { static: true },
186
+ features: { websocket: true },
187
+ });
188
+ ```
189
+
190
+ ```json [package.json]
191
+ {
192
+ "type": "module",
193
+ "scripts": {
194
+ "dev": "nitro dev",
195
+ "build": "nitro build"
196
+ },
197
+ "devDependencies": {
198
+ "nitro": "latest"
199
+ }
200
+ }
201
+ ```
202
+
203
+ ```json [tsconfig.json]
204
+ {
205
+ "extends": "nitro/tsconfig"
206
+ }
207
+ ```
208
+
209
+ ```ts [vite.config.ts]
210
+ import { defineConfig } from "vite";
211
+ import { nitro } from "nitro/vite";
212
+
213
+ export default defineConfig({ plugins: [nitro()] });
214
+ ```
215
+
216
+ ```ts [routes/_ws.ts]
217
+ import { defineWebSocketHandler } from "nitro";
218
+
219
+ export default defineWebSocketHandler({
220
+ open(peer) {
221
+ peer.send({ user: "server", message: `Welcome ${peer}!` });
222
+ peer.publish("chat", { user: "server", message: `${peer} joined!` });
223
+ peer.subscribe("chat");
224
+ },
225
+ message(peer, message) {
226
+ if (message.text().includes("ping")) {
227
+ peer.send({ user: "server", message: "pong" });
228
+ } else {
229
+ const msg = {
230
+ user: peer.toString(),
231
+ message: message.toString(),
232
+ };
233
+ peer.send(msg); // echo
234
+ peer.publish("chat", msg);
235
+ }
236
+ },
237
+ close(peer) {
238
+ peer.publish("chat", { user: "server", message: `${peer} left!` });
239
+ },
240
+ });
241
+ ```
242
+ </code-tree>
243
+
244
+ This example implements a simple chat room using WebSockets. Clients connect, send messages, and receive messages from other users in real-time. The server broadcasts messages to all connected clients using pub/sub channels.
245
+
246
+ ## WebSocket Handler
247
+
248
+ Create a WebSocket route using `defineWebSocketHandler`.
249
+
250
+ ```ts [routes/_ws.ts]
251
+ import { defineWebSocketHandler } from "nitro";
252
+
253
+ export default defineWebSocketHandler({
254
+ open(peer) {
255
+ peer.send({ user: "server", message: `Welcome ${peer}!` });
256
+ peer.publish("chat", { user: "server", message: `${peer} joined!` });
257
+ peer.subscribe("chat");
258
+ },
259
+ message(peer, message) {
260
+ if (message.text().includes("ping")) {
261
+ peer.send({ user: "server", message: "pong" });
262
+ } else {
263
+ const msg = {
264
+ user: peer.toString(),
265
+ message: message.toString(),
266
+ };
267
+ peer.send(msg); // echo
268
+ peer.publish("chat", msg);
269
+ }
270
+ },
271
+ close(peer) {
272
+ peer.publish("chat", { user: "server", message: `${peer} left!` });
273
+ },
274
+ });
275
+ ```
276
+
277
+ Different hooks are exposed by `defineWebSocketHandler()` to integrate with different parts of the websocket lifecycle.
278
+
279
+ ## Learn More
280
+
281
+ - [Routing](/docs/routing)
282
+ - [crossws Documentation](https://crossws.h3.dev/guide/hooks)