@tstdl/base 0.93.182 → 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 +6 -1
- 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
|
@@ -1,312 +0,0 @@
|
|
|
1
|
-
/* eslint-disable */
|
|
2
|
-
import { SIGNAL } from '../symbol.js';
|
|
3
|
-
export { SIGNAL };
|
|
4
|
-
/**
|
|
5
|
-
* @license
|
|
6
|
-
* Copyright Google LLC All Rights Reserved.
|
|
7
|
-
*
|
|
8
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
9
|
-
* found in the LICENSE file at https://angular.io/license
|
|
10
|
-
*/
|
|
11
|
-
/**
|
|
12
|
-
* The currently active consumer `ReactiveNode`, if running code in a reactive context.
|
|
13
|
-
*
|
|
14
|
-
* Change this via `setActiveConsumer`.
|
|
15
|
-
*/
|
|
16
|
-
let activeConsumer = null;
|
|
17
|
-
let inNotificationPhase = false;
|
|
18
|
-
/**
|
|
19
|
-
* Global epoch counter. Incremented whenever a source signal is set.
|
|
20
|
-
*/
|
|
21
|
-
let epoch = 1;
|
|
22
|
-
export function setActiveConsumer(consumer) {
|
|
23
|
-
const prev = activeConsumer;
|
|
24
|
-
activeConsumer = consumer;
|
|
25
|
-
return prev;
|
|
26
|
-
}
|
|
27
|
-
export function getActiveConsumer() {
|
|
28
|
-
return activeConsumer;
|
|
29
|
-
}
|
|
30
|
-
export function isInNotificationPhase() {
|
|
31
|
-
return inNotificationPhase;
|
|
32
|
-
}
|
|
33
|
-
export function isReactive(value) {
|
|
34
|
-
return value[SIGNAL] !== undefined;
|
|
35
|
-
}
|
|
36
|
-
export const REACTIVE_NODE = {
|
|
37
|
-
version: 0,
|
|
38
|
-
lastCleanEpoch: 0,
|
|
39
|
-
dirty: false,
|
|
40
|
-
producerNode: undefined,
|
|
41
|
-
producerLastReadVersion: undefined,
|
|
42
|
-
producerIndexOfThis: undefined,
|
|
43
|
-
nextProducerIndex: 0,
|
|
44
|
-
liveConsumerNode: undefined,
|
|
45
|
-
liveConsumerIndexOfThis: undefined,
|
|
46
|
-
consumerAllowSignalWrites: false,
|
|
47
|
-
consumerIsAlwaysLive: false,
|
|
48
|
-
producerMustRecompute: () => false,
|
|
49
|
-
producerRecomputeValue: () => { },
|
|
50
|
-
consumerMarkedDirty: () => { },
|
|
51
|
-
consumerOnSignalRead: () => { },
|
|
52
|
-
};
|
|
53
|
-
/**
|
|
54
|
-
* Called by implementations when a producer's signal is read.
|
|
55
|
-
*/
|
|
56
|
-
export function producerAccessed(node) {
|
|
57
|
-
if (inNotificationPhase) {
|
|
58
|
-
throw new Error(`Assertion error: signal read during notification phase`);
|
|
59
|
-
}
|
|
60
|
-
if (activeConsumer === null) {
|
|
61
|
-
// Accessed outside of a reactive context, so nothing to record.
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
activeConsumer.consumerOnSignalRead(node);
|
|
65
|
-
// This producer is the `idx`th dependency of `activeConsumer`.
|
|
66
|
-
const idx = activeConsumer.nextProducerIndex++;
|
|
67
|
-
assertConsumerNode(activeConsumer);
|
|
68
|
-
if (idx < activeConsumer.producerNode.length && activeConsumer.producerNode[idx] !== node) {
|
|
69
|
-
// There's been a change in producers since the last execution of `activeConsumer`.
|
|
70
|
-
// `activeConsumer.producerNode[idx]` holds a stale dependency which will be be removed and
|
|
71
|
-
// replaced with `this`.
|
|
72
|
-
//
|
|
73
|
-
// If `activeConsumer` isn't live, then this is a no-op, since we can replace the producer in
|
|
74
|
-
// `activeConsumer.producerNode` directly. However, if `activeConsumer` is live, then we need
|
|
75
|
-
// to remove it from the stale producer's `liveConsumer`s.
|
|
76
|
-
if (consumerIsLive(activeConsumer)) {
|
|
77
|
-
const staleProducer = activeConsumer.producerNode[idx];
|
|
78
|
-
producerRemoveLiveConsumerAtIndex(staleProducer, activeConsumer.producerIndexOfThis[idx]);
|
|
79
|
-
// At this point, the only record of `staleProducer` is the reference at
|
|
80
|
-
// `activeConsumer.producerNode[idx]` which will be overwritten below.
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
if (activeConsumer.producerNode[idx] !== node) {
|
|
84
|
-
// We're a new dependency of the consumer (at `idx`).
|
|
85
|
-
activeConsumer.producerNode[idx] = node;
|
|
86
|
-
// If the active consumer is live, then add it as a live consumer. If not, then use 0 as a
|
|
87
|
-
// placeholder value.
|
|
88
|
-
activeConsumer.producerIndexOfThis[idx] = consumerIsLive(activeConsumer)
|
|
89
|
-
? producerAddLiveConsumer(node, activeConsumer, idx)
|
|
90
|
-
: 0;
|
|
91
|
-
}
|
|
92
|
-
activeConsumer.producerLastReadVersion[idx] = node.version;
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Increment the global epoch counter.
|
|
96
|
-
*
|
|
97
|
-
* Called by source producers (that is, not computeds) whenever their values change.
|
|
98
|
-
*/
|
|
99
|
-
export function producerIncrementEpoch() {
|
|
100
|
-
epoch++;
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Ensure this producer's `version` is up-to-date.
|
|
104
|
-
*/
|
|
105
|
-
export function producerUpdateValueVersion(node) {
|
|
106
|
-
if (consumerIsLive(node) && !node.dirty) {
|
|
107
|
-
// A live consumer will be marked dirty by producers, so a clean state means that its version
|
|
108
|
-
// is guaranteed to be up-to-date.
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
if (!node.dirty && node.lastCleanEpoch === epoch) {
|
|
112
|
-
// Even non-live consumers can skip polling if they previously found themselves to be clean at
|
|
113
|
-
// the current epoch, since their dependencies could not possibly have changed (such a change
|
|
114
|
-
// would've increased the epoch).
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
if (!node.producerMustRecompute(node) && !consumerPollProducersForChange(node)) {
|
|
118
|
-
// None of our producers report a change since the last time they were read, so no
|
|
119
|
-
// recomputation of our value is necessary, and we can consider ourselves clean.
|
|
120
|
-
node.dirty = false;
|
|
121
|
-
node.lastCleanEpoch = epoch;
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
124
|
-
node.producerRecomputeValue(node);
|
|
125
|
-
// After recomputing the value, we're no longer dirty.
|
|
126
|
-
node.dirty = false;
|
|
127
|
-
node.lastCleanEpoch = epoch;
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Propagate a dirty notification to live consumers of this producer.
|
|
131
|
-
*/
|
|
132
|
-
export function producerNotifyConsumers(node) {
|
|
133
|
-
if (node.liveConsumerNode === undefined) {
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
136
|
-
// Prevent signal reads when we're updating the graph
|
|
137
|
-
const prev = inNotificationPhase;
|
|
138
|
-
inNotificationPhase = true;
|
|
139
|
-
try {
|
|
140
|
-
for (const consumer of node.liveConsumerNode) {
|
|
141
|
-
if (!consumer.dirty) {
|
|
142
|
-
consumerMarkDirty(consumer);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
finally {
|
|
147
|
-
inNotificationPhase = prev;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* Whether this `ReactiveNode` in its producer capacity is currently allowed to initiate updates,
|
|
152
|
-
* based on the current consumer context.
|
|
153
|
-
*/
|
|
154
|
-
export function producerUpdatesAllowed() {
|
|
155
|
-
return activeConsumer?.consumerAllowSignalWrites !== false;
|
|
156
|
-
}
|
|
157
|
-
export function consumerMarkDirty(node) {
|
|
158
|
-
node.dirty = true;
|
|
159
|
-
producerNotifyConsumers(node);
|
|
160
|
-
node.consumerMarkedDirty?.(node);
|
|
161
|
-
}
|
|
162
|
-
/**
|
|
163
|
-
* Prepare this consumer to run a computation in its reactive context.
|
|
164
|
-
*
|
|
165
|
-
* Must be called by subclasses which represent reactive computations, before those computations
|
|
166
|
-
* begin.
|
|
167
|
-
*/
|
|
168
|
-
export function consumerBeforeComputation(node) {
|
|
169
|
-
node && (node.nextProducerIndex = 0);
|
|
170
|
-
return setActiveConsumer(node);
|
|
171
|
-
}
|
|
172
|
-
/**
|
|
173
|
-
* Finalize this consumer's state after a reactive computation has run.
|
|
174
|
-
*
|
|
175
|
-
* Must be called by subclasses which represent reactive computations, after those computations
|
|
176
|
-
* have finished.
|
|
177
|
-
*/
|
|
178
|
-
export function consumerAfterComputation(node, prevConsumer) {
|
|
179
|
-
setActiveConsumer(prevConsumer);
|
|
180
|
-
if (!node ||
|
|
181
|
-
node.producerNode === undefined ||
|
|
182
|
-
node.producerIndexOfThis === undefined ||
|
|
183
|
-
node.producerLastReadVersion === undefined) {
|
|
184
|
-
return;
|
|
185
|
-
}
|
|
186
|
-
if (consumerIsLive(node)) {
|
|
187
|
-
// For live consumers, we need to remove the producer -> consumer edge for any stale producers
|
|
188
|
-
// which weren't dependencies after the recomputation.
|
|
189
|
-
for (let i = node.nextProducerIndex; i < node.producerNode.length; i++) {
|
|
190
|
-
producerRemoveLiveConsumerAtIndex(node.producerNode[i], node.producerIndexOfThis[i]);
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
// Truncate the producer tracking arrays.
|
|
194
|
-
// Perf note: this is essentially truncating the length to `node.nextProducerIndex`, but
|
|
195
|
-
// benchmarking has shown that individual pop operations are faster.
|
|
196
|
-
while (node.producerNode.length > node.nextProducerIndex) {
|
|
197
|
-
node.producerNode.pop();
|
|
198
|
-
node.producerLastReadVersion.pop();
|
|
199
|
-
node.producerIndexOfThis.pop();
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
/**
|
|
203
|
-
* Determine whether this consumer has any dependencies which have changed since the last time
|
|
204
|
-
* they were read.
|
|
205
|
-
*/
|
|
206
|
-
export function consumerPollProducersForChange(node) {
|
|
207
|
-
assertConsumerNode(node);
|
|
208
|
-
// Poll producers for change.
|
|
209
|
-
for (let i = 0; i < node.producerNode.length; i++) {
|
|
210
|
-
const producer = node.producerNode[i];
|
|
211
|
-
const seenVersion = node.producerLastReadVersion[i];
|
|
212
|
-
// First check the versions. A mismatch means that the producer's value is known to have
|
|
213
|
-
// changed since the last time we read it.
|
|
214
|
-
if (seenVersion !== producer.version) {
|
|
215
|
-
return true;
|
|
216
|
-
}
|
|
217
|
-
// The producer's version is the same as the last time we read it, but it might itself be
|
|
218
|
-
// stale. Force the producer to recompute its version (calculating a new value if necessary).
|
|
219
|
-
producerUpdateValueVersion(producer);
|
|
220
|
-
// Now when we do this check, `producer.version` is guaranteed to be up to date, so if the
|
|
221
|
-
// versions still match then it has not changed since the last time we read it.
|
|
222
|
-
if (seenVersion !== producer.version) {
|
|
223
|
-
return true;
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
return false;
|
|
227
|
-
}
|
|
228
|
-
/**
|
|
229
|
-
* Disconnect this consumer from the graph.
|
|
230
|
-
*/
|
|
231
|
-
export function consumerDestroy(node) {
|
|
232
|
-
assertConsumerNode(node);
|
|
233
|
-
if (consumerIsLive(node)) {
|
|
234
|
-
// Drop all connections from the graph to this node.
|
|
235
|
-
for (let i = 0; i < node.producerNode.length; i++) {
|
|
236
|
-
producerRemoveLiveConsumerAtIndex(node.producerNode[i], node.producerIndexOfThis[i]);
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
// Truncate all the arrays to drop all connection from this node to the graph.
|
|
240
|
-
node.producerNode.length =
|
|
241
|
-
node.producerLastReadVersion.length =
|
|
242
|
-
node.producerIndexOfThis.length =
|
|
243
|
-
0;
|
|
244
|
-
if (node.liveConsumerNode) {
|
|
245
|
-
node.liveConsumerNode.length = node.liveConsumerIndexOfThis.length = 0;
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
/**
|
|
249
|
-
* Add `consumer` as a live consumer of this node.
|
|
250
|
-
*
|
|
251
|
-
* Note that this operation is potentially transitive. If this node becomes live, then it becomes
|
|
252
|
-
* a live consumer of all of its current producers.
|
|
253
|
-
*/
|
|
254
|
-
function producerAddLiveConsumer(node, consumer, indexOfThis) {
|
|
255
|
-
assertProducerNode(node);
|
|
256
|
-
if (node.liveConsumerNode.length === 0 && isConsumerNode(node)) {
|
|
257
|
-
// When going from 0 to 1 live consumers, we become a live consumer to our producers.
|
|
258
|
-
for (let i = 0; i < node.producerNode.length; i++) {
|
|
259
|
-
node.producerIndexOfThis[i] = producerAddLiveConsumer(node.producerNode[i], node, i);
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
node.liveConsumerIndexOfThis.push(indexOfThis);
|
|
263
|
-
return node.liveConsumerNode.push(consumer) - 1;
|
|
264
|
-
}
|
|
265
|
-
/**
|
|
266
|
-
* Remove the live consumer at `idx`.
|
|
267
|
-
*/
|
|
268
|
-
function producerRemoveLiveConsumerAtIndex(node, idx) {
|
|
269
|
-
assertProducerNode(node);
|
|
270
|
-
if (idx >= node.liveConsumerNode.length) {
|
|
271
|
-
throw new Error(`Assertion error: active consumer index ${idx} is out of bounds of ${node.liveConsumerNode.length} consumers)`);
|
|
272
|
-
}
|
|
273
|
-
if (node.liveConsumerNode.length === 1 && isConsumerNode(node)) {
|
|
274
|
-
// When removing the last live consumer, we will no longer be live. We need to remove
|
|
275
|
-
// ourselves from our producers' tracking (which may cause consumer-producers to lose
|
|
276
|
-
// liveness as well).
|
|
277
|
-
for (let i = 0; i < node.producerNode.length; i++) {
|
|
278
|
-
producerRemoveLiveConsumerAtIndex(node.producerNode[i], node.producerIndexOfThis[i]);
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
// Move the last value of `liveConsumers` into `idx`. Note that if there's only a single
|
|
282
|
-
// live consumer, this is a no-op.
|
|
283
|
-
const lastIdx = node.liveConsumerNode.length - 1;
|
|
284
|
-
node.liveConsumerNode[idx] = node.liveConsumerNode[lastIdx];
|
|
285
|
-
node.liveConsumerIndexOfThis[idx] = node.liveConsumerIndexOfThis[lastIdx];
|
|
286
|
-
// Truncate the array.
|
|
287
|
-
node.liveConsumerNode.length--;
|
|
288
|
-
node.liveConsumerIndexOfThis.length--;
|
|
289
|
-
// If the index is still valid, then we need to fix the index pointer from the producer to this
|
|
290
|
-
// consumer, and update it from `lastIdx` to `idx` (accounting for the move above).
|
|
291
|
-
if (idx < node.liveConsumerNode.length) {
|
|
292
|
-
const idxProducer = node.liveConsumerIndexOfThis[idx];
|
|
293
|
-
const consumer = node.liveConsumerNode[idx];
|
|
294
|
-
assertConsumerNode(consumer);
|
|
295
|
-
consumer.producerIndexOfThis[idxProducer] = idx;
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
function consumerIsLive(node) {
|
|
299
|
-
return node.consumerIsAlwaysLive || (node?.liveConsumerNode?.length ?? 0) > 0;
|
|
300
|
-
}
|
|
301
|
-
function assertConsumerNode(node) {
|
|
302
|
-
node.producerNode ??= [];
|
|
303
|
-
node.producerIndexOfThis ??= [];
|
|
304
|
-
node.producerLastReadVersion ??= [];
|
|
305
|
-
}
|
|
306
|
-
function assertProducerNode(node) {
|
|
307
|
-
node.liveConsumerNode ??= [];
|
|
308
|
-
node.liveConsumerIndexOfThis ??= [];
|
|
309
|
-
}
|
|
310
|
-
function isConsumerNode(node) {
|
|
311
|
-
return node.producerNode !== undefined;
|
|
312
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { type Signal } from './api.js';
|
|
2
|
-
import type { ValueEqualityFn } from './equality.js';
|
|
3
|
-
import { type SignalGetter } from './signal.js';
|
|
4
|
-
/**
|
|
5
|
-
* @license
|
|
6
|
-
* Copyright Google LLC All Rights Reserved.
|
|
7
|
-
*
|
|
8
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
9
|
-
* found in the LICENSE file at https://angular.io/license
|
|
10
|
-
*/
|
|
11
|
-
/**
|
|
12
|
-
* A `Signal` with a value that can be mutated via a setter interface.
|
|
13
|
-
*/
|
|
14
|
-
export interface WritableSignal<T> extends Signal<T> {
|
|
15
|
-
/**
|
|
16
|
-
* Directly set the signal to a new value, and notify any dependents.
|
|
17
|
-
*/
|
|
18
|
-
set(value: T): void;
|
|
19
|
-
/**
|
|
20
|
-
* Update the value of the signal based on its current value, and
|
|
21
|
-
* notify any dependents.
|
|
22
|
-
*/
|
|
23
|
-
update(updateFn: (value: T) => T): void;
|
|
24
|
-
/**
|
|
25
|
-
* Returns a readonly version of this signal. Readonly signals can be accessed to read their value
|
|
26
|
-
* but can't be changed using set or update methods. The readonly signals do _not_ have
|
|
27
|
-
* any built-in mechanism that would prevent deep-mutation of their value.
|
|
28
|
-
*/
|
|
29
|
-
asReadonly(): Signal<T>;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Options passed to the `signal` creation function.
|
|
33
|
-
*/
|
|
34
|
-
export interface CreateSignalOptions<T> {
|
|
35
|
-
/**
|
|
36
|
-
* A comparison function which defines equality for signal values.
|
|
37
|
-
*/
|
|
38
|
-
equal?: ValueEqualityFn<T>;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Create a `Signal` that can be set or updated directly.
|
|
42
|
-
*/
|
|
43
|
-
export declare function signal<T>(initialValue: T, options?: CreateSignalOptions<T>): WritableSignal<T>;
|
|
44
|
-
export declare function signalAsReadonlyFn<T>(this: SignalGetter<T>): Signal<T>;
|
|
45
|
-
/**
|
|
46
|
-
* Checks if the given `value` is a writeable signal.
|
|
47
|
-
*/
|
|
48
|
-
export declare function isWritableSignal(value: unknown): value is WritableSignal<unknown>;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { SIGNAL } from '../symbol.js';
|
|
2
|
-
import { isSignal } from './api.js';
|
|
3
|
-
import { createSignal, signalSetFn, signalUpdateFn } from './signal.js';
|
|
4
|
-
/**
|
|
5
|
-
* Create a `Signal` that can be set or updated directly.
|
|
6
|
-
*/
|
|
7
|
-
export function signal(initialValue, options) {
|
|
8
|
-
const signalFn = createSignal(initialValue);
|
|
9
|
-
const node = signalFn[SIGNAL];
|
|
10
|
-
if (options?.equal) {
|
|
11
|
-
node.equal = options.equal;
|
|
12
|
-
}
|
|
13
|
-
signalFn.set = (newValue) => signalSetFn(node, newValue);
|
|
14
|
-
signalFn.update = (updateFn) => signalUpdateFn(node, updateFn);
|
|
15
|
-
signalFn.asReadonly = signalAsReadonlyFn.bind(signalFn);
|
|
16
|
-
return signalFn;
|
|
17
|
-
}
|
|
18
|
-
export function signalAsReadonlyFn() {
|
|
19
|
-
const node = this[SIGNAL];
|
|
20
|
-
if (node.readonlyFn === undefined) {
|
|
21
|
-
const readonlyFn = () => this();
|
|
22
|
-
readonlyFn[SIGNAL] = node;
|
|
23
|
-
node.readonlyFn = readonlyFn;
|
|
24
|
-
}
|
|
25
|
-
return node.readonlyFn;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Checks if the given `value` is a writeable signal.
|
|
29
|
-
*/
|
|
30
|
-
export function isWritableSignal(value) {
|
|
31
|
-
return isSignal(value) && typeof value.set === 'function';
|
|
32
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|