@statewalker/cellb 0.0.0-stage → 0.1.1

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 (365) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +323 -2
  3. package/dist/adapters/files-backup.d.ts +16 -0
  4. package/dist/adapters/files-backup.js +32 -0
  5. package/dist/adapters/files-backup.js.map +1 -0
  6. package/dist/adapters/files-changelog.d.ts +33 -0
  7. package/dist/adapters/files-changelog.js +96 -0
  8. package/dist/adapters/files-changelog.js.map +1 -0
  9. package/dist/adapters/files-ltx.d.ts +35 -0
  10. package/dist/adapters/files-ltx.js +9 -0
  11. package/dist/adapters/files-ltx.js.map +1 -0
  12. package/dist/adapters/ltx-vfs.d.ts +21 -0
  13. package/dist/adapters/ltx-vfs.js +286 -0
  14. package/dist/adapters/ltx-vfs.js.map +1 -0
  15. package/dist/adapters/node-sqlite.d.ts +45 -0
  16. package/dist/adapters/node-sqlite.js +254 -0
  17. package/dist/adapters/node-sqlite.js.map +1 -0
  18. package/dist/adapters/wasm-page-hook.d.ts +26 -0
  19. package/dist/adapters/wasm-page-hook.js +55 -0
  20. package/dist/adapters/wasm-page-hook.js.map +1 -0
  21. package/dist/adapters/wasm-session.d.ts +11 -0
  22. package/dist/adapters/wasm-session.js +76 -0
  23. package/dist/adapters/wasm-session.js.map +1 -0
  24. package/dist/adapters/wasm-sqlite.d.ts +89 -0
  25. package/dist/adapters/wasm-sqlite.js +258 -0
  26. package/dist/adapters/wasm-sqlite.js.map +1 -0
  27. package/dist/bindings/assets.d.ts +26 -0
  28. package/dist/bindings/assets.js +260 -0
  29. package/dist/bindings/assets.js.map +1 -0
  30. package/dist/bindings/cache.d.ts +16 -0
  31. package/dist/bindings/cache.js +34 -0
  32. package/dist/bindings/cache.js.map +1 -0
  33. package/dist/bindings/celld-kv.d.ts +26 -0
  34. package/dist/bindings/celld-kv.js +81 -0
  35. package/dist/bindings/celld-kv.js.map +1 -0
  36. package/dist/bindings/celld-queues.d.ts +56 -0
  37. package/dist/bindings/celld-queues.js +223 -0
  38. package/dist/bindings/celld-queues.js.map +1 -0
  39. package/dist/bindings/celld-workflows.d.ts +22 -0
  40. package/dist/bindings/celld-workflows.js +54 -0
  41. package/dist/bindings/celld-workflows.js.map +1 -0
  42. package/dist/bindings/cron.d.ts +27 -0
  43. package/dist/bindings/cron.js +232 -0
  44. package/dist/bindings/cron.js.map +1 -0
  45. package/dist/bindings/d1-migrations.d.ts +22 -0
  46. package/dist/bindings/d1-migrations.js +32 -0
  47. package/dist/bindings/d1-migrations.js.map +1 -0
  48. package/dist/bindings/html-rewriter.d.ts +8 -0
  49. package/dist/bindings/html-rewriter.js +75 -0
  50. package/dist/bindings/html-rewriter.js.map +1 -0
  51. package/dist/bindings/r2-celld.d.ts +3 -0
  52. package/dist/bindings/r2-celld.js +113 -0
  53. package/dist/bindings/r2-celld.js.map +1 -0
  54. package/dist/bindings/r2.d.ts +236 -0
  55. package/dist/bindings/r2.js +419 -0
  56. package/dist/bindings/r2.js.map +1 -0
  57. package/dist/bindings/worker-loader.d.ts +83 -0
  58. package/dist/bindings/worker-loader.js +183 -0
  59. package/dist/bindings/worker-loader.js.map +1 -0
  60. package/dist/bindings/workers-ai.d.ts +39 -0
  61. package/dist/bindings/workers-ai.js +175 -0
  62. package/dist/bindings/workers-ai.js.map +1 -0
  63. package/dist/browser.d.ts +7 -0
  64. package/dist/browser.js +8 -0
  65. package/dist/browser.js.map +1 -0
  66. package/dist/bucket/celld-cells.d.ts +86 -0
  67. package/dist/bucket/celld-cells.js +273 -0
  68. package/dist/bucket/celld-cells.js.map +1 -0
  69. package/dist/bucket/celld-format.d.ts +10 -0
  70. package/dist/bucket/celld-format.js +27 -0
  71. package/dist/bucket/celld-format.js.map +1 -0
  72. package/dist/bucket/idb-object-store.d.ts +9 -0
  73. package/dist/bucket/idb-object-store.js +73 -0
  74. package/dist/bucket/idb-object-store.js.map +1 -0
  75. package/dist/bucket/ltx-log.d.ts +34 -0
  76. package/dist/bucket/ltx-log.js +289 -0
  77. package/dist/bucket/ltx-log.js.map +1 -0
  78. package/dist/bucket/object-store.d.ts +51 -0
  79. package/dist/bucket/object-store.js +114 -0
  80. package/dist/bucket/object-store.js.map +1 -0
  81. package/dist/bucket/s3-object-store.d.ts +25 -0
  82. package/dist/bucket/s3-object-store.js +151 -0
  83. package/dist/bucket/s3-object-store.js.map +1 -0
  84. package/dist/bucket/sqlite-object-store.d.ts +10 -0
  85. package/dist/bucket/sqlite-object-store.js +107 -0
  86. package/dist/bucket/sqlite-object-store.js.map +1 -0
  87. package/dist/core/alarms.d.ts +27 -0
  88. package/dist/core/alarms.js +88 -0
  89. package/dist/core/alarms.js.map +1 -0
  90. package/dist/core/async-context.d.ts +34 -0
  91. package/dist/core/async-context.js +50 -0
  92. package/dist/core/async-context.js.map +1 -0
  93. package/dist/core/celld-schema.d.ts +14 -0
  94. package/dist/core/celld-schema.js +34 -0
  95. package/dist/core/celld-schema.js.map +1 -0
  96. package/dist/core/durable-object.d.ts +28 -0
  97. package/dist/core/durable-object.js +31 -0
  98. package/dist/core/durable-object.js.map +1 -0
  99. package/dist/core/gates.d.ts +33 -0
  100. package/dist/core/gates.js +89 -0
  101. package/dist/core/gates.js.map +1 -0
  102. package/dist/core/handles.d.ts +90 -0
  103. package/dist/core/handles.js +224 -0
  104. package/dist/core/handles.js.map +1 -0
  105. package/dist/core/id.d.ts +19 -0
  106. package/dist/core/id.js +64 -0
  107. package/dist/core/id.js.map +1 -0
  108. package/dist/core/namespace.d.ts +38 -0
  109. package/dist/core/namespace.js +141 -0
  110. package/dist/core/namespace.js.map +1 -0
  111. package/dist/core/object-host.d.ts +91 -0
  112. package/dist/core/object-host.js +616 -0
  113. package/dist/core/object-host.js.map +1 -0
  114. package/dist/core/request-body.d.ts +9 -0
  115. package/dist/core/request-body.js +55 -0
  116. package/dist/core/request-body.js.map +1 -0
  117. package/dist/core/runtime.d.ts +121 -0
  118. package/dist/core/runtime.js +366 -0
  119. package/dist/core/runtime.js.map +1 -0
  120. package/dist/core/shard.d.ts +7 -0
  121. package/dist/core/shard.js +10 -0
  122. package/dist/core/shard.js.map +1 -0
  123. package/dist/core/sql-split.d.ts +15 -0
  124. package/dist/core/sql-split.js +101 -0
  125. package/dist/core/sql-split.js.map +1 -0
  126. package/dist/core/sql-storage.d.ts +53 -0
  127. package/dist/core/sql-storage.js +407 -0
  128. package/dist/core/sql-storage.js.map +1 -0
  129. package/dist/core/state.d.ts +44 -0
  130. package/dist/core/state.js +93 -0
  131. package/dist/core/state.js.map +1 -0
  132. package/dist/core/storage.d.ts +103 -0
  133. package/dist/core/storage.js +351 -0
  134. package/dist/core/storage.js.map +1 -0
  135. package/dist/core/worker-rejections.d.ts +21 -0
  136. package/dist/core/worker-rejections.js +55 -0
  137. package/dist/core/worker-rejections.js.map +1 -0
  138. package/dist/index.d.ts +22 -0
  139. package/dist/index.js +23 -0
  140. package/dist/index.js.map +1 -0
  141. package/dist/isolate/browser.d.ts +16 -0
  142. package/dist/isolate/browser.js +37 -0
  143. package/dist/isolate/browser.js.map +1 -0
  144. package/dist/isolate/host.d.ts +24 -0
  145. package/dist/isolate/host.js +74 -0
  146. package/dist/isolate/host.js.map +1 -0
  147. package/dist/isolate/isolate-worker.d.ts +1 -0
  148. package/dist/isolate/isolate-worker.js +53 -0
  149. package/dist/isolate/isolate-worker.js.map +1 -0
  150. package/dist/isolate/isolate.d.ts +10 -0
  151. package/dist/isolate/isolate.js +169 -0
  152. package/dist/isolate/isolate.js.map +1 -0
  153. package/dist/isolate/node-entry.d.ts +1 -0
  154. package/dist/isolate/node-entry.js +12 -0
  155. package/dist/isolate/node-entry.js.map +1 -0
  156. package/dist/isolate/protocol.d.ts +66 -0
  157. package/dist/isolate/protocol.js +205 -0
  158. package/dist/isolate/protocol.js.map +1 -0
  159. package/dist/ltx/crc64.d.ts +6 -0
  160. package/dist/ltx/crc64.js +46 -0
  161. package/dist/ltx/crc64.js.map +1 -0
  162. package/dist/ltx/ltx-page-server.d.ts +65 -0
  163. package/dist/ltx/ltx-page-server.js +309 -0
  164. package/dist/ltx/ltx-page-server.js.map +1 -0
  165. package/dist/ltx/ltx-pages.d.ts +81 -0
  166. package/dist/ltx/ltx-pages.js +315 -0
  167. package/dist/ltx/ltx-pages.js.map +1 -0
  168. package/dist/ltx/ltx-store-worker.d.ts +1 -0
  169. package/dist/ltx/ltx-store-worker.js +38 -0
  170. package/dist/ltx/ltx-store-worker.js.map +1 -0
  171. package/dist/ltx/ltx.d.ts +45 -0
  172. package/dist/ltx/ltx.js +203 -0
  173. package/dist/ltx/ltx.js.map +1 -0
  174. package/dist/ltx/lz4.d.ts +9 -0
  175. package/dist/ltx/lz4.js +156 -0
  176. package/dist/ltx/lz4.js.map +1 -0
  177. package/dist/ltx/opfs-sync-files.d.ts +23 -0
  178. package/dist/ltx/opfs-sync-files.js +191 -0
  179. package/dist/ltx/opfs-sync-files.js.map +1 -0
  180. package/dist/ltx/xxh32.d.ts +1 -0
  181. package/dist/ltx/xxh32.js +43 -0
  182. package/dist/ltx/xxh32.js.map +1 -0
  183. package/dist/miniflare-compat/blob-service.d.ts +13 -0
  184. package/dist/miniflare-compat/blob-service.js +66 -0
  185. package/dist/miniflare-compat/blob-service.js.map +1 -0
  186. package/dist/miniflare-compat/kv-binding.d.ts +44 -0
  187. package/dist/miniflare-compat/kv-binding.js +99 -0
  188. package/dist/miniflare-compat/kv-binding.js.map +1 -0
  189. package/dist/miniflare-compat/shims/assert.d.ts +15 -0
  190. package/dist/miniflare-compat/shims/assert.js +24 -0
  191. package/dist/miniflare-compat/shims/assert.js.map +1 -0
  192. package/dist/miniflare-compat/shims/workerd-cloudflare.d.ts +7 -0
  193. package/dist/miniflare-compat/shims/workerd-cloudflare.js +6 -0
  194. package/dist/miniflare-compat/shims/workerd-cloudflare.js.map +1 -0
  195. package/dist/miniflare-compat/shims/workerd-globals.d.ts +1 -0
  196. package/dist/miniflare-compat/shims/workerd-globals.js +30 -0
  197. package/dist/miniflare-compat/shims/workerd-globals.js.map +1 -0
  198. package/dist/miniflare-compat/shims/workerd-internal.d.ts +20 -0
  199. package/dist/miniflare-compat/shims/workerd-internal.js +23 -0
  200. package/dist/miniflare-compat/shims/workerd-internal.js.map +1 -0
  201. package/dist/miniflare-compat/shims/workerd-performance.d.ts +4 -0
  202. package/dist/miniflare-compat/shims/workerd-performance.js +17 -0
  203. package/dist/miniflare-compat/shims/workerd-performance.js.map +1 -0
  204. package/dist/miniflare-compat/simulator-fetcher.d.ts +9 -0
  205. package/dist/miniflare-compat/simulator-fetcher.js +14 -0
  206. package/dist/miniflare-compat/simulator-fetcher.js.map +1 -0
  207. package/dist/miniflare-compat/vendored.d.ts +15 -0
  208. package/dist/miniflare-compat/vendored.js +27 -0
  209. package/dist/miniflare-compat/vendored.js.map +1 -0
  210. package/dist/node-compat/async_hooks.d.ts +22 -0
  211. package/dist/node-compat/async_hooks.js +176 -0
  212. package/dist/node-compat/async_hooks.js.map +1 -0
  213. package/dist/node-compat/browser-registry.d.ts +3 -0
  214. package/dist/node-compat/browser-registry.js +39 -0
  215. package/dist/node-compat/browser-registry.js.map +1 -0
  216. package/dist/node-compat/crypto.d.ts +60 -0
  217. package/dist/node-compat/crypto.js +143 -0
  218. package/dist/node-compat/crypto.js.map +1 -0
  219. package/dist/node-compat/diagnostics_channel.d.ts +27 -0
  220. package/dist/node-compat/diagnostics_channel.js +46 -0
  221. package/dist/node-compat/diagnostics_channel.js.map +1 -0
  222. package/dist/node-compat/fs.d.ts +35 -0
  223. package/dist/node-compat/fs.js +40 -0
  224. package/dist/node-compat/fs.js.map +1 -0
  225. package/dist/node-compat/globals.d.ts +3 -0
  226. package/dist/node-compat/globals.js +4 -0
  227. package/dist/node-compat/globals.js.map +1 -0
  228. package/dist/node-compat/install.d.ts +5 -0
  229. package/dist/node-compat/install.js +12 -0
  230. package/dist/node-compat/install.js.map +1 -0
  231. package/dist/node-compat/module.d.ts +12 -0
  232. package/dist/node-compat/module.js +36 -0
  233. package/dist/node-compat/module.js.map +1 -0
  234. package/dist/node-compat/modules.d.ts +8 -0
  235. package/dist/node-compat/modules.js +23 -0
  236. package/dist/node-compat/modules.js.map +1 -0
  237. package/dist/node-compat/os.d.ts +36 -0
  238. package/dist/node-compat/os.js +36 -0
  239. package/dist/node-compat/os.js.map +1 -0
  240. package/dist/node-compat/process.d.ts +14 -0
  241. package/dist/node-compat/process.js +16 -0
  242. package/dist/node-compat/process.js.map +1 -0
  243. package/dist/node-compat/shims.d.ts +4 -0
  244. package/dist/node.d.ts +5 -0
  245. package/dist/node.js +6 -0
  246. package/dist/node.js.map +1 -0
  247. package/dist/peer/celld-peer.d.ts +53 -0
  248. package/dist/peer/celld-peer.js +555 -0
  249. package/dist/peer/celld-peer.js.map +1 -0
  250. package/dist/ports.d.ts +183 -0
  251. package/dist/ports.js +10 -0
  252. package/dist/ports.js.map +1 -0
  253. package/dist/project/browser-bundle.d.ts +17 -0
  254. package/dist/project/browser-bundle.js +125 -0
  255. package/dist/project/browser-bundle.js.map +1 -0
  256. package/dist/project/browser-cookies.d.ts +12 -0
  257. package/dist/project/browser-cookies.js +90 -0
  258. package/dist/project/browser-cookies.js.map +1 -0
  259. package/dist/project/browser-host.d.ts +173 -0
  260. package/dist/project/browser-host.js +200 -0
  261. package/dist/project/browser-host.js.map +1 -0
  262. package/dist/project/browser-modules.d.ts +17 -0
  263. package/dist/project/browser-modules.js +89 -0
  264. package/dist/project/browser-modules.js.map +1 -0
  265. package/dist/project/browser-shards.d.ts +62 -0
  266. package/dist/project/browser-shards.js +210 -0
  267. package/dist/project/browser-shards.js.map +1 -0
  268. package/dist/project/browser-tabs.d.ts +103 -0
  269. package/dist/project/browser-tabs.js +418 -0
  270. package/dist/project/browser-tabs.js.map +1 -0
  271. package/dist/project/cloudflare-email.d.ts +8 -0
  272. package/dist/project/cloudflare-email.js +11 -0
  273. package/dist/project/cloudflare-email.js.map +1 -0
  274. package/dist/project/cloudflare-workers.d.ts +12 -0
  275. package/dist/project/cloudflare-workers.js +16 -0
  276. package/dist/project/cloudflare-workers.js.map +1 -0
  277. package/dist/project/host-modules.d.ts +4 -0
  278. package/dist/project/host-modules.js +40 -0
  279. package/dist/project/host-modules.js.map +1 -0
  280. package/dist/project/jsonc.d.ts +2 -0
  281. package/dist/project/jsonc.js +27 -0
  282. package/dist/project/jsonc.js.map +1 -0
  283. package/dist/project/lower-await.d.ts +2 -0
  284. package/dist/project/lower-await.js +151 -0
  285. package/dist/project/lower-await.js.map +1 -0
  286. package/dist/project/node-project.d.ts +38 -0
  287. package/dist/project/node-project.js +373 -0
  288. package/dist/project/node-project.js.map +1 -0
  289. package/dist/project/own-module.d.ts +6 -0
  290. package/dist/project/own-module.js +13 -0
  291. package/dist/project/own-module.js.map +1 -0
  292. package/dist/project/scheduler.d.ts +2 -0
  293. package/dist/project/scheduler.js +3 -0
  294. package/dist/project/scheduler.js.map +1 -0
  295. package/dist/project/site.d.ts +74 -0
  296. package/dist/project/site.js +206 -0
  297. package/dist/project/site.js.map +1 -0
  298. package/dist/project/virtual-modules.d.ts +3 -0
  299. package/dist/project/worker-scope.d.ts +27 -0
  300. package/dist/project/worker-scope.js +46 -0
  301. package/dist/project/worker-scope.js.map +1 -0
  302. package/dist/project/workerd-message-channel.d.ts +13 -0
  303. package/dist/project/workerd-message-channel.js +137 -0
  304. package/dist/project/workerd-message-channel.js.map +1 -0
  305. package/dist/project/workers-global-names.d.ts +6 -0
  306. package/dist/project/workers-global-names.js +15 -0
  307. package/dist/project/workers-global-names.js.map +1 -0
  308. package/dist/project/workers-globals-module.d.ts +8 -0
  309. package/dist/project/workers-globals-module.js +9 -0
  310. package/dist/project/workers-globals-module.js.map +1 -0
  311. package/dist/project/workers-globals.d.ts +9 -0
  312. package/dist/project/workers-globals.js +19 -0
  313. package/dist/project/workers-globals.js.map +1 -0
  314. package/dist/project/wrangler.d.ts +116 -0
  315. package/dist/project/wrangler.js +342 -0
  316. package/dist/project/wrangler.js.map +1 -0
  317. package/dist/router/cell-router.d.ts +72 -0
  318. package/dist/router/cell-router.js +247 -0
  319. package/dist/router/cell-router.js.map +1 -0
  320. package/dist/router/shard-worker.d.ts +44 -0
  321. package/dist/router/shard-worker.js +163 -0
  322. package/dist/router/shard-worker.js.map +1 -0
  323. package/dist/transport/cells-http.d.ts +25 -0
  324. package/dist/transport/cells-http.js +141 -0
  325. package/dist/transport/cells-http.js.map +1 -0
  326. package/dist/transport/cells-link.d.ts +27 -0
  327. package/dist/transport/cells-link.js +71 -0
  328. package/dist/transport/cells-link.js.map +1 -0
  329. package/dist/transport/port.d.ts +26 -0
  330. package/dist/transport/port.js +100 -0
  331. package/dist/transport/port.js.map +1 -0
  332. package/dist/v8/codec.d.ts +6 -0
  333. package/dist/v8/codec.js +9 -0
  334. package/dist/v8/codec.js.map +1 -0
  335. package/dist/v8/serialize.d.ts +10 -0
  336. package/dist/v8/serialize.js +601 -0
  337. package/dist/v8/serialize.js.map +1 -0
  338. package/dist/ws/client.d.ts +25 -0
  339. package/dist/ws/client.js +203 -0
  340. package/dist/ws/client.js.map +1 -0
  341. package/dist/ws/control.d.ts +48 -0
  342. package/dist/ws/control.js +44 -0
  343. package/dist/ws/control.js.map +1 -0
  344. package/dist/ws/frames.d.ts +38 -0
  345. package/dist/ws/frames.js +39 -0
  346. package/dist/ws/frames.js.map +1 -0
  347. package/dist/ws/server.d.ts +99 -0
  348. package/dist/ws/server.js +295 -0
  349. package/dist/ws/server.js.map +1 -0
  350. package/dist/ws/sw-connector.d.ts +10 -0
  351. package/dist/ws/sw-connector.js +25 -0
  352. package/dist/ws/sw-connector.js.map +1 -0
  353. package/dist/ws/upgrade.d.ts +28 -0
  354. package/dist/ws/upgrade.js +75 -0
  355. package/dist/ws/upgrade.js.map +1 -0
  356. package/package.json +111 -3
  357. package/vendor/celld/LICENSE +202 -0
  358. package/vendor/celld/kv.js +1131 -0
  359. package/vendor/celld/queues.js +1656 -0
  360. package/vendor/celld/workflows.js +1610 -0
  361. package/vendor/html-rewriter-wasm/html_rewriter.js +925 -0
  362. package/vendor/html-rewriter-wasm/html_rewriter_bg.wasm +0 -0
  363. package/vendor/miniflare/d1-api.js +738 -0
  364. package/vendor/miniflare/d1-database.js +6978 -0
  365. package/vendor/miniflare/kv-namespace.js +3061 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node-project.js","sourceRoot":"","sources":["../../src/project/node-project.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,WAAW,EACX,WAAW,EACX,YAAY,EACZ,QAAQ,EACR,aAAa,GACd,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAGL,UAAU,EACV,aAAa,GACd,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAG1D,OAAO,KAAK,cAAc,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAoB,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EACL,oBAAoB,EACpB,WAAW,GAIZ,MAAM,eAAe,CAAC;AAEvB,oGAAoG;AACpG,MAAM,UAAU,kBAAkB,CAAC,GAAW;IAC5C,KAAK,MAAM,IAAI,IAAI,CAAC,gBAAgB,EAA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AAC;IACtE,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AACD,KAAK,UAAU,iBAAiB;IAC9B,gBAAgB,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,gBAAgB,CAAC,CAAC,EAAE,aAAa,CAAC,CAAC;IACtF,MAAM,KAAK,CAAC;QACV,WAAW,EAAE,CAAC,SAAS,CAAC,OAAO,IAAI,CAAC,OAAO,EAAE,uBAAuB,CAAC,CAAC;QACtE,OAAO,EAAE,gBAAgB;QACzB,MAAM,EAAE,IAAI;QACZ,MAAM,EAAE,KAAK;QACb,QAAQ,EAAE,MAAM;QAChB,MAAM,EAAE,QAAQ;QAChB,QAAQ,EAAE,QAAQ;KACnB,CAAC,CAAC;IACH,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAED,wFAAwF;AACxF,SAAS,wBAAwB,CAAC,KAAkB;IAClD,MAAM,CAAC,GAAG,UAAqC,CAAC;IAChD,CAAC,CAAC,mBAAmB,GAAG,KAAK,CAAC;IAC9B,CAAC,CAAC,oBAAoB,KAAK,cAAc,CAAC;IAC1C,uEAAuE;IACvE,CAAC,CAAC,kBAAkB,KAAK,IAAI,KAAK,CAChC,EAAE,EACF,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE,CAC5E,CAAC;AACJ,CAAC;AACD,MAAM,cAAc,GAAG,aAAa,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC","sourcesContent":["import {\n existsSync,\n mkdtempSync,\n readdirSync,\n readFileSync,\n statSync,\n writeFileSync,\n} from \"node:fs\";\nimport { builtinModules, createRequire } from \"node:module\";\nimport { tmpdir } from \"node:os\";\nimport { join, resolve } from \"node:path\";\nimport { Worker as NodeWorker } from \"node:worker_threads\";\nimport { build } from \"esbuild\";\nimport { applyD1Migrations } from \"../bindings/d1-migrations.js\";\nimport {\n type LogSink,\n type ModuleLoader,\n moduleText,\n outboundFetch,\n} from \"../bindings/worker-loader.js\";\nimport { ctxExports } from \"../core/handles.js\";\nimport type { WorkerModule } from \"../core/runtime.js\";\nimport { isolatedModuleLoader } from \"../isolate/host.js\";\nimport type { PortLike } from \"../isolate/protocol.js\";\nimport type { CellStorage } from \"../ports.js\";\nimport * as workersClasses from \"./cloudflare-workers.js\";\nimport { parseJsonc } from \"./jsonc.js\";\nimport { ownModule } from \"./own-module.js\";\nimport { type WorkerScope, workerScope } from \"./worker-scope.js\";\nimport {\n createProjectRuntime,\n loadTimeEnv,\n type ProjectHost,\n type ProjectRuntime,\n type WranglerConfig,\n} from \"./wrangler.js\";\n\n/** Reads `wrangler.jsonc` / `wrangler.json` of a project directory (celld reads the same files). */\nexport function readWranglerConfig(dir: string): WranglerConfig {\n for (const name of [\"wrangler.jsonc\", \"wrangler.json\"]) {\n const p = join(dir, name);\n if (existsSync(p)) return parseJsonc(readFileSync(p, \"utf8\")) as WranglerConfig;\n }\n throw new Error(`no wrangler.jsonc or wrangler.json in ${dir}`);\n}\n\n/** A bare Node.js built-in specifier (\"path\", \"fs/promises\"), not one of a package. */\nconst nodeBuiltinName = new RegExp(\n `^(${builtinModules\n .filter((m) => !m.startsWith(\"_\") && !m.includes(\":\"))\n .map((m) => m.replace(/[/]/g, \"\\\\/\"))\n .join(\"|\")})$`,\n);\n\n/**\n * Node host: bundles `main` with esbuild (as `celld deploy` does) and builds the runtime.\n * `cloudflare:workers` resolves to cellb's module so user classes extend the\n * runtime's own DurableObject / WorkerEntrypoint.\n */\n/** Bundles Worker code (a file, or in-memory modules) with the runtime's module mappings, then imports it. */\nexport async function bundleWorker(\n entry: { path: string } | { modules: Record<string, string>; main: string },\n logs?: LogSink,\n outbound?: typeof fetch,\n opts: { nodeCompat?: boolean; standardBinaryType?: boolean; scope?: WorkerScope } = {},\n): Promise<WorkerModule> {\n // `env` and `exports` of `cloudflare:workers` belong to one Worker: the bundle reads them\n // from its own scope (empty objects for code that has none).\n const scopeKey = opts.scope ? `s${Math.random().toString(36).slice(2)}` : \"\";\n if (opts.scope) {\n const g = globalThis as Record<string, unknown>;\n g.__cellsWorkerScopes ??= {};\n (g.__cellsWorkerScopes as Record<string, unknown>)[scopeKey] = opts.scope;\n }\n // Loaded code gets a bundle-local `fetch` (globalOutbound policy)…\n const outboundKey = outbound ? `o${Math.random().toString(36).slice(2)}` : \"\";\n if (outbound) {\n const g = globalThis as Record<string, unknown>;\n g.__cellsOutbound ??= {};\n (g.__cellsOutbound as Record<string, unknown>)[outboundKey] = outbound;\n }\n // …and a bundle-local `console` that also feeds its Tail Workers.\n const consoleKey = logs ? `c${Math.random().toString(36).slice(2)}` : \"\";\n if (logs) {\n const g = globalThis as Record<string, unknown>;\n g.__cellsConsoles ??= {};\n const registry = g.__cellsConsoles as Record<string, unknown>;\n const real = globalThis.console;\n const wrap =\n (level: \"log\" | \"info\" | \"warn\" | \"error\" | \"debug\") =>\n (...args: unknown[]) => {\n logs(level, args);\n real[level](...args);\n };\n registry[consoleKey] = Object.assign(Object.create(real), {\n log: wrap(\"log\"),\n info: wrap(\"info\"),\n warn: wrap(\"warn\"),\n error: wrap(\"error\"),\n debug: wrap(\"debug\"),\n });\n }\n const outDir = mkdtempSync(join(tmpdir(), \"cells-worker-\"));\n const out = join(outDir, \"worker.mjs\");\n const cfWorkers = ownModule(import.meta.dirname, \"cloudflare-workers\");\n // This bundle's `cloudflare:workers`: the runtime's classes plus its own `env` and `exports`.\n // A file of its own, kept out of the bundle so it adds no names to the Worker's scope.\n const workersModule = join(outDir, \"cloudflare-workers.mjs\");\n writeFileSync(\n workersModule,\n [\n `export * from ${JSON.stringify(cfWorkers)};`,\n `const scope = globalThis.__cellsWorkerScopes?.[${JSON.stringify(scopeKey)}];`,\n \"export const env = scope ? scope.env : {};\",\n \"export const exports = scope ? scope.exports : {};\",\n \"export const waitUntil = (p) => scope?.waitUntil(p);\",\n ].join(\"\\n\"),\n );\n const memory = \"modules\" in entry ? entry.modules : undefined;\n await build({\n entryPoints: [\n memory ? `memory:${(entry as { main: string }).main}` : (entry as { path: string }).path,\n ],\n outfile: out,\n bundle: true,\n format: \"esm\",\n platform: \"neutral\",\n // As `celld deploy` resolves packages: workerd's conditions, then `module` and `main` (the\n // neutral platform has no main fields, so a package with only `main` would not resolve).\n conditions: [\"workerd\", \"worker\", \"browser\"],\n mainFields: [\"module\", \"main\"],\n target: \"es2022\",\n logLevel: \"silent\",\n // nodejs_compat: CommonJS dependencies `require()` Node's built-ins (mime-types requires\n // node:path), as they may under workerd's nodejs_compat. In an ES module bundle esbuild's\n // require shim needs a `require` in scope: vitest's module runner provides one, plain Node\n // does not.\n ...(opts.nodeCompat\n ? {\n banner: {\n js: 'import { createRequire as __cellbCreateRequire } from \"node:module\";\\nconst require = __cellbCreateRequire(import.meta.url);',\n },\n }\n : {}),\n inject: [\n ownModule(import.meta.dirname, \"workers-globals\"),\n ...(logs ? [\"cellb:console\"] : []),\n ...(outbound ? [\"cellb:fetch\"] : []),\n ],\n plugins: [\n {\n name: \"cells-modules\",\n setup(b) {\n b.onResolve({ filter: /^cellb:console$/ }, () => ({\n path: \"console\",\n namespace: \"cells-console\",\n }));\n // nodejs_compat on a Node host: `node:*` are the real Node.js modules.\n if (opts.nodeCompat) {\n b.onResolve({ filter: /^node:/ }, (a) => ({ path: a.path, external: true }));\n // workerd's nodejs_compat also takes the bare names (\"path\", \"fs/promises\").\n b.onResolve({ filter: nodeBuiltinName }, (a) => ({\n path: `node:${a.path}`,\n external: true,\n }));\n }\n b.onResolve({ filter: /^cellb:compat$/ }, () => ({\n path: \"compat\",\n namespace: \"cells-compat\",\n }));\n b.onLoad({ filter: /.*/, namespace: \"cells-compat\" }, () => ({\n contents: `export const standardBinaryType = ${!!opts.standardBinaryType};`,\n loader: \"js\",\n }));\n b.onResolve({ filter: /^cellb:fetch$/ }, () => ({\n path: \"fetch\",\n namespace: \"cells-fetch\",\n }));\n b.onLoad({ filter: /.*/, namespace: \"cells-fetch\" }, () => ({\n contents: `export const fetch = globalThis.__cellsOutbound[${JSON.stringify(outboundKey)}];`,\n loader: \"js\",\n }));\n b.onLoad({ filter: /.*/, namespace: \"cells-console\" }, () => ({\n contents: `export const console = globalThis.__cellsConsoles[${JSON.stringify(consoleKey)}];`,\n loader: \"js\",\n }));\n b.onResolve({ filter: /^cloudflare:workers$/ }, () => ({\n path: workersModule,\n external: true,\n }));\n b.onResolve({ filter: /^cloudflare:email$/ }, () => ({\n path: ownModule(import.meta.dirname, \"cloudflare-email\"),\n external: true,\n }));\n b.onResolve({ filter: /^cellb:ws$/ }, () => ({\n path: ownModule(import.meta.dirname, \"workers-globals-module\"),\n external: true,\n }));\n if (!memory) return;\n b.onResolve({ filter: /^memory:/ }, (a) => ({\n path: a.path.slice(7),\n namespace: \"memory\",\n }));\n b.onResolve({ filter: /^\\.{1,2}\\// }, (a) =>\n a.namespace === \"memory\"\n ? {\n path: new URL(a.path, `file:///${a.importer}`).pathname.slice(1),\n namespace: \"memory\",\n }\n : undefined,\n );\n b.onLoad({ filter: /.*/, namespace: \"memory\" }, (a) => ({\n contents: memory[a.path],\n loader: \"js\",\n }));\n },\n },\n ],\n });\n return (await import(/* @vite-ignore */ out)) as WorkerModule;\n}\n\n/** Worker Loader on Node: compiles `WorkerCode.modules` with esbuild (as celld compiles loaded code). */\nexport const nodeModuleLoader: ModuleLoader = async (_id, code, logs) => {\n const outbound = outboundFetch(code);\n const modules: Record<string, string> = {};\n for (const [name, m] of Object.entries(code.modules)) modules[name] = moduleText(m);\n // `env` and `exports` of the loaded code's `cloudflare:workers` are its own (WorkerCode.env).\n const env = code.env ?? {};\n const scope = workerScope(env);\n const module = (await bundleWorker({ modules, main: code.mainModule }, logs, outbound, {\n scope,\n })) as Record<string, unknown>;\n scope.bind({ env, exports: ctxExports(module, env) });\n return module;\n};\n\nexport async function loadNodeProject(\n dir: string,\n host: Omit<ProjectHost, \"loadModules\"> & Partial<Pick<ProjectHost, \"loadModules\">>,\n): Promise<ProjectRuntime & { config: WranglerConfig }> {\n const config = readWranglerConfig(dir);\n if (!config.main && !config.assets)\n throw new Error(\"wrangler config has neither `main` nor `assets`\");\n const flags = config.compatibility_flags ?? [];\n const nodeCompat = flags.some((f) => f.startsWith(\"nodejs_compat\"));\n const standardBinaryType = flags.includes(\"websocket_standard_binary_type\");\n // The module reads `env` from `cloudflare:workers` while it is evaluated, before the\n // runtime exists: until then the scope holds the configuration's vars (and `ai`).\n const scope = workerScope(loadTimeEnv(config, host.ai));\n // A bundle built elsewhere for cellb (cellbHostModule: webrun-bundler in a browser, say) reads\n // the runtime from globals, as in the browser realm: set them here too, so the same bundle\n // runs on Node. (One such project per process: the globals are the process's.)\n installHostModuleGlobals(scope);\n // As the browser host: nodejs_compat fills process.env with the text vars (from compatibility\n // date 2025-04-01). Node shares its real process with the Worker, so they land there.\n if (\n nodeCompat &&\n !flags.includes(\"nodejs_compat_do_not_populate_process_env\") &&\n (flags.includes(\"nodejs_compat_populate_process_env\") ||\n (config.compatibility_date ?? \"\") >= \"2025-04-01\")\n )\n for (const [k, v] of Object.entries(config.vars ?? {}))\n if (typeof v === \"string\") process.env[k] ??= v;\n const module = config.main\n ? await bundleWorker({ path: resolve(dir, config.main) }, undefined, undefined, {\n nodeCompat,\n standardBinaryType,\n scope,\n })\n : ({ default: {} } as WorkerModule);\n const assetFiles = config.assets?.directory\n ? readAssetDirectory(resolve(dir, config.assets.directory))\n : undefined;\n const project = createProjectRuntime(config, module, {\n loadModules: nodeModuleLoader,\n // own realm, as celld; facets logged like the root's\n isolatedModules: nodeIsolatedLoader(() => host.storage),\n assetFiles,\n ...host,\n });\n scope.bind(project.runtime);\n return { ...project, config };\n}\n\n/** Reads an assets directory into \"/path\" → bytes (what `celld deploy` uploads). */\nexport function readAssetDirectory(root: string): Map<string, Uint8Array> {\n const files = new Map<string, Uint8Array>();\n const walk = (dir: string, prefix: string) => {\n for (const name of readdirSync(dir)) {\n const full = join(dir, name);\n if (statSync(full).isDirectory()) walk(full, `${prefix}${name}/`);\n else files.set(`${prefix}${name}`, new Uint8Array(readFileSync(full)));\n }\n };\n walk(root, \"/\");\n return files;\n}\n\n/**\n * `celld d1 migrations apply DATABASE` for a Node-hosted project: reads\n * `migrations_dir` (default \"migrations\") of the `d1_databases` entry and applies what is new.\n */\nexport async function applyNodeD1Migrations(\n dir: string,\n runtime: { env: Record<string, unknown> },\n database: string,\n) {\n const config = readWranglerConfig(dir);\n const d1 = config.d1_databases?.find(\n (d) => d.database_name === database || d.binding === database,\n );\n if (!d1) throw new Error(`no d1_databases entry named ${database}`);\n const mdir = resolve(dir, (d1 as { migrations_dir?: string }).migrations_dir ?? \"migrations\");\n const files: [string, string][] = existsSync(mdir)\n ? readdirSync(mdir).map((f) => [f, readFileSync(join(mdir, f), \"utf8\")])\n : [];\n return applyD1Migrations(\n runtime.env[d1.binding] as never,\n files,\n (d1 as { migrations_table?: string }).migrations_table ?? \"d1_migrations\",\n );\n}\n\n/**\n * Loaded Workers in worker threads (one realm each), like celld's isolates. The code is\n * bundled with esbuild (cloudflare:workers bundled in) and imported in the thread from a\n * data: URL; Durable Object classes for facets still load in this realm.\n */\nlet isolateEntry: Promise<string> | undefined;\nexport function nodeIsolatedLoader(storage?: () => CellStorage | undefined): ModuleLoader {\n return isolatedModuleLoader({\n storage,\n spawn: () => {\n const port = new NodeWorker(new URL(`file://${isolateEntryPathSync()}`));\n port.unref(); // an idle isolate never keeps the process alive\n return { port: port as unknown as PortLike, terminate: () => void port.terminate() };\n },\n prepare: async (_id, code) => {\n isolateEntry ??= buildIsolateEntry();\n await isolateEntry;\n const modules: Record<string, string> = {};\n for (const [name, m] of Object.entries(code.modules)) modules[name] = moduleText(m);\n const out = await build({\n entryPoints: [`memory:${code.mainModule}`],\n write: false,\n bundle: true,\n format: \"esm\",\n platform: \"neutral\",\n target: \"es2022\",\n logLevel: \"silent\",\n plugins: [\n {\n name: \"isolate-modules\",\n setup(b) {\n // The loaded Worker is its thread's own: `env` and `exports` are the scope\n // serveIsolate keeps for it.\n b.onResolve({ filter: /^cloudflare:workers$/ }, () => ({\n path: \"cloudflare:workers\",\n namespace: \"isolate-workers\",\n }));\n b.onLoad({ filter: /.*/, namespace: \"isolate-workers\" }, () => ({\n contents: [\n 'export * from \"./cloudflare-workers.ts\";',\n \"export const env = globalThis.__cellsProjectScope.env, exports = globalThis.__cellsProjectScope.exports, waitUntil = (p) => globalThis.__cellsProjectScope.waitUntil(p);\",\n ].join(\"\\n\"),\n loader: \"js\",\n resolveDir: import.meta.dirname,\n }));\n b.onResolve({ filter: /^cloudflare:email$/ }, () => ({\n path: ownModule(import.meta.dirname, \"cloudflare-email\"),\n }));\n b.onResolve({ filter: /^memory:/ }, (a) => ({\n path: a.path.slice(7),\n namespace: \"memory\",\n }));\n b.onResolve({ filter: /^\\.{1,2}\\// }, (a) =>\n a.namespace === \"memory\"\n ? {\n path: new URL(a.path, `file:///${a.importer}`).pathname.slice(1),\n namespace: \"memory\",\n }\n : undefined,\n );\n b.onLoad({ filter: /.*/, namespace: \"memory\" }, (a) => ({\n contents: modules[a.path],\n loader: \"js\",\n }));\n },\n },\n ],\n });\n return { source: out.outputFiles[0].text };\n },\n });\n}\n\nlet isolateEntryFile = \"\";\nfunction isolateEntryPathSync(): string {\n if (!isolateEntryFile) throw new Error(\"isolate entry not built yet\");\n return isolateEntryFile;\n}\nasync function buildIsolateEntry(): Promise<string> {\n isolateEntryFile = join(mkdtempSync(join(tmpdir(), \"cells-isolate-\")), \"isolate.mjs\");\n await build({\n entryPoints: [ownModule(import.meta.dirname, \"../isolate/node-entry\")],\n outfile: isolateEntryFile,\n bundle: true,\n format: \"esm\",\n platform: \"node\",\n target: \"node22\",\n logLevel: \"silent\",\n });\n return isolateEntryFile;\n}\n\n/** The globals `@statewalker/cellb/host-modules` bundles read (see host-modules.ts). */\nfunction installHostModuleGlobals(scope: WorkerScope): void {\n const g = globalThis as Record<string, unknown>;\n g.__cellsProjectScope = scope;\n g.__cellsWorkersModule ??= workersClasses;\n // node:* from Node itself (the browser realm gives cellb's polyfills).\n g.__cellsNodeModules ??= new Proxy(\n {},\n { get: (_t, k) => (typeof k === \"string\" ? requireBuiltin(k) : undefined) },\n );\n}\nconst requireBuiltin = createRequire(import.meta.url);\n"]}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * A module file of cellb itself, by path, for a bundler or `import()` at run time (Node only):
3
+ * the compiled `.js` beside the caller in the published package (`dist/`), the TypeScript source
4
+ * in the repository (`src/`). `rel` is relative to `dir`, with or without its `.ts` extension.
5
+ */
6
+ export declare function ownModule(dir: string, rel: string): string;
@@ -0,0 +1,13 @@
1
+ import { existsSync } from "node:fs";
2
+ import { resolve } from "node:path";
3
+ /**
4
+ * A module file of cellb itself, by path, for a bundler or `import()` at run time (Node only):
5
+ * the compiled `.js` beside the caller in the published package (`dist/`), the TypeScript source
6
+ * in the repository (`src/`). `rel` is relative to `dir`, with or without its `.ts` extension.
7
+ */
8
+ export function ownModule(dir, rel) {
9
+ const base = rel.replace(/\.ts$/, "");
10
+ const js = resolve(dir, `${base}.js`);
11
+ return existsSync(js) ? js : resolve(dir, `${base}.ts`);
12
+ }
13
+ //# sourceMappingURL=own-module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"own-module.js","sourceRoot":"","sources":["../../src/project/own-module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC;;;;GAIG;AACH,MAAM,UAAU,SAAS,CAAC,GAAW,EAAE,GAAW;IAChD,MAAM,IAAI,GAAG,GAAG,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IACtC,MAAM,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,GAAG,IAAI,KAAK,CAAC,CAAC;IACtC,OAAO,UAAU,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,IAAI,KAAK,CAAC,CAAC;AAC1D,CAAC","sourcesContent":["import { existsSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\n\n/**\n * A module file of cellb itself, by path, for a bundler or `import()` at run time (Node only):\n * the compiled `.js` beside the caller in the published package (`dist/`), the TypeScript source\n * in the repository (`src/`). `rel` is relative to `dir`, with or without its `.ts` extension.\n */\nexport function ownModule(dir: string, rel: string): string {\n const base = rel.replace(/\\.ts$/, \"\");\n const js = resolve(dir, `${base}.js`);\n return existsSync(js) ? js : resolve(dir, `${base}.ts`);\n}\n"]}
@@ -0,0 +1,2 @@
1
+ /** workerd's `scheduler` global as a JS expression, for browser bundles (see workers-globals.ts). */
2
+ export declare const SCHEDULER_EXPRESSION = "({ wait: (ms) => new Promise((resolve) => setTimeout(resolve, ms)) })";
@@ -0,0 +1,3 @@
1
+ /** workerd's `scheduler` global as a JS expression, for browser bundles (see workers-globals.ts). */
2
+ export const SCHEDULER_EXPRESSION = "({ wait: (ms) => new Promise((resolve) => setTimeout(resolve, ms)) })";
3
+ //# sourceMappingURL=scheduler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scheduler.js","sourceRoot":"","sources":["../../src/project/scheduler.ts"],"names":[],"mappings":"AAAA,qGAAqG;AACrG,MAAM,CAAC,MAAM,oBAAoB,GAC/B,uEAAuE,CAAC","sourcesContent":["/** workerd's `scheduler` global as a JS expression, for browser bundles (see workers-globals.ts). */\nexport const SCHEDULER_EXPRESSION =\n \"({ wait: (ms) => new Promise((resolve) => setTimeout(resolve, ms)) })\";\n"]}
@@ -0,0 +1,74 @@
1
+ import { type FilesApi } from "@statewalker/webrun-files";
2
+ import { type SiteHandler } from "@statewalker/webrun-site-builder";
3
+ import { type ModuleLoader, type WorkerCode } from "../bindings/worker-loader.js";
4
+ /**
5
+ * A project served by an in-browser "HTTP server" (webrun-site-builder handler, hosted in a
6
+ * ServiceWorker by webrun-site-host): the browser's own module loader then fetches the
7
+ * Worker code from real URLs — no bundling, no Blob URLs.
8
+ *
9
+ * GET /modules/~/<path> the project's sources compiled to ESM by webrun-modules
10
+ * PUT /loaded-src/<id>/<file> a Worker Loader stores the modules of loaded code
11
+ * GET /loaded/<id>/~/<file> loaded code compiled to ESM by webrun-modules
12
+ * GET /src/<path> raw project files
13
+ *
14
+ * `cloudflare:workers` and the Workers globals (`Response` with status 101, `WebSocketPair`)
15
+ * are webrun-modules `~deps` proxies that read `globalThis.__webrunHostRegistry` in the realm
16
+ * that imports the code (see `workersHostRegistry`). Each loaded Worker gets its own module
17
+ * server whose `console` proxy selects that Worker's console (Tail Workers).
18
+ */
19
+ export declare const LOADED_CONSOLES = "__cellsLoadedConsoles";
20
+ export declare function createProjectSite(opts: {
21
+ projectFiles: FilesApi;
22
+ /**
23
+ * nodejs_compat: serves the `node:*` modules, and (see `lowerAwait`) lowers the modules' awaits
24
+ * to generators so that AsyncLocalStorage stores follow them. It must match the project's flag:
25
+ * without AsyncContext, the browser host makes continuations carry stores for a nodejs_compat
26
+ * project, which awaits that are not lowered would not see.
27
+ */
28
+ nodeCompat?: boolean;
29
+ /**
30
+ * Lower `await` in the modules served. Default: with `nodeCompat`, unless this browser has
31
+ * AsyncContext (the engine then carries the stores through native awaits, as workerd does).
32
+ */
33
+ lowerAwait?: boolean;
34
+ /**
35
+ * The `node:*` registry entries of the realm that runs the code (`nodeRegistryEntries`): a
36
+ * namespace import (`import * as assert from "node:assert"`) exports the keys the server
37
+ * sees here, so without them its members are undefined.
38
+ */
39
+ nodeModules?: Record<string, unknown>;
40
+ }): SiteHandler;
41
+ /**
42
+ * The registry the `~deps` proxies read, for the realm that runs the Worker code. The project
43
+ * and the Workers it loads share this realm's registry, but not their proxies: each has its own
44
+ * module server, so a proxy of loaded code is a module under `<site>loaded/`. A proxy reads the
45
+ * registry while it is evaluated, so the caller on the stack tells whose it is: loaded code gets
46
+ * `workersModule` (`env` and `exports` empty), the project `projectWorkersModule` (its own).
47
+ */
48
+ export declare function workersHostRegistry(entries: {
49
+ /** nodejs_compat: "node:buffer" → module namespace, and the Buffer/process globals. */
50
+ node?: Record<string, unknown>;
51
+ workersModule: object;
52
+ /** With `loadedPrefix` (`<site>loaded/`): the project's own `cloudflare:workers`. */
53
+ projectWorkersModule?: object;
54
+ loadedPrefix?: string;
55
+ emailModule?: unknown;
56
+ Request: unknown;
57
+ Response: unknown;
58
+ WebSocketPair: unknown;
59
+ caches: unknown;
60
+ HTMLRewriter: unknown;
61
+ WebSocketRequestResponsePair?: unknown;
62
+ WebSocket?: unknown;
63
+ }): void;
64
+ /**
65
+ * Stores one module of loaded code on the site (PUT /loaded-src/<id>/<name>). Source goes
66
+ * through webrun-modules; a text, json or wasm entry is stored as the ESM that wraps it.
67
+ */
68
+ export declare function putLoadedModule(url: string, m: WorkerCode["modules"][string]): Promise<Response>;
69
+ /**
70
+ * Worker Loader over the site: `LOADER.get(id, () => code)` uploads the modules to
71
+ * `/loaded-src/<id>/…` and imports `/loaded/<id>/~/<main>` — compiled by webrun-modules and
72
+ * fetched by the browser like any other module. Works in pages, workers and ServiceWorkers.
73
+ */
74
+ export declare function siteModuleLoader(baseUrl: string): ModuleLoader;
@@ -0,0 +1,206 @@
1
+ import { readText } from "@statewalker/webrun-files";
2
+ import { MemFilesApi } from "@statewalker/webrun-files-mem";
3
+ import { newDefaultTransform, newModuleServer } from "@statewalker/webrun-modules";
4
+ import { SiteBuilder } from "@statewalker/webrun-site-builder";
5
+ import { moduleText, outboundFetch, } from "../bindings/worker-loader.js";
6
+ import { nativeAsyncContext } from "../core/async-context.js";
7
+ import { NODE_POLYFILL_FILES, NODE_POLYFILL_PACKAGES } from "../node-compat/modules.js";
8
+ import { lowerAwait } from "./lower-await.js";
9
+ import { SCHEDULER_EXPRESSION } from "./scheduler.js";
10
+ import { WORKERS_GLOBAL_NAMES } from "./workers-global-names.js";
11
+ /**
12
+ * A project served by an in-browser "HTTP server" (webrun-site-builder handler, hosted in a
13
+ * ServiceWorker by webrun-site-host): the browser's own module loader then fetches the
14
+ * Worker code from real URLs — no bundling, no Blob URLs.
15
+ *
16
+ * GET /modules/~/<path> the project's sources compiled to ESM by webrun-modules
17
+ * PUT /loaded-src/<id>/<file> a Worker Loader stores the modules of loaded code
18
+ * GET /loaded/<id>/~/<file> loaded code compiled to ESM by webrun-modules
19
+ * GET /src/<path> raw project files
20
+ *
21
+ * `cloudflare:workers` and the Workers globals (`Response` with status 101, `WebSocketPair`)
22
+ * are webrun-modules `~deps` proxies that read `globalThis.__webrunHostRegistry` in the realm
23
+ * that imports the code (see `workersHostRegistry`). Each loaded Worker gets its own module
24
+ * server whose `console` proxy selects that Worker's console (Tail Workers).
25
+ */
26
+ export const LOADED_CONSOLES = "__cellsLoadedConsoles";
27
+ /** webrun-modules' transform, then `lowerAwait` on its output. */
28
+ function loweringTransform() {
29
+ const base = newDefaultTransform(true);
30
+ return {
31
+ async transform(file, rewrite) {
32
+ const r = await base.transform(file, rewrite);
33
+ return { ...r, code: lowerAwait(r.code) };
34
+ },
35
+ };
36
+ }
37
+ export function createProjectSite(opts) {
38
+ const host = "globalThis.__webrunHostRegistry.get";
39
+ // nodejs_compat: node:* and the Buffer/process globals come from the realm's registry too.
40
+ // A namespace import (`import * as cf`) exports the keys the server sees here.
41
+ const provided = {
42
+ "cloudflare:workers": Object.fromEntries(WORKERS_MODULE_NAMES.map((n) => [n, null])),
43
+ "cloudflare:email": { EmailMessage: null },
44
+ };
45
+ if (opts.nodeCompat)
46
+ for (const name of [
47
+ ...Object.keys(NODE_POLYFILL_PACKAGES),
48
+ ...Object.keys(NODE_POLYFILL_FILES),
49
+ ])
50
+ provided[name] = opts.nodeModules?.[name] ?? {};
51
+ const globals = {
52
+ ...Object.fromEntries(WORKERS_GLOBAL_NAMES.map((n) => [n, `${host}(${JSON.stringify(n)})`])),
53
+ scheduler: SCHEDULER_EXPRESSION,
54
+ ...(opts.nodeCompat ? { Buffer: `${host}("Buffer")`, process: `${host}("process")` } : {}),
55
+ };
56
+ // nodejs_compat without AsyncContext: awaits lowered to generators, so that AsyncLocalStorage
57
+ // stores follow them (the browser host installs the polyfill's continuations for such a project).
58
+ const lower = opts.lowerAwait ?? (!!opts.nodeCompat && !nativeAsyncContext());
59
+ const transform = lower ? loweringTransform() : undefined;
60
+ const modules = newModuleServer({
61
+ cache: new MemFilesApi(),
62
+ project: opts.projectFiles,
63
+ basePath: "/modules/",
64
+ target: "browser",
65
+ provided,
66
+ globals,
67
+ transform,
68
+ });
69
+ // One module server per loaded Worker: its globals proxy (one per project root in
70
+ // webrun-modules) can then bind `console` to that Worker's own console (Tail Workers).
71
+ // `esm`: modules stored as ESM already (text, json, wasm entries), served as they are: the
72
+ // module server would serve `math.wasm` or `text.txt` by their extension.
73
+ const loaded = new Map();
74
+ const loadedFor = (id) => {
75
+ let l = loaded.get(id);
76
+ if (!l) {
77
+ const files = new MemFilesApi();
78
+ const server = newModuleServer({
79
+ cache: new MemFilesApi(),
80
+ project: files,
81
+ basePath: `/loaded/${encodeURIComponent(id)}/`,
82
+ target: "browser",
83
+ provided,
84
+ transform,
85
+ globals: {
86
+ ...globals,
87
+ console: `(globalThis.${LOADED_CONSOLES}?.[${JSON.stringify(id)}] ?? globalThis.console)`,
88
+ fetch: `(globalThis.__cellsLoadedOutbound?.[${JSON.stringify(id)}] ?? globalThis.fetch)`,
89
+ },
90
+ });
91
+ l = { files, server, esm: new Set() };
92
+ loaded.set(id, l);
93
+ }
94
+ return l;
95
+ };
96
+ return new SiteBuilder()
97
+ .setEndpoint("/modules/*", (req) => modules.fetch(req))
98
+ .setEndpoint("/loaded/:id/*", async (req, env) => {
99
+ const l = loadedFor(decodeURIComponent(String(env.params.id)));
100
+ const path = decodeURIComponent(new URL(req.url).pathname.slice(`/loaded/${env.params.id}/~`.length));
101
+ if (!l.esm.has(path))
102
+ return l.server.fetch(req);
103
+ return new Response(await readText(l.files, path), {
104
+ headers: { "content-type": "text/javascript" },
105
+ });
106
+ })
107
+ .setEndpoint("/loaded-src/:id/*", "PUT", async (req, env) => {
108
+ const id = decodeURIComponent(String(env.params.id));
109
+ const path = decodeURIComponent(new URL(req.url).pathname.slice(`/loaded-src/${env.params.id}`.length));
110
+ const l = loadedFor(id);
111
+ await l.files.write(path, [new Uint8Array(await req.arrayBuffer())]);
112
+ if (req.headers.has(ESM_HEADER))
113
+ l.esm.add(path);
114
+ return new Response(null, { status: 204 });
115
+ })
116
+ .setFiles("/src", opts.projectFiles)
117
+ .build();
118
+ }
119
+ /** What `cloudflare:workers` exports on a site (`env` and `exports` are a project's own). */
120
+ const WORKERS_MODULE_NAMES = [
121
+ "DurableObject",
122
+ "WorkerEntrypoint",
123
+ "WorkflowEntrypoint",
124
+ "RpcTarget",
125
+ "env",
126
+ "exports",
127
+ "waitUntil",
128
+ ];
129
+ /**
130
+ * The registry the `~deps` proxies read, for the realm that runs the Worker code. The project
131
+ * and the Workers it loads share this realm's registry, but not their proxies: each has its own
132
+ * module server, so a proxy of loaded code is a module under `<site>loaded/`. A proxy reads the
133
+ * registry while it is evaluated, so the caller on the stack tells whose it is: loaded code gets
134
+ * `workersModule` (`env` and `exports` empty), the project `projectWorkersModule` (its own).
135
+ */
136
+ export function workersHostRegistry(entries) {
137
+ const map = new Map([
138
+ ["cloudflare:workers", { env: {}, exports: {}, waitUntil: () => { }, ...entries.workersModule }],
139
+ ["cloudflare:email", entries.emailModule],
140
+ ...WORKERS_GLOBAL_NAMES.map((n) => [n, entries[n]]),
141
+ ...Object.entries(entries.node ?? {}),
142
+ ]);
143
+ const { projectWorkersModule: project, loadedPrefix } = entries;
144
+ globalThis.__webrunHostRegistry = {
145
+ get: (k) => k === "cloudflare:workers" && project && loadedPrefix
146
+ ? (new Error().stack ?? "").includes(loadedPrefix)
147
+ ? map.get(k)
148
+ : project
149
+ : map.get(k),
150
+ has: (k) => map.has(k),
151
+ set: (k, v) => void map.set(k, v),
152
+ };
153
+ }
154
+ const ESM_HEADER = "x-cellb-esm";
155
+ /**
156
+ * Stores one module of loaded code on the site (PUT /loaded-src/<id>/<name>). Source goes
157
+ * through webrun-modules; a text, json or wasm entry is stored as the ESM that wraps it.
158
+ */
159
+ export function putLoadedModule(url, m) {
160
+ const wrapped = typeof m === "object" && !("js" in m) && !("esModule" in m);
161
+ return fetch(url, {
162
+ method: "PUT",
163
+ body: moduleText(m),
164
+ headers: wrapped ? { [ESM_HEADER]: "1" } : {},
165
+ });
166
+ }
167
+ /**
168
+ * Worker Loader over the site: `LOADER.get(id, () => code)` uploads the modules to
169
+ * `/loaded-src/<id>/…` and imports `/loaded/<id>/~/<main>` — compiled by webrun-modules and
170
+ * fetched by the browser like any other module. Works in pages, workers and ServiceWorkers.
171
+ */
172
+ export function siteModuleLoader(baseUrl) {
173
+ const base = baseUrl.endsWith("/") ? baseUrl : `${baseUrl}/`;
174
+ return async (id, code, logs) => {
175
+ const dir = encodeURIComponent(id);
176
+ for (const [name, m] of Object.entries(code.modules)) {
177
+ const res = await putLoadedModule(`${base}loaded-src/${dir}/${name}`, m);
178
+ if (!res.ok)
179
+ throw new Error(`Worker Loader: cannot store ${id}/${name}: ${res.status}`);
180
+ }
181
+ const outbound = outboundFetch(code);
182
+ if (outbound) {
183
+ const g = globalThis;
184
+ g.__cellsLoadedOutbound ??= {};
185
+ g.__cellsLoadedOutbound[id] = outbound;
186
+ }
187
+ if (logs) {
188
+ const g = globalThis;
189
+ g[LOADED_CONSOLES] ??= {};
190
+ const real = globalThis.console;
191
+ const wrap = (level) => (...args) => {
192
+ logs(level, args);
193
+ real[level](...args);
194
+ };
195
+ g[LOADED_CONSOLES][id] = Object.assign(Object.create(real), {
196
+ log: wrap("log"),
197
+ info: wrap("info"),
198
+ warn: wrap("warn"),
199
+ error: wrap("error"),
200
+ debug: wrap("debug"),
201
+ });
202
+ }
203
+ return (await import(/* @vite-ignore */ `${base}loaded/${dir}/~/${code.mainModule}`));
204
+ };
205
+ }
206
+ //# sourceMappingURL=site.js.map
@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AO,CAAC;aACrB,CAAC,CAAC;QACL,CAAC;QACD,OAAO,CAAC,MAAM,MAAM,CAAC,kBAAkB,CAAC,GAAG,IAAI,UAAU,GAAG,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC,CAGnF,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { type FilesApi, readText } from \"@statewalker/webrun-files\";\nimport { MemFilesApi } from \"@statewalker/webrun-files-mem\";\nimport { newDefaultTransform, newModuleServer, type Transform } from \"@statewalker/webrun-modules\";\nimport { SiteBuilder, type SiteHandler } from \"@statewalker/webrun-site-builder\";\nimport {\n type LogSink,\n type ModuleLoader,\n moduleText,\n outboundFetch,\n type WorkerCode,\n} from \"../bindings/worker-loader.js\";\nimport { nativeAsyncContext } from \"../core/async-context.js\";\nimport { NODE_POLYFILL_FILES, NODE_POLYFILL_PACKAGES } from \"../node-compat/modules.js\";\nimport { lowerAwait } from \"./lower-await.js\";\nimport { SCHEDULER_EXPRESSION } from \"./scheduler.js\";\nimport { WORKERS_GLOBAL_NAMES } from \"./workers-global-names.js\";\n\n/**\n * A project served by an in-browser \"HTTP server\" (webrun-site-builder handler, hosted in a\n * ServiceWorker by webrun-site-host): the browser's own module loader then fetches the\n * Worker code from real URLs — no bundling, no Blob URLs.\n *\n * GET /modules/~/<path> the project's sources compiled to ESM by webrun-modules\n * PUT /loaded-src/<id>/<file> a Worker Loader stores the modules of loaded code\n * GET /loaded/<id>/~/<file> loaded code compiled to ESM by webrun-modules\n * GET /src/<path> raw project files\n *\n * `cloudflare:workers` and the Workers globals (`Response` with status 101, `WebSocketPair`)\n * are webrun-modules `~deps` proxies that read `globalThis.__webrunHostRegistry` in the realm\n * that imports the code (see `workersHostRegistry`). Each loaded Worker gets its own module\n * server whose `console` proxy selects that Worker's console (Tail Workers).\n */\nexport const LOADED_CONSOLES = \"__cellsLoadedConsoles\";\n\n/** webrun-modules' transform, then `lowerAwait` on its output. */\nfunction loweringTransform(): Transform {\n const base = newDefaultTransform(true);\n return {\n async transform(file, rewrite) {\n const r = await base.transform(file, rewrite);\n return { ...r, code: lowerAwait(r.code) };\n },\n };\n}\n\nexport function createProjectSite(opts: {\n projectFiles: FilesApi;\n /**\n * nodejs_compat: serves the `node:*` modules, and (see `lowerAwait`) lowers the modules' awaits\n * to generators so that AsyncLocalStorage stores follow them. It must match the project's flag:\n * without AsyncContext, the browser host makes continuations carry stores for a nodejs_compat\n * project, which awaits that are not lowered would not see.\n */\n nodeCompat?: boolean;\n /**\n * Lower `await` in the modules served. Default: with `nodeCompat`, unless this browser has\n * AsyncContext (the engine then carries the stores through native awaits, as workerd does).\n */\n lowerAwait?: boolean;\n /**\n * The `node:*` registry entries of the realm that runs the code (`nodeRegistryEntries`): a\n * namespace import (`import * as assert from \"node:assert\"`) exports the keys the server\n * sees here, so without them its members are undefined.\n */\n nodeModules?: Record<string, unknown>;\n}): SiteHandler {\n const host = \"globalThis.__webrunHostRegistry.get\";\n // nodejs_compat: node:* and the Buffer/process globals come from the realm's registry too.\n // A namespace import (`import * as cf`) exports the keys the server sees here.\n const provided: Record<string, object> = {\n \"cloudflare:workers\": Object.fromEntries(WORKERS_MODULE_NAMES.map((n) => [n, null])),\n \"cloudflare:email\": { EmailMessage: null },\n };\n if (opts.nodeCompat)\n for (const name of [\n ...Object.keys(NODE_POLYFILL_PACKAGES),\n ...Object.keys(NODE_POLYFILL_FILES),\n ])\n provided[name] = (opts.nodeModules?.[name] as object) ?? {};\n const globals = {\n ...Object.fromEntries(WORKERS_GLOBAL_NAMES.map((n) => [n, `${host}(${JSON.stringify(n)})`])),\n scheduler: SCHEDULER_EXPRESSION,\n ...(opts.nodeCompat ? { Buffer: `${host}(\"Buffer\")`, process: `${host}(\"process\")` } : {}),\n };\n // nodejs_compat without AsyncContext: awaits lowered to generators, so that AsyncLocalStorage\n // stores follow them (the browser host installs the polyfill's continuations for such a project).\n const lower = opts.lowerAwait ?? (!!opts.nodeCompat && !nativeAsyncContext());\n const transform = lower ? loweringTransform() : undefined;\n const modules = newModuleServer({\n cache: new MemFilesApi(),\n project: opts.projectFiles,\n basePath: \"/modules/\",\n target: \"browser\",\n provided,\n globals,\n transform,\n });\n // One module server per loaded Worker: its globals proxy (one per project root in\n // webrun-modules) can then bind `console` to that Worker's own console (Tail Workers).\n // `esm`: modules stored as ESM already (text, json, wasm entries), served as they are: the\n // module server would serve `math.wasm` or `text.txt` by their extension.\n const loaded = new Map<\n string,\n { files: FilesApi; server: ReturnType<typeof newModuleServer>; esm: Set<string> }\n >();\n const loadedFor = (id: string) => {\n let l = loaded.get(id);\n if (!l) {\n const files = new MemFilesApi();\n const server = newModuleServer({\n cache: new MemFilesApi(),\n project: files,\n basePath: `/loaded/${encodeURIComponent(id)}/`,\n target: \"browser\",\n provided,\n transform,\n globals: {\n ...globals,\n console: `(globalThis.${LOADED_CONSOLES}?.[${JSON.stringify(id)}] ?? globalThis.console)`,\n fetch: `(globalThis.__cellsLoadedOutbound?.[${JSON.stringify(id)}] ?? globalThis.fetch)`,\n },\n });\n l = { files, server, esm: new Set() };\n loaded.set(id, l);\n }\n return l;\n };\n return new SiteBuilder()\n .setEndpoint(\"/modules/*\", (req) => modules.fetch(req))\n .setEndpoint(\"/loaded/:id/*\", async (req, env) => {\n const l = loadedFor(decodeURIComponent(String(env.params.id)));\n const path = decodeURIComponent(\n new URL(req.url).pathname.slice(`/loaded/${env.params.id}/~`.length),\n );\n if (!l.esm.has(path)) return l.server.fetch(req);\n return new Response(await readText(l.files, path), {\n headers: { \"content-type\": \"text/javascript\" },\n });\n })\n .setEndpoint(\"/loaded-src/:id/*\", \"PUT\", async (req, env) => {\n const id = decodeURIComponent(String(env.params.id));\n const path = decodeURIComponent(\n new URL(req.url).pathname.slice(`/loaded-src/${env.params.id}`.length),\n );\n const l = loadedFor(id);\n await l.files.write(path, [new Uint8Array(await req.arrayBuffer())]);\n if (req.headers.has(ESM_HEADER)) l.esm.add(path);\n return new Response(null, { status: 204 });\n })\n .setFiles(\"/src\", opts.projectFiles)\n .build();\n}\n\n/** What `cloudflare:workers` exports on a site (`env` and `exports` are a project's own). */\nconst WORKERS_MODULE_NAMES = [\n \"DurableObject\",\n \"WorkerEntrypoint\",\n \"WorkflowEntrypoint\",\n \"RpcTarget\",\n \"env\",\n \"exports\",\n \"waitUntil\",\n];\n\n/**\n * The registry the `~deps` proxies read, for the realm that runs the Worker code. The project\n * and the Workers it loads share this realm's registry, but not their proxies: each has its own\n * module server, so a proxy of loaded code is a module under `<site>loaded/`. A proxy reads the\n * registry while it is evaluated, so the caller on the stack tells whose it is: loaded code gets\n * `workersModule` (`env` and `exports` empty), the project `projectWorkersModule` (its own).\n */\nexport function workersHostRegistry(entries: {\n /** nodejs_compat: \"node:buffer\" → module namespace, and the Buffer/process globals. */\n node?: Record<string, unknown>;\n workersModule: object;\n /** With `loadedPrefix` (`<site>loaded/`): the project's own `cloudflare:workers`. */\n projectWorkersModule?: object;\n loadedPrefix?: string;\n emailModule?: unknown;\n Request: unknown;\n Response: unknown;\n WebSocketPair: unknown;\n caches: unknown;\n HTMLRewriter: unknown;\n WebSocketRequestResponsePair?: unknown;\n WebSocket?: unknown;\n}): void {\n const map = new Map<string, unknown>([\n [\"cloudflare:workers\", { env: {}, exports: {}, waitUntil: () => {}, ...entries.workersModule }],\n [\"cloudflare:email\", entries.emailModule],\n ...WORKERS_GLOBAL_NAMES.map((n) => [n, entries[n]] as const),\n ...Object.entries(entries.node ?? {}),\n ]);\n const { projectWorkersModule: project, loadedPrefix } = entries;\n (globalThis as Record<string, unknown>).__webrunHostRegistry = {\n get: (k: string) =>\n k === \"cloudflare:workers\" && project && loadedPrefix\n ? (new Error().stack ?? \"\").includes(loadedPrefix)\n ? map.get(k)\n : project\n : map.get(k),\n has: (k: string) => map.has(k),\n set: (k: string, v: unknown) => void map.set(k, v),\n };\n}\n\nconst ESM_HEADER = \"x-cellb-esm\";\n\n/**\n * Stores one module of loaded code on the site (PUT /loaded-src/<id>/<name>). Source goes\n * through webrun-modules; a text, json or wasm entry is stored as the ESM that wraps it.\n */\nexport function putLoadedModule(url: string, m: WorkerCode[\"modules\"][string]): Promise<Response> {\n const wrapped = typeof m === \"object\" && !(\"js\" in m) && !(\"esModule\" in m);\n return fetch(url, {\n method: \"PUT\",\n body: moduleText(m),\n headers: wrapped ? { [ESM_HEADER]: \"1\" } : {},\n });\n}\n\n/**\n * Worker Loader over the site: `LOADER.get(id, () => code)` uploads the modules to\n * `/loaded-src/<id>/…` and imports `/loaded/<id>/~/<main>` — compiled by webrun-modules and\n * fetched by the browser like any other module. Works in pages, workers and ServiceWorkers.\n */\nexport function siteModuleLoader(baseUrl: string): ModuleLoader {\n const base = baseUrl.endsWith(\"/\") ? baseUrl : `${baseUrl}/`;\n return async (id: string, code: WorkerCode, logs?: LogSink) => {\n const dir = encodeURIComponent(id);\n for (const [name, m] of Object.entries(code.modules)) {\n const res = await putLoadedModule(`${base}loaded-src/${dir}/${name}`, m);\n if (!res.ok) throw new Error(`Worker Loader: cannot store ${id}/${name}: ${res.status}`);\n }\n const outbound = outboundFetch(code);\n if (outbound) {\n const g = globalThis as Record<string, unknown>;\n g.__cellsLoadedOutbound ??= {};\n (g.__cellsLoadedOutbound as Record<string, unknown>)[id] = outbound;\n }\n if (logs) {\n const g = globalThis as Record<string, unknown>;\n g[LOADED_CONSOLES] ??= {};\n const real = globalThis.console;\n const wrap =\n (level: \"log\" | \"info\" | \"warn\" | \"error\" | \"debug\") =>\n (...args: unknown[]) => {\n logs(level, args);\n real[level](...args);\n };\n (g[LOADED_CONSOLES] as Record<string, unknown>)[id] = Object.assign(Object.create(real), {\n log: wrap(\"log\"),\n info: wrap(\"info\"),\n warn: wrap(\"warn\"),\n error: wrap(\"error\"),\n debug: wrap(\"debug\"),\n });\n }\n return (await import(/* @vite-ignore */ `${base}loaded/${dir}/~/${code.mainModule}`)) as Record<\n string,\n unknown\n >;\n };\n}\n"]}
@@ -0,0 +1,3 @@
1
+ // Virtual specifiers resolved by the bundler plugins (see workers-globals.ts).
2
+ declare module "cellb:ws";
3
+ declare module "cellb:compat";
@@ -0,0 +1,27 @@
1
+ /** `env` and `exports` of `cloudflare:workers` for one project's Worker code. */
2
+ export interface WorkerScope {
3
+ readonly env: Record<string, unknown>;
4
+ readonly exports: Record<string, unknown>;
5
+ /**
6
+ * `waitUntil` of `cloudflare:workers`: the promise runs in the runtime's background (until its
7
+ * `drain()`); before the scope is bound to a runtime, it just runs.
8
+ */
9
+ readonly waitUntil: (p: Promise<unknown>) => void;
10
+ /** Points both at the runtime's own objects (the ones `fetch` and `ctx.exports` see). */
11
+ bind(runtime: {
12
+ env: Record<string, unknown>;
13
+ exports: Record<string, unknown>;
14
+ waitUntil?: (p: Promise<unknown>) => void;
15
+ }): void;
16
+ }
17
+ /**
18
+ * A scope whose `env` serves `vars` until it is bound to a runtime: the code reads `env` while
19
+ * its module is evaluated, before the runtime that builds the bindings exists.
20
+ */
21
+ export declare function workerScope(vars?: Record<string, unknown>): WorkerScope;
22
+ /**
23
+ * The scope of the Worker a loaded Worker's isolate runs, made on first use. It is
24
+ * `globalThis.__cellsProjectScope`, which the realm's `cloudflare:workers` reads, as a browser
25
+ * project's bundle reads its own (`PROJECT_WORKERS_MODULE_SHIM`).
26
+ */
27
+ export declare function realmWorkerScope(): WorkerScope;
@@ -0,0 +1,46 @@
1
+ /**
2
+ * A scope whose `env` serves `vars` until it is bound to a runtime: the code reads `env` while
3
+ * its module is evaluated, before the runtime that builds the bindings exists.
4
+ */
5
+ export function workerScope(vars = {}) {
6
+ let env = { ...vars };
7
+ let exports = {};
8
+ let background;
9
+ const forward = (target) => new Proxy({}, {
10
+ get: (_, k) => Reflect.get(target(), k),
11
+ set: (_, k, v) => Reflect.set(target(), k, v),
12
+ has: (_, k) => Reflect.has(target(), k),
13
+ deleteProperty: (_, k) => Reflect.deleteProperty(target(), k),
14
+ ownKeys: () => Reflect.ownKeys(target()),
15
+ getOwnPropertyDescriptor: (_, k) => {
16
+ const d = Reflect.getOwnPropertyDescriptor(target(), k);
17
+ return d && { ...d, configurable: true };
18
+ },
19
+ });
20
+ return {
21
+ env: forward(() => env),
22
+ exports: forward(() => exports),
23
+ waitUntil: (p) => {
24
+ if (background)
25
+ background(p);
26
+ else
27
+ void Promise.resolve(p).catch(() => { }); // a rejection is the code's own, unreported
28
+ },
29
+ bind(runtime) {
30
+ env = runtime.env;
31
+ exports = runtime.exports;
32
+ background = runtime.waitUntil ?? background;
33
+ },
34
+ };
35
+ }
36
+ /**
37
+ * The scope of the Worker a loaded Worker's isolate runs, made on first use. It is
38
+ * `globalThis.__cellsProjectScope`, which the realm's `cloudflare:workers` reads, as a browser
39
+ * project's bundle reads its own (`PROJECT_WORKERS_MODULE_SHIM`).
40
+ */
41
+ export function realmWorkerScope() {
42
+ const g = globalThis;
43
+ g.__cellsProjectScope ??= workerScope();
44
+ return g.__cellsProjectScope;
45
+ }
46
+ //# sourceMappingURL=worker-scope.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worker-scope.js","sourceRoot":"","sources":["../../src/project/worker-scope.ts"],"names":[],"mappings":"AAiBA;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,IAAI,GAA4B,EAAE;IAC5D,IAAI,GAAG,GAA4B,EAAE,GAAG,IAAI,EAAE,CAAC;IAC/C,IAAI,OAAO,GAA4B,EAAE,CAAC;IAC1C,IAAI,UAAuD,CAAC;IAC5D,MAAM,OAAO,GAAG,CAAC,MAAqC,EAAE,EAAE,CACxD,IAAI,KAAK,CAAC,EAA6B,EAAE;QACvC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QACvC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC;QAC7C,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,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AAC;AAC/B,CAAC","sourcesContent":["/** `env` and `exports` of `cloudflare:workers` for one project's Worker code. */\nexport interface WorkerScope {\n readonly env: Record<string, unknown>;\n readonly exports: Record<string, unknown>;\n /**\n * `waitUntil` of `cloudflare:workers`: the promise runs in the runtime's background (until its\n * `drain()`); before the scope is bound to a runtime, it just runs.\n */\n readonly waitUntil: (p: Promise<unknown>) => void;\n /** Points both at the runtime's own objects (the ones `fetch` and `ctx.exports` see). */\n bind(runtime: {\n env: Record<string, unknown>;\n exports: Record<string, unknown>;\n waitUntil?: (p: Promise<unknown>) => void;\n }): void;\n}\n\n/**\n * A scope whose `env` serves `vars` until it is bound to a runtime: the code reads `env` while\n * its module is evaluated, before the runtime that builds the bindings exists.\n */\nexport function workerScope(vars: Record<string, unknown> = {}): WorkerScope {\n let env: Record<string, unknown> = { ...vars };\n let exports: Record<string, unknown> = {};\n let background: ((p: Promise<unknown>) => void) | undefined;\n const forward = (target: () => Record<string, unknown>) =>\n new Proxy({} as Record<string, unknown>, {\n get: (_, k) => Reflect.get(target(), k),\n set: (_, k, v) => Reflect.set(target(), k, v),\n has: (_, k) => Reflect.has(target(), k),\n deleteProperty: (_, k) => Reflect.deleteProperty(target(), k),\n ownKeys: () => Reflect.ownKeys(target()),\n getOwnPropertyDescriptor: (_, k) => {\n const d = Reflect.getOwnPropertyDescriptor(target(), k);\n return d && { ...d, configurable: true };\n },\n });\n return {\n env: forward(() => env),\n exports: forward(() => exports),\n waitUntil: (p) => {\n if (background) background(p);\n else void Promise.resolve(p).catch(() => {}); // a rejection is the code's own, unreported\n },\n bind(runtime) {\n env = runtime.env;\n exports = runtime.exports;\n background = runtime.waitUntil ?? background;\n },\n };\n}\n\n/**\n * The scope of the Worker a loaded Worker's isolate runs, made on first use. It is\n * `globalThis.__cellsProjectScope`, which the realm's `cloudflare:workers` reads, as a browser\n * project's bundle reads its own (`PROJECT_WORKERS_MODULE_SHIM`).\n */\nexport function realmWorkerScope(): WorkerScope {\n const g = globalThis as { __cellsProjectScope?: WorkerScope };\n g.__cellsProjectScope ??= workerScope();\n return g.__cellsProjectScope;\n}\n"]}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * workerd's `MessageChannel` on a Node host. In workerd an open port does not keep anything
3
+ * alive; on Node a port with a `message` handler is ref'd and holds the event loop open until it
4
+ * is closed. Libraries create such ports at module scope and never close them (React DOM's
5
+ * server renderer schedules its work over one), so a Worker bundle that imports them would keep
6
+ * the Node process alive after its runtime is closed.
7
+ *
8
+ * The ports of this channel are unref'd and hold the loop open only while a message posted to
9
+ * one of them waits for its handler, so a pending render still completes. Messages, transfers
10
+ * and `close()` are the real ports'. Where ports have no `unref` (browsers), it is the plain
11
+ * `MessageChannel`.
12
+ */
13
+ export declare const WorkerdMessageChannel: typeof MessageChannel | undefined;