@tstdl/base 0.84.4 → 0.84.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tstdl/base",
3
- "version": "0.84.4",
3
+ "version": "0.84.5",
4
4
  "author": "Patrick Hein",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -20,6 +20,7 @@
20
20
  "tsc-alias:watch": "tsc-alias --watch"
21
21
  },
22
22
  "dependencies": {
23
+ "@angular/core": "^16.0.0",
23
24
  "luxon": "^3.3",
24
25
  "reflect-metadata": "^0.1",
25
26
  "rxjs": "^7.8",
@@ -0,0 +1,14 @@
1
+ import type * as Types from './implementation/index.js';
2
+ export type { CreateComputedOptions, CreateEffectOptions, CreateSignalOptions, EffectRef, Signal, WritableSignal } from './implementation/index.js';
3
+ export type SignalsConfiguration = {
4
+ signal: typeof Types.signal;
5
+ computed: typeof Types.computed;
6
+ effect: typeof Types.effect;
7
+ untracked: typeof Types.untracked;
8
+ isSignal: typeof Types.isSignal;
9
+ };
10
+ export declare let signal: typeof Types.signal;
11
+ export declare let computed: typeof Types.computed;
12
+ export declare let effect: typeof Types.effect;
13
+ export declare let untracked: typeof Types.untracked;
14
+ export declare let isSignal: typeof Types.isSignal;
package/signals/api.js ADDED
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var api_exports = {};
30
+ __export(api_exports, {
31
+ computed: () => computed,
32
+ effect: () => effect,
33
+ isSignal: () => isSignal,
34
+ signal: () => signal,
35
+ untracked: () => untracked
36
+ });
37
+ module.exports = __toCommonJS(api_exports);
38
+ var AngularCore = __toESM(require("@angular/core"), 1);
39
+ let signal;
40
+ let computed;
41
+ let effect;
42
+ let untracked;
43
+ let isSignal;
44
+ function configureSignals(configuration) {
45
+ signal = configuration.signal;
46
+ computed = configuration.computed;
47
+ effect = configuration.effect;
48
+ untracked = configuration.untracked;
49
+ isSignal = configuration.isSignal;
50
+ }
51
+ configureSignals({
52
+ signal: AngularCore.signal,
53
+ computed: AngularCore.computed,
54
+ effect: AngularCore.effect,
55
+ untracked: AngularCore.untracked,
56
+ isSignal: AngularCore.isSignal
57
+ });
@@ -0,0 +1,62 @@
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.io/license
7
+ */
8
+ import type { ReactiveNode } from './graph.js';
9
+ /**
10
+ * Symbol used to tell `Signal`s apart from other functions.
11
+ *
12
+ * This can be used to auto-unwrap signals in various cases, or to auto-wrap non-signal values.
13
+ */
14
+ declare const SIGNAL: unique symbol;
15
+ /**
16
+ * A reactive value which notifies consumers of any changes.
17
+ *
18
+ * Signals are functions which returns their current value. To access the current value of a signal,
19
+ * call it.
20
+ *
21
+ * Ordinary values can be turned into `Signal`s with the `signal` function.
22
+ */
23
+ export interface Signal<T> {
24
+ (): T;
25
+ [SIGNAL]?: unknown;
26
+ }
27
+ /**
28
+ * Checks if the given `value` function is a reactive `Signal`.
29
+ */
30
+ export declare function isSignal(value: Function): value is Signal<unknown>;
31
+ /**
32
+ * Converts `fn` into a marked signal function (where `isSignal(fn)` will be `true`).
33
+ *
34
+ * @param fn A zero-argument function which will be converted into a `Signal`.
35
+ */
36
+ export declare function createSignalFromFunction<T>(node: ReactiveNode, fn: () => T): Signal<T>;
37
+ /**
38
+ * Converts `fn` into a marked signal function (where `isSignal(fn)` will be `true`), and
39
+ * potentially add some set of extra properties (passed as an object record `extraApi`).
40
+ *
41
+ * @param fn A zero-argument function which will be converted into a `Signal`.
42
+ * @param extraApi An object whose properties will be copied onto `fn` in order to create a specific
43
+ * desired interface for the `Signal`.
44
+ */
45
+ export declare function createSignalFromFunction<T, U extends Record<string, unknown>>(node: ReactiveNode, fn: () => T, extraApi: U): Signal<T> & U;
46
+ /**
47
+ * A comparison function which can determine if two values are equal.
48
+ *
49
+ * @developerPreview
50
+ */
51
+ export type ValueEqualityFn<T> = (a: T, b: T) => boolean;
52
+ /**
53
+ * The default equality function used for `signal` and `computed`, which treats objects and arrays
54
+ * as never equal, and all other primitive values using identity semantics.
55
+ *
56
+ * This allows signals to hold non-primitive values (arrays, objects, other collections) and still
57
+ * propagate change notification upon explicit mutation without identity change.
58
+ *
59
+ * @developerPreview
60
+ */
61
+ export declare function defaultEquals<T>(a: T, b: T): boolean;
62
+ export {};
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var api_exports = {};
20
+ __export(api_exports, {
21
+ createSignalFromFunction: () => createSignalFromFunction,
22
+ defaultEquals: () => defaultEquals,
23
+ isSignal: () => isSignal
24
+ });
25
+ module.exports = __toCommonJS(api_exports);
26
+ /**
27
+ * @license
28
+ * Copyright Google LLC All Rights Reserved.
29
+ *
30
+ * Use of this source code is governed by an MIT-style license that can be
31
+ * found in the LICENSE file at https://angular.io/license
32
+ */
33
+ const SIGNAL = Symbol("SIGNAL");
34
+ function isSignal(value) {
35
+ return value[SIGNAL] !== void 0;
36
+ }
37
+ function createSignalFromFunction(node, fn, extraApi = {}) {
38
+ fn[SIGNAL] = node;
39
+ return Object.assign(fn, extraApi);
40
+ }
41
+ function defaultEquals(a, b) {
42
+ return (a === null || typeof a !== "object") && Object.is(a, b);
43
+ }
@@ -0,0 +1,26 @@
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.io/license
7
+ */
8
+ import type { Signal, ValueEqualityFn } from './api.js';
9
+ /**
10
+ * Options passed to the `computed` creation function.
11
+ *
12
+ * @developerPreview
13
+ */
14
+ export interface CreateComputedOptions<T> {
15
+ /**
16
+ * A comparison function which defines equality for computed values.
17
+ */
18
+ equal?: ValueEqualityFn<T>;
19
+ additionalDependencies?: Signal<any>[];
20
+ }
21
+ /**
22
+ * Create a computed `Signal` which derives a reactive value from an expression.
23
+ *
24
+ * @developerPreview
25
+ */
26
+ export declare function computed<T>(computation: () => T, options?: CreateComputedOptions<T>): Signal<T>;
@@ -0,0 +1,125 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var computed_exports = {};
20
+ __export(computed_exports, {
21
+ computed: () => computed
22
+ });
23
+ module.exports = __toCommonJS(computed_exports);
24
+ var import_type_guards = require("../../utils/type-guards.js");
25
+ var import_api = require("./api.js");
26
+ var import_graph = require("./graph.js");
27
+ /**
28
+ * @license
29
+ * Copyright Google LLC All Rights Reserved.
30
+ *
31
+ * Use of this source code is governed by an MIT-style license that can be
32
+ * found in the LICENSE file at https://angular.io/license
33
+ */
34
+ function computed(computation, options = {}) {
35
+ const actualComputation = (0, import_type_guards.isUndefined)(options.additionalDependencies) || options.additionalDependencies.length == 0 ? computation : () => {
36
+ for (const dependency of options.additionalDependencies) {
37
+ dependency();
38
+ }
39
+ return computation();
40
+ };
41
+ const node = new ComputedImpl(actualComputation, options.equal ?? import_api.defaultEquals);
42
+ return (0, import_api.createSignalFromFunction)(node, node.signal.bind(node));
43
+ }
44
+ const UNSET = Symbol("UNSET");
45
+ const COMPUTING = Symbol("COMPUTING");
46
+ const ERRORED = Symbol("ERRORED");
47
+ class ComputedImpl extends import_graph.ReactiveNode {
48
+ computation;
49
+ equal;
50
+ constructor(computation, equal) {
51
+ super();
52
+ this.computation = computation;
53
+ this.equal = equal;
54
+ }
55
+ /**
56
+ * Current value of the computation.
57
+ *
58
+ * This can also be one of the special values `UNSET`, `COMPUTING`, or `ERRORED`.
59
+ */
60
+ value = UNSET;
61
+ /**
62
+ * If `value` is `ERRORED`, the error caught from the last computation attempt which will
63
+ * be re-thrown.
64
+ */
65
+ error = null;
66
+ /**
67
+ * Flag indicating that the computation is currently stale, meaning that one of the
68
+ * dependencies has notified of a potential change.
69
+ *
70
+ * It's possible that no dependency has _actually_ changed, in which case the `stale`
71
+ * state can be resolved without recomputing the value.
72
+ */
73
+ stale = true;
74
+ consumerAllowSignalWrites = false;
75
+ onConsumerDependencyMayHaveChanged() {
76
+ if (this.stale) {
77
+ return;
78
+ }
79
+ this.stale = true;
80
+ this.producerMayHaveChanged();
81
+ }
82
+ onProducerUpdateValueVersion() {
83
+ if (!this.stale) {
84
+ return;
85
+ }
86
+ if (this.value !== UNSET && this.value !== COMPUTING && !this.consumerPollProducersForChange()) {
87
+ this.stale = false;
88
+ return;
89
+ }
90
+ this.recomputeValue();
91
+ }
92
+ recomputeValue() {
93
+ if (this.value === COMPUTING) {
94
+ throw new Error("Detected cycle in computations.");
95
+ }
96
+ const oldValue = this.value;
97
+ this.value = COMPUTING;
98
+ this.trackingVersion++;
99
+ const prevConsumer = (0, import_graph.setActiveConsumer)(this);
100
+ let newValue;
101
+ try {
102
+ newValue = this.computation();
103
+ } catch (err) {
104
+ newValue = ERRORED;
105
+ this.error = err;
106
+ } finally {
107
+ (0, import_graph.setActiveConsumer)(prevConsumer);
108
+ }
109
+ this.stale = false;
110
+ if (oldValue !== UNSET && oldValue !== ERRORED && newValue !== ERRORED && this.equal(oldValue, newValue)) {
111
+ this.value = oldValue;
112
+ return;
113
+ }
114
+ this.value = newValue;
115
+ this.valueVersion++;
116
+ }
117
+ signal() {
118
+ this.onProducerUpdateValueVersion();
119
+ this.producerAccessed();
120
+ if (this.value === ERRORED) {
121
+ throw this.error;
122
+ }
123
+ return this.value;
124
+ }
125
+ }
@@ -0,0 +1,54 @@
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.io/license
7
+ */
8
+ /**
9
+ * A global reactive effect, which can be manually destroyed.
10
+ */
11
+ export interface EffectRef {
12
+ /**
13
+ * Shut down the effect, removing it from any upcoming scheduled executions.
14
+ */
15
+ destroy(): void;
16
+ }
17
+ /**
18
+ * An effect can, optionally, register a cleanup function. If registered, the cleanup is executed
19
+ * before the next effect run. The cleanup function makes it possible to "cancel" any work that the
20
+ * previous effect run might have started.
21
+ */
22
+ export type EffectCleanupFn = () => void;
23
+ /**
24
+ * A callback passed to the effect function that makes it possible to register cleanup logic.
25
+ */
26
+ export type EffectCleanupRegisterFn = (cleanupFn: EffectCleanupFn) => void;
27
+ export type CreateEffectOptions = {
28
+ /**
29
+ * Whether the `effect` should allow writing to signals.
30
+ *
31
+ * Using effects to synchronize data by writing to signals can lead to confusing and potentially
32
+ * incorrect behavior, and should be enabled only when necessary.
33
+ */
34
+ allowSignalWrites?: boolean;
35
+ /**
36
+ * Immediately run effect after creation without scheduling - for advanced use cases.
37
+ */
38
+ runImmediately?: boolean;
39
+ };
40
+ /**
41
+ * Tracks all effects registered within a given application and runs them via `flush`.
42
+ */
43
+ export declare class EffectManager {
44
+ private readonly all;
45
+ private readonly queue;
46
+ private pendingFlush;
47
+ create(effectFn: (onCleanup: (cleanupFn: EffectCleanupFn) => void) => void, { allowSignalWrites, runImmediately }?: CreateEffectOptions): EffectRef;
48
+ flush(): void;
49
+ get isQueueEmpty(): boolean;
50
+ }
51
+ /**
52
+ * Create a global `Effect` for the given reactive function.
53
+ */
54
+ export declare function effect(effectFn: (onCleanup: EffectCleanupRegisterFn) => void, options?: CreateEffectOptions): EffectRef;
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var effect_exports = {};
20
+ __export(effect_exports, {
21
+ EffectManager: () => EffectManager,
22
+ effect: () => effect
23
+ });
24
+ module.exports = __toCommonJS(effect_exports);
25
+ var import_watch = require("./watch.js");
26
+ /**
27
+ * @license
28
+ * Copyright Google LLC All Rights Reserved.
29
+ *
30
+ * Use of this source code is governed by an MIT-style license that can be
31
+ * found in the LICENSE file at https://angular.io/license
32
+ */
33
+ class EffectManager {
34
+ all = /* @__PURE__ */ new Set();
35
+ queue = /* @__PURE__ */ new Set();
36
+ pendingFlush;
37
+ create(effectFn, { allowSignalWrites = false, runImmediately = false } = {}) {
38
+ const watch = new import_watch.Watch(effectFn, (watch2) => {
39
+ if (!this.all.has(watch2)) {
40
+ return;
41
+ }
42
+ this.queue.add(watch2);
43
+ if (!this.pendingFlush) {
44
+ this.pendingFlush = true;
45
+ queueMicrotask(() => {
46
+ this.pendingFlush = false;
47
+ this.flush();
48
+ });
49
+ }
50
+ }, allowSignalWrites);
51
+ this.all.add(watch);
52
+ if (runImmediately) {
53
+ watch.run();
54
+ } else {
55
+ watch.notify();
56
+ }
57
+ const destroy = () => {
58
+ watch.cleanup();
59
+ this.all.delete(watch);
60
+ this.queue.delete(watch);
61
+ };
62
+ return {
63
+ destroy
64
+ };
65
+ }
66
+ flush() {
67
+ if (this.queue.size === 0) {
68
+ return;
69
+ }
70
+ for (const watch of this.queue) {
71
+ this.queue.delete(watch);
72
+ watch.run();
73
+ }
74
+ }
75
+ get isQueueEmpty() {
76
+ return this.queue.size === 0;
77
+ }
78
+ }
79
+ const effectManager = new EffectManager();
80
+ function effect(effectFn, options) {
81
+ return effectManager.create(effectFn, options);
82
+ }
@@ -0,0 +1,9 @@
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.io/license
7
+ */
8
+ export declare function throwInvalidWriteToSignalError(): void;
9
+ export declare function setThrowInvalidWriteToSignalError(fn: () => never): void;
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var errors_exports = {};
20
+ __export(errors_exports, {
21
+ setThrowInvalidWriteToSignalError: () => setThrowInvalidWriteToSignalError,
22
+ throwInvalidWriteToSignalError: () => throwInvalidWriteToSignalError
23
+ });
24
+ module.exports = __toCommonJS(errors_exports);
25
+ /**
26
+ * @license
27
+ * Copyright Google LLC All Rights Reserved.
28
+ *
29
+ * Use of this source code is governed by an MIT-style license that can be
30
+ * found in the LICENSE file at https://angular.io/license
31
+ */
32
+ function defaultThrowError() {
33
+ throw new Error();
34
+ }
35
+ let throwInvalidWriteToSignalErrorFn = defaultThrowError;
36
+ function throwInvalidWriteToSignalError() {
37
+ throwInvalidWriteToSignalErrorFn();
38
+ }
39
+ function setThrowInvalidWriteToSignalError(fn) {
40
+ throwInvalidWriteToSignalErrorFn = fn;
41
+ }
@@ -0,0 +1,108 @@
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.io/license
7
+ */
8
+ export declare function setActiveConsumer(consumer: ReactiveNode | null): ReactiveNode | null;
9
+ /**
10
+ * A node in the reactive graph.
11
+ *
12
+ * Nodes can be producers of reactive values, consumers of other reactive values, or both.
13
+ *
14
+ * Producers are nodes that produce values, and can be depended upon by consumer nodes.
15
+ *
16
+ * Producers expose a monotonic `valueVersion` counter, and are responsible for incrementing this
17
+ * version when their value semantically changes. Some producers may produce their values lazily and
18
+ * thus at times need to be polled for potential updates to their value (and by extension their
19
+ * `valueVersion`). This is accomplished via the `onProducerUpdateValueVersion` method for
20
+ * implemented by producers, which should perform whatever calculations are necessary to ensure
21
+ * `valueVersion` is up to date.
22
+ *
23
+ * Consumers are nodes that depend on the values of producers and are notified when those values
24
+ * might have changed.
25
+ *
26
+ * Consumers do not wrap the reads they consume themselves, but rather can be set as the active
27
+ * reader via `setActiveConsumer`. Reads of producers that happen while a consumer is active will
28
+ * result in those producers being added as dependencies of that consumer node.
29
+ *
30
+ * The set of dependencies of a consumer is dynamic. Implementers expose a monotonically increasing
31
+ * `trackingVersion` counter, which increments whenever the consumer is about to re-run any reactive
32
+ * reads it needs and establish a new set of dependencies as a result.
33
+ *
34
+ * Producers store the last `trackingVersion` they've seen from `Consumer`s which have read them.
35
+ * This allows a producer to identify whether its record of the dependency is current or stale, by
36
+ * comparing the consumer's `trackingVersion` to the version at which the dependency was
37
+ * last observed.
38
+ */
39
+ export declare abstract class ReactiveNode {
40
+ private readonly id;
41
+ /**
42
+ * A cached weak reference to this node, which will be used in `ReactiveEdge`s.
43
+ */
44
+ private readonly ref;
45
+ /**
46
+ * Edges to producers on which this node depends (in its consumer capacity).
47
+ */
48
+ private readonly producers;
49
+ /**
50
+ * Edges to consumers on which this node depends (in its producer capacity).
51
+ */
52
+ private readonly consumers;
53
+ /**
54
+ * Monotonically increasing counter representing a version of this `Consumer`'s
55
+ * dependencies.
56
+ */
57
+ protected trackingVersion: number;
58
+ /**
59
+ * Monotonically increasing counter which increases when the value of this `Producer`
60
+ * semantically changes.
61
+ */
62
+ protected valueVersion: number;
63
+ /**
64
+ * Whether signal writes should be allowed while this `ReactiveNode` is the current consumer.
65
+ */
66
+ protected abstract readonly consumerAllowSignalWrites: boolean;
67
+ /**
68
+ * Called for consumers whenever one of their dependencies notifies that it might have a new
69
+ * value.
70
+ */
71
+ protected abstract onConsumerDependencyMayHaveChanged(): void;
72
+ /**
73
+ * Called for producers when a dependent consumer is checking if the producer's value has actually
74
+ * changed.
75
+ */
76
+ protected abstract onProducerUpdateValueVersion(): void;
77
+ /**
78
+ * Polls dependencies of a consumer to determine if they have actually changed.
79
+ *
80
+ * If this returns `false`, then even though the consumer may have previously been notified of a
81
+ * change, the values of its dependencies have not actually changed and the consumer should not
82
+ * rerun any reactions.
83
+ */
84
+ protected consumerPollProducersForChange(): boolean;
85
+ /**
86
+ * Notify all consumers of this producer that its value may have changed.
87
+ */
88
+ protected producerMayHaveChanged(): void;
89
+ /**
90
+ * Mark that this producer node has been accessed in the current reactive context.
91
+ */
92
+ protected producerAccessed(): void;
93
+ /**
94
+ * Whether this consumer currently has any producers registered.
95
+ */
96
+ protected get hasProducers(): boolean;
97
+ /**
98
+ * Whether this `ReactiveNode` in its producer capacity is currently allowed to initiate updates,
99
+ * based on the current consumer context.
100
+ */
101
+ protected get producerUpdatesAllowed(): boolean;
102
+ /**
103
+ * Checks if a `Producer` has a current value which is different than the value
104
+ * last seen at a specific version by a `Consumer` which recorded a dependency on
105
+ * this `Producer`.
106
+ */
107
+ private producerPollStatus;
108
+ }