@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.
- package/LICENSE +21 -0
- package/package.json +58 -0
- package/src/index.d.ts +148 -0
- package/src/index.d.ts.map +1 -0
- package/src/index.js +150 -0
- package/src/index.js.map +1 -0
- package/src/lib/after-recomputation.d.ts +327 -0
- package/src/lib/after-recomputation.d.ts.map +1 -0
- package/src/lib/after-recomputation.js +25 -0
- package/src/lib/after-recomputation.js.map +1 -0
- package/src/lib/app-checked-di.d.ts +82 -0
- package/src/lib/app-checked-di.d.ts.map +1 -0
- package/src/lib/app-checked-di.js +1 -0
- package/src/lib/app-checked-di.js.map +1 -0
- package/src/lib/async-process.d.ts +411 -0
- package/src/lib/async-process.d.ts.map +1 -0
- package/src/lib/async-process.js +702 -0
- package/src/lib/async-process.js.map +1 -0
- package/src/lib/branded-component/branded-component.d.ts +129 -0
- package/src/lib/branded-component/branded-component.d.ts.map +1 -0
- package/src/lib/branded-component/branded-component.js +7 -0
- package/src/lib/branded-component/branded-component.js.map +1 -0
- package/src/lib/browser-boundaries.d.ts +165 -0
- package/src/lib/browser-boundaries.d.ts.map +1 -0
- package/src/lib/browser-boundaries.js +550 -0
- package/src/lib/browser-boundaries.js.map +1 -0
- package/src/lib/client-di-requirement.d.ts +28 -0
- package/src/lib/client-di-requirement.d.ts.map +1 -0
- package/src/lib/client-di-requirement.js +11 -0
- package/src/lib/client-di-requirement.js.map +1 -0
- package/src/lib/client-function-middleware.d.ts +130 -0
- package/src/lib/client-function-middleware.d.ts.map +1 -0
- package/src/lib/client-function-middleware.js +144 -0
- package/src/lib/client-function-middleware.js.map +1 -0
- package/src/lib/component-monitoring.d.ts +7 -0
- package/src/lib/component-monitoring.d.ts.map +1 -0
- package/src/lib/component-monitoring.js +28 -0
- package/src/lib/component-monitoring.js.map +1 -0
- package/src/lib/component-register.d.ts +12 -0
- package/src/lib/component-register.d.ts.map +1 -0
- package/src/lib/component-register.js +13 -0
- package/src/lib/component-register.js.map +1 -0
- package/src/lib/computed-source.d.ts +303 -0
- package/src/lib/computed-source.d.ts.map +1 -0
- package/src/lib/computed-source.js +319 -0
- package/src/lib/computed-source.js.map +1 -0
- package/src/lib/correlation-id-plugin.d.ts +3 -0
- package/src/lib/correlation-id-plugin.d.ts.map +1 -0
- package/src/lib/correlation-id-plugin.js +73 -0
- package/src/lib/correlation-id-plugin.js.map +1 -0
- package/src/lib/correlation-id.d.ts +30 -0
- package/src/lib/correlation-id.d.ts.map +1 -0
- package/src/lib/correlation-id.js +86 -0
- package/src/lib/correlation-id.js.map +1 -0
- package/src/lib/craft-a11y.d.ts +22 -0
- package/src/lib/craft-a11y.d.ts.map +1 -0
- package/src/lib/craft-a11y.js +32 -0
- package/src/lib/craft-a11y.js.map +1 -0
- package/src/lib/craft-activated-route.d.ts +21 -0
- package/src/lib/craft-activated-route.d.ts.map +1 -0
- package/src/lib/craft-activated-route.js +20 -0
- package/src/lib/craft-activated-route.js.map +1 -0
- package/src/lib/craft-app-config.d.ts +91 -0
- package/src/lib/craft-app-config.d.ts.map +1 -0
- package/src/lib/craft-app-config.js +64 -0
- package/src/lib/craft-app-config.js.map +1 -0
- package/src/lib/craft-codec.d.ts +16 -0
- package/src/lib/craft-codec.d.ts.map +1 -0
- package/src/lib/craft-codec.js +1 -0
- package/src/lib/craft-codec.js.map +1 -0
- package/src/lib/craft-computed.d.ts +31 -0
- package/src/lib/craft-computed.d.ts.map +1 -0
- package/src/lib/craft-computed.js +81 -0
- package/src/lib/craft-computed.js.map +1 -0
- package/src/lib/craft-control-flow.d.ts +14 -0
- package/src/lib/craft-control-flow.d.ts.map +1 -0
- package/src/lib/craft-control-flow.js +18 -0
- package/src/lib/craft-control-flow.js.map +1 -0
- package/src/lib/craft-effect.d.ts +13 -0
- package/src/lib/craft-effect.d.ts.map +1 -0
- package/src/lib/craft-effect.js +93 -0
- package/src/lib/craft-effect.js.map +1 -0
- package/src/lib/craft-exception.d.ts +40 -0
- package/src/lib/craft-exception.d.ts.map +1 -0
- package/src/lib/craft-exception.js +16 -0
- package/src/lib/craft-exception.js.map +1 -0
- package/src/lib/craft-gen.d.ts +123 -0
- package/src/lib/craft-gen.d.ts.map +1 -0
- package/src/lib/craft-gen.js +90 -0
- package/src/lib/craft-gen.js.map +1 -0
- package/src/lib/craft-generator-runtime.d.ts +110 -0
- package/src/lib/craft-generator-runtime.d.ts.map +1 -0
- package/src/lib/craft-generator-runtime.js +191 -0
- package/src/lib/craft-generator-runtime.js.map +1 -0
- package/src/lib/craft-guard-runtime.d.ts +70 -0
- package/src/lib/craft-guard-runtime.d.ts.map +1 -0
- package/src/lib/craft-guard-runtime.js +195 -0
- package/src/lib/craft-guard-runtime.js.map +1 -0
- package/src/lib/craft-handshake.d.ts +35 -0
- package/src/lib/craft-handshake.d.ts.map +1 -0
- package/src/lib/craft-handshake.js +34 -0
- package/src/lib/craft-handshake.js.map +1 -0
- package/src/lib/craft-http-client.d.ts +236 -0
- package/src/lib/craft-http-client.d.ts.map +1 -0
- package/src/lib/craft-http-client.js +437 -0
- package/src/lib/craft-http-client.js.map +1 -0
- package/src/lib/craft-http-trace.d.ts +12 -0
- package/src/lib/craft-http-trace.d.ts.map +1 -0
- package/src/lib/craft-http-trace.js +28 -0
- package/src/lib/craft-http-trace.js.map +1 -0
- package/src/lib/craft-lazy.d.ts +42 -0
- package/src/lib/craft-lazy.d.ts.map +1 -0
- package/src/lib/craft-lazy.js +83 -0
- package/src/lib/craft-lazy.js.map +1 -0
- package/src/lib/craft-load-retry.d.ts +76 -0
- package/src/lib/craft-load-retry.d.ts.map +1 -0
- package/src/lib/craft-load-retry.js +160 -0
- package/src/lib/craft-load-retry.js.map +1 -0
- package/src/lib/craft-machine-history.d.ts +145 -0
- package/src/lib/craft-machine-history.d.ts.map +1 -0
- package/src/lib/craft-machine-history.js +276 -0
- package/src/lib/craft-machine-history.js.map +1 -0
- package/src/lib/craft-match.d.ts +49 -0
- package/src/lib/craft-match.d.ts.map +1 -0
- package/src/lib/craft-match.js +58 -0
- package/src/lib/craft-match.js.map +1 -0
- package/src/lib/craft-method.d.ts +28 -0
- package/src/lib/craft-method.d.ts.map +1 -0
- package/src/lib/craft-method.js +45 -0
- package/src/lib/craft-method.js.map +1 -0
- package/src/lib/craft-node-directive.d.ts +32 -0
- package/src/lib/craft-node-directive.d.ts.map +1 -0
- package/src/lib/craft-node-directive.js +22 -0
- package/src/lib/craft-node-directive.js.map +1 -0
- package/src/lib/craft-pending.d.ts +115 -0
- package/src/lib/craft-pending.d.ts.map +1 -0
- package/src/lib/craft-pending.js +187 -0
- package/src/lib/craft-pending.js.map +1 -0
- package/src/lib/craft-pipe.d.ts +63 -0
- package/src/lib/craft-pipe.d.ts.map +1 -0
- package/src/lib/craft-pipe.js +57 -0
- package/src/lib/craft-pipe.js.map +1 -0
- package/src/lib/craft-platform.d.ts +50 -0
- package/src/lib/craft-platform.d.ts.map +1 -0
- package/src/lib/craft-platform.js +175 -0
- package/src/lib/craft-platform.js.map +1 -0
- package/src/lib/craft-primitive-gen.d.ts +137 -0
- package/src/lib/craft-primitive-gen.d.ts.map +1 -0
- package/src/lib/craft-primitive-gen.js +76 -0
- package/src/lib/craft-primitive-gen.js.map +1 -0
- package/src/lib/craft-primitive-registry.d.ts +113 -0
- package/src/lib/craft-primitive-registry.d.ts.map +1 -0
- package/src/lib/craft-primitive-registry.js +159 -0
- package/src/lib/craft-primitive-registry.js.map +1 -0
- package/src/lib/craft-program-operators.d.ts +101 -0
- package/src/lib/craft-program-operators.d.ts.map +1 -0
- package/src/lib/craft-program-operators.js +116 -0
- package/src/lib/craft-program-operators.js.map +1 -0
- package/src/lib/craft-program-runtime.d.ts +80 -0
- package/src/lib/craft-program-runtime.d.ts.map +1 -0
- package/src/lib/craft-program-runtime.js +166 -0
- package/src/lib/craft-program-runtime.js.map +1 -0
- package/src/lib/craft-register-for-runtime.d.ts +39 -0
- package/src/lib/craft-register-for-runtime.d.ts.map +1 -0
- package/src/lib/craft-register-for-runtime.js +96 -0
- package/src/lib/craft-register-for-runtime.js.map +1 -0
- package/src/lib/craft-register-for.d.ts +57 -0
- package/src/lib/craft-register-for.d.ts.map +1 -0
- package/src/lib/craft-register-for.js +200 -0
- package/src/lib/craft-register-for.js.map +1 -0
- package/src/lib/craft-render-identity.d.ts +19 -0
- package/src/lib/craft-render-identity.d.ts.map +1 -0
- package/src/lib/craft-render-identity.js +23 -0
- package/src/lib/craft-render-identity.js.map +1 -0
- package/src/lib/craft-replay.d.ts +5 -0
- package/src/lib/craft-replay.d.ts.map +1 -0
- package/src/lib/craft-replay.js +28 -0
- package/src/lib/craft-replay.js.map +1 -0
- package/src/lib/craft-resolve.d.ts +39 -0
- package/src/lib/craft-resolve.d.ts.map +1 -0
- package/src/lib/craft-resolve.js +9 -0
- package/src/lib/craft-resolve.js.map +1 -0
- package/src/lib/craft-resource.d.ts +11 -0
- package/src/lib/craft-resource.d.ts.map +1 -0
- package/src/lib/craft-resource.js +264 -0
- package/src/lib/craft-resource.js.map +1 -0
- package/src/lib/craft-route-exceptions.d.ts +785 -0
- package/src/lib/craft-route-exceptions.d.ts.map +1 -0
- package/src/lib/craft-route-exceptions.js +86 -0
- package/src/lib/craft-route-exceptions.js.map +1 -0
- package/src/lib/craft-route-load-error.d.ts +1145 -0
- package/src/lib/craft-route-load-error.d.ts.map +1 -0
- package/src/lib/craft-route-load-error.js +173 -0
- package/src/lib/craft-route-load-error.js.map +1 -0
- package/src/lib/craft-route-meta.d.ts +52 -0
- package/src/lib/craft-route-meta.d.ts.map +1 -0
- package/src/lib/craft-route-meta.js +16 -0
- package/src/lib/craft-route-meta.js.map +1 -0
- package/src/lib/craft-route-target.d.ts +27 -0
- package/src/lib/craft-route-target.d.ts.map +1 -0
- package/src/lib/craft-route-target.js +22 -0
- package/src/lib/craft-route-target.js.map +1 -0
- package/src/lib/craft-router-outlet.d.ts +105 -0
- package/src/lib/craft-router-outlet.d.ts.map +1 -0
- package/src/lib/craft-router-outlet.js +735 -0
- package/src/lib/craft-router-outlet.js.map +1 -0
- package/src/lib/craft-router-tokens.d.ts +49 -0
- package/src/lib/craft-router-tokens.d.ts.map +1 -0
- package/src/lib/craft-router-tokens.js +15 -0
- package/src/lib/craft-router-tokens.js.map +1 -0
- package/src/lib/craft-router-trace.d.ts +18 -0
- package/src/lib/craft-router-trace.d.ts.map +1 -0
- package/src/lib/craft-router-trace.js +54 -0
- package/src/lib/craft-router-trace.js.map +1 -0
- package/src/lib/craft-router.d.ts +248 -0
- package/src/lib/craft-router.d.ts.map +1 -0
- package/src/lib/craft-router.js +559 -0
- package/src/lib/craft-router.js.map +1 -0
- package/src/lib/craft-routes.d.ts +755 -0
- package/src/lib/craft-routes.d.ts.map +1 -0
- package/src/lib/craft-routes.js +510 -0
- package/src/lib/craft-routes.js.map +1 -0
- package/src/lib/craft-service.d.ts +1034 -0
- package/src/lib/craft-service.d.ts.map +1 -0
- package/src/lib/craft-service.js +1072 -0
- package/src/lib/craft-service.js.map +1 -0
- package/src/lib/craft-service.shared.d.ts +35 -0
- package/src/lib/craft-service.shared.d.ts.map +1 -0
- package/src/lib/craft-service.shared.js +4 -0
- package/src/lib/craft-service.shared.js.map +1 -0
- package/src/lib/craft-settled.d.ts +171 -0
- package/src/lib/craft-settled.d.ts.map +1 -0
- package/src/lib/craft-settled.js +130 -0
- package/src/lib/craft-settled.js.map +1 -0
- package/src/lib/craft-ssr.d.ts +29 -0
- package/src/lib/craft-ssr.d.ts.map +1 -0
- package/src/lib/craft-ssr.js +27 -0
- package/src/lib/craft-ssr.js.map +1 -0
- package/src/lib/craft-state-machine-runtime.d.ts +88 -0
- package/src/lib/craft-state-machine-runtime.d.ts.map +1 -0
- package/src/lib/craft-state-machine-runtime.js +167 -0
- package/src/lib/craft-state-machine-runtime.js.map +1 -0
- package/src/lib/craft-state-machine.d.ts +233 -0
- package/src/lib/craft-state-machine.d.ts.map +1 -0
- package/src/lib/craft-state-machine.js +254 -0
- package/src/lib/craft-state-machine.js.map +1 -0
- package/src/lib/craft-target-runtime.d.ts +20 -0
- package/src/lib/craft-target-runtime.d.ts.map +1 -0
- package/src/lib/craft-target-runtime.js +42 -0
- package/src/lib/craft-target-runtime.js.map +1 -0
- package/src/lib/craft-transfer-snapshot.d.ts +19 -0
- package/src/lib/craft-transfer-snapshot.d.ts.map +1 -0
- package/src/lib/craft-transfer-snapshot.js +90 -0
- package/src/lib/craft-transfer-snapshot.js.map +1 -0
- package/src/lib/craft-unique.d.ts +7 -0
- package/src/lib/craft-unique.d.ts.map +1 -0
- package/src/lib/craft-unique.js +16 -0
- package/src/lib/craft-unique.js.map +1 -0
- package/src/lib/craft-until-settled.d.ts +99 -0
- package/src/lib/craft-until-settled.d.ts.map +1 -0
- package/src/lib/craft-until-settled.js +81 -0
- package/src/lib/craft-until-settled.js.map +1 -0
- package/src/lib/craft-use.d.ts +26 -0
- package/src/lib/craft-use.d.ts.map +1 -0
- package/src/lib/craft-use.js +37 -0
- package/src/lib/craft-use.js.map +1 -0
- package/src/lib/craft-view-transition.d.ts +102 -0
- package/src/lib/craft-view-transition.d.ts.map +1 -0
- package/src/lib/craft-view-transition.js +130 -0
- package/src/lib/craft-view-transition.js.map +1 -0
- package/src/lib/dom-event-hook.d.ts +30 -0
- package/src/lib/dom-event-hook.d.ts.map +1 -0
- package/src/lib/dom-event-hook.js +16 -0
- package/src/lib/dom-event-hook.js.map +1 -0
- package/src/lib/fn-wrapper.d.ts +13 -0
- package/src/lib/fn-wrapper.d.ts.map +1 -0
- package/src/lib/fn-wrapper.js +66 -0
- package/src/lib/fn-wrapper.js.map +1 -0
- package/src/lib/form/craft-field.d.ts +155 -0
- package/src/lib/form/craft-field.d.ts.map +1 -0
- package/src/lib/form/craft-field.directive.d.ts +70 -0
- package/src/lib/form/craft-field.directive.d.ts.map +1 -0
- package/src/lib/form/craft-field.directive.js +549 -0
- package/src/lib/form/craft-field.directive.js.map +1 -0
- package/src/lib/form/craft-field.js +586 -0
- package/src/lib/form/craft-field.js.map +1 -0
- package/src/lib/form/field-exception.d.ts +62 -0
- package/src/lib/form/field-exception.d.ts.map +1 -0
- package/src/lib/form/field-exception.js +37 -0
- package/src/lib/form/field-exception.js.map +1 -0
- package/src/lib/form/field-lens.d.ts +29 -0
- package/src/lib/form/field-lens.d.ts.map +1 -0
- package/src/lib/form/field-lens.js +32 -0
- package/src/lib/form/field-lens.js.map +1 -0
- package/src/lib/form/insert-form-attributes.d.ts +69 -0
- package/src/lib/form/insert-form-attributes.d.ts.map +1 -0
- package/src/lib/form/insert-form-attributes.js +163 -0
- package/src/lib/form/insert-form-attributes.js.map +1 -0
- package/src/lib/form/insert-form-internals.d.ts +110 -0
- package/src/lib/form/insert-form-internals.d.ts.map +1 -0
- package/src/lib/form/insert-form-internals.js +276 -0
- package/src/lib/form/insert-form-internals.js.map +1 -0
- package/src/lib/form/insert-form-schema.d.ts +10 -0
- package/src/lib/form/insert-form-schema.d.ts.map +1 -0
- package/src/lib/form/insert-form-schema.js +62 -0
- package/src/lib/form/insert-form-schema.js.map +1 -0
- package/src/lib/form/insert-form-submit.d.ts +79 -0
- package/src/lib/form/insert-form-submit.d.ts.map +1 -0
- package/src/lib/form/insert-form-submit.js +126 -0
- package/src/lib/form/insert-form-submit.js.map +1 -0
- package/src/lib/form/insert-form.d.ts +39 -0
- package/src/lib/form/insert-form.d.ts.map +1 -0
- package/src/lib/form/insert-form.js +255 -0
- package/src/lib/form/insert-form.js.map +1 -0
- package/src/lib/form/insert-select-form-tree.d.ts +33 -0
- package/src/lib/form/insert-select-form-tree.d.ts.map +1 -0
- package/src/lib/form/insert-select-form-tree.js +144 -0
- package/src/lib/form/insert-select-form-tree.js.map +1 -0
- package/src/lib/form/insert-sub-form-field.d.ts +17 -0
- package/src/lib/form/insert-sub-form-field.d.ts.map +1 -0
- package/src/lib/form/insert-sub-form-field.js +41 -0
- package/src/lib/form/insert-sub-form-field.js.map +1 -0
- package/src/lib/form/make-form-tree-insert.d.ts +22 -0
- package/src/lib/form/make-form-tree-insert.d.ts.map +1 -0
- package/src/lib/form/make-form-tree-insert.js +43 -0
- package/src/lib/form/make-form-tree-insert.js.map +1 -0
- package/src/lib/form/target-form-field.d.ts +11 -0
- package/src/lib/form/target-form-field.d.ts.map +1 -0
- package/src/lib/form/target-form-field.js +1 -0
- package/src/lib/form/target-form-field.js.map +1 -0
- package/src/lib/form/validator.d.ts +174 -0
- package/src/lib/form/validator.d.ts.map +1 -0
- package/src/lib/form/validator.js +465 -0
- package/src/lib/form/validator.js.map +1 -0
- package/src/lib/from-event-to-source$.d.ts +210 -0
- package/src/lib/from-event-to-source$.d.ts.map +1 -0
- package/src/lib/from-event-to-source$.js +29 -0
- package/src/lib/from-event-to-source$.js.map +1 -0
- package/src/lib/global-persister-handler.service.d.ts +10 -0
- package/src/lib/global-persister-handler.service.d.ts.map +1 -0
- package/src/lib/global-persister-handler.service.js +40 -0
- package/src/lib/global-persister-handler.service.js.map +1 -0
- package/src/lib/host/craft-compat.d.ts +242 -0
- package/src/lib/host/craft-compat.d.ts.map +1 -0
- package/src/lib/host/craft-compat.js +444 -0
- package/src/lib/host/craft-compat.js.map +1 -0
- package/src/lib/host/craft-dom.d.ts +16 -0
- package/src/lib/host/craft-dom.d.ts.map +1 -0
- package/src/lib/host/craft-dom.js +24 -0
- package/src/lib/host/craft-dom.js.map +1 -0
- package/src/lib/host/craft-http.d.ts +22 -0
- package/src/lib/host/craft-http.d.ts.map +1 -0
- package/src/lib/host/craft-http.js +80 -0
- package/src/lib/host/craft-http.js.map +1 -0
- package/src/lib/host/craft-injector-host.d.ts +3 -0
- package/src/lib/host/craft-injector-host.d.ts.map +1 -0
- package/src/lib/host/craft-injector-host.js +2 -0
- package/src/lib/host/craft-injector-host.js.map +1 -0
- package/src/lib/host/craft-injector.d.ts +40 -0
- package/src/lib/host/craft-injector.d.ts.map +1 -0
- package/src/lib/host/craft-injector.js +318 -0
- package/src/lib/host/craft-injector.js.map +1 -0
- package/src/lib/host/craft-linked-signal.d.ts +17 -0
- package/src/lib/host/craft-linked-signal.d.ts.map +1 -0
- package/src/lib/host/craft-linked-signal.js +86 -0
- package/src/lib/host/craft-linked-signal.js.map +1 -0
- package/src/lib/host/craft-router-runtime.d.ts +61 -0
- package/src/lib/host/craft-router-runtime.d.ts.map +1 -0
- package/src/lib/host/craft-router-runtime.js +456 -0
- package/src/lib/host/craft-router-runtime.js.map +1 -0
- package/src/lib/host/craft-router-types.d.ts +84 -0
- package/src/lib/host/craft-router-types.d.ts.map +1 -0
- package/src/lib/host/craft-router-types.js +35 -0
- package/src/lib/host/craft-router-types.js.map +1 -0
- package/src/lib/host/craft-signal.d.ts +45 -0
- package/src/lib/host/craft-signal.d.ts.map +1 -0
- package/src/lib/host/craft-signal.js +161 -0
- package/src/lib/host/craft-signal.js.map +1 -0
- package/src/lib/host/craft-test-bed.d.ts +63 -0
- package/src/lib/host/craft-test-bed.d.ts.map +1 -0
- package/src/lib/host/craft-test-bed.js +114 -0
- package/src/lib/host/craft-test-bed.js.map +1 -0
- package/src/lib/host-tag.d.ts +2 -0
- package/src/lib/host-tag.d.ts.map +1 -0
- package/src/lib/host-tag.js +2 -0
- package/src/lib/host-tag.js.map +1 -0
- package/src/lib/insert-entities.d.ts +131 -0
- package/src/lib/insert-entities.d.ts.map +1 -0
- package/src/lib/insert-entities.js +159 -0
- package/src/lib/insert-entities.js.map +1 -0
- package/src/lib/insert-noop-typing-anchor.d.ts +15 -0
- package/src/lib/insert-noop-typing-anchor.d.ts.map +1 -0
- package/src/lib/insert-noop-typing-anchor.js +16 -0
- package/src/lib/insert-noop-typing-anchor.js.map +1 -0
- package/src/lib/insert-pagination-placeholder-data.d.ts +122 -0
- package/src/lib/insert-pagination-placeholder-data.d.ts.map +1 -0
- package/src/lib/insert-pagination-placeholder-data.js +244 -0
- package/src/lib/insert-pagination-placeholder-data.js.map +1 -0
- package/src/lib/insert-react-on-mutation.d.ts +261 -0
- package/src/lib/insert-react-on-mutation.d.ts.map +1 -0
- package/src/lib/insert-react-on-mutation.js +227 -0
- package/src/lib/insert-react-on-mutation.js.map +1 -0
- package/src/lib/insert-select-resource.d.ts +31 -0
- package/src/lib/insert-select-resource.d.ts.map +1 -0
- package/src/lib/insert-select-resource.js +27 -0
- package/src/lib/insert-select-resource.js.map +1 -0
- package/src/lib/insert-select.d.ts +126 -0
- package/src/lib/insert-select.d.ts.map +1 -0
- package/src/lib/insert-select.js +535 -0
- package/src/lib/insert-select.js.map +1 -0
- package/src/lib/insert-storage-persister.d.ts +27 -0
- package/src/lib/insert-storage-persister.d.ts.map +1 -0
- package/src/lib/insert-storage-persister.js +65 -0
- package/src/lib/insert-storage-persister.js.map +1 -0
- package/src/lib/insert-typed-pipes.d.ts +64 -0
- package/src/lib/insert-typed-pipes.d.ts.map +1 -0
- package/src/lib/insert-typed-pipes.js +32 -0
- package/src/lib/insert-typed-pipes.js.map +1 -0
- package/src/lib/linked-source.d.ts +8 -0
- package/src/lib/linked-source.d.ts.map +1 -0
- package/src/lib/linked-source.js +24 -0
- package/src/lib/linked-source.js.map +1 -0
- package/src/lib/local-storage-persister.d.ts +4 -0
- package/src/lib/local-storage-persister.d.ts.map +1 -0
- package/src/lib/local-storage-persister.js +342 -0
- package/src/lib/local-storage-persister.js.map +1 -0
- package/src/lib/middleware-schema-shared.d.ts +67 -0
- package/src/lib/middleware-schema-shared.d.ts.map +1 -0
- package/src/lib/middleware-schema-shared.js +34 -0
- package/src/lib/middleware-schema-shared.js.map +1 -0
- package/src/lib/mock-http-request-for-route.d.ts +173 -0
- package/src/lib/mock-http-request-for-route.d.ts.map +1 -0
- package/src/lib/mock-http-request-for-route.js +127 -0
- package/src/lib/mock-http-request-for-route.js.map +1 -0
- package/src/lib/mutation.d.ts +332 -0
- package/src/lib/mutation.d.ts.map +1 -0
- package/src/lib/mutation.js +923 -0
- package/src/lib/mutation.js.map +1 -0
- package/src/lib/on$.d.ts +26 -0
- package/src/lib/on$.d.ts.map +1 -0
- package/src/lib/on$.js +19 -0
- package/src/lib/on$.js.map +1 -0
- package/src/lib/portable-server-function.d.ts +68 -0
- package/src/lib/portable-server-function.d.ts.map +1 -0
- package/src/lib/portable-server-function.js +97 -0
- package/src/lib/portable-server-function.js.map +1 -0
- package/src/lib/preserved-resource.d.ts +4 -0
- package/src/lib/preserved-resource.d.ts.map +1 -0
- package/src/lib/preserved-resource.js +60 -0
- package/src/lib/preserved-resource.js.map +1 -0
- package/src/lib/primitive-method-runtime-context.d.ts +28 -0
- package/src/lib/primitive-method-runtime-context.d.ts.map +1 -0
- package/src/lib/primitive-method-runtime-context.js +38 -0
- package/src/lib/primitive-method-runtime-context.js.map +1 -0
- package/src/lib/primitive-resource-runtime-context.d.ts +46 -0
- package/src/lib/primitive-resource-runtime-context.d.ts.map +1 -0
- package/src/lib/primitive-resource-runtime-context.js +102 -0
- package/src/lib/primitive-resource-runtime-context.js.map +1 -0
- package/src/lib/query-params.d.ts +216 -0
- package/src/lib/query-params.d.ts.map +1 -0
- package/src/lib/query-params.js +324 -0
- package/src/lib/query-params.js.map +1 -0
- package/src/lib/query.core.d.ts +214 -0
- package/src/lib/query.core.d.ts.map +1 -0
- package/src/lib/query.core.js +210 -0
- package/src/lib/query.core.js.map +1 -0
- package/src/lib/query.d.ts +324 -0
- package/src/lib/query.d.ts.map +1 -0
- package/src/lib/query.js +971 -0
- package/src/lib/query.js.map +1 -0
- package/src/lib/reactive-read.d.ts +162 -0
- package/src/lib/reactive-read.d.ts.map +1 -0
- package/src/lib/reactive-read.js +389 -0
- package/src/lib/reactive-read.js.map +1 -0
- package/src/lib/resource-by-id.d.ts +71 -0
- package/src/lib/resource-by-id.d.ts.map +1 -0
- package/src/lib/resource-by-id.js +294 -0
- package/src/lib/resource-by-id.js.map +1 -0
- package/src/lib/resource-exception.d.ts +30 -0
- package/src/lib/resource-exception.d.ts.map +1 -0
- package/src/lib/resource-exception.js +86 -0
- package/src/lib/resource-exception.js.map +1 -0
- package/src/lib/route-checked-di.d.ts +229 -0
- package/src/lib/route-checked-di.d.ts.map +1 -0
- package/src/lib/route-checked-di.js +1 -0
- package/src/lib/route-checked-di.js.map +1 -0
- package/src/lib/schema-validation.d.ts +89 -0
- package/src/lib/schema-validation.d.ts.map +1 -0
- package/src/lib/schema-validation.js +110 -0
- package/src/lib/schema-validation.js.map +1 -0
- package/src/lib/send-context-to-ai.d.ts +20 -0
- package/src/lib/send-context-to-ai.d.ts.map +1 -0
- package/src/lib/send-context-to-ai.js +18 -0
- package/src/lib/send-context-to-ai.js.map +1 -0
- package/src/lib/send-context-to-ai.tokens.d.ts +12 -0
- package/src/lib/send-context-to-ai.tokens.d.ts.map +1 -0
- package/src/lib/send-context-to-ai.tokens.js +1 -0
- package/src/lib/send-context-to-ai.tokens.js.map +1 -0
- package/src/lib/server-function-client.d.ts +102 -0
- package/src/lib/server-function-client.d.ts.map +1 -0
- package/src/lib/server-function-client.js +106 -0
- package/src/lib/server-function-client.js.map +1 -0
- package/src/lib/server-function-contract.d.ts +42 -0
- package/src/lib/server-function-contract.d.ts.map +1 -0
- package/src/lib/server-function-contract.js +23 -0
- package/src/lib/server-function-contract.js.map +1 -0
- package/src/lib/server-function-middleware.d.ts +222 -0
- package/src/lib/server-function-middleware.d.ts.map +1 -0
- package/src/lib/server-function-middleware.js +189 -0
- package/src/lib/server-function-middleware.js.map +1 -0
- package/src/lib/server-function.d.ts +114 -0
- package/src/lib/server-function.d.ts.map +1 -0
- package/src/lib/server-function.js +80 -0
- package/src/lib/server-function.js.map +1 -0
- package/src/lib/server-layer.d.ts +185 -0
- package/src/lib/server-layer.d.ts.map +1 -0
- package/src/lib/server-layer.js +121 -0
- package/src/lib/server-layer.js.map +1 -0
- package/src/lib/server.d.ts +83 -0
- package/src/lib/server.d.ts.map +1 -0
- package/src/lib/server.js +266 -0
- package/src/lib/server.js.map +1 -0
- package/src/lib/setup-craft-service-test.d.ts +90 -0
- package/src/lib/setup-craft-service-test.d.ts.map +1 -0
- package/src/lib/setup-craft-service-test.js +193 -0
- package/src/lib/setup-craft-service-test.js.map +1 -0
- package/src/lib/setup-craft-service-testing-by-register.d.ts +245 -0
- package/src/lib/setup-craft-service-testing-by-register.d.ts.map +1 -0
- package/src/lib/setup-craft-service-testing-by-register.js +316 -0
- package/src/lib/setup-craft-service-testing-by-register.js.map +1 -0
- package/src/lib/signal-proxy.d.ts +21 -0
- package/src/lib/signal-proxy.d.ts.map +1 -0
- package/src/lib/signal-proxy.js +79 -0
- package/src/lib/signal-proxy.js.map +1 -0
- package/src/lib/signal-source.d.ts +392 -0
- package/src/lib/signal-source.d.ts.map +1 -0
- package/src/lib/signal-source.js +433 -0
- package/src/lib/signal-source.js.map +1 -0
- package/src/lib/source$.d.ts +121 -0
- package/src/lib/source$.d.ts.map +1 -0
- package/src/lib/source$.js +171 -0
- package/src/lib/source$.js.map +1 -0
- package/src/lib/source-from-event.d.ts +350 -0
- package/src/lib/source-from-event.d.ts.map +1 -0
- package/src/lib/source-from-event.js +26 -0
- package/src/lib/source-from-event.js.map +1 -0
- package/src/lib/stacked-source.d.ts +6 -0
- package/src/lib/stacked-source.d.ts.map +1 -0
- package/src/lib/stacked-source.js +29 -0
- package/src/lib/stacked-source.js.map +1 -0
- package/src/lib/standard-schema.d.ts +43 -0
- package/src/lib/standard-schema.d.ts.map +1 -0
- package/src/lib/standard-schema.js +1 -0
- package/src/lib/standard-schema.js.map +1 -0
- package/src/lib/state-method-runtime-context.d.ts +13 -0
- package/src/lib/state-method-runtime-context.d.ts.map +1 -0
- package/src/lib/state-method-runtime-context.js +11 -0
- package/src/lib/state-method-runtime-context.js.map +1 -0
- package/src/lib/state.d.ts +158 -0
- package/src/lib/state.d.ts.map +1 -0
- package/src/lib/state.js +388 -0
- package/src/lib/state.js.map +1 -0
- package/src/lib/storage-persister.service.d.ts +25 -0
- package/src/lib/storage-persister.service.d.ts.map +1 -0
- package/src/lib/storage-persister.service.js +27 -0
- package/src/lib/storage-persister.service.js.map +1 -0
- package/src/lib/take-app-snapshot.d.ts +31 -0
- package/src/lib/take-app-snapshot.d.ts.map +1 -0
- package/src/lib/take-app-snapshot.js +93 -0
- package/src/lib/take-app-snapshot.js.map +1 -0
- package/src/lib/template-trace.d.ts +37 -0
- package/src/lib/template-trace.d.ts.map +1 -0
- package/src/lib/template-trace.js +37 -0
- package/src/lib/template-trace.js.map +1 -0
- package/src/lib/temporal-runtime.d.ts +146 -0
- package/src/lib/temporal-runtime.d.ts.map +1 -0
- package/src/lib/temporal-runtime.js +375 -0
- package/src/lib/temporal-runtime.js.map +1 -0
- package/src/lib/to-source.d.ts +335 -0
- package/src/lib/to-source.d.ts.map +1 -0
- package/src/lib/to-source.js +359 -0
- package/src/lib/to-source.js.map +1 -0
- package/src/lib/util/craft-resource-ref.d.ts +29 -0
- package/src/lib/util/craft-resource-ref.d.ts.map +1 -0
- package/src/lib/util/craft-resource-ref.js +1 -0
- package/src/lib/util/craft-resource-ref.js.map +1 -0
- package/src/lib/util/craft-resource-status.d.ts +17 -0
- package/src/lib/util/craft-resource-status.d.ts.map +1 -0
- package/src/lib/util/craft-resource-status.js +14 -0
- package/src/lib/util/craft-resource-status.js.map +1 -0
- package/src/lib/util/entities-util.d.ts +340 -0
- package/src/lib/util/entities-util.d.ts.map +1 -0
- package/src/lib/util/entities-util.js +136 -0
- package/src/lib/util/entities-util.js.map +1 -0
- package/src/lib/util/explicit-effect.d.ts +42 -0
- package/src/lib/util/explicit-effect.d.ts.map +1 -0
- package/src/lib/util/explicit-effect.js +37 -0
- package/src/lib/util/explicit-effect.js.map +1 -0
- package/src/lib/util/extract-signal-props-and-methods.d.ts +20 -0
- package/src/lib/util/extract-signal-props-and-methods.d.ts.map +1 -0
- package/src/lib/util/extract-signal-props-and-methods.js +1 -0
- package/src/lib/util/extract-signal-props-and-methods.js.map +1 -0
- package/src/lib/util/method-trigger-nonce.d.ts +45 -0
- package/src/lib/util/method-trigger-nonce.d.ts.map +1 -0
- package/src/lib/util/method-trigger-nonce.js +58 -0
- package/src/lib/util/method-trigger-nonce.js.map +1 -0
- package/src/lib/util/persister.type.d.ts +37 -0
- package/src/lib/util/persister.type.d.ts.map +1 -0
- package/src/lib/util/persister.type.js +1 -0
- package/src/lib/util/persister.type.js.map +1 -0
- package/src/lib/util/persister.util.d.ts +8 -0
- package/src/lib/util/persister.util.d.ts.map +1 -0
- package/src/lib/util/persister.util.js +71 -0
- package/src/lib/util/persister.util.js.map +1 -0
- package/src/lib/util/react-on-mutation-effect.d.ts +16 -0
- package/src/lib/util/react-on-mutation-effect.d.ts.map +1 -0
- package/src/lib/util/react-on-mutation-effect.js +148 -0
- package/src/lib/util/react-on-mutation-effect.js.map +1 -0
- package/src/lib/util/resource-by-id-changes-tracker.util.d.ts +27 -0
- package/src/lib/util/resource-by-id-changes-tracker.util.d.ts.map +1 -0
- package/src/lib/util/resource-by-id-changes-tracker.util.js +97 -0
- package/src/lib/util/resource-by-id-changes-tracker.util.js.map +1 -0
- package/src/lib/util/source.type.d.ts +6 -0
- package/src/lib/util/source.type.d.ts.map +1 -0
- package/src/lib/util/source.type.js +1 -0
- package/src/lib/util/source.type.js.map +1 -0
- package/src/lib/util/types/access-type-object-property-by-dotted-path.type.d.ts +4 -0
- package/src/lib/util/types/access-type-object-property-by-dotted-path.type.d.ts.map +1 -0
- package/src/lib/util/types/access-type-object-property-by-dotted-path.type.js +1 -0
- package/src/lib/util/types/access-type-object-property-by-dotted-path.type.js.map +1 -0
- package/src/lib/util/types/boolean-or-mapper-fn-by-path-by-id.type.d.ts +27 -0
- package/src/lib/util/types/boolean-or-mapper-fn-by-path-by-id.type.d.ts.map +1 -0
- package/src/lib/util/types/boolean-or-mapper-fn-by-path-by-id.type.js +1 -0
- package/src/lib/util/types/boolean-or-mapper-fn-by-path-by-id.type.js.map +1 -0
- package/src/lib/util/types/boolean-or-mapper-fn-by-path.type.d.ts +24 -0
- package/src/lib/util/types/boolean-or-mapper-fn-by-path.type.d.ts.map +1 -0
- package/src/lib/util/types/boolean-or-mapper-fn-by-path.type.js +1 -0
- package/src/lib/util/types/boolean-or-mapper-fn-by-path.type.js.map +1 -0
- package/src/lib/util/types/brand.d.ts +7 -0
- package/src/lib/util/types/brand.d.ts.map +1 -0
- package/src/lib/util/types/brand.js +9 -0
- package/src/lib/util/types/brand.js.map +1 -0
- package/src/lib/util/types/object-deep-path-mapper.type.d.ts +13 -0
- package/src/lib/util/types/object-deep-path-mapper.type.d.ts.map +1 -0
- package/src/lib/util/types/object-deep-path-mapper.type.js +1 -0
- package/src/lib/util/types/object-deep-path-mapper.type.js.map +1 -0
- package/src/lib/util/types/resource-by-id-config.type.d.ts +115 -0
- package/src/lib/util/types/resource-by-id-config.type.d.ts.map +1 -0
- package/src/lib/util/types/resource-by-id-config.type.js +1 -0
- package/src/lib/util/types/resource-by-id-config.type.js.map +1 -0
- package/src/lib/util/types/resource-with-params-or-params-fn.type.d.ts +52 -0
- package/src/lib/util/types/resource-with-params-or-params-fn.type.d.ts.map +1 -0
- package/src/lib/util/types/resource-with-params-or-params-fn.type.js +1 -0
- package/src/lib/util/types/resource-with-params-or-params-fn.type.js.map +1 -0
- package/src/lib/util/types/shared.type.d.ts +66 -0
- package/src/lib/util/types/shared.type.d.ts.map +1 -0
- package/src/lib/util/types/shared.type.js +1 -0
- package/src/lib/util/types/shared.type.js.map +1 -0
- package/src/lib/util/types/util.d.ts +16 -0
- package/src/lib/util/types/util.d.ts.map +1 -0
- package/src/lib/util/types/util.js +60 -0
- package/src/lib/util/types/util.js.map +1 -0
- package/src/lib/util/types/util.type.d.ts +67 -0
- package/src/lib/util/types/util.type.d.ts.map +1 -0
- package/src/lib/util/types/util.type.js +5 -0
- package/src/lib/util/types/util.type.js.map +1 -0
- package/src/lib/util/update-state.util.d.ts +10 -0
- package/src/lib/util/update-state.util.d.ts.map +1 -0
- package/src/lib/util/update-state.util.js +31 -0
- package/src/lib/util/update-state.util.js.map +1 -0
- package/src/lib/util/util.d.ts +19 -0
- package/src/lib/util/util.d.ts.map +1 -0
- package/src/lib/util/util.js +50 -0
- package/src/lib/util/util.js.map +1 -0
- package/src/lib/util/util.type.d.ts +107 -0
- package/src/lib/util/util.type.d.ts.map +1 -0
- package/src/lib/util/util.type.js +9 -0
- package/src/lib/util/util.type.js.map +1 -0
- package/src/lib/yieldable.d.ts +94 -0
- package/src/lib/yieldable.d.ts.map +1 -0
- package/src/lib/yieldable.js +109 -0
- package/src/lib/yieldable.js.map +1 -0
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
import { type Signal } from './host/craft-compat';
|
|
2
|
+
import { SignalSource } from './signal-source';
|
|
3
|
+
import { ReadonlySource } from './util/source.type';
|
|
4
|
+
/**
|
|
5
|
+
* Creates a derived readonly source that transforms source emissions through a callback function.
|
|
6
|
+
*
|
|
7
|
+
* This function binds queries, mutations, and async methods to sources for automatic execution by:
|
|
8
|
+
* - Listening to source emissions and computing new values
|
|
9
|
+
* - Providing a readonly source suitable for method binding
|
|
10
|
+
* - Maintaining reactivity through Angular's effect system
|
|
11
|
+
* - Enabling source-based triggering patterns
|
|
12
|
+
*
|
|
13
|
+
* @remarks
|
|
14
|
+
* **Primary Use Case:**
|
|
15
|
+
* Bind queries/mutations/async methods to sources for automatic execution:
|
|
16
|
+
* ```ts
|
|
17
|
+
* method: afterRecomputation(mySource, (data) => data)
|
|
18
|
+
* ```
|
|
19
|
+
* This pattern makes queries/mutations execute automatically when the source emits.
|
|
20
|
+
*
|
|
21
|
+
* **Execution Flow:**
|
|
22
|
+
* 1. Source emits a value via `source.set(value)`
|
|
23
|
+
* 2. afterRecomputation callback transforms the value
|
|
24
|
+
* 3. Resulting readonly source emits the transformed value
|
|
25
|
+
* 4. Bound query/mutation/async method executes with the new value
|
|
26
|
+
*
|
|
27
|
+
* **Difference from computedSource:**
|
|
28
|
+
* - `afterRecomputation`: Designed for binding to method parameters
|
|
29
|
+
* - `computedSource`: General-purpose source transformation
|
|
30
|
+
* - Both transform source values, but afterRecomputation is optimized for method binding
|
|
31
|
+
*
|
|
32
|
+
* **Common Patterns:**
|
|
33
|
+
* - **Identity transformation**: `afterRecomputation(source, (x) => x)` - pass value through
|
|
34
|
+
* - **Field extraction**: `afterRecomputation(source, (data) => data.id)` - extract specific field
|
|
35
|
+
* - **Validation**: `afterRecomputation(source, (data) => validate(data))` - transform and validate
|
|
36
|
+
* - **Mapping**: `afterRecomputation(source, (data) => mapToDto(data))` - convert to different type
|
|
37
|
+
*
|
|
38
|
+
* @template State - The type of values produced by the callback
|
|
39
|
+
* @template SourceType - The type of values emitted by the origin source
|
|
40
|
+
*
|
|
41
|
+
* @param _source - The source to listen to.
|
|
42
|
+
* When this source emits, the callback is invoked.
|
|
43
|
+
*
|
|
44
|
+
* @param callback - Function that transforms source values.
|
|
45
|
+
* Receives the emitted value and returns the transformed result.
|
|
46
|
+
*
|
|
47
|
+
* @returns A readonly source that emits transformed values.
|
|
48
|
+
* Can be used as the `method` parameter in queries, mutations, and async methods.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* Binding a query to a source for automatic execution
|
|
52
|
+
* ```ts
|
|
53
|
+
* const { UserStore } = craftService(
|
|
54
|
+
* { name: 'UserStore', providedIn: 'toProvide' },
|
|
55
|
+
* function* () {
|
|
56
|
+
* const userIdChange = signalSource<string>('userIdChange');
|
|
57
|
+
*
|
|
58
|
+
* const user = yield* query({
|
|
59
|
+
* method: afterRecomputation(userIdChange, (userId) => userId),
|
|
60
|
+
* loader: async ({ params }) => {
|
|
61
|
+
* const response = await fetch(`/api/users/${params}`);
|
|
62
|
+
* return response.json();
|
|
63
|
+
* },
|
|
64
|
+
* });
|
|
65
|
+
*
|
|
66
|
+
* return { userIdChange, user };
|
|
67
|
+
* },
|
|
68
|
+
* );
|
|
69
|
+
*
|
|
70
|
+
* const store = UserStore();
|
|
71
|
+
*
|
|
72
|
+
* // Query executes automatically when source emits
|
|
73
|
+
* store.userIdChange.set('user-123');
|
|
74
|
+
* // -> query loader executes with params 'user-123'
|
|
75
|
+
*
|
|
76
|
+
* store.userIdChange.set('user-456');
|
|
77
|
+
* // -> query loader executes again with params 'user-456'
|
|
78
|
+
* ```
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* Binding a mutation to a source
|
|
82
|
+
* ```ts
|
|
83
|
+
* const { FormStore } = craftService(
|
|
84
|
+
* { name: 'FormStore', providedIn: 'toProvide' },
|
|
85
|
+
* function* () {
|
|
86
|
+
* const submitForm = signalSource<{ name: string; email: string }>('submitForm');
|
|
87
|
+
*
|
|
88
|
+
* const submit = yield* mutation({
|
|
89
|
+
* method: afterRecomputation(submitForm, (formData) => formData),
|
|
90
|
+
* loader: async ({ params }) => {
|
|
91
|
+
* const response = await fetch('/api/submit', {
|
|
92
|
+
* method: 'POST',
|
|
93
|
+
* body: JSON.stringify(params),
|
|
94
|
+
* });
|
|
95
|
+
* return response.json();
|
|
96
|
+
* },
|
|
97
|
+
* });
|
|
98
|
+
*
|
|
99
|
+
* return { submitForm, submit };
|
|
100
|
+
* },
|
|
101
|
+
* );
|
|
102
|
+
*
|
|
103
|
+
* const store = FormStore();
|
|
104
|
+
*
|
|
105
|
+
* // Mutation executes automatically when source emits
|
|
106
|
+
* store.submitForm.set({ name: 'John', email: 'john@example.com' });
|
|
107
|
+
* // -> mutation loader executes with form data
|
|
108
|
+
* // The mutation is driven by the source; store.submit.mutate() is unused here
|
|
109
|
+
* ```
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* Binding an async process to a source
|
|
113
|
+
* ```ts
|
|
114
|
+
* const { SearchStore } = craftService(
|
|
115
|
+
* { name: 'SearchStore', providedIn: 'toProvide' },
|
|
116
|
+
* function* () {
|
|
117
|
+
* const searchInput = signalSource<string>('searchInput');
|
|
118
|
+
*
|
|
119
|
+
* const search = yield* asyncProcess({
|
|
120
|
+
* method: afterRecomputation(searchInput, (term) => term),
|
|
121
|
+
* loader: async ({ params }) => {
|
|
122
|
+
* // Debounce at source level before setting
|
|
123
|
+
* const response = await fetch(`/api/search?q=${params}`);
|
|
124
|
+
* return response.json();
|
|
125
|
+
* },
|
|
126
|
+
* });
|
|
127
|
+
*
|
|
128
|
+
* return { searchInput, search };
|
|
129
|
+
* },
|
|
130
|
+
* );
|
|
131
|
+
*
|
|
132
|
+
* const store = SearchStore();
|
|
133
|
+
*
|
|
134
|
+
* // Async process executes automatically
|
|
135
|
+
* store.searchInput.set('query');
|
|
136
|
+
* // -> search loader executes
|
|
137
|
+
* ```
|
|
138
|
+
*
|
|
139
|
+
* @example
|
|
140
|
+
* Extracting specific field from complex data
|
|
141
|
+
* ```ts
|
|
142
|
+
* type FormData = {
|
|
143
|
+
* user: { id: string; name: string };
|
|
144
|
+
* address: { city: string };
|
|
145
|
+
* };
|
|
146
|
+
*
|
|
147
|
+
* const { UserFormStore } = craftService(
|
|
148
|
+
* { name: 'UserFormStore', providedIn: 'toProvide' },
|
|
149
|
+
* function* () {
|
|
150
|
+
* const formSubmit = signalSource<FormData>('formSubmit');
|
|
151
|
+
*
|
|
152
|
+
* const updateUser = yield* mutation({
|
|
153
|
+
* // Extract only user data
|
|
154
|
+
* method: afterRecomputation(formSubmit, (data) => data.user),
|
|
155
|
+
* loader: async ({ params }) => {
|
|
156
|
+
* const response = await fetch(`/api/users/${params.id}`, {
|
|
157
|
+
* method: 'PATCH',
|
|
158
|
+
* body: JSON.stringify(params),
|
|
159
|
+
* });
|
|
160
|
+
* return response.json();
|
|
161
|
+
* },
|
|
162
|
+
* });
|
|
163
|
+
*
|
|
164
|
+
* return { formSubmit, updateUser };
|
|
165
|
+
* },
|
|
166
|
+
* );
|
|
167
|
+
*
|
|
168
|
+
* const store = UserFormStore();
|
|
169
|
+
*
|
|
170
|
+
* // Only user data is passed to the mutation
|
|
171
|
+
* store.formSubmit.set({
|
|
172
|
+
* user: { id: 'user-1', name: 'John' },
|
|
173
|
+
* address: { city: 'NYC' },
|
|
174
|
+
* });
|
|
175
|
+
* // -> mutation receives only { id: 'user-1', name: 'John' }
|
|
176
|
+
* ```
|
|
177
|
+
*
|
|
178
|
+
* @example
|
|
179
|
+
* Transforming data before execution
|
|
180
|
+
* ```ts
|
|
181
|
+
* const { ResultsStore } = craftService(
|
|
182
|
+
* { name: 'ResultsStore', providedIn: 'toProvide' },
|
|
183
|
+
* function* () {
|
|
184
|
+
* const searchParams = signalSource<{ query: string; filters: string[] }>('searchParams');
|
|
185
|
+
*
|
|
186
|
+
* const results = yield* query({
|
|
187
|
+
* method: afterRecomputation(searchParams, (params) => ({
|
|
188
|
+
* q: params.query.trim().toLowerCase(),
|
|
189
|
+
* f: params.filters.join(','),
|
|
190
|
+
* })),
|
|
191
|
+
* loader: async ({ params }) => {
|
|
192
|
+
* const queryString = new URLSearchParams(params);
|
|
193
|
+
* const response = await fetch(`/api/search?${queryString}`);
|
|
194
|
+
* return response.json();
|
|
195
|
+
* },
|
|
196
|
+
* });
|
|
197
|
+
*
|
|
198
|
+
* return { searchParams, results };
|
|
199
|
+
* },
|
|
200
|
+
* );
|
|
201
|
+
*
|
|
202
|
+
* const store = ResultsStore();
|
|
203
|
+
*
|
|
204
|
+
* // Data is transformed before query execution
|
|
205
|
+
* store.searchParams.set({
|
|
206
|
+
* query: ' Angular ',
|
|
207
|
+
* filters: ['tutorial', 'advanced'],
|
|
208
|
+
* });
|
|
209
|
+
* // -> query receives { q: 'angular', f: 'tutorial,advanced' }
|
|
210
|
+
* ```
|
|
211
|
+
*
|
|
212
|
+
* @example
|
|
213
|
+
* Validation and type narrowing
|
|
214
|
+
* ```ts
|
|
215
|
+
* const { ValidationStore } = craftService(
|
|
216
|
+
* { name: 'ValidationStore', providedIn: 'toProvide' },
|
|
217
|
+
* function* () {
|
|
218
|
+
* const inputChange = signalSource<string>('inputChange');
|
|
219
|
+
*
|
|
220
|
+
* const validate = yield* asyncProcess({
|
|
221
|
+
* method: afterRecomputation(inputChange, (input) => {
|
|
222
|
+
* // Only proceed if input is valid
|
|
223
|
+
* const trimmed = input.trim();
|
|
224
|
+
* if (trimmed.length < 3) {
|
|
225
|
+
* throw new Error('Input too short');
|
|
226
|
+
* }
|
|
227
|
+
* return trimmed;
|
|
228
|
+
* }),
|
|
229
|
+
* loader: async ({ params }) => {
|
|
230
|
+
* const response = await fetch('/api/validate', {
|
|
231
|
+
* method: 'POST',
|
|
232
|
+
* body: JSON.stringify({ input: params }),
|
|
233
|
+
* });
|
|
234
|
+
* return response.json();
|
|
235
|
+
* },
|
|
236
|
+
* });
|
|
237
|
+
*
|
|
238
|
+
* return { inputChange, validate };
|
|
239
|
+
* },
|
|
240
|
+
* );
|
|
241
|
+
*
|
|
242
|
+
* const store = ValidationStore();
|
|
243
|
+
*
|
|
244
|
+
* // Invalid input throws error in the callback
|
|
245
|
+
* store.inputChange.set('ab'); // Error: Input too short
|
|
246
|
+
*
|
|
247
|
+
* // Valid input proceeds
|
|
248
|
+
* store.inputChange.set('valid input'); // Validation executes
|
|
249
|
+
* ```
|
|
250
|
+
*
|
|
251
|
+
* @example
|
|
252
|
+
* Multiple sources with different transformations
|
|
253
|
+
* ```ts
|
|
254
|
+
* const { SearchResultsStore } = craftService(
|
|
255
|
+
* { name: 'SearchResultsStore', providedIn: 'toProvide' },
|
|
256
|
+
* function* () {
|
|
257
|
+
* const quickSearch = signalSource<string>('quickSearch');
|
|
258
|
+
* const advancedSearch = signalSource<{ query: string; options: unknown }>('advancedSearch');
|
|
259
|
+
*
|
|
260
|
+
* const searchResults = yield* query({
|
|
261
|
+
* method: afterRecomputation(
|
|
262
|
+
* // Can combine sources at a higher level
|
|
263
|
+
* quickSearch, // For this example, using one source
|
|
264
|
+
* (term) => ({ query: term, mode: 'quick' }),
|
|
265
|
+
* ),
|
|
266
|
+
* loader: async ({ params }) => {
|
|
267
|
+
* const response = await fetch('/api/search', {
|
|
268
|
+
* method: 'POST',
|
|
269
|
+
* body: JSON.stringify(params),
|
|
270
|
+
* });
|
|
271
|
+
* return response.json();
|
|
272
|
+
* },
|
|
273
|
+
* });
|
|
274
|
+
*
|
|
275
|
+
* return { quickSearch, advancedSearch, searchResults };
|
|
276
|
+
* },
|
|
277
|
+
* );
|
|
278
|
+
*
|
|
279
|
+
* const store = SearchResultsStore();
|
|
280
|
+
*
|
|
281
|
+
* // Quick search with a simple string
|
|
282
|
+
* store.quickSearch.set('angular');
|
|
283
|
+
* // -> query receives { query: 'angular', mode: 'quick' }
|
|
284
|
+
* ```
|
|
285
|
+
*
|
|
286
|
+
* @example
|
|
287
|
+
* Identity transformation (pass-through)
|
|
288
|
+
* ```ts
|
|
289
|
+
* const { DataStore } = craftService(
|
|
290
|
+
* { name: 'DataStore', providedIn: 'toProvide' },
|
|
291
|
+
* function* () {
|
|
292
|
+
* const dataUpdate = signalSource<{ id: string; payload: unknown }>('dataUpdate');
|
|
293
|
+
*
|
|
294
|
+
* const update = yield* mutation({
|
|
295
|
+
* // Pass data through unchanged
|
|
296
|
+
* method: afterRecomputation(dataUpdate, (data) => data),
|
|
297
|
+
* loader: async ({ params }) => {
|
|
298
|
+
* const response = await fetch(`/api/data/${params.id}`, {
|
|
299
|
+
* method: 'PUT',
|
|
300
|
+
* body: JSON.stringify(params.payload),
|
|
301
|
+
* });
|
|
302
|
+
* return response.json();
|
|
303
|
+
* },
|
|
304
|
+
* });
|
|
305
|
+
*
|
|
306
|
+
* return { dataUpdate, update };
|
|
307
|
+
* },
|
|
308
|
+
* );
|
|
309
|
+
*
|
|
310
|
+
* const store = DataStore();
|
|
311
|
+
*
|
|
312
|
+
* // Data passed through unchanged
|
|
313
|
+
* store.dataUpdate.set({ id: 'item-1', payload: { value: 123 } });
|
|
314
|
+
* // -> mutation receives the exact same object
|
|
315
|
+
* ```
|
|
316
|
+
*/
|
|
317
|
+
export declare function afterRecomputation<State, SourceType>(_source: SignalSource<SourceType>, callback: (source: SourceType) => State): ReadonlySource<State>;
|
|
318
|
+
export declare function afterRecomputation<State, SourceType>(_source: ReadonlySource<SourceType>, callback: (source: SourceType) => State): ReadonlySource<State>;
|
|
319
|
+
/**
|
|
320
|
+
* Inside a `transitionStep(...)`, `afterRecomputation` is a machine
|
|
321
|
+
* registration: every time the watched value recomputes, the callback runs
|
|
322
|
+
* untracked with its declaring step restored, so the `transit(...)` attempts it
|
|
323
|
+
* yields target that step. Consume it with `yield*` so the callback's
|
|
324
|
+
* dependencies join the machine's dependency graph.
|
|
325
|
+
*/
|
|
326
|
+
export declare function afterRecomputation<Value, Yielded>(source: Signal<Value>, callback: (value: Value) => Generator<Yielded, unknown, unknown>): Generator<Yielded, void, unknown>;
|
|
327
|
+
//# sourceMappingURL=after-recomputation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"after-recomputation.d.ts","sourceRoot":"","sources":["../../../../../libs/core/src/lib/after-recomputation.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6B,KAAK,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7E,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAOpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwTG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,UAAU,EAClD,OAAO,EAAE,YAAY,CAAC,UAAU,CAAC,EACjC,QAAQ,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,KAAK,GACtC,cAAc,CAAC,KAAK,CAAC,CAAC;AACzB,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,UAAU,EAClD,OAAO,EAAE,cAAc,CAAC,UAAU,CAAC,EACnC,QAAQ,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,KAAK,GACtC,cAAc,CAAC,KAAK,CAAC,CAAC;AACzB;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,EAC/C,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,EACrB,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,SAAS,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,GAC/D,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { effect, signal, untracked } from './host/craft-compat';
|
|
2
|
+
import { SourceBranded } from './util/util';
|
|
3
|
+
import { ɵactiveMachineScope, ɵregisterMachineRecomputation, } from './craft-state-machine-runtime';
|
|
4
|
+
export function afterRecomputation(_source, callback) {
|
|
5
|
+
if (ɵactiveMachineScope()) {
|
|
6
|
+
return ɵregisterMachineRecomputation(_source, callback);
|
|
7
|
+
}
|
|
8
|
+
const source = _source;
|
|
9
|
+
const initialValue = source();
|
|
10
|
+
const derivedSource = signal(initialValue && callback(initialValue));
|
|
11
|
+
const effectRef = effect(() => {
|
|
12
|
+
const sourceValue = source();
|
|
13
|
+
if (sourceValue !== undefined) {
|
|
14
|
+
untracked(() => {
|
|
15
|
+
const newState = callback(sourceValue);
|
|
16
|
+
derivedSource.set(newState);
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
derivedSource.set(undefined);
|
|
21
|
+
}
|
|
22
|
+
}, {});
|
|
23
|
+
return Object.assign(derivedSource, SourceBranded);
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=after-recomputation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"after-recomputation.js","sourceRoot":"","sources":["../../../../../libs/core/src/lib/after-recomputation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAe,MAAM,qBAAqB,CAAC;AAG7E,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EACL,mBAAmB,EACnB,6BAA6B,GAC9B,MAAM,+BAA+B,CAAC;AA8UvC,MAAM,UAAU,kBAAkB,CAChC,OAGsB,EACtB,QAAuC;IAKvC,IAAI,mBAAmB,EAAE,EAAE,CAAC;QAC1B,OAAO,6BAA6B,CAClC,OAAqC,EACrC,QAAqC,CACF,CAAC;IACxC,CAAC;IAED,MAAM,MAAM,GAAG,OAAqC,CAAC;IACrD,MAAM,YAAY,GAAG,MAAM,EAAE,CAAC;IAC9B,MAAM,aAAa,GAAG,MAAM,CAC1B,YAAY,IAAI,QAAQ,CAAC,YAAY,CAAC,CACvC,CAAC;IACF,MAAM,SAAS,GAAG,MAAM,CAAC,GAAG,EAAE;QAC5B,MAAM,WAAW,GAAG,MAAM,EAAE,CAAC;QAC7B,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;YAC9B,SAAS,CAAC,GAAG,EAAE;gBACb,MAAM,QAAQ,GAAG,QAAQ,CAAC,WAAW,CAAC,CAAC;gBACvC,aAAa,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YAC9B,CAAC,CAAC,CAAC;QACL,CAAC;aAAM,CAAC;YACN,aAAa,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAC/B,CAAC;IACH,CAAC,EAAE,EAAE,CAAC,CAAC;IACP,OAAO,MAAM,CAAC,MAAM,CAClB,aAAa,EACb,aAAa,CACsB,CAAC;AACxC,CAAC","sourcesContent":["import { effect, signal, untracked, type Signal } from './host/craft-compat';\nimport { SignalSource } from './signal-source';\nimport { ReadonlySource } from './util/source.type';\nimport { SourceBranded } from './util/util';\nimport {\n ɵactiveMachineScope,\n ɵregisterMachineRecomputation,\n} from './craft-state-machine-runtime';\n\n/**\n * Creates a derived readonly source that transforms source emissions through a callback function.\n *\n * This function binds queries, mutations, and async methods to sources for automatic execution by:\n * - Listening to source emissions and computing new values\n * - Providing a readonly source suitable for method binding\n * - Maintaining reactivity through Angular's effect system\n * - Enabling source-based triggering patterns\n *\n * @remarks\n * **Primary Use Case:**\n * Bind queries/mutations/async methods to sources for automatic execution:\n * ```ts\n * method: afterRecomputation(mySource, (data) => data)\n * ```\n * This pattern makes queries/mutations execute automatically when the source emits.\n *\n * **Execution Flow:**\n * 1. Source emits a value via `source.set(value)`\n * 2. afterRecomputation callback transforms the value\n * 3. Resulting readonly source emits the transformed value\n * 4. Bound query/mutation/async method executes with the new value\n *\n * **Difference from computedSource:**\n * - `afterRecomputation`: Designed for binding to method parameters\n * - `computedSource`: General-purpose source transformation\n * - Both transform source values, but afterRecomputation is optimized for method binding\n *\n * **Common Patterns:**\n * - **Identity transformation**: `afterRecomputation(source, (x) => x)` - pass value through\n * - **Field extraction**: `afterRecomputation(source, (data) => data.id)` - extract specific field\n * - **Validation**: `afterRecomputation(source, (data) => validate(data))` - transform and validate\n * - **Mapping**: `afterRecomputation(source, (data) => mapToDto(data))` - convert to different type\n *\n * @template State - The type of values produced by the callback\n * @template SourceType - The type of values emitted by the origin source\n *\n * @param _source - The source to listen to.\n * When this source emits, the callback is invoked.\n *\n * @param callback - Function that transforms source values.\n * Receives the emitted value and returns the transformed result.\n *\n * @returns A readonly source that emits transformed values.\n * Can be used as the `method` parameter in queries, mutations, and async methods.\n *\n * @example\n * Binding a query to a source for automatic execution\n * ```ts\n * const { UserStore } = craftService(\n * { name: 'UserStore', providedIn: 'toProvide' },\n * function* () {\n * const userIdChange = signalSource<string>('userIdChange');\n *\n * const user = yield* query({\n * method: afterRecomputation(userIdChange, (userId) => userId),\n * loader: async ({ params }) => {\n * const response = await fetch(`/api/users/${params}`);\n * return response.json();\n * },\n * });\n *\n * return { userIdChange, user };\n * },\n * );\n *\n * const store = UserStore();\n *\n * // Query executes automatically when source emits\n * store.userIdChange.set('user-123');\n * // -> query loader executes with params 'user-123'\n *\n * store.userIdChange.set('user-456');\n * // -> query loader executes again with params 'user-456'\n * ```\n *\n * @example\n * Binding a mutation to a source\n * ```ts\n * const { FormStore } = craftService(\n * { name: 'FormStore', providedIn: 'toProvide' },\n * function* () {\n * const submitForm = signalSource<{ name: string; email: string }>('submitForm');\n *\n * const submit = yield* mutation({\n * method: afterRecomputation(submitForm, (formData) => formData),\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 * // Mutation executes automatically when source emits\n * store.submitForm.set({ name: 'John', email: 'john@example.com' });\n * // -> mutation loader executes with form data\n * // The mutation is driven by the source; store.submit.mutate() is unused here\n * ```\n *\n * @example\n * Binding an async process to a source\n * ```ts\n * const { SearchStore } = craftService(\n * { name: 'SearchStore', providedIn: 'toProvide' },\n * function* () {\n * const searchInput = signalSource<string>('searchInput');\n *\n * const search = yield* asyncProcess({\n * method: afterRecomputation(searchInput, (term) => term),\n * loader: async ({ params }) => {\n * // Debounce at source level before setting\n * const response = await fetch(`/api/search?q=${params}`);\n * return response.json();\n * },\n * });\n *\n * return { searchInput, search };\n * },\n * );\n *\n * const store = SearchStore();\n *\n * // Async process executes automatically\n * store.searchInput.set('query');\n * // -> search loader executes\n * ```\n *\n * @example\n * Extracting specific field from complex data\n * ```ts\n * type FormData = {\n * user: { id: string; name: string };\n * address: { city: string };\n * };\n *\n * const { UserFormStore } = craftService(\n * { name: 'UserFormStore', providedIn: 'toProvide' },\n * function* () {\n * const formSubmit = signalSource<FormData>('formSubmit');\n *\n * const updateUser = yield* mutation({\n * // Extract only user data\n * method: afterRecomputation(formSubmit, (data) => data.user),\n * loader: async ({ params }) => {\n * const response = await fetch(`/api/users/${params.id}`, {\n * method: 'PATCH',\n * body: JSON.stringify(params),\n * });\n * return response.json();\n * },\n * });\n *\n * return { formSubmit, updateUser };\n * },\n * );\n *\n * const store = UserFormStore();\n *\n * // Only user data is passed to the mutation\n * store.formSubmit.set({\n * user: { id: 'user-1', name: 'John' },\n * address: { city: 'NYC' },\n * });\n * // -> mutation receives only { id: 'user-1', name: 'John' }\n * ```\n *\n * @example\n * Transforming data before execution\n * ```ts\n * const { ResultsStore } = craftService(\n * { name: 'ResultsStore', providedIn: 'toProvide' },\n * function* () {\n * const searchParams = signalSource<{ query: string; filters: string[] }>('searchParams');\n *\n * const results = yield* query({\n * method: afterRecomputation(searchParams, (params) => ({\n * q: params.query.trim().toLowerCase(),\n * f: params.filters.join(','),\n * })),\n * loader: async ({ params }) => {\n * const queryString = new URLSearchParams(params);\n * const response = await fetch(`/api/search?${queryString}`);\n * return response.json();\n * },\n * });\n *\n * return { searchParams, results };\n * },\n * );\n *\n * const store = ResultsStore();\n *\n * // Data is transformed before query execution\n * store.searchParams.set({\n * query: ' Angular ',\n * filters: ['tutorial', 'advanced'],\n * });\n * // -> query receives { q: 'angular', f: 'tutorial,advanced' }\n * ```\n *\n * @example\n * Validation and type narrowing\n * ```ts\n * const { ValidationStore } = craftService(\n * { name: 'ValidationStore', providedIn: 'toProvide' },\n * function* () {\n * const inputChange = signalSource<string>('inputChange');\n *\n * const validate = yield* asyncProcess({\n * method: afterRecomputation(inputChange, (input) => {\n * // Only proceed if input is valid\n * const trimmed = input.trim();\n * if (trimmed.length < 3) {\n * throw new Error('Input too short');\n * }\n * return trimmed;\n * }),\n * loader: async ({ params }) => {\n * const response = await fetch('/api/validate', {\n * method: 'POST',\n * body: JSON.stringify({ input: params }),\n * });\n * return response.json();\n * },\n * });\n *\n * return { inputChange, validate };\n * },\n * );\n *\n * const store = ValidationStore();\n *\n * // Invalid input throws error in the callback\n * store.inputChange.set('ab'); // Error: Input too short\n *\n * // Valid input proceeds\n * store.inputChange.set('valid input'); // Validation executes\n * ```\n *\n * @example\n * Multiple sources with different transformations\n * ```ts\n * const { SearchResultsStore } = craftService(\n * { name: 'SearchResultsStore', providedIn: 'toProvide' },\n * function* () {\n * const quickSearch = signalSource<string>('quickSearch');\n * const advancedSearch = signalSource<{ query: string; options: unknown }>('advancedSearch');\n *\n * const searchResults = yield* query({\n * method: afterRecomputation(\n * // Can combine sources at a higher level\n * quickSearch, // For this example, using one source\n * (term) => ({ query: term, mode: 'quick' }),\n * ),\n * loader: async ({ params }) => {\n * const response = await fetch('/api/search', {\n * method: 'POST',\n * body: JSON.stringify(params),\n * });\n * return response.json();\n * },\n * });\n *\n * return { quickSearch, advancedSearch, searchResults };\n * },\n * );\n *\n * const store = SearchResultsStore();\n *\n * // Quick search with a simple string\n * store.quickSearch.set('angular');\n * // -> query receives { query: 'angular', mode: 'quick' }\n * ```\n *\n * @example\n * Identity transformation (pass-through)\n * ```ts\n * const { DataStore } = craftService(\n * { name: 'DataStore', providedIn: 'toProvide' },\n * function* () {\n * const dataUpdate = signalSource<{ id: string; payload: unknown }>('dataUpdate');\n *\n * const update = yield* mutation({\n * // Pass data through unchanged\n * method: afterRecomputation(dataUpdate, (data) => data),\n * loader: async ({ params }) => {\n * const response = await fetch(`/api/data/${params.id}`, {\n * method: 'PUT',\n * body: JSON.stringify(params.payload),\n * });\n * return response.json();\n * },\n * });\n *\n * return { dataUpdate, update };\n * },\n * );\n *\n * const store = DataStore();\n *\n * // Data passed through unchanged\n * store.dataUpdate.set({ id: 'item-1', payload: { value: 123 } });\n * // -> mutation receives the exact same object\n * ```\n */\nexport function afterRecomputation<State, SourceType>(\n _source: SignalSource<SourceType>,\n callback: (source: SourceType) => State,\n): ReadonlySource<State>;\nexport function afterRecomputation<State, SourceType>(\n _source: ReadonlySource<SourceType>,\n callback: (source: SourceType) => State,\n): ReadonlySource<State>;\n/**\n * Inside a `transitionStep(...)`, `afterRecomputation` is a machine\n * registration: every time the watched value recomputes, the callback runs\n * untracked with its declaring step restored, so the `transit(...)` attempts it\n * yields target that step. Consume it with `yield*` so the callback's\n * dependencies join the machine's dependency graph.\n */\nexport function afterRecomputation<Value, Yielded>(\n source: Signal<Value>,\n callback: (value: Value) => Generator<Yielded, unknown, unknown>,\n): Generator<Yielded, void, unknown>;\nexport function afterRecomputation<State, SourceType>(\n _source:\n | SignalSource<SourceType>\n | ReadonlySource<SourceType>\n | Signal<SourceType>,\n callback: (source: SourceType) => State,\n // The machine overload resolves to a registration generator instead of a\n // readonly source, so the implementation signature stays deliberately loose.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): any {\n if (ɵactiveMachineScope()) {\n return ɵregisterMachineRecomputation(\n _source as unknown as Signal<unknown>,\n callback as (value: never) => unknown,\n ) as unknown as ReadonlySource<State>;\n }\n\n const source = _source as ReadonlySource<SourceType>;\n const initialValue = source();\n const derivedSource = signal<State | undefined>(\n initialValue && callback(initialValue),\n );\n const effectRef = effect(() => {\n const sourceValue = source();\n if (sourceValue !== undefined) {\n untracked(() => {\n const newState = callback(sourceValue);\n derivedSource.set(newState);\n });\n } else {\n derivedSource.set(undefined);\n }\n }, {});\n return Object.assign(\n derivedSource,\n SourceBranded,\n ) as unknown as ReadonlySource<State>;\n}\n"]}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { Simplify, UnionToTuple } from './craft-service.shared';
|
|
2
|
+
import type { MissingProvidersFromDepsMap } from './branded-component/branded-component';
|
|
3
|
+
import type { AppConfigProvidedDependencyValuesKey, AppConfigProvidedServiceNamesKey } from './craft-app-config';
|
|
4
|
+
type DepsMap<Input> = Input extends {
|
|
5
|
+
deps: infer Deps extends object;
|
|
6
|
+
} ? Deps : {};
|
|
7
|
+
type ProvidedMap<Input> = Input extends {
|
|
8
|
+
provided: infer Provided extends object;
|
|
9
|
+
} ? Provided : {};
|
|
10
|
+
type PublicPropertiesMap<Input> = Input extends {
|
|
11
|
+
publicProperties: infer PublicProperties extends object;
|
|
12
|
+
} ? PublicProperties : {};
|
|
13
|
+
type MissingProviderMap<Input> = Input extends {
|
|
14
|
+
missingProvider: infer MissingProvider extends object;
|
|
15
|
+
} ? MissingProvider : Simplify<Omit<MissingProvidersFromDepsMap<DepsMap<Input>>, keyof ProvidedMap<Input>>>;
|
|
16
|
+
type AppProvidedServiceNames<Routes> = Routes extends {
|
|
17
|
+
readonly [Key in AppConfigProvidedServiceNamesKey]?: infer ProvidedNames extends string;
|
|
18
|
+
} ? ProvidedNames : never;
|
|
19
|
+
type AppProvidedDependencyValues<Routes> = Routes extends {
|
|
20
|
+
readonly [Key in AppConfigProvidedDependencyValuesKey]?: infer ProvidedValues;
|
|
21
|
+
} ? ProvidedValues : never;
|
|
22
|
+
type AppProvidedValueKeys<MissingProviders extends object, ProvidedValues> = {
|
|
23
|
+
[Name in Extract<keyof MissingProviders, string>]: MissingProviders[Name] extends ProvidedValues ? Name : never;
|
|
24
|
+
}[Extract<keyof MissingProviders, string>];
|
|
25
|
+
type AppMissingProviderMap<AppComponentDeps, AppRoutes extends readonly unknown[]> = Simplify<Omit<MissingProviderMap<AppComponentDeps>, AppProvidedServiceNames<AppRoutes> | AppProvidedValueKeys<MissingProviderMap<AppComponentDeps>, AppProvidedDependencyValues<AppRoutes>>>>;
|
|
26
|
+
type InputErrorMessage<Name extends string, Context extends string> = `Input "${Name}" is not provided in ${Context}`;
|
|
27
|
+
type InjectedErrorMessage<Name extends string, Context extends string> = `The ${Name} service is not provided in ${Context}`;
|
|
28
|
+
type InputErrorMessagesFromNames<Names extends readonly unknown[], Context extends string> = Names extends readonly [infer Head extends string, ...infer Tail] ? [
|
|
29
|
+
InputErrorMessage<Head, Context>,
|
|
30
|
+
...InputErrorMessagesFromNames<Tail, Context>
|
|
31
|
+
] : [];
|
|
32
|
+
type InjectedErrorMessagesFromNames<Names extends readonly unknown[], Context extends string> = Names extends readonly [infer Head extends string, ...infer Tail] ? [
|
|
33
|
+
InjectedErrorMessage<Head, Context>,
|
|
34
|
+
...InjectedErrorMessagesFromNames<Tail, Context>
|
|
35
|
+
] : [];
|
|
36
|
+
type InputErrorMessages<Input, Context extends string> = InputErrorMessagesFromNames<UnionToTuple<Extract<keyof PublicPropertiesMap<Input>, string>>, Context>;
|
|
37
|
+
type InjectedErrorMessages<Input, Context extends string> = InjectedErrorMessagesFromNames<UnionToTuple<Extract<keyof MissingProviderMap<Input>, string>>, Context>;
|
|
38
|
+
type RoutePath<RouteDefinition> = RouteDefinition extends {
|
|
39
|
+
path: infer Path extends string;
|
|
40
|
+
} ? Path : string;
|
|
41
|
+
type RouteContext<RouteDefinition> = `path: "${RoutePath<RouteDefinition>}"`;
|
|
42
|
+
type RouteErrorMessages<RouteDefinition> = [
|
|
43
|
+
...InputErrorMessages<RouteDefinition, RouteContext<RouteDefinition>>,
|
|
44
|
+
...InjectedErrorMessages<RouteDefinition, RouteContext<RouteDefinition>>
|
|
45
|
+
];
|
|
46
|
+
type RoutesErrorMessagesByIndex<Routes extends readonly unknown[], Traversed extends readonly unknown[] = readonly []> = number extends Routes['length'] ? UnionToTuple<RouteErrorMessages<Routes[number]>[number]> : Traversed['length'] extends Routes['length'] ? [] : [...Traversed, unknown]['length'] extends Routes['length'] ? [...RouteErrorMessages<Routes[Traversed['length']]>] : [...Traversed, unknown, unknown]['length'] extends Routes['length'] ? [
|
|
47
|
+
...RouteErrorMessages<Routes[Traversed['length']]>,
|
|
48
|
+
...RouteErrorMessages<Routes[[...Traversed, unknown]['length']]>
|
|
49
|
+
] : [
|
|
50
|
+
...Traversed,
|
|
51
|
+
unknown,
|
|
52
|
+
unknown,
|
|
53
|
+
unknown
|
|
54
|
+
]['length'] extends Routes['length'] ? [
|
|
55
|
+
...RouteErrorMessages<Routes[Traversed['length']]>,
|
|
56
|
+
...RouteErrorMessages<Routes[[...Traversed, unknown]['length']]>,
|
|
57
|
+
...RouteErrorMessages<Routes[[...Traversed, unknown, unknown]['length']]>
|
|
58
|
+
] : [
|
|
59
|
+
...RouteErrorMessages<Routes[Traversed['length']]>,
|
|
60
|
+
...RouteErrorMessages<Routes[[...Traversed, unknown]['length']]>,
|
|
61
|
+
...RouteErrorMessages<Routes[[...Traversed, unknown, unknown]['length']]>,
|
|
62
|
+
...RouteErrorMessages<Routes[[...Traversed, unknown, unknown, unknown]['length']]>,
|
|
63
|
+
...RoutesErrorMessagesByIndex<Routes, [
|
|
64
|
+
...Traversed,
|
|
65
|
+
unknown,
|
|
66
|
+
unknown,
|
|
67
|
+
unknown,
|
|
68
|
+
unknown
|
|
69
|
+
]>
|
|
70
|
+
];
|
|
71
|
+
type RoutesErrorMessages<Routes extends readonly unknown[]> = RoutesErrorMessagesByIndex<Routes>;
|
|
72
|
+
type AppErrorMessages<AppComponentDeps, AppRoutes extends readonly unknown[]> = [
|
|
73
|
+
...InputErrorMessages<AppComponentDeps, 'AppComponent'>,
|
|
74
|
+
...InjectedErrorMessagesFromNames<UnionToTuple<Extract<keyof AppMissingProviderMap<AppComponentDeps, AppRoutes>, string>>, 'AppComponent'>
|
|
75
|
+
];
|
|
76
|
+
export type AppCheckedDI<AppComponentDeps, AppRoutes extends readonly unknown[]> = [
|
|
77
|
+
...AppErrorMessages<AppComponentDeps, AppRoutes>,
|
|
78
|
+
...RoutesErrorMessages<AppRoutes>
|
|
79
|
+
] extends infer Errors extends string[] ? Errors extends [] ? true : Errors : never;
|
|
80
|
+
export type CanRun<IsAppValid extends true> = IsAppValid extends true ? true : never;
|
|
81
|
+
export {};
|
|
82
|
+
//# sourceMappingURL=app-checked-di.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-checked-di.d.ts","sourceRoot":"","sources":["../../../../../libs/core/src/lib/app-checked-di.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=app-checked-di.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-checked-di.js","sourceRoot":"","sources":["../../../../../libs/core/src/lib/app-checked-di.ts"],"names":[],"mappings":"","sourcesContent":["import type { Simplify, UnionToTuple } from './craft-service.shared';\nimport type { MissingProvidersFromDepsMap } from './branded-component/branded-component';\nimport type {\n AppConfigProvidedDependencyValuesKey,\n AppConfigProvidedServiceNamesKey,\n} from './craft-app-config';\n\ntype DepsMap<Input> = Input extends { deps: infer Deps extends object }\n ? Deps\n : {};\n\ntype ProvidedMap<Input> = Input extends {\n provided: infer Provided extends object;\n}\n ? Provided\n : {};\n\ntype PublicPropertiesMap<Input> = Input extends {\n publicProperties: infer PublicProperties extends object;\n}\n ? PublicProperties\n : {};\n\ntype MissingProviderMap<Input> = Input extends {\n missingProvider: infer MissingProvider extends object;\n}\n ? MissingProvider\n : Simplify<\n Omit<\n MissingProvidersFromDepsMap<DepsMap<Input>>,\n keyof ProvidedMap<Input>\n >\n >;\n\ntype AppProvidedServiceNames<Routes> = Routes extends {\n readonly [Key in AppConfigProvidedServiceNamesKey]?: infer ProvidedNames extends\n string;\n}\n ? ProvidedNames\n : never;\n\ntype AppProvidedDependencyValues<Routes> = Routes extends {\n readonly [Key in AppConfigProvidedDependencyValuesKey]?: infer ProvidedValues;\n}\n ? ProvidedValues\n : never;\n\ntype AppProvidedValueKeys<MissingProviders extends object, ProvidedValues> = {\n [Name in Extract<\n keyof MissingProviders,\n string\n >]: MissingProviders[Name] extends ProvidedValues ? Name : never;\n}[Extract<keyof MissingProviders, string>];\n\ntype AppMissingProviderMap<\n AppComponentDeps,\n AppRoutes extends readonly unknown[],\n> = Simplify<\n Omit<\n MissingProviderMap<AppComponentDeps>,\n | AppProvidedServiceNames<AppRoutes>\n | AppProvidedValueKeys<\n MissingProviderMap<AppComponentDeps>,\n AppProvidedDependencyValues<AppRoutes>\n >\n >\n>;\n\ntype InputErrorMessage<\n Name extends string,\n Context extends string,\n> = `Input \"${Name}\" is not provided in ${Context}`;\n\ntype InjectedErrorMessage<\n Name extends string,\n Context extends string,\n> = `The ${Name} service is not provided in ${Context}`;\n\ntype InputErrorMessagesFromNames<\n Names extends readonly unknown[],\n Context extends string,\n> = Names extends readonly [infer Head extends string, ...infer Tail]\n ? [\n InputErrorMessage<Head, Context>,\n ...InputErrorMessagesFromNames<Tail, Context>,\n ]\n : [];\n\ntype InjectedErrorMessagesFromNames<\n Names extends readonly unknown[],\n Context extends string,\n> = Names extends readonly [infer Head extends string, ...infer Tail]\n ? [\n InjectedErrorMessage<Head, Context>,\n ...InjectedErrorMessagesFromNames<Tail, Context>,\n ]\n : [];\n\ntype InputErrorMessages<\n Input,\n Context extends string,\n> = InputErrorMessagesFromNames<\n UnionToTuple<Extract<keyof PublicPropertiesMap<Input>, string>>,\n Context\n>;\n\ntype InjectedErrorMessages<\n Input,\n Context extends string,\n> = InjectedErrorMessagesFromNames<\n UnionToTuple<Extract<keyof MissingProviderMap<Input>, string>>,\n Context\n>;\n\ntype RoutePath<RouteDefinition> = RouteDefinition extends {\n path: infer Path extends string;\n}\n ? Path\n : string;\n\ntype RouteContext<RouteDefinition> = `path: \"${RoutePath<RouteDefinition>}\"`;\n\ntype RouteErrorMessages<RouteDefinition> = [\n ...InputErrorMessages<RouteDefinition, RouteContext<RouteDefinition>>,\n ...InjectedErrorMessages<RouteDefinition, RouteContext<RouteDefinition>>,\n];\n\n// Uses index-based access (works with mapped types like APP_CONFIG_META_DATA) and\n// processes 4 routes per step to keep recursion depth ~N/4 for large route tables.\ntype RoutesErrorMessagesByIndex<\n Routes extends readonly unknown[],\n Traversed extends readonly unknown[] = readonly [],\n> = number extends Routes['length']\n ? UnionToTuple<RouteErrorMessages<Routes[number]>[number]>\n : Traversed['length'] extends Routes['length']\n ? []\n : [...Traversed, unknown]['length'] extends Routes['length']\n ? [...RouteErrorMessages<Routes[Traversed['length']]>]\n : [...Traversed, unknown, unknown]['length'] extends Routes['length']\n ? [\n ...RouteErrorMessages<Routes[Traversed['length']]>,\n ...RouteErrorMessages<Routes[[...Traversed, unknown]['length']]>,\n ]\n : [\n ...Traversed,\n unknown,\n unknown,\n unknown,\n ]['length'] extends Routes['length']\n ? [\n ...RouteErrorMessages<Routes[Traversed['length']]>,\n ...RouteErrorMessages<Routes[[...Traversed, unknown]['length']]>,\n ...RouteErrorMessages<\n Routes[[...Traversed, unknown, unknown]['length']]\n >,\n ]\n : [\n ...RouteErrorMessages<Routes[Traversed['length']]>,\n ...RouteErrorMessages<Routes[[...Traversed, unknown]['length']]>,\n ...RouteErrorMessages<\n Routes[[...Traversed, unknown, unknown]['length']]\n >,\n ...RouteErrorMessages<\n Routes[[...Traversed, unknown, unknown, unknown]['length']]\n >,\n ...RoutesErrorMessagesByIndex<\n Routes,\n [...Traversed, unknown, unknown, unknown, unknown]\n >,\n ];\n\ntype RoutesErrorMessages<Routes extends readonly unknown[]> =\n RoutesErrorMessagesByIndex<Routes>;\n\ntype AppErrorMessages<\n AppComponentDeps,\n AppRoutes extends readonly unknown[],\n> = [\n ...InputErrorMessages<AppComponentDeps, 'AppComponent'>,\n ...InjectedErrorMessagesFromNames<\n UnionToTuple<\n Extract<keyof AppMissingProviderMap<AppComponentDeps, AppRoutes>, string>\n >,\n 'AppComponent'\n >,\n];\n\nexport type AppCheckedDI<\n AppComponentDeps,\n AppRoutes extends readonly unknown[],\n> = [\n ...AppErrorMessages<AppComponentDeps, AppRoutes>,\n ...RoutesErrorMessages<AppRoutes>,\n] extends infer Errors extends string[]\n ? Errors extends []\n ? true\n : Errors\n : never;\n\nexport type CanRun<IsAppValid extends true> = IsAppValid extends true\n ? true\n : never;\n"]}
|