@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,50 @@
1
+ import { effect, untracked } from '../host/craft-compat';
2
+ export const SourceBrand = Symbol('SourceBrand');
3
+ export const SourceBranded = {
4
+ [SourceBrand]: true,
5
+ };
6
+ /**
7
+ * Works for Source and ReadonlySource
8
+ */
9
+ export function isSource(value) {
10
+ return (typeof value === 'object' && value !== null) ||
11
+ typeof value === 'function'
12
+ ? SourceBrand in value
13
+ : false;
14
+ }
15
+ export function capitalize(str) {
16
+ return (str.charAt(0).toUpperCase() + str.slice(1));
17
+ }
18
+ export function createMethodHandlers(methodsData, state, options) {
19
+ const { methodsConnectedToSource, methods } = Object.entries(methodsData ?? {}).reduce((acc, [methodName, methodValue]) => {
20
+ if (isSource(methodValue)) {
21
+ acc.methodsConnectedToSource.push(methodValue);
22
+ return acc;
23
+ }
24
+ acc.methods[methodName] = methodValue;
25
+ return acc;
26
+ }, {
27
+ methodsConnectedToSource: [],
28
+ methods: {},
29
+ });
30
+ const finalMethods = Object.entries(methods ?? {}).reduce((acc, [methodName, method]) => {
31
+ acc[methodName] = (...args) => {
32
+ const result = method(...args);
33
+ state.set(result);
34
+ options?.onStateChange?.(result);
35
+ };
36
+ return acc;
37
+ }, {});
38
+ methodsConnectedToSource.forEach((sourceSignal) => {
39
+ effect(() => {
40
+ const newValue = sourceSignal();
41
+ untracked(() => {
42
+ if (newValue !== undefined) {
43
+ state.set(newValue);
44
+ }
45
+ });
46
+ });
47
+ });
48
+ return finalMethods;
49
+ }
50
+ //# sourceMappingURL=util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"util.js","sourceRoot":"","sources":["../../../../../../libs/core/src/lib/util/util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAkB,MAAM,sBAAsB,CAAC;AAGzE,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC,aAAa,CAAC,CAAC;AAEjD,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,CAAC,WAAW,CAAC,EAAE,IAAa;CAC7B,CAAC;AAMF;;GAEG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAU;IACjC,OAAO,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC;QAClD,OAAO,KAAK,KAAK,UAAU;QAC3B,CAAC,CAAC,WAAW,IAAI,KAAK;QACtB,CAAC,CAAC,KAAK,CAAC;AACZ,CAAC;AAID,MAAM,UAAU,UAAU,CAAmB,GAAM;IACjD,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAkB,CAAC;AACvE,CAAC;AAED,MAAM,UAAU,oBAAoB,CAClC,WAKa,EACb,KAA4B,EAC5B,OAEC;IAED,MAAM,EAAE,wBAAwB,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC,OAAO,CAC1D,WAAW,IA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,CAAC","sourcesContent":["import { effect, untracked, WritableSignal } from '../host/craft-compat';\nimport { ReadonlySource } from './source.type';\n\nexport const SourceBrand = Symbol('SourceBrand');\n\nexport const SourceBranded = {\n [SourceBrand]: true as const,\n};\n\nexport type SourceBranded = {\n [SourceBrand]: true;\n};\n\n/**\n * Works for Source and ReadonlySource\n */\nexport function isSource(value: any): boolean {\n return (typeof value === 'object' && value !== null) ||\n typeof value === 'function'\n ? SourceBrand in value\n : false;\n}\n\nexport type SourceBrand = typeof SourceBrand;\n\nexport function capitalize<S extends string>(str: S): Capitalize<S> {\n return (str.charAt(0).toUpperCase() + str.slice(1)) as Capitalize<S>;\n}\n\nexport function createMethodHandlers<State>(\n methodsData:\n | Record<\n string,\n ((...args: any[]) => NoInfer<State>) | ReadonlySource<State>\n >\n | undefined,\n state: WritableSignal<State>,\n options?: {\n onStateChange?: (newValue: State) => void;\n },\n) {\n const { methodsConnectedToSource, methods } = Object.entries(\n methodsData ?? {},\n ).reduce(\n (acc, [methodName, methodValue]) => {\n if (isSource(methodValue)) {\n acc.methodsConnectedToSource.push(\n methodValue as ReadonlySource<unknown>,\n );\n return acc;\n }\n acc.methods[methodName] = methodValue as Function;\n return acc;\n },\n {\n methodsConnectedToSource: [],\n methods: {},\n } as {\n methodsConnectedToSource: ReadonlySource<unknown>[];\n methods: Record<string, Function>;\n },\n );\n\n const finalMethods = Object.entries(methods ?? {}).reduce(\n (acc, [methodName, method]) => {\n acc[methodName] = (...args: any[]) => {\n const result = method(...args);\n state.set(result);\n options?.onStateChange?.(result);\n };\n return acc;\n },\n {} as Record<string, Function>,\n );\n\n methodsConnectedToSource.forEach((sourceSignal) => {\n effect(() => {\n const newValue = sourceSignal();\n untracked(() => {\n if (newValue !== undefined) {\n state.set(newValue as NoInfer<State>);\n }\n });\n });\n });\n return finalMethods;\n}\n"]}
@@ -0,0 +1,107 @@
1
+ import { EventEmitter, Type } from '../host/craft-compat';
2
+ import { SignalSource } from '../signal-source';
3
+ import { ExtractSignalPropsAndMethods } from './extract-signal-props-and-methods';
4
+ import { ReadonlySource } from './source.type';
5
+ import { SourceBranded } from './util';
6
+ export type FilterPrivateFields<T> = {
7
+ [K in keyof T as K extends `_${string}` ? never : K]: T[K];
8
+ };
9
+ export type ToConnectableSourceFromInject<Sources> = {
10
+ [K in keyof Sources]: Sources[K] extends SignalSource<infer SourceType> ? ReadonlySource<SourceType> : never;
11
+ };
12
+ export type ToConnectableMethodFromInject<Methods> = RemoveIndexSignature<{
13
+ [K in keyof Methods]?: Methods[K] extends (payload: infer Payload) => any ? IsUnknown<Payload> extends true ? ReadonlySource<any> | {
14
+ subscribe: EventEmitter<any>['subscribe'];
15
+ } : ReadonlySource<Payload> | {
16
+ subscribe: EventEmitter<Payload>['subscribe'];
17
+ } : never;
18
+ }>;
19
+ export type IsUnknown<T> = unknown extends T ? [T] extends [unknown] ? true : false : false;
20
+ export type RemoveIndexSignature<T> = {
21
+ [K in keyof T as string extends K ? never : number extends K ? never : symbol extends K ? never : K]: T[K];
22
+ };
23
+ export type IsEmptyObject<T> = keyof T extends never ? true : false;
24
+ export type ExcludeCommonKeys<Origin, Target> = {
25
+ [key in keyof Origin as key extends keyof Target ? never : key]: Origin[key];
26
+ };
27
+ export declare const STORE_CONFIG_TOKEN: {
28
+ readonly NAME: "_STORE_NAME_";
29
+ readonly PROVIDED_IN: "_STORE_PROVIDED_IN_";
30
+ };
31
+ export type StoreConfigToken = typeof STORE_CONFIG_TOKEN;
32
+ export type FilterMethodsBoundToSources<Methods extends {}, Rest, MethodPrefix extends string, MethodName extends string, Acc = {}> = Rest extends [infer First, ...infer Next] ? First extends keyof Methods ? Methods[First] extends {
33
+ [Key in MethodName]: infer Method;
34
+ } ? [Method] extends [ReadonlySource<infer SourceState>] ? FilterMethodsBoundToSources<Methods, Next, MethodPrefix, MethodName, Acc> : FilterMethodsBoundToSources<Methods, Next, MethodPrefix, MethodName, Acc & {
35
+ [K in First as `${MethodPrefix}${Capitalize<string & K>}`]: [
36
+ Method
37
+ ] extends [Function] ? Method : never;
38
+ }> : FilterMethodsBoundToSources<Methods, Next, MethodPrefix, MethodName, Acc> : FilterMethodsBoundToSources<Methods, Next, MethodPrefix, MethodName, Acc> : Acc;
39
+ export type FilterSource<Insertions> = {
40
+ [K in keyof Insertions as Insertions[K] extends SourceBranded ? never : K]: Insertions[K];
41
+ };
42
+ export type DeferredExtract<Insertions> = UnionToTuple<keyof Insertions> extends infer Keys ? ExtractSignalPropsAndMethods<Insertions, Keys, {
43
+ props: {};
44
+ methods: Record<string, Function>;
45
+ }> : never;
46
+ export type HasKeys<T> = T extends object ? keyof T extends never ? false : true : false;
47
+ type _FlatRecord<T> = T[keyof T] extends infer U ? {
48
+ [K in keyof U]: U[K];
49
+ } : never;
50
+ export type FlatRecord<T> = Prettify<UnionToIntersection<_FlatRecord<T>>>;
51
+ export type MakeOptionalPropertiesRequired<T, K extends keyof T = keyof T> = T & {
52
+ [P in K]-?: T[P];
53
+ };
54
+ export type MergeObject<A, B> = A & B;
55
+ export type MergeObjects<F extends unknown[], Acc = {}> = F extends [
56
+ infer First,
57
+ ...infer Rest
58
+ ] ? First extends object ? MergeObjects<Rest, MergeObject<Acc, First>> : Prettify<Acc> : Prettify<Acc>;
59
+ /**
60
+ * trick to combine multiple unions of objects into a single object
61
+ * only works with objects not primitives
62
+ * @param union - Union of objects
63
+ * @returns Intersection of objects
64
+ */
65
+ export type UnionToIntersection<union> = (union extends any ? (k: union) => void : never) extends (k: infer intersection) => void ? intersection : never;
66
+ /**
67
+ * get last element of union
68
+ * @param Union - Union of any types
69
+ * @returns Last element of union
70
+ */
71
+ type GetUnionLast<Union> = UnionToIntersection<Union extends any ? () => Union : never> extends () => infer Last ? Last : never;
72
+ /**
73
+ * Convert union to tuple
74
+ * @param Union - Union of any types, can be union of complex, composed or primitive types
75
+ * @returns Tuple of each elements in the union
76
+ */
77
+ export type UnionToTuple<Union, Tuple extends unknown[] = []> = [
78
+ Union
79
+ ] extends [never] ? Tuple : UnionToTuple<Exclude<Union, GetUnionLast<Union>>, [
80
+ GetUnionLast<Union>,
81
+ ...Tuple
82
+ ]>;
83
+ export type HasChild<T> = T extends any[] ? false : T extends object ? true : false;
84
+ export type OmitStrict<T, K extends keyof T> = T extends any ? Pick<T, Exclude<keyof T, K>> : never;
85
+ /**
86
+ * Negates a boolean type.
87
+ */
88
+ export type Not<T extends boolean> = T extends true ? false : true;
89
+ /**
90
+ * @internal
91
+ */
92
+ declare const secret: unique symbol;
93
+ /**
94
+ * @internal
95
+ */
96
+ type Secret = typeof secret;
97
+ /**
98
+ * Checks if the given type is `never`.
99
+ */
100
+ export type IsNever<T> = [T] extends [never] ? true : false;
101
+ export type IsAny<T> = [T] extends [Secret] ? Not<IsNever<T>> : false;
102
+ export type InferInjectedType<T extends Type<unknown>> = T extends Type<infer U> ? U : never;
103
+ export type Prettify<T> = {
104
+ [K in keyof T]: T[K];
105
+ } & {};
106
+ export {};
107
+ //# sourceMappingURL=util.type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"util.type.d.ts","sourceRoot":"","sources":["../../../../../../libs/core/src/lib/util/util.type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,4BAA4B,EAAE,MAAM,oCAAoC,CAAC;AAClF,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAEvC,MAAM,MAAM,mBAAmB,CAAC,CAAC,IAAI;KAClC,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,SAAS,IAAI,MAAM,EAAE,GAAG,KAAK,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAC3D,CAAC;AAEF,MAAM,MAAM,6BAA6B,CAAC,OAAO,IAAI;KAClD,CAAC,IAAI,MAAM,OAA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C,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,IAAI,GAAG,KAAK,CAAC;AAE5D,MAAM,MAAM,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC;AAEtE,MAAM,MAAM,iBAAiB,CAAC,CAAC,SAAS,IAAI,CAAC,OAAO,CAAC,IACnD,CAAC,SAAS,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAEtC,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI;KACvB,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CACrB,GAAG,EAAE,CAAC"}
@@ -0,0 +1,9 @@
1
+ export const STORE_CONFIG_TOKEN = {
2
+ NAME: '_STORE_NAME_',
3
+ PROVIDED_IN: '_STORE_PROVIDED_IN_',
4
+ };
5
+ /**
6
+ * @internal
7
+ */
8
+ const secret = Symbol('secret');
9
+ //# sourceMappingURL=util.type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"util.type.js","sourceRoot":"","sources":["../../../../../../libs/core/src/lib/util/util.type.ts"],"names":[],"mappings":"AAsDA,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,IAAI,EAAE,cAAc;IACpB,WAAW,EAAE,qBAAqB;CAC1B,CAAC;AAiJX;;GAEG;AACH,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC","sourcesContent":["import { EventEmitter, Type } from '../host/craft-compat';\nimport { SignalSource } from '../signal-source';\nimport { ExtractSignalPropsAndMethods } from './extract-signal-props-and-methods';\nimport { ReadonlySource } from './source.type';\nimport { SourceBranded } from './util';\n\nexport type FilterPrivateFields<T> = {\n [K in keyof T as K extends `_${string}` ? never : K]: T[K];\n};\n\nexport type ToConnectableSourceFromInject<Sources> = {\n [K in keyof Sources]: Sources[K] extends SignalSource<infer SourceType>\n ? ReadonlySource<SourceType>\n : never;\n};\n\nexport type ToConnectableMethodFromInject<Methods> = RemoveIndexSignature<{\n [K in keyof Methods]?: Methods[K] extends (payload: infer Payload) => any\n ? IsUnknown<Payload> extends true\n ?\n | ReadonlySource<any>\n | {\n subscribe: EventEmitter<any>['subscribe'];\n }\n :\n | ReadonlySource<Payload>\n | {\n subscribe: EventEmitter<Payload>['subscribe'];\n }\n : never;\n}>;\n\nexport type IsUnknown<T> = unknown extends T\n ? [T] extends [unknown]\n ? true\n : false\n : false;\n\nexport type RemoveIndexSignature<T> = {\n [K in keyof T as string extends K\n ? never\n : number extends K\n ? never\n : symbol extends K\n ? never\n : K]: T[K];\n};\n\nexport type IsEmptyObject<T> = keyof T extends never ? true : false;\n\nexport type ExcludeCommonKeys<Origin, Target> = {\n [key in keyof Origin as key extends keyof Target ? never : key]: Origin[key];\n};\n\nexport const STORE_CONFIG_TOKEN = {\n NAME: '_STORE_NAME_',\n PROVIDED_IN: '_STORE_PROVIDED_IN_',\n} as const;\nexport type StoreConfigToken = typeof STORE_CONFIG_TOKEN;\n\nexport type FilterMethodsBoundToSources<\n Methods extends {},\n Rest,\n MethodPrefix extends string,\n MethodName extends string,\n Acc = {},\n> = Rest extends [infer First, ...infer Next]\n ? First extends keyof Methods\n ? Methods[First] extends {\n [Key in MethodName]: infer Method;\n }\n ? [Method] extends [ReadonlySource<infer SourceState>]\n ? FilterMethodsBoundToSources<\n Methods,\n Next,\n MethodPrefix,\n MethodName,\n Acc\n >\n : FilterMethodsBoundToSources<\n Methods,\n Next,\n MethodPrefix,\n MethodName,\n Acc & {\n [K in First as `${MethodPrefix}${Capitalize<string & K>}`]: [\n Method,\n ] extends [Function]\n ? Method\n : never;\n }\n >\n : FilterMethodsBoundToSources<\n Methods,\n Next,\n MethodPrefix,\n MethodName,\n Acc\n >\n : FilterMethodsBoundToSources<Methods, Next, MethodPrefix, MethodName, Acc>\n : Acc;\n\nexport type FilterSource<Insertions> = {\n [K in keyof Insertions as Insertions[K] extends SourceBranded\n ? never\n : K]: Insertions[K];\n};\n\n// Helper type to defer evaluation and avoid infinite recursion\nexport type DeferredExtract<Insertions> =\n UnionToTuple<keyof Insertions> extends infer Keys\n ? ExtractSignalPropsAndMethods<\n Insertions,\n Keys,\n { props: {}; methods: Record<string, Function> }\n >\n : never;\n\nexport type HasKeys<T> = T extends object\n ? keyof T extends never\n ? false\n : true\n : false;\ntype _FlatRecord<T> = T[keyof T] extends infer U\n ? { [K in keyof U]: U[K] }\n : never;\n\nexport type FlatRecord<T> = Prettify<UnionToIntersection<_FlatRecord<T>>>;\n\n// It is not possible to get all the properties key of an optional object, so make the optional properties required\nexport type MakeOptionalPropertiesRequired<\n T,\n K extends keyof T = keyof T,\n> = T & {\n [P in K]-?: T[P];\n};\n\nexport type MergeObject<A, B> = A & B;\n\nexport type MergeObjects<F extends unknown[], Acc = {}> = F extends [\n infer First,\n ...infer Rest,\n]\n ? First extends object\n ? MergeObjects<Rest, MergeObject<Acc, First>>\n : Prettify<Acc>\n : Prettify<Acc>;\n\n// from https://github.com/ecyrbe/zodios/blob/main/src/utils.types.ts\n/**\n * trick to combine multiple unions of objects into a single object\n * only works with objects not primitives\n * @param union - Union of objects\n * @returns Intersection of objects\n */\nexport type UnionToIntersection<union> = (\n union extends any ? (k: union) => void : never\n) extends (k: infer intersection) => void\n ? intersection\n : never;\n\n/**\n * get last element of union\n * @param Union - Union of any types\n * @returns Last element of union\n */\ntype GetUnionLast<Union> =\n UnionToIntersection<\n Union extends any ? () => Union : never\n > extends () => infer Last\n ? Last\n : never;\n\n/**\n * Convert union to tuple\n * @param Union - Union of any types, can be union of complex, composed or primitive types\n * @returns Tuple of each elements in the union\n */\nexport type UnionToTuple<Union, Tuple extends unknown[] = []> = [\n Union,\n] extends [never]\n ? Tuple\n : UnionToTuple<\n Exclude<Union, GetUnionLast<Union>>,\n [GetUnionLast<Union>, ...Tuple]\n >;\n\nexport type HasChild<T> = T extends any[]\n ? false\n : T extends object\n ? true\n : false;\n\nexport type OmitStrict<T, K extends keyof T> = T extends any\n ? Pick<T, Exclude<keyof T, K>>\n : never;\n\n/**\n * Negates a boolean type.\n */\nexport type Not<T extends boolean> = T extends true ? false : true;\n\n/**\n * @internal\n */\nconst secret = Symbol('secret');\n\n/**\n * @internal\n */\ntype Secret = typeof secret;\n\n/**\n * Checks if the given type is `never`.\n */\nexport type IsNever<T> = [T] extends [never] ? true : false;\n\nexport type IsAny<T> = [T] extends [Secret] ? Not<IsNever<T>> : false;\n\nexport type InferInjectedType<T extends Type<unknown>> =\n T extends Type<infer U> ? U : never;\n\nexport type Prettify<T> = {\n [K in keyof T]: T[K];\n} & {};\n"]}
@@ -0,0 +1,94 @@
1
+ import { type Injector, type Signal } from './host/craft-compat';
2
+ import { type ResolveGeneratorResult } from './craft-generator-runtime';
3
+ import { type NamedYieldableValue, type YieldableReactiveProperties, type YieldableReactiveValue } from './reactive-read';
4
+ export { YIELDABLE_VALUE, type NamedYieldableValue } from './reactive-read';
5
+ /** Shared brand used by Craft methods that are safe to delegate with `yield*`. */
6
+ export declare const YIELDABLE_METHOD: unique symbol;
7
+ /** Brand used by insertion-owned synchronous selectors/read helpers. */
8
+ export declare const NON_YIELDABLE_INSERTION_METHOD: unique symbol;
9
+ /** A signal whose template projection can be consumed with `yield*`. */
10
+ export type YieldableSignal<Name extends string, Value> = NamedYieldableValue<Name, Signal<Value>>;
11
+ /** Projects every exposed reactive property to the public reader contract. */
12
+ export type BrandReactiveProperties<Shape> = YieldableReactiveProperties<Shape>;
13
+ export type Yieldable<Args extends unknown[] = unknown[], Result = unknown, Yielded = unknown> = (...args: Args) => Generator<Yielded, Result, unknown>;
14
+ /**
15
+ * A normal callable carrying the yieldable contract as a phantom property.
16
+ * The normal call signature is intentionally preserved so existing imperative
17
+ * consumers keep type-checking; templates project this brand to `Yieldable`.
18
+ */
19
+ export type YieldableMethod<Args extends unknown[] = unknown[], Result = unknown, Yielded = unknown> = ((...args: Args) => Result) & {
20
+ readonly [YIELDABLE_METHOD]: {
21
+ readonly args?: Args;
22
+ readonly result?: Result;
23
+ readonly yielded?: Yielded;
24
+ };
25
+ };
26
+ /** A primitive trigger invocation consumed with `yield*`. */
27
+ export type YieldableInvocation<Yielded = unknown, Result = unknown> = Generator<Yielded, Result, unknown>;
28
+ /**
29
+ * A method exposed by an insertion. Calling it returns an invocation which can
30
+ * be delegated with `yield*`.
31
+ */
32
+ export type YieldableInsertionMethod<Args extends unknown[] = unknown[], Result = unknown, Yielded = unknown> = ((...args: Args) => YieldableInvocation<Yielded, Result>) & {
33
+ readonly [YIELDABLE_METHOD]?: {
34
+ readonly args?: Args;
35
+ readonly result?: Result;
36
+ readonly yielded?: Yielded;
37
+ };
38
+ };
39
+ export type NonYieldableInsertionMethod<Args extends unknown[] = unknown[], Result = unknown> = ((...args: Args) => Result) & {
40
+ readonly [NON_YIELDABLE_INSERTION_METHOD]: true;
41
+ };
42
+ type YieldableInsertionMethodOf<Fn> = Fn extends NonYieldableInsertionMethod<any, any> ? Fn : Fn extends YieldableReactiveValue<any, any> ? Fn : Fn extends Signal<any> ? Fn : Fn extends {
43
+ emit: (...args: infer Args) => infer Result;
44
+ subscribe: (...args: any[]) => any;
45
+ value: unknown;
46
+ } ? Omit<Fn, 'emit'> & {
47
+ readonly emit: YieldableInsertionMethod<Args, Result>;
48
+ } : Fn extends YieldableInsertionMethod<any, any, any> ? Fn : Fn extends (...args: infer Args) => infer Result ? Result extends Generator<infer Yielded, infer Output, unknown> ? YieldableInsertionMethod<Args, Output, Yielded> : YieldableInsertionMethod<Args, Result> : Fn;
49
+ /** Maps callable insertion outputs to methods consumed with `yield*`. */
50
+ export type YieldableInsertionMethods<Shape> = Shape extends (...args: infer Args) => infer Result ? ((...args: Args) => Result) & {
51
+ [Key in keyof Shape]: YieldableInsertionMethodOf<Shape[Key]>;
52
+ } : {
53
+ [Key in keyof Shape]: YieldableInsertionMethodOf<Shape[Key]>;
54
+ };
55
+ /**
56
+ * Keeps an already-resolved primitive trigger result composable with `yield*`.
57
+ * Primitive methods still resolve their parameters at call time so existing
58
+ * imperative triggers keep their execution timing; the returned invocation is
59
+ * the dependency-tracking boundary consumed by generator hosts.
60
+ */
61
+ export declare function yieldableInvocation<Yielded = never, Result = unknown>(result: Result): YieldableInvocation<Yielded, Result>;
62
+ export type YieldableInsertionRuntimeOptions = Readonly<{
63
+ injector: Injector;
64
+ invalidYieldErrorMessage: string;
65
+ multipleAppStartErrorMessage: string;
66
+ onAppStartNotSupportedErrorMessage: string;
67
+ }>;
68
+ /**
69
+ * Wraps an insertion method while preserving the existing eager Craft method
70
+ * execution semantics. The resolved result is exposed as a generator so the
71
+ * caller must explicitly consume the action with `yield*`.
72
+ */
73
+ export declare function createYieldableInsertionMethod<Fn extends (...args: any[]) => any>(fn: Fn, options: YieldableInsertionRuntimeOptions): YieldableInsertionMethodOf<Fn>;
74
+ export type YieldableMethodOf<Fn> = Fn extends (...args: infer Args) => infer Result ? YieldableMethod<Args, Result> : Fn;
75
+ export type YieldableMethods<Shape> = {
76
+ [Key in keyof Shape]: Shape[Key] extends (...args: infer Args) => infer Result ? YieldableMethod<Args, Result> : Shape[Key];
77
+ };
78
+ export declare function markYieldableMethod<Fn extends (...args: any[]) => any>(fn: Fn): Fn & {
79
+ readonly [YIELDABLE_METHOD]: true;
80
+ };
81
+ export declare function markNonYieldableInsertionMethod<Fn extends (...args: any[]) => any>(fn: Fn): Fn & {
82
+ readonly [NON_YIELDABLE_INSERTION_METHOD]: true;
83
+ };
84
+ export declare function markYieldableValue<Name extends string, Value>(value: Value, name: Name): NamedYieldableValue<Name, Value>;
85
+ export declare function isYieldableValue(value: unknown): value is NamedYieldableValue;
86
+ /** Brands direct reactive members of a runtime value with their property names. */
87
+ export declare function markNamedReactiveProperties<Value>(value: Value): Value;
88
+ export declare function isYieldableMethod(value: unknown): boolean;
89
+ export declare function isNonYieldableInsertionMethod(value: unknown): boolean;
90
+ /** Wraps a sync callback while relaying an already-yieldable result unchanged. */
91
+ export declare function toYieldable<Args extends unknown[], Result, Yielded = unknown>(fn: (...args: Args) => Result | Generator<Yielded, Result, unknown>): Yieldable<Args, Result, Yielded>;
92
+ /** Drives a yieldable callback with the same generator runtime as Craft hosts. */
93
+ export declare function executeYieldable<Args extends unknown[], Result>(callback: (...args: Args) => Result, args: Args, injector: Injector): ResolveGeneratorResult<Result>;
94
+ //# sourceMappingURL=yieldable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"yieldable.d.ts","sourceRoot":"","sources":["../../../../../libs/core/src/lib/yieldable.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,QAAQ,EACb,KAAK,MAAM,EACZ,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAIL,KAAK,sBAAsB,EAC5B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAEL,KAAK,mBAAmB,EACxB,KAAK,2BAA2B,EAChC,KAAK,sBAAsB,EAC5B,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,eAAe,EAAE,KAAK,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAE5E,kFAAkF;AAClF,eAAO,MAAM,gBAAgB,eAAmC,CAAC;AAEjE,wEAAwE;AACxE,eAAO,MAAM,8BAA8B,eAE1C,CAAC;AAEF,wEAAwE;AACxE,MAAM,MAAM,eAAe,CAAC,IAAI,SAAS,MAAM,EAAE,KAAK,IAAI,mBAAmB,CAC3E,IAAI,EACJ,MAAM,CAAC,KAAK,CAAC,CACd,CAAC;AAEF,8EAA8E;AAC9E,MAAM,MAAM,uBAAuB,CAAC,KAAK,IAAI,2BAA2B,CAAC,KAAK,CAAC,CAAC;AAEhF,MAAM,MAAM,SAAS,CACnB,IAAI,SAAS,OAAO,EAAE,GAAG,OAAO,EAAE,EAClC,MAAM,GAAG,OAAO,EAChB,OAAO,GAAG,OAAO,IACf,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,SAAS,CAAC,OAAO,EAA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 +1,109 @@
1
+ import { isSignal, runInInjectionContext, } from './host/craft-compat';
2
+ import { executeGeneratorCompatibleFactory, isGenerator, runCraftGenerator, } from './craft-generator-runtime';
3
+ import { YIELDABLE_VALUE, } from './reactive-read';
4
+ export { YIELDABLE_VALUE } from './reactive-read';
5
+ /** Shared brand used by Craft methods that are safe to delegate with `yield*`. */
6
+ export const YIELDABLE_METHOD = Symbol('craft-yieldable-method');
7
+ /** Brand used by insertion-owned synchronous selectors/read helpers. */
8
+ export const NON_YIELDABLE_INSERTION_METHOD = Symbol('craft-non-yieldable-insertion-method');
9
+ /**
10
+ * Keeps an already-resolved primitive trigger result composable with `yield*`.
11
+ * Primitive methods still resolve their parameters at call time so existing
12
+ * imperative triggers keep their execution timing; the returned invocation is
13
+ * the dependency-tracking boundary consumed by generator hosts.
14
+ */
15
+ export function yieldableInvocation(result) {
16
+ return (function* () {
17
+ return result;
18
+ })();
19
+ }
20
+ /**
21
+ * Wraps an insertion method while preserving the existing eager Craft method
22
+ * execution semantics. The resolved result is exposed as a generator so the
23
+ * caller must explicitly consume the action with `yield*`.
24
+ */
25
+ export function createYieldableInsertionMethod(fn, options) {
26
+ const method = (...args) => {
27
+ const result = runInInjectionContext(options.injector, () => {
28
+ const value = fn(...args);
29
+ if (!isGenerator(value)) {
30
+ return value;
31
+ }
32
+ return runCraftGenerator({
33
+ iterator: value,
34
+ injector: options.injector,
35
+ hostScope: 'function',
36
+ invalidYieldErrorMessage: options.invalidYieldErrorMessage,
37
+ multipleAppStartErrorMessage: options.multipleAppStartErrorMessage,
38
+ onAppStartNotSupportedErrorMessage: options.onAppStartNotSupportedErrorMessage,
39
+ }).value;
40
+ });
41
+ return yieldableInvocation(result);
42
+ };
43
+ return markYieldableMethod(method);
44
+ }
45
+ export function markYieldableMethod(fn) {
46
+ Object.defineProperty(fn, YIELDABLE_METHOD, { value: true });
47
+ return fn;
48
+ }
49
+ export function markNonYieldableInsertionMethod(fn) {
50
+ Object.defineProperty(fn, NON_YIELDABLE_INSERTION_METHOD, { value: true });
51
+ return fn;
52
+ }
53
+ export function markYieldableValue(value, name) {
54
+ if (!isYieldableValue(value)) {
55
+ Object.defineProperty(value, YIELDABLE_VALUE, {
56
+ value: name,
57
+ enumerable: false,
58
+ });
59
+ }
60
+ return value;
61
+ }
62
+ export function isYieldableValue(value) {
63
+ return ((typeof value === 'function' ||
64
+ (typeof value === 'object' && value !== null)) &&
65
+ YIELDABLE_VALUE in value);
66
+ }
67
+ /** Brands direct reactive members of a runtime value with their property names. */
68
+ export function markNamedReactiveProperties(value) {
69
+ if (typeof value !== 'object' && typeof value !== 'function') {
70
+ return value;
71
+ }
72
+ for (const key of Reflect.ownKeys(value)) {
73
+ const child = Reflect.get(value, key);
74
+ if (typeof child !== 'function')
75
+ continue;
76
+ if (isSignal(child)) {
77
+ if (!isYieldableValue(child)) {
78
+ markYieldableValue(child, String(key));
79
+ }
80
+ }
81
+ }
82
+ return value;
83
+ }
84
+ export function isYieldableMethod(value) {
85
+ return typeof value === 'function' && YIELDABLE_METHOD in value;
86
+ }
87
+ export function isNonYieldableInsertionMethod(value) {
88
+ return typeof value === 'function' && NON_YIELDABLE_INSERTION_METHOD in value;
89
+ }
90
+ /** Wraps a sync callback while relaying an already-yieldable result unchanged. */
91
+ export function toYieldable(fn) {
92
+ return function* yieldableCallback(...args) {
93
+ const result = fn(...args);
94
+ return isGenerator(result) ? yield* result : result;
95
+ };
96
+ }
97
+ /** Drives a yieldable callback with the same generator runtime as Craft hosts. */
98
+ export function executeYieldable(callback, args, injector) {
99
+ return executeGeneratorCompatibleFactory({
100
+ factory: callback,
101
+ thisArg: undefined,
102
+ getInjector: () => injector,
103
+ args,
104
+ invalidYieldErrorMessage: 'Craft template callbacks can only yield Craft dependencies or yieldable methods.',
105
+ multipleAppStartErrorMessage: 'Craft template callbacks cannot declare onAppStart(...) more than once.',
106
+ onAppStartNotSupportedErrorMessage: 'Craft template callbacks do not support onAppStart(...).',
107
+ });
108
+ }
109
+ //# sourceMappingURL=yieldable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"yieldable.js","sourceRoot":"","sources":["../../../../../libs/core/src/lib/yieldable.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,qBAAqB,GAGtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,iCAAiC,EACjC,WAAW,EACX,iBAAiB,GAElB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,eAAe,GAIhB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,eAAe,EAA4B,MAAM,iBAAiB,CAAC;AAE5E,kFAAkF;AAClF,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,wBAAwB,CAAC,CAAC;AAEjE,wEAAwE;AACxE,MAAM,CAAC,MAAM,8BAA8B,GAAG,MAAM,CAClD,sCAAsC,CACvC,CAAC;AAiGF;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CACjC,MAAc;IAEd,OAAO,CAAC,QAAQ,CAAC;QACf,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC,EAAE,CAAC;AACP,CAAC;AASD;;;;GAIG;AACH,MAAM,UAAU,8BAA8B,CAG5C,EAAM,EACN,OAAyC;IAEzC,MAAM,MAAM,GAAG,CAAC,GAAG,IAAoB,EAAE,EAAE;QACzC,MAAM,MAAM,GAAG,qBAAqB,CAAC,OAAO,CAAC,QAAQ,EAAE,GAAG,EAAE;YAC1D,MAAM,KAAK,GAAG,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC;YAC1B,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE,CAAC;gBACxB,OAAO,KAAK,CAAC;YACf,CAAC;YAED,OAAO,iBAAiB,CAAC;gBACvB,QAAQ,EAAE,KAAK;gBACf,QAAQ,EAAE,OAAO,CAAC,QAAQ;gBAC1B,SAAS,EAAE,UAAU;gBACrB,wBAAwB,EAAE,OAAO,CAAC,wBAAwB;gBAC1D,4BAA4B,EAAE,OAAO,CAAC,4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ACpF,4BAA4B,EAC1B,yEAAyE;QAC3E,kCAAkC,EAChC,0DAA0D;KAC7D,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {\n isSignal,\n runInInjectionContext,\n type Injector,\n type Signal,\n} from './host/craft-compat';\nimport {\n executeGeneratorCompatibleFactory,\n isGenerator,\n runCraftGenerator,\n type ResolveGeneratorResult,\n} from './craft-generator-runtime';\nimport {\n YIELDABLE_VALUE,\n type NamedYieldableValue,\n type YieldableReactiveProperties,\n type YieldableReactiveValue,\n} from './reactive-read';\n\nexport { YIELDABLE_VALUE, type NamedYieldableValue } from './reactive-read';\n\n/** Shared brand used by Craft methods that are safe to delegate with `yield*`. */\nexport const YIELDABLE_METHOD = Symbol('craft-yieldable-method');\n\n/** Brand used by insertion-owned synchronous selectors/read helpers. */\nexport const NON_YIELDABLE_INSERTION_METHOD = Symbol(\n 'craft-non-yieldable-insertion-method',\n);\n\n/** A signal whose template projection can be consumed with `yield*`. */\nexport type YieldableSignal<Name extends string, Value> = NamedYieldableValue<\n Name,\n Signal<Value>\n>;\n\n/** Projects every exposed reactive property to the public reader contract. */\nexport type BrandReactiveProperties<Shape> = YieldableReactiveProperties<Shape>;\n\nexport type Yieldable<\n Args extends unknown[] = unknown[],\n Result = unknown,\n Yielded = unknown,\n> = (...args: Args) => Generator<Yielded, Result, unknown>;\n\n/**\n * A normal callable carrying the yieldable contract as a phantom property.\n * The normal call signature is intentionally preserved so existing imperative\n * consumers keep type-checking; templates project this brand to `Yieldable`.\n */\nexport type YieldableMethod<\n Args extends unknown[] = unknown[],\n Result = unknown,\n Yielded = unknown,\n> = ((...args: Args) => Result) & {\n readonly [YIELDABLE_METHOD]: {\n readonly args?: Args;\n readonly result?: Result;\n readonly yielded?: Yielded;\n };\n};\n\n/** A primitive trigger invocation consumed with `yield*`. */\nexport type YieldableInvocation<\n Yielded = unknown,\n Result = unknown,\n> = Generator<Yielded, Result, unknown>;\n\n/**\n * A method exposed by an insertion. Calling it returns an invocation which can\n * be delegated with `yield*`.\n */\nexport type YieldableInsertionMethod<\n Args extends unknown[] = unknown[],\n Result = unknown,\n Yielded = unknown,\n> = ((...args: Args) => YieldableInvocation<Yielded, Result>) & {\n readonly [YIELDABLE_METHOD]?: {\n readonly args?: Args;\n readonly result?: Result;\n readonly yielded?: Yielded;\n };\n};\n\nexport type NonYieldableInsertionMethod<\n Args extends unknown[] = unknown[],\n Result = unknown,\n> = ((...args: Args) => Result) & {\n readonly [NON_YIELDABLE_INSERTION_METHOD]: true;\n};\n\ntype YieldableInsertionMethodOf<Fn> =\n Fn extends NonYieldableInsertionMethod<any, any>\n ? Fn\n : Fn extends YieldableReactiveValue<any, any>\n ? Fn\n : Fn extends Signal<any>\n ? Fn\n : Fn extends {\n emit: (...args: infer Args) => infer Result;\n subscribe: (...args: any[]) => any;\n value: unknown;\n }\n ? Omit<Fn, 'emit'> & {\n readonly emit: YieldableInsertionMethod<Args, Result>;\n }\n : Fn extends YieldableInsertionMethod<any, any, any>\n ? Fn\n : Fn extends (...args: infer Args) => infer Result\n ? Result extends Generator<infer Yielded, infer Output, unknown>\n ? YieldableInsertionMethod<Args, Output, Yielded>\n : YieldableInsertionMethod<Args, Result>\n : Fn;\n\n/** Maps callable insertion outputs to methods consumed with `yield*`. */\nexport type YieldableInsertionMethods<Shape> = Shape extends (\n ...args: infer Args\n) => infer Result\n ? ((...args: Args) => Result) & {\n [Key in keyof Shape]: YieldableInsertionMethodOf<Shape[Key]>;\n }\n : {\n [Key in keyof Shape]: YieldableInsertionMethodOf<Shape[Key]>;\n };\n\n/**\n * Keeps an already-resolved primitive trigger result composable with `yield*`.\n * Primitive methods still resolve their parameters at call time so existing\n * imperative triggers keep their execution timing; the returned invocation is\n * the dependency-tracking boundary consumed by generator hosts.\n */\nexport function yieldableInvocation<Yielded = never, Result = unknown>(\n result: Result,\n): YieldableInvocation<Yielded, Result> {\n return (function* () {\n return result;\n })();\n}\n\nexport type YieldableInsertionRuntimeOptions = Readonly<{\n injector: Injector;\n invalidYieldErrorMessage: string;\n multipleAppStartErrorMessage: string;\n onAppStartNotSupportedErrorMessage: string;\n}>;\n\n/**\n * Wraps an insertion method while preserving the existing eager Craft method\n * execution semantics. The resolved result is exposed as a generator so the\n * caller must explicitly consume the action with `yield*`.\n */\nexport function createYieldableInsertionMethod<\n Fn extends (...args: any[]) => any,\n>(\n fn: Fn,\n options: YieldableInsertionRuntimeOptions,\n): YieldableInsertionMethodOf<Fn> {\n const method = (...args: Parameters<Fn>) => {\n const result = runInInjectionContext(options.injector, () => {\n const value = fn(...args);\n if (!isGenerator(value)) {\n return value;\n }\n\n return runCraftGenerator({\n iterator: value,\n injector: options.injector,\n hostScope: 'function',\n invalidYieldErrorMessage: options.invalidYieldErrorMessage,\n multipleAppStartErrorMessage: options.multipleAppStartErrorMessage,\n onAppStartNotSupportedErrorMessage:\n options.onAppStartNotSupportedErrorMessage,\n }).value;\n });\n\n return yieldableInvocation(result);\n };\n\n return markYieldableMethod(\n method,\n ) as unknown as YieldableInsertionMethodOf<Fn>;\n}\n\nexport type YieldableMethodOf<Fn> = Fn extends (\n ...args: infer Args\n) => infer Result\n ? YieldableMethod<Args, Result>\n : Fn;\n\nexport type YieldableMethods<Shape> = {\n [Key in keyof Shape]: Shape[Key] extends (...args: infer Args) => infer Result\n ? YieldableMethod<Args, Result>\n : Shape[Key];\n};\n\nexport function markYieldableMethod<Fn extends (...args: any[]) => any>(\n fn: Fn,\n): Fn & { readonly [YIELDABLE_METHOD]: true } {\n Object.defineProperty(fn, YIELDABLE_METHOD, { value: true });\n return fn as Fn & { readonly [YIELDABLE_METHOD]: true };\n}\n\nexport function markNonYieldableInsertionMethod<\n Fn extends (...args: any[]) => any,\n>(fn: Fn): Fn & { readonly [NON_YIELDABLE_INSERTION_METHOD]: true } {\n Object.defineProperty(fn, NON_YIELDABLE_INSERTION_METHOD, { value: true });\n return fn as Fn & { readonly [NON_YIELDABLE_INSERTION_METHOD]: true };\n}\n\nexport function markYieldableValue<Name extends string, Value>(\n value: Value,\n name: Name,\n): NamedYieldableValue<Name, Value> {\n if (!isYieldableValue(value)) {\n Object.defineProperty(value as object, YIELDABLE_VALUE, {\n value: name,\n enumerable: false,\n });\n }\n return value as NamedYieldableValue<Name, Value>;\n}\n\nexport function isYieldableValue(value: unknown): value is NamedYieldableValue {\n return (\n (typeof value === 'function' ||\n (typeof value === 'object' && value !== null)) &&\n YIELDABLE_VALUE in value\n );\n}\n\n/** Brands direct reactive members of a runtime value with their property names. */\nexport function markNamedReactiveProperties<Value>(value: Value): Value {\n if (typeof value !== 'object' && typeof value !== 'function') {\n return value;\n }\n\n for (const key of Reflect.ownKeys(value as object)) {\n const child = Reflect.get(value as object, key);\n if (typeof child !== 'function') continue;\n\n if (isSignal(child)) {\n if (!isYieldableValue(child)) {\n markYieldableValue(child, String(key));\n }\n }\n }\n\n return value;\n}\n\nexport function isYieldableMethod(value: unknown): boolean {\n return typeof value === 'function' && YIELDABLE_METHOD in value;\n}\n\nexport function isNonYieldableInsertionMethod(value: unknown): boolean {\n return typeof value === 'function' && NON_YIELDABLE_INSERTION_METHOD in value;\n}\n\n/** Wraps a sync callback while relaying an already-yieldable result unchanged. */\nexport function toYieldable<Args extends unknown[], Result, Yielded = unknown>(\n fn: (...args: Args) => Result | Generator<Yielded, Result, unknown>,\n): Yieldable<Args, Result, Yielded> {\n return function* yieldableCallback(...args: Args) {\n const result = fn(...args);\n return isGenerator(result) ? yield* result : (result as Result);\n };\n}\n\n/** Drives a yieldable callback with the same generator runtime as Craft hosts. */\nexport function executeYieldable<Args extends unknown[], Result>(\n callback: (...args: Args) => Result,\n args: Args,\n injector: Injector,\n): ResolveGeneratorResult<Result> {\n return executeGeneratorCompatibleFactory({\n factory: callback,\n thisArg: undefined,\n getInjector: () => injector,\n args,\n invalidYieldErrorMessage:\n 'Craft template callbacks can only yield Craft dependencies or yieldable methods.',\n multipleAppStartErrorMessage:\n 'Craft template callbacks cannot declare onAppStart(...) more than once.',\n onAppStartNotSupportedErrorMessage:\n 'Craft template callbacks do not support onAppStart(...).',\n });\n}\n"]}