@tstdl/base 0.93.181 → 0.93.183
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/api/server/api-request-token.provider.js +1 -1
- package/api/server/gateway.js +8 -3
- package/authentication/authentication.api.d.ts +13 -40
- package/authentication/authentication.api.js +5 -14
- package/authentication/client/authentication.service.d.ts +6 -14
- package/authentication/client/authentication.service.js +22 -4
- package/authentication/client/module.d.ts +1 -1
- package/authentication/client/module.js +4 -4
- package/authentication/models/index.d.ts +1 -0
- package/authentication/models/index.js +1 -0
- package/authentication/models/totp-results.model.d.ts +11 -0
- package/authentication/models/totp-results.model.js +37 -0
- package/authentication/server/authentication.api-controller.d.ts +3 -3
- package/authentication/server/authentication.api-controller.js +31 -4
- package/authentication/server/authentication.service.d.ts +5 -14
- package/authentication/server/authentication.service.js +6 -4
- package/core.d.ts +0 -5
- package/core.js +0 -8
- package/document-management/api/document-management.api.d.ts +2 -2
- package/document-management/service-models/document.service-model.d.ts +1 -1
- package/examples/config.d.ts +25 -0
- package/examples/config.js +26 -0
- package/notification/server/module.d.ts +1 -1
- package/notification/server/module.js +1 -1
- package/package.json +5 -5
- package/signals/api.d.ts +5 -1
- package/signals/api.js +3 -1
- package/signals/implementation/api.d.ts +13 -5
- package/signals/implementation/api.js +7 -1
- package/signals/implementation/asserts.d.ts +2 -2
- package/signals/implementation/asserts.js +3 -3
- package/signals/implementation/computed.d.ts +7 -34
- package/signals/implementation/computed.js +14 -83
- package/signals/implementation/configure.js +6 -2
- package/signals/implementation/effect.d.ts +65 -46
- package/signals/implementation/effect.js +97 -62
- package/signals/implementation/index.d.ts +2 -4
- package/signals/implementation/index.js +2 -4
- package/signals/implementation/linked_signal.d.ts +36 -0
- package/signals/implementation/linked_signal.js +34 -0
- package/signals/implementation/primitive/computed.d.ts +55 -0
- package/signals/implementation/primitive/computed.js +107 -0
- package/signals/implementation/primitive/effect.d.ts +26 -0
- package/signals/implementation/primitive/effect.js +31 -0
- package/signals/implementation/{equality.d.ts → primitive/equality.d.ts} +1 -1
- package/signals/implementation/{equality.js → primitive/equality.js} +1 -1
- package/signals/implementation/primitive/errors.d.ts +10 -0
- package/signals/implementation/{errors.js → primitive/errors.js} +3 -4
- package/signals/implementation/primitive/formatter.d.ts +19 -0
- package/signals/implementation/primitive/formatter.js +136 -0
- package/signals/implementation/{graph.d.ts → primitive/graph.d.ts} +68 -36
- package/signals/implementation/primitive/graph.js +386 -0
- package/signals/implementation/primitive/linked_signal.d.ts +46 -0
- package/signals/implementation/primitive/linked_signal.js +110 -0
- package/signals/implementation/primitive/signal.d.ts +31 -0
- package/signals/implementation/primitive/signal.js +80 -0
- package/signals/implementation/primitive/untracked.d.ts +12 -0
- package/signals/implementation/primitive/untracked.js +23 -0
- package/signals/implementation/{watch.d.ts → primitive/watch.d.ts} +1 -2
- package/signals/implementation/{watch.js → primitive/watch.js} +22 -16
- package/signals/implementation/resource/api.d.ts +275 -0
- package/signals/implementation/resource/api.js +26 -0
- package/signals/implementation/resource/debounce.d.ts +13 -0
- package/signals/implementation/resource/debounce.js +113 -0
- package/signals/implementation/resource/from_snapshots.d.ts +16 -0
- package/signals/implementation/resource/from_snapshots.js +44 -0
- package/signals/implementation/resource/index.d.ts +11 -0
- package/signals/implementation/resource/index.js +11 -0
- package/signals/implementation/resource/resource.d.ts +110 -0
- package/signals/implementation/resource/resource.js +402 -0
- package/signals/implementation/root_effect_scheduler.d.ts +50 -0
- package/signals/implementation/root_effect_scheduler.js +66 -0
- package/signals/implementation/signal.d.ts +42 -18
- package/signals/implementation/signal.js +29 -49
- package/signals/implementation/to-observable.d.ts +12 -5
- package/signals/implementation/to-observable.js +12 -2
- package/signals/implementation/to-signal.d.ts +9 -18
- package/signals/implementation/to-signal.js +46 -13
- package/signals/implementation/untracked.d.ts +1 -1
- package/signals/implementation/untracked.js +3 -11
- package/signals/operators/debounce.d.ts +8 -0
- package/signals/operators/debounce.js +19 -0
- package/signals/operators/derive-async.js +43 -15
- package/signals/operators/index.d.ts +2 -0
- package/signals/operators/index.js +2 -0
- package/signals/operators/throttle.d.ts +8 -0
- package/signals/operators/throttle.js +31 -0
- package/ai/genkit/tests/multi-region.test.d.ts +0 -2
- package/ai/genkit/tests/multi-region.test.js +0 -179
- package/ai/genkit/tests/token-limit-fallback.test.d.ts +0 -2
- package/ai/genkit/tests/token-limit-fallback.test.js +0 -209
- package/ai/prompts/tests/prompt-builder.test.d.ts +0 -1
- package/ai/prompts/tests/prompt-builder.test.js +0 -22
- package/ai/tests/instructions-formatter.test.d.ts +0 -1
- package/ai/tests/instructions-formatter.test.js +0 -116
- package/ai/tests/steering.test.d.ts +0 -1
- package/ai/tests/steering.test.js +0 -37
- package/api/client/tests/api-client.test.d.ts +0 -1
- package/api/client/tests/api-client.test.js +0 -194
- package/api/server/tests/csrf.middleware.test.d.ts +0 -1
- package/api/server/tests/csrf.middleware.test.js +0 -91
- package/authentication/tests/authentication-password-requirements.validator.test.d.ts +0 -1
- package/authentication/tests/authentication-password-requirements.validator.test.js +0 -29
- package/authentication/tests/authentication.api-controller.test.d.ts +0 -1
- package/authentication/tests/authentication.api-controller.test.js +0 -156
- package/authentication/tests/authentication.api-request-token.provider.test.d.ts +0 -1
- package/authentication/tests/authentication.api-request-token.provider.test.js +0 -48
- package/authentication/tests/authentication.client-error-handling.test.d.ts +0 -1
- package/authentication/tests/authentication.client-error-handling.test.js +0 -123
- package/authentication/tests/authentication.client-middleware.test.d.ts +0 -1
- package/authentication/tests/authentication.client-middleware.test.js +0 -118
- package/authentication/tests/authentication.client-service-methods.test.d.ts +0 -1
- package/authentication/tests/authentication.client-service-methods.test.js +0 -177
- package/authentication/tests/authentication.client-service-refresh.test.d.ts +0 -1
- package/authentication/tests/authentication.client-service-refresh.test.js +0 -153
- package/authentication/tests/authentication.client-service.test.d.ts +0 -1
- package/authentication/tests/authentication.client-service.test.js +0 -76
- package/authentication/tests/authentication.refresh-busy-loop.test.d.ts +0 -1
- package/authentication/tests/authentication.refresh-busy-loop.test.js +0 -84
- package/authentication/tests/authentication.service.test.d.ts +0 -1
- package/authentication/tests/authentication.service.test.js +0 -167
- package/authentication/tests/authentication.test-ancillary-service.d.ts +0 -9
- package/authentication/tests/authentication.test-ancillary-service.js +0 -27
- package/authentication/tests/brute-force-protection.test.d.ts +0 -1
- package/authentication/tests/brute-force-protection.test.js +0 -211
- package/authentication/tests/helper.test.d.ts +0 -1
- package/authentication/tests/helper.test.js +0 -122
- package/authentication/tests/password-requirements.error.test.d.ts +0 -1
- package/authentication/tests/password-requirements.error.test.js +0 -14
- package/authentication/tests/remember.api.test.d.ts +0 -1
- package/authentication/tests/remember.api.test.js +0 -117
- package/authentication/tests/remember.service.test.d.ts +0 -1
- package/authentication/tests/remember.service.test.js +0 -83
- package/authentication/tests/subject.service.test.d.ts +0 -1
- package/authentication/tests/subject.service.test.js +0 -140
- package/authentication/tests/suspended-subject.test.d.ts +0 -1
- package/authentication/tests/suspended-subject.test.js +0 -120
- package/authentication/tests/totp.enrollment.test.d.ts +0 -1
- package/authentication/tests/totp.enrollment.test.js +0 -123
- package/authentication/tests/totp.login.test.d.ts +0 -1
- package/authentication/tests/totp.login.test.js +0 -213
- package/authentication/tests/totp.recovery-codes.test.d.ts +0 -1
- package/authentication/tests/totp.recovery-codes.test.js +0 -97
- package/authentication/tests/totp.status.test.d.ts +0 -1
- package/authentication/tests/totp.status.test.js +0 -72
- package/cancellation/tests/coverage.test.d.ts +0 -1
- package/cancellation/tests/coverage.test.js +0 -49
- package/cancellation/tests/leak.test.d.ts +0 -1
- package/cancellation/tests/leak.test.js +0 -35
- package/cancellation/tests/token.test.d.ts +0 -1
- package/cancellation/tests/token.test.js +0 -136
- package/circuit-breaker/tests/circuit-breaker.test.d.ts +0 -1
- package/circuit-breaker/tests/circuit-breaker.test.js +0 -116
- package/cryptography/tests/cryptography.test.d.ts +0 -1
- package/cryptography/tests/cryptography.test.js +0 -175
- package/cryptography/tests/jwt.test.d.ts +0 -1
- package/cryptography/tests/jwt.test.js +0 -54
- package/cryptography/tests/modern.test.d.ts +0 -1
- package/cryptography/tests/modern.test.js +0 -105
- package/cryptography/tests/module.test.d.ts +0 -1
- package/cryptography/tests/module.test.js +0 -100
- package/cryptography/tests/totp.test.d.ts +0 -1
- package/cryptography/tests/totp.test.js +0 -108
- package/document-management/tests/ai-config-hierarchy.test.d.ts +0 -1
- package/document-management/tests/ai-config-hierarchy.test.js +0 -59
- package/document-management/tests/ai-config-integration.test.d.ts +0 -1
- package/document-management/tests/ai-config-integration.test.js +0 -125
- package/document-management/tests/ai-config-merge.test.d.ts +0 -1
- package/document-management/tests/ai-config-merge.test.js +0 -46
- package/document-management/tests/document-management-ai-overrides.test.d.ts +0 -1
- package/document-management/tests/document-management-ai-overrides.test.js +0 -63
- package/document-management/tests/document-management-core.test.d.ts +0 -1
- package/document-management/tests/document-management-core.test.js +0 -157
- package/document-management/tests/document-management.api.test.d.ts +0 -1
- package/document-management/tests/document-management.api.test.js +0 -101
- package/document-management/tests/document-statistics.service.test.d.ts +0 -1
- package/document-management/tests/document-statistics.service.test.js +0 -498
- package/document-management/tests/document-validation-ai-overrides.test.d.ts +0 -1
- package/document-management/tests/document-validation-ai-overrides.test.js +0 -87
- package/document-management/tests/document.service.test.d.ts +0 -1
- package/document-management/tests/document.service.test.js +0 -143
- package/document-management/tests/enum-helpers.test.d.ts +0 -1
- package/document-management/tests/enum-helpers.test.js +0 -452
- package/document-management/tests/helper.d.ts +0 -24
- package/document-management/tests/helper.js +0 -39
- package/errors/tests/format.test.d.ts +0 -1
- package/errors/tests/format.test.js +0 -84
- package/http/tests/server-timing.test.d.ts +0 -1
- package/http/tests/server-timing.test.js +0 -42
- package/injector/tests/advanced.test.d.ts +0 -1
- package/injector/tests/advanced.test.js +0 -116
- package/injector/tests/async-init.test.d.ts +0 -1
- package/injector/tests/async-init.test.js +0 -77
- package/injector/tests/basic.test.d.ts +0 -1
- package/injector/tests/basic.test.js +0 -114
- package/injector/tests/hierarchical.test.d.ts +0 -1
- package/injector/tests/hierarchical.test.js +0 -59
- package/injector/tests/leak.test.d.ts +0 -1
- package/injector/tests/leak.test.js +0 -45
- package/injector/tests/lifecycles.test.d.ts +0 -1
- package/injector/tests/lifecycles.test.js +0 -109
- package/logger/tests/pretty-print.test.d.ts +0 -1
- package/logger/tests/pretty-print.test.js +0 -60
- package/notification/tests/notification-api.test.d.ts +0 -1
- package/notification/tests/notification-api.test.js +0 -124
- package/notification/tests/notification-client.test.d.ts +0 -1
- package/notification/tests/notification-client.test.js +0 -101
- package/notification/tests/notification-flow.test.d.ts +0 -1
- package/notification/tests/notification-flow.test.js +0 -296
- package/notification/tests/notification-sse.service.test.d.ts +0 -1
- package/notification/tests/notification-sse.service.test.js +0 -43
- package/notification/tests/notification-type.service.test.d.ts +0 -1
- package/notification/tests/notification-type.service.test.js +0 -41
- package/object-storage/s3/tests/s3.object-storage.integration.test.d.ts +0 -1
- package/object-storage/s3/tests/s3.object-storage.integration.test.js +0 -303
- package/orm/tests/build-jsonb.test.d.ts +0 -1
- package/orm/tests/build-jsonb.test.js +0 -39
- package/orm/tests/data-types.test.d.ts +0 -1
- package/orm/tests/data-types.test.js +0 -39
- package/orm/tests/database-extension.test.d.ts +0 -1
- package/orm/tests/database-extension.test.js +0 -63
- package/orm/tests/database-migration.test.d.ts +0 -1
- package/orm/tests/database-migration.test.js +0 -83
- package/orm/tests/decorators.test.d.ts +0 -1
- package/orm/tests/decorators.test.js +0 -77
- package/orm/tests/encryption.test.d.ts +0 -1
- package/orm/tests/encryption.test.js +0 -31
- package/orm/tests/query-complex.test.d.ts +0 -1
- package/orm/tests/query-complex.test.js +0 -172
- package/orm/tests/query-converter-complex.test.d.ts +0 -1
- package/orm/tests/query-converter-complex.test.js +0 -131
- package/orm/tests/query-converter.test.d.ts +0 -1
- package/orm/tests/query-converter.test.js +0 -123
- package/orm/tests/repository-advanced.test.d.ts +0 -1
- package/orm/tests/repository-advanced.test.js +0 -189
- package/orm/tests/repository-attributes.test.d.ts +0 -1
- package/orm/tests/repository-attributes.test.js +0 -83
- package/orm/tests/repository-compound-primary-key.test.d.ts +0 -2
- package/orm/tests/repository-compound-primary-key.test.js +0 -226
- package/orm/tests/repository-comprehensive.test.d.ts +0 -1
- package/orm/tests/repository-comprehensive.test.js +0 -162
- package/orm/tests/repository-coverage.test.d.ts +0 -2
- package/orm/tests/repository-coverage.test.js +0 -242
- package/orm/tests/repository-cti-complex.test.d.ts +0 -1
- package/orm/tests/repository-cti-complex.test.js +0 -151
- package/orm/tests/repository-cti-embedded.test.d.ts +0 -1
- package/orm/tests/repository-cti-embedded.test.js +0 -178
- package/orm/tests/repository-cti-extensive.test.d.ts +0 -2
- package/orm/tests/repository-cti-extensive.test.js +0 -279
- package/orm/tests/repository-cti-mapping.test.d.ts +0 -2
- package/orm/tests/repository-cti-mapping.test.js +0 -108
- package/orm/tests/repository-cti-search.test.d.ts +0 -1
- package/orm/tests/repository-cti-search.test.js +0 -141
- package/orm/tests/repository-cti-soft-delete.test.d.ts +0 -2
- package/orm/tests/repository-cti-soft-delete.test.js +0 -103
- package/orm/tests/repository-cti-transactions.test.d.ts +0 -1
- package/orm/tests/repository-cti-transactions.test.js +0 -112
- package/orm/tests/repository-cti-upsert-many.test.d.ts +0 -2
- package/orm/tests/repository-cti-upsert-many.test.js +0 -115
- package/orm/tests/repository-cti.test.d.ts +0 -2
- package/orm/tests/repository-cti.test.js +0 -390
- package/orm/tests/repository-edge-cases.test.d.ts +0 -1
- package/orm/tests/repository-edge-cases.test.js +0 -178
- package/orm/tests/repository-expiration.test.d.ts +0 -2
- package/orm/tests/repository-expiration.test.js +0 -140
- package/orm/tests/repository-extra-coverage.test.d.ts +0 -2
- package/orm/tests/repository-extra-coverage.test.js +0 -402
- package/orm/tests/repository-mapping.test.d.ts +0 -2
- package/orm/tests/repository-mapping.test.js +0 -65
- package/orm/tests/repository-regression.test.d.ts +0 -1
- package/orm/tests/repository-regression.test.js +0 -288
- package/orm/tests/repository-search-coverage.test.d.ts +0 -1
- package/orm/tests/repository-search-coverage.test.js +0 -107
- package/orm/tests/repository-search.test.d.ts +0 -1
- package/orm/tests/repository-search.test.js +0 -105
- package/orm/tests/repository-soft-delete.test.d.ts +0 -1
- package/orm/tests/repository-soft-delete.test.js +0 -118
- package/orm/tests/repository-transactions-nested.test.d.ts +0 -1
- package/orm/tests/repository-transactions-nested.test.js +0 -178
- package/orm/tests/repository-types.test.d.ts +0 -1
- package/orm/tests/repository-types.test.js +0 -184
- package/orm/tests/repository-undelete.test.d.ts +0 -2
- package/orm/tests/repository-undelete.test.js +0 -201
- package/orm/tests/schema-converter.test.d.ts +0 -1
- package/orm/tests/schema-converter.test.js +0 -82
- package/orm/tests/schema-generation.test.d.ts +0 -2
- package/orm/tests/schema-generation.test.js +0 -174
- package/orm/tests/sql-helpers.test.d.ts +0 -1
- package/orm/tests/sql-helpers.test.js +0 -67
- package/orm/tests/transaction-safety.test.d.ts +0 -1
- package/orm/tests/transaction-safety.test.js +0 -81
- package/orm/tests/transactional.test.d.ts +0 -1
- package/orm/tests/transactional.test.js +0 -215
- package/orm/tests/utils.test.d.ts +0 -1
- package/orm/tests/utils.test.js +0 -70
- package/pdf/tests/utils.test.d.ts +0 -1
- package/pdf/tests/utils.test.js +0 -187
- package/process/tests/spawn.test.d.ts +0 -1
- package/process/tests/spawn.test.js +0 -182
- package/rate-limit/tests/postgres-rate-limiter.test.d.ts +0 -1
- package/rate-limit/tests/postgres-rate-limiter.test.js +0 -84
- package/renderer/tests/renderer.test.d.ts +0 -1
- package/renderer/tests/renderer.test.js +0 -88
- package/rpc/tests/rpc.integration.test.d.ts +0 -1
- package/rpc/tests/rpc.integration.test.js +0 -615
- package/signals/implementation/errors.d.ts +0 -2
- package/signals/implementation/graph.js +0 -312
- package/signals/implementation/writable-signal.d.ts +0 -48
- package/signals/implementation/writable-signal.js +0 -32
- package/task-queue/tests/coverage-branch.test.d.ts +0 -1
- package/task-queue/tests/coverage-branch.test.js +0 -395
- package/task-queue/tests/coverage-enhancement.test.d.ts +0 -1
- package/task-queue/tests/coverage-enhancement.test.js +0 -150
- package/task-queue/tests/dag.test.d.ts +0 -1
- package/task-queue/tests/dag.test.js +0 -188
- package/task-queue/tests/dependencies.test.d.ts +0 -1
- package/task-queue/tests/dependencies.test.js +0 -296
- package/task-queue/tests/enqueue-batch.test.d.ts +0 -1
- package/task-queue/tests/enqueue-batch.test.js +0 -125
- package/task-queue/tests/enqueue-item.test.d.ts +0 -1
- package/task-queue/tests/enqueue-item.test.js +0 -12
- package/task-queue/tests/fan-out-spawning.test.d.ts +0 -1
- package/task-queue/tests/fan-out-spawning.test.js +0 -94
- package/task-queue/tests/idempotent-replacement.test.d.ts +0 -1
- package/task-queue/tests/idempotent-replacement.test.js +0 -114
- package/task-queue/tests/missing-idempotent-tasks.test.d.ts +0 -1
- package/task-queue/tests/missing-idempotent-tasks.test.js +0 -39
- package/task-queue/tests/optimization-edge-cases.test.d.ts +0 -1
- package/task-queue/tests/optimization-edge-cases.test.js +0 -124
- package/task-queue/tests/queue-generic.test.d.ts +0 -1
- package/task-queue/tests/queue-generic.test.js +0 -8
- package/task-queue/tests/queue.test.d.ts +0 -1
- package/task-queue/tests/queue.test.js +0 -756
- package/task-queue/tests/shutdown.test.d.ts +0 -1
- package/task-queue/tests/shutdown.test.js +0 -41
- package/task-queue/tests/task-context.test.d.ts +0 -1
- package/task-queue/tests/task-context.test.js +0 -7
- package/task-queue/tests/task-union.test.d.ts +0 -1
- package/task-queue/tests/task-union.test.js +0 -18
- package/task-queue/tests/transactions.test.d.ts +0 -1
- package/task-queue/tests/transactions.test.js +0 -47
- package/task-queue/tests/typing.test.d.ts +0 -1
- package/task-queue/tests/typing.test.js +0 -9
- package/task-queue/tests/worker.test.d.ts +0 -1
- package/task-queue/tests/worker.test.js +0 -258
- package/task-queue/tests/zombie-parent.test.d.ts +0 -1
- package/task-queue/tests/zombie-parent.test.js +0 -45
- package/task-queue/tests/zombie-recovery.test.d.ts +0 -1
- package/task-queue/tests/zombie-recovery.test.js +0 -51
- package/utils/tests/backoff.test.d.ts +0 -1
- package/utils/tests/backoff.test.js +0 -41
- package/utils/tests/retry-with-backoff.test.d.ts +0 -1
- package/utils/tests/retry-with-backoff.test.js +0 -49
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** biome-ignore-all lint: <explanation> */
|
|
2
|
+
import type { DebouncedOptions, DebounceTimer, Resource } from './api.js';
|
|
3
|
+
/**
|
|
4
|
+
* Creates a resource representing a debounced version of the source signal.
|
|
5
|
+
*
|
|
6
|
+
* @param source The source signal to debounce.
|
|
7
|
+
* @param wait The amount of time to wait before calling the source signal, or a function that
|
|
8
|
+
* returns a promise that resolves when the debounced value should be updated.
|
|
9
|
+
* @param options The options to use for the debounced signal.
|
|
10
|
+
* @returns A resource representing the debounced signal.
|
|
11
|
+
* @experimental 22.0
|
|
12
|
+
*/
|
|
13
|
+
export declare function debounced<T>(source: () => T, wait: NoInfer<DebounceTimer<T>>, options?: NoInfer<DebouncedOptions<T>>): Resource<T>;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
/** biome-ignore-all lint: <explanation> */
|
|
3
|
+
/**
|
|
4
|
+
* @license
|
|
5
|
+
* Copyright Google LLC All Rights Reserved.
|
|
6
|
+
*
|
|
7
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
8
|
+
* found in the LICENSE file at https://angular.dev/license
|
|
9
|
+
*/
|
|
10
|
+
import { effect } from '../effect.js';
|
|
11
|
+
import { linkedSignal } from '../linked_signal.js';
|
|
12
|
+
import { untracked } from '../untracked.js';
|
|
13
|
+
import { resourceFromSnapshots } from './from_snapshots.js';
|
|
14
|
+
import { invalidResourceCreationInParams, isInParamsFunction, rethrowFatalErrors, setInParamsFunction } from './resource.js';
|
|
15
|
+
/**
|
|
16
|
+
* Creates a resource representing a debounced version of the source signal.
|
|
17
|
+
*
|
|
18
|
+
* @param source The source signal to debounce.
|
|
19
|
+
* @param wait The amount of time to wait before calling the source signal, or a function that
|
|
20
|
+
* returns a promise that resolves when the debounced value should be updated.
|
|
21
|
+
* @param options The options to use for the debounced signal.
|
|
22
|
+
* @returns A resource representing the debounced signal.
|
|
23
|
+
* @experimental 22.0
|
|
24
|
+
*/
|
|
25
|
+
export function debounced(source, wait, options) {
|
|
26
|
+
if (isInParamsFunction()) {
|
|
27
|
+
throw invalidResourceCreationInParams();
|
|
28
|
+
}
|
|
29
|
+
let active;
|
|
30
|
+
let pendingValue;
|
|
31
|
+
const state = linkedSignal({
|
|
32
|
+
source: () => {
|
|
33
|
+
try {
|
|
34
|
+
setInParamsFunction(true);
|
|
35
|
+
return { value: source(), thrown: false };
|
|
36
|
+
}
|
|
37
|
+
catch (err) {
|
|
38
|
+
rethrowFatalErrors(err);
|
|
39
|
+
return { error: err, thrown: true };
|
|
40
|
+
}
|
|
41
|
+
finally {
|
|
42
|
+
setInParamsFunction(false);
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
computation: (res, previous) => {
|
|
46
|
+
// If we already have a state from the effect or a previous read, keep it!
|
|
47
|
+
// The effect is responsible for timing and state transitions.
|
|
48
|
+
if (previous !== undefined) {
|
|
49
|
+
return previous.value;
|
|
50
|
+
}
|
|
51
|
+
// On the very first evaluation, determine the initial state synchronously.
|
|
52
|
+
if (res.thrown) {
|
|
53
|
+
return { status: 'error', error: res.error };
|
|
54
|
+
}
|
|
55
|
+
return { status: 'resolved', value: res.value };
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
effect(() => {
|
|
59
|
+
// Enter error state if the source throws.
|
|
60
|
+
let value;
|
|
61
|
+
try {
|
|
62
|
+
setInParamsFunction(true);
|
|
63
|
+
value = source();
|
|
64
|
+
}
|
|
65
|
+
catch (err) {
|
|
66
|
+
rethrowFatalErrors(err);
|
|
67
|
+
state.set({ status: 'error', error: err });
|
|
68
|
+
active = pendingValue = undefined;
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
finally {
|
|
72
|
+
setInParamsFunction(false);
|
|
73
|
+
}
|
|
74
|
+
const currentState = untracked(state);
|
|
75
|
+
// Check if the value is the same as the previous one.
|
|
76
|
+
const equal = options?.equal ?? Object.is;
|
|
77
|
+
if (currentState.status === 'reloading' || currentState.status === 'loading') {
|
|
78
|
+
if (equal(value, pendingValue))
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
else if (currentState.status === 'resolved') {
|
|
82
|
+
if (equal(value, currentState.value))
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
const waitFn = typeof wait === 'number'
|
|
86
|
+
? () => new Promise((resolve) => setTimeout(resolve, wait))
|
|
87
|
+
: wait;
|
|
88
|
+
const result = waitFn(value, currentState);
|
|
89
|
+
if (result === undefined) {
|
|
90
|
+
// Synchronous case, go straight to resolved.
|
|
91
|
+
state.set({ status: 'resolved', value });
|
|
92
|
+
active = pendingValue = undefined;
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
// Asynchronous case:
|
|
96
|
+
// If we're in error state or loading state, remain in that state.
|
|
97
|
+
// Otherwise, change to loading state but keep the current value until the new one loads.
|
|
98
|
+
if (currentState.status !== 'loading' && currentState.status !== 'error') {
|
|
99
|
+
state.set({ status: 'loading', value: currentState.value });
|
|
100
|
+
}
|
|
101
|
+
active = result;
|
|
102
|
+
pendingValue = value;
|
|
103
|
+
// Once the promise resolves, update the state to resolved.
|
|
104
|
+
result.then(() => {
|
|
105
|
+
if (active === result) {
|
|
106
|
+
state.set({ status: 'resolved', value });
|
|
107
|
+
active = pendingValue = undefined;
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
}, { injector: options?.injector });
|
|
112
|
+
return resourceFromSnapshots(state);
|
|
113
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.dev/license
|
|
7
|
+
*/
|
|
8
|
+
import type { Resource, ResourceSnapshot } from './api.js';
|
|
9
|
+
/**
|
|
10
|
+
* Creates a `Resource` driven by a source of `ResourceSnapshot`s.
|
|
11
|
+
*
|
|
12
|
+
* @see [Resource composition with snapshots](guide/signals/resource#resource-composition-with-snapshots)
|
|
13
|
+
*
|
|
14
|
+
* @experimental
|
|
15
|
+
*/
|
|
16
|
+
export declare function resourceFromSnapshots<T>(source: () => ResourceSnapshot<T>): Resource<T>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.dev/license
|
|
7
|
+
*/
|
|
8
|
+
/* eslint-disable */
|
|
9
|
+
/** biome-ignore-all lint: <explanation> */
|
|
10
|
+
import { isSignal } from '../api.js';
|
|
11
|
+
import { computed } from '../computed.js';
|
|
12
|
+
import { ResourceValueError } from './resource.js';
|
|
13
|
+
/**
|
|
14
|
+
* Creates a `Resource` driven by a source of `ResourceSnapshot`s.
|
|
15
|
+
*
|
|
16
|
+
* @see [Resource composition with snapshots](guide/signals/resource#resource-composition-with-snapshots)
|
|
17
|
+
*
|
|
18
|
+
* @experimental
|
|
19
|
+
*/
|
|
20
|
+
export function resourceFromSnapshots(source) {
|
|
21
|
+
return new SnapshotResource(isSignal(source) ? source : computed(source));
|
|
22
|
+
}
|
|
23
|
+
class SnapshotResource {
|
|
24
|
+
snapshot;
|
|
25
|
+
constructor(snapshot) {
|
|
26
|
+
this.snapshot = snapshot;
|
|
27
|
+
}
|
|
28
|
+
get state() {
|
|
29
|
+
return this.snapshot();
|
|
30
|
+
}
|
|
31
|
+
value = computed(() => {
|
|
32
|
+
if (this.state.status === 'error') {
|
|
33
|
+
throw new ResourceValueError(this.state.error);
|
|
34
|
+
}
|
|
35
|
+
return this.state.value;
|
|
36
|
+
});
|
|
37
|
+
status = computed(() => this.state.status);
|
|
38
|
+
error = computed(() => (this.state.status === 'error' ? this.state.error : undefined));
|
|
39
|
+
isLoading = computed(() => this.state.status === 'loading' || this.state.status === 'reloading');
|
|
40
|
+
isValueDefined = computed(() => this.state.status !== 'error' && this.state.value !== undefined);
|
|
41
|
+
hasValue() {
|
|
42
|
+
return this.isValueDefined();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.dev/license
|
|
7
|
+
*/
|
|
8
|
+
export * from './api.js';
|
|
9
|
+
export { debounced } from './debounce.js';
|
|
10
|
+
export { resourceFromSnapshots } from './from_snapshots.js';
|
|
11
|
+
export { resource } from './resource.js';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.dev/license
|
|
7
|
+
*/
|
|
8
|
+
export * from './api.js';
|
|
9
|
+
export { debounced } from './debounce.js';
|
|
10
|
+
export { resourceFromSnapshots } from './from_snapshots.js';
|
|
11
|
+
export { resource } from './resource.js';
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.dev/license
|
|
7
|
+
*/
|
|
8
|
+
import type { SignalsInjector } from '../../../signals/api.js';
|
|
9
|
+
import type { Signal, ValueEqualityFn } from '../api.js';
|
|
10
|
+
import { type WritableSignal } from '../signal.js';
|
|
11
|
+
import { type Resource, type ResourceOptions, type ResourceParamsContext, type ResourceRef, type ResourceSnapshot, type ResourceStatus, type ResourceStreamingLoader, type ResourceStreamItem, type WritableResource } from './api.js';
|
|
12
|
+
/**
|
|
13
|
+
* Constructs a `Resource` that projects a reactive request to an asynchronous operation defined by
|
|
14
|
+
* a loader function, which exposes the result of the loading operation via signals.
|
|
15
|
+
*
|
|
16
|
+
* Note that `resource` is intended for _read_ operations, not operations which perform mutations.
|
|
17
|
+
* `resource` will cancel in-progress loads via the `AbortSignal` when destroyed or when a new
|
|
18
|
+
* request object becomes available, which could prematurely abort mutations.
|
|
19
|
+
*/
|
|
20
|
+
export declare function resource<T, R>(options: ResourceOptions<T, R> & {
|
|
21
|
+
defaultValue: NoInfer<T>;
|
|
22
|
+
}): ResourceRef<T>;
|
|
23
|
+
/**
|
|
24
|
+
* Constructs a `Resource` that projects a reactive request to an asynchronous operation defined by
|
|
25
|
+
* a loader function, which exposes the result of the loading operation via signals.
|
|
26
|
+
*
|
|
27
|
+
* Note that `resource` is intended for _read_ operations, not operations which perform mutations.
|
|
28
|
+
* `resource` will cancel in-progress loads via the `AbortSignal` when destroyed or when a new
|
|
29
|
+
* request object becomes available, which could prematurely abort mutations.
|
|
30
|
+
*
|
|
31
|
+
* @experimental 19.0
|
|
32
|
+
* @see [Async reactivity with resources](guide/signals/resource)
|
|
33
|
+
*/
|
|
34
|
+
export declare function resource<T, R>(options: ResourceOptions<T, R>): ResourceRef<T | undefined>;
|
|
35
|
+
type ResourceInternalStatus = 'idle' | 'loading' | 'resolved' | 'local';
|
|
36
|
+
type WrappedRequest = {
|
|
37
|
+
request?: unknown;
|
|
38
|
+
reload: number;
|
|
39
|
+
status?: ResourceInternalStatus;
|
|
40
|
+
error?: Error;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Base class which implements `.value` as a `WritableSignal` by delegating `.set` and `.update`.
|
|
44
|
+
*/
|
|
45
|
+
declare abstract class BaseWritableResource<T> implements WritableResource<T> {
|
|
46
|
+
readonly value: WritableSignal<T>;
|
|
47
|
+
abstract readonly status: Signal<ResourceStatus>;
|
|
48
|
+
abstract readonly error: Signal<Error | undefined>;
|
|
49
|
+
abstract reload(): boolean;
|
|
50
|
+
readonly isLoading: Signal<boolean>;
|
|
51
|
+
constructor(value: Signal<T>, debugName: string | undefined);
|
|
52
|
+
abstract set(value: T): void;
|
|
53
|
+
private readonly isError;
|
|
54
|
+
update(updateFn: (value: T) => T): void;
|
|
55
|
+
private readonly isValueDefined;
|
|
56
|
+
private _snapshot;
|
|
57
|
+
get snapshot(): Signal<ResourceSnapshot<T>>;
|
|
58
|
+
hasValue(): this is ResourceRef<Exclude<T, undefined>>;
|
|
59
|
+
asReadonly(): Resource<T>;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Implementation for `resource()` which uses a `linkedSignal` to manage the resource's state.
|
|
63
|
+
*/
|
|
64
|
+
export declare class ResourceImpl<T, R> extends BaseWritableResource<T> implements ResourceRef<T> {
|
|
65
|
+
/**
|
|
66
|
+
* The current state of the resource. Status, value, and error are derived from this.
|
|
67
|
+
*/
|
|
68
|
+
private readonly state;
|
|
69
|
+
/**
|
|
70
|
+
* Combines the current request with a reload counter which allows the resource to be reloaded on
|
|
71
|
+
* imperative command.
|
|
72
|
+
*/
|
|
73
|
+
protected readonly extRequest: WritableSignal<WrappedRequest>;
|
|
74
|
+
private readonly effectRef;
|
|
75
|
+
private readonly loaderFn;
|
|
76
|
+
defaultValue: T;
|
|
77
|
+
private readonly equal;
|
|
78
|
+
private readonly debugName;
|
|
79
|
+
private pendingController;
|
|
80
|
+
private resolvePendingTask;
|
|
81
|
+
private destroyed;
|
|
82
|
+
private unregisterOnDestroy;
|
|
83
|
+
readonly status: Signal<ResourceStatus>;
|
|
84
|
+
readonly error: Signal<Error | undefined>;
|
|
85
|
+
constructor(request: (ctx: ResourceParamsContext) => R, loaderFn: ResourceStreamingLoader<T, R>, defaultValue: T, equal: ValueEqualityFn<T> | undefined, debugName: string | undefined, injector?: SignalsInjector, getInitialStream?: (request: R) => Signal<ResourceStreamItem<T>> | undefined);
|
|
86
|
+
/**
|
|
87
|
+
* Called either directly via `WritableResource.set` or via `.value.set()`.
|
|
88
|
+
*/
|
|
89
|
+
set(value: T): void;
|
|
90
|
+
reload(): boolean;
|
|
91
|
+
destroy(): void;
|
|
92
|
+
private loadEffect;
|
|
93
|
+
private abortInProgressLoad;
|
|
94
|
+
}
|
|
95
|
+
export declare function encapsulateResourceError(error: unknown): Error;
|
|
96
|
+
export declare function isErrorLike(error: unknown): error is Error;
|
|
97
|
+
export declare class ResourceValueError extends Error {
|
|
98
|
+
constructor(error: Error);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Chains the value of another resource into the params of the current resource, returning the value
|
|
102
|
+
* of the other resource if it is available, or propagating the status to the current resource if it
|
|
103
|
+
* is not.
|
|
104
|
+
*/
|
|
105
|
+
export declare const paramsContext: ResourceParamsContext;
|
|
106
|
+
export declare function isInParamsFunction(): boolean;
|
|
107
|
+
export declare function setInParamsFunction(value: boolean): void;
|
|
108
|
+
export declare function invalidResourceCreationInParams(): Error;
|
|
109
|
+
export declare function rethrowFatalErrors(error: unknown): void;
|
|
110
|
+
export {};
|