@angular/core 20.0.0-next.2 → 20.0.0-next.4

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.
Files changed (56) hide show
  1. package/event_dispatcher.d-pVP0-wST.d.ts +345 -0
  2. package/fesm2022/core.mjs +614 -428
  3. package/fesm2022/core.mjs.map +1 -1
  4. package/fesm2022/injector-BlLwZ2sr.mjs +24 -0
  5. package/fesm2022/injector-BlLwZ2sr.mjs.map +1 -0
  6. package/fesm2022/primitives/di.mjs +5 -18
  7. package/fesm2022/primitives/di.mjs.map +1 -1
  8. package/fesm2022/primitives/event-dispatch.mjs +1 -1
  9. package/fesm2022/primitives/signals.mjs +4 -589
  10. package/fesm2022/primitives/signals.mjs.map +1 -1
  11. package/fesm2022/rxjs-interop.mjs +1 -8
  12. package/fesm2022/rxjs-interop.mjs.map +1 -1
  13. package/fesm2022/testing.mjs +2 -10
  14. package/fesm2022/testing.mjs.map +1 -1
  15. package/fesm2022/untracked-DkcXpNb_.mjs +620 -0
  16. package/fesm2022/untracked-DkcXpNb_.mjs.map +1 -0
  17. package/index.d.ts +7589 -7510
  18. package/{navigation_types.d-u4EOrrdZ.d.ts → navigation_types.d-DgDrF5rp.d.ts} +2 -2
  19. package/package.json +2 -2
  20. package/primitives/di/index.d.ts +25 -10
  21. package/primitives/event-dispatch/index.d.ts +5 -340
  22. package/primitives/signals/index.d.ts +5 -208
  23. package/rxjs-interop/index.d.ts +1 -10
  24. package/schematics/bundles/{apply_import_manager-CyRT0UvU.js → apply_import_manager-CeNv8GIG.js} +6 -6
  25. package/schematics/bundles/{checker-DF8ZaFW5.js → checker-k591b6WQ.js} +856 -180
  26. package/schematics/bundles/cleanup-unused-imports.js +42 -69
  27. package/schematics/bundles/{compiler_host-Da636uJ8.js → compiler_host-DwM3ugW3.js} +2 -2
  28. package/schematics/bundles/control-flow-migration.js +34 -13
  29. package/schematics/bundles/imports-CIX-JgAN.js +1 -1
  30. package/schematics/bundles/{program-BZk27Ndu.js → index-B4OAlHh8.js} +2234 -2097
  31. package/schematics/bundles/{index-DnkWgagp.js → index-BhELUmYx.js} +11 -11
  32. package/schematics/bundles/inject-flags.js +18 -52
  33. package/schematics/bundles/inject-migration.js +3 -3
  34. package/schematics/bundles/leading_space-D9nQ8UQC.js +1 -1
  35. package/schematics/bundles/{migrate_ts_type_references-DtkOnnv0.js → migrate_ts_type_references-Be0TNYen.js} +20 -20
  36. package/schematics/bundles/ng_decorators-DznZ5jMl.js +1 -1
  37. package/schematics/bundles/nodes-B16H9JUd.js +1 -1
  38. package/schematics/bundles/output-migration.js +62 -90
  39. package/schematics/bundles/project_tsconfig_paths-CDVxT6Ov.js +1 -1
  40. package/schematics/bundles/property_name-BBwFuqMe.js +1 -1
  41. package/schematics/bundles/route-lazy-loading.js +3 -3
  42. package/schematics/bundles/{project_paths-Jtbi76Bs.js → run_in_devkit-CkvEksWP.js} +262 -197
  43. package/schematics/bundles/self-closing-tags-migration.js +41 -71
  44. package/schematics/bundles/signal-input-migration.js +69 -97
  45. package/schematics/bundles/signal-queries-migration.js +80 -108
  46. package/schematics/bundles/signals.js +11 -11
  47. package/schematics/bundles/standalone-migration.js +8 -22
  48. package/schematics/bundles/symbol-VPWguRxr.js +25 -0
  49. package/schematics/bundles/test-bed-get.js +98 -0
  50. package/schematics/migrations.json +5 -0
  51. package/testing/index.d.ts +2 -4
  52. package/weak_ref.d-BZ7gyRag.d.ts +216 -0
  53. package/fesm2022/weak_ref-DrMdAIDh.mjs +0 -12
  54. package/fesm2022/weak_ref-DrMdAIDh.mjs.map +0 -1
  55. package/schematics/bundles/index-vGJcp5M7.js +0 -30
  56. package/weak_ref.d-ttyj86RV.d.ts +0 -9
@@ -0,0 +1,620 @@
1
+ /**
2
+ * @license Angular v20.0.0-next.4
3
+ * (c) 2010-2025 Google LLC. https://angular.io/
4
+ * License: MIT
5
+ */
6
+
7
+ /**
8
+ * The default equality function used for `signal` and `computed`, which uses referential equality.
9
+ */
10
+ function defaultEquals(a, b) {
11
+ return Object.is(a, b);
12
+ }
13
+
14
+ /**
15
+ * The currently active consumer `ReactiveNode`, if running code in a reactive context.
16
+ *
17
+ * Change this via `setActiveConsumer`.
18
+ */
19
+ let activeConsumer = null;
20
+ let inNotificationPhase = false;
21
+ /**
22
+ * Global epoch counter. Incremented whenever a source signal is set.
23
+ */
24
+ let epoch = 1;
25
+ /**
26
+ * If set, called after a producer `ReactiveNode` is created.
27
+ */
28
+ let postProducerCreatedFn = null;
29
+ /**
30
+ * Symbol used to tell `Signal`s apart from other functions.
31
+ *
32
+ * This can be used to auto-unwrap signals in various cases, or to auto-wrap non-signal values.
33
+ */
34
+ const SIGNAL = /* @__PURE__ */ Symbol('SIGNAL');
35
+ function setActiveConsumer(consumer) {
36
+ const prev = activeConsumer;
37
+ activeConsumer = consumer;
38
+ return prev;
39
+ }
40
+ function getActiveConsumer() {
41
+ return activeConsumer;
42
+ }
43
+ function isInNotificationPhase() {
44
+ return inNotificationPhase;
45
+ }
46
+ function isReactive(value) {
47
+ return value[SIGNAL] !== undefined;
48
+ }
49
+ const REACTIVE_NODE = {
50
+ version: 0,
51
+ lastCleanEpoch: 0,
52
+ dirty: false,
53
+ producerNode: undefined,
54
+ producerLastReadVersion: undefined,
55
+ producerIndexOfThis: undefined,
56
+ nextProducerIndex: 0,
57
+ liveConsumerNode: undefined,
58
+ liveConsumerIndexOfThis: undefined,
59
+ consumerAllowSignalWrites: false,
60
+ consumerIsAlwaysLive: false,
61
+ kind: 'unknown',
62
+ producerMustRecompute: () => false,
63
+ producerRecomputeValue: () => { },
64
+ consumerMarkedDirty: () => { },
65
+ consumerOnSignalRead: () => { },
66
+ };
67
+ /**
68
+ * Called by implementations when a producer's signal is read.
69
+ */
70
+ function producerAccessed(node) {
71
+ if (inNotificationPhase) {
72
+ throw new Error(typeof ngDevMode !== 'undefined' && ngDevMode
73
+ ? `Assertion error: signal read during notification phase`
74
+ : '');
75
+ }
76
+ if (activeConsumer === null) {
77
+ // Accessed outside of a reactive context, so nothing to record.
78
+ return;
79
+ }
80
+ activeConsumer.consumerOnSignalRead(node);
81
+ // This producer is the `idx`th dependency of `activeConsumer`.
82
+ const idx = activeConsumer.nextProducerIndex++;
83
+ assertConsumerNode(activeConsumer);
84
+ if (idx < activeConsumer.producerNode.length && activeConsumer.producerNode[idx] !== node) {
85
+ // There's been a change in producers since the last execution of `activeConsumer`.
86
+ // `activeConsumer.producerNode[idx]` holds a stale dependency which will be be removed and
87
+ // replaced with `this`.
88
+ //
89
+ // If `activeConsumer` isn't live, then this is a no-op, since we can replace the producer in
90
+ // `activeConsumer.producerNode` directly. However, if `activeConsumer` is live, then we need
91
+ // to remove it from the stale producer's `liveConsumer`s.
92
+ if (consumerIsLive(activeConsumer)) {
93
+ const staleProducer = activeConsumer.producerNode[idx];
94
+ producerRemoveLiveConsumerAtIndex(staleProducer, activeConsumer.producerIndexOfThis[idx]);
95
+ // At this point, the only record of `staleProducer` is the reference at
96
+ // `activeConsumer.producerNode[idx]` which will be overwritten below.
97
+ }
98
+ }
99
+ if (activeConsumer.producerNode[idx] !== node) {
100
+ // We're a new dependency of the consumer (at `idx`).
101
+ activeConsumer.producerNode[idx] = node;
102
+ // If the active consumer is live, then add it as a live consumer. If not, then use 0 as a
103
+ // placeholder value.
104
+ activeConsumer.producerIndexOfThis[idx] = consumerIsLive(activeConsumer)
105
+ ? producerAddLiveConsumer(node, activeConsumer, idx)
106
+ : 0;
107
+ }
108
+ activeConsumer.producerLastReadVersion[idx] = node.version;
109
+ }
110
+ /**
111
+ * Increment the global epoch counter.
112
+ *
113
+ * Called by source producers (that is, not computeds) whenever their values change.
114
+ */
115
+ function producerIncrementEpoch() {
116
+ epoch++;
117
+ }
118
+ /**
119
+ * Ensure this producer's `version` is up-to-date.
120
+ */
121
+ function producerUpdateValueVersion(node) {
122
+ if (consumerIsLive(node) && !node.dirty) {
123
+ // A live consumer will be marked dirty by producers, so a clean state means that its version
124
+ // is guaranteed to be up-to-date.
125
+ return;
126
+ }
127
+ if (!node.dirty && node.lastCleanEpoch === epoch) {
128
+ // Even non-live consumers can skip polling if they previously found themselves to be clean at
129
+ // the current epoch, since their dependencies could not possibly have changed (such a change
130
+ // would've increased the epoch).
131
+ return;
132
+ }
133
+ if (!node.producerMustRecompute(node) && !consumerPollProducersForChange(node)) {
134
+ // None of our producers report a change since the last time they were read, so no
135
+ // recomputation of our value is necessary, and we can consider ourselves clean.
136
+ producerMarkClean(node);
137
+ return;
138
+ }
139
+ node.producerRecomputeValue(node);
140
+ // After recomputing the value, we're no longer dirty.
141
+ producerMarkClean(node);
142
+ }
143
+ /**
144
+ * Propagate a dirty notification to live consumers of this producer.
145
+ */
146
+ function producerNotifyConsumers(node) {
147
+ if (node.liveConsumerNode === undefined) {
148
+ return;
149
+ }
150
+ // Prevent signal reads when we're updating the graph
151
+ const prev = inNotificationPhase;
152
+ inNotificationPhase = true;
153
+ try {
154
+ for (const consumer of node.liveConsumerNode) {
155
+ if (!consumer.dirty) {
156
+ consumerMarkDirty(consumer);
157
+ }
158
+ }
159
+ }
160
+ finally {
161
+ inNotificationPhase = prev;
162
+ }
163
+ }
164
+ /**
165
+ * Whether this `ReactiveNode` in its producer capacity is currently allowed to initiate updates,
166
+ * based on the current consumer context.
167
+ */
168
+ function producerUpdatesAllowed() {
169
+ return activeConsumer?.consumerAllowSignalWrites !== false;
170
+ }
171
+ function consumerMarkDirty(node) {
172
+ node.dirty = true;
173
+ producerNotifyConsumers(node);
174
+ node.consumerMarkedDirty?.(node);
175
+ }
176
+ function producerMarkClean(node) {
177
+ node.dirty = false;
178
+ node.lastCleanEpoch = epoch;
179
+ }
180
+ /**
181
+ * Prepare this consumer to run a computation in its reactive context.
182
+ *
183
+ * Must be called by subclasses which represent reactive computations, before those computations
184
+ * begin.
185
+ */
186
+ function consumerBeforeComputation(node) {
187
+ node && (node.nextProducerIndex = 0);
188
+ return setActiveConsumer(node);
189
+ }
190
+ /**
191
+ * Finalize this consumer's state after a reactive computation has run.
192
+ *
193
+ * Must be called by subclasses which represent reactive computations, after those computations
194
+ * have finished.
195
+ */
196
+ function consumerAfterComputation(node, prevConsumer) {
197
+ setActiveConsumer(prevConsumer);
198
+ if (!node ||
199
+ node.producerNode === undefined ||
200
+ node.producerIndexOfThis === undefined ||
201
+ node.producerLastReadVersion === undefined) {
202
+ return;
203
+ }
204
+ if (consumerIsLive(node)) {
205
+ // For live consumers, we need to remove the producer -> consumer edge for any stale producers
206
+ // which weren't dependencies after the recomputation.
207
+ for (let i = node.nextProducerIndex; i < node.producerNode.length; i++) {
208
+ producerRemoveLiveConsumerAtIndex(node.producerNode[i], node.producerIndexOfThis[i]);
209
+ }
210
+ }
211
+ // Truncate the producer tracking arrays.
212
+ // Perf note: this is essentially truncating the length to `node.nextProducerIndex`, but
213
+ // benchmarking has shown that individual pop operations are faster.
214
+ while (node.producerNode.length > node.nextProducerIndex) {
215
+ node.producerNode.pop();
216
+ node.producerLastReadVersion.pop();
217
+ node.producerIndexOfThis.pop();
218
+ }
219
+ }
220
+ /**
221
+ * Determine whether this consumer has any dependencies which have changed since the last time
222
+ * they were read.
223
+ */
224
+ function consumerPollProducersForChange(node) {
225
+ assertConsumerNode(node);
226
+ // Poll producers for change.
227
+ for (let i = 0; i < node.producerNode.length; i++) {
228
+ const producer = node.producerNode[i];
229
+ const seenVersion = node.producerLastReadVersion[i];
230
+ // First check the versions. A mismatch means that the producer's value is known to have
231
+ // changed since the last time we read it.
232
+ if (seenVersion !== producer.version) {
233
+ return true;
234
+ }
235
+ // The producer's version is the same as the last time we read it, but it might itself be
236
+ // stale. Force the producer to recompute its version (calculating a new value if necessary).
237
+ producerUpdateValueVersion(producer);
238
+ // Now when we do this check, `producer.version` is guaranteed to be up to date, so if the
239
+ // versions still match then it has not changed since the last time we read it.
240
+ if (seenVersion !== producer.version) {
241
+ return true;
242
+ }
243
+ }
244
+ return false;
245
+ }
246
+ /**
247
+ * Disconnect this consumer from the graph.
248
+ */
249
+ function consumerDestroy(node) {
250
+ assertConsumerNode(node);
251
+ if (consumerIsLive(node)) {
252
+ // Drop all connections from the graph to this node.
253
+ for (let i = 0; i < node.producerNode.length; i++) {
254
+ producerRemoveLiveConsumerAtIndex(node.producerNode[i], node.producerIndexOfThis[i]);
255
+ }
256
+ }
257
+ // Truncate all the arrays to drop all connection from this node to the graph.
258
+ node.producerNode.length =
259
+ node.producerLastReadVersion.length =
260
+ node.producerIndexOfThis.length =
261
+ 0;
262
+ if (node.liveConsumerNode) {
263
+ node.liveConsumerNode.length = node.liveConsumerIndexOfThis.length = 0;
264
+ }
265
+ }
266
+ /**
267
+ * Add `consumer` as a live consumer of this node.
268
+ *
269
+ * Note that this operation is potentially transitive. If this node becomes live, then it becomes
270
+ * a live consumer of all of its current producers.
271
+ */
272
+ function producerAddLiveConsumer(node, consumer, indexOfThis) {
273
+ assertProducerNode(node);
274
+ if (node.liveConsumerNode.length === 0 && isConsumerNode(node)) {
275
+ // When going from 0 to 1 live consumers, we become a live consumer to our producers.
276
+ for (let i = 0; i < node.producerNode.length; i++) {
277
+ node.producerIndexOfThis[i] = producerAddLiveConsumer(node.producerNode[i], node, i);
278
+ }
279
+ }
280
+ node.liveConsumerIndexOfThis.push(indexOfThis);
281
+ return node.liveConsumerNode.push(consumer) - 1;
282
+ }
283
+ /**
284
+ * Remove the live consumer at `idx`.
285
+ */
286
+ function producerRemoveLiveConsumerAtIndex(node, idx) {
287
+ assertProducerNode(node);
288
+ if (typeof ngDevMode !== 'undefined' && ngDevMode && idx >= node.liveConsumerNode.length) {
289
+ throw new Error(`Assertion error: active consumer index ${idx} is out of bounds of ${node.liveConsumerNode.length} consumers)`);
290
+ }
291
+ if (node.liveConsumerNode.length === 1 && isConsumerNode(node)) {
292
+ // When removing the last live consumer, we will no longer be live. We need to remove
293
+ // ourselves from our producers' tracking (which may cause consumer-producers to lose
294
+ // liveness as well).
295
+ for (let i = 0; i < node.producerNode.length; i++) {
296
+ producerRemoveLiveConsumerAtIndex(node.producerNode[i], node.producerIndexOfThis[i]);
297
+ }
298
+ }
299
+ // Move the last value of `liveConsumers` into `idx`. Note that if there's only a single
300
+ // live consumer, this is a no-op.
301
+ const lastIdx = node.liveConsumerNode.length - 1;
302
+ node.liveConsumerNode[idx] = node.liveConsumerNode[lastIdx];
303
+ node.liveConsumerIndexOfThis[idx] = node.liveConsumerIndexOfThis[lastIdx];
304
+ // Truncate the array.
305
+ node.liveConsumerNode.length--;
306
+ node.liveConsumerIndexOfThis.length--;
307
+ // If the index is still valid, then we need to fix the index pointer from the producer to this
308
+ // consumer, and update it from `lastIdx` to `idx` (accounting for the move above).
309
+ if (idx < node.liveConsumerNode.length) {
310
+ const idxProducer = node.liveConsumerIndexOfThis[idx];
311
+ const consumer = node.liveConsumerNode[idx];
312
+ assertConsumerNode(consumer);
313
+ consumer.producerIndexOfThis[idxProducer] = idx;
314
+ }
315
+ }
316
+ function consumerIsLive(node) {
317
+ return node.consumerIsAlwaysLive || (node?.liveConsumerNode?.length ?? 0) > 0;
318
+ }
319
+ function assertConsumerNode(node) {
320
+ node.producerNode ??= [];
321
+ node.producerIndexOfThis ??= [];
322
+ node.producerLastReadVersion ??= [];
323
+ }
324
+ function assertProducerNode(node) {
325
+ node.liveConsumerNode ??= [];
326
+ node.liveConsumerIndexOfThis ??= [];
327
+ }
328
+ function isConsumerNode(node) {
329
+ return node.producerNode !== undefined;
330
+ }
331
+ function runPostProducerCreatedFn(node) {
332
+ postProducerCreatedFn?.(node);
333
+ }
334
+ function setPostProducerCreatedFn(fn) {
335
+ const prev = postProducerCreatedFn;
336
+ postProducerCreatedFn = fn;
337
+ return prev;
338
+ }
339
+
340
+ /**
341
+ * Create a computed signal which derives a reactive value from an expression.
342
+ */
343
+ function createComputed(computation, equal) {
344
+ const node = Object.create(COMPUTED_NODE);
345
+ node.computation = computation;
346
+ if (equal !== undefined) {
347
+ node.equal = equal;
348
+ }
349
+ const computed = () => {
350
+ // Check if the value needs updating before returning it.
351
+ producerUpdateValueVersion(node);
352
+ // Record that someone looked at this signal.
353
+ producerAccessed(node);
354
+ if (node.value === ERRORED) {
355
+ throw node.error;
356
+ }
357
+ return node.value;
358
+ };
359
+ computed[SIGNAL] = node;
360
+ runPostProducerCreatedFn(node);
361
+ return computed;
362
+ }
363
+ /**
364
+ * A dedicated symbol used before a computed value has been calculated for the first time.
365
+ * Explicitly typed as `any` so we can use it as signal's value.
366
+ */
367
+ const UNSET = /* @__PURE__ */ Symbol('UNSET');
368
+ /**
369
+ * A dedicated symbol used in place of a computed signal value to indicate that a given computation
370
+ * is in progress. Used to detect cycles in computation chains.
371
+ * Explicitly typed as `any` so we can use it as signal's value.
372
+ */
373
+ const COMPUTING = /* @__PURE__ */ Symbol('COMPUTING');
374
+ /**
375
+ * A dedicated symbol used in place of a computed signal value to indicate that a given computation
376
+ * failed. The thrown error is cached until the computation gets dirty again.
377
+ * Explicitly typed as `any` so we can use it as signal's value.
378
+ */
379
+ const ERRORED = /* @__PURE__ */ Symbol('ERRORED');
380
+ // Note: Using an IIFE here to ensure that the spread assignment is not considered
381
+ // a side-effect, ending up preserving `COMPUTED_NODE` and `REACTIVE_NODE`.
382
+ // TODO: remove when https://github.com/evanw/esbuild/issues/3392 is resolved.
383
+ const COMPUTED_NODE = /* @__PURE__ */ (() => {
384
+ return {
385
+ ...REACTIVE_NODE,
386
+ value: UNSET,
387
+ dirty: true,
388
+ error: null,
389
+ equal: defaultEquals,
390
+ kind: 'computed',
391
+ producerMustRecompute(node) {
392
+ // Force a recomputation if there's no current value, or if the current value is in the
393
+ // process of being calculated (which should throw an error).
394
+ return node.value === UNSET || node.value === COMPUTING;
395
+ },
396
+ producerRecomputeValue(node) {
397
+ if (node.value === COMPUTING) {
398
+ // Our computation somehow led to a cyclic read of itself.
399
+ throw new Error('Detected cycle in computations.');
400
+ }
401
+ const oldValue = node.value;
402
+ node.value = COMPUTING;
403
+ const prevConsumer = consumerBeforeComputation(node);
404
+ let newValue;
405
+ let wasEqual = false;
406
+ try {
407
+ newValue = node.computation();
408
+ // We want to mark this node as errored if calling `equal` throws; however, we don't want
409
+ // to track any reactive reads inside `equal`.
410
+ setActiveConsumer(null);
411
+ wasEqual =
412
+ oldValue !== UNSET &&
413
+ oldValue !== ERRORED &&
414
+ newValue !== ERRORED &&
415
+ node.equal(oldValue, newValue);
416
+ }
417
+ catch (err) {
418
+ newValue = ERRORED;
419
+ node.error = err;
420
+ }
421
+ finally {
422
+ consumerAfterComputation(node, prevConsumer);
423
+ }
424
+ if (wasEqual) {
425
+ // No change to `valueVersion` - old and new values are
426
+ // semantically equivalent.
427
+ node.value = oldValue;
428
+ return;
429
+ }
430
+ node.value = newValue;
431
+ node.version++;
432
+ },
433
+ };
434
+ })();
435
+
436
+ function defaultThrowError() {
437
+ throw new Error();
438
+ }
439
+ let throwInvalidWriteToSignalErrorFn = defaultThrowError;
440
+ function throwInvalidWriteToSignalError(node) {
441
+ throwInvalidWriteToSignalErrorFn(node);
442
+ }
443
+ function setThrowInvalidWriteToSignalError(fn) {
444
+ throwInvalidWriteToSignalErrorFn = fn;
445
+ }
446
+
447
+ /**
448
+ * If set, called after `WritableSignal`s are updated.
449
+ *
450
+ * This hook can be used to achieve various effects, such as running effects synchronously as part
451
+ * of setting a signal.
452
+ */
453
+ let postSignalSetFn = null;
454
+ /**
455
+ * Create a `Signal` that can be set or updated directly.
456
+ */
457
+ function createSignal(initialValue, equal) {
458
+ const node = Object.create(SIGNAL_NODE);
459
+ node.value = initialValue;
460
+ if (equal !== undefined) {
461
+ node.equal = equal;
462
+ }
463
+ const getter = (() => {
464
+ producerAccessed(node);
465
+ return node.value;
466
+ });
467
+ getter[SIGNAL] = node;
468
+ runPostProducerCreatedFn(node);
469
+ return getter;
470
+ }
471
+ function setPostSignalSetFn(fn) {
472
+ const prev = postSignalSetFn;
473
+ postSignalSetFn = fn;
474
+ return prev;
475
+ }
476
+ function signalSetFn(node, newValue) {
477
+ if (!producerUpdatesAllowed()) {
478
+ throwInvalidWriteToSignalError(node);
479
+ }
480
+ if (!node.equal(node.value, newValue)) {
481
+ node.value = newValue;
482
+ signalValueChanged(node);
483
+ }
484
+ }
485
+ function signalUpdateFn(node, updater) {
486
+ if (!producerUpdatesAllowed()) {
487
+ throwInvalidWriteToSignalError(node);
488
+ }
489
+ signalSetFn(node, updater(node.value));
490
+ }
491
+ function runPostSignalSetFn(node) {
492
+ postSignalSetFn?.(node);
493
+ }
494
+ // Note: Using an IIFE here to ensure that the spread assignment is not considered
495
+ // a side-effect, ending up preserving `COMPUTED_NODE` and `REACTIVE_NODE`.
496
+ // TODO: remove when https://github.com/evanw/esbuild/issues/3392 is resolved.
497
+ const SIGNAL_NODE = /* @__PURE__ */ (() => {
498
+ return {
499
+ ...REACTIVE_NODE,
500
+ equal: defaultEquals,
501
+ value: undefined,
502
+ kind: 'signal',
503
+ };
504
+ })();
505
+ function signalValueChanged(node) {
506
+ node.version++;
507
+ producerIncrementEpoch();
508
+ producerNotifyConsumers(node);
509
+ postSignalSetFn?.(node);
510
+ }
511
+
512
+ function createLinkedSignal(sourceFn, computationFn, equalityFn) {
513
+ const node = Object.create(LINKED_SIGNAL_NODE);
514
+ node.source = sourceFn;
515
+ node.computation = computationFn;
516
+ if (equalityFn != undefined) {
517
+ node.equal = equalityFn;
518
+ }
519
+ const linkedSignalGetter = () => {
520
+ // Check if the value needs updating before returning it.
521
+ producerUpdateValueVersion(node);
522
+ // Record that someone looked at this signal.
523
+ producerAccessed(node);
524
+ if (node.value === ERRORED) {
525
+ throw node.error;
526
+ }
527
+ return node.value;
528
+ };
529
+ const getter = linkedSignalGetter;
530
+ getter[SIGNAL] = node;
531
+ runPostProducerCreatedFn(node);
532
+ return getter;
533
+ }
534
+ function linkedSignalSetFn(node, newValue) {
535
+ producerUpdateValueVersion(node);
536
+ signalSetFn(node, newValue);
537
+ producerMarkClean(node);
538
+ }
539
+ function linkedSignalUpdateFn(node, updater) {
540
+ producerUpdateValueVersion(node);
541
+ signalUpdateFn(node, updater);
542
+ producerMarkClean(node);
543
+ }
544
+ // Note: Using an IIFE here to ensure that the spread assignment is not considered
545
+ // a side-effect, ending up preserving `LINKED_SIGNAL_NODE` and `REACTIVE_NODE`.
546
+ // TODO: remove when https://github.com/evanw/esbuild/issues/3392 is resolved.
547
+ const LINKED_SIGNAL_NODE = /* @__PURE__ */ (() => {
548
+ return {
549
+ ...REACTIVE_NODE,
550
+ value: UNSET,
551
+ dirty: true,
552
+ error: null,
553
+ equal: defaultEquals,
554
+ kind: 'linkedSignal',
555
+ producerMustRecompute(node) {
556
+ // Force a recomputation if there's no current value, or if the current value is in the
557
+ // process of being calculated (which should throw an error).
558
+ return node.value === UNSET || node.value === COMPUTING;
559
+ },
560
+ producerRecomputeValue(node) {
561
+ if (node.value === COMPUTING) {
562
+ // Our computation somehow led to a cyclic read of itself.
563
+ throw new Error('Detected cycle in computations.');
564
+ }
565
+ const oldValue = node.value;
566
+ node.value = COMPUTING;
567
+ const prevConsumer = consumerBeforeComputation(node);
568
+ let newValue;
569
+ try {
570
+ const newSourceValue = node.source();
571
+ const prev = oldValue === UNSET || oldValue === ERRORED
572
+ ? undefined
573
+ : {
574
+ source: node.sourceValue,
575
+ value: oldValue,
576
+ };
577
+ newValue = node.computation(newSourceValue, prev);
578
+ node.sourceValue = newSourceValue;
579
+ }
580
+ catch (err) {
581
+ newValue = ERRORED;
582
+ node.error = err;
583
+ }
584
+ finally {
585
+ consumerAfterComputation(node, prevConsumer);
586
+ }
587
+ if (oldValue !== UNSET && newValue !== ERRORED && node.equal(oldValue, newValue)) {
588
+ // No change to `valueVersion` - old and new values are
589
+ // semantically equivalent.
590
+ node.value = oldValue;
591
+ return;
592
+ }
593
+ node.value = newValue;
594
+ node.version++;
595
+ },
596
+ };
597
+ })();
598
+
599
+ function setAlternateWeakRefImpl(impl) {
600
+ // TODO: remove this function
601
+ }
602
+
603
+ /**
604
+ * Execute an arbitrary function in a non-reactive (non-tracking) context. The executed function
605
+ * can, optionally, return a value.
606
+ */
607
+ function untracked(nonReactiveReadsFn) {
608
+ const prevConsumer = setActiveConsumer(null);
609
+ // We are not trying to catch any particular errors here, just making sure that the consumers
610
+ // stack is restored in case of errors.
611
+ try {
612
+ return nonReactiveReadsFn();
613
+ }
614
+ finally {
615
+ setActiveConsumer(prevConsumer);
616
+ }
617
+ }
618
+
619
+ export { setPostSignalSetFn as A, signalSetFn as B, signalUpdateFn as C, setAlternateWeakRefImpl as D, untracked as E, REACTIVE_NODE as R, SIGNAL as S, consumerDestroy as a, consumerPollProducersForChange as b, consumerMarkDirty as c, consumerBeforeComputation as d, consumerAfterComputation as e, createComputed as f, createLinkedSignal as g, linkedSignalUpdateFn as h, isInNotificationPhase as i, defaultEquals as j, getActiveConsumer as k, linkedSignalSetFn as l, isReactive as m, producerIncrementEpoch as n, producerMarkClean as o, producerAccessed as p, producerNotifyConsumers as q, producerUpdateValueVersion as r, setThrowInvalidWriteToSignalError as s, producerUpdatesAllowed as t, runPostProducerCreatedFn as u, setActiveConsumer as v, setPostProducerCreatedFn as w, SIGNAL_NODE as x, createSignal as y, runPostSignalSetFn as z };
620
+ //# sourceMappingURL=untracked-DkcXpNb_.mjs.map