@seanhogg/builderforce-webcontainers-core 2026.10.2 → 2026.10.3

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 (426) hide show
  1. package/dist/build.d.ts +42 -0
  2. package/dist/build.d.ts.map +1 -0
  3. package/dist/build.js +65 -0
  4. package/dist/build.js.map +1 -0
  5. package/dist/buildHost.d.ts +31 -0
  6. package/dist/buildHost.d.ts.map +1 -0
  7. package/dist/buildHost.js +125 -0
  8. package/dist/buildHost.js.map +1 -0
  9. package/dist/buildHtml.d.ts +28 -0
  10. package/dist/buildHtml.d.ts.map +1 -0
  11. package/dist/buildHtml.js +74 -0
  12. package/dist/buildHtml.js.map +1 -0
  13. package/dist/bundler.d.ts +129 -0
  14. package/dist/bundler.d.ts.map +1 -0
  15. package/dist/bundler.js +79 -0
  16. package/dist/bundler.js.map +1 -0
  17. package/dist/check/acquire.d.ts +46 -0
  18. package/dist/check/acquire.d.ts.map +1 -0
  19. package/dist/check/acquire.js +179 -0
  20. package/dist/check/acquire.js.map +1 -0
  21. package/dist/check/compilerHost.d.ts +22 -0
  22. package/dist/check/compilerHost.d.ts.map +1 -0
  23. package/dist/check/compilerHost.js +128 -0
  24. package/dist/check/compilerHost.js.map +1 -0
  25. package/dist/check/diagnostics.d.ts +23 -0
  26. package/dist/check/diagnostics.d.ts.map +1 -0
  27. package/dist/check/diagnostics.js +28 -0
  28. package/dist/check/diagnostics.js.map +1 -0
  29. package/dist/check/index.d.ts +19 -0
  30. package/dist/check/index.d.ts.map +1 -0
  31. package/dist/check/index.js +13 -0
  32. package/dist/check/index.js.map +1 -0
  33. package/dist/check/projects.d.ts +26 -0
  34. package/dist/check/projects.d.ts.map +1 -0
  35. package/dist/check/projects.js +124 -0
  36. package/dist/check/projects.js.map +1 -0
  37. package/dist/check/shims.d.ts +29 -0
  38. package/dist/check/shims.d.ts.map +1 -0
  39. package/dist/check/shims.js +76 -0
  40. package/dist/check/shims.js.map +1 -0
  41. package/dist/check/typeStore.d.ts +57 -0
  42. package/dist/check/typeStore.d.ts.map +1 -0
  43. package/dist/check/typeStore.js +89 -0
  44. package/dist/check/typeStore.js.map +1 -0
  45. package/dist/check/typecheck.d.ts +29 -0
  46. package/dist/check/typecheck.d.ts.map +1 -0
  47. package/dist/check/typecheck.js +91 -0
  48. package/dist/check/typecheck.js.map +1 -0
  49. package/dist/compileComponent.d.ts +8 -0
  50. package/dist/compileComponent.d.ts.map +1 -0
  51. package/dist/compileComponent.js +22 -0
  52. package/dist/compileComponent.js.map +1 -0
  53. package/dist/compileScript.d.ts +19 -4
  54. package/dist/compileScript.d.ts.map +1 -1
  55. package/dist/compileScript.js +37 -12
  56. package/dist/compileScript.js.map +1 -1
  57. package/dist/components.d.ts +41 -0
  58. package/dist/components.d.ts.map +1 -0
  59. package/dist/components.js +14 -0
  60. package/dist/components.js.map +1 -0
  61. package/dist/detectProject.d.ts +3 -0
  62. package/dist/detectProject.d.ts.map +1 -1
  63. package/dist/detectProject.js +16 -6
  64. package/dist/detectProject.js.map +1 -1
  65. package/dist/devServer.d.ts +5 -2
  66. package/dist/devServer.d.ts.map +1 -1
  67. package/dist/devServer.js +10 -6
  68. package/dist/devServer.js.map +1 -1
  69. package/dist/hash.d.ts +2 -0
  70. package/dist/hash.d.ts.map +1 -0
  71. package/dist/hash.js +22 -0
  72. package/dist/hash.js.map +1 -0
  73. package/dist/index.d.ts +24 -6
  74. package/dist/index.d.ts.map +1 -1
  75. package/dist/index.js +14 -3
  76. package/dist/index.js.map +1 -1
  77. package/dist/installer/bins.d.ts +24 -0
  78. package/dist/installer/bins.d.ts.map +1 -0
  79. package/dist/installer/bins.js +56 -0
  80. package/dist/installer/bins.js.map +1 -0
  81. package/dist/installer/index.d.ts +14 -0
  82. package/dist/installer/index.d.ts.map +1 -0
  83. package/dist/installer/index.js +9 -0
  84. package/dist/installer/index.js.map +1 -0
  85. package/dist/installer/install.d.ts +46 -0
  86. package/dist/installer/install.d.ts.map +1 -0
  87. package/dist/installer/install.js +245 -0
  88. package/dist/installer/install.js.map +1 -0
  89. package/dist/installer/lockfile.d.ts +49 -0
  90. package/dist/installer/lockfile.d.ts.map +1 -0
  91. package/dist/installer/lockfile.js +110 -0
  92. package/dist/installer/lockfile.js.map +1 -0
  93. package/dist/installer/registry.d.ts +84 -0
  94. package/dist/installer/registry.d.ts.map +1 -0
  95. package/dist/installer/registry.js +130 -0
  96. package/dist/installer/registry.js.map +1 -0
  97. package/dist/installer/semver.d.ts +38 -0
  98. package/dist/installer/semver.d.ts.map +1 -0
  99. package/dist/installer/semver.js +187 -0
  100. package/dist/installer/semver.js.map +1 -0
  101. package/dist/installer/spec.d.ts +30 -0
  102. package/dist/installer/spec.d.ts.map +1 -0
  103. package/dist/installer/spec.js +30 -0
  104. package/dist/installer/spec.js.map +1 -0
  105. package/dist/installer/tar.d.ts +17 -0
  106. package/dist/installer/tar.d.ts.map +1 -0
  107. package/dist/installer/tar.js +150 -0
  108. package/dist/installer/tar.js.map +1 -0
  109. package/dist/installer/tree.d.ts +48 -0
  110. package/dist/installer/tree.d.ts.map +1 -0
  111. package/dist/installer/tree.js +179 -0
  112. package/dist/installer/tree.js.map +1 -0
  113. package/dist/node/assert.d.ts +15 -0
  114. package/dist/node/assert.d.ts.map +1 -0
  115. package/dist/node/assert.js +137 -0
  116. package/dist/node/assert.js.map +1 -0
  117. package/dist/node/buffer.d.ts +84 -0
  118. package/dist/node/buffer.d.ts.map +1 -0
  119. package/dist/node/buffer.js +304 -0
  120. package/dist/node/buffer.js.map +1 -0
  121. package/dist/node/builtins.d.ts +25 -0
  122. package/dist/node/builtins.d.ts.map +1 -0
  123. package/dist/node/builtins.js +101 -0
  124. package/dist/node/builtins.js.map +1 -0
  125. package/dist/node/callable.d.ts +13 -0
  126. package/dist/node/callable.d.ts.map +1 -0
  127. package/dist/node/callable.js +26 -0
  128. package/dist/node/callable.js.map +1 -0
  129. package/dist/node/childProcess.d.ts +13 -0
  130. package/dist/node/childProcess.d.ts.map +1 -0
  131. package/dist/node/childProcess.js +143 -0
  132. package/dist/node/childProcess.js.map +1 -0
  133. package/dist/node/crypto.d.ts +3 -0
  134. package/dist/node/crypto.d.ts.map +1 -0
  135. package/dist/node/crypto.js +180 -0
  136. package/dist/node/crypto.js.map +1 -0
  137. package/dist/node/esm.d.ts +9 -0
  138. package/dist/node/esm.d.ts.map +1 -0
  139. package/dist/node/esm.js +202 -0
  140. package/dist/node/esm.js.map +1 -0
  141. package/dist/node/events.d.ts +40 -0
  142. package/dist/node/events.d.ts.map +1 -0
  143. package/dist/node/events.js +160 -0
  144. package/dist/node/events.js.map +1 -0
  145. package/dist/node/fs/index.d.ts +7 -0
  146. package/dist/node/fs/index.d.ts.map +1 -0
  147. package/dist/node/fs/index.js +270 -0
  148. package/dist/node/fs/index.js.map +1 -0
  149. package/dist/node/fs/stats.d.ts +93 -0
  150. package/dist/node/fs/stats.d.ts.map +1 -0
  151. package/dist/node/fs/stats.js +104 -0
  152. package/dist/node/fs/stats.js.map +1 -0
  153. package/dist/node/fs/sync.d.ts +98 -0
  154. package/dist/node/fs/sync.d.ts.map +1 -0
  155. package/dist/node/fs/sync.js +348 -0
  156. package/dist/node/fs/sync.js.map +1 -0
  157. package/dist/node/hashes.d.ts +15 -0
  158. package/dist/node/hashes.d.ts.map +1 -0
  159. package/dist/node/hashes.js +195 -0
  160. package/dist/node/hashes.js.map +1 -0
  161. package/dist/node/http/client.d.ts +35 -0
  162. package/dist/node/http/client.d.ts.map +1 -0
  163. package/dist/node/http/client.js +161 -0
  164. package/dist/node/http/client.js.map +1 -0
  165. package/dist/node/http/index.d.ts +5 -0
  166. package/dist/node/http/index.d.ts.map +1 -0
  167. package/dist/node/http/index.js +125 -0
  168. package/dist/node/http/index.js.map +1 -0
  169. package/dist/node/http/server.d.ts +135 -0
  170. package/dist/node/http/server.d.ts.map +1 -0
  171. package/dist/node/http/server.js +308 -0
  172. package/dist/node/http/server.js.map +1 -0
  173. package/dist/node/http/status.d.ts +3 -0
  174. package/dist/node/http/status.d.ts.map +1 -0
  175. package/dist/node/http/status.js +13 -0
  176. package/dist/node/http/status.js.map +1 -0
  177. package/dist/node/inspect.d.ts +22 -0
  178. package/dist/node/inspect.d.ts.map +1 -0
  179. package/dist/node/inspect.js +172 -0
  180. package/dist/node/inspect.js.map +1 -0
  181. package/dist/node/loader.d.ts +91 -0
  182. package/dist/node/loader.d.ts.map +1 -0
  183. package/dist/node/loader.js +265 -0
  184. package/dist/node/loader.js.map +1 -0
  185. package/dist/node/loop.d.ts +71 -0
  186. package/dist/node/loop.d.ts.map +1 -0
  187. package/dist/node/loop.js +189 -0
  188. package/dist/node/loop.js.map +1 -0
  189. package/dist/node/misc.d.ts +10 -0
  190. package/dist/node/misc.d.ts.map +1 -0
  191. package/dist/node/misc.js +256 -0
  192. package/dist/node/misc.js.map +1 -0
  193. package/dist/node/path.d.ts +14 -0
  194. package/dist/node/path.d.ts.map +1 -0
  195. package/dist/node/path.js +128 -0
  196. package/dist/node/path.js.map +1 -0
  197. package/dist/node/process.d.ts +31 -0
  198. package/dist/node/process.d.ts.map +1 -0
  199. package/dist/node/process.js +309 -0
  200. package/dist/node/process.js.map +1 -0
  201. package/dist/node/program.d.ts +19 -0
  202. package/dist/node/program.d.ts.map +1 -0
  203. package/dist/node/program.js +165 -0
  204. package/dist/node/program.js.map +1 -0
  205. package/dist/node/readline.d.ts +2 -0
  206. package/dist/node/readline.d.ts.map +1 -0
  207. package/dist/node/readline.js +155 -0
  208. package/dist/node/readline.js.map +1 -0
  209. package/dist/node/resolve.d.ts +45 -0
  210. package/dist/node/resolve.d.ts.map +1 -0
  211. package/dist/node/resolve.js +206 -0
  212. package/dist/node/resolve.js.map +1 -0
  213. package/dist/node/runtime.d.ts +40 -0
  214. package/dist/node/runtime.d.ts.map +1 -0
  215. package/dist/node/runtime.js +149 -0
  216. package/dist/node/runtime.js.map +1 -0
  217. package/dist/node/stream/index.d.ts +52 -0
  218. package/dist/node/stream/index.d.ts.map +1 -0
  219. package/dist/node/stream/index.js +184 -0
  220. package/dist/node/stream/index.js.map +1 -0
  221. package/dist/node/stream/readable.d.ts +83 -0
  222. package/dist/node/stream/readable.d.ts.map +1 -0
  223. package/dist/node/stream/readable.js +325 -0
  224. package/dist/node/stream/readable.js.map +1 -0
  225. package/dist/node/stream/writable.d.ts +80 -0
  226. package/dist/node/stream/writable.d.ts.map +1 -0
  227. package/dist/node/stream/writable.js +224 -0
  228. package/dist/node/stream/writable.js.map +1 -0
  229. package/dist/node/urlqs.d.ts +22 -0
  230. package/dist/node/urlqs.d.ts.map +1 -0
  231. package/dist/node/urlqs.js +165 -0
  232. package/dist/node/urlqs.js.map +1 -0
  233. package/dist/node/util.d.ts +37 -0
  234. package/dist/node/util.d.ts.map +1 -0
  235. package/dist/node/util.js +160 -0
  236. package/dist/node/util.js.map +1 -0
  237. package/dist/node/zlib.d.ts +2 -0
  238. package/dist/node/zlib.d.ts.map +1 -0
  239. package/dist/node/zlib.js +133 -0
  240. package/dist/node/zlib.js.map +1 -0
  241. package/dist/packageCdn.d.ts +12 -0
  242. package/dist/packageCdn.d.ts.map +1 -1
  243. package/dist/packageCdn.js +3 -1
  244. package/dist/packageCdn.js.map +1 -1
  245. package/dist/projectConfig.d.ts +6 -2
  246. package/dist/projectConfig.d.ts.map +1 -1
  247. package/dist/projectConfig.js +32 -8
  248. package/dist/projectConfig.js.map +1 -1
  249. package/dist/shell/builtins.d.ts +23 -0
  250. package/dist/shell/builtins.d.ts.map +1 -0
  251. package/dist/shell/builtins.js +131 -0
  252. package/dist/shell/builtins.js.map +1 -0
  253. package/dist/shell/context.d.ts +41 -0
  254. package/dist/shell/context.d.ts.map +1 -0
  255. package/dist/shell/context.js +65 -0
  256. package/dist/shell/context.js.map +1 -0
  257. package/dist/shell/devHandoff.d.ts +18 -0
  258. package/dist/shell/devHandoff.d.ts.map +1 -0
  259. package/dist/shell/devHandoff.js +36 -0
  260. package/dist/shell/devHandoff.js.map +1 -0
  261. package/dist/shell/exec.d.ts +67 -0
  262. package/dist/shell/exec.d.ts.map +1 -0
  263. package/dist/shell/exec.js +247 -0
  264. package/dist/shell/exec.js.map +1 -0
  265. package/dist/shell/expand.d.ts +28 -0
  266. package/dist/shell/expand.d.ts.map +1 -0
  267. package/dist/shell/expand.js +149 -0
  268. package/dist/shell/expand.js.map +1 -0
  269. package/dist/shell/fileCommands.d.ts +10 -0
  270. package/dist/shell/fileCommands.d.ts.map +1 -0
  271. package/dist/shell/fileCommands.js +208 -0
  272. package/dist/shell/fileCommands.js.map +1 -0
  273. package/dist/shell/lineEditor.d.ts +43 -0
  274. package/dist/shell/lineEditor.d.ts.map +1 -0
  275. package/dist/shell/lineEditor.js +234 -0
  276. package/dist/shell/lineEditor.js.map +1 -0
  277. package/dist/shell/npm.d.ts +6 -0
  278. package/dist/shell/npm.d.ts.map +1 -0
  279. package/dist/shell/npm.js +234 -0
  280. package/dist/shell/npm.js.map +1 -0
  281. package/dist/shell/parse.d.ts +73 -0
  282. package/dist/shell/parse.d.ts.map +1 -0
  283. package/dist/shell/parse.js +300 -0
  284. package/dist/shell/parse.js.map +1 -0
  285. package/dist/shell/program.d.ts +12 -0
  286. package/dist/shell/program.d.ts.map +1 -0
  287. package/dist/shell/program.js +219 -0
  288. package/dist/shell/program.js.map +1 -0
  289. package/dist/shell/textCommands.d.ts +15 -0
  290. package/dist/shell/textCommands.d.ts.map +1 -0
  291. package/dist/shell/textCommands.js +185 -0
  292. package/dist/shell/textCommands.js.map +1 -0
  293. package/dist/styleModules.d.ts +6 -0
  294. package/dist/styleModules.d.ts.map +1 -1
  295. package/dist/styleModules.js +14 -4
  296. package/dist/styleModules.js.map +1 -1
  297. package/dist/svelteCompiler.d.ts +28 -0
  298. package/dist/svelteCompiler.d.ts.map +1 -0
  299. package/dist/svelteCompiler.js +13 -0
  300. package/dist/svelteCompiler.js.map +1 -0
  301. package/dist/system/commands.d.ts +26 -0
  302. package/dist/system/commands.d.ts.map +1 -0
  303. package/dist/system/commands.js +53 -0
  304. package/dist/system/commands.js.map +1 -0
  305. package/dist/system/index.d.ts +23 -0
  306. package/dist/system/index.d.ts.map +1 -0
  307. package/dist/system/index.js +16 -0
  308. package/dist/system/index.js.map +1 -0
  309. package/dist/system/kernel.d.ts +54 -0
  310. package/dist/system/kernel.d.ts.map +1 -0
  311. package/dist/system/kernel.js +81 -0
  312. package/dist/system/kernel.js.map +1 -0
  313. package/dist/system/ports.d.ts +32 -0
  314. package/dist/system/ports.d.ts.map +1 -0
  315. package/dist/system/ports.js +57 -0
  316. package/dist/system/ports.js.map +1 -0
  317. package/dist/system/process.d.ts +32 -0
  318. package/dist/system/process.d.ts.map +1 -0
  319. package/dist/system/process.js +130 -0
  320. package/dist/system/process.js.map +1 -0
  321. package/dist/system/programs.d.ts +10 -0
  322. package/dist/system/programs.d.ts.map +1 -0
  323. package/dist/system/programs.js +22 -0
  324. package/dist/system/programs.js.map +1 -0
  325. package/dist/system/terminal.d.ts +45 -0
  326. package/dist/system/terminal.d.ts.map +1 -0
  327. package/dist/system/terminal.js +127 -0
  328. package/dist/system/terminal.js.map +1 -0
  329. package/dist/system/types.d.ts +100 -0
  330. package/dist/system/types.d.ts.map +1 -0
  331. package/dist/system/types.js +2 -0
  332. package/dist/system/types.js.map +1 -0
  333. package/dist/vfs.d.ts +28 -4
  334. package/dist/vfs.d.ts.map +1 -1
  335. package/dist/vfs.js +95 -32
  336. package/dist/vfs.js.map +1 -1
  337. package/dist/vueCompiler.d.ts +75 -0
  338. package/dist/vueCompiler.d.ts.map +1 -0
  339. package/dist/vueCompiler.js +67 -0
  340. package/dist/vueCompiler.js.map +1 -0
  341. package/package.json +18 -2
  342. package/src/build.ts +105 -0
  343. package/src/buildHost.ts +154 -0
  344. package/src/buildHtml.ts +101 -0
  345. package/src/bundler.ts +190 -0
  346. package/src/check/acquire.ts +212 -0
  347. package/src/check/compilerHost.ts +138 -0
  348. package/src/check/diagnostics.ts +48 -0
  349. package/src/check/index.ts +28 -0
  350. package/src/check/projects.ts +149 -0
  351. package/src/check/shims.ts +88 -0
  352. package/src/check/typeStore.ts +103 -0
  353. package/src/check/typecheck.ts +134 -0
  354. package/src/compileComponent.ts +21 -0
  355. package/src/compileScript.ts +42 -13
  356. package/src/components.ts +59 -0
  357. package/src/detectProject.ts +18 -6
  358. package/src/devServer.ts +13 -8
  359. package/src/hash.ts +22 -0
  360. package/src/index.ts +35 -6
  361. package/src/installer/bins.ts +64 -0
  362. package/src/installer/index.ts +13 -0
  363. package/src/installer/install.ts +275 -0
  364. package/src/installer/lockfile.ts +146 -0
  365. package/src/installer/registry.ts +175 -0
  366. package/src/installer/semver.ts +190 -0
  367. package/src/installer/spec.ts +53 -0
  368. package/src/installer/tar.ts +155 -0
  369. package/src/installer/tree.ts +236 -0
  370. package/src/node/assert.ts +127 -0
  371. package/src/node/buffer.ts +304 -0
  372. package/src/node/builtins.ts +123 -0
  373. package/src/node/callable.ts +25 -0
  374. package/src/node/childProcess.ts +164 -0
  375. package/src/node/crypto.ts +187 -0
  376. package/src/node/esm.ts +196 -0
  377. package/src/node/events.ts +176 -0
  378. package/src/node/fs/index.ts +277 -0
  379. package/src/node/fs/stats.ts +110 -0
  380. package/src/node/fs/sync.ts +335 -0
  381. package/src/node/hashes.ts +171 -0
  382. package/src/node/http/client.ts +173 -0
  383. package/src/node/http/index.ts +122 -0
  384. package/src/node/http/server.ts +308 -0
  385. package/src/node/http/status.ts +13 -0
  386. package/src/node/inspect.ts +166 -0
  387. package/src/node/loader.ts +293 -0
  388. package/src/node/loop.ts +193 -0
  389. package/src/node/misc.ts +250 -0
  390. package/src/node/path.ts +135 -0
  391. package/src/node/process.ts +324 -0
  392. package/src/node/program.ts +170 -0
  393. package/src/node/readline.ts +157 -0
  394. package/src/node/resolve.ts +216 -0
  395. package/src/node/runtime.ts +184 -0
  396. package/src/node/stream/index.ts +196 -0
  397. package/src/node/stream/readable.ts +345 -0
  398. package/src/node/stream/writable.ts +244 -0
  399. package/src/node/urlqs.ts +162 -0
  400. package/src/node/util.ts +145 -0
  401. package/src/node/zlib.ts +145 -0
  402. package/src/packageCdn.ts +11 -1
  403. package/src/projectConfig.ts +34 -7
  404. package/src/shell/builtins.ts +141 -0
  405. package/src/shell/context.ts +89 -0
  406. package/src/shell/devHandoff.ts +49 -0
  407. package/src/shell/exec.ts +268 -0
  408. package/src/shell/expand.ts +145 -0
  409. package/src/shell/fileCommands.ts +206 -0
  410. package/src/shell/lineEditor.ts +233 -0
  411. package/src/shell/npm.ts +229 -0
  412. package/src/shell/parse.ts +295 -0
  413. package/src/shell/program.ts +223 -0
  414. package/src/shell/textCommands.ts +177 -0
  415. package/src/styleModules.ts +15 -4
  416. package/src/svelteCompiler.ts +31 -0
  417. package/src/system/commands.ts +72 -0
  418. package/src/system/index.ts +22 -0
  419. package/src/system/kernel.ts +106 -0
  420. package/src/system/ports.ts +73 -0
  421. package/src/system/process.ts +158 -0
  422. package/src/system/programs.ts +31 -0
  423. package/src/system/terminal.ts +135 -0
  424. package/src/system/types.ts +103 -0
  425. package/src/vfs.ts +92 -28
  426. package/src/vueCompiler.ts +121 -0
@@ -0,0 +1,250 @@
1
+ /**
2
+ * The small builtins: os, tty, timers (+promises), string_decoder, perf_hooks,
3
+ * async_hooks, worker_threads, vm, dns, v8, diagnostics_channel and stubs for
4
+ * the ones with nothing to offer in a browser (cluster, inspector). Each exists
5
+ * so `require` succeeds and the common calls behave plausibly.
6
+ */
7
+ import { EventEmitterBase } from './events.js';
8
+ import type { EventLoop } from './loop.js';
9
+ import { decode } from './buffer.js';
10
+ import { callable } from './callable.js';
11
+
12
+ export function createOsModule(env: () => Record<string, string | undefined>): Record<string, unknown> {
13
+ const cpus = Array.from({ length: Math.max(1, Math.min(16, globalThis.navigator?.hardwareConcurrency ?? 4)) }, () => ({
14
+ model: 'Browser CPU',
15
+ speed: 2400,
16
+ times: { user: 0, nice: 0, sys: 0, idle: 0, irq: 0 },
17
+ }));
18
+ return {
19
+ EOL: '\n',
20
+ devNull: '/dev/null',
21
+ platform: () => 'linux',
22
+ type: () => 'Linux',
23
+ release: () => '6.1.0-bfwc',
24
+ version: () => '#1 SMP BuilderForce WebContainers',
25
+ machine: () => 'x86_64',
26
+ arch: () => 'x64',
27
+ hostname: () => 'localhost',
28
+ homedir: () => env().HOME ?? '/home/user',
29
+ tmpdir: () => env().TMPDIR ?? '/tmp',
30
+ userInfo: () => ({ uid: 1000, gid: 1000, username: env().USER ?? 'user', homedir: env().HOME ?? '/home/user', shell: '/bin/jsh' }),
31
+ cpus: () => cpus,
32
+ availableParallelism: () => cpus.length,
33
+ totalmem: () => 4 * 1024 ** 3,
34
+ freemem: () => 2 * 1024 ** 3,
35
+ loadavg: () => [0, 0, 0],
36
+ uptime: () => Math.floor(performance.now() / 1000),
37
+ networkInterfaces: () => ({ lo: [{ address: '127.0.0.1', netmask: '255.0.0.0', family: 'IPv4', mac: '00:00:00:00:00:00', internal: true, cidr: '127.0.0.1/8' }] }),
38
+ endianness: () => 'LE',
39
+ getPriority: () => 0,
40
+ setPriority: () => undefined,
41
+ constants: { signals: { SIGHUP: 1, SIGINT: 2, SIGQUIT: 3, SIGKILL: 9, SIGTERM: 15 }, errno: {}, priority: {} },
42
+ };
43
+ }
44
+
45
+ export function createTtyModule(isTerminal: boolean): Record<string, unknown> {
46
+ return {
47
+ isatty: (fd: number) => isTerminal && fd >= 0 && fd <= 2,
48
+ ReadStream: class extends EventEmitterBase {},
49
+ WriteStream: class extends EventEmitterBase {},
50
+ };
51
+ }
52
+
53
+ export function createTimersModule(loop: EventLoop): Record<string, unknown> {
54
+ const promises = {
55
+ setTimeout: (ms?: number, value?: unknown, options?: { signal?: AbortSignal }) =>
56
+ new Promise((resolve, reject) => {
57
+ const t = loop.setTimeout(() => resolve(value), ms);
58
+ options?.signal?.addEventListener('abort', () => {
59
+ loop.clearTimeout(t);
60
+ reject(Object.assign(new Error('The operation was aborted'), { name: 'AbortError', code: 'ABORT_ERR' }));
61
+ });
62
+ }),
63
+ setImmediate: (value?: unknown) => new Promise((resolve) => loop.setImmediate(() => resolve(value))),
64
+ async *setInterval(ms?: number, value?: unknown) {
65
+ while (true) {
66
+ await new Promise((resolve) => loop.setTimeout(resolve, ms));
67
+ yield value;
68
+ }
69
+ },
70
+ scheduler: { wait: (ms: number) => new Promise((resolve) => loop.setTimeout(resolve, ms)), yield: () => new Promise((resolve) => loop.setImmediate(resolve)) },
71
+ };
72
+ return {
73
+ setTimeout: loop.setTimeout,
74
+ clearTimeout: loop.clearTimeout,
75
+ setInterval: loop.setInterval,
76
+ clearInterval: loop.clearInterval,
77
+ setImmediate: loop.setImmediate,
78
+ clearImmediate: loop.clearImmediate,
79
+ promises,
80
+ };
81
+ }
82
+
83
+ export function createStringDecoderModule(): Record<string, unknown> {
84
+ const init = (self: { encoding: string; utf8?: TextDecoder }, encoding?: string) => {
85
+ self.encoding = (encoding ?? 'utf8').toLowerCase().replace('-', '');
86
+ if (self.encoding === 'utf8') self.utf8 = new TextDecoder('utf-8');
87
+ };
88
+ class StringDecoderBase {
89
+ declare encoding: string;
90
+ declare utf8?: TextDecoder;
91
+ constructor(encoding?: string) {
92
+ init(this, encoding);
93
+ }
94
+ write(chunk: Uint8Array | string): string {
95
+ if (typeof chunk === 'string') return chunk;
96
+ return this.utf8 ? this.utf8.decode(chunk, { stream: true }) : decode(chunk, this.encoding);
97
+ }
98
+ end(chunk?: Uint8Array | string): string {
99
+ const head = chunk === undefined ? '' : this.write(chunk);
100
+ return head + (this.utf8 ? this.utf8.decode() : '');
101
+ }
102
+ }
103
+ // iconv-lite (body-parser) subclasses it the pre-ES2015 way: StringDecoder.call(this, enc).
104
+ return { StringDecoder: callable(StringDecoderBase, init) };
105
+ }
106
+
107
+ export function createAsyncHooksModule(): Record<string, unknown> {
108
+ /**
109
+ * Context does not propagate across awaits here (that needs engine support);
110
+ * `run` scopes the store for synchronous code and whatever reads it in the
111
+ * same tick, which is how most request-scoped loggers use it.
112
+ */
113
+ class AsyncLocalStorage<T> {
114
+ private store: T | undefined;
115
+ getStore(): T | undefined {
116
+ return this.store;
117
+ }
118
+ run<R>(store: T, fn: (...args: unknown[]) => R, ...args: unknown[]): R {
119
+ const previous = this.store;
120
+ this.store = store;
121
+ try {
122
+ return fn(...args);
123
+ } finally {
124
+ this.store = previous;
125
+ }
126
+ }
127
+ enterWith(store: T): void {
128
+ this.store = store;
129
+ }
130
+ exit<R>(fn: (...args: unknown[]) => R, ...args: unknown[]): R {
131
+ return this.run(undefined as T, fn, ...args);
132
+ }
133
+ disable(): void {
134
+ this.store = undefined;
135
+ }
136
+ static bind<F>(fn: F): F {
137
+ return fn;
138
+ }
139
+ static snapshot() {
140
+ return <R>(fn: (...args: unknown[]) => R, ...args: unknown[]) => fn(...args);
141
+ }
142
+ }
143
+ class AsyncResource {
144
+ constructor(readonly type: string) {}
145
+ runInAsyncScope<R>(fn: (...args: unknown[]) => R, thisArg?: unknown, ...args: unknown[]): R {
146
+ return fn.apply(thisArg, args);
147
+ }
148
+ bind<F>(fn: F): F {
149
+ return fn;
150
+ }
151
+ static bind<F>(fn: F): F {
152
+ return fn;
153
+ }
154
+ emitDestroy(): this {
155
+ return this;
156
+ }
157
+ asyncId(): number {
158
+ return 1;
159
+ }
160
+ triggerAsyncId(): number {
161
+ return 0;
162
+ }
163
+ }
164
+ return {
165
+ AsyncLocalStorage,
166
+ AsyncResource,
167
+ createHook: () => ({ enable() { return this; }, disable() { return this; } }),
168
+ executionAsyncId: () => 1,
169
+ triggerAsyncId: () => 0,
170
+ executionAsyncResource: () => ({}),
171
+ };
172
+ }
173
+
174
+ export function createVmModule(): Record<string, unknown> {
175
+ const run = (code: string, context: Record<string, unknown> = {}) => {
176
+ const names = Object.keys(context).filter((k) => /^[A-Za-z_$][\w$]*$/.test(k));
177
+ return new Function(...names, `return eval(${JSON.stringify(code)})`)(...names.map((n) => context[n]));
178
+ };
179
+ class Script {
180
+ constructor(private readonly code: string) {}
181
+ runInThisContext(): unknown {
182
+ return (0, eval)(this.code);
183
+ }
184
+ runInNewContext(context?: Record<string, unknown>): unknown {
185
+ return run(this.code, context);
186
+ }
187
+ runInContext(context: Record<string, unknown>): unknown {
188
+ return run(this.code, context);
189
+ }
190
+ }
191
+ return {
192
+ Script,
193
+ runInThisContext: (code: string) => (0, eval)(code),
194
+ runInNewContext: run,
195
+ runInContext: run,
196
+ createContext: (context: Record<string, unknown> = {}) => context,
197
+ isContext: () => true,
198
+ compileFunction: (code: string, params: string[] = []) => new Function(...params, code),
199
+ };
200
+ }
201
+
202
+ export function createDiagnosticsChannelModule(): Record<string, unknown> {
203
+ const channels = new Map<string, { subscribers: Set<(message: unknown, name: string) => void>; name: string }>();
204
+ const channel = (name: string) => {
205
+ let c = channels.get(name);
206
+ if (!c) {
207
+ const subscribers = new Set<(message: unknown, name: string) => void>();
208
+ c = Object.assign({ subscribers, name }, {
209
+ get hasSubscribers() { return subscribers.size > 0; },
210
+ publish: (message: unknown) => subscribers.forEach((s) => s(message, name)),
211
+ subscribe: (fn: (message: unknown, name: string) => void) => void subscribers.add(fn),
212
+ unsubscribe: (fn: (message: unknown, name: string) => void) => subscribers.delete(fn),
213
+ });
214
+ channels.set(name, c);
215
+ }
216
+ return c;
217
+ };
218
+ return {
219
+ channel,
220
+ hasSubscribers: (name: string) => (channels.get(name)?.subscribers.size ?? 0) > 0,
221
+ subscribe: (name: string, fn: (m: unknown, n: string) => void) => channel(name).subscribers.add(fn),
222
+ unsubscribe: (name: string, fn: (m: unknown, n: string) => void) => channel(name).subscribers.delete(fn),
223
+ tracingChannel: (name: string) => ({ start: channel(`tracing:${name}:start`), end: channel(`tracing:${name}:end`), error: channel(`tracing:${name}:error`), traceSync: <R>(fn: () => R) => fn(), tracePromise: <R>(fn: () => R) => fn() }),
224
+ };
225
+ }
226
+
227
+ const unavailable = (name: string) => () => {
228
+ throw Object.assign(new Error(`${name} is not available in the browser runtime`), { code: 'ERR_FEATURE_UNAVAILABLE_ON_PLATFORM' });
229
+ };
230
+
231
+ export function createStubModules(): Record<string, Record<string, unknown>> {
232
+ return {
233
+ perf_hooks: { performance: globalThis.performance, PerformanceObserver: class { observe() {} disconnect() {} }, monitorEventLoopDelay: () => ({ enable() {}, disable() {}, percentile: () => 0, mean: 0, max: 0, min: 0 }), constants: {} },
234
+ worker_threads: { isMainThread: true, parentPort: null, workerData: null, threadId: 0, resourceLimits: {}, Worker: unavailable('worker_threads.Worker'), MessageChannel, MessagePort: globalThis.MessagePort, BroadcastChannel: globalThis.BroadcastChannel, markAsUntransferable: () => undefined, SHARE_ENV: Symbol('SHARE_ENV') },
235
+ dns: { lookup: (host: string, options: unknown, cb?: (e: Error | null, address: string, family: number) => void) => queueMicrotask(() => ((typeof options === 'function' ? options : cb) as NonNullable<typeof cb>)(null, host === 'localhost' ? '127.0.0.1' : host, 4)), resolve: unavailable('dns.resolve'), promises: { lookup: async (host: string) => ({ address: host === 'localhost' ? '127.0.0.1' : host, family: 4 }) }, setDefaultResultOrder: () => undefined },
236
+ v8: { getHeapStatistics: () => ({ total_heap_size: 30e6, used_heap_size: 20e6, heap_size_limit: 2e9 }), getHeapSpaceStatistics: () => [], serialize: (v: unknown) => new TextEncoder().encode(JSON.stringify(v)), deserialize: (b: Uint8Array) => JSON.parse(new TextDecoder().decode(b)), setFlagsFromString: () => undefined, cachedDataVersionTag: () => 0 },
237
+ cluster: { isMaster: true, isPrimary: true, isWorker: false, workers: {}, fork: unavailable('cluster.fork'), on: () => undefined, settings: {} },
238
+ inspector: { open: () => undefined, close: () => undefined, url: () => undefined, Session: class { connect() {} post() {} disconnect() {} }, console: globalThis.console },
239
+ punycode: { toASCII: (s: string) => new URL(`http://${s}`).hostname, toUnicode: (s: string) => s, encode: (s: string) => s, decode: (s: string) => s, ucs2: { decode: (s: string) => Array.from(s, (c) => c.codePointAt(0)!), encode: (a: number[]) => String.fromCodePoint(...a) } },
240
+ tls: { connect: unavailable('tls.connect'), createServer: unavailable('tls.createServer'), createSecureContext: () => ({}), DEFAULT_MIN_VERSION: 'TLSv1.2', DEFAULT_MAX_VERSION: 'TLSv1.3', rootCertificates: [] },
241
+ dgram: { createSocket: unavailable('dgram.createSocket') },
242
+ http2: { connect: unavailable('http2.connect'), createServer: unavailable('http2.createServer'), createSecureServer: unavailable('http2.createSecureServer'), constants: {} },
243
+ trace_events: { createTracing: () => ({ enable() {}, disable() {} }), getEnabledCategories: () => '' },
244
+ sqlite: { DatabaseSync: unavailable('sqlite.DatabaseSync') },
245
+ test: { test: unavailable('node:test'), describe: unavailable('node:test'), it: unavailable('node:test') },
246
+ wasi: { WASI: unavailable('wasi.WASI') },
247
+ repl: { start: unavailable('repl.start') },
248
+ domain: { create: () => Object.assign(new EventEmitterBase(), { run: (fn: () => unknown) => fn(), add() {}, remove() {}, bind: <F>(fn: F) => fn, intercept: <F>(fn: F) => fn, enter() {}, exit() {}, dispose() {} }) },
249
+ };
250
+ }
@@ -0,0 +1,135 @@
1
+ /**
2
+ * Node's `path` module, POSIX flavour — the runtime reports `platform: 'linux'`,
3
+ * so `path.win32` is the same object (Windows paths never occur in the VFS).
4
+ * `resolve` needs a cwd, so the module is created per process.
5
+ */
6
+
7
+ export interface ParsedPath {
8
+ root: string;
9
+ dir: string;
10
+ base: string;
11
+ ext: string;
12
+ name: string;
13
+ }
14
+
15
+ function normalizeString(path: string, allowAboveRoot: boolean): string {
16
+ const out: string[] = [];
17
+ for (const segment of path.split('/')) {
18
+ if (!segment || segment === '.') continue;
19
+ if (segment === '..') {
20
+ if (out.length && out[out.length - 1] !== '..') out.pop();
21
+ else if (allowAboveRoot) out.push('..');
22
+ } else out.push(segment);
23
+ }
24
+ return out.join('/');
25
+ }
26
+
27
+ export function createPathModule(cwd: () => string) {
28
+ const assertPath = (p: unknown) => {
29
+ if (typeof p !== 'string') throw new TypeError(`The "path" argument must be of type string. Received ${typeof p}`);
30
+ };
31
+
32
+ const path = {
33
+ sep: '/',
34
+ delimiter: ':',
35
+
36
+ normalize(p: string): string {
37
+ assertPath(p);
38
+ if (!p) return '.';
39
+ const absolute = p.startsWith('/');
40
+ const trailing = p.endsWith('/');
41
+ let out = normalizeString(p, !absolute);
42
+ if (!out && !absolute) out = '.';
43
+ if (out && trailing) out += '/';
44
+ return absolute ? '/' + out : out;
45
+ },
46
+
47
+ join(...parts: string[]): string {
48
+ parts.forEach(assertPath);
49
+ const joined = parts.filter(Boolean).join('/');
50
+ return joined ? path.normalize(joined) : '.';
51
+ },
52
+
53
+ resolve(...parts: string[]): string {
54
+ let resolved = '';
55
+ for (let i = parts.length - 1; i >= -1 && !resolved.startsWith('/'); i--) {
56
+ const part = i >= 0 ? parts[i]! : cwd();
57
+ assertPath(part);
58
+ if (part) resolved = resolved ? `${part}/${resolved}` : part;
59
+ }
60
+ const out = normalizeString(resolved, false);
61
+ return '/' + out;
62
+ },
63
+
64
+ isAbsolute(p: string): boolean {
65
+ assertPath(p);
66
+ return p.startsWith('/');
67
+ },
68
+
69
+ relative(from: string, to: string): string {
70
+ const a = path.resolve(from).split('/').filter(Boolean);
71
+ const b = path.resolve(to).split('/').filter(Boolean);
72
+ let i = 0;
73
+ while (i < a.length && i < b.length && a[i] === b[i]) i++;
74
+ return [...a.slice(i).map(() => '..'), ...b.slice(i)].join('/');
75
+ },
76
+
77
+ dirname(p: string): string {
78
+ assertPath(p);
79
+ if (!p) return '.';
80
+ const trimmed = p.length > 1 ? p.replace(/\/+$/, '') : p;
81
+ const cut = trimmed.lastIndexOf('/');
82
+ if (cut < 0) return '.';
83
+ if (cut === 0) return '/';
84
+ return trimmed.slice(0, cut);
85
+ },
86
+
87
+ basename(p: string, ext?: string): string {
88
+ assertPath(p);
89
+ const trimmed = p.length > 1 ? p.replace(/\/+$/, '') : p;
90
+ let base = trimmed.slice(trimmed.lastIndexOf('/') + 1);
91
+ if (ext && base.endsWith(ext) && base !== ext) base = base.slice(0, -ext.length);
92
+ return base;
93
+ },
94
+
95
+ extname(p: string): string {
96
+ const base = path.basename(p);
97
+ const dot = base.lastIndexOf('.');
98
+ return dot <= 0 ? '' : base.slice(dot);
99
+ },
100
+
101
+ parse(p: string): ParsedPath {
102
+ const root = p.startsWith('/') ? '/' : '';
103
+ const base = path.basename(p);
104
+ const ext = path.extname(p);
105
+ const dirname = path.dirname(p);
106
+ const dir = dirname === '.' && !p.includes('/') ? '' : dirname;
107
+ return { root, dir, base, ext, name: ext ? base.slice(0, -ext.length) : base };
108
+ },
109
+
110
+ format(parts: Partial<ParsedPath>): string {
111
+ const dir = parts.dir ?? parts.root ?? '';
112
+ const base = parts.base ?? `${parts.name ?? ''}${parts.ext ?? ''}`;
113
+ if (!dir) return base;
114
+ return dir === parts.root ? `${dir}${base}` : `${dir}/${base}`;
115
+ },
116
+
117
+ toNamespacedPath(p: string): string {
118
+ return p;
119
+ },
120
+
121
+ matchesGlob(p: string, pattern: string): boolean {
122
+ const source = pattern
123
+ .replace(/[.+^${}()|[\]\\]/g, '\\$&')
124
+ .replace(/\*\*\/?/g, '\u0000')
125
+ .replace(/\*/g, '[^/]*')
126
+ .replace(/\?/g, '[^/]')
127
+ .replace(/\u0000/g, '(?:.*/)?');
128
+ return new RegExp(`^${source}$`).test(p);
129
+ },
130
+ } as Record<string, any>;
131
+
132
+ path.posix = path;
133
+ path.win32 = path;
134
+ return path;
135
+ }