@angular/core 16.2.5 → 16.2.6

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/fesm2022/core.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v16.2.5
2
+ * @license Angular v16.2.6
3
3
  * (c) 2010-2022 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -2294,7 +2294,7 @@ function getFactoryDef(type, throwNotFound) {
2294
2294
  *
2295
2295
  * This can be used to auto-unwrap signals in various cases, or to auto-wrap non-signal values.
2296
2296
  */
2297
- const SIGNAL = Symbol('SIGNAL');
2297
+ const SIGNAL = /* @__PURE__ */ Symbol('SIGNAL');
2298
2298
  /**
2299
2299
  * Checks if the given `value` is a reactive `Signal`.
2300
2300
  *
@@ -2472,7 +2472,9 @@ function consumerAfterComputation(node, prevConsumer) {
2472
2472
  }
2473
2473
  }
2474
2474
  // Truncate the producer tracking arrays.
2475
- for (let i = node.nextProducerIndex; i < node.producerNode.length; i++) {
2475
+ // Perf note: this is essentially truncating the length to `node.nextProducerIndex`, but
2476
+ // benchmarking has shown that individual pop operations are faster.
2477
+ while (node.producerNode.length > node.nextProducerIndex) {
2476
2478
  node.producerNode.pop();
2477
2479
  node.producerLastReadVersion.pop();
2478
2480
  node.producerIndexOfThis.pop();
@@ -2546,6 +2548,9 @@ function producerAddLiveConsumer(node, consumer, indexOfThis) {
2546
2548
  function producerRemoveLiveConsumerAtIndex(node, idx) {
2547
2549
  assertProducerNode(node);
2548
2550
  assertConsumerNode(node);
2551
+ if (typeof ngDevMode !== 'undefined' && ngDevMode && idx >= node.liveConsumerNode.length) {
2552
+ throw new Error(`Assertion error: active consumer index ${idx} is out of bounds of ${node.liveConsumerNode.length} consumers)`);
2553
+ }
2549
2554
  if (node.liveConsumerNode.length === 1) {
2550
2555
  // When removing the last live consumer, we will no longer be live. We need to remove
2551
2556
  // ourselves from our producers' tracking (which may cause consumer-producers to lose
@@ -2610,60 +2615,65 @@ function computed(computation, options) {
2610
2615
  * A dedicated symbol used before a computed value has been calculated for the first time.
2611
2616
  * Explicitly typed as `any` so we can use it as signal's value.
2612
2617
  */
2613
- const UNSET = Symbol('UNSET');
2618
+ const UNSET = /* @__PURE__ */ Symbol('UNSET');
2614
2619
  /**
2615
2620
  * A dedicated symbol used in place of a computed signal value to indicate that a given computation
2616
2621
  * is in progress. Used to detect cycles in computation chains.
2617
2622
  * Explicitly typed as `any` so we can use it as signal's value.
2618
2623
  */
2619
- const COMPUTING = Symbol('COMPUTING');
2624
+ const COMPUTING = /* @__PURE__ */ Symbol('COMPUTING');
2620
2625
  /**
2621
2626
  * A dedicated symbol used in place of a computed signal value to indicate that a given computation
2622
2627
  * failed. The thrown error is cached until the computation gets dirty again.
2623
2628
  * Explicitly typed as `any` so we can use it as signal's value.
2624
2629
  */
2625
- const ERRORED = Symbol('ERRORED');
2626
- const COMPUTED_NODE = {
2627
- ...REACTIVE_NODE,
2628
- value: UNSET,
2629
- dirty: true,
2630
- error: null,
2631
- equal: defaultEquals,
2632
- producerMustRecompute(node) {
2633
- // Force a recomputation if there's no current value, or if the current value is in the process
2634
- // of being calculated (which should throw an error).
2635
- return node.value === UNSET || node.value === COMPUTING;
2636
- },
2637
- producerRecomputeValue(node) {
2638
- if (node.value === COMPUTING) {
2639
- // Our computation somehow led to a cyclic read of itself.
2640
- throw new Error('Detected cycle in computations.');
2641
- }
2642
- const oldValue = node.value;
2643
- node.value = COMPUTING;
2644
- const prevConsumer = consumerBeforeComputation(node);
2645
- let newValue;
2646
- try {
2647
- newValue = node.computation();
2648
- }
2649
- catch (err) {
2650
- newValue = ERRORED;
2651
- node.error = err;
2652
- }
2653
- finally {
2654
- consumerAfterComputation(node, prevConsumer);
2655
- }
2656
- if (oldValue !== UNSET && oldValue !== ERRORED && newValue !== ERRORED &&
2657
- node.equal(oldValue, newValue)) {
2658
- // No change to `valueVersion` - old and new values are
2659
- // semantically equivalent.
2660
- node.value = oldValue;
2661
- return;
2662
- }
2663
- node.value = newValue;
2664
- node.version++;
2665
- },
2666
- };
2630
+ const ERRORED = /* @__PURE__ */ Symbol('ERRORED');
2631
+ // Note: Using an IIFE here to ensure that the spread assignment is not considered
2632
+ // a side-effect, ending up preserving `COMPUTED_NODE` and `REACTIVE_NODE`.
2633
+ // TODO: remove when https://github.com/evanw/esbuild/issues/3392 is resolved.
2634
+ const COMPUTED_NODE = /* @__PURE__ */ (() => {
2635
+ return {
2636
+ ...REACTIVE_NODE,
2637
+ value: UNSET,
2638
+ dirty: true,
2639
+ error: null,
2640
+ equal: defaultEquals,
2641
+ producerMustRecompute(node) {
2642
+ // Force a recomputation if there's no current value, or if the current value is in the
2643
+ // process of being calculated (which should throw an error).
2644
+ return node.value === UNSET || node.value === COMPUTING;
2645
+ },
2646
+ producerRecomputeValue(node) {
2647
+ if (node.value === COMPUTING) {
2648
+ // Our computation somehow led to a cyclic read of itself.
2649
+ throw new Error('Detected cycle in computations.');
2650
+ }
2651
+ const oldValue = node.value;
2652
+ node.value = COMPUTING;
2653
+ const prevConsumer = consumerBeforeComputation(node);
2654
+ let newValue;
2655
+ try {
2656
+ newValue = node.computation();
2657
+ }
2658
+ catch (err) {
2659
+ newValue = ERRORED;
2660
+ node.error = err;
2661
+ }
2662
+ finally {
2663
+ consumerAfterComputation(node, prevConsumer);
2664
+ }
2665
+ if (oldValue !== UNSET && oldValue !== ERRORED && newValue !== ERRORED &&
2666
+ node.equal(oldValue, newValue)) {
2667
+ // No change to `valueVersion` - old and new values are
2668
+ // semantically equivalent.
2669
+ node.value = oldValue;
2670
+ return;
2671
+ }
2672
+ node.value = newValue;
2673
+ node.version++;
2674
+ },
2675
+ };
2676
+ })();
2667
2677
 
2668
2678
  function defaultThrowError() {
2669
2679
  throw new Error();
@@ -2708,11 +2718,16 @@ function setPostSignalSetFn(fn) {
2708
2718
  postSignalSetFn = fn;
2709
2719
  return prev;
2710
2720
  }
2711
- const SIGNAL_NODE = {
2712
- ...REACTIVE_NODE,
2713
- equal: defaultEquals,
2714
- readonlyFn: undefined,
2715
- };
2721
+ // Note: Using an IIFE here to ensure that the spread assignment is not considered
2722
+ // a side-effect, ending up preserving `COMPUTED_NODE` and `REACTIVE_NODE`.
2723
+ // TODO: remove when https://github.com/evanw/esbuild/issues/3392 is resolved.
2724
+ const SIGNAL_NODE = /* @__PURE__ */ (() => {
2725
+ return {
2726
+ ...REACTIVE_NODE,
2727
+ equal: defaultEquals,
2728
+ readonlyFn: undefined,
2729
+ };
2730
+ })();
2716
2731
  function signalValueChanged(node) {
2717
2732
  node.version++;
2718
2733
  producerNotifyConsumers(node);
@@ -2805,16 +2820,21 @@ function watch(fn, schedule, allowSignalWrites) {
2805
2820
  return node.ref;
2806
2821
  }
2807
2822
  const NOOP_CLEANUP_FN = () => { };
2808
- const WATCH_NODE = {
2809
- ...REACTIVE_NODE,
2810
- consumerIsAlwaysLive: true,
2811
- consumerAllowSignalWrites: false,
2812
- consumerMarkedDirty: (node) => {
2813
- node.schedule(node.ref);
2814
- },
2815
- hasRun: false,
2816
- cleanupFn: NOOP_CLEANUP_FN,
2817
- };
2823
+ // Note: Using an IIFE here to ensure that the spread assignment is not considered
2824
+ // a side-effect, ending up preserving `COMPUTED_NODE` and `REACTIVE_NODE`.
2825
+ // TODO: remove when https://github.com/evanw/esbuild/issues/3392 is resolved.
2826
+ const WATCH_NODE = /* @__PURE__ */ (() => {
2827
+ return {
2828
+ ...REACTIVE_NODE,
2829
+ consumerIsAlwaysLive: true,
2830
+ consumerAllowSignalWrites: false,
2831
+ consumerMarkedDirty: (node) => {
2832
+ node.schedule(node.ref);
2833
+ },
2834
+ hasRun: false,
2835
+ cleanupFn: NOOP_CLEANUP_FN,
2836
+ };
2837
+ })();
2818
2838
 
2819
2839
  function setAlternateWeakRefImpl(impl) {
2820
2840
  // TODO: remove this function
@@ -10256,7 +10276,7 @@ class Version {
10256
10276
  /**
10257
10277
  * @publicApi
10258
10278
  */
10259
- const VERSION = new Version('16.2.5');
10279
+ const VERSION = new Version('16.2.6');
10260
10280
 
10261
10281
  // This default value is when checking the hierarchy for a token.
10262
10282
  //