@angular/core 16.2.3 → 16.2.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 (35) hide show
  1. package/esm2022/src/linker/view_container_ref.mjs +35 -1
  2. package/esm2022/src/render3/component.mjs +4 -3
  3. package/esm2022/src/render3/di.mjs +1 -1
  4. package/esm2022/src/render3/instructions/change_detection.mjs +4 -4
  5. package/esm2022/src/render3/instructions/shared.mjs +20 -14
  6. package/esm2022/src/render3/interfaces/injector.mjs +1 -1
  7. package/esm2022/src/render3/interfaces/styling.mjs +4 -7
  8. package/esm2022/src/render3/node_manipulation.mjs +4 -3
  9. package/esm2022/src/render3/reactive_lview_consumer.mjs +25 -45
  10. package/esm2022/src/render3/reactivity/effect.mjs +8 -8
  11. package/esm2022/src/render3/util/injector_utils.mjs +1 -1
  12. package/esm2022/src/signals/index.mjs +4 -4
  13. package/esm2022/src/signals/src/api.mjs +2 -11
  14. package/esm2022/src/signals/src/computed.mjs +43 -93
  15. package/esm2022/src/signals/src/graph.mjs +238 -162
  16. package/esm2022/src/signals/src/signal.mjs +59 -79
  17. package/esm2022/src/signals/src/watch.mjs +38 -52
  18. package/esm2022/src/signals/src/weak_ref.mjs +2 -29
  19. package/esm2022/src/util/security/trusted_type_defs.mjs +1 -1
  20. package/esm2022/src/util/security/trusted_types.mjs +1 -1
  21. package/esm2022/src/version.mjs +1 -1
  22. package/esm2022/src/zone/ng_zone.mjs +16 -1
  23. package/esm2022/testing/src/logger.mjs +3 -3
  24. package/fesm2022/core.mjs +476 -483
  25. package/fesm2022/core.mjs.map +1 -1
  26. package/fesm2022/rxjs-interop.mjs +373 -413
  27. package/fesm2022/rxjs-interop.mjs.map +1 -1
  28. package/fesm2022/testing.mjs +474 -482
  29. package/fesm2022/testing.mjs.map +1 -1
  30. package/index.d.ts +112 -102
  31. package/package.json +1 -1
  32. package/rxjs-interop/index.d.ts +1 -1
  33. package/schematics/ng-generate/standalone-migration/bundle.js +9 -9
  34. package/schematics/ng-generate/standalone-migration/bundle.js.map +1 -1
  35. package/testing/index.d.ts +1 -1
package/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v16.2.3
2
+ * @license Angular v16.2.4
3
3
  * (c) 2010-2022 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -1928,17 +1928,18 @@ declare const CONTEXT = 8;
1928
1928
  * const applicationRef = await bootstrapApplication(RootComponent);
1929
1929
  *
1930
1930
  * // Locate a DOM node that would be used as a host.
1931
- * const host = document.getElementById('hello-component-host');
1931
+ * const hostElement = document.getElementById('hello-component-host');
1932
1932
  *
1933
1933
  * // Get an `EnvironmentInjector` instance from the `ApplicationRef`.
1934
1934
  * const environmentInjector = applicationRef.injector;
1935
1935
  *
1936
1936
  * // We can now create a `ComponentRef` instance.
1937
- * const componentRef = createComponent(HelloComponent, {host, environmentInjector});
1937
+ * const componentRef = createComponent(HelloComponent, {hostElement, environmentInjector});
1938
1938
  *
1939
1939
  * // Last step is to register the newly created ref using the `ApplicationRef` instance
1940
1940
  * // to include the component view into change detection cycles.
1941
1941
  * applicationRef.attachView(componentRef.hostView);
1942
+ * componentRef.changeDetectorRef.detectChanges();
1942
1943
  * ```
1943
1944
  *
1944
1945
  * @param component Component class reference.
@@ -7225,116 +7226,94 @@ declare const REACTIVE_HOST_BINDING_CONSUMER = 24;
7225
7226
 
7226
7227
  declare const REACTIVE_TEMPLATE_CONSUMER = 23;
7227
7228
 
7228
- declare class ReactiveLViewConsumer extends ReactiveNode {
7229
- protected consumerAllowSignalWrites: boolean;
7230
- private _lView;
7231
- set lView(lView: LView);
7232
- protected onConsumerDependencyMayHaveChanged(): void;
7233
- protected onProducerUpdateValueVersion(): void;
7234
- get hasReadASignal(): boolean;
7235
- runInContext(fn: HostBindingsFunction<unknown> | ComponentTemplate<unknown>, rf: ɵRenderFlags, ctx: unknown): void;
7236
- destroy(): void;
7229
+ declare interface ReactiveLViewConsumer extends ReactiveNode {
7230
+ lView: LView | null;
7237
7231
  }
7238
7232
 
7239
7233
  /**
7240
- * A node in the reactive graph.
7241
- *
7242
- * Nodes can be producers of reactive values, consumers of other reactive values, or both.
7243
- *
7244
- * Producers are nodes that produce values, and can be depended upon by consumer nodes.
7245
- *
7246
- * Producers expose a monotonic `valueVersion` counter, and are responsible for incrementing this
7247
- * version when their value semantically changes. Some producers may produce their values lazily and
7248
- * thus at times need to be polled for potential updates to their value (and by extension their
7249
- * `valueVersion`). This is accomplished via the `onProducerUpdateValueVersion` method for
7250
- * implemented by producers, which should perform whatever calculations are necessary to ensure
7251
- * `valueVersion` is up to date.
7234
+ * A producer and/or consumer which participates in the reactive graph.
7252
7235
  *
7253
- * Consumers are nodes that depend on the values of producers and are notified when those values
7254
- * might have changed.
7236
+ * Producer `ReactiveNode`s which are accessed when a consumer `ReactiveNode` is the
7237
+ * `activeConsumer` are tracked as dependencies of that consumer.
7255
7238
  *
7256
- * Consumers do not wrap the reads they consume themselves, but rather can be set as the active
7257
- * reader via `setActiveConsumer`. Reads of producers that happen while a consumer is active will
7258
- * result in those producers being added as dependencies of that consumer node.
7239
+ * Certain consumers are also tracked as "live" consumers and create edges in the other direction,
7240
+ * from producer to consumer. These edges are used to propagate change notifications when a
7241
+ * producer's value is updated.
7259
7242
  *
7260
- * The set of dependencies of a consumer is dynamic. Implementers expose a monotonically increasing
7261
- * `trackingVersion` counter, which increments whenever the consumer is about to re-run any reactive
7262
- * reads it needs and establish a new set of dependencies as a result.
7263
- *
7264
- * Producers store the last `trackingVersion` they've seen from `Consumer`s which have read them.
7265
- * This allows a producer to identify whether its record of the dependency is current or stale, by
7266
- * comparing the consumer's `trackingVersion` to the version at which the dependency was
7267
- * last observed.
7243
+ * A `ReactiveNode` may be both a producer and consumer.
7268
7244
  */
7269
- declare abstract class ReactiveNode {
7270
- private readonly id;
7271
- /**
7272
- * A cached weak reference to this node, which will be used in `ReactiveEdge`s.
7273
- */
7274
- private readonly ref;
7275
- /**
7276
- * Edges to producers on which this node depends (in its consumer capacity).
7277
- */
7278
- private readonly producers;
7279
- /**
7280
- * Edges to consumers on which this node depends (in its producer capacity).
7281
- */
7282
- private readonly consumers;
7283
- /**
7284
- * Monotonically increasing counter representing a version of this `Consumer`'s
7285
- * dependencies.
7286
- */
7287
- protected trackingVersion: number;
7245
+ declare interface ReactiveNode {
7288
7246
  /**
7289
- * Monotonically increasing counter which increases when the value of this `Producer`
7290
- * semantically changes.
7247
+ * Version of the value that this node produces.
7248
+ *
7249
+ * This is incremented whenever a new value is produced by this node which is not equal to the
7250
+ * previous value (by whatever definition of equality is in use).
7291
7251
  */
7292
- protected valueVersion: number;
7252
+ version: Version_2;
7293
7253
  /**
7294
- * Whether signal writes should be allowed while this `ReactiveNode` is the current consumer.
7254
+ * Whether this node (in its consumer capacity) is dirty.
7255
+ *
7256
+ * Only live consumers become dirty, when receiving a change notification from a dependency
7257
+ * producer.
7295
7258
  */
7296
- protected abstract readonly consumerAllowSignalWrites: boolean;
7259
+ dirty: boolean;
7297
7260
  /**
7298
- * Called for consumers whenever one of their dependencies notifies that it might have a new
7299
- * value.
7261
+ * Producers which are dependencies of this consumer.
7262
+ *
7263
+ * Uses the same indices as the `producerLastReadVersion` and `producerIndexOfThis` arrays.
7300
7264
  */
7301
- protected abstract onConsumerDependencyMayHaveChanged(): void;
7265
+ producerNode: ReactiveNode[] | undefined;
7302
7266
  /**
7303
- * Called for producers when a dependent consumer is checking if the producer's value has actually
7304
- * changed.
7267
+ * `Version` of the value last read by a given producer.
7268
+ *
7269
+ * Uses the same indices as the `producerNode` and `producerIndexOfThis` arrays.
7305
7270
  */
7306
- protected abstract onProducerUpdateValueVersion(): void;
7271
+ producerLastReadVersion: Version_2[] | undefined;
7307
7272
  /**
7308
- * Polls dependencies of a consumer to determine if they have actually changed.
7273
+ * Index of `this` (consumer) in each producer's `liveConsumers` array.
7309
7274
  *
7310
- * If this returns `false`, then even though the consumer may have previously been notified of a
7311
- * change, the values of its dependencies have not actually changed and the consumer should not
7312
- * rerun any reactions.
7275
+ * This value is only meaningful if this node is live (`liveConsumers.length > 0`). Otherwise
7276
+ * these indices are stale.
7277
+ *
7278
+ * Uses the same indices as the `producerNode` and `producerLastReadVersion` arrays.
7313
7279
  */
7314
- protected consumerPollProducersForChange(): boolean;
7280
+ producerIndexOfThis: number[] | undefined;
7315
7281
  /**
7316
- * Notify all consumers of this producer that its value may have changed.
7282
+ * Index into the producer arrays that the next dependency of this node as a consumer will use.
7283
+ *
7284
+ * This index is zeroed before this node as a consumer begins executing. When a producer is read,
7285
+ * it gets inserted into the producers arrays at this index. There may be an existing dependency
7286
+ * in this location which may or may not match the incoming producer, depending on whether the
7287
+ * same producers were read in the same order as the last computation.
7317
7288
  */
7318
- protected producerMayHaveChanged(): void;
7289
+ nextProducerIndex: number;
7319
7290
  /**
7320
- * Mark that this producer node has been accessed in the current reactive context.
7291
+ * Array of consumers of this producer that are "live" (they require push notifications).
7292
+ *
7293
+ * `liveConsumerNode.length` is effectively our reference count for this node.
7321
7294
  */
7322
- protected producerAccessed(): void;
7295
+ liveConsumerNode: ReactiveNode[] | undefined;
7323
7296
  /**
7324
- * Whether this consumer currently has any producers registered.
7297
+ * Index of `this` (producer) in each consumer's `producerNode` array.
7298
+ *
7299
+ * Uses the same indices as the `liveConsumerNode` array.
7325
7300
  */
7326
- protected get hasProducers(): boolean;
7301
+ liveConsumerIndexOfThis: number[] | undefined;
7327
7302
  /**
7328
- * Whether this `ReactiveNode` in its producer capacity is currently allowed to initiate updates,
7329
- * based on the current consumer context.
7303
+ * Whether writes to signals are allowed when this consumer is the `activeConsumer`.
7304
+ *
7305
+ * This is used to enforce guardrails such as preventing writes to writable signals in the
7306
+ * computation function of computed signals, which is supposed to be pure.
7330
7307
  */
7331
- protected get producerUpdatesAllowed(): boolean;
7308
+ consumerAllowSignalWrites: boolean;
7309
+ readonly consumerIsAlwaysLive: boolean;
7332
7310
  /**
7333
- * Checks if a `Producer` has a current value which is different than the value
7334
- * last seen at a specific version by a `Consumer` which recorded a dependency on
7335
- * this `Producer`.
7311
+ * Tracks whether producers need to recompute their value independently of the reactive graph (for
7312
+ * example, if no initial value has been computed).
7336
7313
  */
7337
- private producerPollStatus;
7314
+ producerMustRecompute(node: unknown): boolean;
7315
+ producerRecomputeValue(node: unknown): void;
7316
+ consumerMarkedDirty(node: unknown): void;
7338
7317
  }
7339
7318
 
7340
7319
  /**
@@ -9395,17 +9374,17 @@ export declare const TRANSLATIONS_FORMAT: InjectionToken<string>;
9395
9374
  * https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/trusted-types/index.d.ts
9396
9375
  * but restricted to the API surface used within Angular.
9397
9376
  */
9398
- declare interface TrustedHTML {
9377
+ declare type TrustedHTML = string & {
9399
9378
  __brand__: 'TrustedHTML';
9400
- }
9379
+ };
9401
9380
 
9402
- declare interface TrustedScript {
9381
+ declare type TrustedScript = string & {
9403
9382
  __brand__: 'TrustedScript';
9404
- }
9383
+ };
9405
9384
 
9406
- declare interface TrustedScriptURL {
9385
+ declare type TrustedScriptURL = string & {
9407
9386
  __brand__: 'TrustedScriptURL';
9408
- }
9387
+ };
9409
9388
 
9410
9389
  /**
9411
9390
  * Value stored in the `TData` which is needed to re-concatenate the styling.
@@ -9454,9 +9433,9 @@ declare type TStylingKeyPrimitive = string | null | false;
9454
9433
  *
9455
9434
  * NOTE: `0` has special significance and represents `null` as in no additional pointer.
9456
9435
  */
9457
- declare interface TStylingRange {
9436
+ declare type TStylingRange = number & {
9458
9437
  __brand__: 'TStylingRange';
9459
- }
9438
+ };
9460
9439
 
9461
9440
  /**
9462
9441
  * Store the static values for the styling binding.
@@ -9939,6 +9918,10 @@ export declare class Version {
9939
9918
  constructor(full: string);
9940
9919
  }
9941
9920
 
9921
+ declare type Version_2 = number & {
9922
+ __brand: 'Version';
9923
+ };
9924
+
9942
9925
  declare const VIEW_REFS = 8;
9943
9926
 
9944
9927
  /**
@@ -10112,6 +10095,40 @@ export declare interface ViewChildrenDecorator {
10112
10095
  * A view container instance can contain other view containers,
10113
10096
  * creating a [view hierarchy](guide/glossary#view-hierarchy).
10114
10097
  *
10098
+ * @usageNotes
10099
+ *
10100
+ * The example below demonstrates how the `createComponent` function can be used
10101
+ * to create an instance of a ComponentRef dynamically and attach it to an ApplicationRef,
10102
+ * so that it gets included into change detection cycles.
10103
+ *
10104
+ * Note: the example uses standalone components, but the function can also be used for
10105
+ * non-standalone components (declared in an NgModule) as well.
10106
+ *
10107
+ * ```typescript
10108
+ * @Component({
10109
+ * standalone: true,
10110
+ * selector: 'dynamic',
10111
+ * template: `<span>This is a content of a dynamic component.</span>`,
10112
+ * })
10113
+ * class DynamicComponent {
10114
+ * vcr = inject(ViewContainerRef);
10115
+ * }
10116
+ *
10117
+ * @Component({
10118
+ * standalone: true,
10119
+ * selector: 'app',
10120
+ * template: `<main>Hi! This is the main content.</main>`,
10121
+ * })
10122
+ * class AppComponent {
10123
+ * vcr = inject(ViewContainerRef);
10124
+ *
10125
+ * ngAfterViewInit() {
10126
+ * const compRef = this.vcr.createComponent(DynamicComponent);
10127
+ * compRef.changeDetectorRef.detectChanges();
10128
+ * }
10129
+ * }
10130
+ * ```
10131
+ *
10115
10132
  * @see {@link ComponentRef}
10116
10133
  * @see {@link EmbeddedViewRef}
10117
10134
  *
@@ -10350,14 +10367,6 @@ declare interface ViewRefTracker {
10350
10367
  detachView(viewRef: ViewRef): void;
10351
10368
  }
10352
10369
 
10353
- declare interface WeakRef<T extends object> {
10354
- deref(): T | undefined;
10355
- }
10356
-
10357
- declare interface WeakRefCtor {
10358
- new <T extends object>(value: T): WeakRef<T>;
10359
- }
10360
-
10361
10370
  /**
10362
10371
  * A `Signal` with a value that can be mutated via a setter interface.
10363
10372
  *
@@ -11818,7 +11827,8 @@ export declare interface ɵSafeValue {
11818
11827
  */
11819
11828
  export declare function ɵsetAllowDuplicateNgModuleIdsForTest(allowDuplicates: boolean): void;
11820
11829
 
11821
- export declare function ɵsetAlternateWeakRefImpl(impl: WeakRefCtor): void;
11830
+
11831
+ export declare function ɵsetAlternateWeakRefImpl(impl: unknown): void;
11822
11832
 
11823
11833
  /**
11824
11834
  * Adds decorator, constructor, and property metadata to a given type via static metadata fields
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@angular/core",
3
- "version": "16.2.3",
3
+ "version": "16.2.4",
4
4
  "description": "Angular - the core framework",
5
5
  "author": "angular",
6
6
  "license": "MIT",
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v16.2.3
2
+ * @license Angular v16.2.4
3
3
  * (c) 2010-2022 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -21920,7 +21920,7 @@ function publishFacade(global) {
21920
21920
  }
21921
21921
 
21922
21922
  // bazel-out/k8-fastbuild/bin/packages/compiler/src/version.mjs
21923
- var VERSION2 = new Version("16.2.3");
21923
+ var VERSION2 = new Version("16.2.4");
21924
21924
 
21925
21925
  // bazel-out/k8-fastbuild/bin/packages/compiler/src/i18n/extractor_merger.mjs
21926
21926
  var _I18N_ATTR = "i18n";
@@ -23362,7 +23362,7 @@ var MINIMUM_PARTIAL_LINKER_VERSION = "12.0.0";
23362
23362
  function compileDeclareClassMetadata(metadata) {
23363
23363
  const definitionMap = new DefinitionMap();
23364
23364
  definitionMap.set("minVersion", literal(MINIMUM_PARTIAL_LINKER_VERSION));
23365
- definitionMap.set("version", literal("16.2.3"));
23365
+ definitionMap.set("version", literal("16.2.4"));
23366
23366
  definitionMap.set("ngImport", importExpr(Identifiers.core));
23367
23367
  definitionMap.set("type", metadata.type);
23368
23368
  definitionMap.set("decorators", metadata.decorators);
@@ -23433,7 +23433,7 @@ function createDirectiveDefinitionMap(meta) {
23433
23433
  const hasTransformFunctions = Object.values(meta.inputs).some((input) => input.transformFunction !== null);
23434
23434
  const minVersion = hasTransformFunctions ? MINIMUM_PARTIAL_LINKER_VERSION2 : "14.0.0";
23435
23435
  definitionMap.set("minVersion", literal(minVersion));
23436
- definitionMap.set("version", literal("16.2.3"));
23436
+ definitionMap.set("version", literal("16.2.4"));
23437
23437
  definitionMap.set("type", meta.type.value);
23438
23438
  if (meta.isStandalone) {
23439
23439
  definitionMap.set("isStandalone", literal(meta.isStandalone));
@@ -23618,7 +23618,7 @@ var MINIMUM_PARTIAL_LINKER_VERSION3 = "12.0.0";
23618
23618
  function compileDeclareFactoryFunction(meta) {
23619
23619
  const definitionMap = new DefinitionMap();
23620
23620
  definitionMap.set("minVersion", literal(MINIMUM_PARTIAL_LINKER_VERSION3));
23621
- definitionMap.set("version", literal("16.2.3"));
23621
+ definitionMap.set("version", literal("16.2.4"));
23622
23622
  definitionMap.set("ngImport", importExpr(Identifiers.core));
23623
23623
  definitionMap.set("type", meta.type.value);
23624
23624
  definitionMap.set("deps", compileDependencies(meta.deps));
@@ -23641,7 +23641,7 @@ function compileDeclareInjectableFromMetadata(meta) {
23641
23641
  function createInjectableDefinitionMap(meta) {
23642
23642
  const definitionMap = new DefinitionMap();
23643
23643
  definitionMap.set("minVersion", literal(MINIMUM_PARTIAL_LINKER_VERSION4));
23644
- definitionMap.set("version", literal("16.2.3"));
23644
+ definitionMap.set("version", literal("16.2.4"));
23645
23645
  definitionMap.set("ngImport", importExpr(Identifiers.core));
23646
23646
  definitionMap.set("type", meta.type.value);
23647
23647
  if (meta.providedIn !== void 0) {
@@ -23679,7 +23679,7 @@ function compileDeclareInjectorFromMetadata(meta) {
23679
23679
  function createInjectorDefinitionMap(meta) {
23680
23680
  const definitionMap = new DefinitionMap();
23681
23681
  definitionMap.set("minVersion", literal(MINIMUM_PARTIAL_LINKER_VERSION5));
23682
- definitionMap.set("version", literal("16.2.3"));
23682
+ definitionMap.set("version", literal("16.2.4"));
23683
23683
  definitionMap.set("ngImport", importExpr(Identifiers.core));
23684
23684
  definitionMap.set("type", meta.type.value);
23685
23685
  definitionMap.set("providers", meta.providers);
@@ -23703,7 +23703,7 @@ function createNgModuleDefinitionMap(meta) {
23703
23703
  throw new Error("Invalid path! Local compilation mode should not get into the partial compilation path");
23704
23704
  }
23705
23705
  definitionMap.set("minVersion", literal(MINIMUM_PARTIAL_LINKER_VERSION6));
23706
- definitionMap.set("version", literal("16.2.3"));
23706
+ definitionMap.set("version", literal("16.2.4"));
23707
23707
  definitionMap.set("ngImport", importExpr(Identifiers.core));
23708
23708
  definitionMap.set("type", meta.type.value);
23709
23709
  if (meta.bootstrap.length > 0) {
@@ -23738,7 +23738,7 @@ function compileDeclarePipeFromMetadata(meta) {
23738
23738
  function createPipeDefinitionMap(meta) {
23739
23739
  const definitionMap = new DefinitionMap();
23740
23740
  definitionMap.set("minVersion", literal(MINIMUM_PARTIAL_LINKER_VERSION7));
23741
- definitionMap.set("version", literal("16.2.3"));
23741
+ definitionMap.set("version", literal("16.2.4"));
23742
23742
  definitionMap.set("ngImport", importExpr(Identifiers.core));
23743
23743
  definitionMap.set("type", meta.type.value);
23744
23744
  if (meta.isStandalone) {
@@ -23755,7 +23755,7 @@ function createPipeDefinitionMap(meta) {
23755
23755
  publishFacade(_global);
23756
23756
 
23757
23757
  // bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/version.mjs
23758
- var VERSION3 = new Version("16.2.3");
23758
+ var VERSION3 = new Version("16.2.4");
23759
23759
 
23760
23760
  // bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/transformers/api.mjs
23761
23761
  var EmitFlags;