@shware/workflow 0.0.0-stage → 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (442) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +154 -2
  3. package/dist/_virtual/_rolldown/runtime.cjs +23 -0
  4. package/dist/apns-relay.cjs +105 -0
  5. package/dist/apns-relay.cjs.map +1 -0
  6. package/dist/apns-relay.d.cts +28 -0
  7. package/dist/apns-relay.d.cts.map +1 -0
  8. package/dist/apns-relay.d.mts +28 -0
  9. package/dist/apns-relay.d.mts.map +1 -0
  10. package/dist/apns-relay.mjs +104 -0
  11. package/dist/apns-relay.mjs.map +1 -0
  12. package/dist/apns.cjs +121 -0
  13. package/dist/apns.cjs.map +1 -0
  14. package/dist/apns.d.cts +63 -0
  15. package/dist/apns.d.cts.map +1 -0
  16. package/dist/apns.d.mts +63 -0
  17. package/dist/apns.d.mts.map +1 -0
  18. package/dist/apns.mjs +116 -0
  19. package/dist/apns.mjs.map +1 -0
  20. package/dist/client.cjs +125 -0
  21. package/dist/client.cjs.map +1 -0
  22. package/dist/client.d.cts +108 -0
  23. package/dist/client.d.cts.map +1 -0
  24. package/dist/client.d.mts +108 -0
  25. package/dist/client.d.mts.map +1 -0
  26. package/dist/client.mjs +122 -0
  27. package/dist/client.mjs.map +1 -0
  28. package/dist/cloudflare/bindings.cjs +28 -0
  29. package/dist/cloudflare/bindings.cjs.map +1 -0
  30. package/dist/cloudflare/bindings.d.cts +144 -0
  31. package/dist/cloudflare/bindings.d.cts.map +1 -0
  32. package/dist/cloudflare/bindings.d.mts +144 -0
  33. package/dist/cloudflare/bindings.d.mts.map +1 -0
  34. package/dist/cloudflare/bindings.mjs +25 -0
  35. package/dist/cloudflare/bindings.mjs.map +1 -0
  36. package/dist/cloudflare/channels.cjs +164 -0
  37. package/dist/cloudflare/channels.cjs.map +1 -0
  38. package/dist/cloudflare/channels.d.cts +29 -0
  39. package/dist/cloudflare/channels.d.cts.map +1 -0
  40. package/dist/cloudflare/channels.d.mts +29 -0
  41. package/dist/cloudflare/channels.d.mts.map +1 -0
  42. package/dist/cloudflare/channels.mjs +161 -0
  43. package/dist/cloudflare/channels.mjs.map +1 -0
  44. package/dist/cloudflare/d1-env.cjs +17 -0
  45. package/dist/cloudflare/d1-env.cjs.map +1 -0
  46. package/dist/cloudflare/d1-env.d.cts +12 -0
  47. package/dist/cloudflare/d1-env.d.cts.map +1 -0
  48. package/dist/cloudflare/d1-env.d.mts +12 -0
  49. package/dist/cloudflare/d1-env.d.mts.map +1 -0
  50. package/dist/cloudflare/d1-env.mjs +16 -0
  51. package/dist/cloudflare/d1-env.mjs.map +1 -0
  52. package/dist/cloudflare/index.cjs +54 -0
  53. package/dist/cloudflare/index.d.cts +19 -0
  54. package/dist/cloudflare/index.d.mts +19 -0
  55. package/dist/cloudflare/index.mjs +16 -0
  56. package/dist/cloudflare/router.cjs +516 -0
  57. package/dist/cloudflare/router.cjs.map +1 -0
  58. package/dist/cloudflare/router.d.cts +157 -0
  59. package/dist/cloudflare/router.d.cts.map +1 -0
  60. package/dist/cloudflare/router.d.mts +157 -0
  61. package/dist/cloudflare/router.d.mts.map +1 -0
  62. package/dist/cloudflare/router.mjs +503 -0
  63. package/dist/cloudflare/router.mjs.map +1 -0
  64. package/dist/cloudflare/runner.cjs +225 -0
  65. package/dist/cloudflare/runner.cjs.map +1 -0
  66. package/dist/cloudflare/runner.d.cts +73 -0
  67. package/dist/cloudflare/runner.d.cts.map +1 -0
  68. package/dist/cloudflare/runner.d.mts +73 -0
  69. package/dist/cloudflare/runner.d.mts.map +1 -0
  70. package/dist/cloudflare/runner.mjs +224 -0
  71. package/dist/cloudflare/runner.mjs.map +1 -0
  72. package/dist/cloudflare/schema.sql +127 -0
  73. package/dist/cloudflare/senders.cjs +114 -0
  74. package/dist/cloudflare/senders.cjs.map +1 -0
  75. package/dist/cloudflare/senders.d.cts +68 -0
  76. package/dist/cloudflare/senders.d.cts.map +1 -0
  77. package/dist/cloudflare/senders.d.mts +68 -0
  78. package/dist/cloudflare/senders.d.mts.map +1 -0
  79. package/dist/cloudflare/senders.mjs +108 -0
  80. package/dist/cloudflare/senders.mjs.map +1 -0
  81. package/dist/cloudflare/worker.cjs +228 -0
  82. package/dist/cloudflare/worker.cjs.map +1 -0
  83. package/dist/cloudflare/worker.d.cts +92 -0
  84. package/dist/cloudflare/worker.d.cts.map +1 -0
  85. package/dist/cloudflare/worker.d.mts +92 -0
  86. package/dist/cloudflare/worker.d.mts.map +1 -0
  87. package/dist/cloudflare/worker.mjs +224 -0
  88. package/dist/cloudflare/worker.mjs.map +1 -0
  89. package/dist/cloudflare/workers.d.cjs +0 -0
  90. package/dist/cloudflare/workers.d.cts +44 -0
  91. package/dist/cloudflare/workers.d.cts.map +1 -0
  92. package/dist/cloudflare/workers.d.mts +44 -0
  93. package/dist/cloudflare/workers.d.mts.map +1 -0
  94. package/dist/config.cjs +151 -0
  95. package/dist/config.cjs.map +1 -0
  96. package/dist/config.d.cts +149 -0
  97. package/dist/config.d.cts.map +1 -0
  98. package/dist/config.d.mts +149 -0
  99. package/dist/config.d.mts.map +1 -0
  100. package/dist/config.mjs +143 -0
  101. package/dist/config.mjs.map +1 -0
  102. package/dist/contract.cjs +212 -0
  103. package/dist/contract.cjs.map +1 -0
  104. package/dist/contract.d.cts +90 -0
  105. package/dist/contract.d.cts.map +1 -0
  106. package/dist/contract.d.mts +90 -0
  107. package/dist/contract.d.mts.map +1 -0
  108. package/dist/contract.mjs +206 -0
  109. package/dist/contract.mjs.map +1 -0
  110. package/dist/dsl/action.cjs +29 -0
  111. package/dist/dsl/action.cjs.map +1 -0
  112. package/dist/dsl/action.d.cts +64 -0
  113. package/dist/dsl/action.d.cts.map +1 -0
  114. package/dist/dsl/action.d.mts +64 -0
  115. package/dist/dsl/action.d.mts.map +1 -0
  116. package/dist/dsl/action.mjs +28 -0
  117. package/dist/dsl/action.mjs.map +1 -0
  118. package/dist/dsl/base.cjs +34 -0
  119. package/dist/dsl/base.cjs.map +1 -0
  120. package/dist/dsl/base.d.cts +45 -0
  121. package/dist/dsl/base.d.cts.map +1 -0
  122. package/dist/dsl/base.d.mts +45 -0
  123. package/dist/dsl/base.d.mts.map +1 -0
  124. package/dist/dsl/base.mjs +30 -0
  125. package/dist/dsl/base.mjs.map +1 -0
  126. package/dist/dsl/bundle.cjs +207 -0
  127. package/dist/dsl/bundle.cjs.map +1 -0
  128. package/dist/dsl/bundle.d.cts +19 -0
  129. package/dist/dsl/bundle.d.cts.map +1 -0
  130. package/dist/dsl/bundle.d.mts +19 -0
  131. package/dist/dsl/bundle.d.mts.map +1 -0
  132. package/dist/dsl/bundle.mjs +206 -0
  133. package/dist/dsl/bundle.mjs.map +1 -0
  134. package/dist/dsl/condition.cjs +177 -0
  135. package/dist/dsl/condition.cjs.map +1 -0
  136. package/dist/dsl/condition.d.cts +140 -0
  137. package/dist/dsl/condition.d.cts.map +1 -0
  138. package/dist/dsl/condition.d.mts +140 -0
  139. package/dist/dsl/condition.d.mts.map +1 -0
  140. package/dist/dsl/condition.mjs +156 -0
  141. package/dist/dsl/condition.mjs.map +1 -0
  142. package/dist/dsl/flow.cjs +228 -0
  143. package/dist/dsl/flow.cjs.map +1 -0
  144. package/dist/dsl/flow.d.cts +223 -0
  145. package/dist/dsl/flow.d.cts.map +1 -0
  146. package/dist/dsl/flow.d.mts +223 -0
  147. package/dist/dsl/flow.d.mts.map +1 -0
  148. package/dist/dsl/flow.mjs +226 -0
  149. package/dist/dsl/flow.mjs.map +1 -0
  150. package/dist/dsl/index.cjs +38 -0
  151. package/dist/dsl/index.d.cts +10 -0
  152. package/dist/dsl/index.d.mts +10 -0
  153. package/dist/dsl/index.mjs +9 -0
  154. package/dist/dsl/refs.cjs +59 -0
  155. package/dist/dsl/refs.cjs.map +1 -0
  156. package/dist/dsl/refs.d.cts +88 -0
  157. package/dist/dsl/refs.d.cts.map +1 -0
  158. package/dist/dsl/refs.d.mts +88 -0
  159. package/dist/dsl/refs.d.mts.map +1 -0
  160. package/dist/dsl/refs.mjs +55 -0
  161. package/dist/dsl/refs.mjs.map +1 -0
  162. package/dist/dsl/template.cjs +65 -0
  163. package/dist/dsl/template.cjs.map +1 -0
  164. package/dist/dsl/template.d.cts +75 -0
  165. package/dist/dsl/template.d.cts.map +1 -0
  166. package/dist/dsl/template.d.mts +75 -0
  167. package/dist/dsl/template.d.mts.map +1 -0
  168. package/dist/dsl/template.mjs +63 -0
  169. package/dist/dsl/template.mjs.map +1 -0
  170. package/dist/dsl/trigger.cjs +40 -0
  171. package/dist/dsl/trigger.cjs.map +1 -0
  172. package/dist/dsl/trigger.d.cts +65 -0
  173. package/dist/dsl/trigger.d.cts.map +1 -0
  174. package/dist/dsl/trigger.d.mts +65 -0
  175. package/dist/dsl/trigger.d.mts.map +1 -0
  176. package/dist/dsl/trigger.mjs +39 -0
  177. package/dist/dsl/trigger.mjs.map +1 -0
  178. package/dist/dsl/workflow.cjs +121 -0
  179. package/dist/dsl/workflow.cjs.map +1 -0
  180. package/dist/dsl/workflow.d.cts +59 -0
  181. package/dist/dsl/workflow.d.cts.map +1 -0
  182. package/dist/dsl/workflow.d.mts +59 -0
  183. package/dist/dsl/workflow.d.mts.map +1 -0
  184. package/dist/dsl/workflow.mjs +120 -0
  185. package/dist/dsl/workflow.mjs.map +1 -0
  186. package/dist/engine/actions.cjs +27 -0
  187. package/dist/engine/actions.cjs.map +1 -0
  188. package/dist/engine/actions.d.cts +40 -0
  189. package/dist/engine/actions.d.cts.map +1 -0
  190. package/dist/engine/actions.d.mts +40 -0
  191. package/dist/engine/actions.d.mts.map +1 -0
  192. package/dist/engine/actions.mjs +26 -0
  193. package/dist/engine/actions.mjs.map +1 -0
  194. package/dist/engine/bucket.cjs +72 -0
  195. package/dist/engine/bucket.cjs.map +1 -0
  196. package/dist/engine/bucket.d.cts +32 -0
  197. package/dist/engine/bucket.d.cts.map +1 -0
  198. package/dist/engine/bucket.d.mts +32 -0
  199. package/dist/engine/bucket.d.mts.map +1 -0
  200. package/dist/engine/bucket.mjs +69 -0
  201. package/dist/engine/bucket.mjs.map +1 -0
  202. package/dist/engine/condition.cjs +166 -0
  203. package/dist/engine/condition.cjs.map +1 -0
  204. package/dist/engine/condition.d.cts +52 -0
  205. package/dist/engine/condition.d.cts.map +1 -0
  206. package/dist/engine/condition.d.mts +52 -0
  207. package/dist/engine/condition.d.mts.map +1 -0
  208. package/dist/engine/condition.mjs +161 -0
  209. package/dist/engine/condition.mjs.map +1 -0
  210. package/dist/engine/index.cjs +20 -0
  211. package/dist/engine/index.d.cts +8 -0
  212. package/dist/engine/index.d.mts +8 -0
  213. package/dist/engine/index.mjs +7 -0
  214. package/dist/engine/interpreter.cjs +428 -0
  215. package/dist/engine/interpreter.cjs.map +1 -0
  216. package/dist/engine/interpreter.d.cts +6 -0
  217. package/dist/engine/interpreter.d.cts.map +1 -0
  218. package/dist/engine/interpreter.d.mts +6 -0
  219. package/dist/engine/interpreter.d.mts.map +1 -0
  220. package/dist/engine/interpreter.mjs +427 -0
  221. package/dist/engine/interpreter.mjs.map +1 -0
  222. package/dist/engine/ports.cjs +0 -0
  223. package/dist/engine/ports.d.cts +252 -0
  224. package/dist/engine/ports.d.cts.map +1 -0
  225. package/dist/engine/ports.d.mts +252 -0
  226. package/dist/engine/ports.d.mts.map +1 -0
  227. package/dist/engine/ports.mjs +1 -0
  228. package/dist/engine/recipient.cjs +23 -0
  229. package/dist/engine/recipient.cjs.map +1 -0
  230. package/dist/engine/recipient.d.cts +13 -0
  231. package/dist/engine/recipient.d.cts.map +1 -0
  232. package/dist/engine/recipient.d.mts +13 -0
  233. package/dist/engine/recipient.d.mts.map +1 -0
  234. package/dist/engine/recipient.mjs +22 -0
  235. package/dist/engine/recipient.mjs.map +1 -0
  236. package/dist/engine/time-scale.cjs +54 -0
  237. package/dist/engine/time-scale.cjs.map +1 -0
  238. package/dist/engine/time-scale.d.cts +31 -0
  239. package/dist/engine/time-scale.d.cts.map +1 -0
  240. package/dist/engine/time-scale.d.mts +31 -0
  241. package/dist/engine/time-scale.d.mts.map +1 -0
  242. package/dist/engine/time-scale.mjs +52 -0
  243. package/dist/engine/time-scale.mjs.map +1 -0
  244. package/dist/engine/time-window.cjs +149 -0
  245. package/dist/engine/time-window.cjs.map +1 -0
  246. package/dist/engine/time-window.d.cts +22 -0
  247. package/dist/engine/time-window.d.cts.map +1 -0
  248. package/dist/engine/time-window.d.mts +22 -0
  249. package/dist/engine/time-window.d.mts.map +1 -0
  250. package/dist/engine/time-window.mjs +147 -0
  251. package/dist/engine/time-window.mjs.map +1 -0
  252. package/dist/fcm.cjs +125 -0
  253. package/dist/fcm.cjs.map +1 -0
  254. package/dist/fcm.d.cts +48 -0
  255. package/dist/fcm.d.cts.map +1 -0
  256. package/dist/fcm.d.mts +48 -0
  257. package/dist/fcm.d.mts.map +1 -0
  258. package/dist/fcm.mjs +121 -0
  259. package/dist/fcm.mjs.map +1 -0
  260. package/dist/hash.cjs +245 -0
  261. package/dist/hash.cjs.map +1 -0
  262. package/dist/hash.d.cts +30 -0
  263. package/dist/hash.d.cts.map +1 -0
  264. package/dist/hash.d.mts +30 -0
  265. package/dist/hash.d.mts.map +1 -0
  266. package/dist/hash.mjs +239 -0
  267. package/dist/hash.mjs.map +1 -0
  268. package/dist/index.cjs +100 -0
  269. package/dist/index.d.cts +18 -0
  270. package/dist/index.d.mts +18 -0
  271. package/dist/index.mjs +17 -0
  272. package/dist/ir.cjs +366 -0
  273. package/dist/ir.cjs.map +1 -0
  274. package/dist/ir.d.cts +486 -0
  275. package/dist/ir.d.cts.map +1 -0
  276. package/dist/ir.d.mts +486 -0
  277. package/dist/ir.d.mts.map +1 -0
  278. package/dist/ir.mjs +344 -0
  279. package/dist/ir.mjs.map +1 -0
  280. package/dist/jwt.cjs +22 -0
  281. package/dist/jwt.cjs.map +1 -0
  282. package/dist/jwt.d.cts +9 -0
  283. package/dist/jwt.d.cts.map +1 -0
  284. package/dist/jwt.d.mts +9 -0
  285. package/dist/jwt.d.mts.map +1 -0
  286. package/dist/jwt.mjs +20 -0
  287. package/dist/jwt.mjs.map +1 -0
  288. package/dist/plan.cjs +223 -0
  289. package/dist/plan.cjs.map +1 -0
  290. package/dist/plan.d.cts +68 -0
  291. package/dist/plan.d.cts.map +1 -0
  292. package/dist/plan.d.mts +68 -0
  293. package/dist/plan.d.mts.map +1 -0
  294. package/dist/plan.mjs +221 -0
  295. package/dist/plan.mjs.map +1 -0
  296. package/dist/postgres-js.cjs +42 -0
  297. package/dist/postgres-js.cjs.map +1 -0
  298. package/dist/postgres-js.d.cts +28 -0
  299. package/dist/postgres-js.d.cts.map +1 -0
  300. package/dist/postgres-js.d.mts +28 -0
  301. package/dist/postgres-js.d.mts.map +1 -0
  302. package/dist/postgres-js.mjs +38 -0
  303. package/dist/postgres-js.mjs.map +1 -0
  304. package/dist/provenance.cjs +67 -0
  305. package/dist/provenance.cjs.map +1 -0
  306. package/dist/provenance.d.cts +41 -0
  307. package/dist/provenance.d.cts.map +1 -0
  308. package/dist/provenance.d.mts +41 -0
  309. package/dist/provenance.d.mts.map +1 -0
  310. package/dist/provenance.mjs +65 -0
  311. package/dist/provenance.mjs.map +1 -0
  312. package/dist/push.cjs +14 -0
  313. package/dist/push.cjs.map +1 -0
  314. package/dist/push.d.cts +16 -0
  315. package/dist/push.d.cts.map +1 -0
  316. package/dist/push.d.mts +16 -0
  317. package/dist/push.d.mts.map +1 -0
  318. package/dist/push.mjs +13 -0
  319. package/dist/push.mjs.map +1 -0
  320. package/dist/react-email.cjs +48 -0
  321. package/dist/react-email.cjs.map +1 -0
  322. package/dist/react-email.d.cts +7 -0
  323. package/dist/react-email.d.cts.map +1 -0
  324. package/dist/react-email.d.mts +7 -0
  325. package/dist/react-email.d.mts.map +1 -0
  326. package/dist/react-email.mjs +47 -0
  327. package/dist/react-email.mjs.map +1 -0
  328. package/dist/reporting/classify.cjs +42 -0
  329. package/dist/reporting/classify.cjs.map +1 -0
  330. package/dist/reporting/classify.d.cts +60 -0
  331. package/dist/reporting/classify.d.cts.map +1 -0
  332. package/dist/reporting/classify.d.mts +60 -0
  333. package/dist/reporting/classify.d.mts.map +1 -0
  334. package/dist/reporting/classify.mjs +38 -0
  335. package/dist/reporting/classify.mjs.map +1 -0
  336. package/dist/reporting/observer.cjs +63 -0
  337. package/dist/reporting/observer.cjs.map +1 -0
  338. package/dist/reporting/observer.d.cts +18 -0
  339. package/dist/reporting/observer.d.cts.map +1 -0
  340. package/dist/reporting/observer.d.mts +18 -0
  341. package/dist/reporting/observer.d.mts.map +1 -0
  342. package/dist/reporting/observer.mjs +62 -0
  343. package/dist/reporting/observer.mjs.map +1 -0
  344. package/dist/reporting/tracking.cjs +153 -0
  345. package/dist/reporting/tracking.cjs.map +1 -0
  346. package/dist/reporting/tracking.d.cts +43 -0
  347. package/dist/reporting/tracking.d.cts.map +1 -0
  348. package/dist/reporting/tracking.d.mts +43 -0
  349. package/dist/reporting/tracking.d.mts.map +1 -0
  350. package/dist/reporting/tracking.mjs +151 -0
  351. package/dist/reporting/tracking.mjs.map +1 -0
  352. package/dist/runtime.cjs +19 -0
  353. package/dist/runtime.cjs.map +1 -0
  354. package/dist/runtime.d.cts +30 -0
  355. package/dist/runtime.d.cts.map +1 -0
  356. package/dist/runtime.d.mts +30 -0
  357. package/dist/runtime.d.mts.map +1 -0
  358. package/dist/runtime.mjs +18 -0
  359. package/dist/runtime.mjs.map +1 -0
  360. package/dist/store/d1.cjs +185 -0
  361. package/dist/store/d1.cjs.map +1 -0
  362. package/dist/store/d1.d.cts +55 -0
  363. package/dist/store/d1.d.cts.map +1 -0
  364. package/dist/store/d1.d.mts +55 -0
  365. package/dist/store/d1.d.mts.map +1 -0
  366. package/dist/store/d1.mjs +184 -0
  367. package/dist/store/d1.mjs.map +1 -0
  368. package/dist/store/facts.cjs +60 -0
  369. package/dist/store/facts.cjs.map +1 -0
  370. package/dist/store/facts.d.cts +38 -0
  371. package/dist/store/facts.d.cts.map +1 -0
  372. package/dist/store/facts.d.mts +38 -0
  373. package/dist/store/facts.d.mts.map +1 -0
  374. package/dist/store/facts.mjs +58 -0
  375. package/dist/store/facts.mjs.map +1 -0
  376. package/dist/store/index.cjs +31 -0
  377. package/dist/store/index.cjs.map +1 -0
  378. package/dist/store/index.d.cts +291 -0
  379. package/dist/store/index.d.cts.map +1 -0
  380. package/dist/store/index.d.mts +291 -0
  381. package/dist/store/index.d.mts.map +1 -0
  382. package/dist/store/index.mjs +22 -0
  383. package/dist/store/index.mjs.map +1 -0
  384. package/dist/store/postgres-reporting.cjs +213 -0
  385. package/dist/store/postgres-reporting.cjs.map +1 -0
  386. package/dist/store/postgres-reporting.d.cts +63 -0
  387. package/dist/store/postgres-reporting.d.cts.map +1 -0
  388. package/dist/store/postgres-reporting.d.mts +63 -0
  389. package/dist/store/postgres-reporting.d.mts.map +1 -0
  390. package/dist/store/postgres-reporting.mjs +212 -0
  391. package/dist/store/postgres-reporting.mjs.map +1 -0
  392. package/dist/store/postgres.cjs +309 -0
  393. package/dist/store/postgres.cjs.map +1 -0
  394. package/dist/store/postgres.d.cts +77 -0
  395. package/dist/store/postgres.d.cts.map +1 -0
  396. package/dist/store/postgres.d.mts +77 -0
  397. package/dist/store/postgres.d.mts.map +1 -0
  398. package/dist/store/postgres.mjs +306 -0
  399. package/dist/store/postgres.mjs.map +1 -0
  400. package/dist/store/sql.cjs +24 -0
  401. package/dist/store/sql.cjs.map +1 -0
  402. package/dist/store/sql.d.cts +25 -0
  403. package/dist/store/sql.d.cts.map +1 -0
  404. package/dist/store/sql.d.mts +25 -0
  405. package/dist/store/sql.d.mts.map +1 -0
  406. package/dist/store/sql.mjs +23 -0
  407. package/dist/store/sql.mjs.map +1 -0
  408. package/dist/store/tables.cjs +404 -0
  409. package/dist/store/tables.cjs.map +1 -0
  410. package/dist/store/tables.d.cts +81 -0
  411. package/dist/store/tables.d.cts.map +1 -0
  412. package/dist/store/tables.d.mts +81 -0
  413. package/dist/store/tables.d.mts.map +1 -0
  414. package/dist/store/tables.mjs +399 -0
  415. package/dist/store/tables.mjs.map +1 -0
  416. package/dist/templates.cjs +247 -0
  417. package/dist/templates.cjs.map +1 -0
  418. package/dist/templates.d.cts +187 -0
  419. package/dist/templates.d.cts.map +1 -0
  420. package/dist/templates.d.mts +187 -0
  421. package/dist/templates.d.mts.map +1 -0
  422. package/dist/templates.mjs +230 -0
  423. package/dist/templates.mjs.map +1 -0
  424. package/dist/webhooks.cjs +96 -0
  425. package/dist/webhooks.cjs.map +1 -0
  426. package/dist/webhooks.d.cts +25 -0
  427. package/dist/webhooks.d.cts.map +1 -0
  428. package/dist/webhooks.d.mts +25 -0
  429. package/dist/webhooks.d.mts.map +1 -0
  430. package/dist/webhooks.mjs +94 -0
  431. package/dist/webhooks.mjs.map +1 -0
  432. package/dist/webpush.cjs +180 -0
  433. package/dist/webpush.cjs.map +1 -0
  434. package/dist/webpush.d.cts +53 -0
  435. package/dist/webpush.d.cts.map +1 -0
  436. package/dist/webpush.d.mts +53 -0
  437. package/dist/webpush.d.mts.map +1 -0
  438. package/dist/webpush.mjs +175 -0
  439. package/dist/webpush.mjs.map +1 -0
  440. package/package.json +189 -3
  441. package/src/cloudflare/schema.sql +127 -0
  442. package/src/cloudflare/workers.d.ts +44 -0
@@ -0,0 +1,42 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_runtime = require("./_virtual/_rolldown/runtime.cjs");
3
+ const require_store_postgres = require("./store/postgres.cjs");
4
+ let postgres = require("postgres");
5
+ postgres = require_runtime.__toESM(postgres, 1);
6
+ //#region src/postgres-js.ts
7
+ /**
8
+ * `@shware/workflow/postgres-js` — the Postgres store over postgres.js
9
+ * (`postgres` is an optional peer dependency; import this subpath only when
10
+ * you use it). On Cloudflare the connection string is Hyperdrive's.
11
+ */
12
+ /** postgres.js → the store's minimal client. Inside `begin` every statement runs on the transaction client; the store never nests, so an inner `transaction` continues on the same one. */
13
+ function postgresJsClient(sql, inTransaction = false) {
14
+ return {
15
+ query: (text, params = []) => sql.unsafe(text, params),
16
+ transaction: (fn) => inTransaction ? fn(postgresJsClient(sql, true)) : sql.begin((tx) => fn(postgresJsClient(tx, true)))
17
+ };
18
+ }
19
+ /**
20
+ * Open a Postgres-backed store for one request or workflow run. The lease's
21
+ * `close` ends the client — a Worker cannot share a socket across requests,
22
+ * and Hyperdrive keeps the real pool next to the database.
23
+ */
24
+ function postgresJsStore(connectionString, options = {}) {
25
+ const { connection, ...storeOptions } = options;
26
+ const sql = (0, postgres.default)(connectionString, {
27
+ max: 1,
28
+ idle_timeout: 2,
29
+ fetch_types: false,
30
+ prepare: true,
31
+ ...connection
32
+ });
33
+ return {
34
+ store: new require_store_postgres.PostgresJourneyStore(postgresJsClient(sql), storeOptions),
35
+ close: () => sql.end({ timeout: 5 })
36
+ };
37
+ }
38
+ //#endregion
39
+ exports.postgresJsClient = postgresJsClient;
40
+ exports.postgresJsStore = postgresJsStore;
41
+
42
+ //# sourceMappingURL=postgres-js.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postgres-js.cjs","names":["PostgresJourneyStore"],"sources":["../src/postgres-js.ts"],"sourcesContent":["import postgres from 'postgres';\nimport type { StoreLease } from './store/index';\nimport {\n PostgresJourneyStore,\n type PostgresJourneyStoreOptions,\n type SqlClientLike,\n} from './store/postgres';\n\n/**\n * `@shware/workflow/postgres-js` — the Postgres store over postgres.js\n * (`postgres` is an optional peer dependency; import this subpath only when\n * you use it). On Cloudflare the connection string is Hyperdrive's.\n */\n\n/** postgres.js → the store's minimal client. Inside `begin` every statement runs on the transaction client; the store never nests, so an inner `transaction` continues on the same one. */\nexport function postgresJsClient(\n sql: postgres.Sql | postgres.TransactionSql,\n inTransaction = false\n): SqlClientLike {\n return {\n query: <T>(text: string, params: readonly unknown[] = []) =>\n sql.unsafe(text, params as never) as unknown as Promise<T[]>,\n transaction: <T>(fn: (tx: SqlClientLike) => Promise<T>) =>\n inTransaction\n ? fn(postgresJsClient(sql, true))\n : ((sql as postgres.Sql).begin((tx) => fn(postgresJsClient(tx, true))) as Promise<T>),\n };\n}\n\nexport interface PostgresJsStoreOptions extends PostgresJourneyStoreOptions {\n /**\n * postgres.js options. Defaults suit a Worker with Hyperdrive: one\n * connection per request/run, closed after 2 s idle, no type fetch on\n * connect, prepared statements (Hyperdrive caches them).\n */\n connection?: postgres.Options<Record<string, never>>;\n}\n\n/**\n * Open a Postgres-backed store for one request or workflow run. The lease's\n * `close` ends the client — a Worker cannot share a socket across requests,\n * and Hyperdrive keeps the real pool next to the database.\n */\nexport function postgresJsStore(\n connectionString: string,\n options: PostgresJsStoreOptions = {}\n): Required<StoreLease> {\n const { connection, ...storeOptions } = options;\n const sql = postgres(connectionString, {\n max: 1,\n // A journey run lives for days: between steps it sleeps or waits, and a run holding its\n // connection through that holds one per sleeping instance — hundreds of them exhaust the\n // database. Idle connections close and the next query opens a fresh one.\n idle_timeout: 2,\n fetch_types: false,\n prepare: true,\n ...connection,\n });\n return {\n store: new PostgresJourneyStore(postgresJsClient(sql), storeOptions),\n close: () => sql.end({ timeout: 5 }),\n };\n}\n"],"mappings":";;;;;;;;;;;;AAeA,SAAgB,iBACd,KACA,gBAAgB,OACD;CACf,OAAO;EACL,QAAW,MAAc,SAA6B,CAAC,MACrD,IAAI,OAAO,MAAM,MAAe;EAClC,cAAiB,OACf,gBACI,GAAG,iBAAiB,KAAK,IAAI,CAAC,IAC5B,IAAqB,OAAO,OAAO,GAAG,iBAAiB,IAAI,IAAI,CAAC,CAAC;CAC3E;AACF;;;;;;AAgBA,SAAgB,gBACd,kBACA,UAAkC,CAAC,GACb;CACtB,MAAM,EAAE,YAAY,GAAG,iBAAiB;CACxC,MAAM,OAAA,GAAM,SAAA,QAAA,CAAS,kBAAkB;EACrC,KAAK;EAIL,cAAc;EACd,aAAa;EACb,SAAS;EACT,GAAG;CACL,CAAC;CACD,OAAO;EACL,OAAO,IAAIA,uBAAAA,qBAAqB,iBAAiB,GAAG,GAAG,YAAY;EACnE,aAAa,IAAI,IAAI,EAAE,SAAS,EAAE,CAAC;CACrC;AACF"}
@@ -0,0 +1,28 @@
1
+ import { SqlClientLike } from "./store/sql.cjs";
2
+ import { PostgresJourneyStoreOptions } from "./store/postgres.cjs";
3
+ import { StoreLease } from "./store/index.cjs";
4
+ import postgres from "postgres";
5
+ //#region src/postgres-js.d.ts
6
+ /**
7
+ * `@shware/workflow/postgres-js` — the Postgres store over postgres.js
8
+ * (`postgres` is an optional peer dependency; import this subpath only when
9
+ * you use it). On Cloudflare the connection string is Hyperdrive's.
10
+ */
11
+ /** postgres.js → the store's minimal client. Inside `begin` every statement runs on the transaction client; the store never nests, so an inner `transaction` continues on the same one. */
12
+ export declare function postgresJsClient(sql: postgres.Sql | postgres.TransactionSql, inTransaction?: boolean): SqlClientLike;
13
+ export interface PostgresJsStoreOptions extends PostgresJourneyStoreOptions {
14
+ /**
15
+ * postgres.js options. Defaults suit a Worker with Hyperdrive: one
16
+ * connection per request/run, closed after 2 s idle, no type fetch on
17
+ * connect, prepared statements (Hyperdrive caches them).
18
+ */
19
+ connection?: postgres.Options<Record<string, never>>;
20
+ }
21
+ /**
22
+ * Open a Postgres-backed store for one request or workflow run. The lease's
23
+ * `close` ends the client — a Worker cannot share a socket across requests,
24
+ * and Hyperdrive keeps the real pool next to the database.
25
+ */
26
+ export declare function postgresJsStore(connectionString: string, options?: PostgresJsStoreOptions): Required<StoreLease>;
27
+ //#endregion
28
+ //# sourceMappingURL=postgres-js.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postgres-js.d.cts","names":[],"sources":["../src/postgres-js.ts"],"mappings":";;;;;;;;;;;wBAegB,iBACd,KAAK,SAAS,MAAM,SAAS,gBAC7B,0BACC;iBAWc,+BAA+B;;;;;;EAM9C,aAAa,SAAS,QAAQ;;;;;;;wBAQhB,gBACd,0BACA,UAAS,yBACR,SAAS"}
@@ -0,0 +1,28 @@
1
+ import { SqlClientLike } from "./store/sql.mjs";
2
+ import { PostgresJourneyStoreOptions } from "./store/postgres.mjs";
3
+ import { StoreLease } from "./store/index.mjs";
4
+ import postgres from "postgres";
5
+ //#region src/postgres-js.d.ts
6
+ /**
7
+ * `@shware/workflow/postgres-js` — the Postgres store over postgres.js
8
+ * (`postgres` is an optional peer dependency; import this subpath only when
9
+ * you use it). On Cloudflare the connection string is Hyperdrive's.
10
+ */
11
+ /** postgres.js → the store's minimal client. Inside `begin` every statement runs on the transaction client; the store never nests, so an inner `transaction` continues on the same one. */
12
+ export declare function postgresJsClient(sql: postgres.Sql | postgres.TransactionSql, inTransaction?: boolean): SqlClientLike;
13
+ export interface PostgresJsStoreOptions extends PostgresJourneyStoreOptions {
14
+ /**
15
+ * postgres.js options. Defaults suit a Worker with Hyperdrive: one
16
+ * connection per request/run, closed after 2 s idle, no type fetch on
17
+ * connect, prepared statements (Hyperdrive caches them).
18
+ */
19
+ connection?: postgres.Options<Record<string, never>>;
20
+ }
21
+ /**
22
+ * Open a Postgres-backed store for one request or workflow run. The lease's
23
+ * `close` ends the client — a Worker cannot share a socket across requests,
24
+ * and Hyperdrive keeps the real pool next to the database.
25
+ */
26
+ export declare function postgresJsStore(connectionString: string, options?: PostgresJsStoreOptions): Required<StoreLease>;
27
+ //#endregion
28
+ //# sourceMappingURL=postgres-js.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postgres-js.d.mts","names":[],"sources":["../src/postgres-js.ts"],"mappings":";;;;;;;;;;;wBAegB,iBACd,KAAK,SAAS,MAAM,SAAS,gBAC7B,0BACC;iBAWc,+BAA+B;;;;;;EAM9C,aAAa,SAAS,QAAQ;;;;;;;wBAQhB,gBACd,0BACA,UAAS,yBACR,SAAS"}
@@ -0,0 +1,38 @@
1
+ import { PostgresJourneyStore } from "./store/postgres.mjs";
2
+ import postgres from "postgres";
3
+ //#region src/postgres-js.ts
4
+ /**
5
+ * `@shware/workflow/postgres-js` — the Postgres store over postgres.js
6
+ * (`postgres` is an optional peer dependency; import this subpath only when
7
+ * you use it). On Cloudflare the connection string is Hyperdrive's.
8
+ */
9
+ /** postgres.js → the store's minimal client. Inside `begin` every statement runs on the transaction client; the store never nests, so an inner `transaction` continues on the same one. */
10
+ function postgresJsClient(sql, inTransaction = false) {
11
+ return {
12
+ query: (text, params = []) => sql.unsafe(text, params),
13
+ transaction: (fn) => inTransaction ? fn(postgresJsClient(sql, true)) : sql.begin((tx) => fn(postgresJsClient(tx, true)))
14
+ };
15
+ }
16
+ /**
17
+ * Open a Postgres-backed store for one request or workflow run. The lease's
18
+ * `close` ends the client — a Worker cannot share a socket across requests,
19
+ * and Hyperdrive keeps the real pool next to the database.
20
+ */
21
+ function postgresJsStore(connectionString, options = {}) {
22
+ const { connection, ...storeOptions } = options;
23
+ const sql = postgres(connectionString, {
24
+ max: 1,
25
+ idle_timeout: 2,
26
+ fetch_types: false,
27
+ prepare: true,
28
+ ...connection
29
+ });
30
+ return {
31
+ store: new PostgresJourneyStore(postgresJsClient(sql), storeOptions),
32
+ close: () => sql.end({ timeout: 5 })
33
+ };
34
+ }
35
+ //#endregion
36
+ export { postgresJsClient, postgresJsStore };
37
+
38
+ //# sourceMappingURL=postgres-js.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postgres-js.mjs","names":[],"sources":["../src/postgres-js.ts"],"sourcesContent":["import postgres from 'postgres';\nimport type { StoreLease } from './store/index';\nimport {\n PostgresJourneyStore,\n type PostgresJourneyStoreOptions,\n type SqlClientLike,\n} from './store/postgres';\n\n/**\n * `@shware/workflow/postgres-js` — the Postgres store over postgres.js\n * (`postgres` is an optional peer dependency; import this subpath only when\n * you use it). On Cloudflare the connection string is Hyperdrive's.\n */\n\n/** postgres.js → the store's minimal client. Inside `begin` every statement runs on the transaction client; the store never nests, so an inner `transaction` continues on the same one. */\nexport function postgresJsClient(\n sql: postgres.Sql | postgres.TransactionSql,\n inTransaction = false\n): SqlClientLike {\n return {\n query: <T>(text: string, params: readonly unknown[] = []) =>\n sql.unsafe(text, params as never) as unknown as Promise<T[]>,\n transaction: <T>(fn: (tx: SqlClientLike) => Promise<T>) =>\n inTransaction\n ? fn(postgresJsClient(sql, true))\n : ((sql as postgres.Sql).begin((tx) => fn(postgresJsClient(tx, true))) as Promise<T>),\n };\n}\n\nexport interface PostgresJsStoreOptions extends PostgresJourneyStoreOptions {\n /**\n * postgres.js options. Defaults suit a Worker with Hyperdrive: one\n * connection per request/run, closed after 2 s idle, no type fetch on\n * connect, prepared statements (Hyperdrive caches them).\n */\n connection?: postgres.Options<Record<string, never>>;\n}\n\n/**\n * Open a Postgres-backed store for one request or workflow run. The lease's\n * `close` ends the client — a Worker cannot share a socket across requests,\n * and Hyperdrive keeps the real pool next to the database.\n */\nexport function postgresJsStore(\n connectionString: string,\n options: PostgresJsStoreOptions = {}\n): Required<StoreLease> {\n const { connection, ...storeOptions } = options;\n const sql = postgres(connectionString, {\n max: 1,\n // A journey run lives for days: between steps it sleeps or waits, and a run holding its\n // connection through that holds one per sleeping instance — hundreds of them exhaust the\n // database. Idle connections close and the next query opens a fresh one.\n idle_timeout: 2,\n fetch_types: false,\n prepare: true,\n ...connection,\n });\n return {\n store: new PostgresJourneyStore(postgresJsClient(sql), storeOptions),\n close: () => sql.end({ timeout: 5 }),\n };\n}\n"],"mappings":";;;;;;;;;AAeA,SAAgB,iBACd,KACA,gBAAgB,OACD;CACf,OAAO;EACL,QAAW,MAAc,SAA6B,CAAC,MACrD,IAAI,OAAO,MAAM,MAAe;EAClC,cAAiB,OACf,gBACI,GAAG,iBAAiB,KAAK,IAAI,CAAC,IAC5B,IAAqB,OAAO,OAAO,GAAG,iBAAiB,IAAI,IAAI,CAAC,CAAC;CAC3E;AACF;;;;;;AAgBA,SAAgB,gBACd,kBACA,UAAkC,CAAC,GACb;CACtB,MAAM,EAAE,YAAY,GAAG,iBAAiB;CACxC,MAAM,MAAM,SAAS,kBAAkB;EACrC,KAAK;EAIL,cAAc;EACd,aAAa;EACb,SAAS;EACT,GAAG;CACL,CAAC;CACD,OAAO;EACL,OAAO,IAAI,qBAAqB,iBAAiB,GAAG,GAAG,YAAY;EACnE,aAAa,IAAI,IAAI,EAAE,SAAS,EAAE,CAAC;CACrC;AACF"}
@@ -0,0 +1,67 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#region src/provenance.ts
3
+ /**
4
+ * V8-style frame: `at fn (file:line:col)` / `at file:line:col`, where file may
5
+ * be an absolute path, a file:// URL (Node ESM) or an http(s) URL (Vite dev).
6
+ */
7
+ const FRAME = /at (?:.*? \()?(.+?):(\d+):(\d+)\)?$/;
8
+ /**
9
+ * Capture the source location of the call to `boundary` — pass the public
10
+ * builder method itself; everything at and below it is excluded from the stack.
11
+ */
12
+ function captureLoc(boundary) {
13
+ const capture = Error.captureStackTrace;
14
+ if (typeof capture !== "function") return void 0;
15
+ const holder = /* @__PURE__ */ new Error("provenance capture");
16
+ capture(holder, boundary);
17
+ const frame = holder.stack?.split("\n")[1];
18
+ const match = frame === void 0 ? null : FRAME.exec(frame);
19
+ if (!match) return void 0;
20
+ const [, rawFile, line, column] = match;
21
+ return {
22
+ file: normalizeFile(rawFile, globalThis.process?.cwd?.()),
23
+ line: Number(line),
24
+ column: Number(column)
25
+ };
26
+ }
27
+ /**
28
+ * file:// URLs become plain paths; paths under `cwd` become cwd-relative so the
29
+ * IR stays portable across machines and never leaks a home directory. Browser
30
+ * (Vite dev) URLs pass through untouched.
31
+ *
32
+ * Windows is where this used to give up. An ESM frame there reads
33
+ * 'file:///C:/Users/alice/proj/src/wf.ts' — a URL, with a slash in front of the
34
+ * drive letter — while process.cwd() reads 'C:\\Users\\alice\\proj'. Neither
35
+ * the separators nor that slash lined up, the prefix test failed, and the
36
+ * author's home directory shipped inside every deploy's IR.
37
+ *
38
+ * @internal exported for the tests: this is the compiler's only platform-aware
39
+ * line, and the platform it gets wrong is not the one the suite runs on.
40
+ */
41
+ function normalizeFile(rawFile, cwd) {
42
+ let file = rawFile;
43
+ if (file.startsWith("file://")) {
44
+ file = decodeURIComponent(file.slice(7));
45
+ if (/^\/[A-Za-z]:/.test(file)) file = file.slice(1);
46
+ }
47
+ file = toPosix(file);
48
+ if (cwd !== void 0) {
49
+ const root = toPosix(cwd);
50
+ if (file.startsWith(`${root}/`)) file = file.slice(root.length + 1);
51
+ }
52
+ return file;
53
+ }
54
+ /**
55
+ * One spelling per path so the two can be compared: '/' separators, and an
56
+ * upper-case drive letter — Windows reports the same drive in either case
57
+ * depending on who was asked (the loader's URL, an env var, the shell).
58
+ */
59
+ function toPosix(path) {
60
+ const slashed = path.replaceAll("\\", "/");
61
+ return /^[a-z]:/.test(slashed) ? slashed[0].toUpperCase() + slashed.slice(1) : slashed;
62
+ }
63
+ //#endregion
64
+ exports.captureLoc = captureLoc;
65
+ exports.normalizeFile = normalizeFile;
66
+
67
+ //# sourceMappingURL=provenance.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provenance.cjs","names":[],"sources":["../src/provenance.ts"],"sourcesContent":["import type { SourceLocIR } from './ir';\n\n/**\n * Provenance — where in source code a definition came from.\n *\n * Every builder call records its callsite into `meta.loc`. This is the\n * compiler's source map: the IR knows which file:line:column produced each\n * node, so the UI can jump from a canvas node to the editor, and a UI edit can\n * later be written back as an in-place patch of the exact literal that\n * produced the value. `meta` is excluded from contentHash (see hash.ts), so\n * provenance never affects execution identity, version pinning, or plan.\n *\n * Capture is best-effort by design: it relies on `Error.captureStackTrace`\n * (V8, JavaScriptCore 16.4+, SpiderMonkey 132+) to start the stack at the\n * caller of the public builder method — no frame-skipping heuristics over\n * bundled/unbundled layouts. Where the API or a parsable frame is missing,\n * `loc` is simply absent and every consumer degrades gracefully.\n */\n\ntype AnyFunction = (...args: never[]) => unknown;\n\n/**\n * V8-style frame: `at fn (file:line:col)` / `at file:line:col`, where file may\n * be an absolute path, a file:// URL (Node ESM) or an http(s) URL (Vite dev).\n */\nconst FRAME = /at (?:.*? \\()?(.+?):(\\d+):(\\d+)\\)?$/;\n\n/**\n * Capture the source location of the call to `boundary` — pass the public\n * builder method itself; everything at and below it is excluded from the stack.\n */\nexport function captureLoc(boundary: AnyFunction): SourceLocIR | undefined {\n // Read off the constructor untyped: the API is V8-first, and this module must\n // typecheck in DOM-less / Node-less environments (workerd, browsers) alike.\n const capture = (Error as { captureStackTrace?: (target: object, boundary: AnyFunction) => void })\n .captureStackTrace;\n if (typeof capture !== 'function') return undefined;\n\n const holder = new Error('provenance capture');\n capture(holder, boundary);\n // [0] is the message header; [1] is the first frame past the boundary — the callsite.\n const frame = holder.stack?.split('\\n')[1];\n const match = frame === undefined ? null : FRAME.exec(frame);\n if (!match) return undefined;\n\n const [, rawFile, line, column] = match;\n return {\n // globalThis lookup instead of a bare `process` reference: same portability\n // requirement as above — no Node types in workerd / browser consumers.\n file: normalizeFile(\n rawFile,\n (globalThis as { process?: { cwd?: () => string } }).process?.cwd?.()\n ),\n line: Number(line),\n column: Number(column),\n };\n}\n\n/**\n * file:// URLs become plain paths; paths under `cwd` become cwd-relative so the\n * IR stays portable across machines and never leaks a home directory. Browser\n * (Vite dev) URLs pass through untouched.\n *\n * Windows is where this used to give up. An ESM frame there reads\n * 'file:///C:/Users/alice/proj/src/wf.ts' — a URL, with a slash in front of the\n * drive letter — while process.cwd() reads 'C:\\\\Users\\\\alice\\\\proj'. Neither\n * the separators nor that slash lined up, the prefix test failed, and the\n * author's home directory shipped inside every deploy's IR.\n *\n * @internal exported for the tests: this is the compiler's only platform-aware\n * line, and the platform it gets wrong is not the one the suite runs on.\n */\nexport function normalizeFile(rawFile: string, cwd: string | undefined): string {\n let file = rawFile;\n if (file.startsWith('file://')) {\n file = decodeURIComponent(file.slice('file://'.length));\n // '/C:/…' is URL shape, not path shape\n if (/^\\/[A-Za-z]:/.test(file)) file = file.slice(1);\n }\n file = toPosix(file);\n if (cwd !== undefined) {\n const root = toPosix(cwd);\n if (file.startsWith(`${root}/`)) file = file.slice(root.length + 1);\n }\n return file;\n}\n\n/**\n * One spelling per path so the two can be compared: '/' separators, and an\n * upper-case drive letter — Windows reports the same drive in either case\n * depending on who was asked (the loader's URL, an env var, the shell).\n */\nfunction toPosix(path: string): string {\n const slashed = path.replaceAll('\\\\', '/');\n return /^[a-z]:/.test(slashed) ? slashed[0].toUpperCase() + slashed.slice(1) : slashed;\n}\n"],"mappings":";;;;;;AAyBA,MAAM,QAAQ;;;;;AAMd,SAAgB,WAAW,UAAgD;CAGzE,MAAM,UAAW,MACd;CACH,IAAI,OAAO,YAAY,YAAY,OAAO,KAAA;CAE1C,MAAM,yBAAS,IAAI,MAAM,oBAAoB;CAC7C,QAAQ,QAAQ,QAAQ;CAExB,MAAM,QAAQ,OAAO,OAAO,MAAM,IAAI,CAAC,CAAC;CACxC,MAAM,QAAQ,UAAU,KAAA,IAAY,OAAO,MAAM,KAAK,KAAK;CAC3D,IAAI,CAAC,OAAO,OAAO,KAAA;CAEnB,MAAM,GAAG,SAAS,MAAM,UAAU;CAClC,OAAO;EAGL,MAAM,cACJ,SACC,WAAoD,SAAS,MAAM,CACtE;EACA,MAAM,OAAO,IAAI;EACjB,QAAQ,OAAO,MAAM;CACvB;AACF;;;;;;;;;;;;;;;AAgBA,SAAgB,cAAc,SAAiB,KAAiC;CAC9E,IAAI,OAAO;CACX,IAAI,KAAK,WAAW,SAAS,GAAG;EAC9B,OAAO,mBAAmB,KAAK,MAAM,CAAgB,CAAC;EAEtD,IAAI,eAAe,KAAK,IAAI,GAAG,OAAO,KAAK,MAAM,CAAC;CACpD;CACA,OAAO,QAAQ,IAAI;CACnB,IAAI,QAAQ,KAAA,GAAW;EACrB,MAAM,OAAO,QAAQ,GAAG;EACxB,IAAI,KAAK,WAAW,GAAG,KAAK,EAAE,GAAG,OAAO,KAAK,MAAM,KAAK,SAAS,CAAC;CACpE;CACA,OAAO;AACT;;;;;;AAOA,SAAS,QAAQ,MAAsB;CACrC,MAAM,UAAU,KAAK,WAAW,MAAM,GAAG;CACzC,OAAO,UAAU,KAAK,OAAO,IAAI,QAAQ,EAAE,CAAC,YAAY,IAAI,QAAQ,MAAM,CAAC,IAAI;AACjF"}
@@ -0,0 +1,41 @@
1
+ import { SourceLocIR } from "./ir.cjs";
2
+ //#region src/provenance.d.ts
3
+ /**
4
+ * Provenance — where in source code a definition came from.
5
+ *
6
+ * Every builder call records its callsite into `meta.loc`. This is the
7
+ * compiler's source map: the IR knows which file:line:column produced each
8
+ * node, so the UI can jump from a canvas node to the editor, and a UI edit can
9
+ * later be written back as an in-place patch of the exact literal that
10
+ * produced the value. `meta` is excluded from contentHash (see hash.ts), so
11
+ * provenance never affects execution identity, version pinning, or plan.
12
+ *
13
+ * Capture is best-effort by design: it relies on `Error.captureStackTrace`
14
+ * (V8, JavaScriptCore 16.4+, SpiderMonkey 132+) to start the stack at the
15
+ * caller of the public builder method — no frame-skipping heuristics over
16
+ * bundled/unbundled layouts. Where the API or a parsable frame is missing,
17
+ * `loc` is simply absent and every consumer degrades gracefully.
18
+ */
19
+ type AnyFunction = (...args: never[]) => unknown;
20
+ /**
21
+ * Capture the source location of the call to `boundary` — pass the public
22
+ * builder method itself; everything at and below it is excluded from the stack.
23
+ */
24
+ export declare function captureLoc(boundary: AnyFunction): SourceLocIR | undefined;
25
+ /**
26
+ * file:// URLs become plain paths; paths under `cwd` become cwd-relative so the
27
+ * IR stays portable across machines and never leaks a home directory. Browser
28
+ * (Vite dev) URLs pass through untouched.
29
+ *
30
+ * Windows is where this used to give up. An ESM frame there reads
31
+ * 'file:///C:/Users/alice/proj/src/wf.ts' — a URL, with a slash in front of the
32
+ * drive letter — while process.cwd() reads 'C:\\Users\\alice\\proj'. Neither
33
+ * the separators nor that slash lined up, the prefix test failed, and the
34
+ * author's home directory shipped inside every deploy's IR.
35
+ *
36
+ * @internal exported for the tests: this is the compiler's only platform-aware
37
+ * line, and the platform it gets wrong is not the one the suite runs on.
38
+ */
39
+ export declare function normalizeFile(rawFile: string, cwd: string | undefined): string;
40
+ //#endregion
41
+ //# sourceMappingURL=provenance.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provenance.d.cts","names":[],"sources":["../src/provenance.ts"],"mappings":";;;;;;;;;;;;;;;;;;KAmBK,kBAAkB;;;;;wBAYP,WAAW,UAAU,cAAc;;;;;;;;;;;;;;;wBAyCnC,cAAc,iBAAiB"}
@@ -0,0 +1,41 @@
1
+ import { SourceLocIR } from "./ir.mjs";
2
+ //#region src/provenance.d.ts
3
+ /**
4
+ * Provenance — where in source code a definition came from.
5
+ *
6
+ * Every builder call records its callsite into `meta.loc`. This is the
7
+ * compiler's source map: the IR knows which file:line:column produced each
8
+ * node, so the UI can jump from a canvas node to the editor, and a UI edit can
9
+ * later be written back as an in-place patch of the exact literal that
10
+ * produced the value. `meta` is excluded from contentHash (see hash.ts), so
11
+ * provenance never affects execution identity, version pinning, or plan.
12
+ *
13
+ * Capture is best-effort by design: it relies on `Error.captureStackTrace`
14
+ * (V8, JavaScriptCore 16.4+, SpiderMonkey 132+) to start the stack at the
15
+ * caller of the public builder method — no frame-skipping heuristics over
16
+ * bundled/unbundled layouts. Where the API or a parsable frame is missing,
17
+ * `loc` is simply absent and every consumer degrades gracefully.
18
+ */
19
+ type AnyFunction = (...args: never[]) => unknown;
20
+ /**
21
+ * Capture the source location of the call to `boundary` — pass the public
22
+ * builder method itself; everything at and below it is excluded from the stack.
23
+ */
24
+ export declare function captureLoc(boundary: AnyFunction): SourceLocIR | undefined;
25
+ /**
26
+ * file:// URLs become plain paths; paths under `cwd` become cwd-relative so the
27
+ * IR stays portable across machines and never leaks a home directory. Browser
28
+ * (Vite dev) URLs pass through untouched.
29
+ *
30
+ * Windows is where this used to give up. An ESM frame there reads
31
+ * 'file:///C:/Users/alice/proj/src/wf.ts' — a URL, with a slash in front of the
32
+ * drive letter — while process.cwd() reads 'C:\\Users\\alice\\proj'. Neither
33
+ * the separators nor that slash lined up, the prefix test failed, and the
34
+ * author's home directory shipped inside every deploy's IR.
35
+ *
36
+ * @internal exported for the tests: this is the compiler's only platform-aware
37
+ * line, and the platform it gets wrong is not the one the suite runs on.
38
+ */
39
+ export declare function normalizeFile(rawFile: string, cwd: string | undefined): string;
40
+ //#endregion
41
+ //# sourceMappingURL=provenance.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provenance.d.mts","names":[],"sources":["../src/provenance.ts"],"mappings":";;;;;;;;;;;;;;;;;;KAmBK,kBAAkB;;;;;wBAYP,WAAW,UAAU,cAAc;;;;;;;;;;;;;;;wBAyCnC,cAAc,iBAAiB"}
@@ -0,0 +1,65 @@
1
+ //#region src/provenance.ts
2
+ /**
3
+ * V8-style frame: `at fn (file:line:col)` / `at file:line:col`, where file may
4
+ * be an absolute path, a file:// URL (Node ESM) or an http(s) URL (Vite dev).
5
+ */
6
+ const FRAME = /at (?:.*? \()?(.+?):(\d+):(\d+)\)?$/;
7
+ /**
8
+ * Capture the source location of the call to `boundary` — pass the public
9
+ * builder method itself; everything at and below it is excluded from the stack.
10
+ */
11
+ function captureLoc(boundary) {
12
+ const capture = Error.captureStackTrace;
13
+ if (typeof capture !== "function") return void 0;
14
+ const holder = /* @__PURE__ */ new Error("provenance capture");
15
+ capture(holder, boundary);
16
+ const frame = holder.stack?.split("\n")[1];
17
+ const match = frame === void 0 ? null : FRAME.exec(frame);
18
+ if (!match) return void 0;
19
+ const [, rawFile, line, column] = match;
20
+ return {
21
+ file: normalizeFile(rawFile, globalThis.process?.cwd?.()),
22
+ line: Number(line),
23
+ column: Number(column)
24
+ };
25
+ }
26
+ /**
27
+ * file:// URLs become plain paths; paths under `cwd` become cwd-relative so the
28
+ * IR stays portable across machines and never leaks a home directory. Browser
29
+ * (Vite dev) URLs pass through untouched.
30
+ *
31
+ * Windows is where this used to give up. An ESM frame there reads
32
+ * 'file:///C:/Users/alice/proj/src/wf.ts' — a URL, with a slash in front of the
33
+ * drive letter — while process.cwd() reads 'C:\\Users\\alice\\proj'. Neither
34
+ * the separators nor that slash lined up, the prefix test failed, and the
35
+ * author's home directory shipped inside every deploy's IR.
36
+ *
37
+ * @internal exported for the tests: this is the compiler's only platform-aware
38
+ * line, and the platform it gets wrong is not the one the suite runs on.
39
+ */
40
+ function normalizeFile(rawFile, cwd) {
41
+ let file = rawFile;
42
+ if (file.startsWith("file://")) {
43
+ file = decodeURIComponent(file.slice(7));
44
+ if (/^\/[A-Za-z]:/.test(file)) file = file.slice(1);
45
+ }
46
+ file = toPosix(file);
47
+ if (cwd !== void 0) {
48
+ const root = toPosix(cwd);
49
+ if (file.startsWith(`${root}/`)) file = file.slice(root.length + 1);
50
+ }
51
+ return file;
52
+ }
53
+ /**
54
+ * One spelling per path so the two can be compared: '/' separators, and an
55
+ * upper-case drive letter — Windows reports the same drive in either case
56
+ * depending on who was asked (the loader's URL, an env var, the shell).
57
+ */
58
+ function toPosix(path) {
59
+ const slashed = path.replaceAll("\\", "/");
60
+ return /^[a-z]:/.test(slashed) ? slashed[0].toUpperCase() + slashed.slice(1) : slashed;
61
+ }
62
+ //#endregion
63
+ export { captureLoc, normalizeFile };
64
+
65
+ //# sourceMappingURL=provenance.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provenance.mjs","names":[],"sources":["../src/provenance.ts"],"sourcesContent":["import type { SourceLocIR } from './ir';\n\n/**\n * Provenance — where in source code a definition came from.\n *\n * Every builder call records its callsite into `meta.loc`. This is the\n * compiler's source map: the IR knows which file:line:column produced each\n * node, so the UI can jump from a canvas node to the editor, and a UI edit can\n * later be written back as an in-place patch of the exact literal that\n * produced the value. `meta` is excluded from contentHash (see hash.ts), so\n * provenance never affects execution identity, version pinning, or plan.\n *\n * Capture is best-effort by design: it relies on `Error.captureStackTrace`\n * (V8, JavaScriptCore 16.4+, SpiderMonkey 132+) to start the stack at the\n * caller of the public builder method — no frame-skipping heuristics over\n * bundled/unbundled layouts. Where the API or a parsable frame is missing,\n * `loc` is simply absent and every consumer degrades gracefully.\n */\n\ntype AnyFunction = (...args: never[]) => unknown;\n\n/**\n * V8-style frame: `at fn (file:line:col)` / `at file:line:col`, where file may\n * be an absolute path, a file:// URL (Node ESM) or an http(s) URL (Vite dev).\n */\nconst FRAME = /at (?:.*? \\()?(.+?):(\\d+):(\\d+)\\)?$/;\n\n/**\n * Capture the source location of the call to `boundary` — pass the public\n * builder method itself; everything at and below it is excluded from the stack.\n */\nexport function captureLoc(boundary: AnyFunction): SourceLocIR | undefined {\n // Read off the constructor untyped: the API is V8-first, and this module must\n // typecheck in DOM-less / Node-less environments (workerd, browsers) alike.\n const capture = (Error as { captureStackTrace?: (target: object, boundary: AnyFunction) => void })\n .captureStackTrace;\n if (typeof capture !== 'function') return undefined;\n\n const holder = new Error('provenance capture');\n capture(holder, boundary);\n // [0] is the message header; [1] is the first frame past the boundary — the callsite.\n const frame = holder.stack?.split('\\n')[1];\n const match = frame === undefined ? null : FRAME.exec(frame);\n if (!match) return undefined;\n\n const [, rawFile, line, column] = match;\n return {\n // globalThis lookup instead of a bare `process` reference: same portability\n // requirement as above — no Node types in workerd / browser consumers.\n file: normalizeFile(\n rawFile,\n (globalThis as { process?: { cwd?: () => string } }).process?.cwd?.()\n ),\n line: Number(line),\n column: Number(column),\n };\n}\n\n/**\n * file:// URLs become plain paths; paths under `cwd` become cwd-relative so the\n * IR stays portable across machines and never leaks a home directory. Browser\n * (Vite dev) URLs pass through untouched.\n *\n * Windows is where this used to give up. An ESM frame there reads\n * 'file:///C:/Users/alice/proj/src/wf.ts' — a URL, with a slash in front of the\n * drive letter — while process.cwd() reads 'C:\\\\Users\\\\alice\\\\proj'. Neither\n * the separators nor that slash lined up, the prefix test failed, and the\n * author's home directory shipped inside every deploy's IR.\n *\n * @internal exported for the tests: this is the compiler's only platform-aware\n * line, and the platform it gets wrong is not the one the suite runs on.\n */\nexport function normalizeFile(rawFile: string, cwd: string | undefined): string {\n let file = rawFile;\n if (file.startsWith('file://')) {\n file = decodeURIComponent(file.slice('file://'.length));\n // '/C:/…' is URL shape, not path shape\n if (/^\\/[A-Za-z]:/.test(file)) file = file.slice(1);\n }\n file = toPosix(file);\n if (cwd !== undefined) {\n const root = toPosix(cwd);\n if (file.startsWith(`${root}/`)) file = file.slice(root.length + 1);\n }\n return file;\n}\n\n/**\n * One spelling per path so the two can be compared: '/' separators, and an\n * upper-case drive letter — Windows reports the same drive in either case\n * depending on who was asked (the loader's URL, an env var, the shell).\n */\nfunction toPosix(path: string): string {\n const slashed = path.replaceAll('\\\\', '/');\n return /^[a-z]:/.test(slashed) ? slashed[0].toUpperCase() + slashed.slice(1) : slashed;\n}\n"],"mappings":";;;;;AAyBA,MAAM,QAAQ;;;;;AAMd,SAAgB,WAAW,UAAgD;CAGzE,MAAM,UAAW,MACd;CACH,IAAI,OAAO,YAAY,YAAY,OAAO,KAAA;CAE1C,MAAM,yBAAS,IAAI,MAAM,oBAAoB;CAC7C,QAAQ,QAAQ,QAAQ;CAExB,MAAM,QAAQ,OAAO,OAAO,MAAM,IAAI,CAAC,CAAC;CACxC,MAAM,QAAQ,UAAU,KAAA,IAAY,OAAO,MAAM,KAAK,KAAK;CAC3D,IAAI,CAAC,OAAO,OAAO,KAAA;CAEnB,MAAM,GAAG,SAAS,MAAM,UAAU;CAClC,OAAO;EAGL,MAAM,cACJ,SACC,WAAoD,SAAS,MAAM,CACtE;EACA,MAAM,OAAO,IAAI;EACjB,QAAQ,OAAO,MAAM;CACvB;AACF;;;;;;;;;;;;;;;AAgBA,SAAgB,cAAc,SAAiB,KAAiC;CAC9E,IAAI,OAAO;CACX,IAAI,KAAK,WAAW,SAAS,GAAG;EAC9B,OAAO,mBAAmB,KAAK,MAAM,CAAgB,CAAC;EAEtD,IAAI,eAAe,KAAK,IAAI,GAAG,OAAO,KAAK,MAAM,CAAC;CACpD;CACA,OAAO,QAAQ,IAAI;CACnB,IAAI,QAAQ,KAAA,GAAW;EACrB,MAAM,OAAO,QAAQ,GAAG;EACxB,IAAI,KAAK,WAAW,GAAG,KAAK,EAAE,GAAG,OAAO,KAAK,MAAM,KAAK,SAAS,CAAC;CACpE;CACA,OAAO;AACT;;;;;;AAOA,SAAS,QAAQ,MAAsB;CACrC,MAAM,UAAU,KAAK,WAAW,MAAM,GAAG;CACzC,OAAO,UAAU,KAAK,OAAO,IAAI,QAAQ,EAAE,CAAC,YAAY,IAAI,QAAQ,MAAM,CAAC,IAAI;AACjF"}
package/dist/push.cjs ADDED
@@ -0,0 +1,14 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_templates = require("./templates.cjs");
3
+ //#region src/push.ts
4
+ /** A renderer over the registry; a TemplateValidationError means nothing may be sent. */
5
+ function registryPushRenderer(pushes) {
6
+ return async (key, props) => {
7
+ if (!Object.hasOwn(pushes, key)) throw new Error(`unknown push template: ${key}`);
8
+ return require_templates.renderPushContent(pushes[key], key, props);
9
+ };
10
+ }
11
+ //#endregion
12
+ exports.registryPushRenderer = registryPushRenderer;
13
+
14
+ //# sourceMappingURL=push.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"push.cjs","names":["renderPushContent"],"sources":["../src/push.ts"],"sourcesContent":["import type { ScalarIR } from './ir';\nimport { type PushContent, type PushTemplate, renderPushContent } from './templates';\n\n/**\n * `@shware/workflow/push` — push-notification content. A push is data, not a\n * component: a title and a body the OS renders in its own chrome, built by a\n * `pushTemplate`'s `content(parsedProps)` — final text, never placeholder-\n * expanded, so braces in user data survive. Transport is a separate concern\n * (`@shware/workflow/apns`, `@shware/workflow/fcm`).\n */\n\nexport type RenderedPush = PushContent;\n\nexport type PushRenderer = (\n template: string,\n props: Record<string, ScalarIR | undefined>\n) => Promise<RenderedPush>;\n\n/** A renderer over the registry; a TemplateValidationError means nothing may be sent. */\nexport function registryPushRenderer(pushes: Record<string, PushTemplate>): PushRenderer {\n return async (key, props) => {\n if (!Object.hasOwn(pushes, key)) throw new Error(`unknown push template: ${key}`);\n return renderPushContent(pushes[key], key, props);\n };\n}\n"],"mappings":";;;;AAmBA,SAAgB,qBAAqB,QAAoD;CACvF,OAAO,OAAO,KAAK,UAAU;EAC3B,IAAI,CAAC,OAAO,OAAO,QAAQ,GAAG,GAAG,MAAM,IAAI,MAAM,0BAA0B,KAAK;EAChF,OAAOA,kBAAAA,kBAAkB,OAAO,MAAM,KAAK,KAAK;CAClD;AACF"}
@@ -0,0 +1,16 @@
1
+ import { ScalarIR } from "./ir.cjs";
2
+ import { PushContent, PushTemplate } from "./templates.cjs";
3
+ //#region src/push.d.ts
4
+ /**
5
+ * `@shware/workflow/push` — push-notification content. A push is data, not a
6
+ * component: a title and a body the OS renders in its own chrome, built by a
7
+ * `pushTemplate`'s `content(parsedProps)` — final text, never placeholder-
8
+ * expanded, so braces in user data survive. Transport is a separate concern
9
+ * (`@shware/workflow/apns`, `@shware/workflow/fcm`).
10
+ */
11
+ export type RenderedPush = PushContent;
12
+ export type PushRenderer = (template: string, props: Record<string, ScalarIR | undefined>) => Promise<RenderedPush>;
13
+ /** A renderer over the registry; a TemplateValidationError means nothing may be sent. */
14
+ export declare function registryPushRenderer(pushes: Record<string, PushTemplate>): PushRenderer;
15
+ //#endregion
16
+ //# sourceMappingURL=push.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"push.d.cts","names":[],"sources":["../src/push.ts"],"mappings":";;;;;;;;;;YAWY,eAAe;YAEf,gBACV,kBACA,OAAO,eAAe,0BACnB,QAAQ;;wBAGG,qBAAqB,QAAQ,eAAe,gBAAgB"}
@@ -0,0 +1,16 @@
1
+ import { ScalarIR } from "./ir.mjs";
2
+ import { PushContent, PushTemplate } from "./templates.mjs";
3
+ //#region src/push.d.ts
4
+ /**
5
+ * `@shware/workflow/push` — push-notification content. A push is data, not a
6
+ * component: a title and a body the OS renders in its own chrome, built by a
7
+ * `pushTemplate`'s `content(parsedProps)` — final text, never placeholder-
8
+ * expanded, so braces in user data survive. Transport is a separate concern
9
+ * (`@shware/workflow/apns`, `@shware/workflow/fcm`).
10
+ */
11
+ export type RenderedPush = PushContent;
12
+ export type PushRenderer = (template: string, props: Record<string, ScalarIR | undefined>) => Promise<RenderedPush>;
13
+ /** A renderer over the registry; a TemplateValidationError means nothing may be sent. */
14
+ export declare function registryPushRenderer(pushes: Record<string, PushTemplate>): PushRenderer;
15
+ //#endregion
16
+ //# sourceMappingURL=push.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"push.d.mts","names":[],"sources":["../src/push.ts"],"mappings":";;;;;;;;;;YAWY,eAAe;YAEf,gBACV,kBACA,OAAO,eAAe,0BACnB,QAAQ;;wBAGG,qBAAqB,QAAQ,eAAe,gBAAgB"}
package/dist/push.mjs ADDED
@@ -0,0 +1,13 @@
1
+ import { renderPushContent } from "./templates.mjs";
2
+ //#region src/push.ts
3
+ /** A renderer over the registry; a TemplateValidationError means nothing may be sent. */
4
+ function registryPushRenderer(pushes) {
5
+ return async (key, props) => {
6
+ if (!Object.hasOwn(pushes, key)) throw new Error(`unknown push template: ${key}`);
7
+ return renderPushContent(pushes[key], key, props);
8
+ };
9
+ }
10
+ //#endregion
11
+ export { registryPushRenderer };
12
+
13
+ //# sourceMappingURL=push.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"push.mjs","names":[],"sources":["../src/push.ts"],"sourcesContent":["import type { ScalarIR } from './ir';\nimport { type PushContent, type PushTemplate, renderPushContent } from './templates';\n\n/**\n * `@shware/workflow/push` — push-notification content. A push is data, not a\n * component: a title and a body the OS renders in its own chrome, built by a\n * `pushTemplate`'s `content(parsedProps)` — final text, never placeholder-\n * expanded, so braces in user data survive. Transport is a separate concern\n * (`@shware/workflow/apns`, `@shware/workflow/fcm`).\n */\n\nexport type RenderedPush = PushContent;\n\nexport type PushRenderer = (\n template: string,\n props: Record<string, ScalarIR | undefined>\n) => Promise<RenderedPush>;\n\n/** A renderer over the registry; a TemplateValidationError means nothing may be sent. */\nexport function registryPushRenderer(pushes: Record<string, PushTemplate>): PushRenderer {\n return async (key, props) => {\n if (!Object.hasOwn(pushes, key)) throw new Error(`unknown push template: ${key}`);\n return renderPushContent(pushes[key], key, props);\n };\n}\n"],"mappings":";;;AAmBA,SAAgB,qBAAqB,QAAoD;CACvF,OAAO,OAAO,KAAK,UAAU;EAC3B,IAAI,CAAC,OAAO,OAAO,QAAQ,GAAG,GAAG,MAAM,IAAI,MAAM,0BAA0B,KAAK;EAChF,OAAO,kBAAkB,OAAO,MAAM,KAAK,KAAK;CAClD;AACF"}
@@ -0,0 +1,48 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_templates = require("./templates.cjs");
3
+ let react = require("react");
4
+ let react_dom_server = require("react-dom/server");
5
+ //#region src/react-email.ts
6
+ /**
7
+ * `@shware/workflow/react-email` — an EmailRenderer over the project's email
8
+ * registry (`react-dom` is an optional peer dependency; import this subpath
9
+ * only when you use it).
10
+ *
11
+ * The registry maps keys to `emailTemplate({...})` definitions. Props are
12
+ * parsed against the template's schema before the component renders — a
13
+ * failure throws TemplateValidationError and nothing renders — and the
14
+ * component renders as an element, so hooks and context work. Rendering
15
+ * streams and waits for every Suspense boundary (`allReady`) — react-email's
16
+ * `<Tailwind>` suspends while it compiles the classes, which synchronous
17
+ * static markup cannot wait for — then prepends the XHTML doctype react-email
18
+ * uses. @react-email/render itself is avoided because its Workers build
19
+ * statically imports prettier and html-to-text for options never used here.
20
+ */
21
+ const DOCTYPE = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">";
22
+ function registryRenderer(emails) {
23
+ return async (key, props) => {
24
+ if (!Object.hasOwn(emails, key)) throw new Error(`unknown email template: ${key}`);
25
+ const template = emails[key];
26
+ const parsed = require_templates.parseTemplateProps(template, key, props);
27
+ const element = (0, react.createElement)(template.component, parsed);
28
+ return {
29
+ subject: template.subject,
30
+ html: DOCTYPE + await renderToHtml(element)
31
+ };
32
+ };
33
+ }
34
+ /** Render to a string once every Suspense boundary has resolved; a rendering error rejects. */
35
+ async function renderToHtml(element) {
36
+ let failure;
37
+ const stream = await (0, react_dom_server.renderToReadableStream)(element, { onError: (error) => {
38
+ failure = error;
39
+ } });
40
+ await stream.allReady;
41
+ const html = await new Response(stream).text();
42
+ if (failure !== void 0) throw failure instanceof Error ? failure : new Error("email render failed", { cause: failure });
43
+ return html.replace(/^<!DOCTYPE html>/i, "").replace(/<link rel="preload" as="image"[^>]*\/>/g, "");
44
+ }
45
+ //#endregion
46
+ exports.registryRenderer = registryRenderer;
47
+
48
+ //# sourceMappingURL=react-email.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"react-email.cjs","names":["parseTemplateProps","createElement","renderToReadableStream"],"sources":["../src/react-email.ts"],"sourcesContent":["import { type ComponentType, type ReactElement, createElement } from 'react';\nimport { renderToReadableStream } from 'react-dom/server';\nimport type { EmailRenderer } from './cloudflare';\nimport { type EmailTemplate, parseTemplateProps } from './templates';\n\n/**\n * `@shware/workflow/react-email` — an EmailRenderer over the project's email\n * registry (`react-dom` is an optional peer dependency; import this subpath\n * only when you use it).\n *\n * The registry maps keys to `emailTemplate({...})` definitions. Props are\n * parsed against the template's schema before the component renders — a\n * failure throws TemplateValidationError and nothing renders — and the\n * component renders as an element, so hooks and context work. Rendering\n * streams and waits for every Suspense boundary (`allReady`) — react-email's\n * `<Tailwind>` suspends while it compiles the classes, which synchronous\n * static markup cannot wait for — then prepends the XHTML doctype react-email\n * uses. @react-email/render itself is avoided because its Workers build\n * statically imports prettier and html-to-text for options never used here.\n */\n\nconst DOCTYPE =\n '<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">';\n\nexport function registryRenderer(emails: Record<string, EmailTemplate>): EmailRenderer {\n return async (key, props) => {\n if (!Object.hasOwn(emails, key)) throw new Error(`unknown email template: ${key}`);\n const template = emails[key];\n const parsed = parseTemplateProps(template, key, props);\n const element = createElement(template.component as ComponentType<object>, parsed);\n return { subject: template.subject, html: DOCTYPE + (await renderToHtml(element)) };\n };\n}\n\n/** Render to a string once every Suspense boundary has resolved; a rendering error rejects. */\nasync function renderToHtml(element: ReactElement): Promise<string> {\n let failure: unknown;\n const stream = await renderToReadableStream(element, {\n onError: (error) => {\n failure = error;\n },\n });\n await stream.allReady;\n const html = await new Response(stream).text();\n if (failure !== undefined) {\n throw failure instanceof Error ? failure : new Error('email render failed', { cause: failure });\n }\n // Streaming a document adds what static markup did not: an HTML5 doctype (the caller prepends\n // the XHTML one email clients expect) and React 19's image preload hints, which mean nothing in\n // an email. Both are dropped, as @react-email/render does.\n return html\n .replace(/^<!DOCTYPE html>/i, '')\n .replace(/<link rel=\"preload\" as=\"image\"[^>]*\\/>/g, '');\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAqBA,MAAM,UACJ;AAEF,SAAgB,iBAAiB,QAAsD;CACrF,OAAO,OAAO,KAAK,UAAU;EAC3B,IAAI,CAAC,OAAO,OAAO,QAAQ,GAAG,GAAG,MAAM,IAAI,MAAM,2BAA2B,KAAK;EACjF,MAAM,WAAW,OAAO;EACxB,MAAM,SAASA,kBAAAA,mBAAmB,UAAU,KAAK,KAAK;EACtD,MAAM,WAAA,GAAUC,MAAAA,cAAAA,CAAc,SAAS,WAAoC,MAAM;EACjF,OAAO;GAAE,SAAS,SAAS;GAAS,MAAM,UAAW,MAAM,aAAa,OAAO;EAAG;CACpF;AACF;;AAGA,eAAe,aAAa,SAAwC;CAClE,IAAI;CACJ,MAAM,SAAS,OAAA,GAAMC,iBAAAA,uBAAAA,CAAuB,SAAS,EACnD,UAAU,UAAU;EAClB,UAAU;CACZ,EACF,CAAC;CACD,MAAM,OAAO;CACb,MAAM,OAAO,MAAM,IAAI,SAAS,MAAM,CAAC,CAAC,KAAK;CAC7C,IAAI,YAAY,KAAA,GACd,MAAM,mBAAmB,QAAQ,UAAU,IAAI,MAAM,uBAAuB,EAAE,OAAO,QAAQ,CAAC;CAKhG,OAAO,KACJ,QAAQ,qBAAqB,EAAE,CAAC,CAChC,QAAQ,2CAA2C,EAAE;AAC1D"}
@@ -0,0 +1,7 @@
1
+ import { EmailTemplate } from "./templates.cjs";
2
+ import { EmailRenderer } from "./cloudflare/senders.cjs";
3
+ import "./cloudflare/index.cjs";
4
+ //#region src/react-email.d.ts
5
+ export declare function registryRenderer(emails: Record<string, EmailTemplate>): EmailRenderer;
6
+ //#endregion
7
+ //# sourceMappingURL=react-email.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"react-email.d.cts","names":[],"sources":["../src/react-email.ts"],"mappings":";;;;wBAwBgB,iBAAiB,QAAQ,eAAe,iBAAiB"}
@@ -0,0 +1,7 @@
1
+ import { EmailTemplate } from "./templates.mjs";
2
+ import { EmailRenderer } from "./cloudflare/senders.mjs";
3
+ import "./cloudflare/index.mjs";
4
+ //#region src/react-email.d.ts
5
+ export declare function registryRenderer(emails: Record<string, EmailTemplate>): EmailRenderer;
6
+ //#endregion
7
+ //# sourceMappingURL=react-email.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"react-email.d.mts","names":[],"sources":["../src/react-email.ts"],"mappings":";;;;wBAwBgB,iBAAiB,QAAQ,eAAe,iBAAiB"}