@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,433 @@
1
+ import { assertInInjectionContext, DestroyRef, inject, Injector, linkedSignal, runInInjectionContext, signal, } from './host/craft-compat';
2
+ import { takeUntilDestroyed } from './host/craft-compat';
3
+ import { SourceBranded } from './util/util';
4
+ import { ɵcreateHostTaggedInjector, ɵHOST_TAG_LIST } from './craft-service';
5
+ import { APP_SNAPSHOT_REGISTRY } from './take-app-snapshot';
6
+ import { injectFnWrapper } from './fn-wrapper';
7
+ import { RAW_REACTIVE_VALUE, REACTIVE_VALUE_TYPE, YIELDABLE_VALUE, } from './reactive-read';
8
+ /**
9
+ * Creates a source for event-driven communication with lazy emission semantics.
10
+ *
11
+ * Sources are the foundation of event-driven patterns in craft-ts, enabling:
12
+ * - Discrete event emissions (unlike continuous signals)
13
+ * - Lazy behavior (undefined until explicitly set)
14
+ * - Decoupled communication between components and stores
15
+ * - Automatic triggering of queries, mutations, and async methods
16
+ * - Multi-listener support with independent subscription timing
17
+ *
18
+ * @remarks
19
+ * **Core Concept:**
20
+ * Sources implement event emitter pattern with reactive semantics:
21
+ * - Emit only when explicitly set (not on every read like signals)
22
+ * - Listeners receive `undefined` on first read (lazy semantics)
23
+ * - New listeners don't receive previous emissions by default
24
+ * - Use `preserveLastValue` to get the last emitted value immediately
25
+ *
26
+ * **Difference from Signals:**
27
+ * - **Signals**: Always have a value, recompute on access, continuous state
28
+ * - **Sources**: Emit on explicit set, lazy by default, discrete events
29
+ * - Sources are for events/actions, signals are for state
30
+ *
31
+ * **Use Cases:**
32
+ * - **User actions**: Button clicks, form submissions, custom events
33
+ * - **Navigation events**: Route changes, tab switches
34
+ * - **Data events**: Reload triggers, refresh requests
35
+ * - **Coordination**: Communication between disconnected components
36
+ * - **Store inputs**: Triggering queries/mutations from components
37
+ * - **Event buses**: Decoupled event communication
38
+ *
39
+ * **Integration with Queries/Mutations:**
40
+ * - Bind to method using `afterRecomputation(source, callback)`
41
+ * - Query/mutation executes automatically when source emits
42
+ * - No manual method exposed (source-based triggering)
43
+ *
44
+ * **Listener Semantics:**
45
+ * - **Standard listener**: Returns `undefined` until source emits, then returns new values only
46
+ * - **preserveLastValue**: Returns last emitted value immediately, then tracks new values
47
+ * - Useful for late subscribers that need current state
48
+ *
49
+ * **Limitations:**
50
+ * Sources are signals and behave differently from observables.
51
+ * Understanding these three key limitations is important:
52
+ * - **Multiple sets in same cycle**: When a source is set multiple times during the same cycle
53
+ * (between the first set and the Change Detection that executes all consumer callbacks),
54
+ * consumers will only react once during CD and will only see the last set value.
55
+ * Intermediate values are discarded.
56
+ * - **Multiple sources order**: Within the same cycle, if multiple sources are triggered,
57
+ * consumers cannot determine the order in which the sources were set.
58
+ * The original emission sequence is not preserved.
59
+ * - **Consumer execution order**: When multiple sources are triggered in the same cycle,
60
+ * consumer callbacks are invoked in the order they were declared, not in the order
61
+ * their source producers were triggered.
62
+ * - **No synchronous intermediate value reactions**: Unlike observables, sources cannot react
63
+ * to each intermediate value synchronously. A mechanism similar to observables
64
+ * (or using native Observable API) without RxJS is being considered to enable
65
+ * synchronous reactions to intermediate values, matching the behavior currently
66
+ * offered by observables.
67
+ *
68
+ * @template T - The type of values emitted by the source
69
+ *
70
+ * @param name - Name matching the variable/property this source is assigned to (used for host
71
+ * tagging and dev-tools snapshot reporting, consistent with `craftComputed`/`craftEffect`)
72
+ * @param options - Optional configuration:
73
+ * - `equal`: Custom equality function for change detection (prevents duplicate emissions)
74
+ *
75
+ * @returns A source object with:
76
+ * - `()`: Read current value (undefined until first emission)
77
+ * - `set(value)`: Emit a value to all listeners
78
+ * - `preserveLastValue`: Alternative signal that returns last value immediately
79
+ *
80
+ * @example
81
+ * Basic source for user actions
82
+ * ```ts
83
+ * const { UserStore } = craftService(
84
+ * { name: 'UserStore', providedIn: 'toProvide' },
85
+ * function* () {
86
+ * const loadUser = signalSource<string>('loadUser');
87
+ *
88
+ * const user = yield* query({
89
+ * method: afterRecomputation(loadUser, (userId) => userId),
90
+ * loader: async ({ params }) => {
91
+ * const response = await fetch(`/api/users/${params}`);
92
+ * return response.json();
93
+ * },
94
+ * });
95
+ *
96
+ * return { loadUser, user };
97
+ * },
98
+ * );
99
+ *
100
+ * const store = UserStore();
101
+ *
102
+ * // Query executes automatically when source emits
103
+ * store.loadUser.set('user-123');
104
+ * // -> loadUser source emits 'user-123'
105
+ * // -> user query executes with params 'user-123'
106
+ *
107
+ * store.loadUser.set('user-456');
108
+ * // -> user query executes again with params 'user-456'
109
+ * ```
110
+ *
111
+ * @example
112
+ * Source for form submission
113
+ * ```ts
114
+ * type FormData = { name: string; email: string };
115
+ *
116
+ * const { FormStore } = craftService(
117
+ * { name: 'FormStore', providedIn: 'toProvide' },
118
+ * function* () {
119
+ * const submitForm = signalSource<FormData>('submitForm');
120
+ *
121
+ * const submit = yield* mutation({
122
+ * method: afterRecomputation(submitForm, (data) => data),
123
+ * loader: async ({ params }) => {
124
+ * const response = await fetch('/api/submit', {
125
+ * method: 'POST',
126
+ * body: JSON.stringify(params),
127
+ * });
128
+ * return response.json();
129
+ * },
130
+ * });
131
+ *
132
+ * return { submitForm, submit };
133
+ * },
134
+ * );
135
+ *
136
+ * const store = FormStore();
137
+ *
138
+ * // In component template:
139
+ * // <form (submit)="onSubmit()">
140
+ * // <input name="name" [(ngModel)]="formData.name" />
141
+ * // <input name="email" [(ngModel)]="formData.email" />
142
+ * // </form>
143
+ *
144
+ * onSubmit() {
145
+ * // Mutation executes automatically
146
+ * this.store.submitForm.set(this.formData);
147
+ * // -> submitForm source emits
148
+ * // -> submit mutation executes
149
+ * }
150
+ * ```
151
+ *
152
+ * @example
153
+ * Source for reload/refresh actions
154
+ * ```ts
155
+ * const { DataStore } = craftService(
156
+ * { name: 'DataStore', providedIn: 'toProvide' },
157
+ * function* () {
158
+ * const reload = signalSource<void>('reload');
159
+ *
160
+ * const data = yield* query({
161
+ * method: afterRecomputation(reload, () => ({})),
162
+ * loader: async () => {
163
+ * const response = await fetch('/api/data');
164
+ * return response.json();
165
+ * },
166
+ * });
167
+ *
168
+ * return { reload, data };
169
+ * },
170
+ * );
171
+ *
172
+ * const store = DataStore();
173
+ *
174
+ * // Trigger reload from anywhere
175
+ * store.reload.set();
176
+ * // -> reload source emits
177
+ * // -> query re-executes
178
+ *
179
+ * // In component:
180
+ * // <button (click)="store.reload.set()">Refresh</button>
181
+ * ```
182
+ *
183
+ * @example
184
+ * Multiple sources for different actions
185
+ * ```ts
186
+ * const { TodoStore } = craftService(
187
+ * { name: 'TodoStore', providedIn: 'toProvide' },
188
+ * function* () {
189
+ * const addTodo = signalSource<{ text: string }>('addTodo');
190
+ * const deleteTodo = signalSource<string>('deleteTodo');
191
+ * const toggleTodo = signalSource<string>('toggleTodo');
192
+ *
193
+ * const create = yield* mutation({
194
+ * method: afterRecomputation(addTodo, (data) => data),
195
+ * loader: async ({ params }) => {
196
+ * const response = await fetch('/api/todos', {
197
+ * method: 'POST',
198
+ * body: JSON.stringify(params),
199
+ * });
200
+ * return response.json();
201
+ * },
202
+ * });
203
+ *
204
+ * const remove = yield* mutation({
205
+ * method: afterRecomputation(deleteTodo, (id) => id),
206
+ * loader: async ({ params }) => {
207
+ * await fetch(`/api/todos/${params}`, { method: 'DELETE' });
208
+ * return { deleted: true };
209
+ * },
210
+ * });
211
+ *
212
+ * const toggle = yield* mutation({
213
+ * method: afterRecomputation(toggleTodo, (id) => id),
214
+ * loader: async ({ params }) => {
215
+ * const response = await fetch(`/api/todos/${params}/toggle`, {
216
+ * method: 'PATCH',
217
+ * });
218
+ * return response.json();
219
+ * },
220
+ * });
221
+ *
222
+ * return { addTodo, deleteTodo, toggleTodo, create, remove, toggle };
223
+ * },
224
+ * );
225
+ *
226
+ * const store = TodoStore();
227
+ *
228
+ * // Different actions trigger different mutations
229
+ * store.addTodo.set({ text: 'Buy milk' });
230
+ * store.toggleTodo.set('todo-123');
231
+ * store.deleteTodo.set('todo-456');
232
+ * ```
233
+ *
234
+ * @example
235
+ * Late listener with preserveLastValue
236
+ * ```ts
237
+ * // Inside a component constructor or a craftService factory (injection context)
238
+ * const mySource = signalSource<string>('mySource');
239
+ *
240
+ * // Early listener
241
+ * const listener1 = computed(() => mySource());
242
+ * console.log(listener1()); // undefined
243
+ *
244
+ * // Emit value
245
+ * mySource.set('Hello');
246
+ * console.log(listener1()); // 'Hello'
247
+ *
248
+ * // Late listener (after emission)
249
+ * const listener2 = computed(() => mySource());
250
+ * console.log(listener2()); // undefined (doesn't get previous emission)
251
+ *
252
+ * mySource.set('World');
253
+ * console.log(listener1()); // 'World'
254
+ * console.log(listener2()); // 'World'
255
+ *
256
+ * // Using preserveLastValue for late listeners
257
+ * const listener3 = computed(() => mySource.preserveLastValue());
258
+ * console.log(listener3()); // 'World' (gets last value immediately)
259
+ * ```
260
+ *
261
+ * @example
262
+ * Custom equality to prevent duplicate emissions
263
+ * ```ts
264
+ * type Params = { id: string; timestamp: number };
265
+ *
266
+ * // Inside a component constructor or a craftService factory (injection context)
267
+ * const paramsSource = signalSource<Params>('paramsSource', {
268
+ * equal: (a, b) => a?.id === b?.id, // Compare only by id
269
+ * });
270
+ *
271
+ * const listener = computed(() => paramsSource());
272
+ *
273
+ * paramsSource.set({ id: 'item-1', timestamp: Date.now() });
274
+ * // -> listener receives value
275
+ *
276
+ * paramsSource.set({ id: 'item-1', timestamp: Date.now() });
277
+ * // -> listener does NOT receive value (same id)
278
+ *
279
+ * paramsSource.set({ id: 'item-2', timestamp: Date.now() });
280
+ * // -> listener receives value (different id)
281
+ * ```
282
+ *
283
+ * @example
284
+ * Source for coordinating multiple components
285
+ * ```ts
286
+ * // Root-provided coordinator service, injected wherever the shared source is needed
287
+ * const { RefreshCoordinator } = craftService(
288
+ * { name: 'RefreshCoordinator', scope: 'root' },
289
+ * () => {
290
+ * const refreshAllSource = signalSource<void>('refreshAllSource');
291
+ * return { refreshAllSource };
292
+ * },
293
+ * );
294
+ *
295
+ * // Component A's store
296
+ * const { DataViewStore, provideDataViewStore } = craftService(
297
+ * { name: 'DataViewStore', providedIn: 'toProvide' },
298
+ * function* () {
299
+ * const { refreshAllSource } = RefreshCoordinator();
300
+ *
301
+ * const data = yield* query({
302
+ * method: afterRecomputation(refreshAllSource, () => ({})),
303
+ * loader: async () => {
304
+ * const response = await fetch('/api/data');
305
+ * return response.json();
306
+ * },
307
+ * });
308
+ *
309
+ * return { data };
310
+ * },
311
+ * );
312
+ *
313
+ * @Component({
314
+ * selector: 'app-data-view',
315
+ * template: '...',
316
+ * providers: [provideDataViewStore()],
317
+ * })
318
+ * export class DataViewComponent {
319
+ * store = DataViewStore();
320
+ * }
321
+ *
322
+ * // Component B
323
+ * @Component({
324
+ * selector: 'app-refresh-button',
325
+ * template: '<button (click)="refresh()">Refresh All</button>',
326
+ * })
327
+ * export class RefreshButtonComponent {
328
+ * private readonly coordinator = RefreshCoordinator();
329
+ *
330
+ * refresh() {
331
+ * // Triggers refresh in every store listening to this source
332
+ * this.coordinator.refreshAllSource.set();
333
+ * }
334
+ * }
335
+ * ```
336
+ *
337
+ * @example
338
+ * Source with complex payload
339
+ * ```ts
340
+ * type SearchParams = {
341
+ * query: string;
342
+ * filters: string[];
343
+ * page: number;
344
+ * };
345
+ *
346
+ * const { SearchStore } = craftService(
347
+ * { name: 'SearchStore', providedIn: 'toProvide' },
348
+ * function* () {
349
+ * const search = signalSource<SearchParams>('search');
350
+ *
351
+ * const results = yield* query({
352
+ * method: afterRecomputation(search, (params) => params),
353
+ * loader: async ({ params }) => {
354
+ * const queryString = new URLSearchParams({
355
+ * q: params.query,
356
+ * filters: params.filters.join(','),
357
+ * page: String(params.page),
358
+ * });
359
+ * const response = await fetch(`/api/search?${queryString}`);
360
+ * return response.json();
361
+ * },
362
+ * });
363
+ *
364
+ * return { search, results };
365
+ * },
366
+ * );
367
+ *
368
+ * const store = SearchStore();
369
+ *
370
+ * // Emit complex search parameters
371
+ * store.search.set({
372
+ * query: 'angular',
373
+ * filters: ['tutorial', 'advanced'],
374
+ * page: 1,
375
+ * });
376
+ * ```
377
+ */
378
+ export function signalSource(name, options) {
379
+ assertInInjectionContext(signalSource);
380
+ const injector = inject(Injector);
381
+ const sourceInjector = ɵcreateHostTaggedInjector(injector, `signal-source:${name}`);
382
+ const destroyRef = inject(DestroyRef);
383
+ const sourceState = signal(undefined, {
384
+ ...(options?.equal && { equal: options?.equal }), // add the equal function here, it may helps to detect changes when using scalar values
385
+ debugName: `${name}_sourceState`,
386
+ });
387
+ const wrappedSet = runInInjectionContext(sourceInjector, () => injectFnWrapper()((value) => sourceState.set(value)));
388
+ const set = (value) => runInInjectionContext(sourceInjector, () => wrappedSet(value));
389
+ const listener = (listenerOptions) => linkedSignal({
390
+ source: sourceState,
391
+ computation: (currentSourceState, previousData) => {
392
+ // always when first listened return undefined
393
+ if (!previousData && listenerOptions?.nullishFirstValue !== false) {
394
+ return undefined;
395
+ }
396
+ return currentSourceState;
397
+ },
398
+ ...(options?.equal && { equal: options?.equal }),
399
+ debugName: name,
400
+ });
401
+ const result = listener({
402
+ nullishFirstValue: true,
403
+ });
404
+ const registry = inject(APP_SNAPSHOT_REGISTRY, { optional: true });
405
+ if (registry) {
406
+ const from = sourceInjector.get(ɵHOST_TAG_LIST, null) ?? [];
407
+ registry.triggerSnapshot$
408
+ .pipe(takeUntilDestroyed(destroyRef))
409
+ .subscribe(() => {
410
+ let stateSnapshot;
411
+ try {
412
+ stateSnapshot = result();
413
+ }
414
+ catch (error) {
415
+ stateSnapshot = {
416
+ error: error instanceof Error ? error.message : String(error),
417
+ };
418
+ }
419
+ registry.allSnapShot$.next({
420
+ source: name,
421
+ from,
422
+ state: stateSnapshot,
423
+ });
424
+ });
425
+ }
426
+ return Object.assign(result, {
427
+ preserveLastValue: listener({
428
+ nullishFirstValue: false,
429
+ }),
430
+ set,
431
+ }, SourceBranded);
432
+ }
433
+ //# sourceMappingURL=signal-source.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signal-source.js","sourceRoot":"","sources":["../../../../../libs/core/src/lib/signal-source.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,UAAU,EACV,MAAM,EACN,QAAQ,EACR,YAAY,EACZ,qBAAqB,EAErB,MAAM,GAEP,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,yBAAyB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAC5E,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,eAAe,GAGhB,MAAM,iBAAiB,CAAC;AA4BzB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiXG;AACH,MAAM,UAAU,YAAY,CAC1B,IAAY,EACZ,OAEC;IAED,wBAAwB,CAAC,YAAY,CAAC,CAAC;IACvC,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;IAClC,MAAM,cAAc,GAAG,yBAAyB,CAC9C,QAAQ,EACR,iBAAiB,IAAI,EAAE,CACxB,CAAC;IACF,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;IAEtC,MAAM,WAAW,GAAG,MAAM,CAAgB,SAAS,EAAE;QACnD,GAAG,CAAC,OAAO,EAAE,KAAK,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE,uFAAuF;QACzI,SAAS,EAAE,GAAG,IAAI,cAAc;KACjC,CAAC,CAAC;IAEH,MAAM,UAAU,GAAG,qBAAqB,CAAC,cAAc,EAAE,GAAG,EAAE,CAC5D,eAAe,EAAE,CAAC,CAAC,KAAQ,EAAE,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CACxD,CAAC;IACF,MAAM,GAAG,GAAG,CAAC,KAAQ,EAAE,EAAE,CACvB,qBAAqB,CAAC,cAAc,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC;IAEjE,MAAM,QAAQ,GAAG,CAAC,eAAgD,EAAE,EAAE,CACpE,YAAY,CAAmB;QAC7B,MAAM,EAAE,WAAwB;QAChC,WAAW,EAAE,CAAC,kBAAkB,EAAE,YAAY,EAAE,EAAE;YAChD,8CAA8C;YAC9C,IAAI,CAAC,YAAY,IAAI,eAAe,EAAE,iBAAiB,KAAK,KAAK,EAAE,CAAC;gBAClE,OAAO,SAAS,CAAC;YACnB,CAAC;YACD,OAAO,kBAAkB,CAAC;QAC5B,CAAC;QACD,GAAG,CAAC,OAAO,EAAE,KAAK,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;QAChD,SAAS,EAAE,IAAI;KAChB,CAAC,CAAC;IAEL,MAAM,MAAM,GAAG,QAAQ,CAAC;QACtB,iBAAiB,EAAE,IAAI;KACxB,CAAC,CAAC;IAEH,MAAM,QAAQ,GAAG,MAAM,CAAC,qBAAqB,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;IACnE,IAAI,QAAQ,EAAE,CAAC;QACb,MAAM,IAAI,GAAG,cAAc,CAAC,GAAG,CAAC,cAAc,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC;QAC5D,QAAQ,CAAC,gBAAgB;aACtB,IAAI,CAAC,kBAAkB,CAAC,UAAU,CAAC,CAAC;aACpC,SAAS,CAAC,GAAG,EAAE;YACd,IAAI,aAAsB,CAAC;YAC3B,IAAI,CAAC;gBACH,aAAa,GAAG,MAAM,EAAE,CAAC;YAC3B,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,aAAa,GAAG;oBACd,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;iBAC9D,CAAC;YACJ,CAAC;YACD,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC;gBACzB,MAAM,EAAE,IAAI;gBACZ,IAAI;gBACJ,KAAK,EAAE,aAAa;aACrB,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACP,CAAC;IAED,OAAO,MAAM,CAAC,MAAM,CAClB,MAAM,EACN;QACE,iBAAiB,EAAE,QAAQ,CAAC;YAC1B,iBAAiB,EAAE,KAAK;SACzB,CAAC;QACF,GAAG;KACJ,EACD,aAAa,CACgB,CAAC;AAClC,CAAC","sourcesContent":["import {\n assertInInjectionContext,\n DestroyRef,\n inject,\n Injector,\n linkedSignal,\n runInInjectionContext,\n Signal,\n signal,\n ValueEqualityFn,\n} from './host/craft-compat';\nimport { takeUntilDestroyed } from './host/craft-compat';\nimport { SourceBranded } from './util/util';\nimport { ɵcreateHostTaggedInjector, ɵHOST_TAG_LIST } from './craft-service';\nimport { APP_SNAPSHOT_REGISTRY } from './take-app-snapshot';\nimport { injectFnWrapper } from './fn-wrapper';\nimport {\n RAW_REACTIVE_VALUE,\n REACTIVE_VALUE_TYPE,\n YIELDABLE_VALUE,\n type ReactiveReadRequest,\n type YieldableReactiveValue,\n} from './reactive-read';\n\ntype YieldableSignalSourceValue<T> = YieldableReactiveValue<\n T | undefined,\n string\n>;\n\ntype YieldableSignalSourceMetadata<T> = Omit<\n YieldableSignalSourceValue<T>,\n | typeof RAW_REACTIVE_VALUE\n | typeof REACTIVE_VALUE_TYPE\n | typeof YIELDABLE_VALUE\n> & {\n readonly [RAW_REACTIVE_VALUE]: YieldableSignalSourceValue<T>[typeof RAW_REACTIVE_VALUE];\n readonly [REACTIVE_VALUE_TYPE]: T | undefined;\n readonly [YIELDABLE_VALUE]: string;\n};\n\ntype SignalSourceReader<T> = {\n (): T | undefined;\n (): Generator<ReactiveReadRequest<T | undefined>, T | undefined, unknown>;\n} & YieldableSignalSourceMetadata<T>;\n\nexport type SignalSource<T> = SignalSourceReader<T> & {\n set: (value: T) => void;\n preserveLastValue: SignalSourceReader<T>;\n} & SourceBranded;\n\n/**\n * Creates a source for event-driven communication with lazy emission semantics.\n *\n * Sources are the foundation of event-driven patterns in craft-ts, enabling:\n * - Discrete event emissions (unlike continuous signals)\n * - Lazy behavior (undefined until explicitly set)\n * - Decoupled communication between components and stores\n * - Automatic triggering of queries, mutations, and async methods\n * - Multi-listener support with independent subscription timing\n *\n * @remarks\n * **Core Concept:**\n * Sources implement event emitter pattern with reactive semantics:\n * - Emit only when explicitly set (not on every read like signals)\n * - Listeners receive `undefined` on first read (lazy semantics)\n * - New listeners don't receive previous emissions by default\n * - Use `preserveLastValue` to get the last emitted value immediately\n *\n * **Difference from Signals:**\n * - **Signals**: Always have a value, recompute on access, continuous state\n * - **Sources**: Emit on explicit set, lazy by default, discrete events\n * - Sources are for events/actions, signals are for state\n *\n * **Use Cases:**\n * - **User actions**: Button clicks, form submissions, custom events\n * - **Navigation events**: Route changes, tab switches\n * - **Data events**: Reload triggers, refresh requests\n * - **Coordination**: Communication between disconnected components\n * - **Store inputs**: Triggering queries/mutations from components\n * - **Event buses**: Decoupled event communication\n *\n * **Integration with Queries/Mutations:**\n * - Bind to method using `afterRecomputation(source, callback)`\n * - Query/mutation executes automatically when source emits\n * - No manual method exposed (source-based triggering)\n *\n * **Listener Semantics:**\n * - **Standard listener**: Returns `undefined` until source emits, then returns new values only\n * - **preserveLastValue**: Returns last emitted value immediately, then tracks new values\n * - Useful for late subscribers that need current state\n *\n * **Limitations:**\n * Sources are signals and behave differently from observables.\n * Understanding these three key limitations is important:\n * - **Multiple sets in same cycle**: When a source is set multiple times during the same cycle\n * (between the first set and the Change Detection that executes all consumer callbacks),\n * consumers will only react once during CD and will only see the last set value.\n * Intermediate values are discarded.\n * - **Multiple sources order**: Within the same cycle, if multiple sources are triggered,\n * consumers cannot determine the order in which the sources were set.\n * The original emission sequence is not preserved.\n * - **Consumer execution order**: When multiple sources are triggered in the same cycle,\n * consumer callbacks are invoked in the order they were declared, not in the order\n * their source producers were triggered.\n * - **No synchronous intermediate value reactions**: Unlike observables, sources cannot react\n * to each intermediate value synchronously. A mechanism similar to observables\n * (or using native Observable API) without RxJS is being considered to enable\n * synchronous reactions to intermediate values, matching the behavior currently\n * offered by observables.\n *\n * @template T - The type of values emitted by the source\n *\n * @param name - Name matching the variable/property this source is assigned to (used for host\n * tagging and dev-tools snapshot reporting, consistent with `craftComputed`/`craftEffect`)\n * @param options - Optional configuration:\n * - `equal`: Custom equality function for change detection (prevents duplicate emissions)\n *\n * @returns A source object with:\n * - `()`: Read current value (undefined until first emission)\n * - `set(value)`: Emit a value to all listeners\n * - `preserveLastValue`: Alternative signal that returns last value immediately\n *\n * @example\n * Basic source for user actions\n * ```ts\n * const { UserStore } = craftService(\n * { name: 'UserStore', providedIn: 'toProvide' },\n * function* () {\n * const loadUser = signalSource<string>('loadUser');\n *\n * const user = yield* query({\n * method: afterRecomputation(loadUser, (userId) => userId),\n * loader: async ({ params }) => {\n * const response = await fetch(`/api/users/${params}`);\n * return response.json();\n * },\n * });\n *\n * return { loadUser, user };\n * },\n * );\n *\n * const store = UserStore();\n *\n * // Query executes automatically when source emits\n * store.loadUser.set('user-123');\n * // -> loadUser source emits 'user-123'\n * // -> user query executes with params 'user-123'\n *\n * store.loadUser.set('user-456');\n * // -> user query executes again with params 'user-456'\n * ```\n *\n * @example\n * Source for form submission\n * ```ts\n * type FormData = { name: string; email: string };\n *\n * const { FormStore } = craftService(\n * { name: 'FormStore', providedIn: 'toProvide' },\n * function* () {\n * const submitForm = signalSource<FormData>('submitForm');\n *\n * const submit = yield* mutation({\n * method: afterRecomputation(submitForm, (data) => data),\n * loader: async ({ params }) => {\n * const response = await fetch('/api/submit', {\n * method: 'POST',\n * body: JSON.stringify(params),\n * });\n * return response.json();\n * },\n * });\n *\n * return { submitForm, submit };\n * },\n * );\n *\n * const store = FormStore();\n *\n * // In component template:\n * // <form (submit)=\"onSubmit()\">\n * // <input name=\"name\" [(ngModel)]=\"formData.name\" />\n * // <input name=\"email\" [(ngModel)]=\"formData.email\" />\n * // </form>\n *\n * onSubmit() {\n * // Mutation executes automatically\n * this.store.submitForm.set(this.formData);\n * // -> submitForm source emits\n * // -> submit mutation executes\n * }\n * ```\n *\n * @example\n * Source for reload/refresh actions\n * ```ts\n * const { DataStore } = craftService(\n * { name: 'DataStore', providedIn: 'toProvide' },\n * function* () {\n * const reload = signalSource<void>('reload');\n *\n * const data = yield* query({\n * method: afterRecomputation(reload, () => ({})),\n * loader: async () => {\n * const response = await fetch('/api/data');\n * return response.json();\n * },\n * });\n *\n * return { reload, data };\n * },\n * );\n *\n * const store = DataStore();\n *\n * // Trigger reload from anywhere\n * store.reload.set();\n * // -> reload source emits\n * // -> query re-executes\n *\n * // In component:\n * // <button (click)=\"store.reload.set()\">Refresh</button>\n * ```\n *\n * @example\n * Multiple sources for different actions\n * ```ts\n * const { TodoStore } = craftService(\n * { name: 'TodoStore', providedIn: 'toProvide' },\n * function* () {\n * const addTodo = signalSource<{ text: string }>('addTodo');\n * const deleteTodo = signalSource<string>('deleteTodo');\n * const toggleTodo = signalSource<string>('toggleTodo');\n *\n * const create = yield* mutation({\n * method: afterRecomputation(addTodo, (data) => data),\n * loader: async ({ params }) => {\n * const response = await fetch('/api/todos', {\n * method: 'POST',\n * body: JSON.stringify(params),\n * });\n * return response.json();\n * },\n * });\n *\n * const remove = yield* mutation({\n * method: afterRecomputation(deleteTodo, (id) => id),\n * loader: async ({ params }) => {\n * await fetch(`/api/todos/${params}`, { method: 'DELETE' });\n * return { deleted: true };\n * },\n * });\n *\n * const toggle = yield* mutation({\n * method: afterRecomputation(toggleTodo, (id) => id),\n * loader: async ({ params }) => {\n * const response = await fetch(`/api/todos/${params}/toggle`, {\n * method: 'PATCH',\n * });\n * return response.json();\n * },\n * });\n *\n * return { addTodo, deleteTodo, toggleTodo, create, remove, toggle };\n * },\n * );\n *\n * const store = TodoStore();\n *\n * // Different actions trigger different mutations\n * store.addTodo.set({ text: 'Buy milk' });\n * store.toggleTodo.set('todo-123');\n * store.deleteTodo.set('todo-456');\n * ```\n *\n * @example\n * Late listener with preserveLastValue\n * ```ts\n * // Inside a component constructor or a craftService factory (injection context)\n * const mySource = signalSource<string>('mySource');\n *\n * // Early listener\n * const listener1 = computed(() => mySource());\n * console.log(listener1()); // undefined\n *\n * // Emit value\n * mySource.set('Hello');\n * console.log(listener1()); // 'Hello'\n *\n * // Late listener (after emission)\n * const listener2 = computed(() => mySource());\n * console.log(listener2()); // undefined (doesn't get previous emission)\n *\n * mySource.set('World');\n * console.log(listener1()); // 'World'\n * console.log(listener2()); // 'World'\n *\n * // Using preserveLastValue for late listeners\n * const listener3 = computed(() => mySource.preserveLastValue());\n * console.log(listener3()); // 'World' (gets last value immediately)\n * ```\n *\n * @example\n * Custom equality to prevent duplicate emissions\n * ```ts\n * type Params = { id: string; timestamp: number };\n *\n * // Inside a component constructor or a craftService factory (injection context)\n * const paramsSource = signalSource<Params>('paramsSource', {\n * equal: (a, b) => a?.id === b?.id, // Compare only by id\n * });\n *\n * const listener = computed(() => paramsSource());\n *\n * paramsSource.set({ id: 'item-1', timestamp: Date.now() });\n * // -> listener receives value\n *\n * paramsSource.set({ id: 'item-1', timestamp: Date.now() });\n * // -> listener does NOT receive value (same id)\n *\n * paramsSource.set({ id: 'item-2', timestamp: Date.now() });\n * // -> listener receives value (different id)\n * ```\n *\n * @example\n * Source for coordinating multiple components\n * ```ts\n * // Root-provided coordinator service, injected wherever the shared source is needed\n * const { RefreshCoordinator } = craftService(\n * { name: 'RefreshCoordinator', scope: 'root' },\n * () => {\n * const refreshAllSource = signalSource<void>('refreshAllSource');\n * return { refreshAllSource };\n * },\n * );\n *\n * // Component A's store\n * const { DataViewStore, provideDataViewStore } = craftService(\n * { name: 'DataViewStore', providedIn: 'toProvide' },\n * function* () {\n * const { refreshAllSource } = RefreshCoordinator();\n *\n * const data = yield* query({\n * method: afterRecomputation(refreshAllSource, () => ({})),\n * loader: async () => {\n * const response = await fetch('/api/data');\n * return response.json();\n * },\n * });\n *\n * return { data };\n * },\n * );\n *\n * @Component({\n * selector: 'app-data-view',\n * template: '...',\n * providers: [provideDataViewStore()],\n * })\n * export class DataViewComponent {\n * store = DataViewStore();\n * }\n *\n * // Component B\n * @Component({\n * selector: 'app-refresh-button',\n * template: '<button (click)=\"refresh()\">Refresh All</button>',\n * })\n * export class RefreshButtonComponent {\n * private readonly coordinator = RefreshCoordinator();\n *\n * refresh() {\n * // Triggers refresh in every store listening to this source\n * this.coordinator.refreshAllSource.set();\n * }\n * }\n * ```\n *\n * @example\n * Source with complex payload\n * ```ts\n * type SearchParams = {\n * query: string;\n * filters: string[];\n * page: number;\n * };\n *\n * const { SearchStore } = craftService(\n * { name: 'SearchStore', providedIn: 'toProvide' },\n * function* () {\n * const search = signalSource<SearchParams>('search');\n *\n * const results = yield* query({\n * method: afterRecomputation(search, (params) => params),\n * loader: async ({ params }) => {\n * const queryString = new URLSearchParams({\n * q: params.query,\n * filters: params.filters.join(','),\n * page: String(params.page),\n * });\n * const response = await fetch(`/api/search?${queryString}`);\n * return response.json();\n * },\n * });\n *\n * return { search, results };\n * },\n * );\n *\n * const store = SearchStore();\n *\n * // Emit complex search parameters\n * store.search.set({\n * query: 'angular',\n * filters: ['tutorial', 'advanced'],\n * page: 1,\n * });\n * ```\n */\nexport function signalSource<T>(\n name: string,\n options?: {\n equal?: ValueEqualityFn<NoInfer<T> | undefined>;\n },\n): SignalSource<T> {\n assertInInjectionContext(signalSource);\n const injector = inject(Injector);\n const sourceInjector = ɵcreateHostTaggedInjector(\n injector,\n `signal-source:${name}`,\n );\n const destroyRef = inject(DestroyRef);\n\n const sourceState = signal<T | undefined>(undefined, {\n ...(options?.equal && { equal: options?.equal }), // add the equal function here, it may helps to detect changes when using scalar values\n debugName: `${name}_sourceState`,\n });\n\n const wrappedSet = runInInjectionContext(sourceInjector, () =>\n injectFnWrapper()((value: T) => sourceState.set(value)),\n );\n const set = (value: T) =>\n runInInjectionContext(sourceInjector, () => wrappedSet(value));\n\n const listener = (listenerOptions: { nullishFirstValue?: boolean }) =>\n linkedSignal<T, T | undefined>({\n source: sourceState as Signal<T>,\n computation: (currentSourceState, previousData) => {\n // always when first listened return undefined\n if (!previousData && listenerOptions?.nullishFirstValue !== false) {\n return undefined;\n }\n return currentSourceState;\n },\n ...(options?.equal && { equal: options?.equal }),\n debugName: name,\n });\n\n const result = listener({\n nullishFirstValue: true,\n });\n\n const registry = inject(APP_SNAPSHOT_REGISTRY, { optional: true });\n if (registry) {\n const from = sourceInjector.get(ɵHOST_TAG_LIST, null) ?? [];\n registry.triggerSnapshot$\n .pipe(takeUntilDestroyed(destroyRef))\n .subscribe(() => {\n let stateSnapshot: unknown;\n try {\n stateSnapshot = result();\n } catch (error) {\n stateSnapshot = {\n error: error instanceof Error ? error.message : String(error),\n };\n }\n registry.allSnapShot$.next({\n source: name,\n from,\n state: stateSnapshot,\n });\n });\n }\n\n return Object.assign(\n result,\n {\n preserveLastValue: listener({\n nullishFirstValue: false,\n }),\n set,\n },\n SourceBranded,\n ) as unknown as SignalSource<T>;\n}\n"]}
@@ -0,0 +1,121 @@
1
+ import { EventEmitter, Signal } from './host/craft-compat';
2
+ import type { SERVICE_HELPER_DEPENDENCIES, ServiceDependencies } from './craft-service';
3
+ import { type NamedCraftPrimitiveGen } from './craft-primitive-gen';
4
+ export type SourceDependency<Name extends string> = {
5
+ [K in Name]: ServiceDependencies<'function', {}>;
6
+ };
7
+ type SourceDependencyCarrier<Name extends string> = {
8
+ readonly [SERVICE_HELPER_DEPENDENCIES]?: SourceDependency<Name>;
9
+ };
10
+ export type SourceSubscribe<T> = {
11
+ subscribe: (callback: (value: T) => void) => ReturnType<EventEmitter<T>['subscribe']>;
12
+ };
13
+ export type SourceInstance<T, Name extends string = string> = SourceDependencyCarrier<Name> & {
14
+ emit: (value: T) => void;
15
+ subscribe: (callback: (value: T) => void) => ReturnType<EventEmitter<T>['subscribe']>;
16
+ asReadonly: () => ReadonlySource$<T, Name>;
17
+ preserveLastValue: () => PreservedSource$<T, Name>;
18
+ value: Signal<T | undefined>;
19
+ };
20
+ export type Source$<T, Name extends string = string> = SourceInstance<T, Name> & NamedCraftPrimitiveGen<Name, SourceInstance<T, Name>>;
21
+ export type PreservedSource$<T, Name extends string = string> = SourceDependencyCarrier<Name> & {
22
+ emit: (value: T) => void;
23
+ subscribe: (callback: (value: T) => void) => void;
24
+ asReadonly: () => ReadonlySource$<T, Name>;
25
+ value: Signal<T | undefined>;
26
+ };
27
+ export type ReadonlySource$<T, Name extends string = string> = SourceDependencyCarrier<Name> & {
28
+ subscribe: (callback: (value: T) => void) => ReturnType<EventEmitter<T>['subscribe']>;
29
+ value: Signal<T | undefined>;
30
+ };
31
+ /**
32
+ * Creates an event emitter with automatic cleanup and signal-based value tracking.
33
+ *
34
+ * `source$` provides a lightweight event streaming solution that combines event emission,
35
+ * automatic subscription cleanup via `DestroyRef`, and signal-based reactive value tracking.
36
+ *
37
+ * @template T - The type of values emitted by the source
38
+ *
39
+ * @param name - Name matching the variable/property this source is assigned to (used for host
40
+ * tagging and dev-tools snapshot reporting, consistent with `craftComputed`/`craftEffect`)
41
+ *
42
+ * @returns {Source$<T>} A source object that is also a named primitive
43
+ * generator. Use it directly with `emit()`/`subscribe()`, or consume it with
44
+ * `yield*` to obtain `{ [name]: source }` and propagate its dependency metadata.
45
+ * - `emit(value: T)` - Emits a value to all subscribers and updates the internal signal
46
+ * - `subscribe(callback: (value: T) => void)` - Subscribes to emissions with automatic cleanup
47
+ * - `value: Signal<T | undefined>` - A read-only signal containing the last emitted value
48
+ * - `asReadonly()` - Returns a read-only version (only `subscribe` and `value`)
49
+ * - `preserveLastValue()` - Returns a variant that immediately emits the last value to new subscribers
50
+ *
51
+ * @example
52
+ * Yieldable source service
53
+ * ```typescript
54
+ * const { Reset } = craftService(
55
+ * { name: 'Reset', providedIn: 'global' },
56
+ * function* () {
57
+ * const reset$ = yield* source$<void>('reset$');
58
+ * return reset$;
59
+ * },
60
+ * );
61
+ *
62
+ * const reset = yield* Reset();
63
+ * reset.emit();
64
+ * ```
65
+ *
66
+ * @example
67
+ * Basic usage with state coordination
68
+ * ```typescript
69
+ * import { source$, state, on$ } from '@craft-ts/core';
70
+ *
71
+ * @Component({
72
+ * selector: 'app-counter',
73
+ * template: `
74
+ * <p>Count: {{ counter() }}</p>
75
+ * <button (click)="counter.increment()">+1</button>
76
+ * <button (click)="reset$.emit()">Reset</button>
77
+ * `,
78
+ * })
79
+ * export class CounterComponent {
80
+ * reset$ = source$<void>('reset$');
81
+ *
82
+ * counter = craftUse(state(0, ({ set, update }) => ({
83
+ * increment: () => update((v) => v + 1),
84
+ * reset: on$(this.reset$, () => set(0)),
85
+ * })));
86
+ * }
87
+ * ```
88
+ *
89
+ *
90
+ * @example
91
+ * Late subscriber with preserved last value
92
+ * ```typescript
93
+ * const notifications$ = source$<string>('notifications$').preserveLastValue();
94
+ *
95
+ * notifications$.emit('Server started');
96
+ * notifications$.emit('Database connected');
97
+ *
98
+ * // Late subscriber receives the last value immediately
99
+ * notifications$.subscribe((msg) => {
100
+ * console.log(msg); // 'Database connected'
101
+ * });
102
+ * ```
103
+ *
104
+ * @example
105
+ * Read-only access pattern
106
+ * ```typescript
107
+ * class DataService {
108
+ * private dataUpdated$ = source$<Data>('dataUpdated$');
109
+ * readonly dataUpdated = this.dataUpdated$.asReadonly();
110
+ *
111
+ * updateData(data: Data) {
112
+ * this.dataUpdated$.emit(data);
113
+ * }
114
+ * }
115
+ * ```
116
+ *
117
+ * @see {@link https://craft-ts.dev/utils/source$ | source$ documentation}
118
+ */
119
+ export declare function source$<T, Name extends string = string>(name: Name): Source$<T, Name>;
120
+ export {};
121
+ //# sourceMappingURL=source$.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"source$.d.ts","sourceRoot":"","sources":["../../../../../libs/core/src/lib/source$.ts"],"names":[],"mappings":"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"}