@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,845 @@
1
+ import { ct as join$1, dt as resolve$1, lt as normalize$1 } from "../_build/common.mjs";
2
+ import { createRequire } from "node:module";
3
+ import { existsSync } from "node:fs";
4
+ import { readFile } from "node:fs/promises";
5
+ import { delimiter, dirname, join, normalize, resolve } from "node:path";
6
+ import { cwd } from "node:process";
7
+ import { createRequire as createRequire$1 } from "module";
8
+ import { PassThrough } from "node:stream";
9
+ import { spawn } from "node:child_process";
10
+ import c from "node:readline";
11
+ //#region node_modules/.pnpm/tinyexec@1.0.2/node_modules/tinyexec/dist/main.js
12
+ var l = Object.create;
13
+ var u = Object.defineProperty;
14
+ var d = Object.getOwnPropertyDescriptor;
15
+ var f = Object.getOwnPropertyNames;
16
+ var p = Object.getPrototypeOf;
17
+ var m = Object.prototype.hasOwnProperty;
18
+ var h = (e, t) => () => (t || e((t = { exports: {} }).exports, t), t.exports);
19
+ var g = (e, t, n, r) => {
20
+ if (t && typeof t === "object" || typeof t === "function") for (var i = f(t), a = 0, o = i.length, s; a < o; a++) {
21
+ s = i[a];
22
+ if (!m.call(e, s) && s !== n) u(e, s, {
23
+ get: ((e) => t[e]).bind(null, s),
24
+ enumerable: !(r = d(t, s)) || r.enumerable
25
+ });
26
+ }
27
+ return e;
28
+ };
29
+ var _ = (e, t, n) => (n = e != null ? l(p(e)) : {}, g(t || !e || !e.__esModule ? u(n, "default", {
30
+ value: e,
31
+ enumerable: true
32
+ }) : n, e));
33
+ var v = /* @__PURE__ */ createRequire$1(import.meta.url);
34
+ const y = /^path$/i;
35
+ const b = {
36
+ key: "PATH",
37
+ value: ""
38
+ };
39
+ function x(e) {
40
+ for (const t in e) {
41
+ if (!Object.prototype.hasOwnProperty.call(e, t) || !y.test(t)) continue;
42
+ const n = e[t];
43
+ if (!n) return b;
44
+ return {
45
+ key: t,
46
+ value: n
47
+ };
48
+ }
49
+ return b;
50
+ }
51
+ function S(e, t) {
52
+ const i = t.value.split(delimiter);
53
+ let o = e;
54
+ let s;
55
+ do {
56
+ i.push(resolve(o, "node_modules", ".bin"));
57
+ s = o;
58
+ o = dirname(o);
59
+ } while (o !== s);
60
+ return {
61
+ key: t.key,
62
+ value: i.join(delimiter)
63
+ };
64
+ }
65
+ function C(e, t) {
66
+ const n = {
67
+ ...process.env,
68
+ ...t
69
+ };
70
+ const r = S(e, x(n));
71
+ n[r.key] = r.value;
72
+ return n;
73
+ }
74
+ const w = (e) => {
75
+ let t = e.length;
76
+ const n = new PassThrough();
77
+ const r = () => {
78
+ if (--t === 0) n.emit("end");
79
+ };
80
+ for (const t of e) {
81
+ t.pipe(n, { end: false });
82
+ t.on("end", r);
83
+ }
84
+ return n;
85
+ };
86
+ var T = h((exports, t) => {
87
+ t.exports = a;
88
+ a.sync = o;
89
+ var n = v("fs");
90
+ function r(e, t) {
91
+ var n = t.pathExt !== void 0 ? t.pathExt : process.env.PATHEXT;
92
+ if (!n) return true;
93
+ n = n.split(";");
94
+ if (n.indexOf("") !== -1) return true;
95
+ for (var r = 0; r < n.length; r++) {
96
+ var i = n[r].toLowerCase();
97
+ if (i && e.substr(-i.length).toLowerCase() === i) return true;
98
+ }
99
+ return false;
100
+ }
101
+ function i(e, t, n) {
102
+ if (!e.isSymbolicLink() && !e.isFile()) return false;
103
+ return r(t, n);
104
+ }
105
+ function a(e, t, r) {
106
+ n.stat(e, function(n, a) {
107
+ r(n, n ? false : i(a, e, t));
108
+ });
109
+ }
110
+ function o(e, t) {
111
+ return i(n.statSync(e), e, t);
112
+ }
113
+ });
114
+ var E = h((exports, t) => {
115
+ t.exports = r;
116
+ r.sync = i;
117
+ var n = v("fs");
118
+ function r(e, t, r) {
119
+ n.stat(e, function(e, n) {
120
+ r(e, e ? false : a(n, t));
121
+ });
122
+ }
123
+ function i(e, t) {
124
+ return a(n.statSync(e), t);
125
+ }
126
+ function a(e, t) {
127
+ return e.isFile() && o(e, t);
128
+ }
129
+ function o(e, t) {
130
+ var n = e.mode;
131
+ var r = e.uid;
132
+ var i = e.gid;
133
+ var a = t.uid !== void 0 ? t.uid : process.getuid && process.getuid();
134
+ var o = t.gid !== void 0 ? t.gid : process.getgid && process.getgid();
135
+ var s = parseInt("100", 8);
136
+ var c = parseInt("010", 8);
137
+ var l = parseInt("001", 8);
138
+ var u = s | c;
139
+ return n & l || n & c && i === o || n & s && r === a || n & u && a === 0;
140
+ }
141
+ });
142
+ var D = h((exports, t) => {
143
+ v("fs");
144
+ var r;
145
+ if (process.platform === "win32" || global.TESTING_WINDOWS) r = T();
146
+ else r = E();
147
+ t.exports = i;
148
+ i.sync = a;
149
+ function i(e, t, n) {
150
+ if (typeof t === "function") {
151
+ n = t;
152
+ t = {};
153
+ }
154
+ if (!n) {
155
+ if (typeof Promise !== "function") throw new TypeError("callback not provided");
156
+ return new Promise(function(n, r) {
157
+ i(e, t || {}, function(e, t) {
158
+ if (e) r(e);
159
+ else n(t);
160
+ });
161
+ });
162
+ }
163
+ r(e, t || {}, function(e, r) {
164
+ if (e) {
165
+ if (e.code === "EACCES" || t && t.ignoreErrors) {
166
+ e = null;
167
+ r = false;
168
+ }
169
+ }
170
+ n(e, r);
171
+ });
172
+ }
173
+ function a(e, t) {
174
+ try {
175
+ return r.sync(e, t || {});
176
+ } catch (e) {
177
+ if (t && t.ignoreErrors || e.code === "EACCES") return false;
178
+ else throw e;
179
+ }
180
+ }
181
+ });
182
+ var O = h((exports, t) => {
183
+ const n = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
184
+ const r = v("path");
185
+ const i = n ? ";" : ":";
186
+ const a = D();
187
+ const o = (e) => Object.assign(/* @__PURE__ */ new Error(`not found: ${e}`), { code: "ENOENT" });
188
+ const s = (e, t) => {
189
+ const r = t.colon || i;
190
+ const a = e.match(/\//) || n && e.match(/\\/) ? [""] : [...n ? [process.cwd()] : [], ...(t.path || process.env.PATH || "").split(r)];
191
+ const o = n ? t.pathExt || process.env.PATHEXT || ".EXE;.CMD;.BAT;.COM" : "";
192
+ const s = n ? o.split(r) : [""];
193
+ if (n) {
194
+ if (e.indexOf(".") !== -1 && s[0] !== "") s.unshift("");
195
+ }
196
+ return {
197
+ pathEnv: a,
198
+ pathExt: s,
199
+ pathExtExe: o
200
+ };
201
+ };
202
+ const c = (e, t, n) => {
203
+ if (typeof t === "function") {
204
+ n = t;
205
+ t = {};
206
+ }
207
+ if (!t) t = {};
208
+ const { pathEnv: i, pathExt: c, pathExtExe: l } = s(e, t);
209
+ const u = [];
210
+ const d = (n) => new Promise((a, s) => {
211
+ if (n === i.length) return t.all && u.length ? a(u) : s(o(e));
212
+ const c = i[n];
213
+ const l = /^".*"$/.test(c) ? c.slice(1, -1) : c;
214
+ const d = r.join(l, e);
215
+ a(f(!l && /^\.[\\\/]/.test(e) ? e.slice(0, 2) + d : d, n, 0));
216
+ });
217
+ const f = (e, n, r) => new Promise((i, o) => {
218
+ if (r === c.length) return i(d(n + 1));
219
+ const s = c[r];
220
+ a(e + s, { pathExt: l }, (a, o) => {
221
+ if (!a && o) if (t.all) u.push(e + s);
222
+ else return i(e + s);
223
+ return i(f(e, n, r + 1));
224
+ });
225
+ });
226
+ return n ? d(0).then((e) => n(null, e), n) : d(0);
227
+ };
228
+ const l = (e, t) => {
229
+ t = t || {};
230
+ const { pathEnv: n, pathExt: i, pathExtExe: c } = s(e, t);
231
+ const l = [];
232
+ for (let o = 0; o < n.length; o++) {
233
+ const s = n[o];
234
+ const u = /^".*"$/.test(s) ? s.slice(1, -1) : s;
235
+ const d = r.join(u, e);
236
+ const f = !u && /^\.[\\\/]/.test(e) ? e.slice(0, 2) + d : d;
237
+ for (let e = 0; e < i.length; e++) {
238
+ const n = f + i[e];
239
+ try {
240
+ if (a.sync(n, { pathExt: c })) if (t.all) l.push(n);
241
+ else return n;
242
+ } catch (e) {}
243
+ }
244
+ }
245
+ if (t.all && l.length) return l;
246
+ if (t.nothrow) return null;
247
+ throw o(e);
248
+ };
249
+ t.exports = c;
250
+ c.sync = l;
251
+ });
252
+ var k = h((exports, t) => {
253
+ const n = (e = {}) => {
254
+ const t = e.env || process.env;
255
+ if ((e.platform || process.platform) !== "win32") return "PATH";
256
+ return Object.keys(t).reverse().find((e) => e.toUpperCase() === "PATH") || "Path";
257
+ };
258
+ t.exports = n;
259
+ t.exports.default = n;
260
+ });
261
+ var A = h((exports, t) => {
262
+ const n = v("path");
263
+ const r = O();
264
+ const i = k();
265
+ function a(e, t) {
266
+ const a = e.options.env || process.env;
267
+ const o = process.cwd();
268
+ const s = e.options.cwd != null;
269
+ const c = s && process.chdir !== void 0 && !process.chdir.disabled;
270
+ if (c) try {
271
+ process.chdir(e.options.cwd);
272
+ } catch (e) {}
273
+ let l;
274
+ try {
275
+ l = r.sync(e.command, {
276
+ path: a[i({ env: a })],
277
+ pathExt: t ? n.delimiter : void 0
278
+ });
279
+ } catch (e) {} finally {
280
+ if (c) process.chdir(o);
281
+ }
282
+ if (l) l = n.resolve(s ? e.options.cwd : "", l);
283
+ return l;
284
+ }
285
+ function o(e) {
286
+ return a(e) || a(e, true);
287
+ }
288
+ t.exports = o;
289
+ });
290
+ var j = h((exports, t) => {
291
+ const n = /([()\][%!^"`<>&|;, *?])/g;
292
+ function r(e) {
293
+ e = e.replace(n, "^$1");
294
+ return e;
295
+ }
296
+ function i(e, t) {
297
+ e = `${e}`;
298
+ e = e.replace(/(\\*)"/g, "$1$1\\\"");
299
+ e = e.replace(/(\\*)$/, "$1$1");
300
+ e = `"${e}"`;
301
+ e = e.replace(n, "^$1");
302
+ if (t) e = e.replace(n, "^$1");
303
+ return e;
304
+ }
305
+ t.exports.command = r;
306
+ t.exports.argument = i;
307
+ });
308
+ var M = h((exports, t) => {
309
+ t.exports = /^#!(.*)/;
310
+ });
311
+ var N = h((exports, t) => {
312
+ const n = M();
313
+ t.exports = (e = "") => {
314
+ const t = e.match(n);
315
+ if (!t) return null;
316
+ const [r, i] = t[0].replace(/#! ?/, "").split(" ");
317
+ const a = r.split("/").pop();
318
+ if (a === "env") return i;
319
+ return i ? `${a} ${i}` : a;
320
+ };
321
+ });
322
+ var P = h((exports, t) => {
323
+ const n = v("fs");
324
+ const r = N();
325
+ function i(e) {
326
+ const t = 150;
327
+ const i = Buffer.alloc(t);
328
+ let a;
329
+ try {
330
+ a = n.openSync(e, "r");
331
+ n.readSync(a, i, 0, t, 0);
332
+ n.closeSync(a);
333
+ } catch (e) {}
334
+ return r(i.toString());
335
+ }
336
+ t.exports = i;
337
+ });
338
+ var F = h((exports, t) => {
339
+ const n = v("path");
340
+ const r = A();
341
+ const i = j();
342
+ const a = P();
343
+ const o = process.platform === "win32";
344
+ const s = /\.(?:com|exe)$/i;
345
+ const c = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
346
+ function l(e) {
347
+ e.file = r(e);
348
+ const t = e.file && a(e.file);
349
+ if (t) {
350
+ e.args.unshift(e.file);
351
+ e.command = t;
352
+ return r(e);
353
+ }
354
+ return e.file;
355
+ }
356
+ function u(e) {
357
+ if (!o) return e;
358
+ const t = l(e);
359
+ const r = !s.test(t);
360
+ if (e.options.forceShell || r) {
361
+ const r = c.test(t);
362
+ e.command = n.normalize(e.command);
363
+ e.command = i.command(e.command);
364
+ e.args = e.args.map((e) => i.argument(e, r));
365
+ e.args = [
366
+ "/d",
367
+ "/s",
368
+ "/c",
369
+ `"${[e.command].concat(e.args).join(" ")}"`
370
+ ];
371
+ e.command = process.env.comspec || "cmd.exe";
372
+ e.options.windowsVerbatimArguments = true;
373
+ }
374
+ return e;
375
+ }
376
+ function d(e, t, n) {
377
+ if (t && !Array.isArray(t)) {
378
+ n = t;
379
+ t = null;
380
+ }
381
+ t = t ? t.slice(0) : [];
382
+ n = Object.assign({}, n);
383
+ const r = {
384
+ command: e,
385
+ args: t,
386
+ options: n,
387
+ file: void 0,
388
+ original: {
389
+ command: e,
390
+ args: t
391
+ }
392
+ };
393
+ return n.shell ? r : u(r);
394
+ }
395
+ t.exports = d;
396
+ });
397
+ var I = h((exports, t) => {
398
+ const n = process.platform === "win32";
399
+ function r(e, t) {
400
+ return Object.assign(/* @__PURE__ */ new Error(`${t} ${e.command} ENOENT`), {
401
+ code: "ENOENT",
402
+ errno: "ENOENT",
403
+ syscall: `${t} ${e.command}`,
404
+ path: e.command,
405
+ spawnargs: e.args
406
+ });
407
+ }
408
+ function i(e, t) {
409
+ if (!n) return;
410
+ const r = e.emit;
411
+ e.emit = function(n, i) {
412
+ if (n === "exit") {
413
+ const n = a(i, t, "spawn");
414
+ if (n) return r.call(e, "error", n);
415
+ }
416
+ return r.apply(e, arguments);
417
+ };
418
+ }
419
+ function a(e, t) {
420
+ if (n && e === 1 && !t.file) return r(t.original, "spawn");
421
+ return null;
422
+ }
423
+ function o(e, t) {
424
+ if (n && e === 1 && !t.file) return r(t.original, "spawnSync");
425
+ return null;
426
+ }
427
+ t.exports = {
428
+ hookChildProcess: i,
429
+ verifyENOENT: a,
430
+ verifyENOENTSync: o,
431
+ notFoundError: r
432
+ };
433
+ });
434
+ var R = _(h((exports, t) => {
435
+ const n = v("child_process");
436
+ const r = F();
437
+ const i = I();
438
+ function a(e, t, a) {
439
+ const o = r(e, t, a);
440
+ const s = n.spawn(o.command, o.args, o.options);
441
+ i.hookChildProcess(s, o);
442
+ return s;
443
+ }
444
+ function o(e, t, a) {
445
+ const o = r(e, t, a);
446
+ const s = n.spawnSync(o.command, o.args, o.options);
447
+ s.error = s.error || i.verifyENOENTSync(s.status, o);
448
+ return s;
449
+ }
450
+ t.exports = a;
451
+ t.exports.spawn = a;
452
+ t.exports.sync = o;
453
+ t.exports._parse = r;
454
+ t.exports._enoent = i;
455
+ })(), 1);
456
+ var z = class extends Error {
457
+ result;
458
+ output;
459
+ get exitCode() {
460
+ if (this.result.exitCode !== null) return this.result.exitCode;
461
+ }
462
+ constructor(e, t) {
463
+ super(`Process exited with non-zero status (${e.exitCode})`);
464
+ this.result = e;
465
+ this.output = t;
466
+ }
467
+ };
468
+ const B = {
469
+ timeout: void 0,
470
+ persist: false
471
+ };
472
+ const V = { windowsHide: true };
473
+ function H(e, t) {
474
+ return {
475
+ command: normalize(e),
476
+ args: t ?? []
477
+ };
478
+ }
479
+ function U(e) {
480
+ const t = new AbortController();
481
+ for (const n of e) {
482
+ if (n.aborted) {
483
+ t.abort();
484
+ return n;
485
+ }
486
+ const e = () => {
487
+ t.abort(n.reason);
488
+ };
489
+ n.addEventListener("abort", e, { signal: t.signal });
490
+ }
491
+ return t.signal;
492
+ }
493
+ async function W(e) {
494
+ let t = "";
495
+ for await (const n of e) t += n.toString();
496
+ return t;
497
+ }
498
+ var G = class {
499
+ _process;
500
+ _aborted = false;
501
+ _options;
502
+ _command;
503
+ _args;
504
+ _resolveClose;
505
+ _processClosed;
506
+ _thrownError;
507
+ get process() {
508
+ return this._process;
509
+ }
510
+ get pid() {
511
+ return this._process?.pid;
512
+ }
513
+ get exitCode() {
514
+ if (this._process && this._process.exitCode !== null) return this._process.exitCode;
515
+ }
516
+ constructor(e, t, n) {
517
+ this._options = {
518
+ ...B,
519
+ ...n
520
+ };
521
+ this._command = e;
522
+ this._args = t ?? [];
523
+ this._processClosed = new Promise((e) => {
524
+ this._resolveClose = e;
525
+ });
526
+ }
527
+ kill(e) {
528
+ return this._process?.kill(e) === true;
529
+ }
530
+ get aborted() {
531
+ return this._aborted;
532
+ }
533
+ get killed() {
534
+ return this._process?.killed === true;
535
+ }
536
+ pipe(e, t, n) {
537
+ return q(e, t, {
538
+ ...n,
539
+ stdin: this
540
+ });
541
+ }
542
+ async *[Symbol.asyncIterator]() {
543
+ const e = this._process;
544
+ if (!e) return;
545
+ const t = [];
546
+ if (this._streamErr) t.push(this._streamErr);
547
+ if (this._streamOut) t.push(this._streamOut);
548
+ const n = w(t);
549
+ const r = c.createInterface({ input: n });
550
+ for await (const e of r) yield e.toString();
551
+ await this._processClosed;
552
+ e.removeAllListeners();
553
+ if (this._thrownError) throw this._thrownError;
554
+ if (this._options?.throwOnError && this.exitCode !== 0 && this.exitCode !== void 0) throw new z(this);
555
+ }
556
+ async _waitForOutput() {
557
+ const e = this._process;
558
+ if (!e) throw new Error("No process was started");
559
+ const [t, n] = await Promise.all([this._streamOut ? W(this._streamOut) : "", this._streamErr ? W(this._streamErr) : ""]);
560
+ await this._processClosed;
561
+ if (this._options?.stdin) await this._options.stdin;
562
+ e.removeAllListeners();
563
+ if (this._thrownError) throw this._thrownError;
564
+ const r = {
565
+ stderr: n,
566
+ stdout: t,
567
+ exitCode: this.exitCode
568
+ };
569
+ if (this._options.throwOnError && this.exitCode !== 0 && this.exitCode !== void 0) throw new z(this, r);
570
+ return r;
571
+ }
572
+ then(e, t) {
573
+ return this._waitForOutput().then(e, t);
574
+ }
575
+ _streamOut;
576
+ _streamErr;
577
+ spawn() {
578
+ const e = cwd();
579
+ const n = this._options;
580
+ const r = {
581
+ ...V,
582
+ ...n.nodeOptions
583
+ };
584
+ const i = [];
585
+ this._resetState();
586
+ if (n.timeout !== void 0) i.push(AbortSignal.timeout(n.timeout));
587
+ if (n.signal !== void 0) i.push(n.signal);
588
+ if (n.persist === true) r.detached = true;
589
+ if (i.length > 0) r.signal = U(i);
590
+ r.env = C(e, r.env);
591
+ const { command: a, args: s } = H(this._command, this._args);
592
+ const c = (0, R._parse)(a, s, r);
593
+ const l = spawn(c.command, c.args, c.options);
594
+ if (l.stderr) this._streamErr = l.stderr;
595
+ if (l.stdout) this._streamOut = l.stdout;
596
+ this._process = l;
597
+ l.once("error", this._onError);
598
+ l.once("close", this._onClose);
599
+ if (n.stdin !== void 0 && l.stdin && n.stdin.process) {
600
+ const { stdout: e } = n.stdin.process;
601
+ if (e) e.pipe(l.stdin);
602
+ }
603
+ }
604
+ _resetState() {
605
+ this._aborted = false;
606
+ this._processClosed = new Promise((e) => {
607
+ this._resolveClose = e;
608
+ });
609
+ this._thrownError = void 0;
610
+ }
611
+ _onError = (e) => {
612
+ if (e.name === "AbortError" && (!(e.cause instanceof Error) || e.cause.name !== "TimeoutError")) {
613
+ this._aborted = true;
614
+ return;
615
+ }
616
+ this._thrownError = e;
617
+ };
618
+ _onClose = () => {
619
+ if (this._resolveClose) this._resolveClose();
620
+ };
621
+ };
622
+ const K = (e, t, n) => {
623
+ const r = new G(e, t, n);
624
+ r.spawn();
625
+ return r;
626
+ };
627
+ const q = K;
628
+ //#endregion
629
+ //#region node_modules/.pnpm/nypm@0.6.5/node_modules/nypm/dist/index.mjs
630
+ async function findup(cwd, match, options = {}) {
631
+ const segments = normalize$1(cwd).split("/");
632
+ while (segments.length > 0) {
633
+ const result = await match(segments.join("/") || "/");
634
+ if (result || !options.includeParentDirs) return result;
635
+ segments.pop();
636
+ }
637
+ }
638
+ async function readPackageJSON(cwd) {
639
+ return findup(cwd, (p) => {
640
+ const pkgPath = join(p, "package.json");
641
+ if (existsSync(pkgPath)) return readFile(pkgPath, "utf8").then((data) => JSON.parse(data));
642
+ });
643
+ }
644
+ function cached(fn) {
645
+ let v;
646
+ return () => {
647
+ if (v === void 0) v = fn().then((r) => {
648
+ v = r;
649
+ return v;
650
+ });
651
+ return v;
652
+ };
653
+ }
654
+ const hasCorepack = cached(async () => {
655
+ if (globalThis.process?.versions?.webcontainer) return false;
656
+ try {
657
+ const { exitCode } = await K("corepack", ["--version"]);
658
+ return exitCode === 0;
659
+ } catch {
660
+ return false;
661
+ }
662
+ });
663
+ async function executeCommand(command, args, options = {}) {
664
+ const xArgs = command !== "npm" && command !== "bun" && command !== "deno" && options.corepack !== false && await hasCorepack() ? ["corepack", [command, ...args]] : [command, args];
665
+ const { exitCode, stdout, stderr } = await K(xArgs[0], xArgs[1], { nodeOptions: {
666
+ cwd: resolve$1(options.cwd || process.cwd()),
667
+ env: options.env,
668
+ stdio: options.silent ? "pipe" : "inherit"
669
+ } });
670
+ if (exitCode !== 0) throw new Error(`\`${xArgs.flat().join(" ")}\` failed.${options.silent ? [
671
+ "",
672
+ stdout,
673
+ stderr
674
+ ].join("\n") : ""}`);
675
+ }
676
+ const NO_PACKAGE_MANAGER_DETECTED_ERROR_MSG = "No package manager auto-detected.";
677
+ async function resolveOperationOptions(options = {}) {
678
+ const cwd = options.cwd || process.cwd();
679
+ const env = {
680
+ ...process.env,
681
+ ...options.env
682
+ };
683
+ const packageManager = (typeof options.packageManager === "string" ? packageManagers.find((pm) => pm.name === options.packageManager) : options.packageManager) || await detectPackageManager(options.cwd || process.cwd());
684
+ if (!packageManager) throw new Error(NO_PACKAGE_MANAGER_DETECTED_ERROR_MSG);
685
+ return {
686
+ cwd,
687
+ env,
688
+ silent: options.silent ?? false,
689
+ packageManager,
690
+ dev: options.dev ?? false,
691
+ workspace: options.workspace,
692
+ global: options.global ?? false,
693
+ dry: options.dry ?? false,
694
+ corepack: options.corepack ?? true
695
+ };
696
+ }
697
+ function getWorkspaceArgs(options) {
698
+ if (!options.workspace) return [];
699
+ const workspacePkg = typeof options.workspace === "string" && options.workspace !== "" ? options.workspace : void 0;
700
+ if (options.packageManager.name === "pnpm") return workspacePkg ? ["--filter", workspacePkg] : ["--workspace-root"];
701
+ if (options.packageManager.name === "npm") return workspacePkg ? ["-w", workspacePkg] : ["--workspaces"];
702
+ if (options.packageManager.name === "yarn") if (!options.packageManager.majorVersion || options.packageManager.majorVersion === "1") return workspacePkg ? ["--cwd", workspacePkg] : ["-W"];
703
+ else return workspacePkg ? ["workspace", workspacePkg] : [];
704
+ return [];
705
+ }
706
+ function parsePackageManagerField(packageManager) {
707
+ const [name, _version] = (packageManager || "").split("@");
708
+ const [version, buildMeta] = _version?.split("+") || [];
709
+ if (name && name !== "-" && /^(@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/.test(name)) return {
710
+ name,
711
+ version,
712
+ buildMeta
713
+ };
714
+ const sanitized = (name || "").replace(/\W+/g, "");
715
+ return {
716
+ name: sanitized,
717
+ version,
718
+ buildMeta,
719
+ warnings: [`Abnormal characters found in \`packageManager\` field, sanitizing from \`${name}\` to \`${sanitized}\``]
720
+ };
721
+ }
722
+ const packageManagers = [
723
+ {
724
+ name: "npm",
725
+ command: "npm",
726
+ lockFile: "package-lock.json"
727
+ },
728
+ {
729
+ name: "pnpm",
730
+ command: "pnpm",
731
+ lockFile: "pnpm-lock.yaml",
732
+ files: ["pnpm-workspace.yaml"]
733
+ },
734
+ {
735
+ name: "bun",
736
+ command: "bun",
737
+ lockFile: ["bun.lockb", "bun.lock"]
738
+ },
739
+ {
740
+ name: "yarn",
741
+ command: "yarn",
742
+ lockFile: "yarn.lock",
743
+ files: [".yarnrc.yml"]
744
+ },
745
+ {
746
+ name: "deno",
747
+ command: "deno",
748
+ lockFile: "deno.lock",
749
+ files: ["deno.json"]
750
+ }
751
+ ];
752
+ async function detectPackageManager(cwd, options = {}) {
753
+ const detected = await findup(resolve$1(cwd || "."), async (path) => {
754
+ if (!options.ignorePackageJSON) {
755
+ const packageJSONPath = join$1(path, "package.json");
756
+ if (existsSync(packageJSONPath)) {
757
+ const packageJSON = JSON.parse(await readFile(packageJSONPath, "utf8"));
758
+ if (packageJSON?.packageManager) {
759
+ const { name, version = "0.0.0", buildMeta, warnings } = parsePackageManagerField(packageJSON.packageManager);
760
+ if (name) {
761
+ const majorVersion = version.split(".")[0];
762
+ const packageManager = packageManagers.find((pm) => pm.name === name && pm.majorVersion === majorVersion) || packageManagers.find((pm) => pm.name === name);
763
+ return {
764
+ name,
765
+ command: name,
766
+ version,
767
+ majorVersion,
768
+ buildMeta,
769
+ warnings,
770
+ files: packageManager?.files,
771
+ lockFile: packageManager?.lockFile
772
+ };
773
+ }
774
+ }
775
+ }
776
+ if (existsSync(join$1(path, "deno.json"))) return packageManagers.find((pm) => pm.name === "deno");
777
+ }
778
+ if (!options.ignoreLockFile) {
779
+ for (const packageManager of packageManagers) if ([packageManager.lockFile, packageManager.files].flat().filter(Boolean).some((file) => existsSync(resolve$1(path, file)))) return { ...packageManager };
780
+ }
781
+ }, { includeParentDirs: options.includeParentDirs ?? true });
782
+ if (!detected && !options.ignoreArgv) {
783
+ const scriptArg = process.argv[1];
784
+ if (scriptArg) {
785
+ for (const packageManager of packageManagers) if (new RegExp(`[/\\\\]\\.?${packageManager.command}`).test(scriptArg)) return packageManager;
786
+ }
787
+ }
788
+ return detected;
789
+ }
790
+ async function addDependency(name, options = {}) {
791
+ const resolvedOptions = await resolveOperationOptions(options);
792
+ const names = Array.isArray(name) ? name : [name];
793
+ if (resolvedOptions.packageManager.name === "deno") {
794
+ for (let i = 0; i < names.length; i++) if (!/^(npm|jsr|file):.+$/.test(names[i] || "")) names[i] = `npm:${names[i]}`;
795
+ }
796
+ if (names.length === 0) return {};
797
+ const args = (resolvedOptions.packageManager.name === "yarn" ? [
798
+ ...getWorkspaceArgs(resolvedOptions),
799
+ resolvedOptions.global && resolvedOptions.packageManager.majorVersion === "1" ? "global" : "",
800
+ "add",
801
+ resolvedOptions.dev ? "-D" : "",
802
+ ...names
803
+ ] : [
804
+ resolvedOptions.packageManager.name === "npm" ? "install" : "add",
805
+ ...getWorkspaceArgs(resolvedOptions),
806
+ resolvedOptions.dev ? "-D" : "",
807
+ resolvedOptions.global ? "-g" : "",
808
+ ...names
809
+ ]).filter(Boolean);
810
+ if (!resolvedOptions.dry) await executeCommand(resolvedOptions.packageManager.command, args, {
811
+ cwd: resolvedOptions.cwd,
812
+ silent: resolvedOptions.silent,
813
+ corepack: resolvedOptions.corepack
814
+ });
815
+ if (!resolvedOptions.dry && options.installPeerDependencies) {
816
+ const existingPkg = await readPackageJSON(resolvedOptions.cwd);
817
+ const peerDeps = [];
818
+ const peerDevDeps = [];
819
+ const _require = createRequire(join(resolvedOptions.cwd, "/_.js"));
820
+ for (const _name of names) {
821
+ const pkgName = _name.match(/^(.[^@]+)/)?.[0];
822
+ const pkg = await readPackageJSON(_require.resolve(pkgName));
823
+ if (!pkg?.peerDependencies || pkg?.name !== pkgName) continue;
824
+ for (const [peerDependency, version] of Object.entries(pkg.peerDependencies)) {
825
+ if (pkg.peerDependenciesMeta?.[peerDependency]?.optional) continue;
826
+ if (existingPkg?.dependencies?.[peerDependency] || existingPkg?.devDependencies?.[peerDependency]) continue;
827
+ (pkg.peerDependenciesMeta?.[peerDependency]?.dev ? peerDevDeps : peerDeps).push(`${peerDependency}@${version}`);
828
+ }
829
+ }
830
+ if (peerDeps.length > 0) await addDependency(peerDeps, { ...resolvedOptions });
831
+ if (peerDevDeps.length > 0) await addDevDependency(peerDevDeps, { ...resolvedOptions });
832
+ }
833
+ return { exec: {
834
+ command: resolvedOptions.packageManager.command,
835
+ args
836
+ } };
837
+ }
838
+ async function addDevDependency(name, options = {}) {
839
+ return await addDependency(name, {
840
+ ...options,
841
+ dev: true
842
+ });
843
+ }
844
+ //#endregion
845
+ export { packageManagers as i, addDevDependency as n, detectPackageManager as r, addDependency as t };