@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,303 @@
|
|
|
1
|
+
import { ValueEqualityFn } from './host/craft-compat';
|
|
2
|
+
import { ReadonlySource } from './util/source.type';
|
|
3
|
+
import { SignalSource } from './signal-source';
|
|
4
|
+
/**
|
|
5
|
+
* Creates a derived readonly source that transforms values from an origin source using a computation function.
|
|
6
|
+
*
|
|
7
|
+
* This function enables reactive transformations of source emissions by:
|
|
8
|
+
* - Computing new values whenever the origin source emits
|
|
9
|
+
* - Maintaining source semantics (emits only when explicitly set, not on first read)
|
|
10
|
+
* - Supporting custom equality comparisons for memoization
|
|
11
|
+
* - Providing both standard and value-preserving listeners
|
|
12
|
+
* - Creating composable source pipelines
|
|
13
|
+
*
|
|
14
|
+
* @remarks
|
|
15
|
+
* **Emission Behavior:**
|
|
16
|
+
* - Only emits when the origin source emits (explicit set/update)
|
|
17
|
+
* - First read returns `undefined` by default (maintains source semantics)
|
|
18
|
+
* - Use `preserveLastValue` variant to get computed value on first read
|
|
19
|
+
*
|
|
20
|
+
* **Use Cases:**
|
|
21
|
+
* - **Data transformation**: Convert source payloads to different shapes
|
|
22
|
+
* - **Filtering**: Extract specific fields from complex source data
|
|
23
|
+
* - **Formatting**: Apply formatting logic to source values
|
|
24
|
+
* - **Type narrowing**: Cast or validate source data types
|
|
25
|
+
* - **Composition**: Chain multiple source transformations
|
|
26
|
+
* - **Business logic**: Apply domain-specific computations
|
|
27
|
+
*
|
|
28
|
+
* **Source vs Signal:**
|
|
29
|
+
* - Sources emit only on explicit events (set/update calls)
|
|
30
|
+
* - Signals recompute on every access when dependencies change
|
|
31
|
+
* - computedSource maintains source lazy behavior
|
|
32
|
+
*
|
|
33
|
+
* **Equality Comparison:**
|
|
34
|
+
* - Default: Uses Angular's default equality check
|
|
35
|
+
* - Custom: Provide `equal` option for custom comparison
|
|
36
|
+
* - Prevents unnecessary emissions when computed value hasn't changed
|
|
37
|
+
*
|
|
38
|
+
* @template SourceState - The type of values emitted by the origin source
|
|
39
|
+
* @template ComputedValue - The type of values produced by the computation
|
|
40
|
+
*
|
|
41
|
+
* @param signalOrigin - The source or readonly source to derive from.
|
|
42
|
+
* Values emitted by this source are passed to the computation function.
|
|
43
|
+
*
|
|
44
|
+
* @param computedFn - Function that transforms source values to computed values.
|
|
45
|
+
* Called each time the origin source emits.
|
|
46
|
+
*
|
|
47
|
+
* @param options - Optional configuration:
|
|
48
|
+
* - `equal`: Custom equality function for computed values
|
|
49
|
+
* - `debugName`: Name for debugging purposes
|
|
50
|
+
*
|
|
51
|
+
* @returns A readonly source that emits computed values with:
|
|
52
|
+
* - Standard behavior: First read returns `undefined`, subsequent reads return computed value after source emits
|
|
53
|
+
* - `preserveLastValue` property: Returns computed value immediately on first read if source has emitted
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* Basic transformation of source data
|
|
57
|
+
* ```ts
|
|
58
|
+
* const userSource = source<{ firstName: string; lastName: string }>();
|
|
59
|
+
*
|
|
60
|
+
* // Compute full name from user data
|
|
61
|
+
* const fullNameSource = computedSource(
|
|
62
|
+
* userSource,
|
|
63
|
+
* (user) => `${user.firstName} ${user.lastName}`
|
|
64
|
+
* );
|
|
65
|
+
*
|
|
66
|
+
* // Use in async method or query
|
|
67
|
+
* const greetUser = craftUse(asyncProcess({
|
|
68
|
+
* method: afterRecomputation(fullNameSource, (fullName) => fullName),
|
|
69
|
+
* loader: async ({ params }) => {
|
|
70
|
+
* return `Hello, ${params}!`;
|
|
71
|
+
* },
|
|
72
|
+
* }));
|
|
73
|
+
*
|
|
74
|
+
* // Trigger chain
|
|
75
|
+
* userSource.set({ firstName: 'John', lastName: 'Doe' });
|
|
76
|
+
* // -> fullNameSource emits 'John Doe'
|
|
77
|
+
* // -> greetUser executes with 'John Doe'
|
|
78
|
+
* ```
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* Extracting specific fields from complex data
|
|
82
|
+
* ```ts
|
|
83
|
+
* type FormData = {
|
|
84
|
+
* personal: { name: string; email: string };
|
|
85
|
+
* address: { street: string; city: string };
|
|
86
|
+
* preferences: { newsletter: boolean };
|
|
87
|
+
* };
|
|
88
|
+
*
|
|
89
|
+
* const formSource = source<FormData>();
|
|
90
|
+
*
|
|
91
|
+
* // Extract only email for validation
|
|
92
|
+
* const emailSource = computedSource(
|
|
93
|
+
* formSource,
|
|
94
|
+
* (form) => form.personal.email
|
|
95
|
+
* );
|
|
96
|
+
*
|
|
97
|
+
* // Extract only address for geocoding
|
|
98
|
+
* const addressSource = computedSource(
|
|
99
|
+
* formSource,
|
|
100
|
+
* (form) => form.address
|
|
101
|
+
* );
|
|
102
|
+
*
|
|
103
|
+
* // Use extracted sources
|
|
104
|
+
* const validateEmail = craftUse(asyncProcess({
|
|
105
|
+
* method: afterRecomputation(emailSource, (email) => email),
|
|
106
|
+
* loader: async ({ params }) => {
|
|
107
|
+
* const response = await fetch('/api/validate-email', {
|
|
108
|
+
* method: 'POST',
|
|
109
|
+
* body: JSON.stringify({ email: params }),
|
|
110
|
+
* });
|
|
111
|
+
* return response.json();
|
|
112
|
+
* },
|
|
113
|
+
* }));
|
|
114
|
+
*
|
|
115
|
+
* // Update form triggers both validations
|
|
116
|
+
* formSource.set({
|
|
117
|
+
* personal: { name: 'John', email: 'john@example.com' },
|
|
118
|
+
* address: { street: '123 Main St', city: 'NYC' },
|
|
119
|
+
* preferences: { newsletter: true },
|
|
120
|
+
* });
|
|
121
|
+
* ```
|
|
122
|
+
*
|
|
123
|
+
* @example
|
|
124
|
+
* Chaining computed sources for multi-step transformation
|
|
125
|
+
* ```ts
|
|
126
|
+
* const inputSource = source<string>();
|
|
127
|
+
*
|
|
128
|
+
* // Step 1: Trim and lowercase
|
|
129
|
+
* const normalizedSource = computedSource(
|
|
130
|
+
* inputSource,
|
|
131
|
+
* (input) => input.trim().toLowerCase()
|
|
132
|
+
* );
|
|
133
|
+
*
|
|
134
|
+
* // Step 2: Extract search terms
|
|
135
|
+
* const searchTermsSource = computedSource(
|
|
136
|
+
* normalizedSource,
|
|
137
|
+
* (normalized) => normalized.split(' ').filter(term => term.length > 0)
|
|
138
|
+
* );
|
|
139
|
+
*
|
|
140
|
+
* // Step 3: Create search query
|
|
141
|
+
* const searchQuerySource = computedSource(
|
|
142
|
+
* searchTermsSource,
|
|
143
|
+
* (terms) => ({ terms, operator: 'AND' as const })
|
|
144
|
+
* );
|
|
145
|
+
*
|
|
146
|
+
* // Final async method uses fully transformed data
|
|
147
|
+
* const search = craftUse(asyncProcess({
|
|
148
|
+
* method: afterRecomputation(searchQuerySource, (query) => query),
|
|
149
|
+
* loader: async ({ params }) => {
|
|
150
|
+
* const response = await fetch('/api/search', {
|
|
151
|
+
* method: 'POST',
|
|
152
|
+
* body: JSON.stringify(params),
|
|
153
|
+
* });
|
|
154
|
+
* return response.json();
|
|
155
|
+
* },
|
|
156
|
+
* }));
|
|
157
|
+
*
|
|
158
|
+
* // Single input triggers entire chain
|
|
159
|
+
* inputSource.set(' Angular Signals ');
|
|
160
|
+
* // -> normalizedSource emits 'angular signals'
|
|
161
|
+
* // -> searchTermsSource emits ['angular', 'signals']
|
|
162
|
+
* // -> searchQuerySource emits { terms: ['angular', 'signals'], operator: 'AND' }
|
|
163
|
+
* // -> search executes
|
|
164
|
+
* ```
|
|
165
|
+
*
|
|
166
|
+
* @example
|
|
167
|
+
* Custom equality comparison
|
|
168
|
+
* ```ts
|
|
169
|
+
* type SearchParams = { query: string; timestamp: number };
|
|
170
|
+
*
|
|
171
|
+
* const searchSource = source<SearchParams>();
|
|
172
|
+
*
|
|
173
|
+
* // Only emit when query changes, ignore timestamp
|
|
174
|
+
* const queryOnlySource = computedSource(
|
|
175
|
+
* searchSource,
|
|
176
|
+
* (params) => params.query,
|
|
177
|
+
* {
|
|
178
|
+
* equal: (a, b) => a === b, // Compare strings
|
|
179
|
+
* }
|
|
180
|
+
* );
|
|
181
|
+
*
|
|
182
|
+
* // Update with same query but different timestamp
|
|
183
|
+
* searchSource.set({ query: 'test', timestamp: Date.now() });
|
|
184
|
+
* // -> queryOnlySource emits 'test'
|
|
185
|
+
*
|
|
186
|
+
* searchSource.set({ query: 'test', timestamp: Date.now() });
|
|
187
|
+
* // -> queryOnlySource does NOT emit (same query)
|
|
188
|
+
*
|
|
189
|
+
* searchSource.set({ query: 'new', timestamp: Date.now() });
|
|
190
|
+
* // -> queryOnlySource emits 'new'
|
|
191
|
+
* ```
|
|
192
|
+
*
|
|
193
|
+
* @example
|
|
194
|
+
* Type narrowing and validation
|
|
195
|
+
* ```ts
|
|
196
|
+
* type ApiResponse =
|
|
197
|
+
* | { type: 'success'; data: unknown }
|
|
198
|
+
* | { type: 'error'; message: string };
|
|
199
|
+
*
|
|
200
|
+
* const responseSource = source<ApiResponse>();
|
|
201
|
+
*
|
|
202
|
+
* // Extract only successful data
|
|
203
|
+
* const successDataSource = computedSource(
|
|
204
|
+
* responseSource,
|
|
205
|
+
* (response) => {
|
|
206
|
+
* if (response.type === 'success') {
|
|
207
|
+
* return response.data;
|
|
208
|
+
* }
|
|
209
|
+
* return null;
|
|
210
|
+
* }
|
|
211
|
+
* );
|
|
212
|
+
*
|
|
213
|
+
* // Extract only errors
|
|
214
|
+
* const errorSource = computedSource(
|
|
215
|
+
* responseSource,
|
|
216
|
+
* (response) => {
|
|
217
|
+
* if (response.type === 'error') {
|
|
218
|
+
* return response.message;
|
|
219
|
+
* }
|
|
220
|
+
* return null;
|
|
221
|
+
* }
|
|
222
|
+
* );
|
|
223
|
+
*
|
|
224
|
+
* // Handle success and errors separately
|
|
225
|
+
* const Processuccess = craftUse(asyncProcess({
|
|
226
|
+
* method: afterRecomputation(successDataSource, (data) => data),
|
|
227
|
+
* loader: async ({ params }) => {
|
|
228
|
+
* if (!params) return null;
|
|
229
|
+
* // Process successful data
|
|
230
|
+
* return processData(params);
|
|
231
|
+
* },
|
|
232
|
+
* }));
|
|
233
|
+
*
|
|
234
|
+
* const logError = craftUse(asyncProcess({
|
|
235
|
+
* method: afterRecomputation(errorSource, (error) => error),
|
|
236
|
+
* loader: async ({ params }) => {
|
|
237
|
+
* if (!params) return null;
|
|
238
|
+
* // Log error
|
|
239
|
+
* await logToService(params);
|
|
240
|
+
* return { logged: true };
|
|
241
|
+
* },
|
|
242
|
+
* }));
|
|
243
|
+
* ```
|
|
244
|
+
*
|
|
245
|
+
* @example
|
|
246
|
+
* Formatting and presentation logic
|
|
247
|
+
* ```ts
|
|
248
|
+
* type Price = { amount: number; currency: string };
|
|
249
|
+
*
|
|
250
|
+
* const priceSource = source<Price>();
|
|
251
|
+
*
|
|
252
|
+
* // Format price for display
|
|
253
|
+
* const formattedPriceSource = computedSource(
|
|
254
|
+
* priceSource,
|
|
255
|
+
* (price) => {
|
|
256
|
+
* const formatter = new Intl.NumberFormat('en-US', {
|
|
257
|
+
* style: 'currency',
|
|
258
|
+
* currency: price.currency,
|
|
259
|
+
* });
|
|
260
|
+
* return formatter.format(price.amount);
|
|
261
|
+
* }
|
|
262
|
+
* );
|
|
263
|
+
*
|
|
264
|
+
* // Use formatted value in UI updates
|
|
265
|
+
* const updatePriceDisplay = craftUse(asyncProcess({
|
|
266
|
+
* method: afterRecomputation(formattedPriceSource, (formatted) => formatted),
|
|
267
|
+
* loader: async ({ params }) => {
|
|
268
|
+
* // Update analytics or external service
|
|
269
|
+
* await trackPriceView(params);
|
|
270
|
+
* return { displayed: params };
|
|
271
|
+
* },
|
|
272
|
+
* }));
|
|
273
|
+
*
|
|
274
|
+
* priceSource.set({ amount: 1234.56, currency: 'USD' });
|
|
275
|
+
* // -> formattedPriceSource emits '$1,234.56'
|
|
276
|
+
* ```
|
|
277
|
+
*
|
|
278
|
+
* @example
|
|
279
|
+
* Using preserveLastValue for immediate computed access
|
|
280
|
+
* ```ts
|
|
281
|
+
* const counterSource = source<number>();
|
|
282
|
+
*
|
|
283
|
+
* const doubledSource = computedSource(
|
|
284
|
+
* counterSource,
|
|
285
|
+
* (count) => count * 2
|
|
286
|
+
* );
|
|
287
|
+
*
|
|
288
|
+
* // Standard behavior
|
|
289
|
+
* console.log(doubledSource()); // undefined (no emission yet)
|
|
290
|
+
*
|
|
291
|
+
* counterSource.set(5);
|
|
292
|
+
* console.log(doubledSource()); // 10
|
|
293
|
+
*
|
|
294
|
+
* // Using preserveLastValue
|
|
295
|
+
* const immediateDoubled = doubledSource.preserveLastValue;
|
|
296
|
+
* console.log(immediateDoubled()); // 10 (gets last computed value immediately)
|
|
297
|
+
* ```
|
|
298
|
+
*/
|
|
299
|
+
export declare function computedSource<SourceState, ComputedValue>(signalOrigin: SignalSource<SourceState> | ReadonlySource<SourceState>, computedFn: (sourceValue: NoInfer<SourceState>) => ComputedValue, options?: {
|
|
300
|
+
equal?: ValueEqualityFn<NoInfer<ComputedValue> | undefined>;
|
|
301
|
+
debugName?: string;
|
|
302
|
+
}): ReadonlySource<ComputedValue>;
|
|
303
|
+
//# sourceMappingURL=computed-source.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"computed-source.d.ts","sourceRoot":"","sources":["../../../../../libs/core/src/lib/computed-source.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAG/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsSG;AACH,wBAAgB,cAAc,CAAC,WAAW,EAAE,aAAa,EACvD,YAAY,EAAE,YAAY,CAAC,WAAW,CAAC,GAAG,cAAc,CAAC,WAAW,CAAC,EACrE,UAAU,EAAE,CAAC,WAAW,EAAE,OAAO,CAAC,WAAW,CAAC,KAAK,aAAa,EAChE,OAAO,CAAC,EAAE;IACR,KAAK,CAAC,EAAE,eAAe,CAAC,OAAO,CAAC,aAAa,CAAC,GAAG,SAAS,CAAC,CAAC;IAC5D,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GACA,cAAc,CAAC,aAAa,CAAC,CA0B/B"}
|
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
import { linkedSignal } from './host/craft-compat';
|
|
2
|
+
import { SourceBranded } from './util/util';
|
|
3
|
+
/**
|
|
4
|
+
* Creates a derived readonly source that transforms values from an origin source using a computation function.
|
|
5
|
+
*
|
|
6
|
+
* This function enables reactive transformations of source emissions by:
|
|
7
|
+
* - Computing new values whenever the origin source emits
|
|
8
|
+
* - Maintaining source semantics (emits only when explicitly set, not on first read)
|
|
9
|
+
* - Supporting custom equality comparisons for memoization
|
|
10
|
+
* - Providing both standard and value-preserving listeners
|
|
11
|
+
* - Creating composable source pipelines
|
|
12
|
+
*
|
|
13
|
+
* @remarks
|
|
14
|
+
* **Emission Behavior:**
|
|
15
|
+
* - Only emits when the origin source emits (explicit set/update)
|
|
16
|
+
* - First read returns `undefined` by default (maintains source semantics)
|
|
17
|
+
* - Use `preserveLastValue` variant to get computed value on first read
|
|
18
|
+
*
|
|
19
|
+
* **Use Cases:**
|
|
20
|
+
* - **Data transformation**: Convert source payloads to different shapes
|
|
21
|
+
* - **Filtering**: Extract specific fields from complex source data
|
|
22
|
+
* - **Formatting**: Apply formatting logic to source values
|
|
23
|
+
* - **Type narrowing**: Cast or validate source data types
|
|
24
|
+
* - **Composition**: Chain multiple source transformations
|
|
25
|
+
* - **Business logic**: Apply domain-specific computations
|
|
26
|
+
*
|
|
27
|
+
* **Source vs Signal:**
|
|
28
|
+
* - Sources emit only on explicit events (set/update calls)
|
|
29
|
+
* - Signals recompute on every access when dependencies change
|
|
30
|
+
* - computedSource maintains source lazy behavior
|
|
31
|
+
*
|
|
32
|
+
* **Equality Comparison:**
|
|
33
|
+
* - Default: Uses Angular's default equality check
|
|
34
|
+
* - Custom: Provide `equal` option for custom comparison
|
|
35
|
+
* - Prevents unnecessary emissions when computed value hasn't changed
|
|
36
|
+
*
|
|
37
|
+
* @template SourceState - The type of values emitted by the origin source
|
|
38
|
+
* @template ComputedValue - The type of values produced by the computation
|
|
39
|
+
*
|
|
40
|
+
* @param signalOrigin - The source or readonly source to derive from.
|
|
41
|
+
* Values emitted by this source are passed to the computation function.
|
|
42
|
+
*
|
|
43
|
+
* @param computedFn - Function that transforms source values to computed values.
|
|
44
|
+
* Called each time the origin source emits.
|
|
45
|
+
*
|
|
46
|
+
* @param options - Optional configuration:
|
|
47
|
+
* - `equal`: Custom equality function for computed values
|
|
48
|
+
* - `debugName`: Name for debugging purposes
|
|
49
|
+
*
|
|
50
|
+
* @returns A readonly source that emits computed values with:
|
|
51
|
+
* - Standard behavior: First read returns `undefined`, subsequent reads return computed value after source emits
|
|
52
|
+
* - `preserveLastValue` property: Returns computed value immediately on first read if source has emitted
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* Basic transformation of source data
|
|
56
|
+
* ```ts
|
|
57
|
+
* const userSource = source<{ firstName: string; lastName: string }>();
|
|
58
|
+
*
|
|
59
|
+
* // Compute full name from user data
|
|
60
|
+
* const fullNameSource = computedSource(
|
|
61
|
+
* userSource,
|
|
62
|
+
* (user) => `${user.firstName} ${user.lastName}`
|
|
63
|
+
* );
|
|
64
|
+
*
|
|
65
|
+
* // Use in async method or query
|
|
66
|
+
* const greetUser = craftUse(asyncProcess({
|
|
67
|
+
* method: afterRecomputation(fullNameSource, (fullName) => fullName),
|
|
68
|
+
* loader: async ({ params }) => {
|
|
69
|
+
* return `Hello, ${params}!`;
|
|
70
|
+
* },
|
|
71
|
+
* }));
|
|
72
|
+
*
|
|
73
|
+
* // Trigger chain
|
|
74
|
+
* userSource.set({ firstName: 'John', lastName: 'Doe' });
|
|
75
|
+
* // -> fullNameSource emits 'John Doe'
|
|
76
|
+
* // -> greetUser executes with 'John Doe'
|
|
77
|
+
* ```
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* Extracting specific fields from complex data
|
|
81
|
+
* ```ts
|
|
82
|
+
* type FormData = {
|
|
83
|
+
* personal: { name: string; email: string };
|
|
84
|
+
* address: { street: string; city: string };
|
|
85
|
+
* preferences: { newsletter: boolean };
|
|
86
|
+
* };
|
|
87
|
+
*
|
|
88
|
+
* const formSource = source<FormData>();
|
|
89
|
+
*
|
|
90
|
+
* // Extract only email for validation
|
|
91
|
+
* const emailSource = computedSource(
|
|
92
|
+
* formSource,
|
|
93
|
+
* (form) => form.personal.email
|
|
94
|
+
* );
|
|
95
|
+
*
|
|
96
|
+
* // Extract only address for geocoding
|
|
97
|
+
* const addressSource = computedSource(
|
|
98
|
+
* formSource,
|
|
99
|
+
* (form) => form.address
|
|
100
|
+
* );
|
|
101
|
+
*
|
|
102
|
+
* // Use extracted sources
|
|
103
|
+
* const validateEmail = craftUse(asyncProcess({
|
|
104
|
+
* method: afterRecomputation(emailSource, (email) => email),
|
|
105
|
+
* loader: async ({ params }) => {
|
|
106
|
+
* const response = await fetch('/api/validate-email', {
|
|
107
|
+
* method: 'POST',
|
|
108
|
+
* body: JSON.stringify({ email: params }),
|
|
109
|
+
* });
|
|
110
|
+
* return response.json();
|
|
111
|
+
* },
|
|
112
|
+
* }));
|
|
113
|
+
*
|
|
114
|
+
* // Update form triggers both validations
|
|
115
|
+
* formSource.set({
|
|
116
|
+
* personal: { name: 'John', email: 'john@example.com' },
|
|
117
|
+
* address: { street: '123 Main St', city: 'NYC' },
|
|
118
|
+
* preferences: { newsletter: true },
|
|
119
|
+
* });
|
|
120
|
+
* ```
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* Chaining computed sources for multi-step transformation
|
|
124
|
+
* ```ts
|
|
125
|
+
* const inputSource = source<string>();
|
|
126
|
+
*
|
|
127
|
+
* // Step 1: Trim and lowercase
|
|
128
|
+
* const normalizedSource = computedSource(
|
|
129
|
+
* inputSource,
|
|
130
|
+
* (input) => input.trim().toLowerCase()
|
|
131
|
+
* );
|
|
132
|
+
*
|
|
133
|
+
* // Step 2: Extract search terms
|
|
134
|
+
* const searchTermsSource = computedSource(
|
|
135
|
+
* normalizedSource,
|
|
136
|
+
* (normalized) => normalized.split(' ').filter(term => term.length > 0)
|
|
137
|
+
* );
|
|
138
|
+
*
|
|
139
|
+
* // Step 3: Create search query
|
|
140
|
+
* const searchQuerySource = computedSource(
|
|
141
|
+
* searchTermsSource,
|
|
142
|
+
* (terms) => ({ terms, operator: 'AND' as const })
|
|
143
|
+
* );
|
|
144
|
+
*
|
|
145
|
+
* // Final async method uses fully transformed data
|
|
146
|
+
* const search = craftUse(asyncProcess({
|
|
147
|
+
* method: afterRecomputation(searchQuerySource, (query) => query),
|
|
148
|
+
* loader: async ({ params }) => {
|
|
149
|
+
* const response = await fetch('/api/search', {
|
|
150
|
+
* method: 'POST',
|
|
151
|
+
* body: JSON.stringify(params),
|
|
152
|
+
* });
|
|
153
|
+
* return response.json();
|
|
154
|
+
* },
|
|
155
|
+
* }));
|
|
156
|
+
*
|
|
157
|
+
* // Single input triggers entire chain
|
|
158
|
+
* inputSource.set(' Angular Signals ');
|
|
159
|
+
* // -> normalizedSource emits 'angular signals'
|
|
160
|
+
* // -> searchTermsSource emits ['angular', 'signals']
|
|
161
|
+
* // -> searchQuerySource emits { terms: ['angular', 'signals'], operator: 'AND' }
|
|
162
|
+
* // -> search executes
|
|
163
|
+
* ```
|
|
164
|
+
*
|
|
165
|
+
* @example
|
|
166
|
+
* Custom equality comparison
|
|
167
|
+
* ```ts
|
|
168
|
+
* type SearchParams = { query: string; timestamp: number };
|
|
169
|
+
*
|
|
170
|
+
* const searchSource = source<SearchParams>();
|
|
171
|
+
*
|
|
172
|
+
* // Only emit when query changes, ignore timestamp
|
|
173
|
+
* const queryOnlySource = computedSource(
|
|
174
|
+
* searchSource,
|
|
175
|
+
* (params) => params.query,
|
|
176
|
+
* {
|
|
177
|
+
* equal: (a, b) => a === b, // Compare strings
|
|
178
|
+
* }
|
|
179
|
+
* );
|
|
180
|
+
*
|
|
181
|
+
* // Update with same query but different timestamp
|
|
182
|
+
* searchSource.set({ query: 'test', timestamp: Date.now() });
|
|
183
|
+
* // -> queryOnlySource emits 'test'
|
|
184
|
+
*
|
|
185
|
+
* searchSource.set({ query: 'test', timestamp: Date.now() });
|
|
186
|
+
* // -> queryOnlySource does NOT emit (same query)
|
|
187
|
+
*
|
|
188
|
+
* searchSource.set({ query: 'new', timestamp: Date.now() });
|
|
189
|
+
* // -> queryOnlySource emits 'new'
|
|
190
|
+
* ```
|
|
191
|
+
*
|
|
192
|
+
* @example
|
|
193
|
+
* Type narrowing and validation
|
|
194
|
+
* ```ts
|
|
195
|
+
* type ApiResponse =
|
|
196
|
+
* | { type: 'success'; data: unknown }
|
|
197
|
+
* | { type: 'error'; message: string };
|
|
198
|
+
*
|
|
199
|
+
* const responseSource = source<ApiResponse>();
|
|
200
|
+
*
|
|
201
|
+
* // Extract only successful data
|
|
202
|
+
* const successDataSource = computedSource(
|
|
203
|
+
* responseSource,
|
|
204
|
+
* (response) => {
|
|
205
|
+
* if (response.type === 'success') {
|
|
206
|
+
* return response.data;
|
|
207
|
+
* }
|
|
208
|
+
* return null;
|
|
209
|
+
* }
|
|
210
|
+
* );
|
|
211
|
+
*
|
|
212
|
+
* // Extract only errors
|
|
213
|
+
* const errorSource = computedSource(
|
|
214
|
+
* responseSource,
|
|
215
|
+
* (response) => {
|
|
216
|
+
* if (response.type === 'error') {
|
|
217
|
+
* return response.message;
|
|
218
|
+
* }
|
|
219
|
+
* return null;
|
|
220
|
+
* }
|
|
221
|
+
* );
|
|
222
|
+
*
|
|
223
|
+
* // Handle success and errors separately
|
|
224
|
+
* const Processuccess = craftUse(asyncProcess({
|
|
225
|
+
* method: afterRecomputation(successDataSource, (data) => data),
|
|
226
|
+
* loader: async ({ params }) => {
|
|
227
|
+
* if (!params) return null;
|
|
228
|
+
* // Process successful data
|
|
229
|
+
* return processData(params);
|
|
230
|
+
* },
|
|
231
|
+
* }));
|
|
232
|
+
*
|
|
233
|
+
* const logError = craftUse(asyncProcess({
|
|
234
|
+
* method: afterRecomputation(errorSource, (error) => error),
|
|
235
|
+
* loader: async ({ params }) => {
|
|
236
|
+
* if (!params) return null;
|
|
237
|
+
* // Log error
|
|
238
|
+
* await logToService(params);
|
|
239
|
+
* return { logged: true };
|
|
240
|
+
* },
|
|
241
|
+
* }));
|
|
242
|
+
* ```
|
|
243
|
+
*
|
|
244
|
+
* @example
|
|
245
|
+
* Formatting and presentation logic
|
|
246
|
+
* ```ts
|
|
247
|
+
* type Price = { amount: number; currency: string };
|
|
248
|
+
*
|
|
249
|
+
* const priceSource = source<Price>();
|
|
250
|
+
*
|
|
251
|
+
* // Format price for display
|
|
252
|
+
* const formattedPriceSource = computedSource(
|
|
253
|
+
* priceSource,
|
|
254
|
+
* (price) => {
|
|
255
|
+
* const formatter = new Intl.NumberFormat('en-US', {
|
|
256
|
+
* style: 'currency',
|
|
257
|
+
* currency: price.currency,
|
|
258
|
+
* });
|
|
259
|
+
* return formatter.format(price.amount);
|
|
260
|
+
* }
|
|
261
|
+
* );
|
|
262
|
+
*
|
|
263
|
+
* // Use formatted value in UI updates
|
|
264
|
+
* const updatePriceDisplay = craftUse(asyncProcess({
|
|
265
|
+
* method: afterRecomputation(formattedPriceSource, (formatted) => formatted),
|
|
266
|
+
* loader: async ({ params }) => {
|
|
267
|
+
* // Update analytics or external service
|
|
268
|
+
* await trackPriceView(params);
|
|
269
|
+
* return { displayed: params };
|
|
270
|
+
* },
|
|
271
|
+
* }));
|
|
272
|
+
*
|
|
273
|
+
* priceSource.set({ amount: 1234.56, currency: 'USD' });
|
|
274
|
+
* // -> formattedPriceSource emits '$1,234.56'
|
|
275
|
+
* ```
|
|
276
|
+
*
|
|
277
|
+
* @example
|
|
278
|
+
* Using preserveLastValue for immediate computed access
|
|
279
|
+
* ```ts
|
|
280
|
+
* const counterSource = source<number>();
|
|
281
|
+
*
|
|
282
|
+
* const doubledSource = computedSource(
|
|
283
|
+
* counterSource,
|
|
284
|
+
* (count) => count * 2
|
|
285
|
+
* );
|
|
286
|
+
*
|
|
287
|
+
* // Standard behavior
|
|
288
|
+
* console.log(doubledSource()); // undefined (no emission yet)
|
|
289
|
+
*
|
|
290
|
+
* counterSource.set(5);
|
|
291
|
+
* console.log(doubledSource()); // 10
|
|
292
|
+
*
|
|
293
|
+
* // Using preserveLastValue
|
|
294
|
+
* const immediateDoubled = doubledSource.preserveLastValue;
|
|
295
|
+
* console.log(immediateDoubled()); // 10 (gets last computed value immediately)
|
|
296
|
+
* ```
|
|
297
|
+
*/
|
|
298
|
+
export function computedSource(signalOrigin, computedFn, options) {
|
|
299
|
+
const listener = (listenerOptions) => linkedSignal({
|
|
300
|
+
source: signalOrigin,
|
|
301
|
+
computation: (currentSourceState, previousData) => {
|
|
302
|
+
// always when first listened return undefined
|
|
303
|
+
if (!previousData && listenerOptions?.nullishFirstValue !== false) {
|
|
304
|
+
return undefined;
|
|
305
|
+
}
|
|
306
|
+
return computedFn(currentSourceState);
|
|
307
|
+
},
|
|
308
|
+
...(options?.equal && { equal: options?.equal }),
|
|
309
|
+
...(options?.debugName && { debugName: options?.debugName }),
|
|
310
|
+
});
|
|
311
|
+
return Object.assign(listener({
|
|
312
|
+
nullishFirstValue: true,
|
|
313
|
+
}), {
|
|
314
|
+
preserveLastValue: listener({
|
|
315
|
+
nullishFirstValue: false,
|
|
316
|
+
}),
|
|
317
|
+
}, SourceBranded);
|
|
318
|
+
}
|
|
319
|
+
//# sourceMappingURL=computed-source.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"computed-source.js","sourceRoot":"","sources":["../../../../../libs/core/src/lib/computed-source.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAA2B,MAAM,qBAAqB,CAAC;AAG5E,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsSG;AACH,MAAM,UAAU,cAAc,CAC5B,YAAqE,EACrE,UAAgE,EAChE,OAGC;IAED,MAAM,QAAQ,GAAG,CAAC,eAAgD,EAAE,EAAE,CACpE,YAAY,CAAyC;QACnD,MAAM,EAAE,YAAmC;QAC3C,WAAW,EAAE,CAAC,kBAAkB,EAAE,YAAY,EAAE,EAAE;YAChD,8CAA8C;YAC9C,IAAI,CAAC,YAAY,IAAI,eAAe,EAAE,iBAAiB,KAAK,KAAK,EAAE,CAAC;gBAClE,OAAO,SAAS,CAAC;YACnB,CAAC;YAED,OAAO,UAAU,CAAC,kBAAkB,CAAC,CAAC;QACxC,CAAC;QACD,GAAG,CAAC,OAAO,EAAE,KAAK,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;QAChD,GAAG,CAAC,OAAO,EAAE,SAAS,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;KAC7D,CAAC,CAAC;IACL,OAAO,MAAM,CAAC,MAAM,CAClB,QAAQ,CAAC;QACP,iBAAiB,EAAE,IAAI;KACxB,CAAC,EACF;QACE,iBAAiB,EAAE,QAAQ,CAAC;YAC1B,iBAAiB,EAAE,KAAK;SACzB,CAAC;KACH,EACD,aAAa,CACS,CAAC;AAC3B,CAAC","sourcesContent":["import { linkedSignal, Signal, ValueEqualityFn } from './host/craft-compat';\nimport { ReadonlySource } from './util/source.type';\nimport { SignalSource } from './signal-source';\nimport { SourceBranded } from './util/util';\n\n/**\n * Creates a derived readonly source that transforms values from an origin source using a computation function.\n *\n * This function enables reactive transformations of source emissions by:\n * - Computing new values whenever the origin source emits\n * - Maintaining source semantics (emits only when explicitly set, not on first read)\n * - Supporting custom equality comparisons for memoization\n * - Providing both standard and value-preserving listeners\n * - Creating composable source pipelines\n *\n * @remarks\n * **Emission Behavior:**\n * - Only emits when the origin source emits (explicit set/update)\n * - First read returns `undefined` by default (maintains source semantics)\n * - Use `preserveLastValue` variant to get computed value on first read\n *\n * **Use Cases:**\n * - **Data transformation**: Convert source payloads to different shapes\n * - **Filtering**: Extract specific fields from complex source data\n * - **Formatting**: Apply formatting logic to source values\n * - **Type narrowing**: Cast or validate source data types\n * - **Composition**: Chain multiple source transformations\n * - **Business logic**: Apply domain-specific computations\n *\n * **Source vs Signal:**\n * - Sources emit only on explicit events (set/update calls)\n * - Signals recompute on every access when dependencies change\n * - computedSource maintains source lazy behavior\n *\n * **Equality Comparison:**\n * - Default: Uses Angular's default equality check\n * - Custom: Provide `equal` option for custom comparison\n * - Prevents unnecessary emissions when computed value hasn't changed\n *\n * @template SourceState - The type of values emitted by the origin source\n * @template ComputedValue - The type of values produced by the computation\n *\n * @param signalOrigin - The source or readonly source to derive from.\n * Values emitted by this source are passed to the computation function.\n *\n * @param computedFn - Function that transforms source values to computed values.\n * Called each time the origin source emits.\n *\n * @param options - Optional configuration:\n * - `equal`: Custom equality function for computed values\n * - `debugName`: Name for debugging purposes\n *\n * @returns A readonly source that emits computed values with:\n * - Standard behavior: First read returns `undefined`, subsequent reads return computed value after source emits\n * - `preserveLastValue` property: Returns computed value immediately on first read if source has emitted\n *\n * @example\n * Basic transformation of source data\n * ```ts\n * const userSource = source<{ firstName: string; lastName: string }>();\n *\n * // Compute full name from user data\n * const fullNameSource = computedSource(\n * userSource,\n * (user) => `${user.firstName} ${user.lastName}`\n * );\n *\n * // Use in async method or query\n * const greetUser = craftUse(asyncProcess({\n * method: afterRecomputation(fullNameSource, (fullName) => fullName),\n * loader: async ({ params }) => {\n * return `Hello, ${params}!`;\n * },\n * }));\n *\n * // Trigger chain\n * userSource.set({ firstName: 'John', lastName: 'Doe' });\n * // -> fullNameSource emits 'John Doe'\n * // -> greetUser executes with 'John Doe'\n * ```\n *\n * @example\n * Extracting specific fields from complex data\n * ```ts\n * type FormData = {\n * personal: { name: string; email: string };\n * address: { street: string; city: string };\n * preferences: { newsletter: boolean };\n * };\n *\n * const formSource = source<FormData>();\n *\n * // Extract only email for validation\n * const emailSource = computedSource(\n * formSource,\n * (form) => form.personal.email\n * );\n *\n * // Extract only address for geocoding\n * const addressSource = computedSource(\n * formSource,\n * (form) => form.address\n * );\n *\n * // Use extracted sources\n * const validateEmail = craftUse(asyncProcess({\n * method: afterRecomputation(emailSource, (email) => email),\n * loader: async ({ params }) => {\n * const response = await fetch('/api/validate-email', {\n * method: 'POST',\n * body: JSON.stringify({ email: params }),\n * });\n * return response.json();\n * },\n * }));\n *\n * // Update form triggers both validations\n * formSource.set({\n * personal: { name: 'John', email: 'john@example.com' },\n * address: { street: '123 Main St', city: 'NYC' },\n * preferences: { newsletter: true },\n * });\n * ```\n *\n * @example\n * Chaining computed sources for multi-step transformation\n * ```ts\n * const inputSource = source<string>();\n *\n * // Step 1: Trim and lowercase\n * const normalizedSource = computedSource(\n * inputSource,\n * (input) => input.trim().toLowerCase()\n * );\n *\n * // Step 2: Extract search terms\n * const searchTermsSource = computedSource(\n * normalizedSource,\n * (normalized) => normalized.split(' ').filter(term => term.length > 0)\n * );\n *\n * // Step 3: Create search query\n * const searchQuerySource = computedSource(\n * searchTermsSource,\n * (terms) => ({ terms, operator: 'AND' as const })\n * );\n *\n * // Final async method uses fully transformed data\n * const search = craftUse(asyncProcess({\n * method: afterRecomputation(searchQuerySource, (query) => query),\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 * // Single input triggers entire chain\n * inputSource.set(' Angular Signals ');\n * // -> normalizedSource emits 'angular signals'\n * // -> searchTermsSource emits ['angular', 'signals']\n * // -> searchQuerySource emits { terms: ['angular', 'signals'], operator: 'AND' }\n * // -> search executes\n * ```\n *\n * @example\n * Custom equality comparison\n * ```ts\n * type SearchParams = { query: string; timestamp: number };\n *\n * const searchSource = source<SearchParams>();\n *\n * // Only emit when query changes, ignore timestamp\n * const queryOnlySource = computedSource(\n * searchSource,\n * (params) => params.query,\n * {\n * equal: (a, b) => a === b, // Compare strings\n * }\n * );\n *\n * // Update with same query but different timestamp\n * searchSource.set({ query: 'test', timestamp: Date.now() });\n * // -> queryOnlySource emits 'test'\n *\n * searchSource.set({ query: 'test', timestamp: Date.now() });\n * // -> queryOnlySource does NOT emit (same query)\n *\n * searchSource.set({ query: 'new', timestamp: Date.now() });\n * // -> queryOnlySource emits 'new'\n * ```\n *\n * @example\n * Type narrowing and validation\n * ```ts\n * type ApiResponse =\n * | { type: 'success'; data: unknown }\n * | { type: 'error'; message: string };\n *\n * const responseSource = source<ApiResponse>();\n *\n * // Extract only successful data\n * const successDataSource = computedSource(\n * responseSource,\n * (response) => {\n * if (response.type === 'success') {\n * return response.data;\n * }\n * return null;\n * }\n * );\n *\n * // Extract only errors\n * const errorSource = computedSource(\n * responseSource,\n * (response) => {\n * if (response.type === 'error') {\n * return response.message;\n * }\n * return null;\n * }\n * );\n *\n * // Handle success and errors separately\n * const Processuccess = craftUse(asyncProcess({\n * method: afterRecomputation(successDataSource, (data) => data),\n * loader: async ({ params }) => {\n * if (!params) return null;\n * // Process successful data\n * return processData(params);\n * },\n * }));\n *\n * const logError = craftUse(asyncProcess({\n * method: afterRecomputation(errorSource, (error) => error),\n * loader: async ({ params }) => {\n * if (!params) return null;\n * // Log error\n * await logToService(params);\n * return { logged: true };\n * },\n * }));\n * ```\n *\n * @example\n * Formatting and presentation logic\n * ```ts\n * type Price = { amount: number; currency: string };\n *\n * const priceSource = source<Price>();\n *\n * // Format price for display\n * const formattedPriceSource = computedSource(\n * priceSource,\n * (price) => {\n * const formatter = new Intl.NumberFormat('en-US', {\n * style: 'currency',\n * currency: price.currency,\n * });\n * return formatter.format(price.amount);\n * }\n * );\n *\n * // Use formatted value in UI updates\n * const updatePriceDisplay = craftUse(asyncProcess({\n * method: afterRecomputation(formattedPriceSource, (formatted) => formatted),\n * loader: async ({ params }) => {\n * // Update analytics or external service\n * await trackPriceView(params);\n * return { displayed: params };\n * },\n * }));\n *\n * priceSource.set({ amount: 1234.56, currency: 'USD' });\n * // -> formattedPriceSource emits '$1,234.56'\n * ```\n *\n * @example\n * Using preserveLastValue for immediate computed access\n * ```ts\n * const counterSource = source<number>();\n *\n * const doubledSource = computedSource(\n * counterSource,\n * (count) => count * 2\n * );\n *\n * // Standard behavior\n * console.log(doubledSource()); // undefined (no emission yet)\n *\n * counterSource.set(5);\n * console.log(doubledSource()); // 10\n *\n * // Using preserveLastValue\n * const immediateDoubled = doubledSource.preserveLastValue;\n * console.log(immediateDoubled()); // 10 (gets last computed value immediately)\n * ```\n */\nexport function computedSource<SourceState, ComputedValue>(\n signalOrigin: SignalSource<SourceState> | ReadonlySource<SourceState>,\n computedFn: (sourceValue: NoInfer<SourceState>) => ComputedValue,\n options?: {\n equal?: ValueEqualityFn<NoInfer<ComputedValue> | undefined>;\n debugName?: string;\n },\n): ReadonlySource<ComputedValue> {\n const listener = (listenerOptions: { nullishFirstValue?: boolean }) =>\n linkedSignal<SourceState, ComputedValue | undefined>({\n source: signalOrigin as Signal<SourceState>,\n computation: (currentSourceState, previousData) => {\n // always when first listened return undefined\n if (!previousData && listenerOptions?.nullishFirstValue !== false) {\n return undefined;\n }\n\n return computedFn(currentSourceState);\n },\n ...(options?.equal && { equal: options?.equal }),\n ...(options?.debugName && { debugName: options?.debugName }),\n });\n return Object.assign(\n listener({\n nullishFirstValue: true,\n }),\n {\n preserveLastValue: listener({\n nullishFirstValue: false,\n }),\n },\n SourceBranded,\n ) as ReadonlySource<any>;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"correlation-id-plugin.d.ts","sourceRoot":"","sources":["../../../../../libs/core/src/lib/correlation-id-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,oBAAoB,EACzB,KAAK,QAAQ,EACd,MAAM,qBAAqB,CAAC;AAmF7B,wBAAgB,4BAA4B,IAAI,CAC5C,QAAQ,GACR,oBAAoB,CACvB,EAAE,CAgBF"}
|