@nimbus-sh/worker 0.1.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 (408) hide show
  1. package/README.md +219 -0
  2. package/dist/_shared/bytes.d.ts +18 -0
  3. package/dist/_shared/bytes.d.ts.map +1 -0
  4. package/dist/_shared/bytes.js +17 -0
  5. package/dist/_shared/cache-stats.d.ts +146 -0
  6. package/dist/_shared/cache-stats.d.ts.map +1 -0
  7. package/dist/_shared/cache-stats.js +162 -0
  8. package/dist/_shared/exports-resolver.d.ts +76 -0
  9. package/dist/_shared/exports-resolver.d.ts.map +1 -0
  10. package/dist/_shared/exports-resolver.js +284 -0
  11. package/dist/_shared/install-phase.d.ts +47 -0
  12. package/dist/_shared/install-phase.d.ts.map +1 -0
  13. package/dist/_shared/install-phase.js +1 -0
  14. package/dist/_shared/real-node-imports.d.ts +38 -0
  15. package/dist/_shared/real-node-imports.d.ts.map +1 -0
  16. package/dist/_shared/real-node-imports.js +46 -0
  17. package/dist/_shared/retry.d.ts +93 -0
  18. package/dist/_shared/retry.d.ts.map +1 -0
  19. package/dist/_shared/retry.js +161 -0
  20. package/dist/_shared/session-id.d.ts +39 -0
  21. package/dist/_shared/session-id.d.ts.map +1 -0
  22. package/dist/_shared/session-id.js +127 -0
  23. package/dist/_shared/session-router.d.ts +104 -0
  24. package/dist/_shared/session-router.d.ts.map +1 -0
  25. package/dist/_shared/session-router.js +165 -0
  26. package/dist/_shared/w7-frame.d.ts +93 -0
  27. package/dist/_shared/w7-frame.d.ts.map +1 -0
  28. package/dist/_shared/w7-frame.js +402 -0
  29. package/dist/auth/index.d.ts +16 -0
  30. package/dist/auth/index.d.ts.map +1 -0
  31. package/dist/auth/index.js +15 -0
  32. package/dist/auth/middleware.d.ts +85 -0
  33. package/dist/auth/middleware.d.ts.map +1 -0
  34. package/dist/auth/middleware.js +150 -0
  35. package/dist/auth/token.d.ts +96 -0
  36. package/dist/auth/token.d.ts.map +1 -0
  37. package/dist/auth/token.js +226 -0
  38. package/dist/auth/types.d.ts +141 -0
  39. package/dist/auth/types.d.ts.map +1 -0
  40. package/dist/auth/types.js +114 -0
  41. package/dist/bindings/d1.d.ts +102 -0
  42. package/dist/bindings/d1.d.ts.map +1 -0
  43. package/dist/bindings/d1.js +549 -0
  44. package/dist/bindings/kv.d.ts +82 -0
  45. package/dist/bindings/kv.d.ts.map +1 -0
  46. package/dist/bindings/kv.js +290 -0
  47. package/dist/bindings/r2.d.ts +137 -0
  48. package/dist/bindings/r2.d.ts.map +1 -0
  49. package/dist/bindings/r2.js +379 -0
  50. package/dist/cirrus-npm-cjs.generated.d.ts +17 -0
  51. package/dist/cirrus-npm-cjs.generated.d.ts.map +1 -0
  52. package/dist/cirrus-npm-cjs.generated.js +41 -0
  53. package/dist/cirrus-plugin-react.generated.d.ts +34 -0
  54. package/dist/cirrus-plugin-react.generated.d.ts.map +1 -0
  55. package/dist/cirrus-plugin-react.generated.js +33 -0
  56. package/dist/constants.d.ts +34 -0
  57. package/dist/constants.d.ts.map +1 -0
  58. package/dist/constants.js +116 -0
  59. package/dist/esbuild-wasm-bundle.generated.d.ts +41 -0
  60. package/dist/esbuild-wasm-bundle.generated.d.ts.map +1 -0
  61. package/dist/esbuild-wasm-bundle.generated.js +40 -0
  62. package/dist/facets/cirrus-real.d.ts +147 -0
  63. package/dist/facets/cirrus-real.d.ts.map +1 -0
  64. package/dist/facets/cirrus-real.js +981 -0
  65. package/dist/facets/inner-do-registry.d.ts +41 -0
  66. package/dist/facets/inner-do-registry.d.ts.map +1 -0
  67. package/dist/facets/inner-do-registry.js +51 -0
  68. package/dist/facets/manager.d.ts +314 -0
  69. package/dist/facets/manager.d.ts.map +1 -0
  70. package/dist/facets/manager.js +2681 -0
  71. package/dist/facets/process.d.ts +318 -0
  72. package/dist/facets/process.d.ts.map +1 -0
  73. package/dist/facets/process.js +567 -0
  74. package/dist/facets/real-vite-fs-shim.d.ts +151 -0
  75. package/dist/facets/real-vite-fs-shim.d.ts.map +1 -0
  76. package/dist/facets/real-vite-fs-shim.js +1279 -0
  77. package/dist/facets/real-vite-hmr.d.ts +142 -0
  78. package/dist/facets/real-vite-hmr.d.ts.map +1 -0
  79. package/dist/facets/real-vite-hmr.js +476 -0
  80. package/dist/facets/vite-dev-server.d.ts +293 -0
  81. package/dist/facets/vite-dev-server.d.ts.map +1 -0
  82. package/dist/facets/vite-dev-server.js +2580 -0
  83. package/dist/facets/wasm-swap-registry.d.ts +261 -0
  84. package/dist/facets/wasm-swap-registry.d.ts.map +1 -0
  85. package/dist/facets/wasm-swap-registry.js +551 -0
  86. package/dist/facets/ws-terminal.d.ts +107 -0
  87. package/dist/facets/ws-terminal.d.ts.map +1 -0
  88. package/dist/facets/ws-terminal.js +207 -0
  89. package/dist/git/commands.d.ts +13 -0
  90. package/dist/git/commands.d.ts.map +1 -0
  91. package/dist/git/commands.js +633 -0
  92. package/dist/git/network-facet.d.ts +61 -0
  93. package/dist/git/network-facet.d.ts.map +1 -0
  94. package/dist/git/network-facet.js +700 -0
  95. package/dist/git-bundle.generated.d.ts +16 -0
  96. package/dist/git-bundle.generated.d.ts.map +1 -0
  97. package/dist/git-bundle.generated.js +15 -0
  98. package/dist/index.d.ts +41 -0
  99. package/dist/index.d.ts.map +1 -0
  100. package/dist/index.js +73 -0
  101. package/dist/loaders/child-process/spawn-facet.d.ts +90 -0
  102. package/dist/loaders/child-process/spawn-facet.d.ts.map +1 -0
  103. package/dist/loaders/child-process/spawn-facet.js +103 -0
  104. package/dist/loaders/child-process/spawn-pool.d.ts +110 -0
  105. package/dist/loaders/child-process/spawn-pool.d.ts.map +1 -0
  106. package/dist/loaders/child-process/spawn-pool.js +161 -0
  107. package/dist/loaders/fanout-pool.d.ts +195 -0
  108. package/dist/loaders/fanout-pool.d.ts.map +1 -0
  109. package/dist/loaders/fanout-pool.js +326 -0
  110. package/dist/loaders/generated-workers.d.ts +26 -0
  111. package/dist/loaders/generated-workers.d.ts.map +1 -0
  112. package/dist/loaders/generated-workers.js +25 -0
  113. package/dist/loaders/index.d.ts +15 -0
  114. package/dist/loaders/index.d.ts.map +1 -0
  115. package/dist/loaders/index.js +13 -0
  116. package/dist/loaders/loader-pool.d.ts +273 -0
  117. package/dist/loaders/loader-pool.d.ts.map +1 -0
  118. package/dist/loaders/loader-pool.js +624 -0
  119. package/dist/loaders/npm-resolve-preamble.d.ts +34 -0
  120. package/dist/loaders/npm-resolve-preamble.d.ts.map +1 -0
  121. package/dist/loaders/npm-resolve-preamble.js +237 -0
  122. package/dist/loaders/pre-bundle-preamble.d.ts +41 -0
  123. package/dist/loaders/pre-bundle-preamble.d.ts.map +1 -0
  124. package/dist/loaders/pre-bundle-preamble.js +114 -0
  125. package/dist/loaders/vendor/codegen.d.ts +24 -0
  126. package/dist/loaders/vendor/codegen.d.ts.map +1 -0
  127. package/dist/loaders/vendor/codegen.js +44 -0
  128. package/dist/loaders/vendor/errors.d.ts +24 -0
  129. package/dist/loaders/vendor/errors.d.ts.map +1 -0
  130. package/dist/loaders/vendor/errors.js +46 -0
  131. package/dist/loaders/vendor/index.d.ts +16 -0
  132. package/dist/loaders/vendor/index.d.ts.map +1 -0
  133. package/dist/loaders/vendor/index.js +11 -0
  134. package/dist/loaders/vendor/pool.d.ts +88 -0
  135. package/dist/loaders/vendor/pool.d.ts.map +1 -0
  136. package/dist/loaders/vendor/pool.js +353 -0
  137. package/dist/loaders/vendor/primitives.d.ts +11 -0
  138. package/dist/loaders/vendor/primitives.d.ts.map +1 -0
  139. package/dist/loaders/vendor/primitives.js +33 -0
  140. package/dist/loaders/vendor/serialize.d.ts +3 -0
  141. package/dist/loaders/vendor/serialize.d.ts.map +1 -0
  142. package/dist/loaders/vendor/serialize.js +25 -0
  143. package/dist/loaders/vendor/types.d.ts +60 -0
  144. package/dist/loaders/vendor/types.d.ts.map +1 -0
  145. package/dist/loaders/vendor/types.js +4 -0
  146. package/dist/npm/cache.d.ts +136 -0
  147. package/dist/npm/cache.d.ts.map +1 -0
  148. package/dist/npm/cache.js +429 -0
  149. package/dist/npm/install-batch-facet.d.ts +129 -0
  150. package/dist/npm/install-batch-facet.d.ts.map +1 -0
  151. package/dist/npm/install-batch-facet.js +598 -0
  152. package/dist/npm/install-facet.d.ts +29 -0
  153. package/dist/npm/install-facet.d.ts.map +1 -0
  154. package/dist/npm/install-facet.js +9 -0
  155. package/dist/npm/installer.d.ts +239 -0
  156. package/dist/npm/installer.d.ts.map +1 -0
  157. package/dist/npm/installer.js +2022 -0
  158. package/dist/npm/npx-install.d.ts +74 -0
  159. package/dist/npm/npx-install.d.ts.map +1 -0
  160. package/dist/npm/npx-install.js +302 -0
  161. package/dist/npm/pre-bundle-facet.d.ts +168 -0
  162. package/dist/npm/pre-bundle-facet.d.ts.map +1 -0
  163. package/dist/npm/pre-bundle-facet.js +653 -0
  164. package/dist/npm/r2-cache.d.ts +286 -0
  165. package/dist/npm/r2-cache.d.ts.map +1 -0
  166. package/dist/npm/r2-cache.js +506 -0
  167. package/dist/npm/resolve-facet.d.ts +202 -0
  168. package/dist/npm/resolve-facet.d.ts.map +1 -0
  169. package/dist/npm/resolve-facet.js +833 -0
  170. package/dist/npm/resolve-one-facet.d.ts +204 -0
  171. package/dist/npm/resolve-one-facet.d.ts.map +1 -0
  172. package/dist/npm/resolve-one-facet.js +437 -0
  173. package/dist/npm/resolver.d.ts +109 -0
  174. package/dist/npm/resolver.d.ts.map +1 -0
  175. package/dist/npm/resolver.js +899 -0
  176. package/dist/npm/tarball-stream.d.ts +85 -0
  177. package/dist/npm/tarball-stream.d.ts.map +1 -0
  178. package/dist/npm/tarball-stream.js +205 -0
  179. package/dist/npm/tarball.d.ts +51 -0
  180. package/dist/npm/tarball.d.ts.map +1 -0
  181. package/dist/npm/tarball.js +185 -0
  182. package/dist/observability/diag-counters.d.ts +292 -0
  183. package/dist/observability/diag-counters.d.ts.map +1 -0
  184. package/dist/observability/diag-counters.js +302 -0
  185. package/dist/observability/heap-estimate.d.ts +166 -0
  186. package/dist/observability/heap-estimate.d.ts.map +1 -0
  187. package/dist/observability/heap-estimate.js +192 -0
  188. package/dist/observability/heavy-alloc-coord.d.ts +95 -0
  189. package/dist/observability/heavy-alloc-coord.d.ts.map +1 -0
  190. package/dist/observability/heavy-alloc-coord.js +149 -0
  191. package/dist/observability/oom-classify.d.ts +56 -0
  192. package/dist/observability/oom-classify.d.ts.map +1 -0
  193. package/dist/observability/oom-classify.js +118 -0
  194. package/dist/observability/oom-discriminator.d.ts +192 -0
  195. package/dist/observability/oom-discriminator.d.ts.map +1 -0
  196. package/dist/observability/oom-discriminator.js +233 -0
  197. package/dist/real-vite-bundle.generated.d.ts +46 -0
  198. package/dist/real-vite-bundle.generated.d.ts.map +1 -0
  199. package/dist/real-vite-bundle.generated.js +53 -0
  200. package/dist/replica/routing.d.ts +171 -0
  201. package/dist/replica/routing.d.ts.map +1 -0
  202. package/dist/replica/routing.js +288 -0
  203. package/dist/replica/suspension.d.ts +36 -0
  204. package/dist/replica/suspension.d.ts.map +1 -0
  205. package/dist/replica/suspension.js +49 -0
  206. package/dist/router/index.d.ts +156 -0
  207. package/dist/router/index.d.ts.map +1 -0
  208. package/dist/router/index.js +220 -0
  209. package/dist/runtime/assets-loader.d.ts +71 -0
  210. package/dist/runtime/assets-loader.d.ts.map +1 -0
  211. package/dist/runtime/assets-loader.js +128 -0
  212. package/dist/runtime/barrel-detect.d.ts +46 -0
  213. package/dist/runtime/barrel-detect.d.ts.map +1 -0
  214. package/dist/runtime/barrel-detect.js +73 -0
  215. package/dist/runtime/barrel-synthesizer.d.ts +181 -0
  216. package/dist/runtime/barrel-synthesizer.d.ts.map +1 -0
  217. package/dist/runtime/barrel-synthesizer.js +541 -0
  218. package/dist/runtime/bun-repl.d.ts +46 -0
  219. package/dist/runtime/bun-repl.d.ts.map +1 -0
  220. package/dist/runtime/bun-repl.js +326 -0
  221. package/dist/runtime/bun-runner.d.ts +66 -0
  222. package/dist/runtime/bun-runner.d.ts.map +1 -0
  223. package/dist/runtime/bun-runner.js +219 -0
  224. package/dist/runtime/clang-runner.d.ts +38 -0
  225. package/dist/runtime/clang-runner.d.ts.map +1 -0
  226. package/dist/runtime/clang-runner.js +1033 -0
  227. package/dist/runtime/comment-strip.d.ts +37 -0
  228. package/dist/runtime/comment-strip.d.ts.map +1 -0
  229. package/dist/runtime/comment-strip.js +74 -0
  230. package/dist/runtime/esbuild-service.d.ts +201 -0
  231. package/dist/runtime/esbuild-service.d.ts.map +1 -0
  232. package/dist/runtime/esbuild-service.js +1444 -0
  233. package/dist/runtime/esbuild-wasm-bytes.d.ts +87 -0
  234. package/dist/runtime/esbuild-wasm-bytes.d.ts.map +1 -0
  235. package/dist/runtime/esbuild-wasm-bytes.js +131 -0
  236. package/dist/runtime/framework-detect.d.ts +71 -0
  237. package/dist/runtime/framework-detect.d.ts.map +1 -0
  238. package/dist/runtime/framework-detect.js +178 -0
  239. package/dist/runtime/long-running-handle.d.ts +133 -0
  240. package/dist/runtime/long-running-handle.d.ts.map +1 -0
  241. package/dist/runtime/long-running-handle.js +192 -0
  242. package/dist/runtime/node-repl.d.ts +36 -0
  243. package/dist/runtime/node-repl.d.ts.map +1 -0
  244. package/dist/runtime/node-repl.js +293 -0
  245. package/dist/runtime/node-runner.d.ts +111 -0
  246. package/dist/runtime/node-runner.d.ts.map +1 -0
  247. package/dist/runtime/node-runner.js +194 -0
  248. package/dist/runtime/node-shims.d.ts +24 -0
  249. package/dist/runtime/node-shims.d.ts.map +1 -0
  250. package/dist/runtime/node-shims.js +3019 -0
  251. package/dist/runtime/package-manager.d.ts +118 -0
  252. package/dist/runtime/package-manager.d.ts.map +1 -0
  253. package/dist/runtime/package-manager.js +420 -0
  254. package/dist/runtime/port-registry.d.ts +80 -0
  255. package/dist/runtime/port-registry.d.ts.map +1 -0
  256. package/dist/runtime/port-registry.js +166 -0
  257. package/dist/runtime/process-logs-api.d.ts +102 -0
  258. package/dist/runtime/process-logs-api.d.ts.map +1 -0
  259. package/dist/runtime/process-logs-api.js +253 -0
  260. package/dist/runtime/process-logs.d.ts +311 -0
  261. package/dist/runtime/process-logs.d.ts.map +1 -0
  262. package/dist/runtime/process-logs.js +656 -0
  263. package/dist/runtime/process-table.d.ts +65 -0
  264. package/dist/runtime/process-table.d.ts.map +1 -0
  265. package/dist/runtime/process-table.js +107 -0
  266. package/dist/runtime/project-detect.d.ts +21 -0
  267. package/dist/runtime/project-detect.d.ts.map +1 -0
  268. package/dist/runtime/project-detect.js +46 -0
  269. package/dist/runtime/python-repl.d.ts +66 -0
  270. package/dist/runtime/python-repl.d.ts.map +1 -0
  271. package/dist/runtime/python-repl.js +563 -0
  272. package/dist/runtime/python-runner.d.ts +50 -0
  273. package/dist/runtime/python-runner.d.ts.map +1 -0
  274. package/dist/runtime/python-runner.js +870 -0
  275. package/dist/runtime/repl-session.d.ts +160 -0
  276. package/dist/runtime/repl-session.d.ts.map +1 -0
  277. package/dist/runtime/repl-session.js +393 -0
  278. package/dist/runtime/require-resolver.d.ts +52 -0
  279. package/dist/runtime/require-resolver.d.ts.map +1 -0
  280. package/dist/runtime/require-resolver.js +690 -0
  281. package/dist/runtime/router-basename.d.ts +36 -0
  282. package/dist/runtime/router-basename.d.ts.map +1 -0
  283. package/dist/runtime/router-basename.js +310 -0
  284. package/dist/runtime/ruby-repl.d.ts +43 -0
  285. package/dist/runtime/ruby-repl.d.ts.map +1 -0
  286. package/dist/runtime/ruby-repl.js +229 -0
  287. package/dist/runtime/ruby-runner.d.ts +62 -0
  288. package/dist/runtime/ruby-runner.d.ts.map +1 -0
  289. package/dist/runtime/ruby-runner.js +737 -0
  290. package/dist/runtime/runtime-catalog.d.ts +99 -0
  291. package/dist/runtime/runtime-catalog.d.ts.map +1 -0
  292. package/dist/runtime/runtime-catalog.js +183 -0
  293. package/dist/runtime/runtime-registry.d.ts +136 -0
  294. package/dist/runtime/runtime-registry.d.ts.map +1 -0
  295. package/dist/runtime/runtime-registry.js +318 -0
  296. package/dist/runtime/streams.d.ts +13 -0
  297. package/dist/runtime/streams.d.ts.map +1 -0
  298. package/dist/runtime/streams.js +402 -0
  299. package/dist/runtime/wasi-instance.d.ts +190 -0
  300. package/dist/runtime/wasi-instance.d.ts.map +1 -0
  301. package/dist/runtime/wasi-instance.js +2044 -0
  302. package/dist/runtime/wasm-runner.d.ts +117 -0
  303. package/dist/runtime/wasm-runner.d.ts.map +1 -0
  304. package/dist/runtime/wasm-runner.js +705 -0
  305. package/dist/session/bindings.d.ts +168 -0
  306. package/dist/session/bindings.d.ts.map +1 -0
  307. package/dist/session/bindings.js +524 -0
  308. package/dist/session/ctx-exports.d.ts +16 -0
  309. package/dist/session/ctx-exports.d.ts.map +1 -0
  310. package/dist/session/ctx-exports.js +22 -0
  311. package/dist/session/diag.d.ts +62 -0
  312. package/dist/session/diag.d.ts.map +1 -0
  313. package/dist/session/diag.js +118 -0
  314. package/dist/session/fs-watch.d.ts +132 -0
  315. package/dist/session/fs-watch.d.ts.map +1 -0
  316. package/dist/session/fs-watch.js +255 -0
  317. package/dist/session/helpers.d.ts +150 -0
  318. package/dist/session/helpers.d.ts.map +1 -0
  319. package/dist/session/helpers.js +472 -0
  320. package/dist/session/hibernation.d.ts +145 -0
  321. package/dist/session/hibernation.d.ts.map +1 -0
  322. package/dist/session/hibernation.js +385 -0
  323. package/dist/session/init-phases.d.ts +87 -0
  324. package/dist/session/init-phases.d.ts.map +1 -0
  325. package/dist/session/init-phases.js +137 -0
  326. package/dist/session/init.d.ts +46 -0
  327. package/dist/session/init.d.ts.map +1 -0
  328. package/dist/session/init.js +3579 -0
  329. package/dist/session/keys.d.ts +56 -0
  330. package/dist/session/keys.d.ts.map +1 -0
  331. package/dist/session/keys.js +55 -0
  332. package/dist/session/nimbus-session.d.ts +434 -0
  333. package/dist/session/nimbus-session.d.ts.map +1 -0
  334. package/dist/session/nimbus-session.js +1084 -0
  335. package/dist/session/programmatic.d.ts +105 -0
  336. package/dist/session/programmatic.d.ts.map +1 -0
  337. package/dist/session/programmatic.js +326 -0
  338. package/dist/session/replica-routes.d.ts +68 -0
  339. package/dist/session/replica-routes.d.ts.map +1 -0
  340. package/dist/session/replica-routes.js +77 -0
  341. package/dist/session/routes.d.ts +29 -0
  342. package/dist/session/routes.d.ts.map +1 -0
  343. package/dist/session/routes.js +1331 -0
  344. package/dist/session/rpc.d.ts +323 -0
  345. package/dist/session/rpc.d.ts.map +1 -0
  346. package/dist/session/rpc.js +808 -0
  347. package/dist/session/state-store.d.ts +210 -0
  348. package/dist/session/state-store.d.ts.map +1 -0
  349. package/dist/session/state-store.js +459 -0
  350. package/dist/session/supervisor-rpc.d.ts +269 -0
  351. package/dist/session/supervisor-rpc.d.ts.map +1 -0
  352. package/dist/session/supervisor-rpc.js +437 -0
  353. package/dist/session/ws-hibernation-config.d.ts +64 -0
  354. package/dist/session/ws-hibernation-config.d.ts.map +1 -0
  355. package/dist/session/ws-hibernation-config.js +89 -0
  356. package/dist/session/ws.d.ts +95 -0
  357. package/dist/session/ws.d.ts.map +1 -0
  358. package/dist/session/ws.js +395 -0
  359. package/dist/shell/features.d.ts +410 -0
  360. package/dist/shell/features.d.ts.map +1 -0
  361. package/dist/shell/features.js +1885 -0
  362. package/dist/shell/unix-commands.d.ts +15 -0
  363. package/dist/shell/unix-commands.d.ts.map +1 -0
  364. package/dist/shell/unix-commands.js +3703 -0
  365. package/dist/stubs/lifo-ui.d.ts +10 -0
  366. package/dist/stubs/lifo-ui.d.ts.map +1 -0
  367. package/dist/stubs/lifo-ui.js +1 -0
  368. package/dist/tailwind-play.generated.d.ts +19 -0
  369. package/dist/tailwind-play.generated.d.ts.map +1 -0
  370. package/dist/tailwind-play.generated.js +18 -0
  371. package/dist/vfs/dev-provider.d.ts +64 -0
  372. package/dist/vfs/dev-provider.d.ts.map +1 -0
  373. package/dist/vfs/dev-provider.js +191 -0
  374. package/dist/vfs/events.d.ts +51 -0
  375. package/dist/vfs/events.d.ts.map +1 -0
  376. package/dist/vfs/events.js +127 -0
  377. package/dist/vfs/path.d.ts +30 -0
  378. package/dist/vfs/path.d.ts.map +1 -0
  379. package/dist/vfs/path.js +41 -0
  380. package/dist/vfs/seed-project.d.ts +62 -0
  381. package/dist/vfs/seed-project.d.ts.map +1 -0
  382. package/dist/vfs/seed-project.js +1045 -0
  383. package/dist/vfs/sqlite-vfs.d.ts +435 -0
  384. package/dist/vfs/sqlite-vfs.d.ts.map +1 -0
  385. package/dist/vfs/sqlite-vfs.js +1670 -0
  386. package/dist/vfs/symlink-registry.d.ts +64 -0
  387. package/dist/vfs/symlink-registry.d.ts.map +1 -0
  388. package/dist/vfs/symlink-registry.js +137 -0
  389. package/dist/wrangler/nimbus-wrangler.d.ts +157 -0
  390. package/dist/wrangler/nimbus-wrangler.d.ts.map +1 -0
  391. package/dist/wrangler/nimbus-wrangler.js +931 -0
  392. package/package.json +77 -0
  393. package/public/_assets/cirrus-plugin-react.bundle.js +70740 -0
  394. package/public/_assets/esbuild-0.24.2.wasm +0 -0
  395. package/public/_assets/real-vite-bundle.js +101478 -0
  396. package/public/_assets/rollup.wasm +0 -0
  397. package/public/favicon.svg +8 -0
  398. package/public/index.html +565 -0
  399. package/public/s/index.html +2379 -0
  400. package/scripts/bundle-esbuild-wasm.mjs +244 -0
  401. package/scripts/bundle-facet-workers.mjs +137 -0
  402. package/scripts/bundle-git.mjs +118 -0
  403. package/scripts/bundle-npm-cjs.mjs +363 -0
  404. package/scripts/bundle-plugin-react.mjs +480 -0
  405. package/scripts/bundle-real-vite.mjs +959 -0
  406. package/scripts/bundle-runtime.mjs +600 -0
  407. package/scripts/bundle-tailwind-play.mjs +130 -0
  408. package/scripts/patch-lifo-ui.mjs +131 -0
@@ -0,0 +1,74 @@
1
+ /**
2
+ * npx-install.ts — Nimbus-native npx implementation.
3
+ *
4
+ * Replaces @lifo-sh/core's createNpxCommand (which uses a too-narrow
5
+ * semver-range detector that misses major-only ranges like `'1'`, `'2'`,
6
+ * `'1.0'`). The core's `ic()` regex `/[\^~>=<|*x]/.test(r)` flagged
7
+ * caret/tilde/comparator/x ranges correctly but treated `'1'` as a
8
+ * literal version → fetched `/wrappy/1` → 404 → silently skipped.
9
+ *
10
+ * Symptom captured by tests/behavioral/install/transitive-dep-resolution.mjs:
11
+ * `npx --yes rimraf@3.0.2 --help` →
12
+ * warn: could not install wrappy: Package 'wrappy@1' not found in registry
13
+ * warn: could not install inherits: Package 'inherits@2' not found in registry
14
+ * Cannot find module './' (from /tmp/.npx-cache/node_modules/rimraf)
15
+ *
16
+ * Fix: route the npx install step through Nimbus's NpmInstaller, which
17
+ * uses always-fetch-packument + RESOLVE_VERSION-style version-pick path
18
+ * (resolve-one-facet.ts:264 + RESOLVE_VERSION). Handles all semver-range
19
+ * syntax including major-only and major.minor.
20
+ *
21
+ * Binary-lookup and execution stay closer to the @lifo-sh/core flow:
22
+ * 1. Check cwd/node_modules/.bin/<cmd>
23
+ * 2. Check /tmp/.npx-cache/node_modules/.bin/<cmd>
24
+ * 3. Check global registry (built-ins like vite, esbuild — handled by
25
+ * caller; this module is only invoked when registry resolution failed)
26
+ * 4. Install package via NpmInstaller into /tmp/.npx-cache
27
+ * 5. Locate <pkg>/package.json#bin → resolve absolute path
28
+ * 6. Invoke via Nimbus's `node` registry command (preserves PID
29
+ * tracking, log buffer, process table membership)
30
+ */
31
+ import type { NpmInstaller } from './installer.js';
32
+ import type { SqliteVFS } from '../vfs/sqlite-vfs.js';
33
+ /** Path where npx caches packages it installs. Matches the constant
34
+ * in @lifo-sh/core (Vs in dist/index-Djm2onjx.js) so any other code
35
+ * reading this dir (e.g. tooling that introspects npx state) sees the
36
+ * same layout. */
37
+ export declare const NPX_CACHE_DIR = "/tmp/.npx-cache";
38
+ /**
39
+ * Result of a Nimbus-native npx invocation.
40
+ *
41
+ * ok=true: the binary was located AND about to be invoked. The
42
+ * caller dispatches via the `node` registry handler with
43
+ * { args: [binPath, ...binArgs] }.
44
+ * ok=false: bin not found OR install failed OR arg parse error.
45
+ * `error` is a human-readable message; caller prints to
46
+ * stderr and returns exit code.
47
+ */
48
+ export interface NpxResolveResult {
49
+ ok: boolean;
50
+ binPath?: string;
51
+ binArgs?: string[];
52
+ error?: string;
53
+ /** Diagnostic: which path located the bin (project-nm / npx-cache /
54
+ * fresh-install). Useful in logs. */
55
+ source?: 'project-nm' | 'npx-cache' | 'fresh-install';
56
+ }
57
+ /**
58
+ * Resolve a binary for `npx <args>` by:
59
+ * 1. Parsing args.
60
+ * 2. Checking node_modules/.bin/<binName> in cwd, then NPX cache.
61
+ * 3. If absent, installing the package via NpmInstaller into
62
+ * /tmp/.npx-cache, then re-checking.
63
+ *
64
+ * The caller is responsible for actually invoking the resulting binPath
65
+ * via Nimbus's `node` command — keeping this module pure (no process
66
+ * spawning) makes it testable.
67
+ *
68
+ * Note: deliberately does NOT honor `--version`/`--help` for npx
69
+ * itself (those are caller's job); they bubble up as `error` markers
70
+ * so the caller can format the usage banner consistently with the
71
+ * rest of the shell.
72
+ */
73
+ export declare function resolveNpxBinary(installer: NpmInstaller, vfs: SqliteVFS, cwd: string, rawArgs: string[], log: (msg: string) => void): Promise<NpxResolveResult>;
74
+ //# sourceMappingURL=npx-install.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"npx-install.d.ts","sourceRoot":"","sources":["../../src/npm/npx-install.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEtD;;;mBAGmB;AACnB,eAAO,MAAM,aAAa,oBAAoB,CAAC;AAiN/C;;;;;;;;;GASG;AACH,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,OAAO,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;0CACsC;IACtC,MAAM,CAAC,EAAE,YAAY,GAAG,WAAW,GAAG,eAAe,CAAC;CACvD;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,gBAAgB,CACpC,SAAS,EAAE,YAAY,EACvB,GAAG,EAAE,SAAS,EACd,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,EAAE,EACjB,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,GACzB,OAAO,CAAC,gBAAgB,CAAC,CAgE3B"}
@@ -0,0 +1,302 @@
1
+ /**
2
+ * npx-install.ts — Nimbus-native npx implementation.
3
+ *
4
+ * Replaces @lifo-sh/core's createNpxCommand (which uses a too-narrow
5
+ * semver-range detector that misses major-only ranges like `'1'`, `'2'`,
6
+ * `'1.0'`). The core's `ic()` regex `/[\^~>=<|*x]/.test(r)` flagged
7
+ * caret/tilde/comparator/x ranges correctly but treated `'1'` as a
8
+ * literal version → fetched `/wrappy/1` → 404 → silently skipped.
9
+ *
10
+ * Symptom captured by tests/behavioral/install/transitive-dep-resolution.mjs:
11
+ * `npx --yes rimraf@3.0.2 --help` →
12
+ * warn: could not install wrappy: Package 'wrappy@1' not found in registry
13
+ * warn: could not install inherits: Package 'inherits@2' not found in registry
14
+ * Cannot find module './' (from /tmp/.npx-cache/node_modules/rimraf)
15
+ *
16
+ * Fix: route the npx install step through Nimbus's NpmInstaller, which
17
+ * uses always-fetch-packument + RESOLVE_VERSION-style version-pick path
18
+ * (resolve-one-facet.ts:264 + RESOLVE_VERSION). Handles all semver-range
19
+ * syntax including major-only and major.minor.
20
+ *
21
+ * Binary-lookup and execution stay closer to the @lifo-sh/core flow:
22
+ * 1. Check cwd/node_modules/.bin/<cmd>
23
+ * 2. Check /tmp/.npx-cache/node_modules/.bin/<cmd>
24
+ * 3. Check global registry (built-ins like vite, esbuild — handled by
25
+ * caller; this module is only invoked when registry resolution failed)
26
+ * 4. Install package via NpmInstaller into /tmp/.npx-cache
27
+ * 5. Locate <pkg>/package.json#bin → resolve absolute path
28
+ * 6. Invoke via Nimbus's `node` registry command (preserves PID
29
+ * tracking, log buffer, process table membership)
30
+ */
31
+ /** Path where npx caches packages it installs. Matches the constant
32
+ * in @lifo-sh/core (Vs in dist/index-Djm2onjx.js) so any other code
33
+ * reading this dir (e.g. tooling that introspects npx state) sees the
34
+ * same layout. */
35
+ export const NPX_CACHE_DIR = '/tmp/.npx-cache';
36
+ const NPX_CACHE_NM = `${NPX_CACHE_DIR}/node_modules`;
37
+ /**
38
+ * SqliteVFS uses absolute paths WITHOUT a leading slash (e.g. it stores
39
+ * `tmp/.npx-cache/node_modules/foo/package.json`, not `/tmp/...`). The
40
+ * NpmInstaller's `install()` entry strips the leading slash from its
41
+ * `projectDir` arg, then propagates the slashless form into all
42
+ * downstream pkgDirs and inode keys. To check existence post-install,
43
+ * we MUST strip the same way; `vfs.exists('/...')` always returns false.
44
+ *
45
+ * Mirror of `_strip` in src/runtime/node-shims.ts:204.
46
+ */
47
+ function _vfsKey(p) {
48
+ return p.replace(/^\/+/, '');
49
+ }
50
+ function parseNpxArgs(rawArgs) {
51
+ let pkgOverride = null;
52
+ const consumed = [];
53
+ let yes = false;
54
+ let i = 0;
55
+ while (i < rawArgs.length) {
56
+ const a = rawArgs[i];
57
+ if (a === '-y' || a === '--yes') {
58
+ yes = true;
59
+ i++;
60
+ continue;
61
+ }
62
+ if (a === '--package' && i + 1 < rawArgs.length) {
63
+ pkgOverride = rawArgs[i + 1];
64
+ i += 2;
65
+ continue;
66
+ }
67
+ if (a.startsWith('--package=')) {
68
+ pkgOverride = a.slice('--package='.length);
69
+ i++;
70
+ continue;
71
+ }
72
+ if (a === '--version' || a === '-v' || a === '--help' || a === '-h') {
73
+ // Pass-through to surface npx's own version/help. Caller (init.ts
74
+ // npx handler) is the one that prints these; this module returns
75
+ // an error so the caller can branch.
76
+ return { error: a };
77
+ }
78
+ break;
79
+ }
80
+ const first = rawArgs[i];
81
+ if (!first)
82
+ return { error: 'missing-cmd' };
83
+ consumed.push(...rawArgs.slice(i + 1));
84
+ // If --package=<pkg>, the positional arg is the BIN name; the package
85
+ // installs `<pkg>` and we look for the binary `<first>`.
86
+ // Else, the positional arg is `<name>[@<version>]`; binary is the
87
+ // last path segment of `<name>`.
88
+ let pkgSpec;
89
+ let binName;
90
+ if (pkgOverride) {
91
+ pkgSpec = pkgOverride;
92
+ binName = first;
93
+ }
94
+ else {
95
+ pkgSpec = first;
96
+ const namePart = splitSpec(first).name;
97
+ binName = namePart.split('/').pop() || namePart;
98
+ }
99
+ const { name: pkgName } = splitSpec(pkgSpec);
100
+ return { pkgSpec, pkgName, binName, binArgs: consumed, yes };
101
+ }
102
+ /** Split `name@version` (or scoped `@scope/name@version`) into parts. */
103
+ function splitSpec(spec) {
104
+ if (spec.startsWith('@')) {
105
+ const at = spec.indexOf('@', 1);
106
+ if (at === -1)
107
+ return { name: spec, version: null };
108
+ return { name: spec.slice(0, at), version: spec.slice(at + 1) };
109
+ }
110
+ const at = spec.indexOf('@');
111
+ if (at === -1)
112
+ return { name: spec, version: null };
113
+ return { name: spec.slice(0, at), version: spec.slice(at + 1) };
114
+ }
115
+ /**
116
+ * Find the absolute path of a binary inside a package's directory.
117
+ *
118
+ * package.json#bin can be:
119
+ * - `string` → single bin named after the package itself
120
+ * - `Record<string, string>` → multiple bins
121
+ *
122
+ * Returns the resolved absolute path (rooted at packageDir) if a
123
+ * matching bin name is found, else null. Matches @lifo-sh/core's
124
+ * `Ht()` helper at dist/index-Djm2onjx.js:11707.
125
+ */
126
+ function findBinInPackage(vfs, packageDir, binName) {
127
+ const pkgJsonPath = `${packageDir}/package.json`;
128
+ // SqliteVFS stores keys without leading slash. Check via the stripped
129
+ // key form to match the installer's write convention.
130
+ if (!vfs.exists(_vfsKey(pkgJsonPath)))
131
+ return null;
132
+ let pkgJson;
133
+ try {
134
+ pkgJson = JSON.parse(vfs.readFileString(_vfsKey(pkgJsonPath)));
135
+ }
136
+ catch {
137
+ return null;
138
+ }
139
+ const binField = pkgJson.bin;
140
+ if (!binField)
141
+ return null;
142
+ let resolved = null;
143
+ if (typeof binField === 'string') {
144
+ // Single-bin shorthand: bin name is package name's last segment.
145
+ const expected = String(pkgJson.name || '').split('/').pop();
146
+ if (expected === binName)
147
+ resolved = binField;
148
+ }
149
+ else if (typeof binField === 'object') {
150
+ const candidate = binField[binName];
151
+ if (typeof candidate === 'string') {
152
+ resolved = candidate;
153
+ }
154
+ else {
155
+ // Fall back to the FIRST bin entry — matches @lifo-sh/core's
156
+ // `Object.values(i)[0]` behavior at dist/index-Djm2onjx.js:11710.
157
+ const first = Object.values(binField)[0];
158
+ if (typeof first === 'string')
159
+ resolved = first;
160
+ }
161
+ }
162
+ if (!resolved)
163
+ return null;
164
+ // Strip leading "./" if present and join with packageDir. Return
165
+ // the absolute path (with leading slash) — the `node` registry
166
+ // command expects an absolute filesystem path as the first arg.
167
+ // The vfs.exists checks against _vfsKey internally.
168
+ const rel = resolved.startsWith('./') ? resolved.slice(2) : resolved;
169
+ return `${packageDir}/${rel}`;
170
+ }
171
+ /**
172
+ * Locate a binary by name across the standard search paths npx uses:
173
+ * 1. cwd/node_modules/.bin/<binName> (project-local install)
174
+ * 2. NPX_CACHE_NM/<pkgName>/... (npx-cache install)
175
+ *
176
+ * Returns the absolute path on hit, null on miss.
177
+ */
178
+ function locateBinary(vfs, cwd, pkgName, binName) {
179
+ // 1. Project-local node_modules. The packageDir is cwd/node_modules/<pkgName>.
180
+ const projPkgDir = `${cwd}/node_modules/${pkgName}`;
181
+ const projHit = findBinInPackage(vfs, projPkgDir, binName);
182
+ if (projHit && vfs.exists(_vfsKey(projHit)))
183
+ return projHit;
184
+ // 2. NPX cache.
185
+ const npxPkgDir = `${NPX_CACHE_NM}/${pkgName}`;
186
+ const npxHit = findBinInPackage(vfs, npxPkgDir, binName);
187
+ if (npxHit && vfs.exists(_vfsKey(npxHit)))
188
+ return npxHit;
189
+ return null;
190
+ }
191
+ /**
192
+ * Ensure /tmp/.npx-cache/package.json exists with the requested spec
193
+ * in its dependencies. NpmInstaller reads package.json from projectDir
194
+ * to determine what to install; we synthesize one for the npx cache.
195
+ *
196
+ * Idempotent: if the file already exists and has the spec in deps,
197
+ * leaves it alone. Returns the deps object after the write (useful
198
+ * for the caller's log line).
199
+ */
200
+ function ensureNpxCachePackageJson(vfs, pkgName, pkgRange) {
201
+ const pkgJsonPath = `${NPX_CACHE_DIR}/package.json`;
202
+ const pkgJsonKey = _vfsKey(pkgJsonPath);
203
+ let existing = { name: 'npx-cache', version: '0.0.0', dependencies: {} };
204
+ if (vfs.exists(pkgJsonKey)) {
205
+ try {
206
+ existing = JSON.parse(vfs.readFileString(pkgJsonKey));
207
+ if (!existing.dependencies)
208
+ existing.dependencies = {};
209
+ }
210
+ catch {
211
+ // Corrupted — overwrite with fresh content below.
212
+ existing = { name: 'npx-cache', version: '0.0.0', dependencies: {} };
213
+ }
214
+ }
215
+ else {
216
+ // Ensure the parent dir exists. SqliteVFS auto-creates parent
217
+ // dirs in writeFile, but mkdir defensively for symmetry with
218
+ // @lifo-sh/core's flow.
219
+ try {
220
+ vfs.mkdir(_vfsKey(NPX_CACHE_DIR), { recursive: true });
221
+ }
222
+ catch { /* dir exists */ }
223
+ }
224
+ existing.dependencies[pkgName] = pkgRange;
225
+ vfs.writeFile(pkgJsonKey, JSON.stringify(existing, null, 2) + '\n');
226
+ }
227
+ /**
228
+ * Resolve a binary for `npx <args>` by:
229
+ * 1. Parsing args.
230
+ * 2. Checking node_modules/.bin/<binName> in cwd, then NPX cache.
231
+ * 3. If absent, installing the package via NpmInstaller into
232
+ * /tmp/.npx-cache, then re-checking.
233
+ *
234
+ * The caller is responsible for actually invoking the resulting binPath
235
+ * via Nimbus's `node` command — keeping this module pure (no process
236
+ * spawning) makes it testable.
237
+ *
238
+ * Note: deliberately does NOT honor `--version`/`--help` for npx
239
+ * itself (those are caller's job); they bubble up as `error` markers
240
+ * so the caller can format the usage banner consistently with the
241
+ * rest of the shell.
242
+ */
243
+ export async function resolveNpxBinary(installer, vfs, cwd, rawArgs, log) {
244
+ const parsed = parseNpxArgs(rawArgs);
245
+ if ('error' in parsed) {
246
+ return { ok: false, error: parsed.error };
247
+ }
248
+ // 1. Check project + NPX cache for pre-installed bin.
249
+ const existing = locateBinary(vfs, cwd, parsed.pkgName, parsed.binName);
250
+ if (existing) {
251
+ return {
252
+ ok: true,
253
+ binPath: existing,
254
+ binArgs: parsed.binArgs,
255
+ source: cwd && existing.startsWith(cwd) ? 'project-nm' : 'npx-cache',
256
+ };
257
+ }
258
+ // 2. Not found anywhere — install into NPX cache via NpmInstaller.
259
+ // Use the package's `<pkgSpec>` directly; NpmInstaller parses the
260
+ // `<name>@<version>` form same as `npm install <pkgSpec>`.
261
+ log(` ${parsed.pkgSpec}...`);
262
+ const { name: instName, version: instVer } = splitSpec(parsed.pkgSpec);
263
+ const installSpec = instVer ? `${instName}@${instVer}` : instName;
264
+ // Synthesize npx-cache package.json so NpmInstaller has a project
265
+ // root. The deps map is the source of truth for the install set.
266
+ ensureNpxCachePackageJson(vfs, instName, instVer || 'latest');
267
+ try {
268
+ const result = await installer.install(NPX_CACHE_DIR, {
269
+ packages: [installSpec],
270
+ });
271
+ if ((result.failed?.length || 0) > 0) {
272
+ // Partial install — some package failed to resolve. The fix is
273
+ // designed to handle major-only ranges; a residual failure here
274
+ // means a genuinely missing package or an unrelated transitive
275
+ // gap. Surface it as the error.
276
+ return {
277
+ ok: false,
278
+ error: `npx: install partially failed: ${result.failed.join(', ')}`,
279
+ };
280
+ }
281
+ }
282
+ catch (e) {
283
+ return {
284
+ ok: false,
285
+ error: `npx: install failed: ${e?.message ?? String(e)}`,
286
+ };
287
+ }
288
+ // 3. Re-check NPX cache after install.
289
+ const installed = locateBinary(vfs, cwd, parsed.pkgName, parsed.binName);
290
+ if (installed) {
291
+ return {
292
+ ok: true,
293
+ binPath: installed,
294
+ binArgs: parsed.binArgs,
295
+ source: 'fresh-install',
296
+ };
297
+ }
298
+ return {
299
+ ok: false,
300
+ error: `npx: installed ${parsed.pkgSpec} but could not locate binary '${parsed.binName}' in ${NPX_CACHE_NM}/${parsed.pkgName}`,
301
+ };
302
+ }
@@ -0,0 +1,168 @@
1
+ /**
2
+ * pre-bundle-facet.ts — NimbusLoaderPool entry for esbuild pre-bundling.
3
+ *
4
+ * Why this exists
5
+ * ───────────────
6
+ * Pre-bundling npm packages (the `Pre-bundling N modules…` step in
7
+ * src/npm-installer.ts:704) used to call `EsbuildService.build(...)`
8
+ * inside the supervisor DO isolate. Each `esbuild.build` allocates
9
+ * 30–80 MiB of WASM linear memory plus the input/output graph; against
10
+ * the 128 MB DO heap cap this OOM-killed the supervisor on installs
11
+ * touching large React libraries (motion, framer-motion, etc.). The
12
+ * symptom was a banner re-print after `npm install` succeeded —
13
+ * NimbusSession's constructor running again because workerd had killed
14
+ * the previous isolate.
15
+ *
16
+ * The fix is to dispatch each per-specifier `esbuild.build` to a
17
+ * NimbusLoaderPool isolate. Each facet has its own 128 MB budget and
18
+ * stable-slot reuse keeps the warm-up cost amortized across the 8
19
+ * concurrent specs of a typical install. Same pattern as
20
+ * src/npm-install-facet.ts (tarball extraction).
21
+ *
22
+ * File-slice strategy (zero per-read RPC)
23
+ * ──────────────────────────────────────
24
+ * esbuild's VFS plugin would naturally call back to the supervisor for
25
+ * every onLoad / onResolve hit. With workerd's ~5–20 ms RPC latency and
26
+ * 50–200 reads per bundle × 8 specs that's 4–32 seconds of pure RPC
27
+ * overhead per install — measurably worse than the current OOM-y path.
28
+ *
29
+ * Instead the supervisor walks the spec's transitive non-external
30
+ * dependency tree once (fast — direct VFS access) and ships the
31
+ * entire `{path → bytes}` slice as part of the spec. The facet's VFS
32
+ * plugin reads from this in-memory map. Zero RPC during bundling.
33
+ *
34
+ * Stability invariants
35
+ * ───────────────────
36
+ * cloudflare-parallel serializes the function via `fn.toString()`.
37
+ * - No `this` references (arrow / anonymous async).
38
+ * - No free variables other than preamble names + explicit args.
39
+ * - Module-level constants the function references must come from
40
+ * the preamble (src/parallel/pre-bundle-preamble.ts) — see
41
+ * `ESBUILD_PRELOAD_PREAMBLE`.
42
+ *
43
+ * The supervisor RPC surface (env.SUPERVISOR) is available for emergency
44
+ * fallbacks but the bundle path MUST NOT use it — slice-up-front is the
45
+ * contract.
46
+ */
47
+ import type { SqliteVFS } from '../vfs/sqlite-vfs.js';
48
+ import type { ResolvedPackage } from './resolver.js';
49
+ import { BUNDLER_VERSION } from '../runtime/esbuild-service.js';
50
+ /**
51
+ * One file inside a facet spec's slice. `bytes` is a Uint8Array — esbuild's
52
+ * loader inferences (js/ts/css/binary) need raw bytes for binary entries
53
+ * and TextDecoder produces lossless text for source code.
54
+ *
55
+ * RPC serialisation: workerd transmits Uint8Array via structured-clone with
56
+ * zero-copy semantics across same-process isolates. Memory cost on the
57
+ * facet side equals the spec's slice size; cost on the supervisor side is
58
+ * the same (the slice was just built from VFS reads).
59
+ */
60
+ export interface SlicedFile {
61
+ path: string;
62
+ bytes: Uint8Array;
63
+ isDir: false;
64
+ }
65
+ export interface SlicedDir {
66
+ path: string;
67
+ isDir: true;
68
+ }
69
+ export type SliceEntry = SlicedFile | SlicedDir;
70
+ /** What the supervisor sends per pre-bundle dispatch. */
71
+ export interface PrebundleSpec {
72
+ /** Bare specifier being bundled, e.g. "framer-motion" or "react/jsx-runtime". */
73
+ specifier: string;
74
+ /** VFS path of the entry point, e.g. "/home/user/app/node_modules/framer-motion/dist/es/index.mjs". */
75
+ entryPath: string;
76
+ /** External specifiers (from getSharedRuntimeExternals). */
77
+ externals: string[];
78
+ /**
79
+ * Slice: every file/dir the bundler may need for this spec. Computed
80
+ * supervisor-side via a transitive-dependency walk. Includes:
81
+ * - Every file under node_modules/<spec-pkg>/
82
+ * - Every file under node_modules/<dep>/ for each transitive dep
83
+ * NOT marked external by `externals`.
84
+ */
85
+ slice: SliceEntry[];
86
+ /** Stamp written into pkg_esm_bundles.bundle_hash; matches BUNDLER_VERSION. */
87
+ bundlerVersion: string;
88
+ /** Optional esbuild `define` map. Used by the on-demand bundler path
89
+ * (vite-dev-server) to inject process.env.NODE_ENV, import.meta.env.*,
90
+ * global → globalThis, etc. The pre-bundle path leaves this undefined
91
+ * (browser-target build needs no define replacement). */
92
+ define?: Record<string, string>;
93
+ }
94
+ /** What the facet returns. */
95
+ export interface PrebundleResult {
96
+ specifier: string;
97
+ ok: boolean;
98
+ /** ESM bundle output as a UTF-8 string. Empty when ok=false. */
99
+ esmCode: string;
100
+ /** First esbuild error message; populated when ok=false. */
101
+ errorText?: string;
102
+ /** Wall-clock ms inside the facet (bundling only, excludes RPC roundtrip). */
103
+ elapsed: number;
104
+ /** Non-fatal warnings the supervisor should surface. */
105
+ warnings: string[];
106
+ }
107
+ /**
108
+ * Walk node_modules to collect every file the pre-bundle of `specifier`
109
+ * may read. Runs in the supervisor (cheap — direct VFS access).
110
+ *
111
+ * Algorithm:
112
+ * 1. Compute the externals via getSharedRuntimeExternals(specifier).
113
+ * These are the bare specifiers esbuild will leave external; their
114
+ * files do NOT need to be in the slice.
115
+ * 2. Resolve the spec's package directory and add every file beneath
116
+ * it to the slice.
117
+ * 3. Read its package.json `dependencies` and recurse into each one
118
+ * that is NOT in the externals set. Deps that walked up are
119
+ * visited at most once (visited set).
120
+ *
121
+ * Lives here (alongside the facet function) so changes to the slice
122
+ * shape touch one file — the supervisor caller in npm-installer.ts is
123
+ * a thin orchestrator.
124
+ */
125
+ export interface BuildSliceOptions {
126
+ /** Cap on total bytes shipped to the facet. 24 MiB leaves headroom under
127
+ * the 32 MiB workerd RPC cap. Returns `null` if the cap is exceeded so
128
+ * the caller can decide whether to bail or split (bf41d1c precedent).
129
+ */
130
+ maxBytes?: number;
131
+ }
132
+ export declare function buildSliceForSpecifier(vfs: SqliteVFS, specifier: string, nmDir: string): {
133
+ slice: SliceEntry[];
134
+ totalBytes: number;
135
+ } | null;
136
+ export declare function buildSliceForSpecifierWithCap(vfs: SqliteVFS, specifier: string, nmDir: string, capBytes: number): {
137
+ slice: SliceEntry[];
138
+ totalBytes: number;
139
+ } | null;
140
+ /**
141
+ * Choose the externals list for a specifier, exported so the supervisor
142
+ * can compute the same value when building the spec without re-pulling
143
+ * the helper from esbuild-service.ts on the call site.
144
+ */
145
+ export declare function externalsForSpecifier(specifier: string): string[];
146
+ /**
147
+ * Bundle one specifier in a facet isolate. Returns the ESM bundle output
148
+ * to the supervisor; bundle bytes flow through `pool.map`'s return value
149
+ * (no RPC writeBatch — pkg_esm_bundles is supervisor-side SQLite, not VFS).
150
+ *
151
+ * Memory plan (verified by /api/_diag/memory after the rollout):
152
+ * - Slice retained in facet memory: ~3–10 MiB per typical React lib.
153
+ * - esbuild WASM linear memory: ~30–80 MiB during build.
154
+ * - Output bundle: usually <2 MiB.
155
+ * - Peak in the facet: ~100 MiB worst case (well under 128 MB cap).
156
+ *
157
+ * The supervisor never holds more than the spec arg + result return at
158
+ * once, so its peak stays in the low tens of MiB during the entire
159
+ * pre-bundle phase.
160
+ */
161
+ export declare const prebundleOne: (spec: PrebundleSpec, _env: {
162
+ SUPERVISOR: {
163
+ readFile(p: string): Promise<string | null>;
164
+ };
165
+ }) => Promise<PrebundleResult>;
166
+ export { BUNDLER_VERSION };
167
+ export type _ResolvedPackage = ResolvedPackage;
168
+ //# sourceMappingURL=pre-bundle-facet.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pre-bundle-facet.d.ts","sourceRoot":"","sources":["../../src/npm/pre-bundle-facet.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAA6B,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAgB3F;;;;;;;;;GASG;AACH,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,UAAU,CAAC;IAClB,KAAK,EAAE,KAAK,CAAC;CACd;AACD,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,IAAI,CAAC;CACb;AACD,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG,SAAS,CAAC;AAEhD,yDAAyD;AACzD,MAAM,WAAW,aAAa;IAC5B,iFAAiF;IACjF,SAAS,EAAE,MAAM,CAAC;IAClB,uGAAuG;IACvG,SAAS,EAAE,MAAM,CAAC;IAClB,4DAA4D;IAC5D,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB;;;;;;OAMG;IACH,KAAK,EAAE,UAAU,EAAE,CAAC;IACpB,+EAA+E;IAC/E,cAAc,EAAE,MAAM,CAAC;IACvB;;;8DAG0D;IAC1D,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACjC;AAED,8BAA8B;AAC9B,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,EAAE,EAAE,OAAO,CAAC;IACZ,gEAAgE;IAChE,OAAO,EAAE,MAAM,CAAC;IAChB,4DAA4D;IAC5D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,8EAA8E;IAC9E,OAAO,EAAE,MAAM,CAAC;IAChB,wDAAwD;IACxD,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAID;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AACD,wBAAgB,sBAAsB,CACpC,GAAG,EAAE,SAAS,EACd,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,GACZ;IAAE,KAAK,EAAE,UAAU,EAAE,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAEpD;AAED,wBAAgB,6BAA6B,CAC3C,GAAG,EAAE,SAAS,EACd,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,GACf;IAAE,KAAK,EAAE,UAAU,EAAE,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CA4GpD;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,CAEjE;AAmBD;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,YAAY,GACvB,MAAM,aAAa,EACnB,MAAM;IACJ,UAAU,EAAE;QAAE,QAAQ,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAA;KAAE,CAAC;CAC7D,KACA,OAAO,CAAC,eAAe,CAgazB,CAAC;AAGF,OAAO,EAAE,eAAe,EAAE,CAAC;AAE3B,MAAM,MAAM,gBAAgB,GAAG,eAAe,CAAC"}