@craft-ts/core 0.7.0-beta.13

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 (682) hide show
  1. package/LICENSE +21 -0
  2. package/package.json +58 -0
  3. package/src/index.d.ts +148 -0
  4. package/src/index.d.ts.map +1 -0
  5. package/src/index.js +150 -0
  6. package/src/index.js.map +1 -0
  7. package/src/lib/after-recomputation.d.ts +327 -0
  8. package/src/lib/after-recomputation.d.ts.map +1 -0
  9. package/src/lib/after-recomputation.js +25 -0
  10. package/src/lib/after-recomputation.js.map +1 -0
  11. package/src/lib/app-checked-di.d.ts +82 -0
  12. package/src/lib/app-checked-di.d.ts.map +1 -0
  13. package/src/lib/app-checked-di.js +1 -0
  14. package/src/lib/app-checked-di.js.map +1 -0
  15. package/src/lib/async-process.d.ts +411 -0
  16. package/src/lib/async-process.d.ts.map +1 -0
  17. package/src/lib/async-process.js +702 -0
  18. package/src/lib/async-process.js.map +1 -0
  19. package/src/lib/branded-component/branded-component.d.ts +129 -0
  20. package/src/lib/branded-component/branded-component.d.ts.map +1 -0
  21. package/src/lib/branded-component/branded-component.js +7 -0
  22. package/src/lib/branded-component/branded-component.js.map +1 -0
  23. package/src/lib/browser-boundaries.d.ts +165 -0
  24. package/src/lib/browser-boundaries.d.ts.map +1 -0
  25. package/src/lib/browser-boundaries.js +550 -0
  26. package/src/lib/browser-boundaries.js.map +1 -0
  27. package/src/lib/client-di-requirement.d.ts +28 -0
  28. package/src/lib/client-di-requirement.d.ts.map +1 -0
  29. package/src/lib/client-di-requirement.js +11 -0
  30. package/src/lib/client-di-requirement.js.map +1 -0
  31. package/src/lib/client-function-middleware.d.ts +130 -0
  32. package/src/lib/client-function-middleware.d.ts.map +1 -0
  33. package/src/lib/client-function-middleware.js +144 -0
  34. package/src/lib/client-function-middleware.js.map +1 -0
  35. package/src/lib/component-monitoring.d.ts +7 -0
  36. package/src/lib/component-monitoring.d.ts.map +1 -0
  37. package/src/lib/component-monitoring.js +28 -0
  38. package/src/lib/component-monitoring.js.map +1 -0
  39. package/src/lib/component-register.d.ts +12 -0
  40. package/src/lib/component-register.d.ts.map +1 -0
  41. package/src/lib/component-register.js +13 -0
  42. package/src/lib/component-register.js.map +1 -0
  43. package/src/lib/computed-source.d.ts +303 -0
  44. package/src/lib/computed-source.d.ts.map +1 -0
  45. package/src/lib/computed-source.js +319 -0
  46. package/src/lib/computed-source.js.map +1 -0
  47. package/src/lib/correlation-id-plugin.d.ts +3 -0
  48. package/src/lib/correlation-id-plugin.d.ts.map +1 -0
  49. package/src/lib/correlation-id-plugin.js +73 -0
  50. package/src/lib/correlation-id-plugin.js.map +1 -0
  51. package/src/lib/correlation-id.d.ts +30 -0
  52. package/src/lib/correlation-id.d.ts.map +1 -0
  53. package/src/lib/correlation-id.js +86 -0
  54. package/src/lib/correlation-id.js.map +1 -0
  55. package/src/lib/craft-a11y.d.ts +22 -0
  56. package/src/lib/craft-a11y.d.ts.map +1 -0
  57. package/src/lib/craft-a11y.js +32 -0
  58. package/src/lib/craft-a11y.js.map +1 -0
  59. package/src/lib/craft-activated-route.d.ts +21 -0
  60. package/src/lib/craft-activated-route.d.ts.map +1 -0
  61. package/src/lib/craft-activated-route.js +20 -0
  62. package/src/lib/craft-activated-route.js.map +1 -0
  63. package/src/lib/craft-app-config.d.ts +91 -0
  64. package/src/lib/craft-app-config.d.ts.map +1 -0
  65. package/src/lib/craft-app-config.js +64 -0
  66. package/src/lib/craft-app-config.js.map +1 -0
  67. package/src/lib/craft-codec.d.ts +16 -0
  68. package/src/lib/craft-codec.d.ts.map +1 -0
  69. package/src/lib/craft-codec.js +1 -0
  70. package/src/lib/craft-codec.js.map +1 -0
  71. package/src/lib/craft-computed.d.ts +31 -0
  72. package/src/lib/craft-computed.d.ts.map +1 -0
  73. package/src/lib/craft-computed.js +81 -0
  74. package/src/lib/craft-computed.js.map +1 -0
  75. package/src/lib/craft-control-flow.d.ts +14 -0
  76. package/src/lib/craft-control-flow.d.ts.map +1 -0
  77. package/src/lib/craft-control-flow.js +18 -0
  78. package/src/lib/craft-control-flow.js.map +1 -0
  79. package/src/lib/craft-effect.d.ts +13 -0
  80. package/src/lib/craft-effect.d.ts.map +1 -0
  81. package/src/lib/craft-effect.js +93 -0
  82. package/src/lib/craft-effect.js.map +1 -0
  83. package/src/lib/craft-exception.d.ts +40 -0
  84. package/src/lib/craft-exception.d.ts.map +1 -0
  85. package/src/lib/craft-exception.js +16 -0
  86. package/src/lib/craft-exception.js.map +1 -0
  87. package/src/lib/craft-gen.d.ts +123 -0
  88. package/src/lib/craft-gen.d.ts.map +1 -0
  89. package/src/lib/craft-gen.js +90 -0
  90. package/src/lib/craft-gen.js.map +1 -0
  91. package/src/lib/craft-generator-runtime.d.ts +110 -0
  92. package/src/lib/craft-generator-runtime.d.ts.map +1 -0
  93. package/src/lib/craft-generator-runtime.js +191 -0
  94. package/src/lib/craft-generator-runtime.js.map +1 -0
  95. package/src/lib/craft-guard-runtime.d.ts +70 -0
  96. package/src/lib/craft-guard-runtime.d.ts.map +1 -0
  97. package/src/lib/craft-guard-runtime.js +195 -0
  98. package/src/lib/craft-guard-runtime.js.map +1 -0
  99. package/src/lib/craft-handshake.d.ts +35 -0
  100. package/src/lib/craft-handshake.d.ts.map +1 -0
  101. package/src/lib/craft-handshake.js +34 -0
  102. package/src/lib/craft-handshake.js.map +1 -0
  103. package/src/lib/craft-http-client.d.ts +236 -0
  104. package/src/lib/craft-http-client.d.ts.map +1 -0
  105. package/src/lib/craft-http-client.js +437 -0
  106. package/src/lib/craft-http-client.js.map +1 -0
  107. package/src/lib/craft-http-trace.d.ts +12 -0
  108. package/src/lib/craft-http-trace.d.ts.map +1 -0
  109. package/src/lib/craft-http-trace.js +28 -0
  110. package/src/lib/craft-http-trace.js.map +1 -0
  111. package/src/lib/craft-lazy.d.ts +42 -0
  112. package/src/lib/craft-lazy.d.ts.map +1 -0
  113. package/src/lib/craft-lazy.js +83 -0
  114. package/src/lib/craft-lazy.js.map +1 -0
  115. package/src/lib/craft-load-retry.d.ts +76 -0
  116. package/src/lib/craft-load-retry.d.ts.map +1 -0
  117. package/src/lib/craft-load-retry.js +160 -0
  118. package/src/lib/craft-load-retry.js.map +1 -0
  119. package/src/lib/craft-machine-history.d.ts +145 -0
  120. package/src/lib/craft-machine-history.d.ts.map +1 -0
  121. package/src/lib/craft-machine-history.js +276 -0
  122. package/src/lib/craft-machine-history.js.map +1 -0
  123. package/src/lib/craft-match.d.ts +49 -0
  124. package/src/lib/craft-match.d.ts.map +1 -0
  125. package/src/lib/craft-match.js +58 -0
  126. package/src/lib/craft-match.js.map +1 -0
  127. package/src/lib/craft-method.d.ts +28 -0
  128. package/src/lib/craft-method.d.ts.map +1 -0
  129. package/src/lib/craft-method.js +45 -0
  130. package/src/lib/craft-method.js.map +1 -0
  131. package/src/lib/craft-node-directive.d.ts +32 -0
  132. package/src/lib/craft-node-directive.d.ts.map +1 -0
  133. package/src/lib/craft-node-directive.js +22 -0
  134. package/src/lib/craft-node-directive.js.map +1 -0
  135. package/src/lib/craft-pending.d.ts +115 -0
  136. package/src/lib/craft-pending.d.ts.map +1 -0
  137. package/src/lib/craft-pending.js +187 -0
  138. package/src/lib/craft-pending.js.map +1 -0
  139. package/src/lib/craft-pipe.d.ts +63 -0
  140. package/src/lib/craft-pipe.d.ts.map +1 -0
  141. package/src/lib/craft-pipe.js +57 -0
  142. package/src/lib/craft-pipe.js.map +1 -0
  143. package/src/lib/craft-platform.d.ts +50 -0
  144. package/src/lib/craft-platform.d.ts.map +1 -0
  145. package/src/lib/craft-platform.js +175 -0
  146. package/src/lib/craft-platform.js.map +1 -0
  147. package/src/lib/craft-primitive-gen.d.ts +137 -0
  148. package/src/lib/craft-primitive-gen.d.ts.map +1 -0
  149. package/src/lib/craft-primitive-gen.js +76 -0
  150. package/src/lib/craft-primitive-gen.js.map +1 -0
  151. package/src/lib/craft-primitive-registry.d.ts +113 -0
  152. package/src/lib/craft-primitive-registry.d.ts.map +1 -0
  153. package/src/lib/craft-primitive-registry.js +159 -0
  154. package/src/lib/craft-primitive-registry.js.map +1 -0
  155. package/src/lib/craft-program-operators.d.ts +101 -0
  156. package/src/lib/craft-program-operators.d.ts.map +1 -0
  157. package/src/lib/craft-program-operators.js +116 -0
  158. package/src/lib/craft-program-operators.js.map +1 -0
  159. package/src/lib/craft-program-runtime.d.ts +80 -0
  160. package/src/lib/craft-program-runtime.d.ts.map +1 -0
  161. package/src/lib/craft-program-runtime.js +166 -0
  162. package/src/lib/craft-program-runtime.js.map +1 -0
  163. package/src/lib/craft-register-for-runtime.d.ts +39 -0
  164. package/src/lib/craft-register-for-runtime.d.ts.map +1 -0
  165. package/src/lib/craft-register-for-runtime.js +96 -0
  166. package/src/lib/craft-register-for-runtime.js.map +1 -0
  167. package/src/lib/craft-register-for.d.ts +57 -0
  168. package/src/lib/craft-register-for.d.ts.map +1 -0
  169. package/src/lib/craft-register-for.js +200 -0
  170. package/src/lib/craft-register-for.js.map +1 -0
  171. package/src/lib/craft-render-identity.d.ts +19 -0
  172. package/src/lib/craft-render-identity.d.ts.map +1 -0
  173. package/src/lib/craft-render-identity.js +23 -0
  174. package/src/lib/craft-render-identity.js.map +1 -0
  175. package/src/lib/craft-replay.d.ts +5 -0
  176. package/src/lib/craft-replay.d.ts.map +1 -0
  177. package/src/lib/craft-replay.js +28 -0
  178. package/src/lib/craft-replay.js.map +1 -0
  179. package/src/lib/craft-resolve.d.ts +39 -0
  180. package/src/lib/craft-resolve.d.ts.map +1 -0
  181. package/src/lib/craft-resolve.js +9 -0
  182. package/src/lib/craft-resolve.js.map +1 -0
  183. package/src/lib/craft-resource.d.ts +11 -0
  184. package/src/lib/craft-resource.d.ts.map +1 -0
  185. package/src/lib/craft-resource.js +264 -0
  186. package/src/lib/craft-resource.js.map +1 -0
  187. package/src/lib/craft-route-exceptions.d.ts +785 -0
  188. package/src/lib/craft-route-exceptions.d.ts.map +1 -0
  189. package/src/lib/craft-route-exceptions.js +86 -0
  190. package/src/lib/craft-route-exceptions.js.map +1 -0
  191. package/src/lib/craft-route-load-error.d.ts +1145 -0
  192. package/src/lib/craft-route-load-error.d.ts.map +1 -0
  193. package/src/lib/craft-route-load-error.js +173 -0
  194. package/src/lib/craft-route-load-error.js.map +1 -0
  195. package/src/lib/craft-route-meta.d.ts +52 -0
  196. package/src/lib/craft-route-meta.d.ts.map +1 -0
  197. package/src/lib/craft-route-meta.js +16 -0
  198. package/src/lib/craft-route-meta.js.map +1 -0
  199. package/src/lib/craft-route-target.d.ts +27 -0
  200. package/src/lib/craft-route-target.d.ts.map +1 -0
  201. package/src/lib/craft-route-target.js +22 -0
  202. package/src/lib/craft-route-target.js.map +1 -0
  203. package/src/lib/craft-router-outlet.d.ts +105 -0
  204. package/src/lib/craft-router-outlet.d.ts.map +1 -0
  205. package/src/lib/craft-router-outlet.js +735 -0
  206. package/src/lib/craft-router-outlet.js.map +1 -0
  207. package/src/lib/craft-router-tokens.d.ts +49 -0
  208. package/src/lib/craft-router-tokens.d.ts.map +1 -0
  209. package/src/lib/craft-router-tokens.js +15 -0
  210. package/src/lib/craft-router-tokens.js.map +1 -0
  211. package/src/lib/craft-router-trace.d.ts +18 -0
  212. package/src/lib/craft-router-trace.d.ts.map +1 -0
  213. package/src/lib/craft-router-trace.js +54 -0
  214. package/src/lib/craft-router-trace.js.map +1 -0
  215. package/src/lib/craft-router.d.ts +248 -0
  216. package/src/lib/craft-router.d.ts.map +1 -0
  217. package/src/lib/craft-router.js +559 -0
  218. package/src/lib/craft-router.js.map +1 -0
  219. package/src/lib/craft-routes.d.ts +755 -0
  220. package/src/lib/craft-routes.d.ts.map +1 -0
  221. package/src/lib/craft-routes.js +510 -0
  222. package/src/lib/craft-routes.js.map +1 -0
  223. package/src/lib/craft-service.d.ts +1034 -0
  224. package/src/lib/craft-service.d.ts.map +1 -0
  225. package/src/lib/craft-service.js +1072 -0
  226. package/src/lib/craft-service.js.map +1 -0
  227. package/src/lib/craft-service.shared.d.ts +35 -0
  228. package/src/lib/craft-service.shared.d.ts.map +1 -0
  229. package/src/lib/craft-service.shared.js +4 -0
  230. package/src/lib/craft-service.shared.js.map +1 -0
  231. package/src/lib/craft-settled.d.ts +171 -0
  232. package/src/lib/craft-settled.d.ts.map +1 -0
  233. package/src/lib/craft-settled.js +130 -0
  234. package/src/lib/craft-settled.js.map +1 -0
  235. package/src/lib/craft-ssr.d.ts +29 -0
  236. package/src/lib/craft-ssr.d.ts.map +1 -0
  237. package/src/lib/craft-ssr.js +27 -0
  238. package/src/lib/craft-ssr.js.map +1 -0
  239. package/src/lib/craft-state-machine-runtime.d.ts +88 -0
  240. package/src/lib/craft-state-machine-runtime.d.ts.map +1 -0
  241. package/src/lib/craft-state-machine-runtime.js +167 -0
  242. package/src/lib/craft-state-machine-runtime.js.map +1 -0
  243. package/src/lib/craft-state-machine.d.ts +233 -0
  244. package/src/lib/craft-state-machine.d.ts.map +1 -0
  245. package/src/lib/craft-state-machine.js +254 -0
  246. package/src/lib/craft-state-machine.js.map +1 -0
  247. package/src/lib/craft-target-runtime.d.ts +20 -0
  248. package/src/lib/craft-target-runtime.d.ts.map +1 -0
  249. package/src/lib/craft-target-runtime.js +42 -0
  250. package/src/lib/craft-target-runtime.js.map +1 -0
  251. package/src/lib/craft-transfer-snapshot.d.ts +19 -0
  252. package/src/lib/craft-transfer-snapshot.d.ts.map +1 -0
  253. package/src/lib/craft-transfer-snapshot.js +90 -0
  254. package/src/lib/craft-transfer-snapshot.js.map +1 -0
  255. package/src/lib/craft-unique.d.ts +7 -0
  256. package/src/lib/craft-unique.d.ts.map +1 -0
  257. package/src/lib/craft-unique.js +16 -0
  258. package/src/lib/craft-unique.js.map +1 -0
  259. package/src/lib/craft-until-settled.d.ts +99 -0
  260. package/src/lib/craft-until-settled.d.ts.map +1 -0
  261. package/src/lib/craft-until-settled.js +81 -0
  262. package/src/lib/craft-until-settled.js.map +1 -0
  263. package/src/lib/craft-use.d.ts +26 -0
  264. package/src/lib/craft-use.d.ts.map +1 -0
  265. package/src/lib/craft-use.js +37 -0
  266. package/src/lib/craft-use.js.map +1 -0
  267. package/src/lib/craft-view-transition.d.ts +102 -0
  268. package/src/lib/craft-view-transition.d.ts.map +1 -0
  269. package/src/lib/craft-view-transition.js +130 -0
  270. package/src/lib/craft-view-transition.js.map +1 -0
  271. package/src/lib/dom-event-hook.d.ts +30 -0
  272. package/src/lib/dom-event-hook.d.ts.map +1 -0
  273. package/src/lib/dom-event-hook.js +16 -0
  274. package/src/lib/dom-event-hook.js.map +1 -0
  275. package/src/lib/fn-wrapper.d.ts +13 -0
  276. package/src/lib/fn-wrapper.d.ts.map +1 -0
  277. package/src/lib/fn-wrapper.js +66 -0
  278. package/src/lib/fn-wrapper.js.map +1 -0
  279. package/src/lib/form/craft-field.d.ts +155 -0
  280. package/src/lib/form/craft-field.d.ts.map +1 -0
  281. package/src/lib/form/craft-field.directive.d.ts +70 -0
  282. package/src/lib/form/craft-field.directive.d.ts.map +1 -0
  283. package/src/lib/form/craft-field.directive.js +549 -0
  284. package/src/lib/form/craft-field.directive.js.map +1 -0
  285. package/src/lib/form/craft-field.js +586 -0
  286. package/src/lib/form/craft-field.js.map +1 -0
  287. package/src/lib/form/field-exception.d.ts +62 -0
  288. package/src/lib/form/field-exception.d.ts.map +1 -0
  289. package/src/lib/form/field-exception.js +37 -0
  290. package/src/lib/form/field-exception.js.map +1 -0
  291. package/src/lib/form/field-lens.d.ts +29 -0
  292. package/src/lib/form/field-lens.d.ts.map +1 -0
  293. package/src/lib/form/field-lens.js +32 -0
  294. package/src/lib/form/field-lens.js.map +1 -0
  295. package/src/lib/form/insert-form-attributes.d.ts +69 -0
  296. package/src/lib/form/insert-form-attributes.d.ts.map +1 -0
  297. package/src/lib/form/insert-form-attributes.js +163 -0
  298. package/src/lib/form/insert-form-attributes.js.map +1 -0
  299. package/src/lib/form/insert-form-internals.d.ts +110 -0
  300. package/src/lib/form/insert-form-internals.d.ts.map +1 -0
  301. package/src/lib/form/insert-form-internals.js +276 -0
  302. package/src/lib/form/insert-form-internals.js.map +1 -0
  303. package/src/lib/form/insert-form-schema.d.ts +10 -0
  304. package/src/lib/form/insert-form-schema.d.ts.map +1 -0
  305. package/src/lib/form/insert-form-schema.js +62 -0
  306. package/src/lib/form/insert-form-schema.js.map +1 -0
  307. package/src/lib/form/insert-form-submit.d.ts +79 -0
  308. package/src/lib/form/insert-form-submit.d.ts.map +1 -0
  309. package/src/lib/form/insert-form-submit.js +126 -0
  310. package/src/lib/form/insert-form-submit.js.map +1 -0
  311. package/src/lib/form/insert-form.d.ts +39 -0
  312. package/src/lib/form/insert-form.d.ts.map +1 -0
  313. package/src/lib/form/insert-form.js +255 -0
  314. package/src/lib/form/insert-form.js.map +1 -0
  315. package/src/lib/form/insert-select-form-tree.d.ts +33 -0
  316. package/src/lib/form/insert-select-form-tree.d.ts.map +1 -0
  317. package/src/lib/form/insert-select-form-tree.js +144 -0
  318. package/src/lib/form/insert-select-form-tree.js.map +1 -0
  319. package/src/lib/form/insert-sub-form-field.d.ts +17 -0
  320. package/src/lib/form/insert-sub-form-field.d.ts.map +1 -0
  321. package/src/lib/form/insert-sub-form-field.js +41 -0
  322. package/src/lib/form/insert-sub-form-field.js.map +1 -0
  323. package/src/lib/form/make-form-tree-insert.d.ts +22 -0
  324. package/src/lib/form/make-form-tree-insert.d.ts.map +1 -0
  325. package/src/lib/form/make-form-tree-insert.js +43 -0
  326. package/src/lib/form/make-form-tree-insert.js.map +1 -0
  327. package/src/lib/form/target-form-field.d.ts +11 -0
  328. package/src/lib/form/target-form-field.d.ts.map +1 -0
  329. package/src/lib/form/target-form-field.js +1 -0
  330. package/src/lib/form/target-form-field.js.map +1 -0
  331. package/src/lib/form/validator.d.ts +174 -0
  332. package/src/lib/form/validator.d.ts.map +1 -0
  333. package/src/lib/form/validator.js +465 -0
  334. package/src/lib/form/validator.js.map +1 -0
  335. package/src/lib/from-event-to-source$.d.ts +210 -0
  336. package/src/lib/from-event-to-source$.d.ts.map +1 -0
  337. package/src/lib/from-event-to-source$.js +29 -0
  338. package/src/lib/from-event-to-source$.js.map +1 -0
  339. package/src/lib/global-persister-handler.service.d.ts +10 -0
  340. package/src/lib/global-persister-handler.service.d.ts.map +1 -0
  341. package/src/lib/global-persister-handler.service.js +40 -0
  342. package/src/lib/global-persister-handler.service.js.map +1 -0
  343. package/src/lib/host/craft-compat.d.ts +242 -0
  344. package/src/lib/host/craft-compat.d.ts.map +1 -0
  345. package/src/lib/host/craft-compat.js +444 -0
  346. package/src/lib/host/craft-compat.js.map +1 -0
  347. package/src/lib/host/craft-dom.d.ts +16 -0
  348. package/src/lib/host/craft-dom.d.ts.map +1 -0
  349. package/src/lib/host/craft-dom.js +24 -0
  350. package/src/lib/host/craft-dom.js.map +1 -0
  351. package/src/lib/host/craft-http.d.ts +22 -0
  352. package/src/lib/host/craft-http.d.ts.map +1 -0
  353. package/src/lib/host/craft-http.js +80 -0
  354. package/src/lib/host/craft-http.js.map +1 -0
  355. package/src/lib/host/craft-injector-host.d.ts +3 -0
  356. package/src/lib/host/craft-injector-host.d.ts.map +1 -0
  357. package/src/lib/host/craft-injector-host.js +2 -0
  358. package/src/lib/host/craft-injector-host.js.map +1 -0
  359. package/src/lib/host/craft-injector.d.ts +40 -0
  360. package/src/lib/host/craft-injector.d.ts.map +1 -0
  361. package/src/lib/host/craft-injector.js +318 -0
  362. package/src/lib/host/craft-injector.js.map +1 -0
  363. package/src/lib/host/craft-linked-signal.d.ts +17 -0
  364. package/src/lib/host/craft-linked-signal.d.ts.map +1 -0
  365. package/src/lib/host/craft-linked-signal.js +86 -0
  366. package/src/lib/host/craft-linked-signal.js.map +1 -0
  367. package/src/lib/host/craft-router-runtime.d.ts +61 -0
  368. package/src/lib/host/craft-router-runtime.d.ts.map +1 -0
  369. package/src/lib/host/craft-router-runtime.js +456 -0
  370. package/src/lib/host/craft-router-runtime.js.map +1 -0
  371. package/src/lib/host/craft-router-types.d.ts +84 -0
  372. package/src/lib/host/craft-router-types.d.ts.map +1 -0
  373. package/src/lib/host/craft-router-types.js +35 -0
  374. package/src/lib/host/craft-router-types.js.map +1 -0
  375. package/src/lib/host/craft-signal.d.ts +45 -0
  376. package/src/lib/host/craft-signal.d.ts.map +1 -0
  377. package/src/lib/host/craft-signal.js +161 -0
  378. package/src/lib/host/craft-signal.js.map +1 -0
  379. package/src/lib/host/craft-test-bed.d.ts +63 -0
  380. package/src/lib/host/craft-test-bed.d.ts.map +1 -0
  381. package/src/lib/host/craft-test-bed.js +114 -0
  382. package/src/lib/host/craft-test-bed.js.map +1 -0
  383. package/src/lib/host-tag.d.ts +2 -0
  384. package/src/lib/host-tag.d.ts.map +1 -0
  385. package/src/lib/host-tag.js +2 -0
  386. package/src/lib/host-tag.js.map +1 -0
  387. package/src/lib/insert-entities.d.ts +131 -0
  388. package/src/lib/insert-entities.d.ts.map +1 -0
  389. package/src/lib/insert-entities.js +159 -0
  390. package/src/lib/insert-entities.js.map +1 -0
  391. package/src/lib/insert-noop-typing-anchor.d.ts +15 -0
  392. package/src/lib/insert-noop-typing-anchor.d.ts.map +1 -0
  393. package/src/lib/insert-noop-typing-anchor.js +16 -0
  394. package/src/lib/insert-noop-typing-anchor.js.map +1 -0
  395. package/src/lib/insert-pagination-placeholder-data.d.ts +122 -0
  396. package/src/lib/insert-pagination-placeholder-data.d.ts.map +1 -0
  397. package/src/lib/insert-pagination-placeholder-data.js +244 -0
  398. package/src/lib/insert-pagination-placeholder-data.js.map +1 -0
  399. package/src/lib/insert-react-on-mutation.d.ts +261 -0
  400. package/src/lib/insert-react-on-mutation.d.ts.map +1 -0
  401. package/src/lib/insert-react-on-mutation.js +227 -0
  402. package/src/lib/insert-react-on-mutation.js.map +1 -0
  403. package/src/lib/insert-select-resource.d.ts +31 -0
  404. package/src/lib/insert-select-resource.d.ts.map +1 -0
  405. package/src/lib/insert-select-resource.js +27 -0
  406. package/src/lib/insert-select-resource.js.map +1 -0
  407. package/src/lib/insert-select.d.ts +126 -0
  408. package/src/lib/insert-select.d.ts.map +1 -0
  409. package/src/lib/insert-select.js +535 -0
  410. package/src/lib/insert-select.js.map +1 -0
  411. package/src/lib/insert-storage-persister.d.ts +27 -0
  412. package/src/lib/insert-storage-persister.d.ts.map +1 -0
  413. package/src/lib/insert-storage-persister.js +65 -0
  414. package/src/lib/insert-storage-persister.js.map +1 -0
  415. package/src/lib/insert-typed-pipes.d.ts +64 -0
  416. package/src/lib/insert-typed-pipes.d.ts.map +1 -0
  417. package/src/lib/insert-typed-pipes.js +32 -0
  418. package/src/lib/insert-typed-pipes.js.map +1 -0
  419. package/src/lib/linked-source.d.ts +8 -0
  420. package/src/lib/linked-source.d.ts.map +1 -0
  421. package/src/lib/linked-source.js +24 -0
  422. package/src/lib/linked-source.js.map +1 -0
  423. package/src/lib/local-storage-persister.d.ts +4 -0
  424. package/src/lib/local-storage-persister.d.ts.map +1 -0
  425. package/src/lib/local-storage-persister.js +342 -0
  426. package/src/lib/local-storage-persister.js.map +1 -0
  427. package/src/lib/middleware-schema-shared.d.ts +67 -0
  428. package/src/lib/middleware-schema-shared.d.ts.map +1 -0
  429. package/src/lib/middleware-schema-shared.js +34 -0
  430. package/src/lib/middleware-schema-shared.js.map +1 -0
  431. package/src/lib/mock-http-request-for-route.d.ts +173 -0
  432. package/src/lib/mock-http-request-for-route.d.ts.map +1 -0
  433. package/src/lib/mock-http-request-for-route.js +127 -0
  434. package/src/lib/mock-http-request-for-route.js.map +1 -0
  435. package/src/lib/mutation.d.ts +332 -0
  436. package/src/lib/mutation.d.ts.map +1 -0
  437. package/src/lib/mutation.js +923 -0
  438. package/src/lib/mutation.js.map +1 -0
  439. package/src/lib/on$.d.ts +26 -0
  440. package/src/lib/on$.d.ts.map +1 -0
  441. package/src/lib/on$.js +19 -0
  442. package/src/lib/on$.js.map +1 -0
  443. package/src/lib/portable-server-function.d.ts +68 -0
  444. package/src/lib/portable-server-function.d.ts.map +1 -0
  445. package/src/lib/portable-server-function.js +97 -0
  446. package/src/lib/portable-server-function.js.map +1 -0
  447. package/src/lib/preserved-resource.d.ts +4 -0
  448. package/src/lib/preserved-resource.d.ts.map +1 -0
  449. package/src/lib/preserved-resource.js +60 -0
  450. package/src/lib/preserved-resource.js.map +1 -0
  451. package/src/lib/primitive-method-runtime-context.d.ts +28 -0
  452. package/src/lib/primitive-method-runtime-context.d.ts.map +1 -0
  453. package/src/lib/primitive-method-runtime-context.js +38 -0
  454. package/src/lib/primitive-method-runtime-context.js.map +1 -0
  455. package/src/lib/primitive-resource-runtime-context.d.ts +46 -0
  456. package/src/lib/primitive-resource-runtime-context.d.ts.map +1 -0
  457. package/src/lib/primitive-resource-runtime-context.js +102 -0
  458. package/src/lib/primitive-resource-runtime-context.js.map +1 -0
  459. package/src/lib/query-params.d.ts +216 -0
  460. package/src/lib/query-params.d.ts.map +1 -0
  461. package/src/lib/query-params.js +324 -0
  462. package/src/lib/query-params.js.map +1 -0
  463. package/src/lib/query.core.d.ts +214 -0
  464. package/src/lib/query.core.d.ts.map +1 -0
  465. package/src/lib/query.core.js +210 -0
  466. package/src/lib/query.core.js.map +1 -0
  467. package/src/lib/query.d.ts +324 -0
  468. package/src/lib/query.d.ts.map +1 -0
  469. package/src/lib/query.js +971 -0
  470. package/src/lib/query.js.map +1 -0
  471. package/src/lib/reactive-read.d.ts +162 -0
  472. package/src/lib/reactive-read.d.ts.map +1 -0
  473. package/src/lib/reactive-read.js +389 -0
  474. package/src/lib/reactive-read.js.map +1 -0
  475. package/src/lib/resource-by-id.d.ts +71 -0
  476. package/src/lib/resource-by-id.d.ts.map +1 -0
  477. package/src/lib/resource-by-id.js +294 -0
  478. package/src/lib/resource-by-id.js.map +1 -0
  479. package/src/lib/resource-exception.d.ts +30 -0
  480. package/src/lib/resource-exception.d.ts.map +1 -0
  481. package/src/lib/resource-exception.js +86 -0
  482. package/src/lib/resource-exception.js.map +1 -0
  483. package/src/lib/route-checked-di.d.ts +229 -0
  484. package/src/lib/route-checked-di.d.ts.map +1 -0
  485. package/src/lib/route-checked-di.js +1 -0
  486. package/src/lib/route-checked-di.js.map +1 -0
  487. package/src/lib/schema-validation.d.ts +89 -0
  488. package/src/lib/schema-validation.d.ts.map +1 -0
  489. package/src/lib/schema-validation.js +110 -0
  490. package/src/lib/schema-validation.js.map +1 -0
  491. package/src/lib/send-context-to-ai.d.ts +20 -0
  492. package/src/lib/send-context-to-ai.d.ts.map +1 -0
  493. package/src/lib/send-context-to-ai.js +18 -0
  494. package/src/lib/send-context-to-ai.js.map +1 -0
  495. package/src/lib/send-context-to-ai.tokens.d.ts +12 -0
  496. package/src/lib/send-context-to-ai.tokens.d.ts.map +1 -0
  497. package/src/lib/send-context-to-ai.tokens.js +1 -0
  498. package/src/lib/send-context-to-ai.tokens.js.map +1 -0
  499. package/src/lib/server-function-client.d.ts +102 -0
  500. package/src/lib/server-function-client.d.ts.map +1 -0
  501. package/src/lib/server-function-client.js +106 -0
  502. package/src/lib/server-function-client.js.map +1 -0
  503. package/src/lib/server-function-contract.d.ts +42 -0
  504. package/src/lib/server-function-contract.d.ts.map +1 -0
  505. package/src/lib/server-function-contract.js +23 -0
  506. package/src/lib/server-function-contract.js.map +1 -0
  507. package/src/lib/server-function-middleware.d.ts +222 -0
  508. package/src/lib/server-function-middleware.d.ts.map +1 -0
  509. package/src/lib/server-function-middleware.js +189 -0
  510. package/src/lib/server-function-middleware.js.map +1 -0
  511. package/src/lib/server-function.d.ts +114 -0
  512. package/src/lib/server-function.d.ts.map +1 -0
  513. package/src/lib/server-function.js +80 -0
  514. package/src/lib/server-function.js.map +1 -0
  515. package/src/lib/server-layer.d.ts +185 -0
  516. package/src/lib/server-layer.d.ts.map +1 -0
  517. package/src/lib/server-layer.js +121 -0
  518. package/src/lib/server-layer.js.map +1 -0
  519. package/src/lib/server.d.ts +83 -0
  520. package/src/lib/server.d.ts.map +1 -0
  521. package/src/lib/server.js +266 -0
  522. package/src/lib/server.js.map +1 -0
  523. package/src/lib/setup-craft-service-test.d.ts +90 -0
  524. package/src/lib/setup-craft-service-test.d.ts.map +1 -0
  525. package/src/lib/setup-craft-service-test.js +193 -0
  526. package/src/lib/setup-craft-service-test.js.map +1 -0
  527. package/src/lib/setup-craft-service-testing-by-register.d.ts +245 -0
  528. package/src/lib/setup-craft-service-testing-by-register.d.ts.map +1 -0
  529. package/src/lib/setup-craft-service-testing-by-register.js +316 -0
  530. package/src/lib/setup-craft-service-testing-by-register.js.map +1 -0
  531. package/src/lib/signal-proxy.d.ts +21 -0
  532. package/src/lib/signal-proxy.d.ts.map +1 -0
  533. package/src/lib/signal-proxy.js +79 -0
  534. package/src/lib/signal-proxy.js.map +1 -0
  535. package/src/lib/signal-source.d.ts +392 -0
  536. package/src/lib/signal-source.d.ts.map +1 -0
  537. package/src/lib/signal-source.js +433 -0
  538. package/src/lib/signal-source.js.map +1 -0
  539. package/src/lib/source$.d.ts +121 -0
  540. package/src/lib/source$.d.ts.map +1 -0
  541. package/src/lib/source$.js +171 -0
  542. package/src/lib/source$.js.map +1 -0
  543. package/src/lib/source-from-event.d.ts +350 -0
  544. package/src/lib/source-from-event.d.ts.map +1 -0
  545. package/src/lib/source-from-event.js +26 -0
  546. package/src/lib/source-from-event.js.map +1 -0
  547. package/src/lib/stacked-source.d.ts +6 -0
  548. package/src/lib/stacked-source.d.ts.map +1 -0
  549. package/src/lib/stacked-source.js +29 -0
  550. package/src/lib/stacked-source.js.map +1 -0
  551. package/src/lib/standard-schema.d.ts +43 -0
  552. package/src/lib/standard-schema.d.ts.map +1 -0
  553. package/src/lib/standard-schema.js +1 -0
  554. package/src/lib/standard-schema.js.map +1 -0
  555. package/src/lib/state-method-runtime-context.d.ts +13 -0
  556. package/src/lib/state-method-runtime-context.d.ts.map +1 -0
  557. package/src/lib/state-method-runtime-context.js +11 -0
  558. package/src/lib/state-method-runtime-context.js.map +1 -0
  559. package/src/lib/state.d.ts +158 -0
  560. package/src/lib/state.d.ts.map +1 -0
  561. package/src/lib/state.js +388 -0
  562. package/src/lib/state.js.map +1 -0
  563. package/src/lib/storage-persister.service.d.ts +25 -0
  564. package/src/lib/storage-persister.service.d.ts.map +1 -0
  565. package/src/lib/storage-persister.service.js +27 -0
  566. package/src/lib/storage-persister.service.js.map +1 -0
  567. package/src/lib/take-app-snapshot.d.ts +31 -0
  568. package/src/lib/take-app-snapshot.d.ts.map +1 -0
  569. package/src/lib/take-app-snapshot.js +93 -0
  570. package/src/lib/take-app-snapshot.js.map +1 -0
  571. package/src/lib/template-trace.d.ts +37 -0
  572. package/src/lib/template-trace.d.ts.map +1 -0
  573. package/src/lib/template-trace.js +37 -0
  574. package/src/lib/template-trace.js.map +1 -0
  575. package/src/lib/temporal-runtime.d.ts +146 -0
  576. package/src/lib/temporal-runtime.d.ts.map +1 -0
  577. package/src/lib/temporal-runtime.js +375 -0
  578. package/src/lib/temporal-runtime.js.map +1 -0
  579. package/src/lib/to-source.d.ts +335 -0
  580. package/src/lib/to-source.d.ts.map +1 -0
  581. package/src/lib/to-source.js +359 -0
  582. package/src/lib/to-source.js.map +1 -0
  583. package/src/lib/util/craft-resource-ref.d.ts +29 -0
  584. package/src/lib/util/craft-resource-ref.d.ts.map +1 -0
  585. package/src/lib/util/craft-resource-ref.js +1 -0
  586. package/src/lib/util/craft-resource-ref.js.map +1 -0
  587. package/src/lib/util/craft-resource-status.d.ts +17 -0
  588. package/src/lib/util/craft-resource-status.d.ts.map +1 -0
  589. package/src/lib/util/craft-resource-status.js +14 -0
  590. package/src/lib/util/craft-resource-status.js.map +1 -0
  591. package/src/lib/util/entities-util.d.ts +340 -0
  592. package/src/lib/util/entities-util.d.ts.map +1 -0
  593. package/src/lib/util/entities-util.js +136 -0
  594. package/src/lib/util/entities-util.js.map +1 -0
  595. package/src/lib/util/explicit-effect.d.ts +42 -0
  596. package/src/lib/util/explicit-effect.d.ts.map +1 -0
  597. package/src/lib/util/explicit-effect.js +37 -0
  598. package/src/lib/util/explicit-effect.js.map +1 -0
  599. package/src/lib/util/extract-signal-props-and-methods.d.ts +20 -0
  600. package/src/lib/util/extract-signal-props-and-methods.d.ts.map +1 -0
  601. package/src/lib/util/extract-signal-props-and-methods.js +1 -0
  602. package/src/lib/util/extract-signal-props-and-methods.js.map +1 -0
  603. package/src/lib/util/method-trigger-nonce.d.ts +45 -0
  604. package/src/lib/util/method-trigger-nonce.d.ts.map +1 -0
  605. package/src/lib/util/method-trigger-nonce.js +58 -0
  606. package/src/lib/util/method-trigger-nonce.js.map +1 -0
  607. package/src/lib/util/persister.type.d.ts +37 -0
  608. package/src/lib/util/persister.type.d.ts.map +1 -0
  609. package/src/lib/util/persister.type.js +1 -0
  610. package/src/lib/util/persister.type.js.map +1 -0
  611. package/src/lib/util/persister.util.d.ts +8 -0
  612. package/src/lib/util/persister.util.d.ts.map +1 -0
  613. package/src/lib/util/persister.util.js +71 -0
  614. package/src/lib/util/persister.util.js.map +1 -0
  615. package/src/lib/util/react-on-mutation-effect.d.ts +16 -0
  616. package/src/lib/util/react-on-mutation-effect.d.ts.map +1 -0
  617. package/src/lib/util/react-on-mutation-effect.js +148 -0
  618. package/src/lib/util/react-on-mutation-effect.js.map +1 -0
  619. package/src/lib/util/resource-by-id-changes-tracker.util.d.ts +27 -0
  620. package/src/lib/util/resource-by-id-changes-tracker.util.d.ts.map +1 -0
  621. package/src/lib/util/resource-by-id-changes-tracker.util.js +97 -0
  622. package/src/lib/util/resource-by-id-changes-tracker.util.js.map +1 -0
  623. package/src/lib/util/source.type.d.ts +6 -0
  624. package/src/lib/util/source.type.d.ts.map +1 -0
  625. package/src/lib/util/source.type.js +1 -0
  626. package/src/lib/util/source.type.js.map +1 -0
  627. package/src/lib/util/types/access-type-object-property-by-dotted-path.type.d.ts +4 -0
  628. package/src/lib/util/types/access-type-object-property-by-dotted-path.type.d.ts.map +1 -0
  629. package/src/lib/util/types/access-type-object-property-by-dotted-path.type.js +1 -0
  630. package/src/lib/util/types/access-type-object-property-by-dotted-path.type.js.map +1 -0
  631. package/src/lib/util/types/boolean-or-mapper-fn-by-path-by-id.type.d.ts +27 -0
  632. package/src/lib/util/types/boolean-or-mapper-fn-by-path-by-id.type.d.ts.map +1 -0
  633. package/src/lib/util/types/boolean-or-mapper-fn-by-path-by-id.type.js +1 -0
  634. package/src/lib/util/types/boolean-or-mapper-fn-by-path-by-id.type.js.map +1 -0
  635. package/src/lib/util/types/boolean-or-mapper-fn-by-path.type.d.ts +24 -0
  636. package/src/lib/util/types/boolean-or-mapper-fn-by-path.type.d.ts.map +1 -0
  637. package/src/lib/util/types/boolean-or-mapper-fn-by-path.type.js +1 -0
  638. package/src/lib/util/types/boolean-or-mapper-fn-by-path.type.js.map +1 -0
  639. package/src/lib/util/types/brand.d.ts +7 -0
  640. package/src/lib/util/types/brand.d.ts.map +1 -0
  641. package/src/lib/util/types/brand.js +9 -0
  642. package/src/lib/util/types/brand.js.map +1 -0
  643. package/src/lib/util/types/object-deep-path-mapper.type.d.ts +13 -0
  644. package/src/lib/util/types/object-deep-path-mapper.type.d.ts.map +1 -0
  645. package/src/lib/util/types/object-deep-path-mapper.type.js +1 -0
  646. package/src/lib/util/types/object-deep-path-mapper.type.js.map +1 -0
  647. package/src/lib/util/types/resource-by-id-config.type.d.ts +115 -0
  648. package/src/lib/util/types/resource-by-id-config.type.d.ts.map +1 -0
  649. package/src/lib/util/types/resource-by-id-config.type.js +1 -0
  650. package/src/lib/util/types/resource-by-id-config.type.js.map +1 -0
  651. package/src/lib/util/types/resource-with-params-or-params-fn.type.d.ts +52 -0
  652. package/src/lib/util/types/resource-with-params-or-params-fn.type.d.ts.map +1 -0
  653. package/src/lib/util/types/resource-with-params-or-params-fn.type.js +1 -0
  654. package/src/lib/util/types/resource-with-params-or-params-fn.type.js.map +1 -0
  655. package/src/lib/util/types/shared.type.d.ts +66 -0
  656. package/src/lib/util/types/shared.type.d.ts.map +1 -0
  657. package/src/lib/util/types/shared.type.js +1 -0
  658. package/src/lib/util/types/shared.type.js.map +1 -0
  659. package/src/lib/util/types/util.d.ts +16 -0
  660. package/src/lib/util/types/util.d.ts.map +1 -0
  661. package/src/lib/util/types/util.js +60 -0
  662. package/src/lib/util/types/util.js.map +1 -0
  663. package/src/lib/util/types/util.type.d.ts +67 -0
  664. package/src/lib/util/types/util.type.d.ts.map +1 -0
  665. package/src/lib/util/types/util.type.js +5 -0
  666. package/src/lib/util/types/util.type.js.map +1 -0
  667. package/src/lib/util/update-state.util.d.ts +10 -0
  668. package/src/lib/util/update-state.util.d.ts.map +1 -0
  669. package/src/lib/util/update-state.util.js +31 -0
  670. package/src/lib/util/update-state.util.js.map +1 -0
  671. package/src/lib/util/util.d.ts +19 -0
  672. package/src/lib/util/util.d.ts.map +1 -0
  673. package/src/lib/util/util.js +50 -0
  674. package/src/lib/util/util.js.map +1 -0
  675. package/src/lib/util/util.type.d.ts +107 -0
  676. package/src/lib/util/util.type.d.ts.map +1 -0
  677. package/src/lib/util/util.type.js +9 -0
  678. package/src/lib/util/util.type.js.map +1 -0
  679. package/src/lib/yieldable.d.ts +94 -0
  680. package/src/lib/yieldable.d.ts.map +1 -0
  681. package/src/lib/yieldable.js +109 -0
  682. package/src/lib/yieldable.js.map +1 -0
@@ -0,0 +1,254 @@
1
+ import { assertInInjectionContext, inject, Injector, isSignal, runInInjectionContext, } from './host/craft-compat';
2
+ import { craftComputed as createCraftComputed, craftSignal, } from './host/craft-signal';
3
+ import { injectFnWrapper } from './fn-wrapper';
4
+ import { ɵcreateHostTaggedInjector, ɵHOST_TAG_LIST } from './craft-service';
5
+ import { createNamedPrimitiveGen, } from './craft-primitive-gen';
6
+ import { isSource } from './util/util';
7
+ import { createYieldableInsertionMethod, isNonYieldableInsertionMethod, isYieldableMethod, } from './yieldable';
8
+ import { createYieldableReactiveValue, isYieldableReactiveValue, nameInsertedReactiveValue, } from './reactive-read';
9
+ import { ɵdriveMachineGenerator, ɵregisterMachineInit, ɵrestoreMachineStep, ɵrunTransition, ɵwithMachineScope, ɵwithSuspendedMachine, ɵrequireMachineScope, } from './craft-state-machine-runtime';
10
+ // ---------------------------------------------------------------------------
11
+ // Markers
12
+ // ---------------------------------------------------------------------------
13
+ const TRANSITION_STEP_MARKER = Symbol('craft-transition-step');
14
+ const TRANSITIONS_SETUP_MARKER = Symbol('craft-transitions-setup');
15
+ const TRANSITION_GUARD_MARKER = Symbol('craft-transition-guard');
16
+ // ---------------------------------------------------------------------------
17
+ // Authoring surface
18
+ // ---------------------------------------------------------------------------
19
+ /**
20
+ * Wraps a predicate into a transition guard. Accepts a plain lambda or a
21
+ * generator; a generator guard resolves craft dependencies with `yield*`, and
22
+ * those dependencies join the machine's dependency graph.
23
+ *
24
+ * ```ts
25
+ * transitionGuard(({ context }) => context.form.isValid());
26
+ *
27
+ * transitionGuard(function* ({ context, from, to, event }) {
28
+ * const policy = yield* PolicyService();
29
+ * return policy.canTransition({ from, to, event });
30
+ * });
31
+ * ```
32
+ */
33
+ export function transitionGuard(guard) {
34
+ return Object.assign(guard, {
35
+ [TRANSITION_GUARD_MARKER]: true,
36
+ });
37
+ }
38
+ /**
39
+ * Declares how a machine enters one step. The generator runs once, at machine
40
+ * creation, and registers the reactions that may move the machine here
41
+ * (`on$`, `afterRecomputation`, `initStateMachine`).
42
+ *
43
+ * `transitionStep(...).pipe(transitionGuard(...))` guards every transition
44
+ * declared in that step.
45
+ */
46
+ export function transitionStep(setup) {
47
+ return createTransitionStep(setup, []);
48
+ }
49
+ /**
50
+ * Builds every transition of a machine. The setup generator receives the
51
+ * machine `context` and `transit`, and returns one {@link transitionStep} per
52
+ * step; the record's keys ARE the machine's steps.
53
+ *
54
+ * `transitionsSetup(...).pipe(transitionGuard(...))` guards every transition of
55
+ * every step.
56
+ *
57
+ * Declared standalone, the setup's `context` parameter has to be annotated —
58
+ * typically with `CraftMachineContext<typeof contextFactory>`; `craftStateMachine`
59
+ * then checks the machine's real context against that annotation.
60
+ */
61
+ export function transitionsSetup(setup) {
62
+ return createTransitionsSetup(setup, []);
63
+ }
64
+ /**
65
+ * Registers the callback that gives the machine its initial step. Registrations
66
+ * run after every step has been installed, in declaration order, and the first
67
+ * accepted `transit()` wins — later init registrations are skipped.
68
+ *
69
+ * ```ts
70
+ * yield* initStateMachine(() => transit());
71
+ * ```
72
+ */
73
+ export function initStateMachine(callback) {
74
+ return ɵregisterMachineInit(callback);
75
+ }
76
+ export function craftStateMachine(
77
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
78
+ nameOrContextFactory,
79
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
80
+ contextFactoryOrTransitions,
81
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
82
+ transitionsOrCurrentStepWithContextFactory,
83
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
84
+ currentStepWithContextFactoryOrInsertion,
85
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
86
+ maybeInsertion) {
87
+ const isNamed = typeof nameOrContextFactory === 'string';
88
+ const name = isNamed ? nameOrContextFactory : 'stateMachine';
89
+ const contextFactory = isNamed
90
+ ? contextFactoryOrTransitions
91
+ : nameOrContextFactory;
92
+ const transitions = isNamed
93
+ ? transitionsOrCurrentStepWithContextFactory
94
+ : contextFactoryOrTransitions;
95
+ const currentStepWithContextFactory = isNamed
96
+ ? currentStepWithContextFactoryOrInsertion
97
+ : transitionsOrCurrentStepWithContextFactory;
98
+ const insertion = isNamed
99
+ ? maybeInsertion
100
+ : currentStepWithContextFactoryOrInsertion;
101
+ const ref = createStateMachineRef(name, contextFactory, transitions, currentStepWithContextFactory, insertion);
102
+ return createNamedPrimitiveGen(name, ref);
103
+ }
104
+ function createTransitionStep(setup, guards) {
105
+ const step = {
106
+ [TRANSITION_STEP_MARKER]: true,
107
+ setup,
108
+ guards,
109
+ pipe: (...extraGuards) => createTransitionStep(setup, [...guards, ...extraGuards]),
110
+ };
111
+ return step;
112
+ }
113
+ function createTransitionsSetup(setup, guards) {
114
+ return {
115
+ [TRANSITIONS_SETUP_MARKER]: true,
116
+ setup,
117
+ guards,
118
+ pipe: (...extraGuards) => createTransitionsSetup(setup, [...guards, ...extraGuards]),
119
+ };
120
+ }
121
+ function createTransitionAttempt(event, localGuards) {
122
+ // The scope is captured at CREATION time: `transit(...)` is called from inside
123
+ // a registration callback, which the machine runs with its declaring step
124
+ // restored. Reading it lazily would resolve the wrong target.
125
+ const scope = ɵrequireMachineScope('transit(...)');
126
+ const attempt = ɵrunTransition(scope, event, localGuards);
127
+ return Object.assign(attempt, {
128
+ pipe: (...guards) => ɵwithMachineScope(scope, () => createTransitionAttempt(event, [...localGuards, ...guards])),
129
+ });
130
+ }
131
+ function createTransit() {
132
+ return (event) => createTransitionAttempt(event, []);
133
+ }
134
+ function isStepsRecord(value) {
135
+ return typeof value === 'object' && value !== null;
136
+ }
137
+ function driveFactory(factory, injector, ...args) {
138
+ const wrapped = runInInjectionContext(injector, () => injectFnWrapper()(factory));
139
+ return runInInjectionContext(injector, () => ɵdriveMachineGenerator(wrapped(...args), injector));
140
+ }
141
+ function exposeInsertionOutput(output, injector) {
142
+ return Object.entries(output).reduce((exposed, [key, value]) => {
143
+ if (isYieldableReactiveValue(value)) {
144
+ exposed[key] = nameInsertedReactiveValue(value, key, 'craftStateMachine', `craftStateMachine.${key}`);
145
+ return exposed;
146
+ }
147
+ if (isSource(value) || isSignal(value) || isYieldableMethod(value)) {
148
+ exposed[key] = value;
149
+ return exposed;
150
+ }
151
+ if (typeof value === 'function' && !isNonYieldableInsertionMethod(value)) {
152
+ const methodInjector = ɵcreateHostTaggedInjector(injector, `method:${key}`);
153
+ const wrappedFn = runInInjectionContext(methodInjector, () => injectFnWrapper()(value));
154
+ exposed[key] = createYieldableInsertionMethod(wrappedFn, {
155
+ injector: methodInjector,
156
+ invalidYieldErrorMessage: 'craftStateMachine insertion method generators can only yield craftService dependencies or exposed dependency helpers.',
157
+ multipleAppStartErrorMessage: 'craftStateMachine insertion methods do not support multiple onAppStart(...) declarations.',
158
+ onAppStartNotSupportedErrorMessage: 'craftStateMachine insertion methods do not support onAppStart(...).',
159
+ });
160
+ return exposed;
161
+ }
162
+ exposed[key] = value;
163
+ return exposed;
164
+ }, {});
165
+ }
166
+ /**
167
+ * Normalises the two accepted forms: a bare setup generator carries no
168
+ * machine-wide guard, so it becomes a setup with an empty guard list.
169
+ */
170
+ function toRuntimeTransitionsSetup(transitions) {
171
+ return typeof transitions === 'function'
172
+ ? createTransitionsSetup(transitions, [])
173
+ : transitions;
174
+ }
175
+ function createStateMachineRef(name, contextFactory, transitionsInput, currentStepWithContextFactory, insertion) {
176
+ assertInInjectionContext(craftStateMachine);
177
+ const transitions = toRuntimeTransitionsSetup(transitionsInput);
178
+ const injector = ɵcreateHostTaggedInjector(inject(Injector), `stateMachine:${name}`);
179
+ return runInInjectionContext(injector, () => {
180
+ const context = driveFactory(contextFactory, injector);
181
+ const stepContexts = (currentStepWithContextFactory
182
+ ? driveFactory(currentStepWithContextFactory, injector, context)
183
+ : {});
184
+ const currentStep = craftSignal(undefined);
185
+ const runtime = {
186
+ context,
187
+ currentStep,
188
+ globalGuards: transitions.guards,
189
+ stepGuards: new Map(),
190
+ injector,
191
+ initRegistrations: [],
192
+ observers: new Set(),
193
+ suspended: false,
194
+ };
195
+ const stepsRecord = driveFactory(transitions.setup, injector, context, createTransit());
196
+ if (!isStepsRecord(stepsRecord)) {
197
+ throw new Error('transitionsSetup(...) must return a record of transitionStep(...) entries.');
198
+ }
199
+ for (const [step, definition] of Object.entries(stepsRecord)) {
200
+ runtime.stepGuards.set(step, definition.guards ?? []);
201
+ }
202
+ for (const [step, definition] of Object.entries(stepsRecord)) {
203
+ ɵwithMachineScope({ runtime, target: step }, () => runInInjectionContext(injector, () => ɵdriveMachineGenerator(definition.setup(), injector)));
204
+ }
205
+ // Installation is over: the machine can now take its initial step. The
206
+ // first accepted transit wins, so a later registration is not even run.
207
+ for (const registration of runtime.initRegistrations) {
208
+ if (currentStep() !== undefined) {
209
+ break;
210
+ }
211
+ registration();
212
+ }
213
+ if (currentStep() === undefined) {
214
+ throw new Error(`craftStateMachine "${name}" did not initialise: its initial transition was rejected by a guard.`);
215
+ }
216
+ const currentStepReader = createYieldableReactiveValue(currentStep.asReadonly(), 'currentStep');
217
+ const currentStepWithContextReader = createYieldableReactiveValue(createCraftComputed(() => {
218
+ const step = currentStep();
219
+ if (step === undefined)
220
+ return undefined;
221
+ return Object.assign({}, stepContexts[step], { step });
222
+ }), 'currentStepWithContext');
223
+ const ref = {
224
+ currentStep: currentStepReader,
225
+ currentStepWithContext: currentStepWithContextReader,
226
+ context,
227
+ };
228
+ if (insertion) {
229
+ const controls = {
230
+ hostTags: injector.get(ɵHOST_TAG_LIST, []),
231
+ onTransition: (observer) => {
232
+ runtime.observers.add(observer);
233
+ return () => runtime.observers.delete(observer);
234
+ },
235
+ restoreStep: (step) => {
236
+ if (step === undefined) {
237
+ throw new Error(`craftStateMachine "${name}" cannot restore an undefined step.`);
238
+ }
239
+ ɵrestoreMachineStep(runtime, step);
240
+ },
241
+ suspended: (restore) => ɵwithSuspendedMachine(runtime, restore),
242
+ };
243
+ const output = driveFactory(insertion, injector, {
244
+ context,
245
+ currentStep: currentStepReader,
246
+ currentStepWithContext: currentStepWithContextReader,
247
+ machine: controls,
248
+ });
249
+ Object.assign(ref, exposeInsertionOutput((output ?? {}), injector));
250
+ }
251
+ return ref;
252
+ });
253
+ }
254
+ //# sourceMappingURL=craft-state-machine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"craft-state-machine.js","sourceRoot":"","sources":["../../../../../libs/core/src/lib/craft-state-machine.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,qBAAqB,GACtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,aAAa,IAAI,mBAAmB,EACpC,WAAW,GACZ,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,yBAAyB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAK5E,OAAO,EACL,uBAAuB,GAExB,MAAM,uBAAuB,C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CACzB,CAAC;QAEF,MAAM,GAAG,GAA4B;YACnC,WAAW,EAAE,iBAAiB;YAC9B,sBAAsB,EAAE,4BAA4B;YACpD,OAAO;SACR,CAAC;QAEF,IAAI,SAAS,EAAE,CAAC;YACd,MAAM,QAAQ,GAAG;gBACf,QAAQ,EAAE,QAAQ,CAAC,GAAG,CAAC,cAAc,EAAE,EAAE,CAAsB;gBAC/D,YAAY,EAAE,CAAC,QAAmC,EAAE,EAAE;oBACpD,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;oBAChC,OAAO,GAAG,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;gBAClD,CAAC;gBACD,WAAW,EAAE,CAAC,IAAY,EAAE,EAAE;oBAC5B,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;wBACvB,MAAM,IAAI,KAAK,CACb,sBAAsB,IAAI,qCAAqC,CAChE,CAAC;oBACJ,CAAC;oBACD,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;gBACrC,CAAC;gBACD,SAAS,EAAE,CAAU,OAAqB,EAAE,EAAE,CAC5C,qBAAqB,CAAC,OAAO,EAAE,OAAO,CAAC;aAC1C,CAAC;YAEF,MAAM,MAAM,GAAG,YAAY,CACzB,SAA0C,EAC1C,QAAQ,EACR;gBACE,OAAO;gBACP,WAAW,EAAE,iBAAiB;gBAC9B,sBAAsB,EAAE,4BAA4B;gBACpD,OAAO,EAAE,QAAQ;aAClB,CACF,CAAC;YAEF,MAAM,CAAC,MAAM,CACX,GAAG,EACH,qBAAqB,CACnB,CAAC,MAAM,IAAI,EAAE,CAA4B,EACzC,QAAQ,CACT,CACF,CAAC;QACJ,CAAC;QAED,OAAO,GAAG,CAAC;IACb,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {\n assertInInjectionContext,\n inject,\n Injector,\n isSignal,\n runInInjectionContext,\n} from './host/craft-compat';\nimport {\n craftComputed as createCraftComputed,\n craftSignal,\n} from './host/craft-signal';\nimport { injectFnWrapper } from './fn-wrapper';\nimport { ɵcreateHostTaggedInjector, ɵHOST_TAG_LIST } from './craft-service';\nimport type {\n CompleteServiceDependencyMapFromYielded,\n SERVICE_HELPER_DEPENDENCIES,\n} from './craft-service';\nimport {\n createNamedPrimitiveGen,\n type NamedCraftPrimitiveGen,\n} from './craft-primitive-gen';\nimport { isSource } from './util/util';\nimport {\n createYieldableInsertionMethod,\n isNonYieldableInsertionMethod,\n isYieldableMethod,\n type BrandReactiveProperties,\n type YieldableInsertionMethods,\n} from './yieldable';\nimport {\n createYieldableReactiveValue,\n isYieldableReactiveValue,\n nameInsertedReactiveValue,\n type YieldableReactiveValue,\n} from './reactive-read';\nimport type { MergeObject } from './util/types/util.type';\nimport {\n ɵdriveMachineGenerator,\n ɵregisterMachineInit,\n ɵrestoreMachineStep,\n ɵrunTransition,\n ɵwithMachineScope,\n ɵwithSuspendedMachine,\n ɵrequireMachineScope,\n type MachineRuntime,\n type MachineTransitionObserver,\n type RuntimeTransitionGuard,\n} from './craft-state-machine-runtime';\n\n// ---------------------------------------------------------------------------\n// Markers\n// ---------------------------------------------------------------------------\n\nconst TRANSITION_STEP_MARKER = Symbol('craft-transition-step');\nconst TRANSITIONS_SETUP_MARKER = Symbol('craft-transitions-setup');\nconst TRANSITION_GUARD_MARKER = Symbol('craft-transition-guard');\n\n/** Type-only carriers. None of these exist at runtime. */\ndeclare const TRANSITION_STEP_YIELDED: unique symbol;\ndeclare const TRANSITIONS_SETUP_CONTEXT: unique symbol;\ndeclare const TRANSITIONS_SETUP_STEPS: unique symbol;\ndeclare const TRANSITIONS_SETUP_YIELDED: unique symbol;\ndeclare const MISSING_INIT_STATE_MACHINE: unique symbol;\n\n/**\n * Phantom request advertised by `initStateMachine(...)`. It is never yielded at\n * runtime; `craftStateMachine` reads it off the transitions' `Yielded` to reject\n * a machine that declares no way to reach its first step.\n */\nexport declare const CRAFT_MACHINE_INIT_REQUEST: unique symbol;\n\nexport interface CraftMachineInitRequest {\n readonly [CRAFT_MACHINE_INIT_REQUEST]: true;\n}\n\n// ---------------------------------------------------------------------------\n// Public types\n// ---------------------------------------------------------------------------\n\n/**\n * What a guard sees. `from` is `undefined` for the very first transition — the\n * one that gives the machine its initial step.\n */\nexport type CraftTransition<\n Context = unknown,\n Steps extends string = string,\n Event = unknown,\n> = {\n readonly from: Steps | undefined;\n readonly to: Steps;\n readonly context: Context;\n readonly event: Event;\n};\n\n/**\n * A guard, built by {@link transitionGuard}. It answers a single transition\n * attempt; a generator guard may `yield*` craft dependencies, which the machine\n * folds into its own dependency graph.\n */\nexport type CraftTransitionGuard<\n Transition = CraftTransition<any, string, any>,\n Yielded = never,\n> = ((\n transition: Transition,\n) => boolean | Generator<Yielded, boolean, unknown>) & {\n readonly [TRANSITION_GUARD_MARKER]: true;\n};\n\n/** A transition attempt: `yield*` it to run it, `.pipe(...)` to guard it. */\nexport type CraftTransitionAttempt<\n Context,\n Event,\n Yielded = never,\n> = Generator<Yielded, boolean, unknown> & {\n readonly pipe: CraftTransitionAttemptPipe<Context, Event, Yielded>;\n};\n\ntype AttemptGuard<Context, Event, Yielded> = CraftTransitionGuard<\n CraftTransition<Context, string, Event>,\n Yielded\n>;\n\nexport interface CraftTransitionAttemptPipe<Context, Event, Yielded> {\n <Y1>(\n guard1: AttemptGuard<Context, Event, Y1>,\n ): CraftTransitionAttempt<Context, Event, Yielded | Y1>;\n <Y1, Y2>(\n guard1: AttemptGuard<Context, Event, Y1>,\n guard2: AttemptGuard<Context, Event, Y2>,\n ): CraftTransitionAttempt<Context, Event, Yielded | Y1 | Y2>;\n <Y1, Y2, Y3>(\n guard1: AttemptGuard<Context, Event, Y1>,\n guard2: AttemptGuard<Context, Event, Y2>,\n guard3: AttemptGuard<Context, Event, Y3>,\n ): CraftTransitionAttempt<Context, Event, Yielded | Y1 | Y2 | Y3>;\n <Y1, Y2, Y3, Y4>(\n guard1: AttemptGuard<Context, Event, Y1>,\n guard2: AttemptGuard<Context, Event, Y2>,\n guard3: AttemptGuard<Context, Event, Y3>,\n guard4: AttemptGuard<Context, Event, Y4>,\n ): CraftTransitionAttempt<Context, Event, Yielded | Y1 | Y2 | Y3 | Y4>;\n}\n\n/**\n * The `transit` handed to the transitions setup. Called inside a\n * `transitionStep('x', ...)` registration, it targets that very step: the step\n * a machine can move to is the step whose block declared the attempt.\n */\nexport interface CraftTransit<Context> {\n (): CraftTransitionAttempt<Context, void>;\n <Event>(event: Event): CraftTransitionAttempt<Context, Event>;\n}\n\ntype StepGuard<Yielded> = CraftTransitionGuard<\n CraftTransition<any, string, any>,\n Yielded\n>;\n\nexport interface CraftTransitionStepPipe<Yielded> {\n <Y1>(guard1: StepGuard<Y1>): CraftTransitionStep<Yielded | Y1>;\n <Y1, Y2>(\n guard1: StepGuard<Y1>,\n guard2: StepGuard<Y2>,\n ): CraftTransitionStep<Yielded | Y1 | Y2>;\n <Y1, Y2, Y3>(\n guard1: StepGuard<Y1>,\n guard2: StepGuard<Y2>,\n guard3: StepGuard<Y3>,\n ): CraftTransitionStep<Yielded | Y1 | Y2 | Y3>;\n <Y1, Y2, Y3, Y4>(\n guard1: StepGuard<Y1>,\n guard2: StepGuard<Y2>,\n guard3: StepGuard<Y3>,\n guard4: StepGuard<Y4>,\n ): CraftTransitionStep<Yielded | Y1 | Y2 | Y3 | Y4>;\n}\n\n/** One entry of the transitions record: how the machine enters that step. */\nexport interface CraftTransitionStep<Yielded = never> {\n readonly [TRANSITION_STEP_MARKER]: true;\n readonly [TRANSITION_STEP_YIELDED]?: Yielded;\n readonly pipe: CraftTransitionStepPipe<Yielded>;\n}\n\ntype AnyStepsRecord = Record<string, CraftTransitionStep<any>>;\n\ntype StepYielded<Step> = typeof TRANSITION_STEP_YIELDED extends keyof Step\n ? Step extends { readonly [TRANSITION_STEP_YIELDED]?: infer Yielded }\n ? Yielded\n : never\n : never;\n\ntype StepsRecordYielded<Steps extends AnyStepsRecord> = {\n [Key in keyof Steps]: StepYielded<Steps[Key]>;\n}[keyof Steps];\n\ntype SetupGuard<Context, Steps extends string, Yielded> = CraftTransitionGuard<\n CraftTransition<Context, Steps, unknown>,\n Yielded\n>;\n\n/** The step names a transitions record declares. */\ntype MachineSteps<StepsRecord> = Extract<keyof StepsRecord, string>;\n\nexport interface CraftTransitionsSetupPipe<\n Context,\n StepsRecord extends AnyStepsRecord,\n Yielded,\n> {\n <Y1>(\n guard1: SetupGuard<Context, MachineSteps<StepsRecord>, Y1>,\n ): CraftTransitionsSetup<Context, StepsRecord, Yielded | Y1>;\n <Y1, Y2>(\n guard1: SetupGuard<Context, MachineSteps<StepsRecord>, Y1>,\n guard2: SetupGuard<Context, MachineSteps<StepsRecord>, Y2>,\n ): CraftTransitionsSetup<Context, StepsRecord, Yielded | Y1 | Y2>;\n <Y1, Y2, Y3>(\n guard1: SetupGuard<Context, MachineSteps<StepsRecord>, Y1>,\n guard2: SetupGuard<Context, MachineSteps<StepsRecord>, Y2>,\n guard3: SetupGuard<Context, MachineSteps<StepsRecord>, Y3>,\n ): CraftTransitionsSetup<Context, StepsRecord, Yielded | Y1 | Y2 | Y3>;\n <Y1, Y2, Y3, Y4>(\n guard1: SetupGuard<Context, MachineSteps<StepsRecord>, Y1>,\n guard2: SetupGuard<Context, MachineSteps<StepsRecord>, Y2>,\n guard3: SetupGuard<Context, MachineSteps<StepsRecord>, Y3>,\n guard4: SetupGuard<Context, MachineSteps<StepsRecord>, Y4>,\n ): CraftTransitionsSetup<Context, StepsRecord, Yielded | Y1 | Y2 | Y3 | Y4>;\n}\n\n/**\n * The setup generator itself: the form `craftStateMachine` takes when the\n * transitions carry no machine-wide guard. `Context` is contextually typed by\n * the machine, so the parameter needs no annotation here.\n */\nexport type CraftTransitionsSetupFn<\n Context,\n StepsRecord extends AnyStepsRecord,\n Yielded,\n> = (\n context: Context,\n transit: CraftTransit<Context>,\n) => Generator<Yielded, StepsRecord, unknown>;\n\n/**\n * The transitions once {@link transitionsSetup} has wrapped them, which is what\n * carries `.pipe(...)`. `Context` travels contravariantly so `craftStateMachine`\n * accepts a setup whose annotated context is satisfied by the machine's actual\n * context, and refuses one that asks for more.\n */\nexport interface CraftTransitionsSetup<\n Context,\n StepsRecord extends AnyStepsRecord,\n Yielded = never,\n> {\n readonly [TRANSITIONS_SETUP_MARKER]: true;\n readonly [TRANSITIONS_SETUP_CONTEXT]?: (context: Context) => void;\n readonly [TRANSITIONS_SETUP_STEPS]?: StepsRecord;\n readonly [TRANSITIONS_SETUP_YIELDED]?: Yielded;\n readonly pipe: CraftTransitionsSetupPipe<Context, StepsRecord, Yielded>;\n}\n\n/**\n * What `craftStateMachine` accepts as its transitions: the bare setup\n * generator, or the same generator wrapped in {@link transitionsSetup} when a\n * machine-wide guard has to be piped onto it.\n */\nexport type CraftTransitionsInput<\n Context,\n StepsRecord extends AnyStepsRecord,\n Yielded,\n> =\n | CraftTransitionsSetupFn<Context, StepsRecord, Yielded>\n | CraftTransitionsSetup<Context, StepsRecord, Yielded>;\n\n/**\n * `yield* initStateMachine(...)` is not optional: without it nothing would ever\n * give the machine its first step. The obligation is enforced here, by making\n * the transitions argument unassignable until the marker shows up.\n */\nexport type CraftMachineInitRequirement<Yielded> = [\n Extract<Yielded, CraftMachineInitRequest>,\n] extends [never]\n ? {\n readonly [MISSING_INIT_STATE_MACHINE]: 'This state machine never initialises: add `yield* initStateMachine(() => transit())` to one of its transitionStep(...) blocks.';\n }\n : unknown;\n\n/** The registration value the machine-scoped helpers resolve to. */\nexport type CraftMachineRegistration<Yielded = never> = Generator<\n Yielded,\n void,\n unknown\n>;\n\n/** Reads the context type a `craftStateMachine` context factory produces. */\nexport type CraftMachineContext<ContextFactory> = ContextFactory extends (\n ...args: any[]\n) => Generator<any, infer Context, any>\n ? Context\n : ContextFactory extends (...args: any[]) => infer Context\n ? Context\n : never;\n\ntype CurrentStepWithContextForStep<StepContexts, Step extends string> =\n Step extends keyof StepContexts\n ? StepContexts[Step] extends object\n ? { readonly step: Step } & StepContexts[Step]\n : { readonly step: Step; readonly context: StepContexts[Step] }\n : { readonly step: Step; readonly context: unknown };\n\ntype CurrentStepWithContextValue<\n StepContexts,\n Steps extends string,\n> = Steps extends string\n ? CurrentStepWithContextForStep<StepContexts, Steps>\n : never;\n\n/** One decided transition attempt, as an insertion observes it. */\nexport type CraftMachineTransition<Steps extends string = string> = Readonly<{\n from: Steps | undefined;\n to: Steps;\n event: unknown;\n accepted: boolean;\n}>;\n\n/**\n * The machine's own controls, handed to its insertion. This is what a feature\n * built on top of the machine — a history, a replay — needs and the machine\n * core deliberately does not provide itself.\n */\nexport type CraftMachineControls<Steps extends string = string> = Readonly<{\n /** Host chain of the machine, to scope a registry capture to what it owns. */\n hostTags: readonly string[];\n /** Observes every decided attempt, accepted or refused. Returns a release. */\n onTransition(\n observer: (transition: CraftMachineTransition<Steps>) => void,\n ): () => void;\n /** Moves to a step without consulting any guard. */\n restoreStep(step: Steps): void;\n /** Runs `restore` with the machine's registrations muted. */\n suspended<Result>(restore: () => Result): Result;\n}>;\n\nexport type CraftMachineInsertionContext<\n Context,\n Steps extends string,\n StepContexts,\n> = {\n readonly context: Context;\n readonly currentStep: YieldableReactiveValue<Steps, 'currentStep'>;\n readonly currentStepWithContext: YieldableReactiveValue<\n CurrentStepWithContextValue<StepContexts, Steps>,\n 'currentStepWithContext'\n >;\n readonly machine: CraftMachineControls<Steps>;\n};\n\nexport type CraftStateMachineOutput<\n Context,\n Steps extends string,\n StepContexts,\n Insertions,\n Dependencies = {},\n> = MergeObject<\n {\n readonly currentStep: YieldableReactiveValue<Steps, 'currentStep'>;\n readonly currentStepWithContext: YieldableReactiveValue<\n CurrentStepWithContextValue<StepContexts, Steps>,\n 'currentStepWithContext'\n >;\n readonly context: Context;\n },\n MergeObject<\n BrandReactiveProperties<YieldableInsertionMethods<Insertions>>,\n { readonly [SERVICE_HELPER_DEPENDENCIES]?: Dependencies }\n >\n>;\n\n// ---------------------------------------------------------------------------\n// Authoring surface\n// ---------------------------------------------------------------------------\n\n/**\n * Wraps a predicate into a transition guard. Accepts a plain lambda or a\n * generator; a generator guard resolves craft dependencies with `yield*`, and\n * those dependencies join the machine's dependency graph.\n *\n * ```ts\n * transitionGuard(({ context }) => context.form.isValid());\n *\n * transitionGuard(function* ({ context, from, to, event }) {\n * const policy = yield* PolicyService();\n * return policy.canTransition({ from, to, event });\n * });\n * ```\n */\nexport function transitionGuard<\n Transition extends CraftTransition<any, any, any>,\n Yielded = never,\n>(\n guard: (\n transition: Transition,\n ) => boolean | Generator<Yielded, boolean, unknown>,\n): CraftTransitionGuard<Transition, Yielded> {\n return Object.assign(guard, {\n [TRANSITION_GUARD_MARKER]: true as const,\n }) as CraftTransitionGuard<Transition, Yielded>;\n}\n\n/**\n * Declares how a machine enters one step. The generator runs once, at machine\n * creation, and registers the reactions that may move the machine here\n * (`on$`, `afterRecomputation`, `initStateMachine`).\n *\n * `transitionStep(...).pipe(transitionGuard(...))` guards every transition\n * declared in that step.\n */\nexport function transitionStep<Yielded = never>(\n setup: () => Generator<Yielded, unknown, unknown> | void,\n): CraftTransitionStep<Yielded> {\n return createTransitionStep(setup as () => unknown, []);\n}\n\n/**\n * Builds every transition of a machine. The setup generator receives the\n * machine `context` and `transit`, and returns one {@link transitionStep} per\n * step; the record's keys ARE the machine's steps.\n *\n * `transitionsSetup(...).pipe(transitionGuard(...))` guards every transition of\n * every step.\n *\n * Declared standalone, the setup's `context` parameter has to be annotated —\n * typically with `CraftMachineContext<typeof contextFactory>`; `craftStateMachine`\n * then checks the machine's real context against that annotation.\n */\nexport function transitionsSetup<\n Context,\n StepsRecord extends AnyStepsRecord,\n SetupYielded = never,\n>(\n setup: CraftTransitionsSetupFn<Context, StepsRecord, SetupYielded>,\n): CraftTransitionsSetup<Context, StepsRecord, SetupYielded> {\n return createTransitionsSetup(\n setup as unknown as (context: unknown, transit: unknown) => unknown,\n [],\n ) as unknown as CraftTransitionsSetup<Context, StepsRecord, SetupYielded>;\n}\n\n/**\n * Registers the callback that gives the machine its initial step. Registrations\n * run after every step has been installed, in declaration order, and the first\n * accepted `transit()` wins — later init registrations are skipped.\n *\n * ```ts\n * yield* initStateMachine(() => transit());\n * ```\n */\nexport function initStateMachine<Yielded = never>(\n callback: () => Generator<Yielded, unknown, unknown> | void,\n): CraftMachineRegistration<Yielded | CraftMachineInitRequest> {\n return ɵregisterMachineInit(callback as () => unknown) as CraftMachineRegistration<\n Yielded | CraftMachineInitRequest\n >;\n}\n\n// ---------------------------------------------------------------------------\n// craftStateMachine\n// ---------------------------------------------------------------------------\n\ntype ContextFactory<Yielded, Context> = () => Generator<\n Yielded,\n Context,\n unknown\n>;\n\ntype CurrentStepWithContextFactory<Context, Yielded, StepContexts> = (\n context: Context,\n) => Generator<Yielded, StepContexts, unknown>;\n\ntype MachineInsertion<Context, Steps extends string, StepContexts, Yielded, Insertions> =\n (\n context: CraftMachineInsertionContext<Context, Steps, StepContexts>,\n ) => Generator<Yielded, Insertions, unknown> | Insertions;\n\n/** Everything the transitions advertise: the setup's yields plus each step's. */\ntype MachineYielded<SetupYielded, StepsRecord extends AnyStepsRecord> =\n | SetupYielded\n | StepsRecordYielded<StepsRecord>;\n\ntype MachineDependencies<\n ContextYielded,\n TransitionsYielded,\n StepContextYielded,\n InsertionYielded,\n> = CompleteServiceDependencyMapFromYielded<\n ContextYielded | TransitionsYielded | StepContextYielded | InsertionYielded\n>;\n\nexport function craftStateMachine<\n Name extends string,\n ContextYielded,\n Context extends object,\n StepsRecord extends AnyStepsRecord,\n SetupYielded,\n StepContextYielded,\n StepContexts extends Record<MachineSteps<StepsRecord>, unknown>,\n InsertionYielded,\n Insertions,\n>(\n name: Name,\n contextFactory: ContextFactory<ContextYielded, Context>,\n transitions: CraftTransitionsInput<\n NoInfer<Context>,\n StepsRecord,\n SetupYielded\n > &\n CraftMachineInitRequirement<MachineYielded<SetupYielded, StepsRecord>>,\n currentStepWithContextFactory: CurrentStepWithContextFactory<\n NoInfer<Context>,\n StepContextYielded,\n StepContexts\n >,\n insertion: MachineInsertion<\n NoInfer<Context>,\n NoInfer<MachineSteps<StepsRecord>>,\n NoInfer<StepContexts>,\n InsertionYielded,\n Insertions\n >,\n): NamedCraftPrimitiveGen<\n Name,\n CraftStateMachineOutput<\n Context,\n MachineSteps<StepsRecord>,\n StepContexts,\n Insertions,\n MachineDependencies<\n ContextYielded,\n MachineYielded<SetupYielded, StepsRecord>,\n StepContextYielded,\n InsertionYielded\n >\n >\n>;\nexport function craftStateMachine<\n Name extends string,\n ContextYielded,\n Context extends object,\n StepsRecord extends AnyStepsRecord,\n SetupYielded,\n StepContextYielded,\n StepContexts extends Record<MachineSteps<StepsRecord>, unknown>,\n>(\n name: Name,\n contextFactory: ContextFactory<ContextYielded, Context>,\n transitions: CraftTransitionsInput<\n NoInfer<Context>,\n StepsRecord,\n SetupYielded\n > &\n CraftMachineInitRequirement<MachineYielded<SetupYielded, StepsRecord>>,\n currentStepWithContextFactory: CurrentStepWithContextFactory<\n NoInfer<Context>,\n StepContextYielded,\n StepContexts\n >,\n): NamedCraftPrimitiveGen<\n Name,\n CraftStateMachineOutput<\n Context,\n MachineSteps<StepsRecord>,\n StepContexts,\n {},\n MachineDependencies<\n ContextYielded,\n MachineYielded<SetupYielded, StepsRecord>,\n StepContextYielded,\n never\n >\n >\n>;\nexport function craftStateMachine<\n ContextYielded,\n Context extends object,\n StepsRecord extends AnyStepsRecord,\n SetupYielded,\n StepContextYielded,\n StepContexts extends Record<MachineSteps<StepsRecord>, unknown>,\n InsertionYielded,\n Insertions,\n>(\n contextFactory: ContextFactory<ContextYielded, Context>,\n transitions: CraftTransitionsInput<\n NoInfer<Context>,\n StepsRecord,\n SetupYielded\n > &\n CraftMachineInitRequirement<MachineYielded<SetupYielded, StepsRecord>>,\n currentStepWithContextFactory: CurrentStepWithContextFactory<\n NoInfer<Context>,\n StepContextYielded,\n StepContexts\n >,\n insertion: MachineInsertion<\n NoInfer<Context>,\n NoInfer<MachineSteps<StepsRecord>>,\n NoInfer<StepContexts>,\n InsertionYielded,\n Insertions\n >,\n): NamedCraftPrimitiveGen<\n 'stateMachine',\n CraftStateMachineOutput<\n Context,\n MachineSteps<StepsRecord>,\n StepContexts,\n Insertions,\n MachineDependencies<\n ContextYielded,\n MachineYielded<SetupYielded, StepsRecord>,\n StepContextYielded,\n InsertionYielded\n >\n >\n>;\nexport function craftStateMachine<\n ContextYielded,\n Context extends object,\n StepsRecord extends AnyStepsRecord,\n SetupYielded,\n StepContextYielded,\n StepContexts extends Record<MachineSteps<StepsRecord>, unknown>,\n>(\n contextFactory: ContextFactory<ContextYielded, Context>,\n transitions: CraftTransitionsInput<\n NoInfer<Context>,\n StepsRecord,\n SetupYielded\n > &\n CraftMachineInitRequirement<MachineYielded<SetupYielded, StepsRecord>>,\n currentStepWithContextFactory: CurrentStepWithContextFactory<\n NoInfer<Context>,\n StepContextYielded,\n StepContexts\n >,\n): NamedCraftPrimitiveGen<\n 'stateMachine',\n CraftStateMachineOutput<\n Context,\n MachineSteps<StepsRecord>,\n StepContexts,\n {},\n MachineDependencies<\n ContextYielded,\n MachineYielded<SetupYielded, StepsRecord>,\n StepContextYielded,\n never\n >\n >\n>;\nexport function craftStateMachine(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n nameOrContextFactory: any,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n contextFactoryOrTransitions?: any,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n transitionsOrCurrentStepWithContextFactory?: any,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n currentStepWithContextFactoryOrInsertion?: any,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n maybeInsertion?: any,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): any {\n const isNamed = typeof nameOrContextFactory === 'string';\n const name = isNamed ? nameOrContextFactory : 'stateMachine';\n const contextFactory = isNamed\n ? contextFactoryOrTransitions\n : nameOrContextFactory;\n const transitions = isNamed\n ? transitionsOrCurrentStepWithContextFactory\n : contextFactoryOrTransitions;\n const currentStepWithContextFactory = isNamed\n ? currentStepWithContextFactoryOrInsertion\n : transitionsOrCurrentStepWithContextFactory;\n const insertion = isNamed\n ? maybeInsertion\n : currentStepWithContextFactoryOrInsertion;\n\n const ref = createStateMachineRef(\n name,\n contextFactory,\n transitions,\n currentStepWithContextFactory,\n insertion,\n );\n\n return createNamedPrimitiveGen(name, ref);\n}\n\n// ---------------------------------------------------------------------------\n// Runtime\n// ---------------------------------------------------------------------------\n\ntype RuntimeTransitionStep = {\n readonly [TRANSITION_STEP_MARKER]: true;\n readonly setup: () => unknown;\n readonly guards: readonly RuntimeTransitionGuard[];\n readonly pipe: (...guards: RuntimeTransitionGuard[]) => RuntimeTransitionStep;\n};\n\ntype RuntimeTransitionsSetup = {\n readonly [TRANSITIONS_SETUP_MARKER]: true;\n readonly setup: (context: unknown, transit: unknown) => unknown;\n readonly guards: readonly RuntimeTransitionGuard[];\n readonly pipe: (\n ...guards: RuntimeTransitionGuard[]\n ) => RuntimeTransitionsSetup;\n};\n\nfunction createTransitionStep(\n setup: () => unknown,\n guards: readonly RuntimeTransitionGuard[],\n): RuntimeTransitionStep & CraftTransitionStep<any> {\n const step = {\n [TRANSITION_STEP_MARKER]: true as const,\n setup,\n guards,\n pipe: (...extraGuards: RuntimeTransitionGuard[]) =>\n createTransitionStep(setup, [...guards, ...extraGuards]),\n };\n\n return step as RuntimeTransitionStep & CraftTransitionStep<any>;\n}\n\nfunction createTransitionsSetup(\n setup: (context: unknown, transit: unknown) => unknown,\n guards: readonly RuntimeTransitionGuard[],\n): RuntimeTransitionsSetup {\n return {\n [TRANSITIONS_SETUP_MARKER]: true as const,\n setup,\n guards,\n pipe: (...extraGuards: RuntimeTransitionGuard[]) =>\n createTransitionsSetup(setup, [...guards, ...extraGuards]),\n };\n}\n\nfunction createTransitionAttempt(\n event: unknown,\n localGuards: readonly RuntimeTransitionGuard[],\n): Generator<unknown, boolean, unknown> {\n // The scope is captured at CREATION time: `transit(...)` is called from inside\n // a registration callback, which the machine runs with its declaring step\n // restored. Reading it lazily would resolve the wrong target.\n const scope = ɵrequireMachineScope('transit(...)');\n const attempt = ɵrunTransition(scope, event, localGuards);\n\n return Object.assign(attempt, {\n pipe: (...guards: RuntimeTransitionGuard[]) =>\n ɵwithMachineScope(scope, () =>\n createTransitionAttempt(event, [...localGuards, ...guards]),\n ),\n });\n}\n\nfunction createTransit(): (event?: unknown) => unknown {\n return (event?: unknown) => createTransitionAttempt(event, []);\n}\n\nfunction isStepsRecord(value: unknown): value is Record<string, RuntimeTransitionStep> {\n return typeof value === 'object' && value !== null;\n}\n\nfunction driveFactory(\n factory: (...args: never[]) => unknown,\n injector: Injector,\n ...args: unknown[]\n): unknown {\n const wrapped = runInInjectionContext(injector, () =>\n injectFnWrapper()(factory as (...values: unknown[]) => unknown),\n );\n\n return runInInjectionContext(injector, () =>\n ɵdriveMachineGenerator(wrapped(...args), injector),\n );\n}\n\nfunction exposeInsertionOutput(\n output: Record<string, unknown>,\n injector: Injector,\n): Record<string, unknown> {\n return Object.entries(output).reduce(\n (exposed, [key, value]) => {\n if (isYieldableReactiveValue(value)) {\n exposed[key] = nameInsertedReactiveValue(\n value,\n key,\n 'craftStateMachine',\n `craftStateMachine.${key}`,\n );\n return exposed;\n }\n\n if (isSource(value) || isSignal(value) || isYieldableMethod(value)) {\n exposed[key] = value;\n return exposed;\n }\n\n if (typeof value === 'function' && !isNonYieldableInsertionMethod(value)) {\n const methodInjector = ɵcreateHostTaggedInjector(\n injector,\n `method:${key}`,\n );\n const wrappedFn = runInInjectionContext(methodInjector, () =>\n injectFnWrapper()(value as (...args: unknown[]) => unknown),\n );\n exposed[key] = createYieldableInsertionMethod(wrappedFn, {\n injector: methodInjector,\n invalidYieldErrorMessage:\n 'craftStateMachine insertion method generators can only yield craftService dependencies or exposed dependency helpers.',\n multipleAppStartErrorMessage:\n 'craftStateMachine insertion methods do not support multiple onAppStart(...) declarations.',\n onAppStartNotSupportedErrorMessage:\n 'craftStateMachine insertion methods do not support onAppStart(...).',\n });\n return exposed;\n }\n\n exposed[key] = value;\n return exposed;\n },\n {} as Record<string, unknown>,\n );\n}\n\n/**\n * Normalises the two accepted forms: a bare setup generator carries no\n * machine-wide guard, so it becomes a setup with an empty guard list.\n */\nfunction toRuntimeTransitionsSetup(\n transitions: RuntimeTransitionsSetup | ((...args: never[]) => unknown),\n): RuntimeTransitionsSetup {\n return typeof transitions === 'function'\n ? createTransitionsSetup(\n transitions as unknown as (context: unknown, transit: unknown) => unknown,\n [],\n )\n : transitions;\n}\n\nfunction createStateMachineRef(\n name: string,\n contextFactory: () => unknown,\n transitionsInput: RuntimeTransitionsSetup | ((...args: never[]) => unknown),\n currentStepWithContextFactory?: (context: unknown) => unknown,\n insertion?: (context: unknown) => unknown,\n): Record<string, unknown> {\n assertInInjectionContext(craftStateMachine);\n const transitions = toRuntimeTransitionsSetup(transitionsInput);\n const injector = ɵcreateHostTaggedInjector(\n inject(Injector),\n `stateMachine:${name}`,\n );\n\n return runInInjectionContext(injector, () => {\n const context = driveFactory(contextFactory, injector) as Record<\n string,\n unknown\n >;\n\n const stepContexts = (\n currentStepWithContextFactory\n ? driveFactory(\n currentStepWithContextFactory as (...args: never[]) => unknown,\n injector,\n context,\n )\n : {}\n ) as Record<string, unknown>;\n\n const currentStep = craftSignal<string | undefined>(undefined);\n const runtime: MachineRuntime = {\n context,\n currentStep,\n globalGuards: transitions.guards,\n stepGuards: new Map(),\n injector,\n initRegistrations: [],\n observers: new Set(),\n suspended: false,\n };\n\n const stepsRecord = driveFactory(\n transitions.setup as (...args: never[]) => unknown,\n injector,\n context,\n createTransit(),\n );\n\n if (!isStepsRecord(stepsRecord)) {\n throw new Error(\n 'transitionsSetup(...) must return a record of transitionStep(...) entries.',\n );\n }\n\n for (const [step, definition] of Object.entries(stepsRecord)) {\n runtime.stepGuards.set(step, definition.guards ?? []);\n }\n\n for (const [step, definition] of Object.entries(stepsRecord)) {\n ɵwithMachineScope({ runtime, target: step }, () =>\n runInInjectionContext(injector, () =>\n ɵdriveMachineGenerator(definition.setup(), injector),\n ),\n );\n }\n\n // Installation is over: the machine can now take its initial step. The\n // first accepted transit wins, so a later registration is not even run.\n for (const registration of runtime.initRegistrations) {\n if (currentStep() !== undefined) {\n break;\n }\n registration();\n }\n\n if (currentStep() === undefined) {\n throw new Error(\n `craftStateMachine \"${name}\" did not initialise: its initial transition was rejected by a guard.`,\n );\n }\n\n const currentStepReader = createYieldableReactiveValue(\n currentStep.asReadonly(),\n 'currentStep',\n );\n const currentStepWithContextReader = createYieldableReactiveValue(\n createCraftComputed(() => {\n const step = currentStep();\n if (step === undefined) return undefined;\n return Object.assign({}, stepContexts[step] as object, { step });\n }),\n 'currentStepWithContext',\n );\n\n const ref: Record<string, unknown> = {\n currentStep: currentStepReader,\n currentStepWithContext: currentStepWithContextReader,\n context,\n };\n\n if (insertion) {\n const controls = {\n hostTags: injector.get(ɵHOST_TAG_LIST, []) as readonly string[],\n onTransition: (observer: MachineTransitionObserver) => {\n runtime.observers.add(observer);\n return () => runtime.observers.delete(observer);\n },\n restoreStep: (step: string) => {\n if (step === undefined) {\n throw new Error(\n `craftStateMachine \"${name}\" cannot restore an undefined step.`,\n );\n }\n ɵrestoreMachineStep(runtime, step);\n },\n suspended: <Result,>(restore: () => Result) =>\n ɵwithSuspendedMachine(runtime, restore),\n };\n\n const output = driveFactory(\n insertion as (...args: never[]) => unknown,\n injector,\n {\n context,\n currentStep: currentStepReader,\n currentStepWithContext: currentStepWithContextReader,\n machine: controls,\n },\n );\n\n Object.assign(\n ref,\n exposeInsertionOutput(\n (output ?? {}) as Record<string, unknown>,\n injector,\n ),\n );\n }\n\n return ref;\n });\n}\n"]}
@@ -0,0 +1,20 @@
1
+ import { InjectionToken, type Injector, type Provider } from './host/craft-compat';
2
+ export type CraftTargetKind = 'component' | 'directive';
3
+ export type CraftTargetContext = Readonly<{
4
+ target: unknown;
5
+ kind: CraftTargetKind;
6
+ name: string;
7
+ ref: unknown;
8
+ hostName: string;
9
+ injector: Injector;
10
+ }>;
11
+ export type CraftTargetContextOverrides = Readonly<{
12
+ hostName?: string;
13
+ }>;
14
+ export type CraftTargetRelease = () => void;
15
+ export type CraftTargetWrapper = (context: CraftTargetContext, next: (overrides?: CraftTargetContextOverrides) => Generator<unknown, CraftTargetRelease, unknown>) => Generator<unknown, CraftTargetRelease, unknown>;
16
+ export declare const CRAFT_TARGET_WRAPPER: InjectionToken<readonly CraftTargetWrapper[]>;
17
+ /** Adds a wrapper around the lifecycle registration of Craft targets. */
18
+ export declare function provideCraftTargetWrapper(_warning: string, wrapper: CraftTargetWrapper): Provider;
19
+ export declare function ɵrunCraftTargetWrappers(injector: Injector, context: CraftTargetContext, autoCleanup: boolean): CraftTargetRelease;
20
+ //# sourceMappingURL=craft-target-runtime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"craft-target-runtime.d.ts","sourceRoot":"","sources":["../../../../../libs/core/src/lib/craft-target-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,cAAc,EACd,KAAK,QAAQ,EACb,KAAK,QAAQ,EACd,MAAM,qBAAqB,CAAC;AAG7B,MAAM,MAAM,eAAe,GAAG,WAAW,GAAG,WAAW,CAAC;AAExD,MAAM,MAAM,kBAAkB,GAAG,QAAQ,CAAC;IACxC,MAAM,EAAE,OAAO,CAAC;IAChB,IAAI,EAAE,eAAe,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,OAAO,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,QAAQ,CAAC;CACpB,CAAC,CAAC;AAEH,MAAM,MAAM,2BAA2B,GAAG,QAAQ,CAAC;IACjD,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC,CAAC;AAEH,MAAM,MAAM,kBAAkB,GAAG,MAAM,IAAI,CAAC;AAE5C,MAAM,MAAM,kBAAkB,GAAG,CAC/B,OAAO,EAAE,kBAAkB,EAC3B,IAAI,EAAE,CACJ,SAAS,CAAC,EAAE,2BAA2B,KACpC,SAAS,CAAC,OAAO,EAAE,kBAAkB,EAAE,OAAO,CAAC,KACjD,SAAS,CAAC,OAAO,EAAE,kBAAkB,EAAE,OAAO,CAAC,CAAC;AAErD,eAAO,MAAM,oBAAoB,+CAM/B,CAAC;AAEH,yEAAyE;AACzE,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,kBAAkB,GAC1B,QAAQ,CAMV;AAOD,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,kBAAkB,EAC3B,WAAW,EAAE,OAAO,GACnB,kBAAkB,CAgCpB"}
@@ -0,0 +1,42 @@
1
+ import { DestroyRef, InjectionToken, } from './host/craft-compat';
2
+ import { runCraftGenerator } from './craft-generator-runtime';
3
+ export const CRAFT_TARGET_WRAPPER = new InjectionToken('CRAFT_TARGET_WRAPPER', {
4
+ providedIn: 'root',
5
+ factory: () => [],
6
+ multi: true,
7
+ });
8
+ /** Adds a wrapper around the lifecycle registration of Craft targets. */
9
+ export function provideCraftTargetWrapper(_warning, wrapper) {
10
+ return {
11
+ provide: CRAFT_TARGET_WRAPPER,
12
+ useValue: wrapper,
13
+ multi: true,
14
+ };
15
+ }
16
+ const EMPTY_RELEASE = () => undefined;
17
+ export function ɵrunCraftTargetWrappers(injector, context, autoCleanup) {
18
+ const wrappers = injector.get(CRAFT_TARGET_WRAPPER, []);
19
+ let next = function* () {
20
+ return EMPTY_RELEASE;
21
+ };
22
+ for (let index = wrappers.length - 1; index >= 0; index -= 1) {
23
+ const wrapper = wrappers[index];
24
+ const inner = next;
25
+ next = (current) => (function* () {
26
+ return yield* wrapper(current, (overrides) => inner({ ...current, ...overrides }));
27
+ })();
28
+ }
29
+ const release = runCraftGenerator({
30
+ iterator: next(context),
31
+ injector,
32
+ hostScope: 'function',
33
+ invalidYieldErrorMessage: 'Craft target wrappers can only yield Craft dependencies.',
34
+ multipleAppStartErrorMessage: 'Craft target wrappers cannot declare app-start hooks more than once.',
35
+ onAppStartNotSupportedErrorMessage: 'Craft target wrappers cannot declare app-start hooks.',
36
+ }).value;
37
+ if (autoCleanup) {
38
+ injector.get(DestroyRef, null)?.onDestroy(release);
39
+ }
40
+ return release;
41
+ }
42
+ //# sourceMappingURL=craft-target-runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"craft-target-runtime.js","sourceRoot":"","sources":["../../../../../libs/core/src/lib/craft-target-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,cAAc,GAGf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AA0B9D,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,cAAc,CAEpD,sBAAsB,EAAE;IACxB,UAAU,EAAE,MAAM;IAClB,OAAO,EAAE,GAAG,EAAE,CAAC,EAAE;IACjB,KAAK,EAAE,IAAI;CACZ,CAAC,CAAC;AAEH,yEAAyE;AACzE,MAAM,UAAU,yBAAyB,CACvC,QAAgB,EAChB,OAA2B;IAE3B,OAAO;QACL,OAAO,EAAE,oBAAoB;QAC7B,QAAQ,EAAE,OAAO;QACjB,KAAK,EAAE,IAAI;KACZ,CAAC;AACJ,CAAC;AAED,MAAM,aAAa,GAAuB,GAAG,EAAE,CAAC,SAAS,CAAC;AAK1D,MAAM,UAAU,uBAAuB,CACrC,QAAkB,EAClB,OAA2B,EAC3B,WAAoB;IAEpB,MAAM,QAAQ,GAAG,QAAQ,CAAC,GAAG,CAAC,oBAAoB,EAAE,EAAE,CAAC,CAAC;IACxD,IAAI,IAAI,GAA6B,QAAQ,CAAC;QAC5C,OAAO,aAAa,CAAC;IACvB,CAAC,CAAC;IAEF,KAAK,IAAI,KAAK,GAAG,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;QAC7D,MAAM,OAAO,GAAG,QAAQ,CAAC,KAAK,CAAE,CAAC;QACjC,MAAM,KAAK,GAAG,IAAI,CAAC;QACnB,IAAI,GAAG,CAAC,OAAO,EAAE,EAAE,CACjB,CAAC,QAAQ,CAAC;YACR,OAAO,KAAK,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,SAAS,EAAE,EAAE,CAC3C,KAAK,CAAC,EAAE,GAAG,OAAO,EAAE,GAAG,SAAS,EAAE,CAAC,CACpC,CAAC;QACJ,CAAC,CAAC,EAAE,CAAC;IACT,CAAC;IAED,MAAM,OAAO,GAAG,iBAAiB,CAAC;QAChC,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC;QACvB,QAAQ;QACR,SAAS,EAAE,UAAU;QACrB,wBAAwB,EACtB,0DAA0D;QAC5D,4BAA4B,EAC1B,sEAAsE;QACxE,kCAAkC,EAChC,uDAAuD;KAC1D,CAAC,CAAC,KAA2B,CAAC;IAC/B,IAAI,WAAW,EAAE,CAAC;QAChB,QAAQ,CAAC,GAAG,CAAC,UAAU,EAAE,IAAI,CAAC,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;IACrD,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import {\n DestroyRef,\n InjectionToken,\n type Injector,\n type Provider,\n} from './host/craft-compat';\nimport { runCraftGenerator } from './craft-generator-runtime';\n\nexport type CraftTargetKind = 'component' | 'directive';\n\nexport type CraftTargetContext = Readonly<{\n target: unknown;\n kind: CraftTargetKind;\n name: string;\n ref: unknown;\n hostName: string;\n injector: Injector;\n}>;\n\nexport type CraftTargetContextOverrides = Readonly<{\n hostName?: string;\n}>;\n\nexport type CraftTargetRelease = () => void;\n\nexport type CraftTargetWrapper = (\n context: CraftTargetContext,\n next: (\n overrides?: CraftTargetContextOverrides,\n ) => Generator<unknown, CraftTargetRelease, unknown>,\n) => Generator<unknown, CraftTargetRelease, unknown>;\n\nexport const CRAFT_TARGET_WRAPPER = new InjectionToken<\n readonly CraftTargetWrapper[]\n>('CRAFT_TARGET_WRAPPER', {\n providedIn: 'root',\n factory: () => [],\n multi: true,\n});\n\n/** Adds a wrapper around the lifecycle registration of Craft targets. */\nexport function provideCraftTargetWrapper(\n _warning: string,\n wrapper: CraftTargetWrapper,\n): Provider {\n return {\n provide: CRAFT_TARGET_WRAPPER,\n useValue: wrapper,\n multi: true,\n };\n}\n\nconst EMPTY_RELEASE: CraftTargetRelease = () => undefined;\ntype CraftTargetWrapperRunner = (\n context: CraftTargetContext,\n) => Generator<unknown, CraftTargetRelease, unknown>;\n\nexport function ɵrunCraftTargetWrappers(\n injector: Injector,\n context: CraftTargetContext,\n autoCleanup: boolean,\n): CraftTargetRelease {\n const wrappers = injector.get(CRAFT_TARGET_WRAPPER, []);\n let next: CraftTargetWrapperRunner = function* () {\n return EMPTY_RELEASE;\n };\n\n for (let index = wrappers.length - 1; index >= 0; index -= 1) {\n const wrapper = wrappers[index]!;\n const inner = next;\n next = (current) =>\n (function* () {\n return yield* wrapper(current, (overrides) =>\n inner({ ...current, ...overrides }),\n );\n })();\n }\n\n const release = runCraftGenerator({\n iterator: next(context),\n injector,\n hostScope: 'function',\n invalidYieldErrorMessage:\n 'Craft target wrappers can only yield Craft dependencies.',\n multipleAppStartErrorMessage:\n 'Craft target wrappers cannot declare app-start hooks more than once.',\n onAppStartNotSupportedErrorMessage:\n 'Craft target wrappers cannot declare app-start hooks.',\n }).value as CraftTargetRelease;\n if (autoCleanup) {\n injector.get(DestroyRef, null)?.onDestroy(release);\n }\n return release;\n}\n"]}
@@ -0,0 +1,19 @@
1
+ import type { CraftPrimitiveRegistry } from './craft-primitive-registry';
2
+ export declare const CRAFT_TRANSFER_SNAPSHOT_VERSION = 1;
3
+ export type CraftTransferQuerySnapshot = Readonly<{
4
+ status: string;
5
+ value?: unknown;
6
+ error?: unknown;
7
+ }>;
8
+ export type CraftTransferSnapshot = Readonly<{
9
+ version: number;
10
+ values: Readonly<Record<string, unknown>>;
11
+ queries: Readonly<Record<string, CraftTransferQuerySnapshot>>;
12
+ }>;
13
+ /** Captures only JSON-compatible state; non-serializable entries fail loudly. */
14
+ export declare function captureCraftTransferSnapshot(registry: CraftPrimitiveRegistry): CraftTransferSnapshot;
15
+ /** Primes registrations that will be created during the first client render. */
16
+ export declare function primeCraftTransferSnapshot(registry: CraftPrimitiveRegistry, snapshot: CraftTransferSnapshot): void;
17
+ /** JSON safe for embedding in an HTML script element. */
18
+ export declare function serializeCraftTransferSnapshot(snapshot: CraftTransferSnapshot): string;
19
+ //# sourceMappingURL=craft-transfer-snapshot.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"craft-transfer-snapshot.d.ts","sourceRoot":"","sources":["../../../../../libs/core/src/lib/craft-transfer-snapshot.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,sBAAsB,EACvB,MAAM,4BAA4B,CAAC;AAEpC,eAAO,MAAM,+BAA+B,IAAI,CAAC;AAEjD,MAAM,MAAM,0BAA0B,GAAG,QAAQ,CAAC;IAChD,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC,CAAC;AAEH,MAAM,MAAM,qBAAqB,GAAG,QAAQ,CAAC;IAC3C,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAC1C,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,0BAA0B,CAAC,CAAC,CAAC;CAC/D,CAAC,CAAC;AAEH,iFAAiF;AACjF,wBAAgB,4BAA4B,CAC1C,QAAQ,EAAE,sBAAsB,GAC/B,qBAAqB,CAwBvB;AAQD,gFAAgF;AAChF,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,sBAAsB,EAChC,QAAQ,EAAE,qBAAqB,GAC9B,IAAI,CAcN;AAED,yDAAyD;AACzD,wBAAgB,8BAA8B,CAC5C,QAAQ,EAAE,qBAAqB,GAC9B,MAAM,CAOR"}
@@ -0,0 +1,90 @@
1
+ export const CRAFT_TRANSFER_SNAPSHOT_VERSION = 1;
2
+ /** Captures only JSON-compatible state; non-serializable entries fail loudly. */
3
+ export function captureCraftTransferSnapshot(registry) {
4
+ const values = {};
5
+ const queries = {};
6
+ for (const entry of registry.list()) {
7
+ const value = readSerializableEntry(entry);
8
+ if (value === SKIP_ENTRY)
9
+ continue;
10
+ if (entry.kind === 'query') {
11
+ const error = entry.error?.();
12
+ queries[entry.address] = {
13
+ status: entry.status?.() ?? (value === undefined ? 'idle' : 'resolved'),
14
+ ...(value === undefined ? {} : { value }),
15
+ ...(error === undefined ? {} : { error: serializeError(error) }),
16
+ };
17
+ }
18
+ else {
19
+ values[entry.address] = value;
20
+ }
21
+ }
22
+ return {
23
+ version: CRAFT_TRANSFER_SNAPSHOT_VERSION,
24
+ values,
25
+ queries,
26
+ };
27
+ }
28
+ function serializeError(error) {
29
+ return error instanceof Error
30
+ ? { name: error.name, message: error.message }
31
+ : error;
32
+ }
33
+ /** Primes registrations that will be created during the first client render. */
34
+ export function primeCraftTransferSnapshot(registry, snapshot) {
35
+ if (snapshot.version !== CRAFT_TRANSFER_SNAPSHOT_VERSION) {
36
+ throw new Error(`Unsupported Craft transfer snapshot version ${snapshot.version}.`);
37
+ }
38
+ registry.prime({
39
+ ...snapshot.values,
40
+ ...Object.fromEntries(Object.entries(snapshot.queries).flatMap(([address, query]) => 'value' in query ? [[address, query.value]] : [])),
41
+ });
42
+ }
43
+ /** JSON safe for embedding in an HTML script element. */
44
+ export function serializeCraftTransferSnapshot(snapshot) {
45
+ return JSON.stringify(snapshot)
46
+ .replaceAll('<', '\\u003c')
47
+ .replaceAll('>', '\\u003e')
48
+ .replaceAll('&', '\\u0026')
49
+ .replaceAll('\u2028', '\\u2028')
50
+ .replaceAll('\u2029', '\\u2029');
51
+ }
52
+ const SKIP_ENTRY = Symbol('skip-transfer-entry');
53
+ function readSerializableEntry(entry) {
54
+ let value;
55
+ try {
56
+ value = entry.read();
57
+ }
58
+ catch {
59
+ return SKIP_ENTRY;
60
+ }
61
+ assertSerializable(value, entry.address, new Set());
62
+ return value;
63
+ }
64
+ function assertSerializable(value, address, seen) {
65
+ if (value === null ||
66
+ value === undefined ||
67
+ typeof value === 'string' ||
68
+ typeof value === 'number' ||
69
+ typeof value === 'boolean') {
70
+ return;
71
+ }
72
+ if (typeof value === 'bigint' || typeof value === 'function') {
73
+ throw new Error(`Craft transfer value "${address}" is not JSON-serializable.`);
74
+ }
75
+ if (typeof value !== 'object')
76
+ return;
77
+ if (seen.has(value)) {
78
+ throw new Error(`Craft transfer value "${address}" contains a cycle.`);
79
+ }
80
+ if (Object.getPrototypeOf(value) !== Object.prototype &&
81
+ Object.getPrototypeOf(value) !== Array.prototype) {
82
+ throw new Error(`Craft transfer value "${address}" must contain only plain objects and arrays.`);
83
+ }
84
+ seen.add(value);
85
+ for (const child of Object.values(value)) {
86
+ assertSerializable(child, address, seen);
87
+ }
88
+ seen.delete(value);
89
+ }
90
+ //# sourceMappingURL=craft-transfer-snapshot.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"craft-transfer-snapshot.js","sourceRoot":"","sources":["../../../../../libs/core/src/lib/craft-transfer-snapshot.ts"],"names":[],"mappings":"AAKA,MAAM,CAAC,MAAM,+BAA+B,GAAG,CAAC,CAAC;AAcjD,iFAAiF;AACjF,MAAM,UAAU,4BAA4B,CAC1C,QAAgC;IAEhC,MAAM,MAAM,GAA4B,EAAE,CAAC;IAC3C,MAAM,OAAO,GAA+C,EAAE,CAAC;IAE/D,KAAK,MAAM,KAAK,IAAI,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC;QACpC,MAAM,KAAK,GAAG,qBAAqB,CAAC,KAAK,CAAC,CAAC;QAC3C,IAAI,KAAK,KAAK,UAAU;YAAE,SAAS;QACnC,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;YAC3B,MAAM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AE,CAAC;QAC7D,MAAM,IAAI,KAAK,CACb,yBAAyB,OAAO,6BAA6B,CAC9D,CAAC;IACJ,CAAC;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO;IACtC,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CAAC,yBAAyB,OAAO,qBAAqB,CAAC,CAAC;IACzE,CAAC;IACD,IACE,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,KAAK,MAAM,CAAC,SAAS;QACjD,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,KAAK,KAAK,CAAC,SAAS,EAChD,CAAC;QACD,MAAM,IAAI,KAAK,CACb,yBAAyB,OAAO,+CAA+C,CAChF,CAAC;IACJ,CAAC;IACD,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAChB,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;QACzC,kBAAkB,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;IAC3C,CAAC;IACD,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACrB,CAAC","sourcesContent":["import type {\n CraftPrimitiveEntry,\n CraftPrimitiveRegistry,\n} from './craft-primitive-registry';\n\nexport const CRAFT_TRANSFER_SNAPSHOT_VERSION = 1;\n\nexport type CraftTransferQuerySnapshot = Readonly<{\n status: string;\n value?: unknown;\n error?: unknown;\n}>;\n\nexport type CraftTransferSnapshot = Readonly<{\n version: number;\n values: Readonly<Record<string, unknown>>;\n queries: Readonly<Record<string, CraftTransferQuerySnapshot>>;\n}>;\n\n/** Captures only JSON-compatible state; non-serializable entries fail loudly. */\nexport function captureCraftTransferSnapshot(\n registry: CraftPrimitiveRegistry,\n): CraftTransferSnapshot {\n const values: Record<string, unknown> = {};\n const queries: Record<string, CraftTransferQuerySnapshot> = {};\n\n for (const entry of registry.list()) {\n const value = readSerializableEntry(entry);\n if (value === SKIP_ENTRY) continue;\n if (entry.kind === 'query') {\n const error = entry.error?.();\n queries[entry.address] = {\n status: entry.status?.() ?? (value === undefined ? 'idle' : 'resolved'),\n ...(value === undefined ? {} : { value }),\n ...(error === undefined ? {} : { error: serializeError(error) }),\n };\n } else {\n values[entry.address] = value;\n }\n }\n\n return {\n version: CRAFT_TRANSFER_SNAPSHOT_VERSION,\n values,\n queries,\n };\n}\n\nfunction serializeError(error: unknown): unknown {\n return error instanceof Error\n ? { name: error.name, message: error.message }\n : error;\n}\n\n/** Primes registrations that will be created during the first client render. */\nexport function primeCraftTransferSnapshot(\n registry: CraftPrimitiveRegistry,\n snapshot: CraftTransferSnapshot,\n): void {\n if (snapshot.version !== CRAFT_TRANSFER_SNAPSHOT_VERSION) {\n throw new Error(\n `Unsupported Craft transfer snapshot version ${snapshot.version}.`,\n );\n }\n registry.prime({\n ...snapshot.values,\n ...Object.fromEntries(\n Object.entries(snapshot.queries).flatMap(([address, query]) =>\n 'value' in query ? [[address, query.value]] : [],\n ),\n ),\n });\n}\n\n/** JSON safe for embedding in an HTML script element. */\nexport function serializeCraftTransferSnapshot(\n snapshot: CraftTransferSnapshot,\n): string {\n return JSON.stringify(snapshot)\n .replaceAll('<', '\\\\u003c')\n .replaceAll('>', '\\\\u003e')\n .replaceAll('&', '\\\\u0026')\n .replaceAll('\\u2028', '\\\\u2028')\n .replaceAll('\\u2029', '\\\\u2029');\n}\n\nconst SKIP_ENTRY = Symbol('skip-transfer-entry');\n\nfunction readSerializableEntry(\n entry: CraftPrimitiveEntry,\n): unknown | typeof SKIP_ENTRY {\n let value: unknown;\n try {\n value = entry.read();\n } catch {\n return SKIP_ENTRY;\n }\n assertSerializable(value, entry.address, new Set());\n return value;\n}\n\nfunction assertSerializable(\n value: unknown,\n address: string,\n seen: Set<object>,\n): void {\n if (\n value === null ||\n value === undefined ||\n typeof value === 'string' ||\n typeof value === 'number' ||\n typeof value === 'boolean'\n ) {\n return;\n }\n if (typeof value === 'bigint' || typeof value === 'function') {\n throw new Error(\n `Craft transfer value \"${address}\" is not JSON-serializable.`,\n );\n }\n if (typeof value !== 'object') return;\n if (seen.has(value)) {\n throw new Error(`Craft transfer value \"${address}\" contains a cycle.`);\n }\n if (\n Object.getPrototypeOf(value) !== Object.prototype &&\n Object.getPrototypeOf(value) !== Array.prototype\n ) {\n throw new Error(\n `Craft transfer value \"${address}\" must contain only plain objects and arrays.`,\n );\n }\n seen.add(value);\n for (const child of Object.values(value)) {\n assertSerializable(child, address, seen);\n }\n seen.delete(value);\n}\n"]}
@@ -0,0 +1,7 @@
1
+ export declare const CRAFT_UNIQUE: unique symbol;
2
+ export type CraftUnique<T> = T & {
3
+ readonly [CRAFT_UNIQUE]: true;
4
+ };
5
+ export declare function craftUnique<const T>(value: T): CraftUnique<T>;
6
+ export declare function isCraftUnique(value: unknown): value is CraftUnique<unknown>;
7
+ //# sourceMappingURL=craft-unique.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"craft-unique.d.ts","sourceRoot":"","sources":["../../../../../libs/core/src/lib/craft-unique.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY,eAAwB,CAAC;AAElD,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,CAAC,GAAG;IAC/B,QAAQ,CAAC,CAAC,YAAY,CAAC,EAAE,IAAI,CAAC;CAC/B,CAAC;AAEF,wBAAgB,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAS7D;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,WAAW,CAAC,OAAO,CAAC,CAK3E"}
@@ -0,0 +1,16 @@
1
+ export const CRAFT_UNIQUE = Symbol('craftUnique');
2
+ export function craftUnique(value) {
3
+ if (value !== null && (typeof value === 'object' || typeof value === 'function')) {
4
+ Object.defineProperty(value, CRAFT_UNIQUE, {
5
+ value: true,
6
+ enumerable: false,
7
+ configurable: false,
8
+ });
9
+ }
10
+ return value;
11
+ }
12
+ export function isCraftUnique(value) {
13
+ return ((typeof value === 'object' && value !== null && CRAFT_UNIQUE in value) ||
14
+ (typeof value === 'function' && CRAFT_UNIQUE in value));
15
+ }
16
+ //# sourceMappingURL=craft-unique.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"craft-unique.js","sourceRoot":"","sources":["../../../../../libs/core/src/lib/craft-unique.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC,aAAa,CAAC,CAAC;AAMlD,MAAM,UAAU,WAAW,CAAU,KAAQ;IAC3C,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,UAAU,CAAC,EAAE,CAAC;QACjF,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,YAAY,EAAE;YACzC,KAAK,EAAE,IAAI;YACX,UAAU,EAAE,KAAK;YACjB,YAAY,EAAE,KAAK;SACpB,CAAC,CAAC;IACL,CAAC;IACD,OAAO,KAAuB,CAAC;AACjC,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,KAAc;IAC1C,OAAO,CACL,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,YAAY,IAAI,KAAK,CAAC;QACtE,CAAC,OAAO,KAAK,KAAK,UAAU,IAAI,YAAY,IAAI,KAAK,CAAC,CACvD,CAAC;AACJ,CAAC","sourcesContent":["export const CRAFT_UNIQUE = Symbol('craftUnique');\n\nexport type CraftUnique<T> = T & {\n readonly [CRAFT_UNIQUE]: true;\n};\n\nexport function craftUnique<const T>(value: T): CraftUnique<T> {\n if (value !== null && (typeof value === 'object' || typeof value === 'function')) {\n Object.defineProperty(value, CRAFT_UNIQUE, {\n value: true,\n enumerable: false,\n configurable: false,\n });\n }\n return value as CraftUnique<T>;\n}\n\nexport function isCraftUnique(value: unknown): value is CraftUnique<unknown> {\n return (\n (typeof value === 'object' && value !== null && CRAFT_UNIQUE in value) ||\n (typeof value === 'function' && CRAFT_UNIQUE in value)\n );\n}\n"]}