@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,1606 @@
1
+ import { n as __exportAll } from "../_common.mjs";
2
+ import { stat, unwatchFile, watch, watchFile } from "node:fs";
3
+ import { lstat, open, readdir, realpath, stat as stat$1 } from "node:fs/promises";
4
+ import { type } from "node:os";
5
+ import * as sp from "node:path";
6
+ import { join, relative, resolve, sep } from "node:path";
7
+ import { EventEmitter } from "node:events";
8
+ import { Readable } from "node:stream";
9
+ //#region node_modules/.pnpm/readdirp@5.0.0/node_modules/readdirp/index.js
10
+ const EntryTypes = {
11
+ FILE_TYPE: "files",
12
+ DIR_TYPE: "directories",
13
+ FILE_DIR_TYPE: "files_directories",
14
+ EVERYTHING_TYPE: "all"
15
+ };
16
+ const defaultOptions = {
17
+ root: ".",
18
+ fileFilter: (_entryInfo) => true,
19
+ directoryFilter: (_entryInfo) => true,
20
+ type: EntryTypes.FILE_TYPE,
21
+ lstat: false,
22
+ depth: 2147483648,
23
+ alwaysStat: false,
24
+ highWaterMark: 4096
25
+ };
26
+ Object.freeze(defaultOptions);
27
+ const RECURSIVE_ERROR_CODE = "READDIRP_RECURSIVE_ERROR";
28
+ const NORMAL_FLOW_ERRORS = new Set([
29
+ "ENOENT",
30
+ "EPERM",
31
+ "EACCES",
32
+ "ELOOP",
33
+ RECURSIVE_ERROR_CODE
34
+ ]);
35
+ const ALL_TYPES = [
36
+ EntryTypes.DIR_TYPE,
37
+ EntryTypes.EVERYTHING_TYPE,
38
+ EntryTypes.FILE_DIR_TYPE,
39
+ EntryTypes.FILE_TYPE
40
+ ];
41
+ const DIR_TYPES = new Set([
42
+ EntryTypes.DIR_TYPE,
43
+ EntryTypes.EVERYTHING_TYPE,
44
+ EntryTypes.FILE_DIR_TYPE
45
+ ]);
46
+ const FILE_TYPES = new Set([
47
+ EntryTypes.EVERYTHING_TYPE,
48
+ EntryTypes.FILE_DIR_TYPE,
49
+ EntryTypes.FILE_TYPE
50
+ ]);
51
+ const isNormalFlowError = (error) => NORMAL_FLOW_ERRORS.has(error.code);
52
+ const wantBigintFsStats = process.platform === "win32";
53
+ const emptyFn = (_entryInfo) => true;
54
+ const normalizeFilter = (filter) => {
55
+ if (filter === void 0) return emptyFn;
56
+ if (typeof filter === "function") return filter;
57
+ if (typeof filter === "string") {
58
+ const fl = filter.trim();
59
+ return (entry) => entry.basename === fl;
60
+ }
61
+ if (Array.isArray(filter)) {
62
+ const trItems = filter.map((item) => item.trim());
63
+ return (entry) => trItems.some((f) => entry.basename === f);
64
+ }
65
+ return emptyFn;
66
+ };
67
+ /** Readable readdir stream, emitting new files as they're being listed. */
68
+ var ReaddirpStream = class extends Readable {
69
+ parents;
70
+ reading;
71
+ parent;
72
+ _stat;
73
+ _maxDepth;
74
+ _wantsDir;
75
+ _wantsFile;
76
+ _wantsEverything;
77
+ _root;
78
+ _isDirent;
79
+ _statsProp;
80
+ _rdOptions;
81
+ _fileFilter;
82
+ _directoryFilter;
83
+ constructor(options = {}) {
84
+ super({
85
+ objectMode: true,
86
+ autoDestroy: true,
87
+ highWaterMark: options.highWaterMark
88
+ });
89
+ const opts = {
90
+ ...defaultOptions,
91
+ ...options
92
+ };
93
+ const { root, type } = opts;
94
+ this._fileFilter = normalizeFilter(opts.fileFilter);
95
+ this._directoryFilter = normalizeFilter(opts.directoryFilter);
96
+ const statMethod = opts.lstat ? lstat : stat$1;
97
+ if (wantBigintFsStats) this._stat = (path) => statMethod(path, { bigint: true });
98
+ else this._stat = statMethod;
99
+ this._maxDepth = opts.depth != null && Number.isSafeInteger(opts.depth) ? opts.depth : defaultOptions.depth;
100
+ this._wantsDir = type ? DIR_TYPES.has(type) : false;
101
+ this._wantsFile = type ? FILE_TYPES.has(type) : false;
102
+ this._wantsEverything = type === EntryTypes.EVERYTHING_TYPE;
103
+ this._root = resolve(root);
104
+ this._isDirent = !opts.alwaysStat;
105
+ this._statsProp = this._isDirent ? "dirent" : "stats";
106
+ this._rdOptions = {
107
+ encoding: "utf8",
108
+ withFileTypes: this._isDirent
109
+ };
110
+ this.parents = [this._exploreDir(root, 1)];
111
+ this.reading = false;
112
+ this.parent = void 0;
113
+ }
114
+ async _read(batch) {
115
+ if (this.reading) return;
116
+ this.reading = true;
117
+ try {
118
+ while (!this.destroyed && batch > 0) {
119
+ const par = this.parent;
120
+ const fil = par && par.files;
121
+ if (fil && fil.length > 0) {
122
+ const { path, depth } = par;
123
+ const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path));
124
+ const awaited = await Promise.all(slice);
125
+ for (const entry of awaited) {
126
+ if (!entry) continue;
127
+ if (this.destroyed) return;
128
+ const entryType = await this._getEntryType(entry);
129
+ if (entryType === "directory" && this._directoryFilter(entry)) {
130
+ if (depth <= this._maxDepth) this.parents.push(this._exploreDir(entry.fullPath, depth + 1));
131
+ if (this._wantsDir) {
132
+ this.push(entry);
133
+ batch--;
134
+ }
135
+ } else if ((entryType === "file" || this._includeAsFile(entry)) && this._fileFilter(entry)) {
136
+ if (this._wantsFile) {
137
+ this.push(entry);
138
+ batch--;
139
+ }
140
+ }
141
+ }
142
+ } else {
143
+ const parent = this.parents.pop();
144
+ if (!parent) {
145
+ this.push(null);
146
+ break;
147
+ }
148
+ this.parent = await parent;
149
+ if (this.destroyed) return;
150
+ }
151
+ }
152
+ } catch (error) {
153
+ this.destroy(error);
154
+ } finally {
155
+ this.reading = false;
156
+ }
157
+ }
158
+ async _exploreDir(path, depth) {
159
+ let files;
160
+ try {
161
+ files = await readdir(path, this._rdOptions);
162
+ } catch (error) {
163
+ this._onError(error);
164
+ }
165
+ return {
166
+ files,
167
+ depth,
168
+ path
169
+ };
170
+ }
171
+ async _formatEntry(dirent, path) {
172
+ let entry;
173
+ const basename = this._isDirent ? dirent.name : dirent;
174
+ try {
175
+ const fullPath = resolve(join(path, basename));
176
+ entry = {
177
+ path: relative(this._root, fullPath),
178
+ fullPath,
179
+ basename
180
+ };
181
+ entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
182
+ } catch (err) {
183
+ this._onError(err);
184
+ return;
185
+ }
186
+ return entry;
187
+ }
188
+ _onError(err) {
189
+ if (isNormalFlowError(err) && !this.destroyed) this.emit("warn", err);
190
+ else this.destroy(err);
191
+ }
192
+ async _getEntryType(entry) {
193
+ if (!entry && this._statsProp in entry) return "";
194
+ const stats = entry[this._statsProp];
195
+ if (stats.isFile()) return "file";
196
+ if (stats.isDirectory()) return "directory";
197
+ if (stats && stats.isSymbolicLink()) {
198
+ const full = entry.fullPath;
199
+ try {
200
+ const entryRealPath = await realpath(full);
201
+ const entryRealPathStats = await lstat(entryRealPath);
202
+ if (entryRealPathStats.isFile()) return "file";
203
+ if (entryRealPathStats.isDirectory()) {
204
+ const len = entryRealPath.length;
205
+ if (full.startsWith(entryRealPath) && full.substr(len, 1) === sep) {
206
+ const recursiveError = /* @__PURE__ */ new Error(`Circular symlink detected: "${full}" points to "${entryRealPath}"`);
207
+ recursiveError.code = RECURSIVE_ERROR_CODE;
208
+ return this._onError(recursiveError);
209
+ }
210
+ return "directory";
211
+ }
212
+ } catch (error) {
213
+ this._onError(error);
214
+ return "";
215
+ }
216
+ }
217
+ }
218
+ _includeAsFile(entry) {
219
+ const stats = entry && entry[this._statsProp];
220
+ return stats && this._wantsEverything && !stats.isDirectory();
221
+ }
222
+ };
223
+ /**
224
+ * Streaming version: Reads all files and directories in given root recursively.
225
+ * Consumes ~constant small amount of RAM.
226
+ * @param root Root directory
227
+ * @param options Options to specify root (start directory), filters and recursion depth
228
+ */
229
+ function readdirp(root, options = {}) {
230
+ let type = options.entryType || options.type;
231
+ if (type === "both") type = EntryTypes.FILE_DIR_TYPE;
232
+ if (type) options.type = type;
233
+ if (!root) throw new Error("readdirp: root argument is required. Usage: readdirp(root, options)");
234
+ else if (typeof root !== "string") throw new TypeError("readdirp: root argument must be a string. Usage: readdirp(root, options)");
235
+ else if (type && !ALL_TYPES.includes(type)) throw new Error(`readdirp: Invalid type passed. Use one of ${ALL_TYPES.join(", ")}`);
236
+ options.root = root;
237
+ return new ReaddirpStream(options);
238
+ }
239
+ //#endregion
240
+ //#region node_modules/.pnpm/chokidar@5.0.0/node_modules/chokidar/handler.js
241
+ const STR_DATA = "data";
242
+ const STR_CLOSE = "close";
243
+ const EMPTY_FN = () => {};
244
+ const pl = process.platform;
245
+ const isWindows = pl === "win32";
246
+ const isMacos = pl === "darwin";
247
+ const isLinux = pl === "linux";
248
+ const isFreeBSD = pl === "freebsd";
249
+ const isIBMi = type() === "OS400";
250
+ const EVENTS = {
251
+ ALL: "all",
252
+ READY: "ready",
253
+ ADD: "add",
254
+ CHANGE: "change",
255
+ ADD_DIR: "addDir",
256
+ UNLINK: "unlink",
257
+ UNLINK_DIR: "unlinkDir",
258
+ RAW: "raw",
259
+ ERROR: "error"
260
+ };
261
+ const EV = EVENTS;
262
+ const THROTTLE_MODE_WATCH = "watch";
263
+ const statMethods = {
264
+ lstat,
265
+ stat: stat$1
266
+ };
267
+ const KEY_LISTENERS = "listeners";
268
+ const KEY_ERR = "errHandlers";
269
+ const KEY_RAW = "rawEmitters";
270
+ const HANDLER_KEYS = [
271
+ KEY_LISTENERS,
272
+ KEY_ERR,
273
+ KEY_RAW
274
+ ];
275
+ const binaryExtensions = new Set([
276
+ "3dm",
277
+ "3ds",
278
+ "3g2",
279
+ "3gp",
280
+ "7z",
281
+ "a",
282
+ "aac",
283
+ "adp",
284
+ "afdesign",
285
+ "afphoto",
286
+ "afpub",
287
+ "ai",
288
+ "aif",
289
+ "aiff",
290
+ "alz",
291
+ "ape",
292
+ "apk",
293
+ "appimage",
294
+ "ar",
295
+ "arj",
296
+ "asf",
297
+ "au",
298
+ "avi",
299
+ "bak",
300
+ "baml",
301
+ "bh",
302
+ "bin",
303
+ "bk",
304
+ "bmp",
305
+ "btif",
306
+ "bz2",
307
+ "bzip2",
308
+ "cab",
309
+ "caf",
310
+ "cgm",
311
+ "class",
312
+ "cmx",
313
+ "cpio",
314
+ "cr2",
315
+ "cur",
316
+ "dat",
317
+ "dcm",
318
+ "deb",
319
+ "dex",
320
+ "djvu",
321
+ "dll",
322
+ "dmg",
323
+ "dng",
324
+ "doc",
325
+ "docm",
326
+ "docx",
327
+ "dot",
328
+ "dotm",
329
+ "dra",
330
+ "DS_Store",
331
+ "dsk",
332
+ "dts",
333
+ "dtshd",
334
+ "dvb",
335
+ "dwg",
336
+ "dxf",
337
+ "ecelp4800",
338
+ "ecelp7470",
339
+ "ecelp9600",
340
+ "egg",
341
+ "eol",
342
+ "eot",
343
+ "epub",
344
+ "exe",
345
+ "f4v",
346
+ "fbs",
347
+ "fh",
348
+ "fla",
349
+ "flac",
350
+ "flatpak",
351
+ "fli",
352
+ "flv",
353
+ "fpx",
354
+ "fst",
355
+ "fvt",
356
+ "g3",
357
+ "gh",
358
+ "gif",
359
+ "graffle",
360
+ "gz",
361
+ "gzip",
362
+ "h261",
363
+ "h263",
364
+ "h264",
365
+ "icns",
366
+ "ico",
367
+ "ief",
368
+ "img",
369
+ "ipa",
370
+ "iso",
371
+ "jar",
372
+ "jpeg",
373
+ "jpg",
374
+ "jpgv",
375
+ "jpm",
376
+ "jxr",
377
+ "key",
378
+ "ktx",
379
+ "lha",
380
+ "lib",
381
+ "lvp",
382
+ "lz",
383
+ "lzh",
384
+ "lzma",
385
+ "lzo",
386
+ "m3u",
387
+ "m4a",
388
+ "m4v",
389
+ "mar",
390
+ "mdi",
391
+ "mht",
392
+ "mid",
393
+ "midi",
394
+ "mj2",
395
+ "mka",
396
+ "mkv",
397
+ "mmr",
398
+ "mng",
399
+ "mobi",
400
+ "mov",
401
+ "movie",
402
+ "mp3",
403
+ "mp4",
404
+ "mp4a",
405
+ "mpeg",
406
+ "mpg",
407
+ "mpga",
408
+ "mxu",
409
+ "nef",
410
+ "npx",
411
+ "numbers",
412
+ "nupkg",
413
+ "o",
414
+ "odp",
415
+ "ods",
416
+ "odt",
417
+ "oga",
418
+ "ogg",
419
+ "ogv",
420
+ "otf",
421
+ "ott",
422
+ "pages",
423
+ "pbm",
424
+ "pcx",
425
+ "pdb",
426
+ "pdf",
427
+ "pea",
428
+ "pgm",
429
+ "pic",
430
+ "png",
431
+ "pnm",
432
+ "pot",
433
+ "potm",
434
+ "potx",
435
+ "ppa",
436
+ "ppam",
437
+ "ppm",
438
+ "pps",
439
+ "ppsm",
440
+ "ppsx",
441
+ "ppt",
442
+ "pptm",
443
+ "pptx",
444
+ "psd",
445
+ "pya",
446
+ "pyc",
447
+ "pyo",
448
+ "pyv",
449
+ "qt",
450
+ "rar",
451
+ "ras",
452
+ "raw",
453
+ "resources",
454
+ "rgb",
455
+ "rip",
456
+ "rlc",
457
+ "rmf",
458
+ "rmvb",
459
+ "rpm",
460
+ "rtf",
461
+ "rz",
462
+ "s3m",
463
+ "s7z",
464
+ "scpt",
465
+ "sgi",
466
+ "shar",
467
+ "snap",
468
+ "sil",
469
+ "sketch",
470
+ "slk",
471
+ "smv",
472
+ "snk",
473
+ "so",
474
+ "stl",
475
+ "suo",
476
+ "sub",
477
+ "swf",
478
+ "tar",
479
+ "tbz",
480
+ "tbz2",
481
+ "tga",
482
+ "tgz",
483
+ "thmx",
484
+ "tif",
485
+ "tiff",
486
+ "tlz",
487
+ "ttc",
488
+ "ttf",
489
+ "txz",
490
+ "udf",
491
+ "uvh",
492
+ "uvi",
493
+ "uvm",
494
+ "uvp",
495
+ "uvs",
496
+ "uvu",
497
+ "viv",
498
+ "vob",
499
+ "war",
500
+ "wav",
501
+ "wax",
502
+ "wbmp",
503
+ "wdp",
504
+ "weba",
505
+ "webm",
506
+ "webp",
507
+ "whl",
508
+ "wim",
509
+ "wm",
510
+ "wma",
511
+ "wmv",
512
+ "wmx",
513
+ "woff",
514
+ "woff2",
515
+ "wrm",
516
+ "wvx",
517
+ "xbm",
518
+ "xif",
519
+ "xla",
520
+ "xlam",
521
+ "xls",
522
+ "xlsb",
523
+ "xlsm",
524
+ "xlsx",
525
+ "xlt",
526
+ "xltm",
527
+ "xltx",
528
+ "xm",
529
+ "xmind",
530
+ "xpi",
531
+ "xpm",
532
+ "xwd",
533
+ "xz",
534
+ "z",
535
+ "zip",
536
+ "zipx"
537
+ ]);
538
+ const isBinaryPath = (filePath) => binaryExtensions.has(sp.extname(filePath).slice(1).toLowerCase());
539
+ const foreach = (val, fn) => {
540
+ if (val instanceof Set) val.forEach(fn);
541
+ else fn(val);
542
+ };
543
+ const addAndConvert = (main, prop, item) => {
544
+ let container = main[prop];
545
+ if (!(container instanceof Set)) main[prop] = container = new Set([container]);
546
+ container.add(item);
547
+ };
548
+ const clearItem = (cont) => (key) => {
549
+ const set = cont[key];
550
+ if (set instanceof Set) set.clear();
551
+ else delete cont[key];
552
+ };
553
+ const delFromSet = (main, prop, item) => {
554
+ const container = main[prop];
555
+ if (container instanceof Set) container.delete(item);
556
+ else if (container === item) delete main[prop];
557
+ };
558
+ const isEmptySet = (val) => val instanceof Set ? val.size === 0 : !val;
559
+ const FsWatchInstances = /* @__PURE__ */ new Map();
560
+ /**
561
+ * Instantiates the fs_watch interface
562
+ * @param path to be watched
563
+ * @param options to be passed to fs_watch
564
+ * @param listener main event handler
565
+ * @param errHandler emits info about errors
566
+ * @param emitRaw emits raw event data
567
+ * @returns {NativeFsWatcher}
568
+ */
569
+ function createFsWatchInstance(path, options, listener, errHandler, emitRaw) {
570
+ const handleEvent = (rawEvent, evPath) => {
571
+ listener(path);
572
+ emitRaw(rawEvent, evPath, { watchedPath: path });
573
+ if (evPath && path !== evPath) fsWatchBroadcast(sp.resolve(path, evPath), KEY_LISTENERS, sp.join(path, evPath));
574
+ };
575
+ try {
576
+ return watch(path, { persistent: options.persistent }, handleEvent);
577
+ } catch (error) {
578
+ errHandler(error);
579
+ return;
580
+ }
581
+ }
582
+ /**
583
+ * Helper for passing fs_watch event data to a collection of listeners
584
+ * @param fullPath absolute path bound to fs_watch instance
585
+ */
586
+ const fsWatchBroadcast = (fullPath, listenerType, val1, val2, val3) => {
587
+ const cont = FsWatchInstances.get(fullPath);
588
+ if (!cont) return;
589
+ foreach(cont[listenerType], (listener) => {
590
+ listener(val1, val2, val3);
591
+ });
592
+ };
593
+ /**
594
+ * Instantiates the fs_watch interface or binds listeners
595
+ * to an existing one covering the same file system entry
596
+ * @param path
597
+ * @param fullPath absolute path
598
+ * @param options to be passed to fs_watch
599
+ * @param handlers container for event listener functions
600
+ */
601
+ const setFsWatchListener = (path, fullPath, options, handlers) => {
602
+ const { listener, errHandler, rawEmitter } = handlers;
603
+ let cont = FsWatchInstances.get(fullPath);
604
+ let watcher;
605
+ if (!options.persistent) {
606
+ watcher = createFsWatchInstance(path, options, listener, errHandler, rawEmitter);
607
+ if (!watcher) return;
608
+ return watcher.close.bind(watcher);
609
+ }
610
+ if (cont) {
611
+ addAndConvert(cont, KEY_LISTENERS, listener);
612
+ addAndConvert(cont, KEY_ERR, errHandler);
613
+ addAndConvert(cont, KEY_RAW, rawEmitter);
614
+ } else {
615
+ watcher = createFsWatchInstance(path, options, fsWatchBroadcast.bind(null, fullPath, KEY_LISTENERS), errHandler, fsWatchBroadcast.bind(null, fullPath, KEY_RAW));
616
+ if (!watcher) return;
617
+ watcher.on(EV.ERROR, async (error) => {
618
+ const broadcastErr = fsWatchBroadcast.bind(null, fullPath, KEY_ERR);
619
+ if (cont) cont.watcherUnusable = true;
620
+ if (isWindows && error.code === "EPERM") try {
621
+ await (await open(path, "r")).close();
622
+ broadcastErr(error);
623
+ } catch (err) {}
624
+ else broadcastErr(error);
625
+ });
626
+ cont = {
627
+ listeners: listener,
628
+ errHandlers: errHandler,
629
+ rawEmitters: rawEmitter,
630
+ watcher
631
+ };
632
+ FsWatchInstances.set(fullPath, cont);
633
+ }
634
+ return () => {
635
+ delFromSet(cont, KEY_LISTENERS, listener);
636
+ delFromSet(cont, KEY_ERR, errHandler);
637
+ delFromSet(cont, KEY_RAW, rawEmitter);
638
+ if (isEmptySet(cont.listeners)) {
639
+ cont.watcher.close();
640
+ FsWatchInstances.delete(fullPath);
641
+ HANDLER_KEYS.forEach(clearItem(cont));
642
+ cont.watcher = void 0;
643
+ Object.freeze(cont);
644
+ }
645
+ };
646
+ };
647
+ const FsWatchFileInstances = /* @__PURE__ */ new Map();
648
+ /**
649
+ * Instantiates the fs_watchFile interface or binds listeners
650
+ * to an existing one covering the same file system entry
651
+ * @param path to be watched
652
+ * @param fullPath absolute path
653
+ * @param options options to be passed to fs_watchFile
654
+ * @param handlers container for event listener functions
655
+ * @returns closer
656
+ */
657
+ const setFsWatchFileListener = (path, fullPath, options, handlers) => {
658
+ const { listener, rawEmitter } = handlers;
659
+ let cont = FsWatchFileInstances.get(fullPath);
660
+ const copts = cont && cont.options;
661
+ if (copts && (copts.persistent < options.persistent || copts.interval > options.interval)) {
662
+ unwatchFile(fullPath);
663
+ cont = void 0;
664
+ }
665
+ if (cont) {
666
+ addAndConvert(cont, KEY_LISTENERS, listener);
667
+ addAndConvert(cont, KEY_RAW, rawEmitter);
668
+ } else {
669
+ cont = {
670
+ listeners: listener,
671
+ rawEmitters: rawEmitter,
672
+ options,
673
+ watcher: watchFile(fullPath, options, (curr, prev) => {
674
+ foreach(cont.rawEmitters, (rawEmitter) => {
675
+ rawEmitter(EV.CHANGE, fullPath, {
676
+ curr,
677
+ prev
678
+ });
679
+ });
680
+ const currmtime = curr.mtimeMs;
681
+ if (curr.size !== prev.size || currmtime > prev.mtimeMs || currmtime === 0) foreach(cont.listeners, (listener) => listener(path, curr));
682
+ })
683
+ };
684
+ FsWatchFileInstances.set(fullPath, cont);
685
+ }
686
+ return () => {
687
+ delFromSet(cont, KEY_LISTENERS, listener);
688
+ delFromSet(cont, KEY_RAW, rawEmitter);
689
+ if (isEmptySet(cont.listeners)) {
690
+ FsWatchFileInstances.delete(fullPath);
691
+ unwatchFile(fullPath);
692
+ cont.options = cont.watcher = void 0;
693
+ Object.freeze(cont);
694
+ }
695
+ };
696
+ };
697
+ /**
698
+ * @mixin
699
+ */
700
+ var NodeFsHandler = class {
701
+ fsw;
702
+ _boundHandleError;
703
+ constructor(fsW) {
704
+ this.fsw = fsW;
705
+ this._boundHandleError = (error) => fsW._handleError(error);
706
+ }
707
+ /**
708
+ * Watch file for changes with fs_watchFile or fs_watch.
709
+ * @param path to file or dir
710
+ * @param listener on fs change
711
+ * @returns closer for the watcher instance
712
+ */
713
+ _watchWithNodeFs(path, listener) {
714
+ const opts = this.fsw.options;
715
+ const directory = sp.dirname(path);
716
+ const basename = sp.basename(path);
717
+ this.fsw._getWatchedDir(directory).add(basename);
718
+ const absolutePath = sp.resolve(path);
719
+ const options = { persistent: opts.persistent };
720
+ if (!listener) listener = EMPTY_FN;
721
+ let closer;
722
+ if (opts.usePolling) {
723
+ options.interval = opts.interval !== opts.binaryInterval && isBinaryPath(basename) ? opts.binaryInterval : opts.interval;
724
+ closer = setFsWatchFileListener(path, absolutePath, options, {
725
+ listener,
726
+ rawEmitter: this.fsw._emitRaw
727
+ });
728
+ } else closer = setFsWatchListener(path, absolutePath, options, {
729
+ listener,
730
+ errHandler: this._boundHandleError,
731
+ rawEmitter: this.fsw._emitRaw
732
+ });
733
+ return closer;
734
+ }
735
+ /**
736
+ * Watch a file and emit add event if warranted.
737
+ * @returns closer for the watcher instance
738
+ */
739
+ _handleFile(file, stats, initialAdd) {
740
+ if (this.fsw.closed) return;
741
+ const dirname = sp.dirname(file);
742
+ const basename = sp.basename(file);
743
+ const parent = this.fsw._getWatchedDir(dirname);
744
+ let prevStats = stats;
745
+ if (parent.has(basename)) return;
746
+ const listener = async (path, newStats) => {
747
+ if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file, 5)) return;
748
+ if (!newStats || newStats.mtimeMs === 0) try {
749
+ const newStats = await stat$1(file);
750
+ if (this.fsw.closed) return;
751
+ const at = newStats.atimeMs;
752
+ const mt = newStats.mtimeMs;
753
+ if (!at || at <= mt || mt !== prevStats.mtimeMs) this.fsw._emit(EV.CHANGE, file, newStats);
754
+ if ((isMacos || isLinux || isFreeBSD) && prevStats.ino !== newStats.ino) {
755
+ this.fsw._closeFile(path);
756
+ prevStats = newStats;
757
+ const closer = this._watchWithNodeFs(file, listener);
758
+ if (closer) this.fsw._addPathCloser(path, closer);
759
+ } else prevStats = newStats;
760
+ } catch (error) {
761
+ this.fsw._remove(dirname, basename);
762
+ }
763
+ else if (parent.has(basename)) {
764
+ const at = newStats.atimeMs;
765
+ const mt = newStats.mtimeMs;
766
+ if (!at || at <= mt || mt !== prevStats.mtimeMs) this.fsw._emit(EV.CHANGE, file, newStats);
767
+ prevStats = newStats;
768
+ }
769
+ };
770
+ const closer = this._watchWithNodeFs(file, listener);
771
+ if (!(initialAdd && this.fsw.options.ignoreInitial) && this.fsw._isntIgnored(file)) {
772
+ if (!this.fsw._throttle(EV.ADD, file, 0)) return;
773
+ this.fsw._emit(EV.ADD, file, stats);
774
+ }
775
+ return closer;
776
+ }
777
+ /**
778
+ * Handle symlinks encountered while reading a dir.
779
+ * @param entry returned by readdirp
780
+ * @param directory path of dir being read
781
+ * @param path of this item
782
+ * @param item basename of this item
783
+ * @returns true if no more processing is needed for this entry.
784
+ */
785
+ async _handleSymlink(entry, directory, path, item) {
786
+ if (this.fsw.closed) return;
787
+ const full = entry.fullPath;
788
+ const dir = this.fsw._getWatchedDir(directory);
789
+ if (!this.fsw.options.followSymlinks) {
790
+ this.fsw._incrReadyCount();
791
+ let linkPath;
792
+ try {
793
+ linkPath = await realpath(path);
794
+ } catch (e) {
795
+ this.fsw._emitReady();
796
+ return true;
797
+ }
798
+ if (this.fsw.closed) return;
799
+ if (dir.has(item)) {
800
+ if (this.fsw._symlinkPaths.get(full) !== linkPath) {
801
+ this.fsw._symlinkPaths.set(full, linkPath);
802
+ this.fsw._emit(EV.CHANGE, path, entry.stats);
803
+ }
804
+ } else {
805
+ dir.add(item);
806
+ this.fsw._symlinkPaths.set(full, linkPath);
807
+ this.fsw._emit(EV.ADD, path, entry.stats);
808
+ }
809
+ this.fsw._emitReady();
810
+ return true;
811
+ }
812
+ if (this.fsw._symlinkPaths.has(full)) return true;
813
+ this.fsw._symlinkPaths.set(full, true);
814
+ }
815
+ _handleRead(directory, initialAdd, wh, target, dir, depth, throttler) {
816
+ directory = sp.join(directory, "");
817
+ const throttleKey = target ? `${directory}:${target}` : directory;
818
+ throttler = this.fsw._throttle("readdir", throttleKey, 1e3);
819
+ if (!throttler) return;
820
+ const previous = this.fsw._getWatchedDir(wh.path);
821
+ const current = /* @__PURE__ */ new Set();
822
+ let stream = this.fsw._readdirp(directory, {
823
+ fileFilter: (entry) => wh.filterPath(entry),
824
+ directoryFilter: (entry) => wh.filterDir(entry)
825
+ });
826
+ if (!stream) return;
827
+ stream.on(STR_DATA, async (entry) => {
828
+ if (this.fsw.closed) {
829
+ stream = void 0;
830
+ return;
831
+ }
832
+ const item = entry.path;
833
+ let path = sp.join(directory, item);
834
+ current.add(item);
835
+ if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path, item)) return;
836
+ if (this.fsw.closed) {
837
+ stream = void 0;
838
+ return;
839
+ }
840
+ if (item === target || !target && !previous.has(item)) {
841
+ this.fsw._incrReadyCount();
842
+ path = sp.join(dir, sp.relative(dir, path));
843
+ this._addToNodeFs(path, initialAdd, wh, depth + 1);
844
+ }
845
+ }).on(EV.ERROR, this._boundHandleError);
846
+ return new Promise((resolve, reject) => {
847
+ if (!stream) return reject();
848
+ stream.once("end", () => {
849
+ if (this.fsw.closed) {
850
+ stream = void 0;
851
+ return;
852
+ }
853
+ const wasThrottled = throttler ? throttler.clear() : false;
854
+ resolve(void 0);
855
+ previous.getChildren().filter((item) => {
856
+ return item !== directory && !current.has(item);
857
+ }).forEach((item) => {
858
+ this.fsw._remove(directory, item);
859
+ });
860
+ stream = void 0;
861
+ if (wasThrottled) this._handleRead(directory, false, wh, target, dir, depth, throttler);
862
+ });
863
+ });
864
+ }
865
+ /**
866
+ * Read directory to add / remove files from `@watched` list and re-read it on change.
867
+ * @param dir fs path
868
+ * @param stats
869
+ * @param initialAdd
870
+ * @param depth relative to user-supplied path
871
+ * @param target child path targeted for watch
872
+ * @param wh Common watch helpers for this path
873
+ * @param realpath
874
+ * @returns closer for the watcher instance.
875
+ */
876
+ async _handleDir(dir, stats, initialAdd, depth, target, wh, realpath) {
877
+ const parentDir = this.fsw._getWatchedDir(sp.dirname(dir));
878
+ const tracked = parentDir.has(sp.basename(dir));
879
+ if (!(initialAdd && this.fsw.options.ignoreInitial) && !target && !tracked) this.fsw._emit(EV.ADD_DIR, dir, stats);
880
+ parentDir.add(sp.basename(dir));
881
+ this.fsw._getWatchedDir(dir);
882
+ let throttler;
883
+ let closer;
884
+ const oDepth = this.fsw.options.depth;
885
+ if ((oDepth == null || depth <= oDepth) && !this.fsw._symlinkPaths.has(realpath)) {
886
+ if (!target) {
887
+ await this._handleRead(dir, initialAdd, wh, target, dir, depth, throttler);
888
+ if (this.fsw.closed) return;
889
+ }
890
+ closer = this._watchWithNodeFs(dir, (dirPath, stats) => {
891
+ if (stats && stats.mtimeMs === 0) return;
892
+ this._handleRead(dirPath, false, wh, target, dir, depth, throttler);
893
+ });
894
+ }
895
+ return closer;
896
+ }
897
+ /**
898
+ * Handle added file, directory, or glob pattern.
899
+ * Delegates call to _handleFile / _handleDir after checks.
900
+ * @param path to file or ir
901
+ * @param initialAdd was the file added at watch instantiation?
902
+ * @param priorWh depth relative to user-supplied path
903
+ * @param depth Child path actually targeted for watch
904
+ * @param target Child path actually targeted for watch
905
+ */
906
+ async _addToNodeFs(path, initialAdd, priorWh, depth, target) {
907
+ const ready = this.fsw._emitReady;
908
+ if (this.fsw._isIgnored(path) || this.fsw.closed) {
909
+ ready();
910
+ return false;
911
+ }
912
+ const wh = this.fsw._getWatchHelpers(path);
913
+ if (priorWh) {
914
+ wh.filterPath = (entry) => priorWh.filterPath(entry);
915
+ wh.filterDir = (entry) => priorWh.filterDir(entry);
916
+ }
917
+ try {
918
+ const stats = await statMethods[wh.statMethod](wh.watchPath);
919
+ if (this.fsw.closed) return;
920
+ if (this.fsw._isIgnored(wh.watchPath, stats)) {
921
+ ready();
922
+ return false;
923
+ }
924
+ const follow = this.fsw.options.followSymlinks;
925
+ let closer;
926
+ if (stats.isDirectory()) {
927
+ const absPath = sp.resolve(path);
928
+ const targetPath = follow ? await realpath(path) : path;
929
+ if (this.fsw.closed) return;
930
+ closer = await this._handleDir(wh.watchPath, stats, initialAdd, depth, target, wh, targetPath);
931
+ if (this.fsw.closed) return;
932
+ if (absPath !== targetPath && targetPath !== void 0) this.fsw._symlinkPaths.set(absPath, targetPath);
933
+ } else if (stats.isSymbolicLink()) {
934
+ const targetPath = follow ? await realpath(path) : path;
935
+ if (this.fsw.closed) return;
936
+ const parent = sp.dirname(wh.watchPath);
937
+ this.fsw._getWatchedDir(parent).add(wh.watchPath);
938
+ this.fsw._emit(EV.ADD, wh.watchPath, stats);
939
+ closer = await this._handleDir(parent, stats, initialAdd, depth, path, wh, targetPath);
940
+ if (this.fsw.closed) return;
941
+ if (targetPath !== void 0) this.fsw._symlinkPaths.set(sp.resolve(path), targetPath);
942
+ } else closer = this._handleFile(wh.watchPath, stats, initialAdd);
943
+ ready();
944
+ if (closer) this.fsw._addPathCloser(path, closer);
945
+ return false;
946
+ } catch (error) {
947
+ if (this.fsw._handleError(error)) {
948
+ ready();
949
+ return path;
950
+ }
951
+ }
952
+ }
953
+ };
954
+ //#endregion
955
+ //#region node_modules/.pnpm/chokidar@5.0.0/node_modules/chokidar/index.js
956
+ /*! chokidar - MIT License (c) 2012 Paul Miller (paulmillr.com) */
957
+ var chokidar_exports = /* @__PURE__ */ __exportAll({
958
+ FSWatcher: () => FSWatcher,
959
+ WatchHelper: () => WatchHelper,
960
+ default: () => chokidar_default,
961
+ watch: () => watch$1
962
+ });
963
+ const SLASH = "/";
964
+ const SLASH_SLASH = "//";
965
+ const ONE_DOT = ".";
966
+ const TWO_DOTS = "..";
967
+ const STRING_TYPE = "string";
968
+ const BACK_SLASH_RE = /\\/g;
969
+ const DOUBLE_SLASH_RE = /\/\//g;
970
+ const DOT_RE = /\..*\.(sw[px])$|~$|\.subl.*\.tmp/;
971
+ const REPLACER_RE = /^\.[/\\]/;
972
+ function arrify(item) {
973
+ return Array.isArray(item) ? item : [item];
974
+ }
975
+ const isMatcherObject = (matcher) => typeof matcher === "object" && matcher !== null && !(matcher instanceof RegExp);
976
+ function createPattern(matcher) {
977
+ if (typeof matcher === "function") return matcher;
978
+ if (typeof matcher === "string") return (string) => matcher === string;
979
+ if (matcher instanceof RegExp) return (string) => matcher.test(string);
980
+ if (typeof matcher === "object" && matcher !== null) return (string) => {
981
+ if (matcher.path === string) return true;
982
+ if (matcher.recursive) {
983
+ const relative = sp.relative(matcher.path, string);
984
+ if (!relative) return false;
985
+ return !relative.startsWith("..") && !sp.isAbsolute(relative);
986
+ }
987
+ return false;
988
+ };
989
+ return () => false;
990
+ }
991
+ function normalizePath(path) {
992
+ if (typeof path !== "string") throw new Error("string expected");
993
+ path = sp.normalize(path);
994
+ path = path.replace(/\\/g, "/");
995
+ let prepend = false;
996
+ if (path.startsWith("//")) prepend = true;
997
+ path = path.replace(DOUBLE_SLASH_RE, "/");
998
+ if (prepend) path = "/" + path;
999
+ return path;
1000
+ }
1001
+ function matchPatterns(patterns, testString, stats) {
1002
+ const path = normalizePath(testString);
1003
+ for (let index = 0; index < patterns.length; index++) {
1004
+ const pattern = patterns[index];
1005
+ if (pattern(path, stats)) return true;
1006
+ }
1007
+ return false;
1008
+ }
1009
+ function anymatch(matchers, testString) {
1010
+ if (matchers == null) throw new TypeError("anymatch: specify first argument");
1011
+ const patterns = arrify(matchers).map((matcher) => createPattern(matcher));
1012
+ if (testString == null) return (testString, stats) => {
1013
+ return matchPatterns(patterns, testString, stats);
1014
+ };
1015
+ return matchPatterns(patterns, testString);
1016
+ }
1017
+ const unifyPaths = (paths_) => {
1018
+ const paths = arrify(paths_).flat();
1019
+ if (!paths.every((p) => typeof p === STRING_TYPE)) throw new TypeError(`Non-string provided as watch path: ${paths}`);
1020
+ return paths.map(normalizePathToUnix);
1021
+ };
1022
+ const toUnix = (string) => {
1023
+ let str = string.replace(BACK_SLASH_RE, SLASH);
1024
+ let prepend = false;
1025
+ if (str.startsWith(SLASH_SLASH)) prepend = true;
1026
+ str = str.replace(DOUBLE_SLASH_RE, SLASH);
1027
+ if (prepend) str = SLASH + str;
1028
+ return str;
1029
+ };
1030
+ const normalizePathToUnix = (path) => toUnix(sp.normalize(toUnix(path)));
1031
+ const normalizeIgnored = (cwd = "") => (path) => {
1032
+ if (typeof path === "string") return normalizePathToUnix(sp.isAbsolute(path) ? path : sp.join(cwd, path));
1033
+ else return path;
1034
+ };
1035
+ const getAbsolutePath = (path, cwd) => {
1036
+ if (sp.isAbsolute(path)) return path;
1037
+ return sp.join(cwd, path);
1038
+ };
1039
+ const EMPTY_SET = Object.freeze(/* @__PURE__ */ new Set());
1040
+ /**
1041
+ * Directory entry.
1042
+ */
1043
+ var DirEntry = class {
1044
+ path;
1045
+ _removeWatcher;
1046
+ items;
1047
+ constructor(dir, removeWatcher) {
1048
+ this.path = dir;
1049
+ this._removeWatcher = removeWatcher;
1050
+ this.items = /* @__PURE__ */ new Set();
1051
+ }
1052
+ add(item) {
1053
+ const { items } = this;
1054
+ if (!items) return;
1055
+ if (item !== ONE_DOT && item !== TWO_DOTS) items.add(item);
1056
+ }
1057
+ async remove(item) {
1058
+ const { items } = this;
1059
+ if (!items) return;
1060
+ items.delete(item);
1061
+ if (items.size > 0) return;
1062
+ const dir = this.path;
1063
+ try {
1064
+ await readdir(dir);
1065
+ } catch (err) {
1066
+ if (this._removeWatcher) this._removeWatcher(sp.dirname(dir), sp.basename(dir));
1067
+ }
1068
+ }
1069
+ has(item) {
1070
+ const { items } = this;
1071
+ if (!items) return;
1072
+ return items.has(item);
1073
+ }
1074
+ getChildren() {
1075
+ const { items } = this;
1076
+ if (!items) return [];
1077
+ return [...items.values()];
1078
+ }
1079
+ dispose() {
1080
+ this.items.clear();
1081
+ this.path = "";
1082
+ this._removeWatcher = EMPTY_FN;
1083
+ this.items = EMPTY_SET;
1084
+ Object.freeze(this);
1085
+ }
1086
+ };
1087
+ const STAT_METHOD_F = "stat";
1088
+ const STAT_METHOD_L = "lstat";
1089
+ var WatchHelper = class {
1090
+ fsw;
1091
+ path;
1092
+ watchPath;
1093
+ fullWatchPath;
1094
+ dirParts;
1095
+ followSymlinks;
1096
+ statMethod;
1097
+ constructor(path, follow, fsw) {
1098
+ this.fsw = fsw;
1099
+ const watchPath = path;
1100
+ this.path = path = path.replace(REPLACER_RE, "");
1101
+ this.watchPath = watchPath;
1102
+ this.fullWatchPath = sp.resolve(watchPath);
1103
+ this.dirParts = [];
1104
+ this.dirParts.forEach((parts) => {
1105
+ if (parts.length > 1) parts.pop();
1106
+ });
1107
+ this.followSymlinks = follow;
1108
+ this.statMethod = follow ? STAT_METHOD_F : STAT_METHOD_L;
1109
+ }
1110
+ entryPath(entry) {
1111
+ return sp.join(this.watchPath, sp.relative(this.watchPath, entry.fullPath));
1112
+ }
1113
+ filterPath(entry) {
1114
+ const { stats } = entry;
1115
+ if (stats && stats.isSymbolicLink()) return this.filterDir(entry);
1116
+ const resolvedPath = this.entryPath(entry);
1117
+ return this.fsw._isntIgnored(resolvedPath, stats) && this.fsw._hasReadPermissions(stats);
1118
+ }
1119
+ filterDir(entry) {
1120
+ return this.fsw._isntIgnored(this.entryPath(entry), entry.stats);
1121
+ }
1122
+ };
1123
+ /**
1124
+ * Watches files & directories for changes. Emitted events:
1125
+ * `add`, `addDir`, `change`, `unlink`, `unlinkDir`, `all`, `error`
1126
+ *
1127
+ * new FSWatcher()
1128
+ * .add(directories)
1129
+ * .on('add', path => log('File', path, 'was added'))
1130
+ */
1131
+ var FSWatcher = class extends EventEmitter {
1132
+ closed;
1133
+ options;
1134
+ _closers;
1135
+ _ignoredPaths;
1136
+ _throttled;
1137
+ _streams;
1138
+ _symlinkPaths;
1139
+ _watched;
1140
+ _pendingWrites;
1141
+ _pendingUnlinks;
1142
+ _readyCount;
1143
+ _emitReady;
1144
+ _closePromise;
1145
+ _userIgnored;
1146
+ _readyEmitted;
1147
+ _emitRaw;
1148
+ _boundRemove;
1149
+ _nodeFsHandler;
1150
+ constructor(_opts = {}) {
1151
+ super();
1152
+ this.closed = false;
1153
+ this._closers = /* @__PURE__ */ new Map();
1154
+ this._ignoredPaths = /* @__PURE__ */ new Set();
1155
+ this._throttled = /* @__PURE__ */ new Map();
1156
+ this._streams = /* @__PURE__ */ new Set();
1157
+ this._symlinkPaths = /* @__PURE__ */ new Map();
1158
+ this._watched = /* @__PURE__ */ new Map();
1159
+ this._pendingWrites = /* @__PURE__ */ new Map();
1160
+ this._pendingUnlinks = /* @__PURE__ */ new Map();
1161
+ this._readyCount = 0;
1162
+ this._readyEmitted = false;
1163
+ const awf = _opts.awaitWriteFinish;
1164
+ const DEF_AWF = {
1165
+ stabilityThreshold: 2e3,
1166
+ pollInterval: 100
1167
+ };
1168
+ const opts = {
1169
+ persistent: true,
1170
+ ignoreInitial: false,
1171
+ ignorePermissionErrors: false,
1172
+ interval: 100,
1173
+ binaryInterval: 300,
1174
+ followSymlinks: true,
1175
+ usePolling: false,
1176
+ atomic: true,
1177
+ ..._opts,
1178
+ ignored: _opts.ignored ? arrify(_opts.ignored) : arrify([]),
1179
+ awaitWriteFinish: awf === true ? DEF_AWF : typeof awf === "object" ? {
1180
+ ...DEF_AWF,
1181
+ ...awf
1182
+ } : false
1183
+ };
1184
+ if (isIBMi) opts.usePolling = true;
1185
+ if (opts.atomic === void 0) opts.atomic = !opts.usePolling;
1186
+ const envPoll = process.env.CHOKIDAR_USEPOLLING;
1187
+ if (envPoll !== void 0) {
1188
+ const envLower = envPoll.toLowerCase();
1189
+ if (envLower === "false" || envLower === "0") opts.usePolling = false;
1190
+ else if (envLower === "true" || envLower === "1") opts.usePolling = true;
1191
+ else opts.usePolling = !!envLower;
1192
+ }
1193
+ const envInterval = process.env.CHOKIDAR_INTERVAL;
1194
+ if (envInterval) opts.interval = Number.parseInt(envInterval, 10);
1195
+ let readyCalls = 0;
1196
+ this._emitReady = () => {
1197
+ readyCalls++;
1198
+ if (readyCalls >= this._readyCount) {
1199
+ this._emitReady = EMPTY_FN;
1200
+ this._readyEmitted = true;
1201
+ process.nextTick(() => this.emit(EVENTS.READY));
1202
+ }
1203
+ };
1204
+ this._emitRaw = (...args) => this.emit(EVENTS.RAW, ...args);
1205
+ this._boundRemove = this._remove.bind(this);
1206
+ this.options = opts;
1207
+ this._nodeFsHandler = new NodeFsHandler(this);
1208
+ Object.freeze(opts);
1209
+ }
1210
+ _addIgnoredPath(matcher) {
1211
+ if (isMatcherObject(matcher)) {
1212
+ for (const ignored of this._ignoredPaths) if (isMatcherObject(ignored) && ignored.path === matcher.path && ignored.recursive === matcher.recursive) return;
1213
+ }
1214
+ this._ignoredPaths.add(matcher);
1215
+ }
1216
+ _removeIgnoredPath(matcher) {
1217
+ this._ignoredPaths.delete(matcher);
1218
+ if (typeof matcher === "string") {
1219
+ for (const ignored of this._ignoredPaths) if (isMatcherObject(ignored) && ignored.path === matcher) this._ignoredPaths.delete(ignored);
1220
+ }
1221
+ }
1222
+ /**
1223
+ * Adds paths to be watched on an existing FSWatcher instance.
1224
+ * @param paths_ file or file list. Other arguments are unused
1225
+ */
1226
+ add(paths_, _origAdd, _internal) {
1227
+ const { cwd } = this.options;
1228
+ this.closed = false;
1229
+ this._closePromise = void 0;
1230
+ let paths = unifyPaths(paths_);
1231
+ if (cwd) paths = paths.map((path) => {
1232
+ return getAbsolutePath(path, cwd);
1233
+ });
1234
+ paths.forEach((path) => {
1235
+ this._removeIgnoredPath(path);
1236
+ });
1237
+ this._userIgnored = void 0;
1238
+ if (!this._readyCount) this._readyCount = 0;
1239
+ this._readyCount += paths.length;
1240
+ Promise.all(paths.map(async (path) => {
1241
+ const res = await this._nodeFsHandler._addToNodeFs(path, !_internal, void 0, 0, _origAdd);
1242
+ if (res) this._emitReady();
1243
+ return res;
1244
+ })).then((results) => {
1245
+ if (this.closed) return;
1246
+ results.forEach((item) => {
1247
+ if (item) this.add(sp.dirname(item), sp.basename(_origAdd || item));
1248
+ });
1249
+ });
1250
+ return this;
1251
+ }
1252
+ /**
1253
+ * Close watchers or start ignoring events from specified paths.
1254
+ */
1255
+ unwatch(paths_) {
1256
+ if (this.closed) return this;
1257
+ const paths = unifyPaths(paths_);
1258
+ const { cwd } = this.options;
1259
+ paths.forEach((path) => {
1260
+ if (!sp.isAbsolute(path) && !this._closers.has(path)) {
1261
+ if (cwd) path = sp.join(cwd, path);
1262
+ path = sp.resolve(path);
1263
+ }
1264
+ this._closePath(path);
1265
+ this._addIgnoredPath(path);
1266
+ if (this._watched.has(path)) this._addIgnoredPath({
1267
+ path,
1268
+ recursive: true
1269
+ });
1270
+ this._userIgnored = void 0;
1271
+ });
1272
+ return this;
1273
+ }
1274
+ /**
1275
+ * Close watchers and remove all listeners from watched paths.
1276
+ */
1277
+ close() {
1278
+ if (this._closePromise) return this._closePromise;
1279
+ this.closed = true;
1280
+ this.removeAllListeners();
1281
+ const closers = [];
1282
+ this._closers.forEach((closerList) => closerList.forEach((closer) => {
1283
+ const promise = closer();
1284
+ if (promise instanceof Promise) closers.push(promise);
1285
+ }));
1286
+ this._streams.forEach((stream) => stream.destroy());
1287
+ this._userIgnored = void 0;
1288
+ this._readyCount = 0;
1289
+ this._readyEmitted = false;
1290
+ this._watched.forEach((dirent) => dirent.dispose());
1291
+ this._closers.clear();
1292
+ this._watched.clear();
1293
+ this._streams.clear();
1294
+ this._symlinkPaths.clear();
1295
+ this._throttled.clear();
1296
+ this._closePromise = closers.length ? Promise.all(closers).then(() => void 0) : Promise.resolve();
1297
+ return this._closePromise;
1298
+ }
1299
+ /**
1300
+ * Expose list of watched paths
1301
+ * @returns for chaining
1302
+ */
1303
+ getWatched() {
1304
+ const watchList = {};
1305
+ this._watched.forEach((entry, dir) => {
1306
+ const index = (this.options.cwd ? sp.relative(this.options.cwd, dir) : dir) || ONE_DOT;
1307
+ watchList[index] = entry.getChildren().sort();
1308
+ });
1309
+ return watchList;
1310
+ }
1311
+ emitWithAll(event, args) {
1312
+ this.emit(event, ...args);
1313
+ if (event !== EVENTS.ERROR) this.emit(EVENTS.ALL, event, ...args);
1314
+ }
1315
+ /**
1316
+ * Normalize and emit events.
1317
+ * Calling _emit DOES NOT MEAN emit() would be called!
1318
+ * @param event Type of event
1319
+ * @param path File or directory path
1320
+ * @param stats arguments to be passed with event
1321
+ * @returns the error if defined, otherwise the value of the FSWatcher instance's `closed` flag
1322
+ */
1323
+ async _emit(event, path, stats) {
1324
+ if (this.closed) return;
1325
+ const opts = this.options;
1326
+ if (isWindows) path = sp.normalize(path);
1327
+ if (opts.cwd) path = sp.relative(opts.cwd, path);
1328
+ const args = [path];
1329
+ if (stats != null) args.push(stats);
1330
+ const awf = opts.awaitWriteFinish;
1331
+ let pw;
1332
+ if (awf && (pw = this._pendingWrites.get(path))) {
1333
+ pw.lastChange = /* @__PURE__ */ new Date();
1334
+ return this;
1335
+ }
1336
+ if (opts.atomic) {
1337
+ if (event === EVENTS.UNLINK) {
1338
+ this._pendingUnlinks.set(path, [event, ...args]);
1339
+ setTimeout(() => {
1340
+ this._pendingUnlinks.forEach((entry, path) => {
1341
+ this.emit(...entry);
1342
+ this.emit(EVENTS.ALL, ...entry);
1343
+ this._pendingUnlinks.delete(path);
1344
+ });
1345
+ }, typeof opts.atomic === "number" ? opts.atomic : 100);
1346
+ return this;
1347
+ }
1348
+ if (event === EVENTS.ADD && this._pendingUnlinks.has(path)) {
1349
+ event = EVENTS.CHANGE;
1350
+ this._pendingUnlinks.delete(path);
1351
+ }
1352
+ }
1353
+ if (awf && (event === EVENTS.ADD || event === EVENTS.CHANGE) && this._readyEmitted) {
1354
+ const awfEmit = (err, stats) => {
1355
+ if (err) {
1356
+ event = EVENTS.ERROR;
1357
+ args[0] = err;
1358
+ this.emitWithAll(event, args);
1359
+ } else if (stats) {
1360
+ if (args.length > 1) args[1] = stats;
1361
+ else args.push(stats);
1362
+ this.emitWithAll(event, args);
1363
+ }
1364
+ };
1365
+ this._awaitWriteFinish(path, awf.stabilityThreshold, event, awfEmit);
1366
+ return this;
1367
+ }
1368
+ if (event === EVENTS.CHANGE) {
1369
+ if (!this._throttle(EVENTS.CHANGE, path, 50)) return this;
1370
+ }
1371
+ if (opts.alwaysStat && stats === void 0 && (event === EVENTS.ADD || event === EVENTS.ADD_DIR || event === EVENTS.CHANGE)) {
1372
+ const fullPath = opts.cwd ? sp.join(opts.cwd, path) : path;
1373
+ let stats;
1374
+ try {
1375
+ stats = await stat$1(fullPath);
1376
+ } catch (err) {}
1377
+ if (!stats || this.closed) return;
1378
+ args.push(stats);
1379
+ }
1380
+ this.emitWithAll(event, args);
1381
+ return this;
1382
+ }
1383
+ /**
1384
+ * Common handler for errors
1385
+ * @returns The error if defined, otherwise the value of the FSWatcher instance's `closed` flag
1386
+ */
1387
+ _handleError(error) {
1388
+ const code = error && error.code;
1389
+ if (error && code !== "ENOENT" && code !== "ENOTDIR" && (!this.options.ignorePermissionErrors || code !== "EPERM" && code !== "EACCES")) this.emit(EVENTS.ERROR, error);
1390
+ return error || this.closed;
1391
+ }
1392
+ /**
1393
+ * Helper utility for throttling
1394
+ * @param actionType type being throttled
1395
+ * @param path being acted upon
1396
+ * @param timeout duration of time to suppress duplicate actions
1397
+ * @returns tracking object or false if action should be suppressed
1398
+ */
1399
+ _throttle(actionType, path, timeout) {
1400
+ if (!this._throttled.has(actionType)) this._throttled.set(actionType, /* @__PURE__ */ new Map());
1401
+ const action = this._throttled.get(actionType);
1402
+ if (!action) throw new Error("invalid throttle");
1403
+ const actionPath = action.get(path);
1404
+ if (actionPath) {
1405
+ actionPath.count++;
1406
+ return false;
1407
+ }
1408
+ let timeoutObject;
1409
+ const clear = () => {
1410
+ const item = action.get(path);
1411
+ const count = item ? item.count : 0;
1412
+ action.delete(path);
1413
+ clearTimeout(timeoutObject);
1414
+ if (item) clearTimeout(item.timeoutObject);
1415
+ return count;
1416
+ };
1417
+ timeoutObject = setTimeout(clear, timeout);
1418
+ const thr = {
1419
+ timeoutObject,
1420
+ clear,
1421
+ count: 0
1422
+ };
1423
+ action.set(path, thr);
1424
+ return thr;
1425
+ }
1426
+ _incrReadyCount() {
1427
+ return this._readyCount++;
1428
+ }
1429
+ /**
1430
+ * Awaits write operation to finish.
1431
+ * Polls a newly created file for size variations. When files size does not change for 'threshold' milliseconds calls callback.
1432
+ * @param path being acted upon
1433
+ * @param threshold Time in milliseconds a file size must be fixed before acknowledging write OP is finished
1434
+ * @param event
1435
+ * @param awfEmit Callback to be called when ready for event to be emitted.
1436
+ */
1437
+ _awaitWriteFinish(path, threshold, event, awfEmit) {
1438
+ const awf = this.options.awaitWriteFinish;
1439
+ if (typeof awf !== "object") return;
1440
+ const pollInterval = awf.pollInterval;
1441
+ let timeoutHandler;
1442
+ let fullPath = path;
1443
+ if (this.options.cwd && !sp.isAbsolute(path)) fullPath = sp.join(this.options.cwd, path);
1444
+ const now = /* @__PURE__ */ new Date();
1445
+ const writes = this._pendingWrites;
1446
+ function awaitWriteFinishFn(prevStat) {
1447
+ stat(fullPath, (err, curStat) => {
1448
+ if (err || !writes.has(path)) {
1449
+ if (err && err.code !== "ENOENT") awfEmit(err);
1450
+ return;
1451
+ }
1452
+ const now = Number(/* @__PURE__ */ new Date());
1453
+ if (prevStat && curStat.size !== prevStat.size) writes.get(path).lastChange = now;
1454
+ if (now - writes.get(path).lastChange >= threshold) {
1455
+ writes.delete(path);
1456
+ awfEmit(void 0, curStat);
1457
+ } else timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval, curStat);
1458
+ });
1459
+ }
1460
+ if (!writes.has(path)) {
1461
+ writes.set(path, {
1462
+ lastChange: now,
1463
+ cancelWait: () => {
1464
+ writes.delete(path);
1465
+ clearTimeout(timeoutHandler);
1466
+ return event;
1467
+ }
1468
+ });
1469
+ timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval);
1470
+ }
1471
+ }
1472
+ /**
1473
+ * Determines whether user has asked to ignore this path.
1474
+ */
1475
+ _isIgnored(path, stats) {
1476
+ if (this.options.atomic && DOT_RE.test(path)) return true;
1477
+ if (!this._userIgnored) {
1478
+ const { cwd } = this.options;
1479
+ const ignored = (this.options.ignored || []).map(normalizeIgnored(cwd));
1480
+ this._userIgnored = anymatch([...[...this._ignoredPaths].map(normalizeIgnored(cwd)), ...ignored], void 0);
1481
+ }
1482
+ return this._userIgnored(path, stats);
1483
+ }
1484
+ _isntIgnored(path, stat) {
1485
+ return !this._isIgnored(path, stat);
1486
+ }
1487
+ /**
1488
+ * Provides a set of common helpers and properties relating to symlink handling.
1489
+ * @param path file or directory pattern being watched
1490
+ */
1491
+ _getWatchHelpers(path) {
1492
+ return new WatchHelper(path, this.options.followSymlinks, this);
1493
+ }
1494
+ /**
1495
+ * Provides directory tracking objects
1496
+ * @param directory path of the directory
1497
+ */
1498
+ _getWatchedDir(directory) {
1499
+ const dir = sp.resolve(directory);
1500
+ if (!this._watched.has(dir)) this._watched.set(dir, new DirEntry(dir, this._boundRemove));
1501
+ return this._watched.get(dir);
1502
+ }
1503
+ /**
1504
+ * Check for read permissions: https://stackoverflow.com/a/11781404/1358405
1505
+ */
1506
+ _hasReadPermissions(stats) {
1507
+ if (this.options.ignorePermissionErrors) return true;
1508
+ return Boolean(Number(stats.mode) & 256);
1509
+ }
1510
+ /**
1511
+ * Handles emitting unlink events for
1512
+ * files and directories, and via recursion, for
1513
+ * files and directories within directories that are unlinked
1514
+ * @param directory within which the following item is located
1515
+ * @param item base path of item/directory
1516
+ */
1517
+ _remove(directory, item, isDirectory) {
1518
+ const path = sp.join(directory, item);
1519
+ const fullPath = sp.resolve(path);
1520
+ isDirectory = isDirectory != null ? isDirectory : this._watched.has(path) || this._watched.has(fullPath);
1521
+ if (!this._throttle("remove", path, 100)) return;
1522
+ if (!isDirectory && this._watched.size === 1) this.add(directory, item, true);
1523
+ this._getWatchedDir(path).getChildren().forEach((nested) => this._remove(path, nested));
1524
+ const parent = this._getWatchedDir(directory);
1525
+ const wasTracked = parent.has(item);
1526
+ parent.remove(item);
1527
+ if (this._symlinkPaths.has(fullPath)) this._symlinkPaths.delete(fullPath);
1528
+ let relPath = path;
1529
+ if (this.options.cwd) relPath = sp.relative(this.options.cwd, path);
1530
+ if (this.options.awaitWriteFinish && this._pendingWrites.has(relPath)) {
1531
+ if (this._pendingWrites.get(relPath).cancelWait() === EVENTS.ADD) return;
1532
+ }
1533
+ this._watched.delete(path);
1534
+ this._watched.delete(fullPath);
1535
+ const eventName = isDirectory ? EVENTS.UNLINK_DIR : EVENTS.UNLINK;
1536
+ if (wasTracked && !this._isIgnored(path)) this._emit(eventName, path);
1537
+ this._closePath(path);
1538
+ }
1539
+ /**
1540
+ * Closes all watchers for a path
1541
+ */
1542
+ _closePath(path) {
1543
+ this._closeFile(path);
1544
+ const dir = sp.dirname(path);
1545
+ this._getWatchedDir(dir).remove(sp.basename(path));
1546
+ }
1547
+ /**
1548
+ * Closes only file-specific watchers
1549
+ */
1550
+ _closeFile(path) {
1551
+ const closers = this._closers.get(path);
1552
+ if (!closers) return;
1553
+ closers.forEach((closer) => closer());
1554
+ this._closers.delete(path);
1555
+ }
1556
+ _addPathCloser(path, closer) {
1557
+ if (!closer) return;
1558
+ let list = this._closers.get(path);
1559
+ if (!list) {
1560
+ list = [];
1561
+ this._closers.set(path, list);
1562
+ }
1563
+ list.push(closer);
1564
+ }
1565
+ _readdirp(root, opts) {
1566
+ if (this.closed) return;
1567
+ let stream = readdirp(root, {
1568
+ type: EVENTS.ALL,
1569
+ alwaysStat: true,
1570
+ lstat: true,
1571
+ ...opts,
1572
+ depth: 0
1573
+ });
1574
+ this._streams.add(stream);
1575
+ stream.once(STR_CLOSE, () => {
1576
+ stream = void 0;
1577
+ });
1578
+ stream.once("end", () => {
1579
+ if (stream) {
1580
+ this._streams.delete(stream);
1581
+ stream = void 0;
1582
+ }
1583
+ });
1584
+ return stream;
1585
+ }
1586
+ };
1587
+ /**
1588
+ * Instantiates watcher with paths to be tracked.
1589
+ * @param paths file / directory paths
1590
+ * @param options opts, such as `atomic`, `awaitWriteFinish`, `ignored`, and others
1591
+ * @returns an instance of FSWatcher for chaining.
1592
+ * @example
1593
+ * const watcher = watch('.').on('all', (event, path) => { console.log(event, path); });
1594
+ * watch('.', { atomic: true, awaitWriteFinish: true, ignored: (f, stats) => stats?.isFile() && !f.endsWith('.js') })
1595
+ */
1596
+ function watch$1(paths, options = {}) {
1597
+ const watcher = new FSWatcher(options);
1598
+ watcher.add(paths);
1599
+ return watcher;
1600
+ }
1601
+ var chokidar_default = {
1602
+ watch: watch$1,
1603
+ FSWatcher
1604
+ };
1605
+ //#endregion
1606
+ export { watch$1 as n, chokidar_exports as t };