@nimbus-sh/core 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 (1056) hide show
  1. package/dist/_shared/ai-egress.d.ts +73 -0
  2. package/dist/_shared/ai-egress.d.ts.map +1 -0
  3. package/dist/_shared/ai-egress.js +88 -0
  4. package/dist/_shared/byte-stream.d.ts +59 -0
  5. package/dist/_shared/byte-stream.d.ts.map +1 -0
  6. package/dist/_shared/byte-stream.js +77 -0
  7. package/dist/_shared/bytes.d.ts +18 -0
  8. package/dist/_shared/bytes.d.ts.map +1 -0
  9. package/dist/_shared/bytes.js +17 -0
  10. package/dist/_shared/cache-stats.d.ts +145 -0
  11. package/dist/_shared/cache-stats.d.ts.map +1 -0
  12. package/dist/_shared/cache-stats.js +161 -0
  13. package/dist/_shared/crypto.d.ts +17 -0
  14. package/dist/_shared/crypto.d.ts.map +1 -0
  15. package/dist/_shared/crypto.js +131 -0
  16. package/dist/_shared/esbuild-facet-shim.d.ts +21 -0
  17. package/dist/_shared/esbuild-facet-shim.d.ts.map +1 -0
  18. package/dist/_shared/esbuild-facet-shim.js +22 -0
  19. package/dist/_shared/exports-resolver.d.ts +74 -0
  20. package/dist/_shared/exports-resolver.d.ts.map +1 -0
  21. package/dist/_shared/exports-resolver.js +284 -0
  22. package/dist/_shared/facet-vfs-cursor.d.ts +48 -0
  23. package/dist/_shared/facet-vfs-cursor.d.ts.map +1 -0
  24. package/dist/_shared/facet-vfs-cursor.js +51 -0
  25. package/dist/_shared/install-phase.d.ts +47 -0
  26. package/dist/_shared/install-phase.d.ts.map +1 -0
  27. package/dist/_shared/install-phase.js +1 -0
  28. package/dist/_shared/lru-map.d.ts +25 -0
  29. package/dist/_shared/lru-map.d.ts.map +1 -0
  30. package/dist/_shared/lru-map.js +57 -0
  31. package/dist/_shared/real-node-imports.d.ts +43 -0
  32. package/dist/_shared/real-node-imports.d.ts.map +1 -0
  33. package/dist/_shared/real-node-imports.js +52 -0
  34. package/dist/_shared/retry.d.ts +92 -0
  35. package/dist/_shared/retry.d.ts.map +1 -0
  36. package/dist/_shared/retry.js +155 -0
  37. package/dist/_shared/rpc-dispose.d.ts +4 -0
  38. package/dist/_shared/rpc-dispose.d.ts.map +1 -0
  39. package/dist/_shared/rpc-dispose.js +30 -0
  40. package/dist/_shared/terminal.d.ts +2 -0
  41. package/dist/_shared/terminal.d.ts.map +1 -0
  42. package/dist/_shared/terminal.js +3 -0
  43. package/dist/_shared/typescript-specifiers.d.ts +58 -0
  44. package/dist/_shared/typescript-specifiers.d.ts.map +1 -0
  45. package/dist/_shared/typescript-specifiers.js +84 -0
  46. package/dist/_shared/untrusted-request.d.ts +34 -0
  47. package/dist/_shared/untrusted-request.d.ts.map +1 -0
  48. package/dist/_shared/untrusted-request.js +74 -0
  49. package/dist/_shared/vfs-write-ledger.d.ts +3 -0
  50. package/dist/_shared/vfs-write-ledger.d.ts.map +1 -0
  51. package/dist/_shared/vfs-write-ledger.js +439 -0
  52. package/dist/_shared/w7-frame.d.ts +79 -0
  53. package/dist/_shared/w7-frame.d.ts.map +1 -0
  54. package/dist/_shared/w7-frame.js +839 -0
  55. package/dist/_shared/weighted-credit-pool.d.ts +61 -0
  56. package/dist/_shared/weighted-credit-pool.d.ts.map +1 -0
  57. package/dist/_shared/weighted-credit-pool.js +196 -0
  58. package/dist/constants.d.ts +64 -0
  59. package/dist/constants.d.ts.map +1 -0
  60. package/dist/constants.js +264 -0
  61. package/dist/index.d.ts +16 -0
  62. package/dist/index.d.ts.map +1 -0
  63. package/dist/index.js +13 -0
  64. package/dist/observability/diag-counters.d.ts +236 -0
  65. package/dist/observability/diag-counters.d.ts.map +1 -0
  66. package/dist/observability/diag-counters.js +195 -0
  67. package/dist/observability/heap-estimate.d.ts +225 -0
  68. package/dist/observability/heap-estimate.d.ts.map +1 -0
  69. package/dist/observability/heap-estimate.js +185 -0
  70. package/dist/observability/heavy-alloc-coord.d.ts +93 -0
  71. package/dist/observability/heavy-alloc-coord.d.ts.map +1 -0
  72. package/dist/observability/heavy-alloc-coord.js +181 -0
  73. package/dist/observability/oom-classify.d.ts +138 -0
  74. package/dist/observability/oom-classify.d.ts.map +1 -0
  75. package/dist/observability/oom-classify.js +261 -0
  76. package/dist/observability/oom-discriminator.d.ts +176 -0
  77. package/dist/observability/oom-discriminator.d.ts.map +1 -0
  78. package/dist/observability/oom-discriminator.js +272 -0
  79. package/dist/runtime/assets-loader.d.ts +71 -0
  80. package/dist/runtime/assets-loader.d.ts.map +1 -0
  81. package/dist/runtime/assets-loader.js +139 -0
  82. package/dist/runtime/barrel-detect.d.ts +46 -0
  83. package/dist/runtime/barrel-detect.d.ts.map +1 -0
  84. package/dist/runtime/barrel-detect.js +73 -0
  85. package/dist/runtime/bash/preamble.d.ts +2 -0
  86. package/dist/runtime/bash/preamble.d.ts.map +1 -0
  87. package/dist/runtime/bash/preamble.js +1849 -0
  88. package/dist/runtime/bash/types.d.ts +433 -0
  89. package/dist/runtime/bash/types.d.ts.map +1 -0
  90. package/dist/runtime/bash/types.js +1 -0
  91. package/dist/runtime/bundle-profile.d.ts +14 -0
  92. package/dist/runtime/bundle-profile.d.ts.map +1 -0
  93. package/dist/runtime/bundle-profile.js +20 -0
  94. package/dist/runtime/cirrus-vite-config-rewriter.d.ts +2 -0
  95. package/dist/runtime/cirrus-vite-config-rewriter.d.ts.map +1 -0
  96. package/dist/runtime/cirrus-vite-config-rewriter.js +28 -0
  97. package/dist/runtime/cli-flags.d.ts +2 -0
  98. package/dist/runtime/cli-flags.d.ts.map +1 -0
  99. package/dist/runtime/cli-flags.js +11 -0
  100. package/dist/runtime/comment-strip.d.ts +37 -0
  101. package/dist/runtime/comment-strip.d.ts.map +1 -0
  102. package/dist/runtime/comment-strip.js +74 -0
  103. package/dist/runtime/cpython-preamble.d.ts +32 -0
  104. package/dist/runtime/cpython-preamble.d.ts.map +1 -0
  105. package/dist/runtime/cpython-preamble.js +296 -0
  106. package/dist/runtime/esbuild-service.d.ts +242 -0
  107. package/dist/runtime/esbuild-service.d.ts.map +1 -0
  108. package/dist/runtime/esbuild-service.js +1452 -0
  109. package/dist/runtime/framework-detect.d.ts +70 -0
  110. package/dist/runtime/framework-detect.d.ts.map +1 -0
  111. package/dist/runtime/framework-detect.js +177 -0
  112. package/dist/runtime/import-meta-transform.d.ts +3 -0
  113. package/dist/runtime/import-meta-transform.d.ts.map +1 -0
  114. package/dist/runtime/import-meta-transform.js +15 -0
  115. package/dist/runtime/javascript-ast.d.ts +13 -0
  116. package/dist/runtime/javascript-ast.d.ts.map +1 -0
  117. package/dist/runtime/javascript-ast.js +57 -0
  118. package/dist/runtime/long-running-handle.d.ts +119 -0
  119. package/dist/runtime/long-running-handle.d.ts.map +1 -0
  120. package/dist/runtime/long-running-handle.js +169 -0
  121. package/dist/runtime/module-source-rewriter.d.ts +11 -0
  122. package/dist/runtime/module-source-rewriter.d.ts.map +1 -0
  123. package/dist/runtime/module-source-rewriter.js +61 -0
  124. package/dist/runtime/opentui-wasm-backend.d.ts +160 -0
  125. package/dist/runtime/opentui-wasm-backend.d.ts.map +1 -0
  126. package/dist/runtime/opentui-wasm-backend.js +416 -0
  127. package/dist/runtime/os-contracts.d.ts +436 -0
  128. package/dist/runtime/os-contracts.d.ts.map +1 -0
  129. package/dist/runtime/os-contracts.js +101 -0
  130. package/dist/runtime/port-registry.d.ts +100 -0
  131. package/dist/runtime/port-registry.d.ts.map +1 -0
  132. package/dist/runtime/port-registry.js +265 -0
  133. package/dist/runtime/process-input-routing.d.ts +33 -0
  134. package/dist/runtime/process-input-routing.d.ts.map +1 -0
  135. package/dist/runtime/process-input-routing.js +59 -0
  136. package/dist/runtime/process-input.d.ts +39 -0
  137. package/dist/runtime/process-input.d.ts.map +1 -0
  138. package/dist/runtime/process-input.js +117 -0
  139. package/dist/runtime/process-io-protocol.d.ts +90 -0
  140. package/dist/runtime/process-io-protocol.d.ts.map +1 -0
  141. package/dist/runtime/process-io-protocol.js +81 -0
  142. package/dist/runtime/process-logs.d.ts +352 -0
  143. package/dist/runtime/process-logs.d.ts.map +1 -0
  144. package/dist/runtime/process-logs.js +750 -0
  145. package/dist/runtime/process-table.d.ts +101 -0
  146. package/dist/runtime/process-table.d.ts.map +1 -0
  147. package/dist/runtime/process-table.js +175 -0
  148. package/dist/runtime/project-detect.d.ts +21 -0
  149. package/dist/runtime/project-detect.d.ts.map +1 -0
  150. package/dist/runtime/project-detect.js +46 -0
  151. package/dist/runtime/python-server-adapter.d.ts +33 -0
  152. package/dist/runtime/python-server-adapter.d.ts.map +1 -0
  153. package/dist/runtime/python-server-adapter.js +132 -0
  154. package/dist/runtime/require-resolver.d.ts +44 -0
  155. package/dist/runtime/require-resolver.d.ts.map +1 -0
  156. package/dist/runtime/require-resolver.js +698 -0
  157. package/dist/runtime/router-basename.d.ts +36 -0
  158. package/dist/runtime/router-basename.d.ts.map +1 -0
  159. package/dist/runtime/router-basename.js +310 -0
  160. package/dist/runtime/ruby-green-threads.d.ts +136 -0
  161. package/dist/runtime/ruby-green-threads.d.ts.map +1 -0
  162. package/dist/runtime/ruby-green-threads.js +904 -0
  163. package/dist/runtime/ruby-socket-shim.d.ts +2 -0
  164. package/dist/runtime/ruby-socket-shim.d.ts.map +1 -0
  165. package/dist/runtime/ruby-socket-shim.js +548 -0
  166. package/dist/runtime/session-process-supervisor.d.ts +156 -0
  167. package/dist/runtime/session-process-supervisor.d.ts.map +1 -0
  168. package/dist/runtime/session-process-supervisor.js +238 -0
  169. package/dist/runtime/sqlite-runtime-fs-bridge.d.ts +70 -0
  170. package/dist/runtime/sqlite-runtime-fs-bridge.d.ts.map +1 -0
  171. package/dist/runtime/sqlite-runtime-fs-bridge.js +425 -0
  172. package/dist/runtime/streams.d.ts +13 -0
  173. package/dist/runtime/streams.d.ts.map +1 -0
  174. package/dist/runtime/streams.js +546 -0
  175. package/dist/runtime/undici-shim.d.ts +62 -0
  176. package/dist/runtime/undici-shim.d.ts.map +1 -0
  177. package/dist/runtime/undici-shim.js +516 -0
  178. package/dist/runtime/vfs-manifest.d.ts +63 -0
  179. package/dist/runtime/vfs-manifest.d.ts.map +1 -0
  180. package/dist/runtime/vfs-manifest.js +141 -0
  181. package/dist/runtime/vfs-snapshot.d.ts +75 -0
  182. package/dist/runtime/vfs-snapshot.d.ts.map +1 -0
  183. package/dist/runtime/vfs-snapshot.js +220 -0
  184. package/dist/runtime/virtual-socket-kernel.d.ts +252 -0
  185. package/dist/runtime/virtual-socket-kernel.d.ts.map +1 -0
  186. package/dist/runtime/virtual-socket-kernel.js +1143 -0
  187. package/dist/runtime/vite-config-parser.d.ts +13 -0
  188. package/dist/runtime/vite-config-parser.d.ts.map +1 -0
  189. package/dist/runtime/vite-config-parser.js +258 -0
  190. package/dist/runtime/wasi/types.d.ts +347 -0
  191. package/dist/runtime/wasi/types.d.ts.map +1 -0
  192. package/dist/runtime/wasi/types.js +1 -0
  193. package/dist/runtime/wasi-instance.d.ts +215 -0
  194. package/dist/runtime/wasi-instance.d.ts.map +1 -0
  195. package/dist/runtime/wasi-instance.generated.d.ts +14 -0
  196. package/dist/runtime/wasi-instance.generated.d.ts.map +1 -0
  197. package/dist/runtime/wasi-instance.generated.js +13 -0
  198. package/dist/runtime/wasi-instance.js +179 -0
  199. package/dist/runtime/wasi-threads.d.ts +169 -0
  200. package/dist/runtime/wasi-threads.d.ts.map +1 -0
  201. package/dist/runtime/wasi-threads.js +669 -0
  202. package/dist/runtime/wasm-memory.d.ts +84 -0
  203. package/dist/runtime/wasm-memory.d.ts.map +1 -0
  204. package/dist/runtime/wasm-memory.js +235 -0
  205. package/dist/shell/elevation-commands.d.ts +5 -0
  206. package/dist/shell/elevation-commands.d.ts.map +1 -0
  207. package/dist/shell/elevation-commands.js +109 -0
  208. package/dist/shell/exec-dispatch.d.ts +57 -0
  209. package/dist/shell/exec-dispatch.d.ts.map +1 -0
  210. package/dist/shell/exec-dispatch.js +181 -0
  211. package/dist/shell/features.d.ts +154 -0
  212. package/dist/shell/features.d.ts.map +1 -0
  213. package/dist/shell/features.js +792 -0
  214. package/dist/shell/shell-entrypoints.d.ts +55 -0
  215. package/dist/shell/shell-entrypoints.d.ts.map +1 -0
  216. package/dist/shell/shell-entrypoints.js +230 -0
  217. package/dist/shell/shell-invocation.d.ts +36 -0
  218. package/dist/shell/shell-invocation.d.ts.map +1 -0
  219. package/dist/shell/shell-invocation.js +148 -0
  220. package/dist/shell/unix-accounts.d.ts +27 -0
  221. package/dist/shell/unix-accounts.d.ts.map +1 -0
  222. package/dist/shell/unix-accounts.js +105 -0
  223. package/dist/shell/unix-commands.d.ts +15 -0
  224. package/dist/shell/unix-commands.d.ts.map +1 -0
  225. package/dist/shell/unix-commands.js +4702 -0
  226. package/dist/substrate/lifo/commands/archive/gunzip.d.ts +4 -0
  227. package/dist/substrate/lifo/commands/archive/gunzip.d.ts.map +1 -0
  228. package/dist/substrate/lifo/commands/archive/gunzip.js +58 -0
  229. package/dist/substrate/lifo/commands/archive/gzip.d.ts +4 -0
  230. package/dist/substrate/lifo/commands/archive/gzip.d.ts.map +1 -0
  231. package/dist/substrate/lifo/commands/archive/gzip.js +73 -0
  232. package/dist/substrate/lifo/commands/archive/tar.d.ts +4 -0
  233. package/dist/substrate/lifo/commands/archive/tar.d.ts.map +1 -0
  234. package/dist/substrate/lifo/commands/archive/tar.js +158 -0
  235. package/dist/substrate/lifo/commands/archive/unzip.d.ts +4 -0
  236. package/dist/substrate/lifo/commands/archive/unzip.d.ts.map +1 -0
  237. package/dist/substrate/lifo/commands/archive/unzip.js +114 -0
  238. package/dist/substrate/lifo/commands/archive/zip.d.ts +4 -0
  239. package/dist/substrate/lifo/commands/archive/zip.d.ts.map +1 -0
  240. package/dist/substrate/lifo/commands/archive/zip.js +58 -0
  241. package/dist/substrate/lifo/commands/fs/basename.d.ts +4 -0
  242. package/dist/substrate/lifo/commands/fs/basename.d.ts.map +1 -0
  243. package/dist/substrate/lifo/commands/fs/basename.js +12 -0
  244. package/dist/substrate/lifo/commands/fs/cat.d.ts +4 -0
  245. package/dist/substrate/lifo/commands/fs/cat.d.ts.map +1 -0
  246. package/dist/substrate/lifo/commands/fs/cat.js +52 -0
  247. package/dist/substrate/lifo/commands/fs/chmod.d.ts +25 -0
  248. package/dist/substrate/lifo/commands/fs/chmod.d.ts.map +1 -0
  249. package/dist/substrate/lifo/commands/fs/chmod.js +97 -0
  250. package/dist/substrate/lifo/commands/fs/chown.d.ts +4 -0
  251. package/dist/substrate/lifo/commands/fs/chown.d.ts.map +1 -0
  252. package/dist/substrate/lifo/commands/fs/chown.js +41 -0
  253. package/dist/substrate/lifo/commands/fs/cp.d.ts +4 -0
  254. package/dist/substrate/lifo/commands/fs/cp.d.ts.map +1 -0
  255. package/dist/substrate/lifo/commands/fs/cp.js +29 -0
  256. package/dist/substrate/lifo/commands/fs/df.d.ts +4 -0
  257. package/dist/substrate/lifo/commands/fs/df.d.ts.map +1 -0
  258. package/dist/substrate/lifo/commands/fs/df.js +52 -0
  259. package/dist/substrate/lifo/commands/fs/dirname.d.ts +4 -0
  260. package/dist/substrate/lifo/commands/fs/dirname.d.ts.map +1 -0
  261. package/dist/substrate/lifo/commands/fs/dirname.js +12 -0
  262. package/dist/substrate/lifo/commands/fs/du.d.ts +4 -0
  263. package/dist/substrate/lifo/commands/fs/du.d.ts.map +1 -0
  264. package/dist/substrate/lifo/commands/fs/du.js +104 -0
  265. package/dist/substrate/lifo/commands/fs/file.d.ts +4 -0
  266. package/dist/substrate/lifo/commands/fs/file.d.ts.map +1 -0
  267. package/dist/substrate/lifo/commands/fs/file.js +84 -0
  268. package/dist/substrate/lifo/commands/fs/find.d.ts +4 -0
  269. package/dist/substrate/lifo/commands/fs/find.d.ts.map +1 -0
  270. package/dist/substrate/lifo/commands/fs/find.js +72 -0
  271. package/dist/substrate/lifo/commands/fs/ln.d.ts +4 -0
  272. package/dist/substrate/lifo/commands/fs/ln.d.ts.map +1 -0
  273. package/dist/substrate/lifo/commands/fs/ln.js +15 -0
  274. package/dist/substrate/lifo/commands/fs/ls.d.ts +4 -0
  275. package/dist/substrate/lifo/commands/fs/ls.d.ts.map +1 -0
  276. package/dist/substrate/lifo/commands/fs/ls.js +146 -0
  277. package/dist/substrate/lifo/commands/fs/mkdir.d.ts +4 -0
  278. package/dist/substrate/lifo/commands/fs/mkdir.d.ts.map +1 -0
  279. package/dist/substrate/lifo/commands/fs/mkdir.js +31 -0
  280. package/dist/substrate/lifo/commands/fs/mktemp.d.ts +4 -0
  281. package/dist/substrate/lifo/commands/fs/mktemp.d.ts.map +1 -0
  282. package/dist/substrate/lifo/commands/fs/mktemp.js +48 -0
  283. package/dist/substrate/lifo/commands/fs/mv.d.ts +4 -0
  284. package/dist/substrate/lifo/commands/fs/mv.d.ts.map +1 -0
  285. package/dist/substrate/lifo/commands/fs/mv.js +113 -0
  286. package/dist/substrate/lifo/commands/fs/realpath.d.ts +4 -0
  287. package/dist/substrate/lifo/commands/fs/realpath.d.ts.map +1 -0
  288. package/dist/substrate/lifo/commands/fs/realpath.js +27 -0
  289. package/dist/substrate/lifo/commands/fs/rm.d.ts +4 -0
  290. package/dist/substrate/lifo/commands/fs/rm.d.ts.map +1 -0
  291. package/dist/substrate/lifo/commands/fs/rm.js +48 -0
  292. package/dist/substrate/lifo/commands/fs/rmdir.d.ts +4 -0
  293. package/dist/substrate/lifo/commands/fs/rmdir.d.ts.map +1 -0
  294. package/dist/substrate/lifo/commands/fs/rmdir.js +44 -0
  295. package/dist/substrate/lifo/commands/fs/stat.d.ts +4 -0
  296. package/dist/substrate/lifo/commands/fs/stat.d.ts.map +1 -0
  297. package/dist/substrate/lifo/commands/fs/stat.js +35 -0
  298. package/dist/substrate/lifo/commands/fs/touch.d.ts +4 -0
  299. package/dist/substrate/lifo/commands/fs/touch.d.ts.map +1 -0
  300. package/dist/substrate/lifo/commands/fs/touch.js +26 -0
  301. package/dist/substrate/lifo/commands/fs/tree.d.ts +4 -0
  302. package/dist/substrate/lifo/commands/fs/tree.d.ts.map +1 -0
  303. package/dist/substrate/lifo/commands/fs/tree.js +69 -0
  304. package/dist/substrate/lifo/commands/index.d.ts +3 -0
  305. package/dist/substrate/lifo/commands/index.d.ts.map +1 -0
  306. package/dist/substrate/lifo/commands/index.js +1 -0
  307. package/dist/substrate/lifo/commands/io/dd.d.ts +4 -0
  308. package/dist/substrate/lifo/commands/io/dd.d.ts.map +1 -0
  309. package/dist/substrate/lifo/commands/io/dd.js +256 -0
  310. package/dist/substrate/lifo/commands/io/printf.d.ts +4 -0
  311. package/dist/substrate/lifo/commands/io/printf.d.ts.map +1 -0
  312. package/dist/substrate/lifo/commands/io/printf.js +82 -0
  313. package/dist/substrate/lifo/commands/io/tee.d.ts +4 -0
  314. package/dist/substrate/lifo/commands/io/tee.d.ts.map +1 -0
  315. package/dist/substrate/lifo/commands/io/tee.js +31 -0
  316. package/dist/substrate/lifo/commands/io/xargs.d.ts +4 -0
  317. package/dist/substrate/lifo/commands/io/xargs.d.ts.map +1 -0
  318. package/dist/substrate/lifo/commands/io/xargs.js +44 -0
  319. package/dist/substrate/lifo/commands/io/yes.d.ts +4 -0
  320. package/dist/substrate/lifo/commands/io/yes.d.ts.map +1 -0
  321. package/dist/substrate/lifo/commands/io/yes.js +10 -0
  322. package/dist/substrate/lifo/commands/net/curl.d.ts +6 -0
  323. package/dist/substrate/lifo/commands/net/curl.d.ts.map +1 -0
  324. package/dist/substrate/lifo/commands/net/curl.js +617 -0
  325. package/dist/substrate/lifo/commands/net/dig.d.ts +4 -0
  326. package/dist/substrate/lifo/commands/net/dig.d.ts.map +1 -0
  327. package/dist/substrate/lifo/commands/net/dig.js +77 -0
  328. package/dist/substrate/lifo/commands/net/forward.d.ts +14 -0
  329. package/dist/substrate/lifo/commands/net/forward.d.ts.map +1 -0
  330. package/dist/substrate/lifo/commands/net/forward.js +80 -0
  331. package/dist/substrate/lifo/commands/net/host.d.ts +14 -0
  332. package/dist/substrate/lifo/commands/net/host.d.ts.map +1 -0
  333. package/dist/substrate/lifo/commands/net/host.js +160 -0
  334. package/dist/substrate/lifo/commands/net/ifconfig.d.ts +8 -0
  335. package/dist/substrate/lifo/commands/net/ifconfig.d.ts.map +1 -0
  336. package/dist/substrate/lifo/commands/net/ifconfig.js +120 -0
  337. package/dist/substrate/lifo/commands/net/ip.d.ts +14 -0
  338. package/dist/substrate/lifo/commands/net/ip.d.ts.map +1 -0
  339. package/dist/substrate/lifo/commands/net/ip.js +508 -0
  340. package/dist/substrate/lifo/commands/net/netstat.d.ts +8 -0
  341. package/dist/substrate/lifo/commands/net/netstat.d.ts.map +1 -0
  342. package/dist/substrate/lifo/commands/net/netstat.js +94 -0
  343. package/dist/substrate/lifo/commands/net/ping.d.ts +4 -0
  344. package/dist/substrate/lifo/commands/net/ping.d.ts.map +1 -0
  345. package/dist/substrate/lifo/commands/net/ping.js +64 -0
  346. package/dist/substrate/lifo/commands/net/ports.d.ts +8 -0
  347. package/dist/substrate/lifo/commands/net/ports.d.ts.map +1 -0
  348. package/dist/substrate/lifo/commands/net/ports.js +36 -0
  349. package/dist/substrate/lifo/commands/net/route.d.ts +8 -0
  350. package/dist/substrate/lifo/commands/net/route.d.ts.map +1 -0
  351. package/dist/substrate/lifo/commands/net/route.js +128 -0
  352. package/dist/substrate/lifo/commands/net/tunnel-v2.d.ts +4 -0
  353. package/dist/substrate/lifo/commands/net/tunnel-v2.d.ts.map +1 -0
  354. package/dist/substrate/lifo/commands/net/tunnel-v2.js +141 -0
  355. package/dist/substrate/lifo/commands/net/tunnel.d.ts +6 -0
  356. package/dist/substrate/lifo/commands/net/tunnel.d.ts.map +1 -0
  357. package/dist/substrate/lifo/commands/net/tunnel.js +232 -0
  358. package/dist/substrate/lifo/commands/net/wget.d.ts +4 -0
  359. package/dist/substrate/lifo/commands/net/wget.d.ts.map +1 -0
  360. package/dist/substrate/lifo/commands/net/wget.js +78 -0
  361. package/dist/substrate/lifo/commands/registry.d.ts +15 -0
  362. package/dist/substrate/lifo/commands/registry.d.ts.map +1 -0
  363. package/dist/substrate/lifo/commands/registry.js +120 -0
  364. package/dist/substrate/lifo/commands/signal.d.ts +12 -0
  365. package/dist/substrate/lifo/commands/signal.d.ts.map +1 -0
  366. package/dist/substrate/lifo/commands/signal.js +47 -0
  367. package/dist/substrate/lifo/commands/system/bc.d.ts +4 -0
  368. package/dist/substrate/lifo/commands/system/bc.d.ts.map +1 -0
  369. package/dist/substrate/lifo/commands/system/bc.js +243 -0
  370. package/dist/substrate/lifo/commands/system/cal.d.ts +4 -0
  371. package/dist/substrate/lifo/commands/system/cal.d.ts.map +1 -0
  372. package/dist/substrate/lifo/commands/system/cal.js +81 -0
  373. package/dist/substrate/lifo/commands/system/date.d.ts +4 -0
  374. package/dist/substrate/lifo/commands/system/date.d.ts.map +1 -0
  375. package/dist/substrate/lifo/commands/system/date.js +79 -0
  376. package/dist/substrate/lifo/commands/system/env.d.ts +4 -0
  377. package/dist/substrate/lifo/commands/system/env.d.ts.map +1 -0
  378. package/dist/substrate/lifo/commands/system/env.js +7 -0
  379. package/dist/substrate/lifo/commands/system/fastfetch.d.ts +4 -0
  380. package/dist/substrate/lifo/commands/system/fastfetch.d.ts.map +1 -0
  381. package/dist/substrate/lifo/commands/system/fastfetch.js +385 -0
  382. package/dist/substrate/lifo/commands/system/free.d.ts +4 -0
  383. package/dist/substrate/lifo/commands/system/free.d.ts.map +1 -0
  384. package/dist/substrate/lifo/commands/system/free.js +36 -0
  385. package/dist/substrate/lifo/commands/system/help.d.ts +4 -0
  386. package/dist/substrate/lifo/commands/system/help.d.ts.map +1 -0
  387. package/dist/substrate/lifo/commands/system/help.js +46 -0
  388. package/dist/substrate/lifo/commands/system/hostname.d.ts +4 -0
  389. package/dist/substrate/lifo/commands/system/hostname.d.ts.map +1 -0
  390. package/dist/substrate/lifo/commands/system/hostname.js +6 -0
  391. package/dist/substrate/lifo/commands/system/kill.d.ts +4 -0
  392. package/dist/substrate/lifo/commands/system/kill.d.ts.map +1 -0
  393. package/dist/substrate/lifo/commands/system/kill.js +76 -0
  394. package/dist/substrate/lifo/commands/system/lifo.d.ts +41 -0
  395. package/dist/substrate/lifo/commands/system/lifo.d.ts.map +1 -0
  396. package/dist/substrate/lifo/commands/system/lifo.js +446 -0
  397. package/dist/substrate/lifo/commands/system/logout.d.ts +5 -0
  398. package/dist/substrate/lifo/commands/system/logout.d.ts.map +1 -0
  399. package/dist/substrate/lifo/commands/system/logout.js +15 -0
  400. package/dist/substrate/lifo/commands/system/man.d.ts +4 -0
  401. package/dist/substrate/lifo/commands/system/man.d.ts.map +1 -0
  402. package/dist/substrate/lifo/commands/system/man.js +144 -0
  403. package/dist/substrate/lifo/commands/system/node.d.ts +6 -0
  404. package/dist/substrate/lifo/commands/system/node.d.ts.map +1 -0
  405. package/dist/substrate/lifo/commands/system/node.js +1241 -0
  406. package/dist/substrate/lifo/commands/system/npm.d.ts +26 -0
  407. package/dist/substrate/lifo/commands/system/npm.d.ts.map +1 -0
  408. package/dist/substrate/lifo/commands/system/npm.js +934 -0
  409. package/dist/substrate/lifo/commands/system/pkg.d.ts +4 -0
  410. package/dist/substrate/lifo/commands/system/pkg.d.ts.map +1 -0
  411. package/dist/substrate/lifo/commands/system/pkg.js +97 -0
  412. package/dist/substrate/lifo/commands/system/ps.d.ts +5 -0
  413. package/dist/substrate/lifo/commands/system/ps.d.ts.map +1 -0
  414. package/dist/substrate/lifo/commands/system/ps.js +35 -0
  415. package/dist/substrate/lifo/commands/system/registry-schemas.d.ts +44 -0
  416. package/dist/substrate/lifo/commands/system/registry-schemas.d.ts.map +1 -0
  417. package/dist/substrate/lifo/commands/system/registry-schemas.js +28 -0
  418. package/dist/substrate/lifo/commands/system/sha256sum.d.ts +4 -0
  419. package/dist/substrate/lifo/commands/system/sha256sum.d.ts.map +1 -0
  420. package/dist/substrate/lifo/commands/system/sha256sum.js +86 -0
  421. package/dist/substrate/lifo/commands/system/sl.d.ts +4 -0
  422. package/dist/substrate/lifo/commands/system/sl.d.ts.map +1 -0
  423. package/dist/substrate/lifo/commands/system/sl.js +204 -0
  424. package/dist/substrate/lifo/commands/system/sleep.d.ts +4 -0
  425. package/dist/substrate/lifo/commands/system/sleep.d.ts.map +1 -0
  426. package/dist/substrate/lifo/commands/system/sleep.js +27 -0
  427. package/dist/substrate/lifo/commands/system/stty.d.ts +4 -0
  428. package/dist/substrate/lifo/commands/system/stty.d.ts.map +1 -0
  429. package/dist/substrate/lifo/commands/system/stty.js +61 -0
  430. package/dist/substrate/lifo/commands/system/systemctl.d.ts +4 -0
  431. package/dist/substrate/lifo/commands/system/systemctl.d.ts.map +1 -0
  432. package/dist/substrate/lifo/commands/system/systemctl.js +164 -0
  433. package/dist/substrate/lifo/commands/system/top.d.ts +4 -0
  434. package/dist/substrate/lifo/commands/system/top.d.ts.map +1 -0
  435. package/dist/substrate/lifo/commands/system/top.js +38 -0
  436. package/dist/substrate/lifo/commands/system/uname.d.ts +4 -0
  437. package/dist/substrate/lifo/commands/system/uname.d.ts.map +1 -0
  438. package/dist/substrate/lifo/commands/system/uname.js +55 -0
  439. package/dist/substrate/lifo/commands/system/uptime.d.ts +4 -0
  440. package/dist/substrate/lifo/commands/system/uptime.d.ts.map +1 -0
  441. package/dist/substrate/lifo/commands/system/uptime.js +16 -0
  442. package/dist/substrate/lifo/commands/system/watch.d.ts +4 -0
  443. package/dist/substrate/lifo/commands/system/watch.d.ts.map +1 -0
  444. package/dist/substrate/lifo/commands/system/watch.js +53 -0
  445. package/dist/substrate/lifo/commands/system/which.d.ts +4 -0
  446. package/dist/substrate/lifo/commands/system/which.d.ts.map +1 -0
  447. package/dist/substrate/lifo/commands/system/which.js +45 -0
  448. package/dist/substrate/lifo/commands/system/whoami.d.ts +4 -0
  449. package/dist/substrate/lifo/commands/system/whoami.d.ts.map +1 -0
  450. package/dist/substrate/lifo/commands/system/whoami.js +6 -0
  451. package/dist/substrate/lifo/commands/text/awk.d.ts +4 -0
  452. package/dist/substrate/lifo/commands/text/awk.d.ts.map +1 -0
  453. package/dist/substrate/lifo/commands/text/awk.js +200 -0
  454. package/dist/substrate/lifo/commands/text/base64.d.ts +4 -0
  455. package/dist/substrate/lifo/commands/text/base64.d.ts.map +1 -0
  456. package/dist/substrate/lifo/commands/text/base64.js +102 -0
  457. package/dist/substrate/lifo/commands/text/cut.d.ts +4 -0
  458. package/dist/substrate/lifo/commands/text/cut.d.ts.map +1 -0
  459. package/dist/substrate/lifo/commands/text/cut.js +91 -0
  460. package/dist/substrate/lifo/commands/text/diff.d.ts +4 -0
  461. package/dist/substrate/lifo/commands/text/diff.d.ts.map +1 -0
  462. package/dist/substrate/lifo/commands/text/diff.js +292 -0
  463. package/dist/substrate/lifo/commands/text/grep.d.ts +4 -0
  464. package/dist/substrate/lifo/commands/text/grep.d.ts.map +1 -0
  465. package/dist/substrate/lifo/commands/text/grep.js +189 -0
  466. package/dist/substrate/lifo/commands/text/head.d.ts +4 -0
  467. package/dist/substrate/lifo/commands/text/head.d.ts.map +1 -0
  468. package/dist/substrate/lifo/commands/text/head.js +111 -0
  469. package/dist/substrate/lifo/commands/text/less.d.ts +4 -0
  470. package/dist/substrate/lifo/commands/text/less.d.ts.map +1 -0
  471. package/dist/substrate/lifo/commands/text/less.js +335 -0
  472. package/dist/substrate/lifo/commands/text/nano.d.ts +4 -0
  473. package/dist/substrate/lifo/commands/text/nano.d.ts.map +1 -0
  474. package/dist/substrate/lifo/commands/text/nano.js +510 -0
  475. package/dist/substrate/lifo/commands/text/nl.d.ts +4 -0
  476. package/dist/substrate/lifo/commands/text/nl.d.ts.map +1 -0
  477. package/dist/substrate/lifo/commands/text/nl.js +64 -0
  478. package/dist/substrate/lifo/commands/text/rev.d.ts +4 -0
  479. package/dist/substrate/lifo/commands/text/rev.d.ts.map +1 -0
  480. package/dist/substrate/lifo/commands/text/rev.js +41 -0
  481. package/dist/substrate/lifo/commands/text/sed.d.ts +21 -0
  482. package/dist/substrate/lifo/commands/text/sed.d.ts.map +1 -0
  483. package/dist/substrate/lifo/commands/text/sed.js +248 -0
  484. package/dist/substrate/lifo/commands/text/seq.d.ts +4 -0
  485. package/dist/substrate/lifo/commands/text/seq.d.ts.map +1 -0
  486. package/dist/substrate/lifo/commands/text/seq.js +69 -0
  487. package/dist/substrate/lifo/commands/text/sort.d.ts +4 -0
  488. package/dist/substrate/lifo/commands/text/sort.d.ts.map +1 -0
  489. package/dist/substrate/lifo/commands/text/sort.js +90 -0
  490. package/dist/substrate/lifo/commands/text/strings.d.ts +4 -0
  491. package/dist/substrate/lifo/commands/text/strings.d.ts.map +1 -0
  492. package/dist/substrate/lifo/commands/text/strings.js +69 -0
  493. package/dist/substrate/lifo/commands/text/tac.d.ts +4 -0
  494. package/dist/substrate/lifo/commands/text/tac.d.ts.map +1 -0
  495. package/dist/substrate/lifo/commands/text/tac.js +32 -0
  496. package/dist/substrate/lifo/commands/text/tail.d.ts +4 -0
  497. package/dist/substrate/lifo/commands/text/tail.d.ts.map +1 -0
  498. package/dist/substrate/lifo/commands/text/tail.js +64 -0
  499. package/dist/substrate/lifo/commands/text/tr.d.ts +4 -0
  500. package/dist/substrate/lifo/commands/text/tr.d.ts.map +1 -0
  501. package/dist/substrate/lifo/commands/text/tr.js +180 -0
  502. package/dist/substrate/lifo/commands/text/uniq.d.ts +4 -0
  503. package/dist/substrate/lifo/commands/text/uniq.d.ts.map +1 -0
  504. package/dist/substrate/lifo/commands/text/uniq.js +82 -0
  505. package/dist/substrate/lifo/commands/text/wc.d.ts +4 -0
  506. package/dist/substrate/lifo/commands/text/wc.d.ts.map +1 -0
  507. package/dist/substrate/lifo/commands/text/wc.js +107 -0
  508. package/dist/substrate/lifo/commands/types.d.ts +49 -0
  509. package/dist/substrate/lifo/commands/types.d.ts.map +1 -0
  510. package/dist/substrate/lifo/commands/types.js +1 -0
  511. package/dist/substrate/lifo/index.d.ts +67 -0
  512. package/dist/substrate/lifo/index.d.ts.map +1 -0
  513. package/dist/substrate/lifo/index.js +66 -0
  514. package/dist/substrate/lifo/kernel/ServiceManager.d.ts +51 -0
  515. package/dist/substrate/lifo/kernel/ServiceManager.d.ts.map +1 -0
  516. package/dist/substrate/lifo/kernel/ServiceManager.js +302 -0
  517. package/dist/substrate/lifo/kernel/index.d.ts +40 -0
  518. package/dist/substrate/lifo/kernel/index.d.ts.map +1 -0
  519. package/dist/substrate/lifo/kernel/index.js +170 -0
  520. package/dist/substrate/lifo/kernel/network/Bridge.d.ts +110 -0
  521. package/dist/substrate/lifo/kernel/network/Bridge.d.ts.map +1 -0
  522. package/dist/substrate/lifo/kernel/network/Bridge.js +278 -0
  523. package/dist/substrate/lifo/kernel/network/DNSResolver.d.ts +50 -0
  524. package/dist/substrate/lifo/kernel/network/DNSResolver.d.ts.map +1 -0
  525. package/dist/substrate/lifo/kernel/network/DNSResolver.js +135 -0
  526. package/dist/substrate/lifo/kernel/network/NetworkInterface.d.ts +83 -0
  527. package/dist/substrate/lifo/kernel/network/NetworkInterface.d.ts.map +1 -0
  528. package/dist/substrate/lifo/kernel/network/NetworkInterface.js +183 -0
  529. package/dist/substrate/lifo/kernel/network/NetworkNamespace.d.ts +98 -0
  530. package/dist/substrate/lifo/kernel/network/NetworkNamespace.d.ts.map +1 -0
  531. package/dist/substrate/lifo/kernel/network/NetworkNamespace.js +149 -0
  532. package/dist/substrate/lifo/kernel/network/NetworkStack.d.ts +178 -0
  533. package/dist/substrate/lifo/kernel/network/NetworkStack.d.ts.map +1 -0
  534. package/dist/substrate/lifo/kernel/network/NetworkStack.js +460 -0
  535. package/dist/substrate/lifo/kernel/network/PortBridge.d.ts +44 -0
  536. package/dist/substrate/lifo/kernel/network/PortBridge.d.ts.map +1 -0
  537. package/dist/substrate/lifo/kernel/network/PortBridge.js +158 -0
  538. package/dist/substrate/lifo/kernel/network/RoutingTable.d.ts +55 -0
  539. package/dist/substrate/lifo/kernel/network/RoutingTable.d.ts.map +1 -0
  540. package/dist/substrate/lifo/kernel/network/RoutingTable.js +167 -0
  541. package/dist/substrate/lifo/kernel/network/Socket.d.ts +65 -0
  542. package/dist/substrate/lifo/kernel/network/Socket.d.ts.map +1 -0
  543. package/dist/substrate/lifo/kernel/network/Socket.js +201 -0
  544. package/dist/substrate/lifo/kernel/network/index.d.ts +11 -0
  545. package/dist/substrate/lifo/kernel/network/index.d.ts.map +1 -0
  546. package/dist/substrate/lifo/kernel/network/index.js +9 -0
  547. package/dist/substrate/lifo/kernel/network/tunnel/BaseTunnel.d.ts +55 -0
  548. package/dist/substrate/lifo/kernel/network/tunnel/BaseTunnel.d.ts.map +1 -0
  549. package/dist/substrate/lifo/kernel/network/tunnel/BaseTunnel.js +88 -0
  550. package/dist/substrate/lifo/kernel/network/tunnel/VETHPair.d.ts +71 -0
  551. package/dist/substrate/lifo/kernel/network/tunnel/VETHPair.d.ts.map +1 -0
  552. package/dist/substrate/lifo/kernel/network/tunnel/VETHPair.js +191 -0
  553. package/dist/substrate/lifo/kernel/network/tunnel/WebSocketTunnel.d.ts +89 -0
  554. package/dist/substrate/lifo/kernel/network/tunnel/WebSocketTunnel.d.ts.map +1 -0
  555. package/dist/substrate/lifo/kernel/network/tunnel/WebSocketTunnel.js +324 -0
  556. package/dist/substrate/lifo/kernel/network/types.d.ts +159 -0
  557. package/dist/substrate/lifo/kernel/network/types.d.ts.map +1 -0
  558. package/dist/substrate/lifo/kernel/network/types.js +5 -0
  559. package/dist/substrate/lifo/kernel/persistence/PersistenceManager.d.ts +12 -0
  560. package/dist/substrate/lifo/kernel/persistence/PersistenceManager.d.ts.map +1 -0
  561. package/dist/substrate/lifo/kernel/persistence/PersistenceManager.js +47 -0
  562. package/dist/substrate/lifo/kernel/persistence/backends.d.ts +15 -0
  563. package/dist/substrate/lifo/kernel/persistence/backends.d.ts.map +1 -0
  564. package/dist/substrate/lifo/kernel/persistence/backends.js +18 -0
  565. package/dist/substrate/lifo/kernel/persistence/index.d.ts +6 -0
  566. package/dist/substrate/lifo/kernel/persistence/index.d.ts.map +1 -0
  567. package/dist/substrate/lifo/kernel/persistence/index.js +3 -0
  568. package/dist/substrate/lifo/kernel/persistence/serializer.d.ts +21 -0
  569. package/dist/substrate/lifo/kernel/persistence/serializer.d.ts.map +1 -0
  570. package/dist/substrate/lifo/kernel/persistence/serializer.js +99 -0
  571. package/dist/substrate/lifo/kernel/samples.d.ts +3 -0
  572. package/dist/substrate/lifo/kernel/samples.d.ts.map +1 -0
  573. package/dist/substrate/lifo/kernel/samples.js +930 -0
  574. package/dist/substrate/lifo/kernel/storage/BlobStore.d.ts +22 -0
  575. package/dist/substrate/lifo/kernel/storage/BlobStore.d.ts.map +1 -0
  576. package/dist/substrate/lifo/kernel/storage/BlobStore.js +84 -0
  577. package/dist/substrate/lifo/kernel/storage/ContentStore.d.ts +54 -0
  578. package/dist/substrate/lifo/kernel/storage/ContentStore.d.ts.map +1 -0
  579. package/dist/substrate/lifo/kernel/storage/ContentStore.js +120 -0
  580. package/dist/substrate/lifo/kernel/storage/index.d.ts +6 -0
  581. package/dist/substrate/lifo/kernel/storage/index.d.ts.map +1 -0
  582. package/dist/substrate/lifo/kernel/storage/index.js +3 -0
  583. package/dist/substrate/lifo/kernel/unit-parser.d.ts +22 -0
  584. package/dist/substrate/lifo/kernel/unit-parser.d.ts.map +1 -0
  585. package/dist/substrate/lifo/kernel/unit-parser.js +80 -0
  586. package/dist/substrate/lifo/kernel/vfs/VFS.d.ts +99 -0
  587. package/dist/substrate/lifo/kernel/vfs/VFS.d.ts.map +1 -0
  588. package/dist/substrate/lifo/kernel/vfs/VFS.js +679 -0
  589. package/dist/substrate/lifo/kernel/vfs/index.d.ts +8 -0
  590. package/dist/substrate/lifo/kernel/vfs/index.d.ts.map +1 -0
  591. package/dist/substrate/lifo/kernel/vfs/index.js +5 -0
  592. package/dist/substrate/lifo/kernel/vfs/providers/DevProvider.d.ts +21 -0
  593. package/dist/substrate/lifo/kernel/vfs/providers/DevProvider.d.ts.map +1 -0
  594. package/dist/substrate/lifo/kernel/vfs/providers/DevProvider.js +137 -0
  595. package/dist/substrate/lifo/kernel/vfs/providers/NativeFsProvider.d.ts +63 -0
  596. package/dist/substrate/lifo/kernel/vfs/providers/NativeFsProvider.d.ts.map +1 -0
  597. package/dist/substrate/lifo/kernel/vfs/providers/NativeFsProvider.js +175 -0
  598. package/dist/substrate/lifo/kernel/vfs/providers/ProcProvider.d.ts +14 -0
  599. package/dist/substrate/lifo/kernel/vfs/providers/ProcProvider.d.ts.map +1 -0
  600. package/dist/substrate/lifo/kernel/vfs/providers/ProcProvider.js +126 -0
  601. package/dist/substrate/lifo/kernel/vfs/types.d.ts +117 -0
  602. package/dist/substrate/lifo/kernel/vfs/types.d.ts.map +1 -0
  603. package/dist/substrate/lifo/kernel/vfs/types.js +42 -0
  604. package/dist/substrate/lifo/node-compat/buffer.d.ts +44 -0
  605. package/dist/substrate/lifo/node-compat/buffer.d.ts.map +1 -0
  606. package/dist/substrate/lifo/node-compat/buffer.js +331 -0
  607. package/dist/substrate/lifo/node-compat/child_process.d.ts +10 -0
  608. package/dist/substrate/lifo/node-compat/child_process.d.ts.map +1 -0
  609. package/dist/substrate/lifo/node-compat/child_process.js +42 -0
  610. package/dist/substrate/lifo/node-compat/console.d.ts +21 -0
  611. package/dist/substrate/lifo/node-compat/console.d.ts.map +1 -0
  612. package/dist/substrate/lifo/node-compat/console.js +68 -0
  613. package/dist/substrate/lifo/node-compat/crypto.d.ts +24 -0
  614. package/dist/substrate/lifo/node-compat/crypto.d.ts.map +1 -0
  615. package/dist/substrate/lifo/node-compat/crypto.js +216 -0
  616. package/dist/substrate/lifo/node-compat/dns.d.ts +117 -0
  617. package/dist/substrate/lifo/node-compat/dns.d.ts.map +1 -0
  618. package/dist/substrate/lifo/node-compat/dns.js +144 -0
  619. package/dist/substrate/lifo/node-compat/esbuild.d.ts +10 -0
  620. package/dist/substrate/lifo/node-compat/esbuild.d.ts.map +1 -0
  621. package/dist/substrate/lifo/node-compat/esbuild.js +70 -0
  622. package/dist/substrate/lifo/node-compat/events.d.ts +19 -0
  623. package/dist/substrate/lifo/node-compat/events.d.ts.map +1 -0
  624. package/dist/substrate/lifo/node-compat/events.js +83 -0
  625. package/dist/substrate/lifo/node-compat/fs.d.ts +195 -0
  626. package/dist/substrate/lifo/node-compat/fs.d.ts.map +1 -0
  627. package/dist/substrate/lifo/node-compat/fs.js +624 -0
  628. package/dist/substrate/lifo/node-compat/http.d.ts +133 -0
  629. package/dist/substrate/lifo/node-compat/http.d.ts.map +1 -0
  630. package/dist/substrate/lifo/node-compat/http.js +452 -0
  631. package/dist/substrate/lifo/node-compat/index.d.ts +20 -0
  632. package/dist/substrate/lifo/node-compat/index.d.ts.map +1 -0
  633. package/dist/substrate/lifo/node-compat/index.js +291 -0
  634. package/dist/substrate/lifo/node-compat/module.d.ts +55 -0
  635. package/dist/substrate/lifo/node-compat/module.d.ts.map +1 -0
  636. package/dist/substrate/lifo/node-compat/module.js +124 -0
  637. package/dist/substrate/lifo/node-compat/os.d.ts +39 -0
  638. package/dist/substrate/lifo/node-compat/os.d.ts.map +1 -0
  639. package/dist/substrate/lifo/node-compat/os.js +45 -0
  640. package/dist/substrate/lifo/node-compat/path.d.ts +86 -0
  641. package/dist/substrate/lifo/node-compat/path.d.ts.map +1 -0
  642. package/dist/substrate/lifo/node-compat/path.js +49 -0
  643. package/dist/substrate/lifo/node-compat/process.d.ts +127 -0
  644. package/dist/substrate/lifo/node-compat/process.d.ts.map +1 -0
  645. package/dist/substrate/lifo/node-compat/process.js +173 -0
  646. package/dist/substrate/lifo/node-compat/readline.d.ts +85 -0
  647. package/dist/substrate/lifo/node-compat/readline.d.ts.map +1 -0
  648. package/dist/substrate/lifo/node-compat/readline.js +205 -0
  649. package/dist/substrate/lifo/node-compat/rimraf.d.ts +30 -0
  650. package/dist/substrate/lifo/node-compat/rimraf.d.ts.map +1 -0
  651. package/dist/substrate/lifo/node-compat/rimraf.js +63 -0
  652. package/dist/substrate/lifo/node-compat/stream.d.ts +36 -0
  653. package/dist/substrate/lifo/node-compat/stream.d.ts.map +1 -0
  654. package/dist/substrate/lifo/node-compat/stream.js +90 -0
  655. package/dist/substrate/lifo/node-compat/string_decoder.d.ts +11 -0
  656. package/dist/substrate/lifo/node-compat/string_decoder.d.ts.map +1 -0
  657. package/dist/substrate/lifo/node-compat/string_decoder.js +23 -0
  658. package/dist/substrate/lifo/node-compat/timers.d.ts +16 -0
  659. package/dist/substrate/lifo/node-compat/timers.d.ts.map +1 -0
  660. package/dist/substrate/lifo/node-compat/timers.js +18 -0
  661. package/dist/substrate/lifo/node-compat/tty.d.ts +32 -0
  662. package/dist/substrate/lifo/node-compat/tty.d.ts.map +1 -0
  663. package/dist/substrate/lifo/node-compat/tty.js +76 -0
  664. package/dist/substrate/lifo/node-compat/url.d.ts +37 -0
  665. package/dist/substrate/lifo/node-compat/url.d.ts.map +1 -0
  666. package/dist/substrate/lifo/node-compat/url.js +65 -0
  667. package/dist/substrate/lifo/node-compat/util.d.ts +42 -0
  668. package/dist/substrate/lifo/node-compat/util.d.ts.map +1 -0
  669. package/dist/substrate/lifo/node-compat/util.js +132 -0
  670. package/dist/substrate/lifo/node-compat/zlib.d.ts +66 -0
  671. package/dist/substrate/lifo/node-compat/zlib.d.ts.map +1 -0
  672. package/dist/substrate/lifo/node-compat/zlib.js +80 -0
  673. package/dist/substrate/lifo/pkg/PackageManager.d.ts +19 -0
  674. package/dist/substrate/lifo/pkg/PackageManager.d.ts.map +1 -0
  675. package/dist/substrate/lifo/pkg/PackageManager.js +97 -0
  676. package/dist/substrate/lifo/pkg/lifo-dev.d.ts +38 -0
  677. package/dist/substrate/lifo/pkg/lifo-dev.d.ts.map +1 -0
  678. package/dist/substrate/lifo/pkg/lifo-dev.js +98 -0
  679. package/dist/substrate/lifo/pkg/lifo-runtime.d.ts +44 -0
  680. package/dist/substrate/lifo/pkg/lifo-runtime.d.ts.map +1 -0
  681. package/dist/substrate/lifo/pkg/lifo-runtime.js +372 -0
  682. package/dist/substrate/lifo/pkg/loader.d.ts +4 -0
  683. package/dist/substrate/lifo/pkg/loader.d.ts.map +1 -0
  684. package/dist/substrate/lifo/pkg/loader.js +24 -0
  685. package/dist/substrate/lifo/sandbox/HeadlessTerminal.d.ts +18 -0
  686. package/dist/substrate/lifo/sandbox/HeadlessTerminal.d.ts.map +1 -0
  687. package/dist/substrate/lifo/sandbox/HeadlessTerminal.js +28 -0
  688. package/dist/substrate/lifo/sandbox/Sandbox.d.ts +59 -0
  689. package/dist/substrate/lifo/sandbox/Sandbox.d.ts.map +1 -0
  690. package/dist/substrate/lifo/sandbox/Sandbox.js +234 -0
  691. package/dist/substrate/lifo/sandbox/SandboxCommands.d.ts +18 -0
  692. package/dist/substrate/lifo/sandbox/SandboxCommands.d.ts.map +1 -0
  693. package/dist/substrate/lifo/sandbox/SandboxCommands.js +64 -0
  694. package/dist/substrate/lifo/sandbox/SandboxFs.d.ts +43 -0
  695. package/dist/substrate/lifo/sandbox/SandboxFs.d.ts.map +1 -0
  696. package/dist/substrate/lifo/sandbox/SandboxFs.js +136 -0
  697. package/dist/substrate/lifo/sandbox/index.d.ts +3 -0
  698. package/dist/substrate/lifo/sandbox/index.d.ts.map +1 -0
  699. package/dist/substrate/lifo/sandbox/index.js +1 -0
  700. package/dist/substrate/lifo/sandbox/types.d.ts +116 -0
  701. package/dist/substrate/lifo/sandbox/types.d.ts.map +1 -0
  702. package/dist/substrate/lifo/sandbox/types.js +1 -0
  703. package/dist/substrate/lifo/shell/ProcessRegistry.d.ts +142 -0
  704. package/dist/substrate/lifo/shell/ProcessRegistry.d.ts.map +1 -0
  705. package/dist/substrate/lifo/shell/ProcessRegistry.js +256 -0
  706. package/dist/substrate/lifo/shell/Shell.d.ts +170 -0
  707. package/dist/substrate/lifo/shell/Shell.d.ts.map +1 -0
  708. package/dist/substrate/lifo/shell/Shell.js +1863 -0
  709. package/dist/substrate/lifo/shell/completer.d.ts +19 -0
  710. package/dist/substrate/lifo/shell/completer.d.ts.map +1 -0
  711. package/dist/substrate/lifo/shell/completer.js +164 -0
  712. package/dist/substrate/lifo/shell/default-shell.d.ts +9 -0
  713. package/dist/substrate/lifo/shell/default-shell.d.ts.map +1 -0
  714. package/dist/substrate/lifo/shell/default-shell.js +53 -0
  715. package/dist/substrate/lifo/shell/expander.d.ts +48 -0
  716. package/dist/substrate/lifo/shell/expander.d.ts.map +1 -0
  717. package/dist/substrate/lifo/shell/expander.js +1204 -0
  718. package/dist/substrate/lifo/shell/history.d.ts +22 -0
  719. package/dist/substrate/lifo/shell/history.d.ts.map +1 -0
  720. package/dist/substrate/lifo/shell/history.js +121 -0
  721. package/dist/substrate/lifo/shell/interpreter.d.ts +257 -0
  722. package/dist/substrate/lifo/shell/interpreter.d.ts.map +1 -0
  723. package/dist/substrate/lifo/shell/interpreter.js +1490 -0
  724. package/dist/substrate/lifo/shell/jobs.d.ts +21 -0
  725. package/dist/substrate/lifo/shell/jobs.d.ts.map +1 -0
  726. package/dist/substrate/lifo/shell/jobs.js +48 -0
  727. package/dist/substrate/lifo/shell/lexer.d.ts +13 -0
  728. package/dist/substrate/lifo/shell/lexer.d.ts.map +1 -0
  729. package/dist/substrate/lifo/shell/lexer.js +614 -0
  730. package/dist/substrate/lifo/shell/parser.d.ts +7 -0
  731. package/dist/substrate/lifo/shell/parser.d.ts.map +1 -0
  732. package/dist/substrate/lifo/shell/parser.js +573 -0
  733. package/dist/substrate/lifo/shell/pipe.d.ts +15 -0
  734. package/dist/substrate/lifo/shell/pipe.d.ts.map +1 -0
  735. package/dist/substrate/lifo/shell/pipe.js +86 -0
  736. package/dist/substrate/lifo/shell/signals.d.ts +11 -0
  737. package/dist/substrate/lifo/shell/signals.d.ts.map +1 -0
  738. package/dist/substrate/lifo/shell/signals.js +57 -0
  739. package/dist/substrate/lifo/shell/terminal-stdin.d.ts +28 -0
  740. package/dist/substrate/lifo/shell/terminal-stdin.d.ts.map +1 -0
  741. package/dist/substrate/lifo/shell/terminal-stdin.js +100 -0
  742. package/dist/substrate/lifo/shell/test-builtin.d.ts +16 -0
  743. package/dist/substrate/lifo/shell/test-builtin.d.ts.map +1 -0
  744. package/dist/substrate/lifo/shell/test-builtin.js +237 -0
  745. package/dist/substrate/lifo/shell/types.d.ts +140 -0
  746. package/dist/substrate/lifo/shell/types.d.ts.map +1 -0
  747. package/dist/substrate/lifo/shell/types.js +25 -0
  748. package/dist/substrate/lifo/terminal/ITerminal.d.ts +10 -0
  749. package/dist/substrate/lifo/terminal/ITerminal.d.ts.map +1 -0
  750. package/dist/substrate/lifo/terminal/ITerminal.js +1 -0
  751. package/dist/substrate/lifo/utils/archive.d.ts +28 -0
  752. package/dist/substrate/lifo/utils/archive.d.ts.map +1 -0
  753. package/dist/substrate/lifo/utils/archive.js +323 -0
  754. package/dist/substrate/lifo/utils/args.d.ts +18 -0
  755. package/dist/substrate/lifo/utils/args.d.ts.map +1 -0
  756. package/dist/substrate/lifo/utils/args.js +73 -0
  757. package/dist/substrate/lifo/utils/colors.d.ts +27 -0
  758. package/dist/substrate/lifo/utils/colors.d.ts.map +1 -0
  759. package/dist/substrate/lifo/utils/colors.js +26 -0
  760. package/dist/substrate/lifo/utils/encoding.d.ts +4 -0
  761. package/dist/substrate/lifo/utils/encoding.d.ts.map +1 -0
  762. package/dist/substrate/lifo/utils/encoding.js +18 -0
  763. package/dist/substrate/lifo/utils/glob.d.ts +12 -0
  764. package/dist/substrate/lifo/utils/glob.d.ts.map +1 -0
  765. package/dist/substrate/lifo/utils/glob.js +150 -0
  766. package/dist/substrate/lifo/utils/mime.d.ts +4 -0
  767. package/dist/substrate/lifo/utils/mime.d.ts.map +1 -0
  768. package/dist/substrate/lifo/utils/mime.js +107 -0
  769. package/dist/substrate/lifo/utils/path.d.ts +12 -0
  770. package/dist/substrate/lifo/utils/path.d.ts.map +1 -0
  771. package/dist/substrate/lifo/utils/path.js +82 -0
  772. package/dist/vfs/events.d.ts +51 -0
  773. package/dist/vfs/events.d.ts.map +1 -0
  774. package/dist/vfs/events.js +127 -0
  775. package/dist/vfs/path.d.ts +46 -0
  776. package/dist/vfs/path.d.ts.map +1 -0
  777. package/dist/vfs/path.js +69 -0
  778. package/dist/vfs/seed-project.d.ts +62 -0
  779. package/dist/vfs/seed-project.d.ts.map +1 -0
  780. package/dist/vfs/seed-project.js +1054 -0
  781. package/dist/vfs/sqlite-vfs.d.ts +821 -0
  782. package/dist/vfs/sqlite-vfs.d.ts.map +1 -0
  783. package/dist/vfs/sqlite-vfs.js +4135 -0
  784. package/dist/vfs/symlink-registry.d.ts +60 -0
  785. package/dist/vfs/symlink-registry.d.ts.map +1 -0
  786. package/dist/vfs/symlink-registry.js +162 -0
  787. package/dist/workspace/nimbus-workspace.d.ts +94 -0
  788. package/dist/workspace/nimbus-workspace.d.ts.map +1 -0
  789. package/dist/workspace/nimbus-workspace.js +167 -0
  790. package/package.json +69 -0
  791. package/src/_shared/ai-egress.ts +91 -0
  792. package/src/_shared/byte-stream.ts +97 -0
  793. package/src/_shared/bytes.ts +19 -0
  794. package/src/_shared/cache-stats.ts +231 -0
  795. package/src/_shared/crypto.ts +184 -0
  796. package/src/_shared/esbuild-facet-shim.ts +22 -0
  797. package/src/_shared/exports-resolver.ts +308 -0
  798. package/src/_shared/facet-vfs-cursor.ts +58 -0
  799. package/src/_shared/install-phase.ts +56 -0
  800. package/src/_shared/lru-map.ts +59 -0
  801. package/src/_shared/real-node-imports.ts +53 -0
  802. package/src/_shared/retry.ts +202 -0
  803. package/src/_shared/rpc-dispose.ts +31 -0
  804. package/src/_shared/terminal.ts +3 -0
  805. package/src/_shared/typescript-specifiers.ts +86 -0
  806. package/src/_shared/untrusted-request.ts +75 -0
  807. package/src/_shared/vfs-write-ledger.ts +440 -0
  808. package/src/_shared/w7-frame.ts +1012 -0
  809. package/src/_shared/weighted-credit-pool.ts +244 -0
  810. package/src/constants.ts +285 -0
  811. package/src/index.ts +22 -0
  812. package/src/observability/diag-counters.ts +343 -0
  813. package/src/observability/heap-estimate.ts +331 -0
  814. package/src/observability/heavy-alloc-coord.ts +241 -0
  815. package/src/observability/oom-classify.ts +253 -0
  816. package/src/observability/oom-discriminator.ts +405 -0
  817. package/src/runtime/assets-loader.ts +189 -0
  818. package/src/runtime/barrel-detect.ts +69 -0
  819. package/src/runtime/bash/preamble.ts +1519 -0
  820. package/src/runtime/bash/types.ts +497 -0
  821. package/src/runtime/bundle-profile.ts +32 -0
  822. package/src/runtime/cirrus-vite-config-rewriter.ts +28 -0
  823. package/src/runtime/cli-flags.ts +11 -0
  824. package/src/runtime/comment-strip.ts +73 -0
  825. package/src/runtime/cpython-preamble.ts +298 -0
  826. package/src/runtime/esbuild-service.ts +1470 -0
  827. package/src/runtime/framework-detect.ts +245 -0
  828. package/src/runtime/import-meta-transform.ts +16 -0
  829. package/src/runtime/javascript-ast.ts +66 -0
  830. package/src/runtime/long-running-handle.ts +185 -0
  831. package/src/runtime/module-source-rewriter.ts +95 -0
  832. package/src/runtime/opentui-wasm-backend.ts +608 -0
  833. package/src/runtime/os-contracts.ts +529 -0
  834. package/src/runtime/port-registry.ts +298 -0
  835. package/src/runtime/process-input-routing.ts +92 -0
  836. package/src/runtime/process-input.ts +148 -0
  837. package/src/runtime/process-io-protocol.ts +97 -0
  838. package/src/runtime/process-logs.ts +882 -0
  839. package/src/runtime/process-table.ts +225 -0
  840. package/src/runtime/project-detect.ts +42 -0
  841. package/src/runtime/python-server-adapter.ts +133 -0
  842. package/src/runtime/require-resolver.ts +760 -0
  843. package/src/runtime/router-basename.ts +279 -0
  844. package/src/runtime/ruby-green-threads.ts +904 -0
  845. package/src/runtime/ruby-socket-shim.ts +548 -0
  846. package/src/runtime/session-process-supervisor.ts +323 -0
  847. package/src/runtime/sqlite-runtime-fs-bridge.ts +468 -0
  848. package/src/runtime/streams.ts +547 -0
  849. package/src/runtime/undici-shim.ts +517 -0
  850. package/src/runtime/vfs-manifest.ts +170 -0
  851. package/src/runtime/vfs-snapshot.ts +273 -0
  852. package/src/runtime/virtual-socket-kernel.ts +1370 -0
  853. package/src/runtime/vite-config-parser.ts +273 -0
  854. package/src/runtime/wasi/types.ts +448 -0
  855. package/src/runtime/wasi-instance.generated.ts +14 -0
  856. package/src/runtime/wasi-instance.ts +259 -0
  857. package/src/runtime/wasi-threads.ts +682 -0
  858. package/src/runtime/wasm-memory.ts +261 -0
  859. package/src/shell/elevation-commands.ts +117 -0
  860. package/src/shell/exec-dispatch.ts +201 -0
  861. package/src/shell/features.ts +870 -0
  862. package/src/shell/shell-entrypoints.ts +323 -0
  863. package/src/shell/shell-invocation.ts +181 -0
  864. package/src/shell/unix-accounts.ts +128 -0
  865. package/src/shell/unix-commands.ts +4335 -0
  866. package/src/substrate/lifo/UPSTREAM.md +14 -0
  867. package/src/substrate/lifo/commands/archive/gunzip.ts +63 -0
  868. package/src/substrate/lifo/commands/archive/gzip.ts +76 -0
  869. package/src/substrate/lifo/commands/archive/tar.ts +157 -0
  870. package/src/substrate/lifo/commands/archive/unzip.ts +112 -0
  871. package/src/substrate/lifo/commands/archive/zip.ts +70 -0
  872. package/src/substrate/lifo/commands/fs/basename.ts +16 -0
  873. package/src/substrate/lifo/commands/fs/cat.ts +54 -0
  874. package/src/substrate/lifo/commands/fs/chmod.ts +110 -0
  875. package/src/substrate/lifo/commands/fs/chown.ts +45 -0
  876. package/src/substrate/lifo/commands/fs/cp.ts +33 -0
  877. package/src/substrate/lifo/commands/fs/df.ts +56 -0
  878. package/src/substrate/lifo/commands/fs/dirname.ts +16 -0
  879. package/src/substrate/lifo/commands/fs/du.ts +100 -0
  880. package/src/substrate/lifo/commands/fs/file.ts +90 -0
  881. package/src/substrate/lifo/commands/fs/find.ts +76 -0
  882. package/src/substrate/lifo/commands/fs/ln.ts +19 -0
  883. package/src/substrate/lifo/commands/fs/ls.ts +164 -0
  884. package/src/substrate/lifo/commands/fs/mkdir.ts +37 -0
  885. package/src/substrate/lifo/commands/fs/mktemp.ts +56 -0
  886. package/src/substrate/lifo/commands/fs/mv.ts +111 -0
  887. package/src/substrate/lifo/commands/fs/realpath.ts +31 -0
  888. package/src/substrate/lifo/commands/fs/rm.ts +53 -0
  889. package/src/substrate/lifo/commands/fs/rmdir.ts +50 -0
  890. package/src/substrate/lifo/commands/fs/stat.ts +39 -0
  891. package/src/substrate/lifo/commands/fs/touch.ts +30 -0
  892. package/src/substrate/lifo/commands/fs/tree.ts +76 -0
  893. package/src/substrate/lifo/commands/index.ts +2 -0
  894. package/src/substrate/lifo/commands/io/dd.ts +289 -0
  895. package/src/substrate/lifo/commands/io/printf.ts +78 -0
  896. package/src/substrate/lifo/commands/io/tee.ts +37 -0
  897. package/src/substrate/lifo/commands/io/xargs.ts +49 -0
  898. package/src/substrate/lifo/commands/io/yes.ts +15 -0
  899. package/src/substrate/lifo/commands/net/curl.ts +739 -0
  900. package/src/substrate/lifo/commands/net/dig.ts +99 -0
  901. package/src/substrate/lifo/commands/net/forward.ts +90 -0
  902. package/src/substrate/lifo/commands/net/host.ts +182 -0
  903. package/src/substrate/lifo/commands/net/ifconfig.ts +139 -0
  904. package/src/substrate/lifo/commands/net/ip.ts +633 -0
  905. package/src/substrate/lifo/commands/net/netstat.ts +106 -0
  906. package/src/substrate/lifo/commands/net/ping.ts +74 -0
  907. package/src/substrate/lifo/commands/net/ports.ts +45 -0
  908. package/src/substrate/lifo/commands/net/route.ts +153 -0
  909. package/src/substrate/lifo/commands/net/tunnel-v2.ts +183 -0
  910. package/src/substrate/lifo/commands/net/tunnel.ts +272 -0
  911. package/src/substrate/lifo/commands/net/wget.ts +88 -0
  912. package/src/substrate/lifo/commands/registry.ts +141 -0
  913. package/src/substrate/lifo/commands/signal.ts +65 -0
  914. package/src/substrate/lifo/commands/system/bc.ts +265 -0
  915. package/src/substrate/lifo/commands/system/cal.ts +90 -0
  916. package/src/substrate/lifo/commands/system/date.ts +59 -0
  917. package/src/substrate/lifo/commands/system/env.ts +10 -0
  918. package/src/substrate/lifo/commands/system/fastfetch.ts +428 -0
  919. package/src/substrate/lifo/commands/system/free.ts +38 -0
  920. package/src/substrate/lifo/commands/system/help.ts +53 -0
  921. package/src/substrate/lifo/commands/system/hostname.ts +9 -0
  922. package/src/substrate/lifo/commands/system/kill.ts +89 -0
  923. package/src/substrate/lifo/commands/system/lifo.ts +525 -0
  924. package/src/substrate/lifo/commands/system/logout.ts +17 -0
  925. package/src/substrate/lifo/commands/system/man.ts +167 -0
  926. package/src/substrate/lifo/commands/system/node.ts +1305 -0
  927. package/src/substrate/lifo/commands/system/npm.ts +1078 -0
  928. package/src/substrate/lifo/commands/system/pkg.ts +111 -0
  929. package/src/substrate/lifo/commands/system/ps.ts +46 -0
  930. package/src/substrate/lifo/commands/system/registry-schemas.ts +33 -0
  931. package/src/substrate/lifo/commands/system/sha256sum.ts +89 -0
  932. package/src/substrate/lifo/commands/system/sl.ts +249 -0
  933. package/src/substrate/lifo/commands/system/sleep.ts +36 -0
  934. package/src/substrate/lifo/commands/system/stty.ts +69 -0
  935. package/src/substrate/lifo/commands/system/systemctl.ts +184 -0
  936. package/src/substrate/lifo/commands/system/top.ts +53 -0
  937. package/src/substrate/lifo/commands/system/uname.ts +59 -0
  938. package/src/substrate/lifo/commands/system/uptime.ts +19 -0
  939. package/src/substrate/lifo/commands/system/watch.ts +67 -0
  940. package/src/substrate/lifo/commands/system/which.ts +51 -0
  941. package/src/substrate/lifo/commands/system/whoami.ts +9 -0
  942. package/src/substrate/lifo/commands/text/awk.ts +210 -0
  943. package/src/substrate/lifo/commands/text/base64.ts +102 -0
  944. package/src/substrate/lifo/commands/text/cut.ts +92 -0
  945. package/src/substrate/lifo/commands/text/diff.ts +314 -0
  946. package/src/substrate/lifo/commands/text/grep.ts +170 -0
  947. package/src/substrate/lifo/commands/text/head.ts +95 -0
  948. package/src/substrate/lifo/commands/text/less.ts +335 -0
  949. package/src/substrate/lifo/commands/text/nano.ts +513 -0
  950. package/src/substrate/lifo/commands/text/nl.ts +74 -0
  951. package/src/substrate/lifo/commands/text/rev.ts +46 -0
  952. package/src/substrate/lifo/commands/text/sed.ts +297 -0
  953. package/src/substrate/lifo/commands/text/seq.ts +76 -0
  954. package/src/substrate/lifo/commands/text/sort.ts +88 -0
  955. package/src/substrate/lifo/commands/text/strings.ts +73 -0
  956. package/src/substrate/lifo/commands/text/tac.ts +37 -0
  957. package/src/substrate/lifo/commands/text/tail.ts +63 -0
  958. package/src/substrate/lifo/commands/text/tr.ts +192 -0
  959. package/src/substrate/lifo/commands/text/uniq.ts +77 -0
  960. package/src/substrate/lifo/commands/text/wc.ts +104 -0
  961. package/src/substrate/lifo/commands/types.ts +58 -0
  962. package/src/substrate/lifo/index.ts +173 -0
  963. package/src/substrate/lifo/kernel/ServiceManager.ts +371 -0
  964. package/src/substrate/lifo/kernel/index.ts +209 -0
  965. package/src/substrate/lifo/kernel/network/Bridge.ts +336 -0
  966. package/src/substrate/lifo/kernel/network/DNSResolver.ts +158 -0
  967. package/src/substrate/lifo/kernel/network/NetworkInterface.ts +235 -0
  968. package/src/substrate/lifo/kernel/network/NetworkNamespace.ts +182 -0
  969. package/src/substrate/lifo/kernel/network/NetworkStack.ts +590 -0
  970. package/src/substrate/lifo/kernel/network/PortBridge.ts +182 -0
  971. package/src/substrate/lifo/kernel/network/RoutingTable.ts +209 -0
  972. package/src/substrate/lifo/kernel/network/Socket.ts +245 -0
  973. package/src/substrate/lifo/kernel/network/index.ts +29 -0
  974. package/src/substrate/lifo/kernel/network/tunnel/BaseTunnel.ts +124 -0
  975. package/src/substrate/lifo/kernel/network/tunnel/VETHPair.ts +227 -0
  976. package/src/substrate/lifo/kernel/network/tunnel/WebSocketTunnel.ts +387 -0
  977. package/src/substrate/lifo/kernel/network/types.ts +178 -0
  978. package/src/substrate/lifo/kernel/persistence/PersistenceManager.ts +50 -0
  979. package/src/substrate/lifo/kernel/persistence/backends.ts +36 -0
  980. package/src/substrate/lifo/kernel/persistence/index.ts +5 -0
  981. package/src/substrate/lifo/kernel/persistence/serializer.ts +127 -0
  982. package/src/substrate/lifo/kernel/samples.ts +966 -0
  983. package/src/substrate/lifo/kernel/storage/BlobStore.ts +114 -0
  984. package/src/substrate/lifo/kernel/storage/ContentStore.ts +150 -0
  985. package/src/substrate/lifo/kernel/storage/index.ts +5 -0
  986. package/src/substrate/lifo/kernel/unit-parser.ts +95 -0
  987. package/src/substrate/lifo/kernel/vfs/VFS.ts +768 -0
  988. package/src/substrate/lifo/kernel/vfs/index.ts +9 -0
  989. package/src/substrate/lifo/kernel/vfs/providers/DevProvider.ts +172 -0
  990. package/src/substrate/lifo/kernel/vfs/providers/NativeFsProvider.ts +198 -0
  991. package/src/substrate/lifo/kernel/vfs/providers/ProcProvider.ts +144 -0
  992. package/src/substrate/lifo/kernel/vfs/types.ts +145 -0
  993. package/src/substrate/lifo/node-compat/buffer.ts +357 -0
  994. package/src/substrate/lifo/node-compat/child_process.ts +52 -0
  995. package/src/substrate/lifo/node-compat/console.ts +70 -0
  996. package/src/substrate/lifo/node-compat/crypto.ts +186 -0
  997. package/src/substrate/lifo/node-compat/dns.ts +214 -0
  998. package/src/substrate/lifo/node-compat/esbuild.ts +85 -0
  999. package/src/substrate/lifo/node-compat/events.ts +94 -0
  1000. package/src/substrate/lifo/node-compat/fs.ts +762 -0
  1001. package/src/substrate/lifo/node-compat/http.ts +561 -0
  1002. package/src/substrate/lifo/node-compat/index.ts +300 -0
  1003. package/src/substrate/lifo/node-compat/module.ts +148 -0
  1004. package/src/substrate/lifo/node-compat/os.ts +44 -0
  1005. package/src/substrate/lifo/node-compat/path.ts +74 -0
  1006. package/src/substrate/lifo/node-compat/process.ts +178 -0
  1007. package/src/substrate/lifo/node-compat/readline.ts +244 -0
  1008. package/src/substrate/lifo/node-compat/rimraf.ts +80 -0
  1009. package/src/substrate/lifo/node-compat/stream.ts +98 -0
  1010. package/src/substrate/lifo/node-compat/string_decoder.ts +26 -0
  1011. package/src/substrate/lifo/node-compat/timers.ts +21 -0
  1012. package/src/substrate/lifo/node-compat/tty.ts +83 -0
  1013. package/src/substrate/lifo/node-compat/url.ts +76 -0
  1014. package/src/substrate/lifo/node-compat/util.ts +133 -0
  1015. package/src/substrate/lifo/node-compat/zlib.ts +94 -0
  1016. package/src/substrate/lifo/pkg/PackageManager.ts +105 -0
  1017. package/src/substrate/lifo/pkg/lifo-dev.ts +130 -0
  1018. package/src/substrate/lifo/pkg/lifo-runtime.ts +473 -0
  1019. package/src/substrate/lifo/pkg/loader.ts +33 -0
  1020. package/src/substrate/lifo/platform-globals.d.ts +41 -0
  1021. package/src/substrate/lifo/sandbox/HeadlessTerminal.ts +38 -0
  1022. package/src/substrate/lifo/sandbox/Sandbox.ts +279 -0
  1023. package/src/substrate/lifo/sandbox/SandboxCommands.ts +74 -0
  1024. package/src/substrate/lifo/sandbox/SandboxFs.ts +160 -0
  1025. package/src/substrate/lifo/sandbox/index.ts +8 -0
  1026. package/src/substrate/lifo/sandbox/types.ts +117 -0
  1027. package/src/substrate/lifo/shell/ProcessRegistry.ts +379 -0
  1028. package/src/substrate/lifo/shell/Shell.ts +2048 -0
  1029. package/src/substrate/lifo/shell/completer.ts +212 -0
  1030. package/src/substrate/lifo/shell/default-shell.ts +63 -0
  1031. package/src/substrate/lifo/shell/expander.ts +1349 -0
  1032. package/src/substrate/lifo/shell/history.ts +138 -0
  1033. package/src/substrate/lifo/shell/interpreter.ts +1754 -0
  1034. package/src/substrate/lifo/shell/jobs.ts +64 -0
  1035. package/src/substrate/lifo/shell/lexer.ts +698 -0
  1036. package/src/substrate/lifo/shell/parser.ts +711 -0
  1037. package/src/substrate/lifo/shell/pipe.ts +92 -0
  1038. package/src/substrate/lifo/shell/signals.ts +70 -0
  1039. package/src/substrate/lifo/shell/terminal-stdin.ts +109 -0
  1040. package/src/substrate/lifo/shell/test-builtin.ts +316 -0
  1041. package/src/substrate/lifo/shell/types.ts +166 -0
  1042. package/src/substrate/lifo/terminal/ITerminal.ts +9 -0
  1043. package/src/substrate/lifo/utils/archive.ts +389 -0
  1044. package/src/substrate/lifo/utils/args.ts +89 -0
  1045. package/src/substrate/lifo/utils/colors.ts +29 -0
  1046. package/src/substrate/lifo/utils/encoding.ts +21 -0
  1047. package/src/substrate/lifo/utils/glob.ts +172 -0
  1048. package/src/substrate/lifo/utils/mime.ts +114 -0
  1049. package/src/substrate/lifo/utils/path.ts +83 -0
  1050. package/src/types/assets.d.ts +4 -0
  1051. package/src/vfs/events.ts +134 -0
  1052. package/src/vfs/path.ts +71 -0
  1053. package/src/vfs/seed-project.ts +1094 -0
  1054. package/src/vfs/sqlite-vfs.ts +5035 -0
  1055. package/src/vfs/symlink-registry.ts +172 -0
  1056. package/src/workspace/nimbus-workspace.ts +213 -0
@@ -0,0 +1,1452 @@
1
+ /**
2
+ * EsbuildService — TypeScript/JSX transform + bundling via esbuild-wasm.
3
+ *
4
+ * Architecture:
5
+ * - esbuild-wasm is imported directly in the supervisor bundle
6
+ * - WASM is compiled during module evaluation (startup phase) — allowed
7
+ * - transform() runs in the supervisor's isolate (fast, no facet needed)
8
+ * - build() also runs in supervisor with a VFS resolver plugin
9
+ *
10
+ * Why not a facet? The esbuild-wasm WASM binary needs to be compiled
11
+ * during module startup (not request time). Dynamic workers created via
12
+ * LOADER.load() have the same restriction. Since esbuild-wasm is bundled
13
+ * into the supervisor, it initializes once at startup and stays warm.
14
+ *
15
+ * Memory: esbuild-wasm uses ~15-20MB heap. Within the DO's 128MB budget
16
+ * this is acceptable for Phase 3. Phase 4+ can move it to a dedicated
17
+ * facet once wasm module passing to dynamic workers is stable.
18
+ */
19
+ import { CRED_KERNEL } from './os-contracts.js';
20
+ import { resolvePackageEntry, resolveExports } from '../_shared/exports-resolver.js';
21
+ import { normalizeVfsPath, stripLeadingSlashes } from '../vfs/path.js';
22
+ /**
23
+ * Bundler version tag. BUMP THIS whenever bundling semantics change —
24
+ * the esbuild plugin's resolver logic, the shared-externals rules, the
25
+ * post-processing pipeline, or anything that would invalidate cached
26
+ * pre-bundles. The version is stored in pkg_esm_bundles.bundle_hash and
27
+ * checked on read; cache entries with a different version are treated
28
+ * as missing and rebuilt from scratch.
29
+ *
30
+ * History:
31
+ * v1 — initial pre-bundling
32
+ * v2 — shared React externals, CJS named exports
33
+ * v3 — Node subpath imports (#foo) support for vfile/unified ecosystem
34
+ * v4 — legacy flat-subpath resolution (pkg/sub without exports field);
35
+ * CDN fallback wrapper no longer crashes on modules without default
36
+ * v5 — normalize `../` segments in joined entry paths (react-remove-scroll-bar
37
+ * style: nested package.json with "module": "../dist/es2015/foo.js")
38
+ * v6 — externals enforced via plugin onResolve only (top-level `external:`
39
+ * dropped). Fixes dual-React-instance bug where jsx-runtime and
40
+ * react-dom/client were inlining their own copy of react because
41
+ * esbuild's entry-point external check rejected the externals when
42
+ * passed at the top level. v5 cache entries are wrong (contain
43
+ * embedded react copies) and must be invalidated.
44
+ * v7 — barrel-package bundles include a named-import signature in
45
+ * pkg_esm_bundles.input_hash. Prevents reusing a lucide-react
46
+ * bundle synthesized for one icon set after user source imports
47
+ * additional icons.
48
+ * v8 — pkg_esm_bundles now stores RAW esbuild output (base-independent);
49
+ * the module-URL rewrite that used to be baked in is applied per
50
+ * request at serve time so one bundle serves every mount base. v7
51
+ * rows hold post-rewrite text and must be re-bundled. user_module_
52
+ * transforms is likewise re-keyed by mount base.
53
+ */
54
+ export const BUNDLER_VERSION = 'v8';
55
+ // ── Shared-runtime externals ────────────────────────────────────────────
56
+ /**
57
+ * Returns the list of specifiers that must be marked `external` when bundling
58
+ * `specifier` so that React / React-DOM / Scheduler share a single instance
59
+ * across all /@modules/ bundles.
60
+ *
61
+ * Why: React uses an internal module-scoped singleton
62
+ * (`__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED`) for current dispatcher,
63
+ * owner, etc. If two bundles each contain their own embedded React, they each
64
+ * have their own singleton, and `createRoot` from one bundle sees JSX elements
65
+ * created by the other as "alien" — silent render failure (root stays empty).
66
+ *
67
+ * The fix: when bundling react-dom/*, mark react/* and scheduler as external.
68
+ * The bundler leaves `import {...} from "react"` in the output; the browser
69
+ * then fetches /preview/@modules/react, which is the SAME URL the jsx-runtime
70
+ * bundle imports — so both react-dom and jsx-runtime share ONE React instance.
71
+ *
72
+ * Similarly for react/jsx-runtime and react/jsx-dev-runtime (they must share
73
+ * react's internals), we externalize `react` (but not `scheduler` — jsx-runtime
74
+ * doesn't need it).
75
+ */
76
+ export function getSharedRuntimeExternals(specifier) {
77
+ // react: the canonical bundle. No externals — it's the source of truth.
78
+ if (specifier === 'react')
79
+ return [];
80
+ // react/jsx-runtime, react/jsx-dev-runtime: import from react's
81
+ // ReactSharedInternals to use the dispatcher. Externalize `react` so
82
+ // the jsx-runtime bundle is just the JSX helpers (~5 KiB) sharing
83
+ // ONE React instance via the browser's module loader.
84
+ if (specifier === 'react/jsx-runtime' || specifier === 'react/jsx-dev-runtime') {
85
+ return ['react'];
86
+ }
87
+ // Other react/* subpaths (e.g., react/server) — externalize react.
88
+ if (specifier.startsWith('react/')) {
89
+ return ['react'];
90
+ }
91
+ // EVERYTHING ELSE — react-dom, framer-motion, lucide-react, zustand,
92
+ // @radix-ui/*, react-router, etc. — must share react's singleton. If any
93
+ // of these embeds its own React copy, elements tagged by that copy get
94
+ // rejected as "alien" by the createRoot from the OTHER React copy
95
+ // (silent render fail / "Objects are not valid as a React child" with
96
+ // $$typeof spelled out). Externalize the entire React runtime.
97
+ //
98
+ // We DO NOT use `react/*` glob here because that has historically tripped
99
+ // esbuild's entry-point check. Instead we list the specific subpath
100
+ // imports React's ecosystem actually emits: jsx-runtime + jsx-dev-runtime.
101
+ // (react-dom subpaths are handled below by 'react-dom/*'.)
102
+ //
103
+ // Filter out patterns that match the spec being bundled — when
104
+ // bundling 'react-dom', drop 'react-dom' / 'react-dom/*' from the list
105
+ // so the entry can be bundled.
106
+ const all = [
107
+ 'react',
108
+ 'react/jsx-runtime',
109
+ 'react/jsx-dev-runtime',
110
+ 'react-dom',
111
+ 'react-dom/*',
112
+ 'scheduler',
113
+ ];
114
+ // Determine the package name for the spec being bundled (handles
115
+ // scoped packages and subpaths: 'react-dom/client' → 'react-dom').
116
+ const specPkg = specifier.startsWith('@')
117
+ ? specifier.split('/').slice(0, 2).join('/')
118
+ : specifier.split('/')[0];
119
+ return all.filter((pat) => {
120
+ if (pat === specifier)
121
+ return false;
122
+ if (pat.endsWith('/*')) {
123
+ const prefix = pat.slice(0, -1); // e.g. 'react-dom/'
124
+ const pkgName = pat.slice(0, -2); // e.g. 'react-dom'
125
+ if (specifier.startsWith(prefix))
126
+ return false;
127
+ if (specifier === pkgName)
128
+ return false;
129
+ if (specPkg === pkgName)
130
+ return false;
131
+ }
132
+ else {
133
+ // Plain (non-glob) external. Drop if the spec being bundled is
134
+ // a subpath of this external's package.
135
+ if (specPkg === pat)
136
+ return false;
137
+ }
138
+ return true;
139
+ });
140
+ }
141
+ /**
142
+ * Detect top-level await in source. Used by `EsbuildService.transform`
143
+ * to decide whether to async-IIFE-wrap CJS-target sources (see
144
+ * transform()'s header comment).
145
+ *
146
+ * Token scan over a comment-and-string-stripped source. Tracks paren
147
+ * depth AND function-body depth so a `{` inside a parameter list (a
148
+ * default-value object literal — `async function f(opts = {})`) is NOT
149
+ * mistaken for the function body. The earlier heuristic lacked the paren
150
+ * guard: the `= {}` braces consumed the body-tracking slot, leaving the
151
+ * real body untracked so an internal `await` read as top-level. That
152
+ * wrongly routed such files (e.g. @bluwy/giget-core's
153
+ * download-template.js, reached by create-astro) into the two-pass
154
+ * ESM→require rewrite, whose assembled output still carried export/import
155
+ * statements → "Cannot use import statement outside a module" at startup.
156
+ *
157
+ * Arrow bodies are distinguished from arrow expression bodies (the
158
+ * `arrowPending` flag): only a `{` immediately following `=>` opens a
159
+ * function scope. The idiomatic object-returning arrow `x => ({ ... })`
160
+ * has its `{` at parenDepth 1, so it opens no body slot — otherwise the
161
+ * leaked slot would be consumed by a later top-level `{ ... }` block,
162
+ * making a real top-level `await` inside it read as non-TLA (false
163
+ * negative) and routing genuine ESM-with-TLA into the wrong transform.
164
+ *
165
+ * A regex/token scan (not acorn) is kept here deliberately: pulling
166
+ * acorn into the esbuild-service bundle chunk duplicates its ~15 KiB
167
+ * Unicode identifier tables.
168
+ */
169
+ export function hasTopLevelAwait(src) {
170
+ if (!src || src.indexOf('await') === -1)
171
+ return false;
172
+ const stripped = stripCommentsAndStrings(src);
173
+ // Tokens: keywords, arrow, and each bracket kind. `parenDepth` rises
174
+ // inside `(...)`; a `{` only opens a function body when a `function`/
175
+ // `=>` is pending AND we're at parenDepth 0 (past the param list).
176
+ const re = /\b(await|function|class)\b|=>|\{|\}|\(|\)/g;
177
+ let m;
178
+ const fnEntryDepths = [];
179
+ let depth = 0;
180
+ let parenDepth = 0;
181
+ let pendingFn = 0;
182
+ // An arrow can have either a block body (`=> { ... }`) — which opens a
183
+ // function scope — or an expression body (`=> expr`), which does not.
184
+ // We can only tell which by looking at the token right after `=>`: a
185
+ // block body has `{` as its very next token. `arrowPending` carries
186
+ // that "the next `{` (and only an immediately-following `{`) is this
187
+ // arrow's body" intent, separately from `pendingFn` so the idiomatic
188
+ // `x => ({ ... })` (object-returning expression body, `{` at parenDepth
189
+ // 1) does not leak a body slot onto a later top-level block.
190
+ let arrowPending = false;
191
+ while ((m = re.exec(stripped)) !== null) {
192
+ const tok = m[0];
193
+ if (arrowPending && tok !== '{')
194
+ arrowPending = false;
195
+ if (tok === '(') {
196
+ parenDepth++;
197
+ }
198
+ else if (tok === ')') {
199
+ if (parenDepth > 0)
200
+ parenDepth--;
201
+ }
202
+ else if (tok === '{') {
203
+ depth++;
204
+ if (arrowPending) {
205
+ fnEntryDepths.push(depth);
206
+ arrowPending = false;
207
+ }
208
+ else if (pendingFn > 0 && parenDepth === 0) {
209
+ fnEntryDepths.push(depth);
210
+ pendingFn--;
211
+ }
212
+ }
213
+ else if (tok === '}') {
214
+ if (fnEntryDepths.length > 0 && fnEntryDepths[fnEntryDepths.length - 1] === depth)
215
+ fnEntryDepths.pop();
216
+ depth--;
217
+ }
218
+ else if (tok === 'function' || tok === 'class') {
219
+ pendingFn++;
220
+ }
221
+ else if (tok === '=>') {
222
+ arrowPending = true;
223
+ }
224
+ else if (tok === 'await') {
225
+ if (fnEntryDepths.length === 0)
226
+ return true;
227
+ }
228
+ }
229
+ return false;
230
+ }
231
+ /**
232
+ * Cheap heuristic: does the source contain a top-level ESM `import`
233
+ * statement? Used by `EsbuildService.transform` to detect sources that
234
+ * cannot be IIFE-wrapped as-is.
235
+ *
236
+ * Bug history (nuxt-esm-in-cjs wave):
237
+ * ─────────────────────────────────
238
+ * The TLA fix (framework-gaps-fix P2) wraps CJS-target sources in an
239
+ * async IIFE:
240
+ *
241
+ * ;(async () => { <source> })().catch(...);
242
+ *
243
+ * For sources with TLA-only, that works: `await` becomes legal inside
244
+ * the async function body. But for sources with BOTH TLA AND ESM
245
+ * `import` statements (real-world example: nuxi's `bin/nuxi.mjs`), the
246
+ * wrap moves `import` statements into a function body — and ESM
247
+ * `import` syntax is only legal at module top-level. esbuild rejects
248
+ * the wrapped source with `Unexpected "<binding>"` at line 3 of stdin
249
+ * (the wrap's line 1 is `;(async () =>...`, line 2 is the open brace,
250
+ * line 3 is the first user import).
251
+ *
252
+ * When TLA AND ESM imports coexist we must extract the imports first,
253
+ * rewrite them as `const X = require(...)` shims at top-level (above
254
+ * the IIFE), then wrap the rest. See `convertEsmImportsToRequire` for
255
+ * the rewrite contract and `transform()` for the integration site.
256
+ *
257
+ * Heuristic match: any of `import "..."` / `import x from "..."` /
258
+ * `import { ... } from "..."` / `import * as ns from "..."` / `import
259
+ * x, { ... } from "..."` appearing on a line whose first non-whitespace
260
+ * token is the `import` keyword. Dynamic `import(...)` calls are
261
+ * EXCLUDED — those are expressions, legal anywhere including IIFE
262
+ * bodies, and need no rewrite.
263
+ *
264
+ * Operates on the comment-and-string-stripped source so commented-out
265
+ * imports and "import" appearing inside string literals don't trigger.
266
+ * We reuse the comment/string stripper from `hasTopLevelAwait`'s pass
267
+ * — see `stripCommentsAndStrings` below.
268
+ */
269
+ function hasEsmImports(src) {
270
+ if (!src || src.indexOf('import') === -1)
271
+ return false;
272
+ const stripped = stripCommentsAndStrings(src);
273
+ // Top-level `import ... from "..."` OR side-effect `import "..."`.
274
+ // Negative lookbehind for `.` (avoids `something.import` member
275
+ // access) is unsupported in some JS engines; we match start-of-line
276
+ // (after whitespace) + the keyword. dynamic import() is matched as
277
+ // `import(` and excluded by negative lookahead.
278
+ const re = /^[ \t]*import\b(?!\s*\()/m;
279
+ return re.test(stripped);
280
+ }
281
+ function hasEsmExports(src) {
282
+ if (!src || src.indexOf('export') === -1)
283
+ return false;
284
+ const stripped = stripCommentsAndStrings(src);
285
+ return /^[ \t]*export\b/m.test(stripped);
286
+ }
287
+ /**
288
+ * Strip `//` and `/* * /` comments and string / template literals from
289
+ * source, replacing each with a single space. The result is byte-aligned
290
+ * with the input on a per-line basis (newlines are preserved), so error
291
+ * line numbers from downstream parsers still align with the original.
292
+ *
293
+ * Shared by `hasTopLevelAwait` (which had this inline) and
294
+ * `hasEsmImports`. Pure function — no caching needed for the small
295
+ * inputs we see (typical .mjs entry-point: <2KiB).
296
+ */
297
+ function stripCommentsAndStrings(src) {
298
+ let stripped = '';
299
+ let i = 0;
300
+ const N = src.length;
301
+ // Track the last non-whitespace non-comment output character so we
302
+ // can disambiguate `/` as division (after identifier/literal/`)`/`]`)
303
+ // vs regex-literal opener (after operator / punctuator / keyword /
304
+ // start-of-file). Pre-fix the stripper had no regex awareness, so
305
+ // patterns like `var X = /^(?:'…)/` contained an unmatched `'` that
306
+ // bit it as a string opener that didn't close until many lines
307
+ // later — corrupting every downstream classifier (export-scanner,
308
+ // hasEsmImports, hasTopLevelAwait). Real-world bite: sv-utils@0.0.3
309
+ // index.mjs has dozens of these regex literals.
310
+ let lastNonWsChar = '';
311
+ const recordOut = (ch) => {
312
+ if (ch !== ' ' && ch !== '\t' && ch !== '\n' && ch !== '\r') {
313
+ lastNonWsChar = ch;
314
+ }
315
+ };
316
+ // Identifier-suffix detection on lastNonWsChar: any of these means
317
+ // `/` is division. Anything else means `/` opens a regex.
318
+ // Includes ascii word chars + `)` `]` to cover `foo()/x` `a[i]/y`.
319
+ const DIVISION_AFTER = /[A-Za-z0-9_$\)\]]/;
320
+ while (i < N) {
321
+ const c = src[i];
322
+ if (c === '/' && src[i + 1] === '/') {
323
+ while (i < N && src[i] !== '\n')
324
+ i++;
325
+ stripped += ' ';
326
+ continue;
327
+ }
328
+ if (c === '/' && src[i + 1] === '*') {
329
+ i += 2;
330
+ while (i < N && !(src[i] === '*' && src[i + 1] === '/')) {
331
+ // Preserve newlines so line numbers stay aligned.
332
+ if (src[i] === '\n')
333
+ stripped += '\n';
334
+ i++;
335
+ }
336
+ i += 2;
337
+ stripped += ' ';
338
+ continue;
339
+ }
340
+ // Regex literal: `/` not followed by `/` or `*` (already handled
341
+ // above), AND preceded by something that makes regex valid here.
342
+ // The classifier looks at lastNonWsChar — for `(`, `,`, `=`, `;`,
343
+ // `{`, `[`, `:`, `!`, `&`, `|`, `?`, operators, or start-of-file,
344
+ // a slash is a regex opener.
345
+ if (c === '/' && !DIVISION_AFTER.test(lastNonWsChar)) {
346
+ stripped += ' ';
347
+ i++;
348
+ while (i < N) {
349
+ const rc = src[i];
350
+ if (rc === '\\') {
351
+ i += 2;
352
+ continue;
353
+ }
354
+ // Regex character class [...]: `/` inside it is content.
355
+ if (rc === '[') {
356
+ i++;
357
+ while (i < N && src[i] !== ']') {
358
+ if (src[i] === '\\') {
359
+ i += 2;
360
+ continue;
361
+ }
362
+ if (src[i] === '\n') {
363
+ stripped += '\n';
364
+ }
365
+ i++;
366
+ }
367
+ if (i < N)
368
+ i++; // consume ']'
369
+ continue;
370
+ }
371
+ if (rc === '/') {
372
+ i++;
373
+ break;
374
+ }
375
+ if (rc === '\n') {
376
+ // Regex literals can't span newlines. If we hit one without
377
+ // finding the closing `/`, this was probably NOT a regex —
378
+ // bail out gracefully (rare in practice; better than getting
379
+ // stuck in a wrong state).
380
+ break;
381
+ }
382
+ i++;
383
+ }
384
+ // Skip regex flags (g, i, m, s, u, y, d).
385
+ while (i < N && /[gimsuyd]/.test(src[i]))
386
+ i++;
387
+ recordOut('/');
388
+ continue;
389
+ }
390
+ if (c === '"' || c === "'" || c === '`') {
391
+ const q = c;
392
+ stripped += ' ';
393
+ i++;
394
+ while (i < N) {
395
+ const cc = src[i];
396
+ if (cc === '\\') {
397
+ i += 2;
398
+ continue;
399
+ }
400
+ if (cc === q) {
401
+ i++;
402
+ break;
403
+ }
404
+ // Template interpolation: ${...} — preserve the inner
405
+ // expression as raw code so the caller's depth-tracker can
406
+ // see `await` etc. inside it. Strip the wrapping `${`/`}`
407
+ // (those don't affect brace-depth from the caller's POV).
408
+ //
409
+ // CRITICAL: inside the interpolation expression, we must
410
+ // recognise NESTED strings (`'}'`, `"}"`, `` `${...}` ``) so
411
+ // their internal `}` characters don't decrement the depth
412
+ // counter — otherwise we exit the interpolation early and
413
+ // start consuming code as string content, eventually parsing
414
+ // the rest of the file as one massive unclosed string. This
415
+ // bit sv-utils/dist/index.mjs: multi-line backticks with
416
+ // `${url.replace('}', '_')}`-style interpolations corrupted
417
+ // line classification downstream. Recursive-by-loop here.
418
+ if (q === '`' && cc === '$' && src[i + 1] === '{') {
419
+ stripped += '${';
420
+ i += 2;
421
+ let depth = 1;
422
+ while (i < N && depth > 0) {
423
+ const ic = src[i];
424
+ // Nested string inside interpolation: skip its content.
425
+ if (ic === '"' || ic === "'" || ic === '`') {
426
+ const iq = ic;
427
+ stripped += ' ';
428
+ i++;
429
+ while (i < N) {
430
+ const icc = src[i];
431
+ if (icc === '\\') {
432
+ i += 2;
433
+ continue;
434
+ }
435
+ if (icc === iq) {
436
+ i++;
437
+ break;
438
+ }
439
+ // Nested template inside interpolation can also have its
440
+ // own ${...} — recurse once more (the practical depth
441
+ // observed in real code never exceeds 2; deeper nesting
442
+ // falls back to brace counting which is a best-effort).
443
+ if (iq === '`' && icc === '$' && src[i + 1] === '{') {
444
+ stripped += '${';
445
+ i += 2;
446
+ let d2 = 1;
447
+ while (i < N && d2 > 0) {
448
+ const i2 = src[i];
449
+ if (i2 === '{')
450
+ d2++;
451
+ else if (i2 === '}')
452
+ d2--;
453
+ if (d2 > 0)
454
+ stripped += i2;
455
+ i++;
456
+ }
457
+ stripped += '}';
458
+ continue;
459
+ }
460
+ if (icc === '\n')
461
+ stripped += '\n';
462
+ i++;
463
+ }
464
+ continue;
465
+ }
466
+ if (ic === '{')
467
+ depth++;
468
+ else if (ic === '}')
469
+ depth--;
470
+ if (depth > 0)
471
+ stripped += ic;
472
+ i++;
473
+ }
474
+ stripped += '}';
475
+ continue;
476
+ }
477
+ if (cc === '\n')
478
+ stripped += '\n';
479
+ i++;
480
+ }
481
+ continue;
482
+ }
483
+ stripped += c;
484
+ recordOut(c);
485
+ i++;
486
+ }
487
+ return stripped;
488
+ }
489
+ /**
490
+ * Convert ESM `import` statements at the top of `src` to CJS
491
+ * `require()` declarations, returning `{ requires, body }` where
492
+ * `requires` is the require-shim block (a single string of newline-
493
+ * separated declarations) and `body` is the source with the imports
494
+ * removed.
495
+ *
496
+ * Operates on the OUTPUT of an esbuild `format: 'esm'` pre-pass, NOT
497
+ * on raw user source. esbuild normalises imports onto single lines and
498
+ * canonicalises the binding shape, which means a small regex over the
499
+ * normalised output is reliable. Specifically:
500
+ * - Multi-line imports are collapsed to one line per import
501
+ * - `import x from 'm';` always has the semicolon
502
+ * - String quotes are normalised to double-quotes
503
+ * - Whitespace is canonical
504
+ *
505
+ * Supported import shapes (after esbuild normalisation):
506
+ * 1. `import "m";` side-effect
507
+ * 2. `import x from "m";` default
508
+ * 3. `import * as ns from "m";` namespace
509
+ * 4. `import { a, b as c } from "m";` named (with optional rename)
510
+ * 5. `import x, { a } from "m";` default + named
511
+ * 6. `import x, * as ns from "m";` default + namespace
512
+ *
513
+ * Rewrites:
514
+ * 1. `require("m");`
515
+ * 2. `const x = (() => { const _m = require("m"); return _m && _m.__esModule ? _m.default : _m; })();`
516
+ * 3. `const ns = require("m");`
517
+ * 4. `const { a, b: c } = require("m");`
518
+ * 5. `const _m_<n> = require("m"); const x = _m_<n>.__esModule ? _m_<n>.default : _m_<n>; const { a } = _m_<n>;`
519
+ * 6. `const ns = require("m"); const x = ns.__esModule ? ns.default : ns;`
520
+ *
521
+ * Default-binding compat: ESM `import x from "m"` binds the module's
522
+ * default export, OR the whole module if there is no default. Real
523
+ * Node + esbuild's __esModule interop check handle this with the
524
+ * `__esModule ? .default : whole` pattern reproduced above. Same as
525
+ * what esbuild emits inline when targeting CJS for a no-TLA source
526
+ * (verified empirically against `esbuild-wasm 0.24.2`).
527
+ *
528
+ * Unknown shapes are left in `body` unchanged — esbuild will reject
529
+ * them on the second pass and the caller surfaces a clear error.
530
+ * That's the safe failure mode.
531
+ */
532
+ function convertEsmImportsToRequire(src) {
533
+ const lines = src.split('\n');
534
+ // Strip comments + string/template literals so the line scanner only
535
+ // sees real syntax. Without this, import-shaped lines INSIDE template
536
+ // literals (real-world: sv@0.15.3's engine.mjs scaffolds SvelteKit
537
+ // project files via templates containing `import { redirect } from
538
+ // '@sveltejs/kit';`) get parsed as actual imports — emitted twice into
539
+ // the requires block → duplicate const declaration → SyntaxError at
540
+ // facet pre-compile ("Identifier 'redirect' has already been declared").
541
+ //
542
+ // stripCommentsAndStrings preserves newlines, so line indices align
543
+ // between `src` and `strippedLines`. We use the stripped line to
544
+ // CLASSIFY (is this an import line?) and the original line to
545
+ // EXTRACT the actual import shape (specifier, bindings).
546
+ //
547
+ const strippedLines = stripCommentsAndStrings(src).split('\n');
548
+ const requires = [];
549
+ const bodyLines = [];
550
+ let counter = 0;
551
+ for (let li = 0; li < lines.length; li++) {
552
+ const line = lines[li];
553
+ const cls = strippedLines[li] ?? '';
554
+ // Classification check: is this line a real top-level import?
555
+ // The stripped version masks string content, so import-shaped
556
+ // template-literal lines are now whitespace.
557
+ if (!/^[ \t]*import\b/.test(cls)) {
558
+ bodyLines.push(line);
559
+ continue;
560
+ }
561
+ // Side-effect import: `import "m";` / `import 'm';`
562
+ let m = line.match(/^[ \t]*import\s+["']([^"']+)["']\s*;?\s*$/);
563
+ if (m) {
564
+ requires.push(`require(${JSON.stringify(m[1])});`);
565
+ continue;
566
+ }
567
+ // Identifier class: JS spec allows `$` and `_` in addition to `\w`
568
+ // (letters/digits/underscore). esbuild's ESM-pass-1 emits `process$1`
569
+ // when colliding with a global (e.g. `import process from 'node:process'`
570
+ // becomes `process$1`). Pre-fix `\w+` truncated at `$`, all the regexes
571
+ // below missed → line fell through to bodyLines → top-level `import`
572
+ // statement survived into the async-IIFE wrap → SyntaxError
573
+ // "import statement outside module" at facet pre-compile.
574
+ // Default + namespace: `import x, * as ns from "m";`
575
+ m = line.match(/^[ \t]*import\s+([\w$]+)\s*,\s*\*\s+as\s+([\w$]+)\s+from\s+["']([^"']+)["']\s*;?\s*$/);
576
+ if (m) {
577
+ const def = m[1], ns = m[2], mod = m[3];
578
+ requires.push(`const ${ns} = require(${JSON.stringify(mod)}); const ${def} = ${ns}.__esModule ? ${ns}.default : ${ns};`);
579
+ continue;
580
+ }
581
+ // Default + named: `import x, { a, b as c } from "m";`
582
+ m = line.match(/^[ \t]*import\s+([\w$]+)\s*,\s*\{([^}]+)\}\s+from\s+["']([^"']+)["']\s*;?\s*$/);
583
+ if (m) {
584
+ const def = m[1], bindings = m[2], mod = m[3];
585
+ const tmp = `_nimbus_m_${counter++}`;
586
+ const named = bindings.split(',').map((b) => {
587
+ const am = b.trim().match(/^([\w$]+)(?:\s+as\s+([\w$]+))?$/);
588
+ if (!am)
589
+ return b.trim();
590
+ return am[2] ? `${am[1]}: ${am[2]}` : am[1];
591
+ }).join(', ');
592
+ requires.push(`const ${tmp} = require(${JSON.stringify(mod)}); const ${def} = ${tmp}.__esModule ? ${tmp}.default : ${tmp}; const { ${named} } = ${tmp};`);
593
+ continue;
594
+ }
595
+ // Namespace: `import * as ns from "m";`
596
+ m = line.match(/^[ \t]*import\s+\*\s+as\s+([\w$]+)\s+from\s+["']([^"']+)["']\s*;?\s*$/);
597
+ if (m) {
598
+ requires.push(`const ${m[1]} = require(${JSON.stringify(m[2])});`);
599
+ continue;
600
+ }
601
+ // Named only: `import { a, b as c } from "m";`
602
+ m = line.match(/^[ \t]*import\s+\{([^}]+)\}\s+from\s+["']([^"']+)["']\s*;?\s*$/);
603
+ if (m) {
604
+ const bindings = m[1], mod = m[2];
605
+ const named = bindings.split(',').map((b) => {
606
+ const am = b.trim().match(/^([\w$]+)(?:\s+as\s+([\w$]+))?$/);
607
+ if (!am)
608
+ return b.trim();
609
+ return am[2] ? `${am[1]}: ${am[2]}` : am[1];
610
+ }).join(', ');
611
+ requires.push(`const { ${named} } = require(${JSON.stringify(mod)});`);
612
+ continue;
613
+ }
614
+ // Default only: `import x from "m";`
615
+ m = line.match(/^[ \t]*import\s+([\w$]+)\s+from\s+["']([^"']+)["']\s*;?\s*$/);
616
+ if (m) {
617
+ const def = m[1], mod = m[2];
618
+ requires.push(`const ${def} = (() => { const _m = require(${JSON.stringify(mod)}); return _m && _m.__esModule ? _m.default : _m; })();`);
619
+ continue;
620
+ }
621
+ // Stripped-line claimed this was an import, but none of the shape
622
+ // regexes matched. Unknown import form (e.g. multi-line import that
623
+ // esbuild's pass-1 normalization didn't collapse, or a future-syntax
624
+ // variant). Keep in body — esbuild's pass-2 will reject it with a
625
+ // clear error if it's actually invalid, or accept it if it's a form
626
+ // we don't yet recognise.
627
+ bodyLines.push(line);
628
+ }
629
+ // ── Pass 2: scan bodyLines for top-level `export` statements. ──────
630
+ //
631
+ // After import-stripping, the body still has every `export` statement
632
+ // verbatim. The async-IIFE wrap (the caller wraps body in
633
+ // `;(async () => { ... })();`) makes those exports illegal grammar
634
+ // ('export' is module-only, not legal in function bodies) →
635
+ // SyntaxError "Unexpected token 'export'" at facet pre-compile.
636
+ //
637
+ // Rewrite each top-level export to a CJS-compatible equivalent (see
638
+ // Same defences as imports:
639
+ // - String-content masking (template-literal exports don't trigger)
640
+ // - $-aware identifier regex ([\w$]+, esbuild emits foo$1 ids)
641
+ //
642
+ // Multi-line `export { ... }` lists are coalesced before shape match.
643
+ const bodySrc = bodyLines.join('\n');
644
+ const bodyLines2 = bodySrc.split('\n');
645
+ const strippedBody = stripCommentsAndStrings(bodySrc).split('\n');
646
+ const out = [];
647
+ let i = 0;
648
+ let exportCounter = 0;
649
+ while (i < bodyLines2.length) {
650
+ const line = bodyLines2[i];
651
+ const cls = strippedBody[i] ?? '';
652
+ if (!/^[ \t]*export\b/.test(cls)) {
653
+ out.push(line);
654
+ i++;
655
+ continue;
656
+ }
657
+ // Multi-line collector: if the stripped line opens a `{` for an
658
+ // `export { ... }` list and doesn't close it on the same line,
659
+ // accumulate subsequent lines until the matching `}` (tracked on
660
+ // the stripped lines so string `}`s don't trip us).
661
+ let coalesced = line;
662
+ let coalescedCls = cls;
663
+ if (/^[ \t]*export\s*\{/.test(cls) && !/\}/.test(cls)) {
664
+ let j = i + 1;
665
+ while (j < bodyLines2.length) {
666
+ coalesced += ' ' + bodyLines2[j];
667
+ coalescedCls += ' ' + (strippedBody[j] ?? '');
668
+ if (/\}/.test(strippedBody[j] ?? '')) {
669
+ j++;
670
+ break;
671
+ }
672
+ j++;
673
+ }
674
+ i = j;
675
+ }
676
+ else {
677
+ i++;
678
+ }
679
+ // Helper: emit a `__esModule = true` marker exactly once.
680
+ // (Mirrors esbuild's own emit; consumers using the __esModule check
681
+ // in convertEsmImportsToRequire's default-import shim then pick
682
+ // .default correctly.)
683
+ const ensureEsmMarker = (() => {
684
+ let emitted = false;
685
+ return () => {
686
+ if (emitted)
687
+ return '';
688
+ emitted = true;
689
+ return 'module.exports.__esModule = true; ';
690
+ };
691
+ })();
692
+ // Shape regexes operate on the COALESCED ORIGINAL line. We use the
693
+ // stripped version only for classification (already done above).
694
+ let m;
695
+ // export default function/class — declaration form
696
+ // `export default function foo(args){...}` (named declaration)
697
+ m = coalesced.match(/^([ \t]*)export\s+default\s+(async\s+)?function\s*([\w$]+)\s*([\s\S]*)$/);
698
+ if (m) {
699
+ const indent = m[1], asyncKw = m[2] || '', name = m[3], rest = m[4];
700
+ out.push(`${indent}${asyncKw}function ${name} ${rest}`);
701
+ out.push(`${ensureEsmMarker()}module.exports.default = ${name};`);
702
+ continue;
703
+ }
704
+ // export default class K {...}
705
+ m = coalesced.match(/^([ \t]*)export\s+default\s+class\s+([\w$]+)\s*([\s\S]*)$/);
706
+ if (m) {
707
+ const indent = m[1], name = m[2], rest = m[3];
708
+ out.push(`${indent}class ${name} ${rest}`);
709
+ out.push(`${ensureEsmMarker()}module.exports.default = ${name};`);
710
+ continue;
711
+ }
712
+ // export default <anonymous-function | anonymous-class | expression>
713
+ // Match any remaining `export default …` shape and emit as assignment.
714
+ m = coalesced.match(/^([ \t]*)export\s+default\s+([\s\S]*)$/);
715
+ if (m) {
716
+ const indent = m[1];
717
+ let rest = m[2];
718
+ // Strip trailing semicolon (we add our own).
719
+ rest = rest.replace(/;\s*$/, '');
720
+ out.push(`${indent}${ensureEsmMarker()}module.exports.default = (${rest});`);
721
+ continue;
722
+ }
723
+ // export named-declaration: const/let/var
724
+ m = coalesced.match(/^([ \t]*)export\s+(const|let|var)\s+([\w$]+)\s*=\s*([\s\S]*)$/);
725
+ if (m) {
726
+ const indent = m[1], kw = m[2], name = m[3];
727
+ let rest = m[4];
728
+ rest = rest.replace(/;\s*$/, '');
729
+ out.push(`${indent}${kw} ${name} = ${rest};`);
730
+ out.push(`${ensureEsmMarker()}module.exports.${name} = ${name};`);
731
+ continue;
732
+ }
733
+ // export function NAME(...) {...}
734
+ m = coalesced.match(/^([ \t]*)export\s+(async\s+)?function\s*\*?\s*([\w$]+)\s*([\s\S]*)$/);
735
+ if (m) {
736
+ const indent = m[1], asyncKw = m[2] || '', name = m[3], rest = m[4];
737
+ // Preserve generator-star if present (function\s*\*).
738
+ const generatorStar = /^export\s+(?:async\s+)?function\s*\*/.test(coalesced.replace(/^[ \t]+/, '')) ? '*' : '';
739
+ out.push(`${indent}${asyncKw}function${generatorStar} ${name} ${rest}`);
740
+ out.push(`${ensureEsmMarker()}module.exports.${name} = ${name};`);
741
+ continue;
742
+ }
743
+ // export class NAME { ... } / export class NAME extends X { ... }
744
+ m = coalesced.match(/^([ \t]*)export\s+class\s+([\w$]+)\s*([\s\S]*)$/);
745
+ if (m) {
746
+ const indent = m[1], name = m[2], rest = m[3];
747
+ out.push(`${indent}class ${name} ${rest}`);
748
+ out.push(`${ensureEsmMarker()}module.exports.${name} = ${name};`);
749
+ continue;
750
+ }
751
+ // export { x, y as z } from 'm' / export * from 'm' / export * as ns from 'm'
752
+ m = coalesced.match(/^([ \t]*)export\s*\*\s+as\s+([\w$]+)\s+from\s+["']([^"']+)["']\s*;?\s*$/);
753
+ if (m) {
754
+ const indent = m[1], ns = m[2], mod = m[3];
755
+ out.push(`${indent}${ensureEsmMarker()}module.exports.${ns} = require(${JSON.stringify(mod)});`);
756
+ continue;
757
+ }
758
+ m = coalesced.match(/^([ \t]*)export\s*\*\s+from\s+["']([^"']+)["']\s*;?\s*$/);
759
+ if (m) {
760
+ const indent = m[1], mod = m[2];
761
+ const tmp = `_nimbus_re_${exportCounter++}`;
762
+ out.push(`${indent}${ensureEsmMarker()}{ const ${tmp} = require(${JSON.stringify(mod)}); for (const _k in ${tmp}) { if (_k !== "default" && _k !== "__esModule") module.exports[_k] = ${tmp}[_k]; } }`);
763
+ continue;
764
+ }
765
+ m = coalesced.match(/^([ \t]*)export\s*\{([^}]*)\}\s+from\s+["']([^"']+)["']\s*;?\s*$/);
766
+ if (m) {
767
+ const indent = m[1], bindings = m[2], mod = m[3];
768
+ const tmp = `_nimbus_re_${exportCounter++}`;
769
+ const parts = bindings.split(',').map((b) => b.trim()).filter(Boolean);
770
+ const assigns = [];
771
+ for (const p of parts) {
772
+ const am = p.match(/^([\w$]+)(?:\s+as\s+([\w$]+))?$/);
773
+ if (!am)
774
+ continue;
775
+ const src = am[1], dst = am[2] || am[1];
776
+ assigns.push(`module.exports.${dst} = ${tmp}.${src};`);
777
+ }
778
+ out.push(`${indent}${ensureEsmMarker()}{ const ${tmp} = require(${JSON.stringify(mod)}); ${assigns.join(' ')} }`);
779
+ continue;
780
+ }
781
+ // export { x, y as z } (binding-only list — no `from`)
782
+ m = coalesced.match(/^([ \t]*)export\s*\{([^}]*)\}\s*;?\s*$/);
783
+ if (m) {
784
+ const indent = m[1], bindings = m[2];
785
+ const parts = bindings.split(',').map((b) => b.trim()).filter(Boolean);
786
+ const assigns = [];
787
+ for (const p of parts) {
788
+ const am = p.match(/^([\w$]+)(?:\s+as\s+([\w$]+))?$/);
789
+ if (!am)
790
+ continue;
791
+ const src = am[1], dst = am[2] || am[1];
792
+ assigns.push(`module.exports.${dst} = ${src};`);
793
+ }
794
+ out.push(`${indent}${ensureEsmMarker()}${assigns.join(' ')}`);
795
+ continue;
796
+ }
797
+ // Unknown export shape — leave in body (esbuild will surface a clear
798
+ // error at the next pass, or this is a future-syntax variant we
799
+ // don't yet recognise).
800
+ out.push(coalesced);
801
+ }
802
+ return { requires: requires.join('\n'), body: out.join('\n') };
803
+ }
804
+ import esbuildWasmUrl from 'esbuild-wasm/esbuild.wasm';
805
+ /**
806
+ * Cached reference to the esbuild namespace. Populated on first
807
+ * `loadEsbuild()` call; nullable until then so module-load code paths
808
+ * that never touch bundling can complete without ever evaluating
809
+ * `esbuild-wasm/lib/main.js`.
810
+ */
811
+ let _esbuildMod = null;
812
+ let _esbuildLoadPromise = null;
813
+ /**
814
+ * Lazily load the esbuild-wasm namespace. Safe to call many times;
815
+ * concurrent callers share a single in-flight Promise. Throws if the
816
+ * CJS main module itself can't run (i.e. the runtime doesn't support
817
+ * the require('fs') pattern esbuild-wasm uses) — callers should catch
818
+ * and surface a helpful error rather than crash the Worker.
819
+ */
820
+ async function loadEsbuild() {
821
+ if (_esbuildMod)
822
+ return _esbuildMod;
823
+ if (_esbuildLoadPromise)
824
+ return _esbuildLoadPromise;
825
+ _esbuildLoadPromise = (async () => {
826
+ const mod = await import('esbuild-wasm');
827
+ _esbuildMod = mod;
828
+ return _esbuildMod;
829
+ })();
830
+ try {
831
+ return await _esbuildLoadPromise;
832
+ }
833
+ catch (e) {
834
+ // Reset so a future call can retry (e.g., after the caller has done
835
+ // environment setup we didn't anticipate).
836
+ _esbuildLoadPromise = null;
837
+ throw e;
838
+ }
839
+ }
840
+ // ── EsbuildService ──────────────────────────────────────────────────────
841
+ export class EsbuildService {
842
+ vfs;
843
+ initialized = false;
844
+ initPromise = null;
845
+ /** Resolved esbuild namespace — populated by ensureInit() after loadEsbuild(). */
846
+ _esbuild = null;
847
+ constructor(vfs) {
848
+ this.vfs = vfs.as(CRED_KERNEL);
849
+ }
850
+ /**
851
+ * Initialize esbuild-wasm (lazy, on first use). Loads the namespace
852
+ * via `loadEsbuild()` (which itself is deferred) and caches it on
853
+ * `this._esbuild` so subsequent calls don't pay the dynamic-import
854
+ * overhead. All call sites that previously used the top-level
855
+ * `esbuild` namespace now use `this._esbuild!` after `await this.ensureInit()`.
856
+ */
857
+ async ensureInit() {
858
+ if (this.initialized && this._esbuild)
859
+ return;
860
+ if (this.initPromise)
861
+ return this.initPromise;
862
+ this.initPromise = (async () => {
863
+ try {
864
+ const esb = await loadEsbuild();
865
+ this._esbuild = esb;
866
+ // The supervisor loads esbuild-wasm via wrangler's static-import
867
+ // resolution (`import esbuildWasmUrl from 'esbuild-wasm/esbuild.wasm'`
868
+ // at the top of this file). At deploy time wrangler bundles the
869
+ // .wasm bytes INTO the worker and resolves the import to a
870
+ // WebAssembly.Module value. If the import didn't resolve to a
871
+ // module — for example, a future bundler regression — we used
872
+ // to silently fall back to fetching from cdn.jsdelivr.net. That
873
+ // fallback violated the 100% edge contract: the supervisor
874
+ // would issue a third-party CDN request mid-request to bring
875
+ // up its bundler. Removed.
876
+ //
877
+ // If the bundled import is missing, fail loud with a clear
878
+ // remediation (rebuild the worker with the wasm asset). The
879
+ // supervisor's pre-bundle path also embeds esbuild-wasm via
880
+ // src/esbuild-wasm-bundle.generated.ts, so a complete loss of
881
+ // wasm support would surface there too.
882
+ if (!esbuildWasmUrl || typeof esbuildWasmUrl !== 'object') {
883
+ throw new Error('esbuild-wasm bundled import is not a WebAssembly.Module. ' +
884
+ 'Rebuild the worker so wrangler resolves ' +
885
+ '`esbuild-wasm/esbuild.wasm` at bundle time. ' +
886
+ 'NO CDN fallback (100% edge contract).');
887
+ }
888
+ // [WRANGLER-DEV-HANG P0b] Time-bound esb.initialize. Workerd
889
+ // has historically had cases where wasm init blocks indefinitely;
890
+ // 30 s is well above the typical ~200 ms init time.
891
+ const INIT_TIMEOUT_MS = 30_000;
892
+ let initTimeout = null;
893
+ await Promise.race([
894
+ esb.initialize({
895
+ wasmModule: esbuildWasmUrl,
896
+ worker: false,
897
+ }),
898
+ new Promise((_, reject) => {
899
+ initTimeout = setTimeout(() => {
900
+ reject(new Error(`esbuild init exceeded ${INIT_TIMEOUT_MS / 1000}s. ` +
901
+ `wasmModule type=${typeof esbuildWasmUrl}; ` +
902
+ `Likely cause: WebAssembly compile/init stall in workerd.`));
903
+ }, INIT_TIMEOUT_MS);
904
+ }),
905
+ ]).finally(() => { if (initTimeout)
906
+ clearTimeout(initTimeout); });
907
+ this.initialized = true;
908
+ }
909
+ catch (e) {
910
+ // "Cannot call initialize more than once" means it's already ready
911
+ if (e?.message?.includes('more than once')) {
912
+ this.initialized = true;
913
+ return;
914
+ }
915
+ this.initPromise = null;
916
+ throw new Error('esbuild init failed: ' + (e?.message || e));
917
+ }
918
+ })();
919
+ return this.initPromise;
920
+ }
921
+ /**
922
+ * Transform a single code string (TS→JS, JSX→JS, minify, etc.)
923
+ *
924
+ * Top-level await note (gap #2 in framework-gaps-fix):
925
+ * ─────────────────────────────────────────────────────
926
+ * esbuild rejects top-level await when output format is 'cjs' or
927
+ * 'iife' — neither has a runtime primitive for it. Real Node
928
+ * supports TLA only in ESM. Nimbus's facet wrapper executes the
929
+ * transformed code via `new Function(...)` which is CJS-shaped.
930
+ *
931
+ * Several modern CLIs (nuxi, vite-cli, oclif's lazy-load bootstrap,
932
+ * many ESM-only-by-default tools) use TLA at the entry point. With
933
+ * format:'cjs' those would crash with "Top-level await is currently
934
+ * not supported with the 'cjs' output format" — an esbuild
935
+ * SyntaxError surfaced as a Nimbus diagnostic. The user can't
936
+ * fix this without rewriting upstream.
937
+ *
938
+ * Fix: when caller asks for format 'cjs' AND the source has a
939
+ * top-level await, wrap the source in an async IIFE and return its
940
+ * Promise to the facet runner:
941
+ *
942
+ * return (async () => {
943
+ * <original-source>
944
+ * })();
945
+ *
946
+ * Inside the IIFE, await is legal. Returning the Promise is required:
947
+ * the facet runner awaits promise-returning entry functions so
948
+ * sequential TLA execution cannot race process teardown or VFS flushes.
949
+ *
950
+ * ESM-imports-in-CJS note (nuxt-esm-in-cjs wave):
951
+ * ─────────────────────────────────────────────────
952
+ * The IIFE wrap above moves the user source INTO a function body.
953
+ * Top-level ESM `import` statements are LEGAL only at module top
954
+ * level — inside a function body they're a SyntaxError. Real-world
955
+ * trigger: nuxi's `bin/nuxi.mjs` opens with `import { performance }
956
+ * from "node:perf_hooks"` and ends with `const { runMain } = await
957
+ * import("./dist/index.mjs"); runMain()` — both ESM imports AND TLA.
958
+ * Pre-fix the IIFE wrap caused esbuild to fail with
959
+ * `Unexpected "<binding>"` at line 3 of stdin.
960
+ *
961
+ * Fix: when TLA AND ESM imports coexist, run a two-stage transform:
962
+ * 1. Pass 1: `esbuild.transform(code, { format: 'esm', ... })` —
963
+ * esbuild accepts TLA + imports cleanly when emitting ESM.
964
+ * Output is JS-canonicalised: multi-line imports collapsed,
965
+ * bindings normalised, etc.
966
+ * 2. Extract top-level imports from the pass-1 output and rewrite
967
+ * them as `const X = require(...)` shims (see
968
+ * `convertEsmImportsToRequire` for the contract / shape).
969
+ * 3. Wrap the remaining body in a returned async IIFE.
970
+ * 4. Return the assembled string as the transform result.
971
+ *
972
+ * The require-shim emits the standard `__esModule` interop check
973
+ * (matches what esbuild itself emits for ESM→CJS conversions), so
974
+ * default-export binding semantics are preserved.
975
+ *
976
+ * If TLA but no ESM imports → existing single-pass IIFE wrap.
977
+ * If ESM imports but no TLA → existing single-pass esbuild
978
+ * format:cjs (it auto-converts ESM→CJS gracefully).
979
+ *
980
+ * This is bytes-stable for sources outside the TLA+ESM-imports
981
+ * intersection.
982
+ */
983
+ async transform(code, options) {
984
+ await this.ensureInit();
985
+ const format = options?.format || 'esm';
986
+ const loader = options?.loader || 'ts';
987
+ // ── CJS + TLA + ESM module syntax: two-pass with module rewrite ──
988
+ // This precedes the simple TLA-only IIFE wrap. We test ESM module
989
+ // syntax first because the IIFE wrap is incompatible with import
990
+ // and export statements; if both conditions hold we MUST go through
991
+ // the rewrite path.
992
+ if (format === 'cjs' && hasTopLevelAwait(code) && (hasEsmImports(code) || hasEsmExports(code))) {
993
+ // Pass 1: emit ESM so esbuild accepts TLA + imports without complaint.
994
+ // We use the same loader/target so TS/JSX is handled here too.
995
+ const pass1 = await this._esbuild.transform(code, {
996
+ loader,
997
+ format: 'esm',
998
+ target: options?.target || 'esnext',
999
+ sourcemap: false, // pass-1 source map is discarded; pass-2 doesn't run esbuild
1000
+ minify: false, // minify only on the final output if requested
1001
+ jsx: options?.jsx,
1002
+ jsxFactory: options?.jsxFactory,
1003
+ jsxFragment: options?.jsxFragment,
1004
+ tsconfigRaw: options?.tsconfigRaw,
1005
+ define: options?.define,
1006
+ // Dynamic-import lowering: rewrites `import(x)` to
1007
+ // `Promise.resolve().then(() => __toESM(require(x)))` so the
1008
+ // call routes through Nimbus's scopedRequire → VFS lookup
1009
+ // instead of workerd's worker-module-map resolver (which only
1010
+ // knows {'runner.js': workerCode}). Without this, every user
1011
+ // dynamic import() rejects with "No such module ..." — and if
1012
+ // user code has no .catch() (e.g. create-astro.mjs's
1013
+ // `import('./dist/index.js').then(({main}) => main())`), the
1014
+ // rejection is unhandled and the facet exits silently
1015
+ supported: { 'dynamic-import': false },
1016
+ });
1017
+ const { requires, body } = convertEsmImportsToRequire(pass1.code);
1018
+ const assembled = requires + '\n' +
1019
+ 'return (async () => {\n' +
1020
+ body +
1021
+ '\n})();\n';
1022
+ return {
1023
+ code: assembled,
1024
+ map: '',
1025
+ warnings: pass1.warnings?.map((w) => ({
1026
+ text: w.text,
1027
+ location: w.location,
1028
+ })) || [],
1029
+ };
1030
+ }
1031
+ // ── CJS + TLA (no ESM imports): single-pass IIFE wrap (P2 fix) ──
1032
+ let sourceToTransform = code;
1033
+ if (format === 'cjs' && hasTopLevelAwait(code)) {
1034
+ sourceToTransform =
1035
+ 'return (async () => {\n' +
1036
+ code +
1037
+ '\n})();\n';
1038
+ }
1039
+ const result = await this._esbuild.transform(sourceToTransform, {
1040
+ loader,
1041
+ format,
1042
+ target: options?.target || 'esnext',
1043
+ sourcemap: options?.sourcemap ?? false,
1044
+ minify: options?.minify ?? false,
1045
+ jsx: options?.jsx,
1046
+ jsxFactory: options?.jsxFactory,
1047
+ jsxFragment: options?.jsxFragment,
1048
+ tsconfigRaw: options?.tsconfigRaw,
1049
+ define: options?.define,
1050
+ // Dynamic-import lowering — see two-pass branch above for rationale.
1051
+ supported: { 'dynamic-import': false },
1052
+ });
1053
+ return {
1054
+ code: result.code,
1055
+ map: result.map || '',
1056
+ warnings: result.warnings?.map(w => ({
1057
+ text: w.text,
1058
+ location: w.location,
1059
+ })) || [],
1060
+ };
1061
+ }
1062
+ /**
1063
+ * Bundle entry points from the VFS.
1064
+ */
1065
+ async build(entryPoints, options) {
1066
+ await this.ensureInit();
1067
+ // VFS plugin reads directly from VFS (synchronous, co-located)
1068
+ const vfsPlugin = this.makeVfsPlugin();
1069
+ const result = await this._esbuild.build({
1070
+ entryPoints: entryPoints.map(ep => ep.startsWith('/') ? ep : '/' + ep),
1071
+ bundle: options?.bundle ?? true,
1072
+ write: false,
1073
+ format: options?.format || 'esm',
1074
+ target: options?.target || 'esnext',
1075
+ platform: options?.platform || 'browser',
1076
+ outdir: options?.outdir || (options?.outfile ? undefined : '/dist'),
1077
+ outfile: options?.outfile,
1078
+ sourcemap: options?.sourcemap ?? false,
1079
+ minify: options?.minify ?? false,
1080
+ external: options?.external,
1081
+ define: options?.define,
1082
+ globalName: options?.globalName,
1083
+ tsconfigRaw: options?.tsconfigRaw,
1084
+ alias: options?.alias,
1085
+ keepNames: options?.keepNames,
1086
+ // Prefer ESM builds and modern module fields. This matters for packages
1087
+ // like zustand that ship both CJS (main) and ESM (module / exports.import).
1088
+ // Without these, esbuild falls back to CJS which wraps everything in
1089
+ // __commonJS and only emits `export default`, losing named exports.
1090
+ conditions: ['import', 'module', 'browser', 'default'],
1091
+ mainFields: ['module', 'browser', 'main'],
1092
+ plugins: [vfsPlugin],
1093
+ });
1094
+ return {
1095
+ outputFiles: (result.outputFiles || []).map(f => ({
1096
+ path: f.path,
1097
+ contents: f.text,
1098
+ })),
1099
+ errors: result.errors?.map(e => ({ text: e.text, location: e.location })) || [],
1100
+ warnings: result.warnings?.map(w => ({ text: w.text, location: w.location })) || [],
1101
+ };
1102
+ }
1103
+ /**
1104
+ * VFS resolver plugin for esbuild.
1105
+ * Reads directly from the SqliteVFS (synchronous, co-located — no snapshot needed).
1106
+ * Handles: absolute paths, relative paths, bare specifiers (node_modules).
1107
+ */
1108
+ makeVfsPlugin() {
1109
+ const vfs = this.vfs;
1110
+ const EXTS = ['', '.ts', '.tsx', '.js', '.jsx', '.mts', '.mjs', '.cjs', '.json', '.css'];
1111
+ const INDEX_FILES = ['index.ts', 'index.tsx', 'index.js', 'index.jsx', 'index.mjs'];
1112
+ // Path helpers shared with git-commands via ./vfs-path.ts.
1113
+ // Local aliases preserve the existing call-site readability inside this
1114
+ // closure; behavior is identical (the canonical normalizeVfsPath has a
1115
+ // bounds check on `..` that the previous local `normalize` lacked, but
1116
+ // for the well-formed paths esbuild produces this is a no-op).
1117
+ const strip = stripLeadingSlashes;
1118
+ const normalize = normalizeVfsPath;
1119
+ /**
1120
+ * Try to resolve a VFS path with extension/index fallbacks.
1121
+ *
1122
+ * Resolution order (first match wins):
1123
+ * 1. Exact path as given (covers `.ts`, `.js`, `.json`, `.css`, and
1124
+ * any extension on disk) — via `''` being first in EXTS.
1125
+ * 2. Append-extension candidates from EXTS (`.ts`, `.tsx`, `.js`, …)
1126
+ * for extensionless imports like `./foo`.
1127
+ * 3. TypeScript/ESM `moduleResolution: "bundler"` compatibility:
1128
+ * if the input ends in `.js` / `.mjs` / `.cjs` / `.jsx` and
1129
+ * NO file matched above, swap the extension to the TS
1130
+ * equivalent and try those. This is the idiomatic
1131
+ * `import {X} from './y.js'` pattern where on-disk it's `y.ts`.
1132
+ * Order (TS spec): `.ts` → `.tsx` for `.js`/`.jsx`;
1133
+ * `.mts` for `.mjs`;
1134
+ * `.cts` for `.cjs`.
1135
+ * Exact-match (step 1) happens first so a real `.js` on disk
1136
+ * takes precedence over a co-located `.ts` — we never pretend
1137
+ * a `.ts` is canonical when a `.js` actually exists.
1138
+ * 4. Directory index files (e.g. `./foo/index.ts`) as a last step.
1139
+ */
1140
+ function tryResolve(base) {
1141
+ const norm = normalize(base);
1142
+ for (const ext of EXTS) {
1143
+ const candidate = norm + ext;
1144
+ if (vfs.exists(strip(candidate)) && !vfs.isDirectory(strip(candidate))) {
1145
+ return '/' + strip(candidate);
1146
+ }
1147
+ }
1148
+ // Step 3: TypeScript-bundler extension swap. Only runs when no
1149
+ // exact / extension-append match succeeded above — so real `.js`
1150
+ // files on disk always win.
1151
+ const jsExtMatch = norm.match(/\.(js|mjs|cjs|jsx)$/);
1152
+ if (jsExtMatch) {
1153
+ const withoutExt = norm.slice(0, norm.length - jsExtMatch[0].length);
1154
+ const swapMap = {
1155
+ js: ['.ts', '.tsx'],
1156
+ jsx: ['.tsx', '.ts'],
1157
+ mjs: ['.mts', '.ts'],
1158
+ cjs: ['.cts', '.ts'],
1159
+ };
1160
+ const swaps = swapMap[jsExtMatch[1]] || [];
1161
+ for (const tsExt of swaps) {
1162
+ const candidate = withoutExt + tsExt;
1163
+ if (vfs.exists(strip(candidate)) && !vfs.isDirectory(strip(candidate))) {
1164
+ return '/' + strip(candidate);
1165
+ }
1166
+ }
1167
+ }
1168
+ // Step 4: directory index fallback.
1169
+ if (vfs.exists(strip(norm)) && vfs.isDirectory(strip(norm))) {
1170
+ for (const idx of INDEX_FILES) {
1171
+ const candidate = norm + '/' + idx;
1172
+ if (vfs.exists(strip(candidate)))
1173
+ return '/' + strip(candidate);
1174
+ }
1175
+ }
1176
+ return null;
1177
+ }
1178
+ /**
1179
+ * Resolve a Node.js subpath import (`#foo`).
1180
+ *
1181
+ * Per https://nodejs.org/api/packages.html#subpath-imports, a specifier
1182
+ * starting with `#` is looked up in the closest ancestor package.json's
1183
+ * `imports` field (not `exports`). This is used by packages like `vfile`
1184
+ * to switch between node and browser implementations:
1185
+ *
1186
+ * "imports": {
1187
+ * "#minpath": {
1188
+ * "node": "./lib/minpath.js",
1189
+ * "default": "./lib/minpath.browser.js"
1190
+ * }
1191
+ * }
1192
+ *
1193
+ * We walk up from the importer's directory looking for package.json.
1194
+ * Once found, we resolve the subpath using the same condition algorithm
1195
+ * as `exports` (with `import`, `module`, `browser`, `default` — skipping
1196
+ * `node` since we're bundling for the browser).
1197
+ *
1198
+ * The resolved value is a path relative to the owning package root, which
1199
+ * we turn back into a VFS path for esbuild to load.
1200
+ */
1201
+ function resolvePackageImport(specifier, fromDir) {
1202
+ let dir = strip(fromDir);
1203
+ const visited = new Set();
1204
+ while (dir && !visited.has(dir)) {
1205
+ visited.add(dir);
1206
+ const pkgJsonPath = dir + '/package.json';
1207
+ if (vfs.exists(strip(pkgJsonPath))) {
1208
+ try {
1209
+ const pkgJson = JSON.parse(vfs.readFileString(strip(pkgJsonPath)));
1210
+ if (pkgJson.imports) {
1211
+ // resolveExports happens to work for the imports field too —
1212
+ // both are subpath→condition maps using the same format. We
1213
+ // reuse it. The specifier (`#minpath`) IS the subpath key.
1214
+ const resolved = resolveExports(pkgJson.imports, specifier);
1215
+ if (resolved) {
1216
+ // Resolved value is relative to the owning package root
1217
+ const pkgRoot = dir;
1218
+ const absPath = pkgRoot + '/' + resolved.replace(/^\.\//, '');
1219
+ const finalPath = tryResolve(absPath);
1220
+ if (finalPath)
1221
+ return finalPath;
1222
+ }
1223
+ }
1224
+ }
1225
+ catch { /* malformed package.json — try parent */ }
1226
+ }
1227
+ // Stop at node_modules boundary — subpath imports only resolve against
1228
+ // the consuming package's own package.json, not its dependencies'.
1229
+ // But DO go up through node_modules/<pkg>/ to find <pkg>/package.json.
1230
+ if (dir.endsWith('/node_modules') || dir === 'node_modules')
1231
+ break;
1232
+ const lastSlash = dir.lastIndexOf('/');
1233
+ if (lastSlash <= 0)
1234
+ break;
1235
+ dir = dir.substring(0, lastSlash);
1236
+ }
1237
+ return null;
1238
+ }
1239
+ // Conditions per-resolution. CJS `require('X')` callers need the
1240
+ // `require` condition selected so packages that ship a dual-export
1241
+ // CJS trick (e.g. @babel/runtime/helpers/X — `module.exports = fn;
1242
+ // module.exports.default = module.exports;`) resolve to the CJS
1243
+ // file. The ESM helper file declares only `export { fn as default }`,
1244
+ // which esbuild's __toCommonJS wrap surfaces to CJS callers as
1245
+ // `{ default: fn }` — and the downstream callsite calls the
1246
+ // namespace as a function and crashes with
1247
+ // `_objectWithoutPropertiesLoose2 is not a function`.
1248
+ //
1249
+ // This affects every CJS-shipping npm package that depends on
1250
+ // `@babel/runtime/helpers/*` (thousands — anything compiled with
1251
+ // `@babel/preset-env`'s `transform-runtime`).
1252
+ // See pre-bundle-facet.ts for the matching fix in the install-time
1253
+ // pre-bundle plugin. Both code paths must agree.
1254
+ const ESM_CONDITIONS = ['import', 'module', 'browser', 'default'];
1255
+ const CJS_CONDITIONS = ['require', 'node', 'browser', 'default'];
1256
+ /**
1257
+ * Resolve bare specifier (npm package) by walking up node_modules.
1258
+ * Uses the full Node.js exports-field algorithm. `conditions` is
1259
+ * passed through so caller can request CJS-flavoured resolution
1260
+ * (for `require()` calls in bundled CJS code).
1261
+ */
1262
+ function resolveBarePkg(specifier, fromDir, conditions) {
1263
+ // Split scoped packages: @scope/pkg → ["@scope/pkg"]
1264
+ // Split subpath imports: pkg/sub/path → pkg, sub/path
1265
+ let pkgName;
1266
+ let subpath;
1267
+ if (specifier.startsWith('@')) {
1268
+ const parts = specifier.split('/');
1269
+ pkgName = parts.slice(0, 2).join('/');
1270
+ subpath = parts.slice(2).join('/');
1271
+ }
1272
+ else {
1273
+ const parts = specifier.split('/');
1274
+ pkgName = parts[0];
1275
+ subpath = parts.slice(1).join('/');
1276
+ }
1277
+ // Walk up directories looking for node_modules/<pkg>
1278
+ let dir = strip(fromDir);
1279
+ const visited = new Set();
1280
+ while (dir && !visited.has(dir)) {
1281
+ visited.add(dir);
1282
+ const nmDir = dir + '/node_modules/' + pkgName;
1283
+ if (vfs.exists(strip(nmDir)) && vfs.isDirectory(strip(nmDir))) {
1284
+ // Read package.json so we can consult the exports field.
1285
+ const pkgJsonPath = nmDir + '/package.json';
1286
+ let pkgJson = null;
1287
+ if (vfs.exists(strip(pkgJsonPath))) {
1288
+ try {
1289
+ pkgJson = JSON.parse(vfs.readFileString(strip(pkgJsonPath)));
1290
+ }
1291
+ catch { }
1292
+ }
1293
+ if (pkgJson) {
1294
+ // Use the full exports-field resolution. Conditions are
1295
+ // caller-supplied so `require()` and `import` get distinct
1296
+ // resolutions per Node spec.
1297
+ const subpathKey = subpath ? './' + subpath : '.';
1298
+ const entry = resolvePackageEntry(pkgJson, subpathKey, conditions);
1299
+ if (entry) {
1300
+ const resolved = tryResolve(nmDir + '/' + entry.replace(/^\.\//, ''));
1301
+ if (resolved)
1302
+ return resolved;
1303
+ }
1304
+ }
1305
+ // Fallback for subpath: try direct file resolution (e.g. pkg/lib/foo).
1306
+ if (subpath) {
1307
+ const resolved = tryResolve(nmDir + '/' + subpath);
1308
+ if (resolved)
1309
+ return resolved;
1310
+ }
1311
+ // Fallback for root: try index files directly
1312
+ const resolved = tryResolve(nmDir + '/index');
1313
+ if (resolved)
1314
+ return resolved;
1315
+ }
1316
+ // Move up one directory
1317
+ const lastSlash = dir.lastIndexOf('/');
1318
+ if (lastSlash <= 0)
1319
+ break;
1320
+ dir = dir.substring(0, lastSlash);
1321
+ }
1322
+ return null;
1323
+ }
1324
+ function inferLoader(path) {
1325
+ if (path.endsWith('.ts') || path.endsWith('.mts') || path.endsWith('.cts'))
1326
+ return 'ts';
1327
+ if (path.endsWith('.tsx'))
1328
+ return 'tsx';
1329
+ if (path.endsWith('.jsx'))
1330
+ return 'jsx';
1331
+ if (path.endsWith('.json'))
1332
+ return 'json';
1333
+ if (path.endsWith('.css'))
1334
+ return 'css';
1335
+ // Native binaries — load as base64 blobs instead of parsing as JS.
1336
+ // Defense-in-depth: the npm-installer pre-bundler also skips these,
1337
+ // but on-demand bundling or direct `import 'foo.wasm'` could still
1338
+ // hand us a raw WASM/native-addon path.
1339
+ if (path.endsWith('.wasm'))
1340
+ return 'binary';
1341
+ if (path.endsWith('.node'))
1342
+ return 'binary';
1343
+ return 'js';
1344
+ }
1345
+ return {
1346
+ name: 'nimbus-vfs',
1347
+ setup(build) {
1348
+ // Pre-compile the external list into exact matches and prefix patterns.
1349
+ // esbuild's `external` supports glob-like patterns (`react/*`) — we
1350
+ // reproduce that here so our plugin doesn't override the user's
1351
+ // external directive by resolving packages that should stay external.
1352
+ const externalList = build.initialOptions.external || [];
1353
+ const externalExact = new Set();
1354
+ const externalPrefixes = [];
1355
+ for (const pat of externalList) {
1356
+ if (pat.endsWith('/*')) {
1357
+ externalPrefixes.push(pat.slice(0, -1)); // "react/" prefix (for "react/*")
1358
+ }
1359
+ else {
1360
+ externalExact.add(pat);
1361
+ }
1362
+ }
1363
+ const isExternal = (spec) => {
1364
+ if (externalExact.has(spec))
1365
+ return true;
1366
+ for (const pre of externalPrefixes) {
1367
+ if (spec.startsWith(pre))
1368
+ return true;
1369
+ }
1370
+ return false;
1371
+ };
1372
+ build.onResolve({ filter: /.*/ }, (args) => {
1373
+ // 1. Subpath imports (#foo) — Node.js package.json `imports` field.
1374
+ // These MUST be resolved against the owning package's package.json,
1375
+ // not node_modules. Used by vfile, unified, and others to switch
1376
+ // between node/browser implementations.
1377
+ if (args.path.startsWith('#') && args.resolveDir) {
1378
+ const resolved = resolvePackageImport(args.path, strip(args.resolveDir));
1379
+ if (resolved)
1380
+ return { path: resolved, namespace: 'nimbus-vfs' };
1381
+ // If we can't resolve it, fall through — better to leak a bare
1382
+ // import that fails loudly than to pretend it's external.
1383
+ }
1384
+ // 2. Bare specifier + external → leave as-is so the browser resolves
1385
+ // via its own module resolver (which hits /preview/@modules/...).
1386
+ // This MUST come before any vfs resolution, otherwise we'd embed
1387
+ // the package into the bundle and break single-instance invariants
1388
+ // for react/react-dom.
1389
+ if (!args.path.startsWith('/') && !args.path.startsWith('.') && !args.path.startsWith('#')) {
1390
+ if (isExternal(args.path))
1391
+ return { external: true };
1392
+ }
1393
+ // 3. Absolute paths
1394
+ if (args.path.startsWith('/')) {
1395
+ const resolved = tryResolve(args.path);
1396
+ if (resolved)
1397
+ return { path: resolved, namespace: 'nimbus-vfs' };
1398
+ }
1399
+ // 4. Relative paths
1400
+ if (args.path.startsWith('.') && args.resolveDir) {
1401
+ const dir = strip(args.resolveDir);
1402
+ const resolved = tryResolve(dir + '/' + args.path);
1403
+ if (resolved)
1404
+ return { path: resolved, namespace: 'nimbus-vfs' };
1405
+ }
1406
+ // 5. Bare specifier (npm package)
1407
+ if (!args.path.startsWith('/') && !args.path.startsWith('.') && !args.path.startsWith('#')) {
1408
+ const fromDir = args.resolveDir || '/home/user';
1409
+ // Per Node spec: `require()` triggers the 'require' condition,
1410
+ // `import` triggers 'import'. esbuild surfaces this via
1411
+ // args.kind. Without this, packages that ship a dual-export
1412
+ // CJS file alongside a bare ESM file (e.g. @babel/runtime/
1413
+ // helpers/*) get resolved to the ESM variant for CJS callers,
1414
+ // and the `__toCommonJS` wrapper surfaces `{ default: fn }`
1415
+ // to a callsite that expects the function directly — runtime
1416
+ // crash with "<helper>2 is not a function" on the first
1417
+ // route that uses the affected package.
1418
+ const conditions = args.kind === 'require-call' || args.kind === 'require-resolve'
1419
+ ? CJS_CONDITIONS
1420
+ : ESM_CONDITIONS;
1421
+ const resolved = resolveBarePkg(args.path, fromDir, conditions);
1422
+ if (resolved)
1423
+ return { path: resolved, namespace: 'nimbus-vfs' };
1424
+ // Mark as external if not found (common for Node built-ins)
1425
+ return { external: true };
1426
+ }
1427
+ return { external: true };
1428
+ });
1429
+ build.onLoad({ filter: /.*/, namespace: 'nimbus-vfs' }, (args) => {
1430
+ const stripped = strip(args.path);
1431
+ try {
1432
+ const loader = inferLoader(args.path);
1433
+ const lastSlash = stripped.lastIndexOf('/');
1434
+ const resolveDir = lastSlash > 0 ? '/' + stripped.substring(0, lastSlash) : '/';
1435
+ // Binary loaders (wasm, native addons) must receive raw bytes.
1436
+ // TextDecoder would corrupt them with U+FFFD replacement chars.
1437
+ if (loader === 'binary') {
1438
+ const bytes = vfs.readFile(stripped);
1439
+ return { contents: bytes, loader, resolveDir };
1440
+ }
1441
+ const contents = vfs.readFileString(stripped);
1442
+ return { contents, loader, resolveDir };
1443
+ }
1444
+ catch {
1445
+ return { errors: [{ text: 'File not found in VFS: ' + args.path }] };
1446
+ }
1447
+ });
1448
+ },
1449
+ };
1450
+ }
1451
+ get isInitialized() { return this.initialized; }
1452
+ }