static-injector 6.3.1 → 7.0.0

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 (55) hide show
  1. package/import/application/application_tokens.d.ts +58 -0
  2. package/import/application/stability_debug.d.ts +13 -0
  3. package/import/authoring/output/output_ref.d.ts +37 -0
  4. package/import/change_detection/scheduling/zoneless_scheduling.d.ts +0 -7
  5. package/import/core_reactivity_export_internal.d.ts +1 -1
  6. package/import/defer/idle_service.d.ts +42 -0
  7. package/import/di/create_injector.d.ts +2 -2
  8. package/import/di/forward_ref.d.ts +2 -2
  9. package/import/di/index.d.ts +5 -0
  10. package/import/di/inject_async.d.ts +91 -0
  11. package/import/di/injectable.d.ts +7 -1
  12. package/import/di/injection_token.d.ts +7 -0
  13. package/import/di/injector.d.ts +1 -1
  14. package/import/di/injector_compatibility.d.ts +0 -1
  15. package/import/di/interface/defs.d.ts +2 -2
  16. package/import/di/interface/provider.d.ts +0 -15
  17. package/import/document.d.ts +18 -0
  18. package/import/errors.d.ts +13 -9
  19. package/import/event_emitter.d.ts +101 -0
  20. package/import/hydration/cache.d.ts +14 -0
  21. package/import/index.d.ts +16 -0
  22. package/import/linker.d.ts +1 -0
  23. package/import/pending_tasks.d.ts +1 -24
  24. package/import/pending_tasks_internal.d.ts +31 -0
  25. package/import/render3/debug/injector_profiler.d.ts +139 -0
  26. package/import/render3/debug/special_providers.d.ts +17 -0
  27. package/import/render3/errors_di.d.ts +25 -0
  28. package/import/render3/reactivity/api.d.ts +15 -0
  29. package/import/render3/reactivity/asserts.d.ts +1 -0
  30. package/import/render3/reactivity/effect.d.ts +3 -1
  31. package/import/render3/reactivity/root_effect_scheduler.d.ts +1 -1
  32. package/import/render3/reactivity/signal.d.ts +0 -4
  33. package/import/render3/util/stringify_utils.d.ts +21 -0
  34. package/import/resource/api.d.ts +101 -15
  35. package/import/resource/debounce.d.ts +21 -0
  36. package/import/resource/from_snapshots.d.ts +16 -0
  37. package/import/resource/index.d.ts +2 -0
  38. package/import/resource/resource.d.ts +32 -8
  39. package/import/transfer_state.d.ts +89 -0
  40. package/import/util/array_utils.d.ts +132 -0
  41. package/import/util/assert.d.ts +28 -0
  42. package/import/util/default_export.d.ts +24 -0
  43. package/import/util/promise_with_resolvers.d.ts +38 -0
  44. package/import/zone/ng_zone.d.ts +261 -0
  45. package/index.js +2263 -1224
  46. package/index.js.map +4 -4
  47. package/index.mjs +2246 -1218
  48. package/index.mjs.map +4 -4
  49. package/package.json +2 -2
  50. package/primitives/signals/index.d.ts +1 -1
  51. package/primitives/signals/src/formatter.d.ts +2 -1
  52. package/primitives/signals/src/graph.d.ts +8 -1
  53. package/primitives/signals/src/linked_signal.d.ts +1 -1
  54. package/readme.md +1 -1
  55. /package/import/{interface → change_detection}/lifecycle_hooks.d.ts +0 -0
package/index.js CHANGED
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/import/index.ts
21
21
  var import_exports = {};
22
22
  __export(import_exports, {
23
+ APP_ID: () => APP_ID,
23
24
  ChangeDetectionScheduler: () => ChangeDetectionScheduler,
24
25
  ChangeDetectionSchedulerImpl: () => ChangeDetectionSchedulerImpl,
25
26
  DecoratorFlags: () => DecoratorFlags,
@@ -27,6 +28,7 @@ __export(import_exports, {
27
28
  EffectScheduler: () => EffectScheduler,
28
29
  EnvironmentInjector: () => EnvironmentInjector,
29
30
  ErrorHandler: () => ErrorHandler,
31
+ EventEmitter: () => EventEmitter,
30
32
  INJECTOR_SCOPE: () => INJECTOR_SCOPE,
31
33
  INTERNAL_APPLICATION_ERROR_HANDLER: () => INTERNAL_APPLICATION_ERROR_HANDLER,
32
34
  Inject: () => Inject,
@@ -40,20 +42,20 @@ __export(import_exports, {
40
42
  NotificationSource: () => NotificationSource,
41
43
  NullInjector: () => NullInjector,
42
44
  Optional: () => Optional,
43
- PROVIDED_ZONELESS: () => PROVIDED_ZONELESS,
44
45
  PendingTasks: () => PendingTasks,
45
- PendingTasksInternal: () => PendingTasksInternal,
46
46
  R3Injector: () => R3Injector,
47
+ ResourceDependencyError: () => ResourceDependencyError,
48
+ ResourceParamsStatus: () => ResourceParamsStatus,
47
49
  RetrievingInjector: () => RetrievingInjector,
48
50
  RootStaticInjectOptions: () => RootStaticInjectOptions,
49
- SCHEDULE_IN_ROOT_ZONE: () => SCHEDULE_IN_ROOT_ZONE,
50
51
  SOURCE: () => SOURCE,
51
52
  Self: () => Self,
52
53
  SkipSelf: () => SkipSelf,
53
54
  StaticInjectOptions: () => StaticInjectOptions,
54
55
  THROW_IF_NOT_FOUND: () => THROW_IF_NOT_FOUND,
55
- ZONELESS_ENABLED: () => ZONELESS_ENABLED,
56
- ZONELESS_SCHEDULER_DISABLED: () => ZONELESS_SCHEDULER_DISABLED,
56
+ TransferState: () => TransferState,
57
+ Type: () => Type,
58
+ assertInInjectionContext: () => assertInInjectionContext,
57
59
  assertNotDestroyed: () => assertNotDestroyed,
58
60
  assertNotInReactiveContext: () => assertNotInReactiveContext,
59
61
  attachInjectFlag: () => attachInjectFlag,
@@ -61,8 +63,9 @@ __export(import_exports, {
61
63
  convertToBitFlags: () => convertToBitFlags,
62
64
  createInjector: () => createInjector2,
63
65
  createRootInjector: () => createRootInjector,
66
+ debounced: () => debounced,
64
67
  effect: () => effect,
65
- formatError: () => formatError,
68
+ forwardRef: () => forwardRef,
66
69
  getCurrentInjector: () => getCurrentInjector,
67
70
  getInheritedInjectableDef: () => getInheritedInjectableDef,
68
71
  getInjectFlag: () => getInjectFlag,
@@ -71,12 +74,20 @@ __export(import_exports, {
71
74
  getNullInjector: () => getNullInjector,
72
75
  inject: () => inject2,
73
76
  injectArgs: () => injectArgs,
77
+ injectAsync: () => injectAsync,
74
78
  injectInjectorOnly: () => injectInjectorOnly,
75
79
  isInjectable: () => isInjectable,
76
- isSignal: () => isSignal,
80
+ isSignal: () => isSignal2,
81
+ isWritableSignal: () => isWritableSignal,
77
82
  linkedSignal: () => linkedSignal,
83
+ makeStateKey: () => makeStateKey,
84
+ onIdle: () => onIdle,
85
+ provideIdleServiceWith: () => provideIdleServiceWith,
78
86
  providerToFactory: () => providerToFactory,
87
+ resolveForwardRef: () => resolveForwardRef,
79
88
  resource: () => resource,
89
+ resourceFromSnapshots: () => resourceFromSnapshots,
90
+ runInInjectionContext: () => runInInjectionContext,
80
91
  setCurrentInjector: () => setCurrentInjector,
81
92
  signal: () => signal,
82
93
  untracked: () => untracked2,
@@ -91,6 +102,9 @@ __export(import_exports, {
91
102
  });
92
103
  module.exports = __toCommonJS(import_exports);
93
104
 
105
+ // script/shim.js
106
+ var ngDevMode = typeof ngDevMode === "undefined" ? true : ngDevMode;
107
+
94
108
  // src/import/di/interface/provider.ts
95
109
  function isEnvironmentProviders(value) {
96
110
  return value && !!value.ɵproviders;
@@ -108,17 +122,15 @@ function formatRuntimeErrorCode(code) {
108
122
  }
109
123
  function formatRuntimeError(code, message) {
110
124
  const fullCode = formatRuntimeErrorCode(code);
111
- const errorMessage = `${fullCode}${message ? ": " + message : ""}`;
112
- if (false) {
125
+ let errorMessage = `${fullCode}${message ? ": " + message : ""}`;
126
+ if (ngDevMode && code < 0) {
127
+ const addPeriodSeparator = !errorMessage.match(/[.,;!?\n]$/);
128
+ const separator = addPeriodSeparator ? "." : "";
129
+ errorMessage = `${errorMessage}${separator} Find more at ${"https://v22.angular.dev/errors"}/${fullCode}`;
113
130
  }
114
131
  return errorMessage;
115
132
  }
116
133
 
117
- // src/import/render3/definition_factory.ts
118
- function getFactoryDef(type, throwNotFound) {
119
- return () => new type();
120
- }
121
-
122
134
  // src/import/util/property.ts
123
135
  function getClosureSafeProperty(objWithPropertyToExtract) {
124
136
  for (const key in objWithPropertyToExtract) {
@@ -126,41 +138,7 @@ function getClosureSafeProperty(objWithPropertyToExtract) {
126
138
  return key;
127
139
  }
128
140
  }
129
- throw Error("");
130
- }
131
-
132
- // src/import/render3/errors_di.ts
133
- var NG_RUNTIME_ERROR_CODE = getClosureSafeProperty({ ngErrorCode: getClosureSafeProperty });
134
- var NG_RUNTIME_ERROR_MESSAGE = getClosureSafeProperty({ ngErrorMessage: getClosureSafeProperty });
135
- var NG_TOKEN_PATH = getClosureSafeProperty({ ngTokenPath: getClosureSafeProperty });
136
- function cyclicDependencyError(token, path) {
137
- const message = "";
138
- return createRuntimeError(message, -200 /* CYCLIC_DI_DEPENDENCY */, path);
139
- }
140
- function throwProviderNotFoundError(token, injectorName) {
141
- const errorMessage = void 0;
142
- throw new RuntimeError(-201 /* PROVIDER_NOT_FOUND */, errorMessage);
143
- }
144
- function createRuntimeError(message, code, path) {
145
- const error = new RuntimeError(code, message);
146
- error[NG_RUNTIME_ERROR_CODE] = code;
147
- error[NG_RUNTIME_ERROR_MESSAGE] = message;
148
- if (path) {
149
- error[NG_TOKEN_PATH] = path;
150
- }
151
- return error;
152
- }
153
- function getRuntimeErrorCode(error) {
154
- return error[NG_RUNTIME_ERROR_CODE];
155
- }
156
-
157
- // src/import/render3/fields.ts
158
- var NG_FACTORY_DEF = getClosureSafeProperty({ ɵfac: getClosureSafeProperty });
159
- var NG_ENV_ID = getClosureSafeProperty({ __NG_ENV_ID__: getClosureSafeProperty });
160
-
161
- // src/import/util/empty.ts
162
- var EMPTY_ARRAY = [];
163
- if (false) {
141
+ throw Error(typeof ngDevMode !== "undefined" && ngDevMode ? "Could not find renamed property on target object." : "");
164
142
  }
165
143
 
166
144
  // src/import/util/stringify.ts
@@ -190,9 +168,11 @@ function stringify(token) {
190
168
  var __forward_ref__ = getClosureSafeProperty({ __forward_ref__: getClosureSafeProperty });
191
169
  function forwardRef(forwardRefFn) {
192
170
  forwardRefFn.__forward_ref__ = forwardRef;
193
- forwardRefFn.toString = function() {
194
- return stringify(this());
195
- };
171
+ if (ngDevMode) {
172
+ forwardRefFn.toString = function() {
173
+ return stringify(this());
174
+ };
175
+ }
196
176
  return forwardRefFn;
197
177
  }
198
178
  function resolveForwardRef(type) {
@@ -202,1237 +182,1600 @@ function isForwardRef(fn) {
202
182
  return typeof fn === "function" && fn.hasOwnProperty(__forward_ref__) && fn.__forward_ref__ === forwardRef;
203
183
  }
204
184
 
205
- // src/import/di/interface/defs.ts
206
- function ɵɵdefineInjectable(opts) {
207
- return {
208
- token: opts.token,
209
- providedIn: opts.providedIn || null,
210
- factory: opts.factory,
211
- value: void 0
212
- };
213
- }
214
- function ɵɵdefineInjector(options) {
215
- return { providers: options.providers || [], imports: options.imports || [] };
216
- }
217
- function getInjectableDef(type) {
218
- return getOwnDefinition(type, NG_PROV_DEF) || { token: type, factory: () => new type(), ...type.injectOptions };
185
+ // src/primitives/signals/src/graph.ts
186
+ var activeConsumer = null;
187
+ var inNotificationPhase = false;
188
+ var epoch = 1;
189
+ var postProducerCreatedFn = null;
190
+ var SIGNAL = /* @__PURE__ */ Symbol("SIGNAL");
191
+ function setActiveConsumer(consumer) {
192
+ const prev = activeConsumer;
193
+ activeConsumer = consumer;
194
+ return prev;
219
195
  }
220
- function isInjectable(type) {
221
- return getInjectableDef(type) !== null;
196
+ function getActiveConsumer() {
197
+ return activeConsumer;
222
198
  }
223
- function getOwnDefinition(type, field) {
224
- return type.hasOwnProperty(field) && type[field] || null;
199
+ function isInNotificationPhase() {
200
+ return inNotificationPhase;
225
201
  }
226
- function getInheritedInjectableDef(type) {
227
- const def = type?.[NG_PROV_DEF] ?? null;
228
- if (def) {
229
- return def;
202
+ var REACTIVE_NODE = {
203
+ version: 0,
204
+ lastCleanEpoch: 0,
205
+ dirty: false,
206
+ producers: void 0,
207
+ producersTail: void 0,
208
+ consumers: void 0,
209
+ consumersTail: void 0,
210
+ recomputing: false,
211
+ consumerAllowSignalWrites: false,
212
+ consumerIsAlwaysLive: false,
213
+ kind: "unknown",
214
+ producerMustRecompute: () => false,
215
+ producerRecomputeValue: () => {
216
+ },
217
+ consumerMarkedDirty: () => {
218
+ },
219
+ consumerOnSignalRead: () => {
220
+ }
221
+ };
222
+ function producerAccessed(node) {
223
+ if (inNotificationPhase) {
224
+ throw new Error(typeof ngDevMode !== "undefined" && ngDevMode ? `Assertion error: signal read during notification phase` : "");
225
+ }
226
+ if (activeConsumer === null) {
227
+ return;
228
+ }
229
+ activeConsumer.consumerOnSignalRead(node);
230
+ const prevProducerLink = activeConsumer.producersTail;
231
+ if (prevProducerLink !== void 0 && prevProducerLink.producer === node) {
232
+ return;
233
+ }
234
+ let nextProducerLink = void 0;
235
+ const isRecomputing = activeConsumer.recomputing;
236
+ if (isRecomputing) {
237
+ nextProducerLink = prevProducerLink !== void 0 ? prevProducerLink.nextProducer : activeConsumer.producers;
238
+ if (nextProducerLink !== void 0 && nextProducerLink.producer === node) {
239
+ activeConsumer.producersTail = nextProducerLink;
240
+ nextProducerLink.lastReadVersion = node.version;
241
+ nextProducerLink.knownValidAtEpoch = epoch;
242
+ return;
243
+ }
244
+ }
245
+ const prevConsumerLink = node.consumersTail;
246
+ if (prevConsumerLink !== void 0 && prevConsumerLink.consumer === activeConsumer && (!isRecomputing || prevConsumerLink.knownValidAtEpoch === epoch)) {
247
+ return;
248
+ }
249
+ const isLive = consumerIsLive(activeConsumer);
250
+ const newLink = {
251
+ producer: node,
252
+ consumer: activeConsumer,
253
+ // instead of eagerly destroying the previous link, we delay until we've finished recomputing
254
+ // the producers list, so that we can destroy all of the old links at once.
255
+ nextProducer: nextProducerLink,
256
+ // Don't set prevConsumer here — it's only meaningful when the link is part of
257
+ // the producer's consumer list. producerAddLiveConsumer sets it correctly when
258
+ // the link is actually inserted. Setting it eagerly would create a dangling
259
+ // reference into the consumer list that prevents GC of removed entries.
260
+ prevConsumer: void 0,
261
+ knownValidAtEpoch: epoch,
262
+ lastReadVersion: node.version,
263
+ nextConsumer: void 0
264
+ };
265
+ activeConsumer.producersTail = newLink;
266
+ if (prevProducerLink !== void 0) {
267
+ prevProducerLink.nextProducer = newLink;
230
268
  } else {
231
- return null;
269
+ activeConsumer.producers = newLink;
270
+ }
271
+ if (isLive) {
272
+ producerAddLiveConsumer(node, newLink);
232
273
  }
233
274
  }
234
- function getInjectorDef(type) {
235
- return type && type.hasOwnProperty(NG_INJ_DEF) ? type[NG_INJ_DEF] : null;
275
+ function producerIncrementEpoch() {
276
+ epoch++;
236
277
  }
237
- var NG_PROV_DEF = getClosureSafeProperty({ ɵprov: getClosureSafeProperty });
238
- var NG_INJ_DEF = getClosureSafeProperty({ ɵinj: getClosureSafeProperty });
239
-
240
- // src/import/di/injection_token.ts
241
- var InjectionToken = class {
242
- /**
243
- * @param _desc Description for the token,
244
- * used only for debugging purposes,
245
- * it should but does not need to be unique
246
- * @param options Options for the token's usage, as described above
247
- */
248
- constructor(_desc, options) {
249
- this._desc = _desc;
250
- this.ɵprov = void 0;
251
- if (typeof options === "number") {
252
- } else if (options !== void 0) {
253
- this.ɵprov = ɵɵdefineInjectable({
254
- token: this,
255
- providedIn: options.providedIn || "root",
256
- factory: options.factory
257
- });
258
- }
278
+ function producerUpdateValueVersion(node) {
279
+ if (consumerIsLive(node) && !node.dirty) {
280
+ return;
259
281
  }
260
- /** @internal */
261
- ngMetadataName = "InjectionToken";
262
- ɵprov;
263
- /**
264
- * @internal
265
- */
266
- get multi() {
267
- return this;
282
+ if (!node.dirty && node.lastCleanEpoch === epoch) {
283
+ return;
268
284
  }
269
- toString() {
270
- return `InjectionToken ${this._desc}`;
285
+ if (!node.producerMustRecompute(node) && !consumerPollProducersForChange(node)) {
286
+ producerMarkClean(node);
287
+ return;
271
288
  }
272
- };
273
-
274
- // src/import/di/initializer_token.ts
275
- var ENVIRONMENT_INITIALIZER = new InjectionToken("");
276
-
277
- // src/import/di/interface/injector.ts
278
- var DecoratorFlags = /* @__PURE__ */ ((DecoratorFlags2) => {
279
- DecoratorFlags2[DecoratorFlags2["Inject"] = -1] = "Inject";
280
- return DecoratorFlags2;
281
- })(DecoratorFlags || {});
282
- var InternalInjectFlags = /* @__PURE__ */ ((InternalInjectFlags2) => {
283
- InternalInjectFlags2[InternalInjectFlags2["Default"] = 0] = "Default";
284
- InternalInjectFlags2[InternalInjectFlags2["Host"] = 1] = "Host";
285
- InternalInjectFlags2[InternalInjectFlags2["Self"] = 2] = "Self";
286
- InternalInjectFlags2[InternalInjectFlags2["SkipSelf"] = 4] = "SkipSelf";
287
- InternalInjectFlags2[InternalInjectFlags2["Optional"] = 8] = "Optional";
288
- InternalInjectFlags2[InternalInjectFlags2["ForPipe"] = 16] = "ForPipe";
289
- return InternalInjectFlags2;
290
- })(InternalInjectFlags || {});
291
-
292
- // src/import/di/inject_switch.ts
293
- var _injectImplementation;
294
- function getInjectImplementation() {
295
- return _injectImplementation;
296
- }
297
- function setInjectImplementation(impl) {
298
- const previous = _injectImplementation;
299
- _injectImplementation = impl;
300
- return previous;
289
+ node.producerRecomputeValue(node);
290
+ producerMarkClean(node);
301
291
  }
302
- function injectRootLimpMode(token, notFoundValue, flags) {
303
- const injectableDef = getInjectableDef(token);
304
- if (injectableDef && injectableDef.providedIn == "root") {
305
- return injectableDef.value === void 0 ? injectableDef.value = injectableDef.factory() : injectableDef.value;
292
+ function producerNotifyConsumers(node) {
293
+ if (node.consumers === void 0) {
294
+ return;
295
+ }
296
+ const prev = inNotificationPhase;
297
+ inNotificationPhase = true;
298
+ try {
299
+ for (let link = node.consumers; link !== void 0; link = link.nextConsumer) {
300
+ const consumer = link.consumer;
301
+ if (!consumer.dirty) {
302
+ consumerMarkDirty(consumer);
303
+ }
304
+ }
305
+ } finally {
306
+ inNotificationPhase = prev;
306
307
  }
307
- if (flags & 8 /* Optional */) return null;
308
- if (notFoundValue !== void 0) return notFoundValue;
309
- throwProviderNotFoundError(token, "Injector");
310
308
  }
311
-
312
- // src/primitives/di/src/injector.ts
313
- var _currentInjector = void 0;
314
- function getCurrentInjector() {
315
- return _currentInjector;
309
+ function producerUpdatesAllowed() {
310
+ return activeConsumer?.consumerAllowSignalWrites !== false;
316
311
  }
317
- function setCurrentInjector(injector) {
318
- const former = _currentInjector;
319
- _currentInjector = injector;
320
- return former;
312
+ function consumerMarkDirty(node) {
313
+ node.dirty = true;
314
+ producerNotifyConsumers(node);
315
+ node.consumerMarkedDirty?.(node);
321
316
  }
322
-
323
- // src/primitives/di/src/not_found.ts
324
- var NOT_FOUND = Symbol("NotFound");
325
- function isNotFound(e) {
326
- return e === NOT_FOUND || e?.name === "ɵNotFound";
317
+ function producerMarkClean(node) {
318
+ node.dirty = false;
319
+ node.lastCleanEpoch = epoch;
327
320
  }
328
-
329
- // src/import/di/injector_compatibility.ts
330
- var _THROW_IF_NOT_FOUND = {};
331
- var THROW_IF_NOT_FOUND = _THROW_IF_NOT_FOUND;
332
- var DI_DECORATOR_FLAG = "__NG_DI_FLAG__";
333
- var RetrievingInjector = class {
334
- constructor(injector) {
335
- this.injector = injector;
336
- }
337
- retrieve(token, options) {
338
- const flags = convertToBitFlags(options) || 0 /* Default */;
339
- try {
340
- return this.injector.get(
341
- token,
342
- // When a dependency is requested with an optional flag, DI returns null as the default value.
343
- flags & 8 /* Optional */ ? null : THROW_IF_NOT_FOUND,
344
- flags
345
- );
346
- } catch (e) {
347
- if (isNotFound(e)) {
348
- return e;
349
- }
350
- throw e;
351
- }
352
- }
353
- };
354
- var NG_TEMP_TOKEN_PATH = "ngTempTokenPath";
355
- var NEW_LINE = /\n/gm;
356
- var NO_NEW_LINE = "ɵ";
357
- var SOURCE = "__source";
358
- function injectInjectorOnly(token, flags = 0 /* Default */) {
359
- const currentInjector = getCurrentInjector();
360
- if (currentInjector === void 0) {
361
- throw new RuntimeError(-203 /* MISSING_INJECTION_CONTEXT */, void 0);
362
- } else if (currentInjector === null) {
363
- return injectRootLimpMode(token, void 0, flags);
364
- } else {
365
- const options = convertToInjectOptions(flags);
366
- const value = currentInjector.retrieve(token, options);
367
- if (isNotFound(value)) {
368
- if (options.optional) {
369
- return null;
370
- }
371
- throw value;
321
+ function consumerBeforeComputation(node) {
322
+ if (node) resetConsumerBeforeComputation(node);
323
+ return setActiveConsumer(node);
324
+ }
325
+ function resetConsumerBeforeComputation(node) {
326
+ if (node.producersTail?.knownValidAtEpoch === epoch) {
327
+ let producer = node.producers;
328
+ while (producer !== void 0) {
329
+ producer.knownValidAtEpoch = null;
330
+ producer = producer.nextProducer;
372
331
  }
373
- return value;
374
332
  }
333
+ node.producersTail = void 0;
334
+ node.recomputing = true;
375
335
  }
376
- function ɵɵinject(token, flags = 0 /* Default */) {
377
- return (getInjectImplementation() || injectInjectorOnly)(resolveForwardRef(token), flags);
378
- }
379
- function ɵɵinvalidFactoryDep(index) {
380
- throw new RuntimeError(202 /* INVALID_FACTORY_DEPENDENCY */, void 0);
381
- }
382
- function inject2(token, options) {
383
- return ɵɵinject(token, convertToBitFlags(options));
336
+ function consumerAfterComputation(node, prevConsumer) {
337
+ setActiveConsumer(prevConsumer);
338
+ if (node) finalizeConsumerAfterComputation(node);
384
339
  }
385
- function convertToBitFlags(flags) {
386
- if (typeof flags === "undefined" || typeof flags === "number") {
387
- return flags;
340
+ function finalizeConsumerAfterComputation(node) {
341
+ node.recomputing = false;
342
+ const producersTail = node.producersTail;
343
+ let toRemove = producersTail !== void 0 ? producersTail.nextProducer : node.producers;
344
+ if (toRemove !== void 0) {
345
+ if (consumerIsLive(node)) {
346
+ do {
347
+ toRemove = producerRemoveLiveConsumerLink(toRemove);
348
+ } while (toRemove !== void 0);
349
+ }
350
+ if (producersTail !== void 0) {
351
+ producersTail.nextProducer = void 0;
352
+ } else {
353
+ node.producers = void 0;
354
+ }
388
355
  }
389
- return 0 /* Default */ | // comment to force a line break in the formatter
390
- (flags.optional && 8 /* Optional */) | 0 | (flags.self && 2 /* Self */) | (flags.skipSelf && 4 /* SkipSelf */);
391
- }
392
- function convertToInjectOptions(flags) {
393
- return {
394
- optional: !!(flags & 8 /* Optional */),
395
- host: !!(flags & 1 /* Host */),
396
- self: !!(flags & 2 /* Self */),
397
- skipSelf: !!(flags & 4 /* SkipSelf */)
398
- };
399
356
  }
400
- function injectArgs(types) {
401
- const args = [];
402
- for (let i = 0; i < types.length; i++) {
403
- const arg = resolveForwardRef(types[i]);
404
- if (Array.isArray(arg)) {
405
- if (arg.length === 0) {
406
- throw new RuntimeError(900 /* INVALID_DIFFER_INPUT */, void 0);
407
- }
408
- let type = void 0;
409
- let flags = 0 /* Default */;
410
- for (let j = 0; j < arg.length; j++) {
411
- const meta = arg[j];
412
- const flag = getInjectFlag(meta);
413
- if (typeof flag === "number") {
414
- if (flag === -1 /* Inject */) {
415
- type = meta.token;
416
- } else {
417
- flags |= flag;
418
- }
419
- } else {
420
- type = meta;
421
- }
422
- }
423
- args.push(ɵɵinject(type, flags));
424
- } else {
425
- args.push(ɵɵinject(arg));
357
+ function consumerPollProducersForChange(node) {
358
+ for (let link = node.producers; link !== void 0; link = link.nextProducer) {
359
+ const producer = link.producer;
360
+ const seenVersion = link.lastReadVersion;
361
+ if (seenVersion !== producer.version) {
362
+ return true;
363
+ }
364
+ producerUpdateValueVersion(producer);
365
+ if (seenVersion !== producer.version) {
366
+ return true;
426
367
  }
427
368
  }
428
- return args;
369
+ return false;
429
370
  }
430
- function attachInjectFlag(decorator, flag) {
431
- decorator[DI_DECORATOR_FLAG] = flag;
432
- decorator.prototype[DI_DECORATOR_FLAG] = flag;
433
- return decorator;
371
+ function consumerDestroy(node) {
372
+ if (consumerIsLive(node)) {
373
+ let link = node.producers;
374
+ while (link !== void 0) {
375
+ link = producerRemoveLiveConsumerLink(link);
376
+ }
377
+ }
378
+ node.producers = void 0;
379
+ node.producersTail = void 0;
380
+ node.consumers = void 0;
381
+ node.consumersTail = void 0;
434
382
  }
435
- function getInjectFlag(token) {
436
- return token[DI_DECORATOR_FLAG];
383
+ function producerAddLiveConsumer(node, link) {
384
+ const consumersTail = node.consumersTail;
385
+ const wasLive = consumerIsLive(node);
386
+ if (consumersTail !== void 0) {
387
+ link.nextConsumer = consumersTail.nextConsumer;
388
+ consumersTail.nextConsumer = link;
389
+ } else {
390
+ link.nextConsumer = void 0;
391
+ node.consumers = link;
392
+ }
393
+ link.prevConsumer = consumersTail;
394
+ node.consumersTail = link;
395
+ if (!wasLive) {
396
+ for (let link2 = node.producers; link2 !== void 0; link2 = link2.nextProducer) {
397
+ producerAddLiveConsumer(link2.producer, link2);
398
+ }
399
+ }
437
400
  }
438
- function formatError(text, obj, injectorErrorName, source = null) {
439
- text = text && text.charAt(0) === "\n" && text.charAt(1) == NO_NEW_LINE ? text.slice(2) : text;
440
- let context = stringify(obj);
441
- if (Array.isArray(obj)) {
442
- context = obj.map(stringify).join(" -> ");
443
- } else if (typeof obj === "object") {
444
- const parts = [];
445
- for (const key in obj) {
446
- if (obj.hasOwnProperty(key)) {
447
- const value = obj[key];
448
- parts.push(key + ":" + (typeof value === "string" ? JSON.stringify(value) : stringify(value)));
401
+ function producerRemoveLiveConsumerLink(link) {
402
+ const producer = link.producer;
403
+ const nextProducer = link.nextProducer;
404
+ const nextConsumer = link.nextConsumer;
405
+ const prevConsumer = link.prevConsumer;
406
+ link.nextConsumer = void 0;
407
+ link.prevConsumer = void 0;
408
+ if (nextConsumer !== void 0) {
409
+ nextConsumer.prevConsumer = prevConsumer;
410
+ } else {
411
+ producer.consumersTail = prevConsumer;
412
+ }
413
+ if (prevConsumer !== void 0) {
414
+ prevConsumer.nextConsumer = nextConsumer;
415
+ } else {
416
+ producer.consumers = nextConsumer;
417
+ if (!consumerIsLive(producer)) {
418
+ let producerLink = producer.producers;
419
+ while (producerLink !== void 0) {
420
+ producerLink = producerRemoveLiveConsumerLink(producerLink);
449
421
  }
450
422
  }
451
- context = `{${parts.join(", ")}}`;
452
423
  }
453
- return `${injectorErrorName}${source ? "(" + source + ")" : ""}[${context}]: ${text.replace(NEW_LINE, "\n ")}`;
424
+ return nextProducer;
425
+ }
426
+ function consumerIsLive(node) {
427
+ return node.consumerIsAlwaysLive || node.consumers !== void 0;
428
+ }
429
+ function runPostProducerCreatedFn(node) {
430
+ postProducerCreatedFn?.(node);
454
431
  }
455
432
 
456
- // src/import/di/injector_token.ts
457
- var INJECTOR = new InjectionToken(
458
- "",
459
- // Disable tslint because this is const enum which gets inlined not top level prop access.
460
- // tslint:disable-next-line: no-toplevel-property-access
461
- -1 /* Injector */
462
- // Special value used by Ivy to identify `Injector`.
463
- );
464
-
465
- // src/import/di/internal_tokens.ts
466
- var INJECTOR_DEF_TYPES = new InjectionToken("");
467
-
468
- // src/import/di/null_injector.ts
469
- var NullInjector = class {
470
- get(token, notFoundValue = THROW_IF_NOT_FOUND) {
471
- if (notFoundValue === THROW_IF_NOT_FOUND) {
472
- const message = "";
473
- const error = createRuntimeError(message, -201 /* PROVIDER_NOT_FOUND */);
474
- error.name = "ɵNotFound";
475
- throw error;
433
+ // src/primitives/signals/src/formatter.ts
434
+ var formatter = {
435
+ /**
436
+ * If the function returns `null`, the formatter is not used for this reference
437
+ */
438
+ header: (sig, config) => {
439
+ if (!isSignal(sig) || config?.ngSkipFormatting) return null;
440
+ let value;
441
+ try {
442
+ value = sig();
443
+ } catch (e) {
444
+ return ["span", `Signal(⚠️ Error)${e.message ? `: ${e.message}` : ""}`];
445
+ }
446
+ const kind = "computation" in sig[SIGNAL] ? "Computed" : "Signal";
447
+ const isPrimitive = value === null || !Array.isArray(value) && typeof value !== "object";
448
+ return [
449
+ "span",
450
+ {},
451
+ ["span", {}, `${kind}(`],
452
+ (() => {
453
+ if (isSignal(value)) {
454
+ return formatter.header(value, config);
455
+ } else if (isPrimitive && value !== void 0 && typeof value !== "function") {
456
+ return ["object", { object: value }];
457
+ } else {
458
+ return prettifyPreview(value);
459
+ }
460
+ })(),
461
+ ["span", {}, `)`]
462
+ ];
463
+ },
464
+ hasBody: (sig, config) => {
465
+ if (!isSignal(sig)) return false;
466
+ try {
467
+ sig();
468
+ } catch {
469
+ return false;
476
470
  }
477
- return notFoundValue;
471
+ return !config?.ngSkipFormatting;
472
+ },
473
+ body: (sig, config) => {
474
+ const color = "var(--sys-color-primary)";
475
+ return [
476
+ "div",
477
+ { style: `background: #FFFFFF10; padding-left: 4px; padding-top: 2px; padding-bottom: 2px;` },
478
+ ["div", { style: `color: ${color}` }, "Signal value: "],
479
+ ["div", { style: `padding-left: .5rem;` }, ["object", { object: sig(), config }]],
480
+ ["div", { style: `color: ${color}` }, "Signal function: "],
481
+ ["div", { style: `padding-left: .5rem;` }, ["object", { object: sig, config: { ...config, ngSkipFormatting: true } }]]
482
+ ];
478
483
  }
479
484
  };
480
-
481
- // src/import/di/provider_collection.ts
482
- var USE_VALUE = getClosureSafeProperty({
483
- provide: String,
484
- useValue: getClosureSafeProperty
485
- });
486
- function isValueProvider(value) {
487
- return value !== null && typeof value === "object" && USE_VALUE in value;
488
- }
489
- function isExistingProvider(value) {
490
- return !!(value && value.useExisting);
485
+ function prettifyPreview(value) {
486
+ if (value === null) return "null";
487
+ if (Array.isArray(value)) return `Array(${value.length})`;
488
+ if (value instanceof Element) return `<${value.tagName.toLowerCase()}>`;
489
+ if (value instanceof URL) return `URL`;
490
+ switch (typeof value) {
491
+ case "undefined": {
492
+ return "undefined";
493
+ }
494
+ case "function": {
495
+ if ("prototype" in value) {
496
+ return "class";
497
+ } else {
498
+ return "() => {…}";
499
+ }
500
+ }
501
+ case "object": {
502
+ if (value.constructor.name === "Object") {
503
+ return "{…}";
504
+ } else {
505
+ return `${value.constructor.name} {}`;
506
+ }
507
+ }
508
+ default: {
509
+ return ["object", { object: value, config: { ngSkipFormatting: true } }];
510
+ }
511
+ }
491
512
  }
492
- function isFactoryProvider(value) {
493
- return !!(value && value.useFactory);
513
+ function isSignal(value) {
514
+ return value[SIGNAL] !== void 0;
494
515
  }
495
- function isTypeProvider(value) {
496
- return typeof value === "function";
516
+ function installDevToolsSignalFormatter() {
517
+ globalThis.devtoolsFormatters ??= [];
518
+ if (!globalThis.devtoolsFormatters.some((f) => f === formatter)) {
519
+ globalThis.devtoolsFormatters.push(formatter);
520
+ }
497
521
  }
498
522
 
499
- // src/import/di/scope.ts
500
- var INJECTOR_SCOPE = new InjectionToken("");
523
+ // src/primitives/signals/src/equality.ts
524
+ function defaultEquals(a, b) {
525
+ return Object.is(a, b);
526
+ }
501
527
 
502
- // src/import/di/r3_injector.ts
503
- var NOT_YET = {};
504
- var CIRCULAR = {};
505
- var NULL_INJECTOR = void 0;
506
- function getNullInjector() {
507
- if (NULL_INJECTOR === void 0) {
508
- NULL_INJECTOR = new NullInjector();
528
+ // src/primitives/signals/src/computed.ts
529
+ function createComputed(computation, equal) {
530
+ const node = Object.create(COMPUTED_NODE);
531
+ node.computation = computation;
532
+ if (equal !== void 0) {
533
+ node.equal = equal;
509
534
  }
510
- return NULL_INJECTOR;
511
- }
512
- var EnvironmentInjector = class {
513
- };
514
- var R3Injector = class extends EnvironmentInjector {
515
- constructor(providers, parent, source, scopes) {
516
- super();
517
- this.parent = parent;
518
- this.source = source;
519
- this.scopes = scopes;
520
- forEachSingleProvider(providers, (provider) => this.processProvider(provider));
521
- this.records.set(INJECTOR, makeRecord(void 0, this));
522
- if (scopes.has("environment")) {
523
- this.records.set(EnvironmentInjector, makeRecord(void 0, this));
524
- }
525
- const record = this.records.get(INJECTOR_SCOPE);
526
- if (record != null && typeof record.value === "string") {
527
- this.scopes.add(record.value);
535
+ const computed2 = () => {
536
+ producerUpdateValueVersion(node);
537
+ producerAccessed(node);
538
+ if (node.value === ERRORED) {
539
+ throw node.error;
528
540
  }
529
- this.injectorDefTypes = new Set(this.get(INJECTOR_DEF_TYPES, EMPTY_ARRAY, { self: true }));
530
- }
531
- /**
532
- * Map of tokens to records which contain the instances of those tokens.
533
- * - `null` value implies that we don't have the record. Used by tree-shakable injectors
534
- * to prevent further searches.
535
- */
536
- records = /* @__PURE__ */ new Map();
537
- /**
538
- * Set of values instantiated by this injector which contain `ngOnDestroy` lifecycle hooks.
539
- */
540
- _ngOnDestroyHooks = /* @__PURE__ */ new Set();
541
- _onDestroyHooks = [];
542
- /**
543
- * Flag indicating that this injector was previously destroyed.
544
- */
545
- get destroyed() {
546
- return this._destroyed;
541
+ return node.value;
542
+ };
543
+ computed2[SIGNAL] = node;
544
+ if (typeof ngDevMode !== "undefined" && ngDevMode) {
545
+ computed2.toString = () => `[Computed${node.debugName ? " (" + node.debugName + ")" : ""}: ${String(node.value)}]`;
547
546
  }
548
- _destroyed = false;
549
- injectorDefTypes;
550
- retrieve(token, options) {
551
- const flags = convertToBitFlags(options) || 0 /* Default */;
552
- try {
553
- return this.get(
554
- token,
555
- // When a dependency is requested with an optional flag, DI returns null as the default value.
556
- THROW_IF_NOT_FOUND,
557
- flags
558
- );
559
- } catch (e) {
560
- if (isNotFound(e)) {
561
- return e;
562
- }
563
- throw e;
547
+ runPostProducerCreatedFn(node);
548
+ return computed2;
549
+ }
550
+ var UNSET = /* @__PURE__ */ Symbol("UNSET");
551
+ var COMPUTING = /* @__PURE__ */ Symbol("COMPUTING");
552
+ var ERRORED = /* @__PURE__ */ Symbol("ERRORED");
553
+ var COMPUTED_NODE = /* @__PURE__ */ (() => ({
554
+ ...REACTIVE_NODE,
555
+ value: UNSET,
556
+ dirty: true,
557
+ error: null,
558
+ equal: defaultEquals,
559
+ kind: "computed",
560
+ producerMustRecompute(node) {
561
+ return node.value === UNSET || node.value === COMPUTING;
562
+ },
563
+ producerRecomputeValue(node) {
564
+ if (node.value === COMPUTING) {
565
+ throw new Error(typeof ngDevMode !== "undefined" && ngDevMode ? "Detected cycle in computations." : "");
564
566
  }
565
- }
566
- /**
567
- * Destroy the injector and release references to every instance or provider associated with it.
568
- *
569
- * Also calls the `OnDestroy` lifecycle hooks of every instance that was created for which a
570
- * hook was found.
571
- */
572
- destroy() {
573
- assertNotDestroyed(this);
574
- this._destroyed = true;
567
+ const oldValue = node.value;
568
+ node.value = COMPUTING;
569
+ const prevConsumer = consumerBeforeComputation(node);
570
+ let newValue;
571
+ let wasEqual = false;
575
572
  try {
576
- for (const service of this._ngOnDestroyHooks) {
577
- service.ngOnDestroy();
578
- }
579
- const onDestroyHooks = this._onDestroyHooks;
580
- this._onDestroyHooks = [];
581
- for (const hook of onDestroyHooks) {
582
- hook();
583
- }
573
+ newValue = node.computation();
574
+ setActiveConsumer(null);
575
+ wasEqual = oldValue !== UNSET && oldValue !== ERRORED && newValue !== ERRORED && node.equal(oldValue, newValue);
576
+ } catch (err) {
577
+ newValue = ERRORED;
578
+ node.error = err;
584
579
  } finally {
585
- this.records.clear();
586
- this._ngOnDestroyHooks.clear();
587
- this.injectorDefTypes.clear();
588
- }
589
- }
590
- onDestroy(callback) {
591
- assertNotDestroyed(this);
592
- this._onDestroyHooks.push(callback);
593
- return () => this.removeOnDestroy(callback);
594
- }
595
- runInContext(fn) {
596
- assertNotDestroyed(this);
597
- const previousInjector = setCurrentInjector(this);
598
- const previousInjectImplementation = setInjectImplementation(void 0);
599
- if (false) {
580
+ consumerAfterComputation(node, prevConsumer);
600
581
  }
601
- try {
602
- return fn();
603
- } finally {
604
- setCurrentInjector(previousInjector);
605
- setInjectImplementation(previousInjectImplementation);
582
+ if (wasEqual) {
583
+ node.value = oldValue;
584
+ return;
606
585
  }
586
+ node.value = newValue;
587
+ node.version++;
607
588
  }
608
- get(token, notFoundValue = THROW_IF_NOT_FOUND, options) {
609
- assertNotDestroyed(this);
610
- if (token.hasOwnProperty(NG_ENV_ID)) {
611
- return token[NG_ENV_ID](this);
612
- }
613
- const flags = convertToBitFlags(options);
614
- if (false) {
615
- }
616
- const previousInjector = setCurrentInjector(this);
617
- const previousInjectImplementation = setInjectImplementation(void 0);
618
- try {
619
- if (!(flags & 4 /* SkipSelf */)) {
620
- let record = this.records.get(token);
621
- if (record === void 0) {
622
- const def = couldBeInjectableType(token) && getInjectableDef(token);
623
- if (def && this.injectableDefInScope(def)) {
624
- if (false) {
625
- }
626
- record = makeRecord(injectableDefOrInjectorDefFactory(token), NOT_YET);
627
- } else {
628
- record = null;
629
- }
630
- this.records.set(token, record);
631
- }
632
- if (record != null) {
633
- return this.hydrate(token, record, flags);
634
- }
635
- }
636
- const nextInjector = !(flags & 2 /* Self */) ? this.parent : getNullInjector();
637
- notFoundValue = flags & 8 /* Optional */ && notFoundValue === THROW_IF_NOT_FOUND ? null : notFoundValue;
638
- return nextInjector.get(token, notFoundValue);
639
- } catch (error) {
640
- const errorCode = getRuntimeErrorCode(error);
641
- if (errorCode === -200 /* CYCLIC_DI_DEPENDENCY */ || errorCode === -201 /* PROVIDER_NOT_FOUND */) {
642
- if (false) {
643
- } else {
644
- throw new RuntimeError(errorCode, null);
645
- }
646
- } else {
647
- throw error;
648
- }
649
- } finally {
650
- setInjectImplementation(previousInjectImplementation);
651
- setCurrentInjector(previousInjector);
652
- }
589
+ }))();
590
+
591
+ // src/primitives/signals/src/errors.ts
592
+ function defaultThrowError() {
593
+ throw new Error();
594
+ }
595
+ var throwInvalidWriteToSignalErrorFn = defaultThrowError;
596
+ function throwInvalidWriteToSignalError(node) {
597
+ throwInvalidWriteToSignalErrorFn(node);
598
+ }
599
+
600
+ // src/primitives/signals/src/signal.ts
601
+ var postSignalSetFn = null;
602
+ function createSignal(initialValue, equal) {
603
+ const node = Object.create(SIGNAL_NODE);
604
+ node.value = initialValue;
605
+ if (equal !== void 0) {
606
+ node.equal = equal;
653
607
  }
654
- /** @internal */
655
- resolveInjectorInitializers() {
656
- const previousInjector = setCurrentInjector(this);
657
- const previousInjectImplementation = setInjectImplementation(void 0);
658
- if (false) {
659
- }
660
- try {
661
- const initializers = this.get(ENVIRONMENT_INITIALIZER, EMPTY_ARRAY, { self: true });
662
- if (false) {
663
- }
664
- for (const initializer of initializers) {
665
- initializer();
666
- }
667
- } finally {
668
- setCurrentInjector(previousInjector);
669
- setInjectImplementation(previousInjectImplementation);
670
- }
608
+ const getter = () => signalGetFn(node);
609
+ getter[SIGNAL] = node;
610
+ if (typeof ngDevMode !== "undefined" && ngDevMode) {
611
+ getter.toString = () => `[Signal${node.debugName ? " (" + node.debugName + ")" : ""}: ${String(node.value)}]`;
671
612
  }
672
- toString() {
673
- const tokens = [];
674
- const records = this.records;
675
- for (const token of records.keys()) {
676
- tokens.push(stringify(token));
677
- }
678
- return `R3Injector[${tokens.join(", ")}]`;
613
+ runPostProducerCreatedFn(node);
614
+ const set = (newValue) => signalSetFn(node, newValue);
615
+ const update = (updateFn) => signalUpdateFn(node, updateFn);
616
+ return [getter, set, update];
617
+ }
618
+ function signalGetFn(node) {
619
+ producerAccessed(node);
620
+ return node.value;
621
+ }
622
+ function signalSetFn(node, newValue) {
623
+ if (!producerUpdatesAllowed()) {
624
+ throwInvalidWriteToSignalError(node);
679
625
  }
680
- /**
681
- * Process a `SingleProvider` and add it.
682
- */
683
- processProvider(provider) {
684
- provider = resolveForwardRef(provider);
685
- let token = isTypeProvider(provider) ? provider : resolveForwardRef(provider && provider.provide);
686
- const record = providerToRecord(provider);
687
- if (false) {
688
- }
689
- if (!isTypeProvider(provider) && provider.multi === true) {
690
- let multiRecord = this.records.get(token);
691
- if (multiRecord) {
692
- if (false) {
693
- }
694
- } else {
695
- multiRecord = makeRecord(void 0, NOT_YET, true);
696
- multiRecord.factory = () => injectArgs(multiRecord.multi);
697
- this.records.set(token, multiRecord);
698
- }
699
- token = provider;
700
- multiRecord.multi.push(provider);
701
- } else {
702
- if (false) {
703
- }
704
- }
705
- this.records.set(token, record);
626
+ if (!node.equal(node.value, newValue)) {
627
+ node.value = newValue;
628
+ signalValueChanged(node);
706
629
  }
707
- hydrate(token, record, flags) {
708
- try {
709
- if (record.value === CIRCULAR) {
710
- throw cyclicDependencyError(stringify(token));
711
- } else if (record.value === NOT_YET) {
712
- record.value = CIRCULAR;
713
- if (false) {
714
- } else {
715
- record.value = record.factory(void 0, flags);
716
- }
717
- }
718
- if (typeof record.value === "object" && record.value && hasOnDestroy(record.value)) {
719
- this._ngOnDestroyHooks.add(record.value);
720
- }
721
- return record.value;
722
- } finally {
723
- }
630
+ }
631
+ function signalUpdateFn(node, updater) {
632
+ if (!producerUpdatesAllowed()) {
633
+ throwInvalidWriteToSignalError(node);
724
634
  }
725
- injectableDefInScope(def) {
726
- if (!def.providedIn) {
727
- return false;
728
- }
729
- const providedIn = resolveForwardRef(def.providedIn);
730
- if (typeof providedIn === "string") {
731
- return providedIn === "any" || this.scopes.has(providedIn);
732
- } else {
733
- return this.injectorDefTypes.has(providedIn);
734
- }
635
+ signalSetFn(node, updater(node.value));
636
+ }
637
+ var SIGNAL_NODE = /* @__PURE__ */ (() => ({
638
+ ...REACTIVE_NODE,
639
+ equal: defaultEquals,
640
+ value: void 0,
641
+ kind: "signal"
642
+ }))();
643
+ function signalValueChanged(node) {
644
+ node.version++;
645
+ producerIncrementEpoch();
646
+ producerNotifyConsumers(node);
647
+ postSignalSetFn?.(node);
648
+ }
649
+
650
+ // src/primitives/signals/src/linked_signal.ts
651
+ function createLinkedSignal(sourceFn, computationFn, equalityFn) {
652
+ const node = Object.create(LINKED_SIGNAL_NODE);
653
+ node.source = sourceFn;
654
+ node.computation = computationFn;
655
+ if (equalityFn != void 0) {
656
+ node.equal = equalityFn;
735
657
  }
736
- removeOnDestroy(callback) {
737
- const destroyCBIdx = this._onDestroyHooks.indexOf(callback);
738
- if (destroyCBIdx !== -1) {
739
- this._onDestroyHooks.splice(destroyCBIdx, 1);
658
+ const linkedSignalGetter = () => {
659
+ producerUpdateValueVersion(node);
660
+ producerAccessed(node);
661
+ if (node.value === ERRORED) {
662
+ throw node.error;
740
663
  }
664
+ return node.value;
665
+ };
666
+ const getter = linkedSignalGetter;
667
+ getter[SIGNAL] = node;
668
+ if (typeof ngDevMode !== "undefined" && ngDevMode) {
669
+ getter.toString = () => `[LinkedSignal${node.debugName ? " (" + node.debugName + ")" : ""}: ${String(node.value)}]`;
741
670
  }
742
- };
743
- function injectableDefOrInjectorDefFactory(token) {
744
- const injectableDef = getInjectableDef(token);
745
- const factory = injectableDef !== null ? injectableDef.factory : getFactoryDef(token);
746
- if (factory !== null) {
747
- return factory;
671
+ runPostProducerCreatedFn(node);
672
+ return getter;
673
+ }
674
+ function linkedSignalSetFn(node, newValue) {
675
+ producerUpdateValueVersion(node);
676
+ signalSetFn(node, newValue);
677
+ producerMarkClean(node);
678
+ }
679
+ function linkedSignalUpdateFn(node, updater) {
680
+ producerUpdateValueVersion(node);
681
+ if (node.value === ERRORED) {
682
+ throw node.error;
748
683
  }
749
- if (token instanceof InjectionToken) {
750
- throw new RuntimeError(204 /* INVALID_INJECTION_TOKEN */, void 0);
684
+ signalUpdateFn(node, updater);
685
+ producerMarkClean(node);
686
+ }
687
+ var LINKED_SIGNAL_NODE = /* @__PURE__ */ (() => ({
688
+ ...REACTIVE_NODE,
689
+ value: UNSET,
690
+ dirty: true,
691
+ error: null,
692
+ equal: defaultEquals,
693
+ kind: "linkedSignal",
694
+ producerMustRecompute(node) {
695
+ return node.value === UNSET || node.value === COMPUTING;
696
+ },
697
+ producerRecomputeValue(node) {
698
+ if (node.value === COMPUTING) {
699
+ throw new Error(typeof ngDevMode !== "undefined" && ngDevMode ? "Detected cycle in computations." : "");
700
+ }
701
+ const oldValue = node.value;
702
+ node.value = COMPUTING;
703
+ const prevConsumer = consumerBeforeComputation(node);
704
+ let newValue;
705
+ let wasEqual = false;
706
+ try {
707
+ const newSourceValue = node.source();
708
+ const oldValueValid = oldValue !== UNSET && oldValue !== ERRORED;
709
+ const prev = oldValueValid ? {
710
+ source: node.sourceValue,
711
+ value: oldValue
712
+ } : void 0;
713
+ newValue = node.computation(newSourceValue, prev);
714
+ node.sourceValue = newSourceValue;
715
+ setActiveConsumer(null);
716
+ wasEqual = oldValueValid && newValue !== ERRORED && node.equal(oldValue, newValue);
717
+ } catch (err) {
718
+ newValue = ERRORED;
719
+ node.error = err;
720
+ } finally {
721
+ consumerAfterComputation(node, prevConsumer);
722
+ }
723
+ if (wasEqual) {
724
+ node.value = oldValue;
725
+ return;
726
+ }
727
+ node.value = newValue;
728
+ node.version++;
751
729
  }
752
- if (token instanceof Function) {
753
- return getUndecoratedInjectableFactory(token);
730
+ }))();
731
+
732
+ // src/primitives/signals/src/untracked.ts
733
+ function untracked(nonReactiveReadsFn) {
734
+ const prevConsumer = setActiveConsumer(null);
735
+ try {
736
+ return nonReactiveReadsFn();
737
+ } finally {
738
+ setActiveConsumer(prevConsumer);
754
739
  }
755
- throw new RuntimeError(204 /* INVALID_INJECTION_TOKEN */, void 0);
756
740
  }
757
- function getUndecoratedInjectableFactory(token) {
758
- const paramLength = token.length;
759
- if (paramLength > 0) {
760
- throw new RuntimeError(204 /* INVALID_INJECTION_TOKEN */, void 0);
741
+
742
+ // src/primitives/signals/src/effect.ts
743
+ var BASE_EFFECT_NODE = /* @__PURE__ */ (() => ({
744
+ ...REACTIVE_NODE,
745
+ consumerIsAlwaysLive: true,
746
+ consumerAllowSignalWrites: true,
747
+ dirty: true,
748
+ kind: "effect"
749
+ }))();
750
+ function runEffect(node) {
751
+ node.dirty = false;
752
+ if (node.version > 0 && !consumerPollProducersForChange(node)) {
753
+ return;
761
754
  }
762
- const inheritedInjectableDef = getInheritedInjectableDef(token);
763
- if (inheritedInjectableDef !== null) {
764
- return () => inheritedInjectableDef.factory(token);
765
- } else {
766
- return () => new token();
755
+ node.version++;
756
+ const prevNode = consumerBeforeComputation(node);
757
+ try {
758
+ node.cleanup();
759
+ node.fn();
760
+ } finally {
761
+ consumerAfterComputation(node, prevNode);
767
762
  }
768
763
  }
769
- function providerToRecord(provider) {
770
- if (isValueProvider(provider)) {
771
- return makeRecord(void 0, provider.useValue);
772
- } else {
773
- const factory = providerToFactory(provider);
774
- return makeRecord(factory, NOT_YET);
775
- }
764
+
765
+ // src/primitives/signals/index.ts
766
+ if (typeof ngDevMode === "undefined" || ngDevMode) {
767
+ installDevToolsSignalFormatter();
776
768
  }
777
- function providerToFactory(provider, ngModuleType, providers) {
778
- let factory = void 0;
779
- if (false) {
780
- }
781
- if (isTypeProvider(provider)) {
782
- const unwrappedProvider = resolveForwardRef(provider);
783
- return getFactoryDef(unwrappedProvider) || injectableDefOrInjectorDefFactory(unwrappedProvider);
784
- } else {
785
- if (isValueProvider(provider)) {
786
- factory = () => resolveForwardRef(provider.useValue);
787
- } else if (isFactoryProvider(provider)) {
788
- factory = () => provider.useFactory(...injectArgs(provider.deps || []));
789
- } else if (isExistingProvider(provider)) {
790
- factory = (_, flags) => ɵɵinject(resolveForwardRef(provider.useExisting), flags !== void 0 && flags & 8 /* Optional */ ? 8 /* Optional */ : void 0);
791
- } else {
792
- const classRef = resolveForwardRef(provider && (provider.useClass || provider.provide));
793
- if (false) {
794
- }
795
- if (hasDeps(provider)) {
796
- factory = () => new classRef(...injectArgs(provider.deps));
797
- } else {
798
- return getFactoryDef(classRef) || injectableDefOrInjectorDefFactory(classRef);
799
- }
800
- }
769
+
770
+ // src/import/util/assert.ts
771
+ function assertLessThan(actual, expected, msg) {
772
+ if (!(actual < expected)) {
773
+ throwError(msg, actual, expected, "<");
801
774
  }
802
- return factory;
803
775
  }
804
- function assertNotDestroyed(injector) {
805
- if (injector.destroyed) {
806
- throw new RuntimeError(205 /* INJECTOR_ALREADY_DESTROYED */, void 0);
776
+ function assertDefined(actual, msg) {
777
+ if (actual == null) {
778
+ throwError(msg, actual, null, "!=");
807
779
  }
808
780
  }
809
- function makeRecord(factory, value, multi = false) {
781
+ function throwError(msg, actual, expected, comparison) {
782
+ throw new Error(`ASSERTION ERROR: ${msg}` + (comparison == null ? "" : ` [Expected=> ${expected} ${comparison} ${actual} <=Actual]`));
783
+ }
784
+
785
+ // src/import/di/interface/defs.ts
786
+ function ɵɵdefineInjectable(opts) {
810
787
  return {
811
- factory,
812
- value,
813
- multi: multi ? [] : void 0
788
+ token: opts.token,
789
+ providedIn: opts.providedIn || null,
790
+ factory: opts.factory,
791
+ value: void 0
814
792
  };
815
793
  }
816
- function hasDeps(value) {
817
- return !!value.deps;
794
+ function ɵɵdefineInjector(options) {
795
+ return { providers: options.providers || [], imports: options.imports || [] };
818
796
  }
819
- function hasOnDestroy(value) {
820
- return value !== null && typeof value === "object" && typeof value.ngOnDestroy === "function";
797
+ function getInjectableDef(type) {
798
+ return getOwnDefinition(type, NG_PROV_DEF) || { token: type, factory: () => new type(), ...type.injectOptions };
821
799
  }
822
- function couldBeInjectableType(value) {
823
- return typeof value === "function" || typeof value === "object" && value.ngMetadataName === "InjectionToken";
800
+ function isInjectable(type) {
801
+ return getInjectableDef(type) !== null;
824
802
  }
825
- function forEachSingleProvider(providers, fn) {
826
- for (const provider of providers) {
827
- if (Array.isArray(provider)) {
828
- forEachSingleProvider(provider, fn);
829
- } else if (provider && isEnvironmentProviders(provider)) {
830
- forEachSingleProvider(provider.ɵproviders, fn);
831
- } else {
832
- fn(provider);
833
- }
803
+ function getOwnDefinition(type, field) {
804
+ return type.hasOwnProperty(field) && type[field] || null;
805
+ }
806
+ function getInheritedInjectableDef(type) {
807
+ const def = type?.[NG_PROV_DEF] ?? null;
808
+ if (def) {
809
+ ngDevMode && console.warn(
810
+ `DEPRECATED: DI is instantiating a token "${type.name}" that inherits its @Injectable decorator but does not provide one itself.
811
+ This will become an error in a future version of Angular. Please add @Injectable() to the "${type.name}" class.`
812
+ );
813
+ return def;
814
+ } else {
815
+ return null;
834
816
  }
835
817
  }
836
-
837
- // src/import/util/closure.ts
838
- function noSideEffects(fn) {
839
- return { toString: fn }.toString();
818
+ function getInjectorDef(type) {
819
+ return type && type.hasOwnProperty(NG_INJ_DEF) ? type[NG_INJ_DEF] : null;
840
820
  }
821
+ var NG_PROV_DEF = getClosureSafeProperty({ ɵprov: getClosureSafeProperty });
822
+ var NG_INJ_DEF = getClosureSafeProperty({ ɵinj: getClosureSafeProperty });
841
823
 
842
- // src/import/util/decorators.ts
843
- function makeMetadataCtor(props) {
844
- return function ctor(...args) {
845
- if (props) {
846
- const values = props(...args);
847
- for (const propName in values) {
848
- this[propName] = values[propName];
849
- }
824
+ // src/import/di/injection_token.ts
825
+ var InjectionToken = class {
826
+ constructor(_desc, options) {
827
+ this._desc = _desc;
828
+ this.ɵprov = void 0;
829
+ if (typeof options === "number") {
830
+ (typeof ngDevMode === "undefined" || ngDevMode) && assertLessThan(options, 0, "Only negative numbers are supported here");
831
+ } else if (options !== void 0) {
832
+ this.ɵprov = ɵɵdefineInjectable({
833
+ token: this,
834
+ providedIn: options.providedIn || "root",
835
+ factory: options.factory
836
+ });
850
837
  }
851
- };
838
+ }
839
+ /** @internal */
840
+ ngMetadataName = "InjectionToken";
841
+ ɵprov;
842
+ /**
843
+ * @internal
844
+ */
845
+ get multi() {
846
+ return this;
847
+ }
848
+ toString() {
849
+ return `InjectionToken ${this._desc}`;
850
+ }
851
+ };
852
+
853
+ // src/import/render3/debug/injector_profiler.ts
854
+ var _injectorProfilerContext;
855
+ function getInjectorProfilerContext() {
856
+ !ngDevMode && throwError("getInjectorProfilerContext should never be called in production mode");
857
+ return _injectorProfilerContext;
858
+ }
859
+ function setInjectorProfilerContext(context) {
860
+ !ngDevMode && throwError("setInjectorProfilerContext should never be called in production mode");
861
+ const previous = _injectorProfilerContext;
862
+ _injectorProfilerContext = context;
863
+ return previous;
852
864
  }
853
- function makeParamDecorator(name, props, parentClass) {
854
- return noSideEffects(() => {
855
- const metaCtor = makeMetadataCtor(props);
856
- function ParamDecoratorFactory(...args) {
857
- metaCtor.apply(this, args);
858
- return this;
859
- }
860
- if (parentClass) {
861
- }
862
- return ParamDecoratorFactory;
865
+ var injectorProfilerCallbacks = [];
866
+ function injectorProfiler(event) {
867
+ !ngDevMode && throwError("Injector profiler should never be called in production mode");
868
+ for (let i = 0; i < injectorProfilerCallbacks.length; i++) {
869
+ const injectorProfilerCallback = injectorProfilerCallbacks[i];
870
+ injectorProfilerCallback(event);
871
+ }
872
+ }
873
+ function emitProviderConfiguredEvent(eventProvider, isViewProvider = false) {
874
+ !ngDevMode && throwError("Injector profiler should never be called in production mode");
875
+ let token;
876
+ if (typeof eventProvider === "function") {
877
+ token = eventProvider;
878
+ } else if (eventProvider instanceof InjectionToken) {
879
+ token = eventProvider;
880
+ } else {
881
+ token = resolveForwardRef(eventProvider.provide);
882
+ }
883
+ let provider = eventProvider;
884
+ if (eventProvider instanceof InjectionToken) {
885
+ provider = eventProvider.ɵprov || eventProvider;
886
+ }
887
+ injectorProfiler({
888
+ type: 2 /* ProviderConfigured */,
889
+ context: getInjectorProfilerContext(),
890
+ providerRecord: { token, provider, isViewProvider }
891
+ });
892
+ }
893
+ function emitInjectorToCreateInstanceEvent(token) {
894
+ !ngDevMode && throwError("Injector profiler should never be called in production mode");
895
+ injectorProfiler({
896
+ type: 5 /* InjectorToCreateInstanceEvent */,
897
+ context: getInjectorProfilerContext(),
898
+ token
863
899
  });
864
900
  }
901
+ function emitInstanceCreatedByInjectorEvent(instance) {
902
+ !ngDevMode && throwError("Injector profiler should never be called in production mode");
903
+ injectorProfiler({
904
+ type: 1 /* InstanceCreatedByInjector */,
905
+ context: getInjectorProfilerContext(),
906
+ instance: { value: instance }
907
+ });
908
+ }
909
+ function emitInjectEvent(token, value, flags) {
910
+ !ngDevMode && throwError("Injector profiler should never be called in production mode");
911
+ injectorProfiler({
912
+ type: 0 /* Inject */,
913
+ context: getInjectorProfilerContext(),
914
+ service: { token, value, flags }
915
+ });
916
+ }
917
+ function emitEffectCreatedEvent(effect2) {
918
+ !ngDevMode && throwError("Injector profiler should never be called in production mode");
919
+ injectorProfiler({
920
+ type: 3 /* EffectCreated */,
921
+ context: getInjectorProfilerContext(),
922
+ effect: effect2
923
+ });
924
+ }
925
+ function runInInjectorProfilerContext(injector, token, callback) {
926
+ !ngDevMode && throwError("runInInjectorProfilerContext should never be called in production mode");
927
+ const prevInjectContext = setInjectorProfilerContext({ injector, token });
928
+ try {
929
+ callback();
930
+ } finally {
931
+ setInjectorProfilerContext(prevInjectContext);
932
+ }
933
+ }
865
934
 
866
- // src/import/di/metadata.ts
867
- var Inject = attachInjectFlag(
868
- // Disable tslint because `DecoratorFlags` is a const enum which gets inlined.
869
- makeParamDecorator("Inject", (token) => ({ token })),
870
- // tslint:disable-next-line: no-toplevel-property-access
871
- -1 /* Inject */
872
- );
873
- var Optional = (
874
- // Disable tslint because `InternalInjectFlags` is a const enum which gets inlined.
875
- // tslint:disable-next-line: no-toplevel-property-access
876
- attachInjectFlag(makeParamDecorator("Optional"), 8 /* Optional */)
877
- );
878
- var Self = (
879
- // Disable tslint because `InternalInjectFlags` is a const enum which gets inlined.
880
- // tslint:disable-next-line: no-toplevel-property-access
881
- attachInjectFlag(makeParamDecorator("Self"), 2 /* Self */)
882
- );
883
- var SkipSelf = (
884
- // Disable tslint because `InternalInjectFlags` is a const enum which gets inlined.
885
- // tslint:disable-next-line: no-toplevel-property-access
886
- attachInjectFlag(makeParamDecorator("SkipSelf"), 4 /* SkipSelf */)
887
- );
935
+ // src/import/render3/definition_factory.ts
936
+ function getFactoryDef(type, throwNotFound) {
937
+ return () => new type();
938
+ }
888
939
 
889
- // src/import/di/create_injector.ts
890
- function createInjector(defType, parent = null, additionalProviders = null, name) {
891
- const injector = createInjectorWithoutInjectorInstances(defType, parent, additionalProviders, name);
892
- injector.resolveInjectorInitializers();
893
- return injector;
940
+ // src/import/render3/util/stringify_utils.ts
941
+ function renderStringify(value) {
942
+ if (typeof value === "string") return value;
943
+ if (value == null) return "";
944
+ return String(value);
945
+ }
946
+ function stringifyForError(value) {
947
+ if (typeof value === "function") return value.name || value.toString();
948
+ if (typeof value === "object" && value != null && typeof value.type === "function") {
949
+ return value.type.name || value.type.toString();
950
+ }
951
+ return renderStringify(value);
952
+ }
953
+
954
+ // src/import/render3/errors_di.ts
955
+ var NG_RUNTIME_ERROR_CODE = getClosureSafeProperty({ ngErrorCode: getClosureSafeProperty });
956
+ var NG_RUNTIME_ERROR_MESSAGE = getClosureSafeProperty({ ngErrorMessage: getClosureSafeProperty });
957
+ var NG_TOKEN_PATH = getClosureSafeProperty({ ngTokenPath: getClosureSafeProperty });
958
+ function cyclicDependencyError(token, path) {
959
+ const message = ngDevMode ? `Circular dependency detected for \`${token}\`.` : "";
960
+ return createRuntimeError(message, -200 /* CYCLIC_DI_DEPENDENCY */, path);
961
+ }
962
+ function throwMixedMultiProviderError() {
963
+ throw new Error(`Cannot mix multi providers and regular providers`);
964
+ }
965
+ function throwInvalidProviderError(ngModuleType, providers, provider) {
966
+ if (ngModuleType && providers) {
967
+ const providerDetail = providers.map((v) => v == provider ? "?" + provider + "?" : "...");
968
+ throw new Error(`Invalid provider for the NgModule '${stringify(ngModuleType)}' - only instances of Provider and Type are allowed, got: [${providerDetail.join(", ")}]`);
969
+ } else if (isEnvironmentProviders(provider)) {
970
+ if (provider.ɵfromNgModule) {
971
+ throw new RuntimeError(
972
+ -207 /* PROVIDER_IN_WRONG_CONTEXT */,
973
+ `Invalid providers from 'importProvidersFrom' present in a non-environment injector. 'importProvidersFrom' can't be used for component providers.`
974
+ );
975
+ } else {
976
+ throw new RuntimeError(-207 /* PROVIDER_IN_WRONG_CONTEXT */, `Invalid providers present in a non-environment injector. 'EnvironmentProviders' can't be used for component providers.`);
977
+ }
978
+ } else {
979
+ throw new Error("Invalid provider");
980
+ }
981
+ }
982
+ function throwProviderNotFoundError(token, injectorName) {
983
+ const errorMessage = ngDevMode && `No provider for ${stringifyForError(token)} found${injectorName ? ` in ${injectorName}` : ""}`;
984
+ throw new RuntimeError(-201 /* PROVIDER_NOT_FOUND */, errorMessage);
985
+ }
986
+ function prependTokenToDependencyPath(error, token) {
987
+ error[NG_TOKEN_PATH] ??= [];
988
+ const currentPath = error[NG_TOKEN_PATH];
989
+ let pathStr;
990
+ if (typeof token === "object" && "multi" in token && token?.multi === true) {
991
+ assertDefined(token.provide, "Token with multi: true should have a provide property");
992
+ pathStr = stringifyForError(token.provide);
993
+ } else {
994
+ pathStr = stringifyForError(token);
995
+ }
996
+ if (currentPath[0] !== pathStr) {
997
+ error[NG_TOKEN_PATH].unshift(pathStr);
998
+ }
999
+ }
1000
+ function augmentRuntimeError(error, source) {
1001
+ const tokenPath = error[NG_TOKEN_PATH];
1002
+ const errorCode = error[NG_RUNTIME_ERROR_CODE];
1003
+ const message = error[NG_RUNTIME_ERROR_MESSAGE] || error.message;
1004
+ error.message = formatErrorMessage(message, errorCode, tokenPath, source);
1005
+ return error;
1006
+ }
1007
+ function createRuntimeError(message, code, path) {
1008
+ const error = new RuntimeError(code, message);
1009
+ error[NG_RUNTIME_ERROR_CODE] = code;
1010
+ error[NG_RUNTIME_ERROR_MESSAGE] = message;
1011
+ if (path) {
1012
+ error[NG_TOKEN_PATH] = path;
1013
+ }
1014
+ return error;
894
1015
  }
895
- function createInjectorWithoutInjectorInstances(defType, parent = null, additionalProviders = null, name, scopes = /* @__PURE__ */ new Set()) {
896
- const providers = [additionalProviders || EMPTY_ARRAY];
897
- name = name || (typeof defType === "object" ? void 0 : stringify(defType));
898
- return new R3Injector(providers, parent || getNullInjector(), name || null, scopes);
1016
+ function getRuntimeErrorCode(error) {
1017
+ return error[NG_RUNTIME_ERROR_CODE];
1018
+ }
1019
+ function formatErrorMessage(text, code, path = [], source = null) {
1020
+ let pathDetails = "";
1021
+ if (path && path.length > 1) {
1022
+ pathDetails = ` Path: ${path.join(" -> ")}.`;
1023
+ }
1024
+ const sourceDetails = source ? ` Source: ${source}.` : "";
1025
+ return formatRuntimeError(code, `${text}${sourceDetails}${pathDetails}`);
899
1026
  }
900
1027
 
901
- // src/import/di/injector.ts
902
- var Injector = class _Injector {
903
- static THROW_IF_NOT_FOUND = THROW_IF_NOT_FOUND;
904
- static NULL = /* @__PURE__ */ new NullInjector();
905
- static create(options, parent) {
906
- if (Array.isArray(options)) {
907
- return createInjector({ name: "" }, parent, options, "");
908
- } else {
909
- const name = options.name ?? "";
910
- return createInjector({ name }, options.parent, options.providers, name);
911
- }
1028
+ // src/import/render3/fields.ts
1029
+ var NG_FACTORY_DEF = getClosureSafeProperty({ ɵfac: getClosureSafeProperty });
1030
+ var NG_ENV_ID = getClosureSafeProperty({ __NG_ENV_ID__: getClosureSafeProperty });
1031
+
1032
+ // src/import/util/array_utils.ts
1033
+ function newArray(size, value) {
1034
+ const list = [];
1035
+ for (let i = 0; i < size; i++) {
1036
+ list.push(value);
912
1037
  }
913
- /** @nocollapse */
914
- static ɵprov = (
915
- /** @pureOrBreakMyCode */
916
- /* @__PURE__ */ ɵɵdefineInjectable({
917
- token: _Injector,
918
- providedIn: "any",
919
- factory: () => ɵɵinject(INJECTOR)
920
- })
921
- );
922
- /**
923
- * @internal
924
- * @nocollapse
925
- */
926
- static __NG_ELEMENT_ID__ = -1 /* Injector */;
927
- };
1038
+ return list;
1039
+ }
928
1040
 
929
- // src/import/render3/instructions/di.ts
930
- function ɵɵinvalidFactory() {
931
- const msg = "invalid";
932
- throw new Error(msg);
1041
+ // src/import/util/empty.ts
1042
+ var EMPTY_OBJ = {};
1043
+ var EMPTY_ARRAY = [];
1044
+ if ((typeof ngDevMode === "undefined" || ngDevMode) && true) {
1045
+ Object.freeze(EMPTY_OBJ);
1046
+ Object.freeze(EMPTY_ARRAY);
933
1047
  }
934
1048
 
935
- // src/primitives/signals/src/graph.ts
936
- var activeConsumer = null;
937
- var inNotificationPhase = false;
938
- var epoch = 1;
939
- var postProducerCreatedFn = null;
940
- var SIGNAL = /* @__PURE__ */ Symbol("SIGNAL");
941
- function setActiveConsumer(consumer) {
942
- const prev = activeConsumer;
943
- activeConsumer = consumer;
944
- return prev;
1049
+ // src/import/di/initializer_token.ts
1050
+ var ENVIRONMENT_INITIALIZER = new InjectionToken(typeof ngDevMode !== "undefined" && ngDevMode ? "ENVIRONMENT_INITIALIZER" : "");
1051
+
1052
+ // src/import/di/interface/injector.ts
1053
+ var DecoratorFlags = /* @__PURE__ */ ((DecoratorFlags2) => {
1054
+ DecoratorFlags2[DecoratorFlags2["Inject"] = -1] = "Inject";
1055
+ return DecoratorFlags2;
1056
+ })(DecoratorFlags || {});
1057
+ var InternalInjectFlags = /* @__PURE__ */ ((InternalInjectFlags2) => {
1058
+ InternalInjectFlags2[InternalInjectFlags2["Default"] = 0] = "Default";
1059
+ InternalInjectFlags2[InternalInjectFlags2["Host"] = 1] = "Host";
1060
+ InternalInjectFlags2[InternalInjectFlags2["Self"] = 2] = "Self";
1061
+ InternalInjectFlags2[InternalInjectFlags2["SkipSelf"] = 4] = "SkipSelf";
1062
+ InternalInjectFlags2[InternalInjectFlags2["Optional"] = 8] = "Optional";
1063
+ InternalInjectFlags2[InternalInjectFlags2["ForPipe"] = 16] = "ForPipe";
1064
+ return InternalInjectFlags2;
1065
+ })(InternalInjectFlags || {});
1066
+
1067
+ // src/import/di/inject_switch.ts
1068
+ var _injectImplementation;
1069
+ function getInjectImplementation() {
1070
+ return _injectImplementation;
945
1071
  }
946
- function getActiveConsumer() {
947
- return activeConsumer;
1072
+ function setInjectImplementation(impl) {
1073
+ const previous = _injectImplementation;
1074
+ _injectImplementation = impl;
1075
+ return previous;
948
1076
  }
949
- var REACTIVE_NODE = {
950
- version: 0,
951
- lastCleanEpoch: 0,
952
- dirty: false,
953
- producers: void 0,
954
- producersTail: void 0,
955
- consumers: void 0,
956
- consumersTail: void 0,
957
- recomputing: false,
958
- consumerAllowSignalWrites: false,
959
- consumerIsAlwaysLive: false,
960
- kind: "unknown",
961
- producerMustRecompute: () => false,
962
- producerRecomputeValue: () => {
963
- },
964
- consumerMarkedDirty: () => {
965
- },
966
- consumerOnSignalRead: () => {
967
- }
968
- };
969
- function producerAccessed(node) {
970
- if (inNotificationPhase) {
971
- throw new Error(false ? `Assertion error: signal read during notification phase` : "");
972
- }
973
- if (activeConsumer === null) {
974
- return;
1077
+ function injectRootLimpMode(token, notFoundValue, flags) {
1078
+ const injectableDef = getInjectableDef(token);
1079
+ if (injectableDef && injectableDef.providedIn == "root") {
1080
+ return injectableDef.value === void 0 ? injectableDef.value = injectableDef.factory() : injectableDef.value;
975
1081
  }
976
- activeConsumer.consumerOnSignalRead(node);
977
- const prevProducerLink = activeConsumer.producersTail;
978
- if (prevProducerLink !== void 0 && prevProducerLink.producer === node) {
979
- return;
1082
+ if (flags & 8 /* Optional */) return null;
1083
+ if (notFoundValue !== void 0) return notFoundValue;
1084
+ throwProviderNotFoundError(token, typeof ngDevMode !== "undefined" && ngDevMode ? "Injector" : "");
1085
+ }
1086
+
1087
+ // src/primitives/di/src/injector.ts
1088
+ var _currentInjector = void 0;
1089
+ function getCurrentInjector() {
1090
+ return _currentInjector;
1091
+ }
1092
+ function setCurrentInjector(injector) {
1093
+ const former = _currentInjector;
1094
+ _currentInjector = injector;
1095
+ return former;
1096
+ }
1097
+
1098
+ // src/primitives/di/src/not_found.ts
1099
+ var NOT_FOUND = Symbol("NotFound");
1100
+ function isNotFound(e) {
1101
+ return e === NOT_FOUND || e?.name === "ɵNotFound";
1102
+ }
1103
+
1104
+ // src/import/di/injector_compatibility.ts
1105
+ var _THROW_IF_NOT_FOUND = {};
1106
+ var THROW_IF_NOT_FOUND = _THROW_IF_NOT_FOUND;
1107
+ var DI_DECORATOR_FLAG = "__NG_DI_FLAG__";
1108
+ var RetrievingInjector = class {
1109
+ constructor(injector) {
1110
+ this.injector = injector;
980
1111
  }
981
- let nextProducerLink = void 0;
982
- const isRecomputing = activeConsumer.recomputing;
983
- if (isRecomputing) {
984
- nextProducerLink = prevProducerLink !== void 0 ? prevProducerLink.nextProducer : activeConsumer.producers;
985
- if (nextProducerLink !== void 0 && nextProducerLink.producer === node) {
986
- activeConsumer.producersTail = nextProducerLink;
987
- nextProducerLink.lastReadVersion = node.version;
988
- return;
1112
+ retrieve(token, options) {
1113
+ const flags = convertToBitFlags(options) || 0 /* Default */;
1114
+ try {
1115
+ return this.injector.get(
1116
+ token,
1117
+ // When a dependency is requested with an optional flag, DI returns null as the default value.
1118
+ flags & 8 /* Optional */ ? null : THROW_IF_NOT_FOUND,
1119
+ flags
1120
+ );
1121
+ } catch (e) {
1122
+ if (isNotFound(e)) {
1123
+ return e;
1124
+ }
1125
+ throw e;
989
1126
  }
990
1127
  }
991
- const prevConsumerLink = node.consumersTail;
992
- if (prevConsumerLink !== void 0 && prevConsumerLink.consumer === activeConsumer && // However, we have to make sure that the link we've discovered isn't from a node that is incrementally rebuilding its producer list
993
- (!isRecomputing || isValidLink(prevConsumerLink, activeConsumer))) {
994
- return;
995
- }
996
- const isLive = consumerIsLive(activeConsumer);
997
- const newLink = {
998
- producer: node,
999
- consumer: activeConsumer,
1000
- // instead of eagerly destroying the previous link, we delay until we've finished recomputing
1001
- // the producers list, so that we can destroy all of the old links at once.
1002
- nextProducer: nextProducerLink,
1003
- prevConsumer: prevConsumerLink,
1004
- lastReadVersion: node.version,
1005
- nextConsumer: void 0
1006
- };
1007
- activeConsumer.producersTail = newLink;
1008
- if (prevProducerLink !== void 0) {
1009
- prevProducerLink.nextProducer = newLink;
1128
+ };
1129
+ var NG_TEMP_TOKEN_PATH = "ngTempTokenPath";
1130
+ var SOURCE = "__source";
1131
+ function injectInjectorOnly(token, flags = 0 /* Default */) {
1132
+ const currentInjector = getCurrentInjector();
1133
+ if (currentInjector === void 0) {
1134
+ throw new RuntimeError(
1135
+ -203 /* MISSING_INJECTION_CONTEXT */,
1136
+ ngDevMode && `The \`${stringify(token)}\` token injection failed. \`inject()\` function must be called from an injection context such as a constructor, a factory function, a field initializer, or a function used with \`runInInjectionContext\`.`
1137
+ );
1138
+ } else if (currentInjector === null) {
1139
+ return injectRootLimpMode(token, void 0, flags);
1010
1140
  } else {
1011
- activeConsumer.producers = newLink;
1012
- }
1013
- if (isLive) {
1014
- producerAddLiveConsumer(node, newLink);
1141
+ const options = convertToInjectOptions(flags);
1142
+ const value = currentInjector.retrieve(token, options);
1143
+ ngDevMode && emitInjectEvent(token, value, flags);
1144
+ if (isNotFound(value)) {
1145
+ if (options.optional) {
1146
+ return null;
1147
+ }
1148
+ throw value;
1149
+ }
1150
+ return value;
1015
1151
  }
1016
1152
  }
1017
- function producerIncrementEpoch() {
1018
- epoch++;
1153
+ function ɵɵinject(token, flags = 0 /* Default */) {
1154
+ return (getInjectImplementation() || injectInjectorOnly)(resolveForwardRef(token), flags);
1019
1155
  }
1020
- function producerUpdateValueVersion(node) {
1021
- if (consumerIsLive(node) && !node.dirty) {
1022
- return;
1023
- }
1024
- if (!node.dirty && node.lastCleanEpoch === epoch) {
1025
- return;
1026
- }
1027
- if (!node.producerMustRecompute(node) && !consumerPollProducersForChange(node)) {
1028
- producerMarkClean(node);
1029
- return;
1030
- }
1031
- node.producerRecomputeValue(node);
1032
- producerMarkClean(node);
1156
+ function ɵɵinvalidFactoryDep(index) {
1157
+ throw new RuntimeError(
1158
+ 202 /* INVALID_FACTORY_DEPENDENCY */,
1159
+ ngDevMode && `This constructor is not compatible with Angular Dependency Injection because its dependency at index ${index} of the parameter list is invalid.
1160
+ This can happen if the dependency type is a primitive like a string or if an ancestor of this class is missing an Angular decorator.
1161
+
1162
+ Please check that 1) the type for the parameter at index ${index} is correct and 2) the correct Angular decorators are defined for this class and its ancestors.`
1163
+ );
1033
1164
  }
1034
- function producerNotifyConsumers(node) {
1035
- if (node.consumers === void 0) {
1036
- return;
1165
+ function inject2(token, options) {
1166
+ return ɵɵinject(token, convertToBitFlags(options));
1167
+ }
1168
+ function convertToBitFlags(flags) {
1169
+ if (typeof flags === "undefined" || typeof flags === "number") {
1170
+ return flags;
1037
1171
  }
1038
- const prev = inNotificationPhase;
1039
- inNotificationPhase = true;
1040
- try {
1041
- for (let link = node.consumers; link !== void 0; link = link.nextConsumer) {
1042
- const consumer = link.consumer;
1043
- if (!consumer.dirty) {
1044
- consumerMarkDirty(consumer);
1172
+ return 0 /* Default */ | // comment to force a line break in the formatter
1173
+ (flags.optional && 8 /* Optional */) | 0 | (flags.self && 2 /* Self */) | (flags.skipSelf && 4 /* SkipSelf */);
1174
+ }
1175
+ function convertToInjectOptions(flags) {
1176
+ return {
1177
+ optional: !!(flags & 8 /* Optional */),
1178
+ host: !!(flags & 1 /* Host */),
1179
+ self: !!(flags & 2 /* Self */),
1180
+ skipSelf: !!(flags & 4 /* SkipSelf */)
1181
+ };
1182
+ }
1183
+ function injectArgs(types) {
1184
+ const args = [];
1185
+ for (let i = 0; i < types.length; i++) {
1186
+ const arg = resolveForwardRef(types[i]);
1187
+ if (Array.isArray(arg)) {
1188
+ if (arg.length === 0) {
1189
+ throw new RuntimeError(900 /* INVALID_DIFFER_INPUT */, ngDevMode && "Arguments array must have arguments.");
1045
1190
  }
1191
+ let type = void 0;
1192
+ let flags = 0 /* Default */;
1193
+ for (let j = 0; j < arg.length; j++) {
1194
+ const meta = arg[j];
1195
+ const flag = getInjectFlag(meta);
1196
+ if (typeof flag === "number") {
1197
+ if (flag === -1 /* Inject */) {
1198
+ type = meta.token;
1199
+ } else {
1200
+ flags |= flag;
1201
+ }
1202
+ } else {
1203
+ type = meta;
1204
+ }
1205
+ }
1206
+ args.push(ɵɵinject(type, flags));
1207
+ } else {
1208
+ args.push(ɵɵinject(arg));
1046
1209
  }
1047
- } finally {
1048
- inNotificationPhase = prev;
1049
1210
  }
1211
+ return args;
1050
1212
  }
1051
- function producerUpdatesAllowed() {
1052
- return activeConsumer?.consumerAllowSignalWrites !== false;
1213
+ function attachInjectFlag(decorator, flag) {
1214
+ decorator[DI_DECORATOR_FLAG] = flag;
1215
+ decorator.prototype[DI_DECORATOR_FLAG] = flag;
1216
+ return decorator;
1053
1217
  }
1054
- function consumerMarkDirty(node) {
1055
- node.dirty = true;
1056
- producerNotifyConsumers(node);
1057
- node.consumerMarkedDirty?.(node);
1218
+ function getInjectFlag(token) {
1219
+ return token[DI_DECORATOR_FLAG];
1058
1220
  }
1059
- function producerMarkClean(node) {
1060
- node.dirty = false;
1061
- node.lastCleanEpoch = epoch;
1221
+
1222
+ // src/import/di/injector_token.ts
1223
+ var INJECTOR = new InjectionToken(
1224
+ typeof ngDevMode !== "undefined" && ngDevMode ? "INJECTOR" : "",
1225
+ // Disable tslint because this is const enum which gets inlined not top level prop access.
1226
+ // tslint:disable-next-line: no-toplevel-property-access
1227
+ -1 /* Injector */
1228
+ // Special value used by Ivy to identify `Injector`.
1229
+ );
1230
+
1231
+ // src/import/di/internal_tokens.ts
1232
+ var INJECTOR_DEF_TYPES = new InjectionToken(typeof ngDevMode !== "undefined" && ngDevMode ? "INJECTOR_DEF_TYPES" : "");
1233
+
1234
+ // src/import/di/null_injector.ts
1235
+ var NullInjector = class {
1236
+ get(token, notFoundValue = THROW_IF_NOT_FOUND) {
1237
+ if (notFoundValue === THROW_IF_NOT_FOUND) {
1238
+ const message = ngDevMode ? `No provider found for \`${stringify(token)}\`.` : "";
1239
+ const error = createRuntimeError(message, -201 /* PROVIDER_NOT_FOUND */);
1240
+ error.name = "ɵNotFound";
1241
+ throw error;
1242
+ }
1243
+ return notFoundValue;
1244
+ }
1245
+ };
1246
+
1247
+ // src/import/di/provider_collection.ts
1248
+ function makeEnvironmentProviders(providers) {
1249
+ return {
1250
+ ɵproviders: providers
1251
+ };
1062
1252
  }
1063
- function consumerBeforeComputation(node) {
1064
- if (node) resetConsumerBeforeComputation(node);
1065
- return setActiveConsumer(node);
1253
+ var USE_VALUE = getClosureSafeProperty({
1254
+ provide: String,
1255
+ useValue: getClosureSafeProperty
1256
+ });
1257
+ function isValueProvider(value) {
1258
+ return value !== null && typeof value === "object" && USE_VALUE in value;
1066
1259
  }
1067
- function resetConsumerBeforeComputation(node) {
1068
- node.producersTail = void 0;
1069
- node.recomputing = true;
1260
+ function isExistingProvider(value) {
1261
+ return !!(value && value.useExisting);
1070
1262
  }
1071
- function consumerAfterComputation(node, prevConsumer) {
1072
- setActiveConsumer(prevConsumer);
1073
- if (node) finalizeConsumerAfterComputation(node);
1263
+ function isFactoryProvider(value) {
1264
+ return !!(value && value.useFactory);
1074
1265
  }
1075
- function finalizeConsumerAfterComputation(node) {
1076
- node.recomputing = false;
1077
- const producersTail = node.producersTail;
1078
- let toRemove = producersTail !== void 0 ? producersTail.nextProducer : node.producers;
1079
- if (toRemove !== void 0) {
1080
- if (consumerIsLive(node)) {
1081
- do {
1082
- toRemove = producerRemoveLiveConsumerLink(toRemove);
1083
- } while (toRemove !== void 0);
1266
+ function isTypeProvider(value) {
1267
+ return typeof value === "function";
1268
+ }
1269
+
1270
+ // src/import/di/scope.ts
1271
+ var INJECTOR_SCOPE = new InjectionToken(typeof ngDevMode !== "undefined" && ngDevMode ? "Set Injector scope." : "");
1272
+
1273
+ // src/import/di/r3_injector.ts
1274
+ var NOT_YET = {};
1275
+ var CIRCULAR = {};
1276
+ var NULL_INJECTOR = void 0;
1277
+ function getNullInjector() {
1278
+ if (NULL_INJECTOR === void 0) {
1279
+ NULL_INJECTOR = new NullInjector();
1280
+ }
1281
+ return NULL_INJECTOR;
1282
+ }
1283
+ var EnvironmentInjector = class {
1284
+ };
1285
+ var R3Injector = class extends EnvironmentInjector {
1286
+ constructor(providers, parent, source, scopes) {
1287
+ super();
1288
+ this.parent = parent;
1289
+ this.source = source;
1290
+ this.scopes = scopes;
1291
+ forEachSingleProvider(providers, (provider) => this.processProvider(provider));
1292
+ this.records.set(INJECTOR, makeRecord(void 0, this));
1293
+ if (scopes.has("environment")) {
1294
+ this.records.set(EnvironmentInjector, makeRecord(void 0, this));
1084
1295
  }
1085
- if (producersTail !== void 0) {
1086
- producersTail.nextProducer = void 0;
1087
- } else {
1088
- node.producers = void 0;
1296
+ const record = this.records.get(INJECTOR_SCOPE);
1297
+ if (record != null && typeof record.value === "string") {
1298
+ this.scopes.add(record.value);
1089
1299
  }
1300
+ this.injectorDefTypes = new Set(this.get(INJECTOR_DEF_TYPES, EMPTY_ARRAY, { self: true }));
1090
1301
  }
1091
- }
1092
- function consumerPollProducersForChange(node) {
1093
- for (let link = node.producers; link !== void 0; link = link.nextProducer) {
1094
- const producer = link.producer;
1095
- const seenVersion = link.lastReadVersion;
1096
- if (seenVersion !== producer.version) {
1097
- return true;
1302
+ /**
1303
+ * Map of tokens to records which contain the instances of those tokens.
1304
+ * - `null` value implies that we don't have the record. Used by tree-shakable injectors
1305
+ * to prevent further searches.
1306
+ */
1307
+ records = /* @__PURE__ */ new Map();
1308
+ /**
1309
+ * Set of values instantiated by this injector which contain `ngOnDestroy` lifecycle hooks.
1310
+ */
1311
+ _ngOnDestroyHooks = /* @__PURE__ */ new Set();
1312
+ _onDestroyHooks = [];
1313
+ /**
1314
+ * Flag indicating that this injector was previously destroyed.
1315
+ */
1316
+ get destroyed() {
1317
+ return this._destroyed;
1318
+ }
1319
+ _destroyed = false;
1320
+ injectorDefTypes;
1321
+ retrieve(token, options) {
1322
+ const flags = convertToBitFlags(options) || 0 /* Default */;
1323
+ try {
1324
+ return this.get(
1325
+ token,
1326
+ // When a dependency is requested with an optional flag, DI returns null as the default value.
1327
+ THROW_IF_NOT_FOUND,
1328
+ flags
1329
+ );
1330
+ } catch (e) {
1331
+ if (isNotFound(e)) {
1332
+ return e;
1333
+ }
1334
+ throw e;
1098
1335
  }
1099
- producerUpdateValueVersion(producer);
1100
- if (seenVersion !== producer.version) {
1101
- return true;
1336
+ }
1337
+ /**
1338
+ * Destroy the injector and release references to every instance or provider associated with it.
1339
+ *
1340
+ * Also calls the `OnDestroy` lifecycle hooks of every instance that was created for which a
1341
+ * hook was found.
1342
+ */
1343
+ destroy() {
1344
+ assertNotDestroyed(this);
1345
+ this._destroyed = true;
1346
+ try {
1347
+ for (const service of this._ngOnDestroyHooks) {
1348
+ service.ngOnDestroy();
1349
+ }
1350
+ const onDestroyHooks = this._onDestroyHooks;
1351
+ this._onDestroyHooks = [];
1352
+ for (const hook of onDestroyHooks) {
1353
+ hook();
1354
+ }
1355
+ } finally {
1356
+ this.records.clear();
1357
+ this._ngOnDestroyHooks.clear();
1358
+ this.injectorDefTypes.clear();
1102
1359
  }
1103
1360
  }
1104
- return false;
1105
- }
1106
- function consumerDestroy(node) {
1107
- if (consumerIsLive(node)) {
1108
- let link = node.producers;
1109
- while (link !== void 0) {
1110
- link = producerRemoveLiveConsumerLink(link);
1361
+ onDestroy(callback) {
1362
+ assertNotDestroyed(this);
1363
+ this._onDestroyHooks.push(callback);
1364
+ return () => this.removeOnDestroy(callback);
1365
+ }
1366
+ runInContext(fn) {
1367
+ assertNotDestroyed(this);
1368
+ const previousInjector = setCurrentInjector(this);
1369
+ const previousInjectImplementation = setInjectImplementation(void 0);
1370
+ let prevInjectContext;
1371
+ if (ngDevMode) {
1372
+ prevInjectContext = setInjectorProfilerContext({ injector: this, token: null });
1373
+ }
1374
+ try {
1375
+ return fn();
1376
+ } finally {
1377
+ setCurrentInjector(previousInjector);
1378
+ setInjectImplementation(previousInjectImplementation);
1379
+ ngDevMode && setInjectorProfilerContext(prevInjectContext);
1380
+ }
1381
+ }
1382
+ get(token, notFoundValue = THROW_IF_NOT_FOUND, options) {
1383
+ assertNotDestroyed(this);
1384
+ if (token.hasOwnProperty(NG_ENV_ID)) {
1385
+ return token[NG_ENV_ID](this);
1386
+ }
1387
+ const flags = convertToBitFlags(options);
1388
+ let prevInjectContext;
1389
+ if (ngDevMode) {
1390
+ prevInjectContext = setInjectorProfilerContext({ injector: this, token });
1391
+ }
1392
+ const previousInjector = setCurrentInjector(this);
1393
+ const previousInjectImplementation = setInjectImplementation(void 0);
1394
+ try {
1395
+ if (!(flags & 4 /* SkipSelf */)) {
1396
+ let record = this.records.get(token);
1397
+ if (record === void 0) {
1398
+ const def = couldBeInjectableType(token) && getInjectableDef(token);
1399
+ if (def && this.injectableDefInScope(def)) {
1400
+ if (ngDevMode) {
1401
+ runInInjectorProfilerContext(this, token, () => {
1402
+ emitProviderConfiguredEvent(token);
1403
+ });
1404
+ }
1405
+ record = makeRecord(injectableDefOrInjectorDefFactory(token), NOT_YET);
1406
+ } else {
1407
+ record = null;
1408
+ }
1409
+ this.records.set(token, record);
1410
+ }
1411
+ if (record != null) {
1412
+ return this.hydrate(token, record, flags);
1413
+ }
1414
+ }
1415
+ const nextInjector = !(flags & 2 /* Self */) ? this.parent : getNullInjector();
1416
+ notFoundValue = flags & 8 /* Optional */ && notFoundValue === THROW_IF_NOT_FOUND ? null : notFoundValue;
1417
+ return nextInjector.get(token, notFoundValue);
1418
+ } catch (error) {
1419
+ const errorCode = getRuntimeErrorCode(error);
1420
+ if (errorCode === -200 /* CYCLIC_DI_DEPENDENCY */ || errorCode === -201 /* PROVIDER_NOT_FOUND */) {
1421
+ if (ngDevMode) {
1422
+ prependTokenToDependencyPath(error, token);
1423
+ if (previousInjector) {
1424
+ throw error;
1425
+ } else {
1426
+ throw augmentRuntimeError(error, this.source);
1427
+ }
1428
+ } else {
1429
+ throw new RuntimeError(errorCode, null);
1430
+ }
1431
+ } else {
1432
+ throw error;
1433
+ }
1434
+ } finally {
1435
+ setInjectImplementation(previousInjectImplementation);
1436
+ setCurrentInjector(previousInjector);
1437
+ ngDevMode && setInjectorProfilerContext(prevInjectContext);
1111
1438
  }
1112
1439
  }
1113
- node.producers = void 0;
1114
- node.producersTail = void 0;
1115
- node.consumers = void 0;
1116
- node.consumersTail = void 0;
1117
- }
1118
- function producerAddLiveConsumer(node, link) {
1119
- const consumersTail = node.consumersTail;
1120
- const wasLive = consumerIsLive(node);
1121
- if (consumersTail !== void 0) {
1122
- link.nextConsumer = consumersTail.nextConsumer;
1123
- consumersTail.nextConsumer = link;
1124
- } else {
1125
- link.nextConsumer = void 0;
1126
- node.consumers = link;
1127
- }
1128
- link.prevConsumer = consumersTail;
1129
- node.consumersTail = link;
1130
- if (!wasLive) {
1131
- for (let link2 = node.producers; link2 !== void 0; link2 = link2.nextProducer) {
1132
- producerAddLiveConsumer(link2.producer, link2);
1440
+ /** @internal */
1441
+ resolveInjectorInitializers() {
1442
+ const previousInjector = setCurrentInjector(this);
1443
+ const previousInjectImplementation = setInjectImplementation(void 0);
1444
+ let prevInjectContext;
1445
+ if (ngDevMode) {
1446
+ prevInjectContext = setInjectorProfilerContext({ injector: this, token: null });
1447
+ }
1448
+ try {
1449
+ const initializers = this.get(ENVIRONMENT_INITIALIZER, EMPTY_ARRAY, { self: true });
1450
+ if (ngDevMode && !Array.isArray(initializers)) {
1451
+ throw new RuntimeError(
1452
+ -209 /* INVALID_MULTI_PROVIDER */,
1453
+ `Unexpected type of the \`ENVIRONMENT_INITIALIZER\` token value (expected an array, but got ${typeof initializers}). Please check that the \`ENVIRONMENT_INITIALIZER\` token is configured as a \`multi: true\` provider.`
1454
+ );
1455
+ }
1456
+ for (const initializer of initializers) {
1457
+ initializer();
1458
+ }
1459
+ } finally {
1460
+ setCurrentInjector(previousInjector);
1461
+ setInjectImplementation(previousInjectImplementation);
1462
+ ngDevMode && setInjectorProfilerContext(prevInjectContext);
1133
1463
  }
1134
1464
  }
1135
- }
1136
- function producerRemoveLiveConsumerLink(link) {
1137
- const producer = link.producer;
1138
- const nextProducer = link.nextProducer;
1139
- const nextConsumer = link.nextConsumer;
1140
- const prevConsumer = link.prevConsumer;
1141
- link.nextConsumer = void 0;
1142
- link.prevConsumer = void 0;
1143
- if (nextConsumer !== void 0) {
1144
- nextConsumer.prevConsumer = prevConsumer;
1145
- } else {
1146
- producer.consumersTail = prevConsumer;
1147
- }
1148
- if (prevConsumer !== void 0) {
1149
- prevConsumer.nextConsumer = nextConsumer;
1150
- } else {
1151
- producer.consumers = nextConsumer;
1152
- if (!consumerIsLive(producer)) {
1153
- let producerLink = producer.producers;
1154
- while (producerLink !== void 0) {
1155
- producerLink = producerRemoveLiveConsumerLink(producerLink);
1465
+ toString() {
1466
+ if (ngDevMode) {
1467
+ const tokens = [];
1468
+ const records = this.records;
1469
+ for (const token of records.keys()) {
1470
+ tokens.push(stringify(token));
1156
1471
  }
1472
+ return `R3Injector[${tokens.join(", ")}]`;
1157
1473
  }
1474
+ return "R3Injector[...]";
1158
1475
  }
1159
- return nextProducer;
1160
- }
1161
- function consumerIsLive(node) {
1162
- return node.consumerIsAlwaysLive || node.consumers !== void 0;
1163
- }
1164
- function runPostProducerCreatedFn(node) {
1165
- postProducerCreatedFn?.(node);
1166
- }
1167
- function isValidLink(checkLink, consumer) {
1168
- const producersTail = consumer.producersTail;
1169
- if (producersTail !== void 0) {
1170
- let link = consumer.producers;
1171
- do {
1172
- if (link === checkLink) {
1173
- return true;
1476
+ /**
1477
+ * Process a `SingleProvider` and add it.
1478
+ */
1479
+ processProvider(provider) {
1480
+ provider = resolveForwardRef(provider);
1481
+ let token = isTypeProvider(provider) ? provider : resolveForwardRef(provider && provider.provide);
1482
+ const record = providerToRecord(provider);
1483
+ if (ngDevMode) {
1484
+ runInInjectorProfilerContext(this, token, () => {
1485
+ if (isValueProvider(provider)) {
1486
+ emitInjectorToCreateInstanceEvent(token);
1487
+ emitInstanceCreatedByInjectorEvent(provider.useValue);
1488
+ }
1489
+ emitProviderConfiguredEvent(provider);
1490
+ });
1491
+ }
1492
+ if (!isTypeProvider(provider) && provider.multi === true) {
1493
+ let multiRecord = this.records.get(token);
1494
+ if (multiRecord) {
1495
+ if (ngDevMode && multiRecord.multi === void 0) {
1496
+ throwMixedMultiProviderError();
1497
+ }
1498
+ } else {
1499
+ multiRecord = makeRecord(void 0, NOT_YET, true);
1500
+ multiRecord.factory = () => injectArgs(multiRecord.multi);
1501
+ this.records.set(token, multiRecord);
1174
1502
  }
1175
- if (link === producersTail) {
1176
- break;
1503
+ token = provider;
1504
+ multiRecord.multi.push(provider);
1505
+ } else {
1506
+ if (ngDevMode) {
1507
+ const existing = this.records.get(token);
1508
+ if (existing && existing.multi !== void 0) {
1509
+ throwMixedMultiProviderError();
1510
+ }
1177
1511
  }
1178
- link = link.nextProducer;
1179
- } while (link !== void 0);
1180
- }
1181
- return false;
1182
- }
1183
-
1184
- // src/primitives/signals/src/equality.ts
1185
- function defaultEquals(a, b) {
1186
- return Object.is(a, b);
1187
- }
1188
-
1189
- // src/primitives/signals/src/computed.ts
1190
- function createComputed(computation, equal) {
1191
- const node = Object.create(COMPUTED_NODE);
1192
- node.computation = computation;
1193
- if (equal !== void 0) {
1194
- node.equal = equal;
1195
- }
1196
- const computed2 = () => {
1197
- producerUpdateValueVersion(node);
1198
- producerAccessed(node);
1199
- if (node.value === ERRORED) {
1200
- throw node.error;
1201
1512
  }
1202
- return node.value;
1203
- };
1204
- computed2[SIGNAL] = node;
1205
- if (false) {
1206
- const debugName = node.debugName ? " (" + node.debugName + ")" : "";
1207
- computed2.toString = () => `[Computed${debugName}: ${node.value}]`;
1513
+ this.records.set(token, record);
1208
1514
  }
1209
- runPostProducerCreatedFn(node);
1210
- return computed2;
1211
- }
1212
- var UNSET = /* @__PURE__ */ Symbol("UNSET");
1213
- var COMPUTING = /* @__PURE__ */ Symbol("COMPUTING");
1214
- var ERRORED = /* @__PURE__ */ Symbol("ERRORED");
1215
- var COMPUTED_NODE = /* @__PURE__ */ (() => ({
1216
- ...REACTIVE_NODE,
1217
- value: UNSET,
1218
- dirty: true,
1219
- error: null,
1220
- equal: defaultEquals,
1221
- kind: "computed",
1222
- producerMustRecompute(node) {
1223
- return node.value === UNSET || node.value === COMPUTING;
1224
- },
1225
- producerRecomputeValue(node) {
1226
- if (node.value === COMPUTING) {
1227
- throw new Error(false ? "Detected cycle in computations." : "");
1228
- }
1229
- const oldValue = node.value;
1230
- node.value = COMPUTING;
1231
- const prevConsumer = consumerBeforeComputation(node);
1232
- let newValue;
1233
- let wasEqual = false;
1515
+ hydrate(token, record, flags) {
1234
1516
  try {
1235
- newValue = node.computation();
1236
- setActiveConsumer(null);
1237
- wasEqual = oldValue !== UNSET && oldValue !== ERRORED && newValue !== ERRORED && node.equal(oldValue, newValue);
1238
- } catch (err) {
1239
- newValue = ERRORED;
1240
- node.error = err;
1517
+ if (record.value === CIRCULAR) {
1518
+ throw cyclicDependencyError(ngDevMode ? stringify(token) : "");
1519
+ } else if (record.value === NOT_YET) {
1520
+ record.value = CIRCULAR;
1521
+ if (ngDevMode) {
1522
+ runInInjectorProfilerContext(this, token, () => {
1523
+ emitInjectorToCreateInstanceEvent(token);
1524
+ record.value = record.factory(void 0, flags);
1525
+ emitInstanceCreatedByInjectorEvent(record.value);
1526
+ });
1527
+ } else {
1528
+ record.value = record.factory(void 0, flags);
1529
+ }
1530
+ }
1531
+ if (typeof record.value === "object" && record.value && hasOnDestroy(record.value)) {
1532
+ this._ngOnDestroyHooks.add(record.value);
1533
+ }
1534
+ return record.value;
1241
1535
  } finally {
1242
- consumerAfterComputation(node, prevConsumer);
1243
1536
  }
1244
- if (wasEqual) {
1245
- node.value = oldValue;
1246
- return;
1537
+ }
1538
+ injectableDefInScope(def) {
1539
+ if (!def.providedIn) {
1540
+ return false;
1541
+ }
1542
+ const providedIn = resolveForwardRef(def.providedIn);
1543
+ if (typeof providedIn === "string") {
1544
+ return providedIn === "any" || this.scopes.has(providedIn);
1545
+ } else {
1546
+ return this.injectorDefTypes.has(providedIn);
1247
1547
  }
1248
- node.value = newValue;
1249
- node.version++;
1250
1548
  }
1251
- }))();
1252
-
1253
- // src/primitives/signals/src/errors.ts
1254
- function defaultThrowError() {
1255
- throw new Error();
1256
- }
1257
- var throwInvalidWriteToSignalErrorFn = defaultThrowError;
1258
- function throwInvalidWriteToSignalError(node) {
1259
- throwInvalidWriteToSignalErrorFn(node);
1549
+ removeOnDestroy(callback) {
1550
+ const destroyCBIdx = this._onDestroyHooks.indexOf(callback);
1551
+ if (destroyCBIdx !== -1) {
1552
+ this._onDestroyHooks.splice(destroyCBIdx, 1);
1553
+ }
1554
+ }
1555
+ };
1556
+ function injectableDefOrInjectorDefFactory(token) {
1557
+ const injectableDef = getInjectableDef(token);
1558
+ const factory = injectableDef !== null ? injectableDef.factory : getFactoryDef(token);
1559
+ if (factory !== null) {
1560
+ return factory;
1561
+ }
1562
+ if (token instanceof InjectionToken) {
1563
+ throw new RuntimeError(-204 /* INVALID_INJECTION_TOKEN */, ngDevMode && `Token ${stringify(token)} is missing a ɵprov definition.`);
1564
+ }
1565
+ if (token instanceof Function) {
1566
+ return getUndecoratedInjectableFactory(token);
1567
+ }
1568
+ throw new RuntimeError(-204 /* INVALID_INJECTION_TOKEN */, ngDevMode && "unreachable");
1260
1569
  }
1261
-
1262
- // src/primitives/signals/src/signal.ts
1263
- var postSignalSetFn = null;
1264
- function createSignal(initialValue, equal) {
1265
- const node = Object.create(SIGNAL_NODE);
1266
- node.value = initialValue;
1267
- if (equal !== void 0) {
1268
- node.equal = equal;
1570
+ function getUndecoratedInjectableFactory(token) {
1571
+ const paramLength = token.length;
1572
+ if (paramLength > 0) {
1573
+ throw new RuntimeError(-204 /* INVALID_INJECTION_TOKEN */, ngDevMode && `Can't resolve all parameters for ${stringify(token)}: (${newArray(paramLength, "?").join(", ")}).`);
1269
1574
  }
1270
- const getter = () => signalGetFn(node);
1271
- getter[SIGNAL] = node;
1272
- if (false) {
1273
- const debugName = node.debugName ? " (" + node.debugName + ")" : "";
1274
- getter.toString = () => `[Signal${debugName}: ${node.value}]`;
1575
+ const inheritedInjectableDef = getInheritedInjectableDef(token);
1576
+ if (inheritedInjectableDef !== null) {
1577
+ return () => inheritedInjectableDef.factory(token);
1578
+ } else {
1579
+ return () => new token();
1275
1580
  }
1276
- runPostProducerCreatedFn(node);
1277
- const set = (newValue) => signalSetFn(node, newValue);
1278
- const update = (updateFn) => signalUpdateFn(node, updateFn);
1279
- return [getter, set, update];
1280
1581
  }
1281
- function signalGetFn(node) {
1282
- producerAccessed(node);
1283
- return node.value;
1582
+ function providerToRecord(provider) {
1583
+ if (isValueProvider(provider)) {
1584
+ return makeRecord(void 0, provider.useValue);
1585
+ } else {
1586
+ const factory = providerToFactory(provider);
1587
+ return makeRecord(factory, NOT_YET);
1588
+ }
1284
1589
  }
1285
- function signalSetFn(node, newValue) {
1286
- if (!producerUpdatesAllowed()) {
1287
- throwInvalidWriteToSignalError(node);
1590
+ function providerToFactory(provider, ngModuleType, providers) {
1591
+ let factory = void 0;
1592
+ if (ngDevMode && isEnvironmentProviders(provider)) {
1593
+ throwInvalidProviderError(void 0, providers, provider);
1288
1594
  }
1289
- if (!node.equal(node.value, newValue)) {
1290
- node.value = newValue;
1291
- signalValueChanged(node);
1595
+ if (isTypeProvider(provider)) {
1596
+ const unwrappedProvider = resolveForwardRef(provider);
1597
+ return getFactoryDef(unwrappedProvider) || injectableDefOrInjectorDefFactory(unwrappedProvider);
1598
+ } else {
1599
+ if (isValueProvider(provider)) {
1600
+ factory = () => resolveForwardRef(provider.useValue);
1601
+ } else if (isFactoryProvider(provider)) {
1602
+ factory = () => provider.useFactory(...injectArgs(provider.deps || []));
1603
+ } else if (isExistingProvider(provider)) {
1604
+ factory = (_, flags) => ɵɵinject(resolveForwardRef(provider.useExisting), flags !== void 0 && flags & 8 /* Optional */ ? 8 /* Optional */ : void 0);
1605
+ } else {
1606
+ const classRef = resolveForwardRef(provider && (provider.useClass || provider.provide));
1607
+ if (ngDevMode && !classRef) {
1608
+ throwInvalidProviderError(ngModuleType, providers, provider);
1609
+ }
1610
+ if (hasDeps(provider)) {
1611
+ factory = () => new classRef(...injectArgs(provider.deps));
1612
+ } else {
1613
+ return getFactoryDef(classRef) || injectableDefOrInjectorDefFactory(classRef);
1614
+ }
1615
+ }
1292
1616
  }
1617
+ return factory;
1293
1618
  }
1294
- function signalUpdateFn(node, updater) {
1295
- if (!producerUpdatesAllowed()) {
1296
- throwInvalidWriteToSignalError(node);
1619
+ function assertNotDestroyed(injector) {
1620
+ if (injector.destroyed) {
1621
+ throw new RuntimeError(-205 /* INJECTOR_ALREADY_DESTROYED */, ngDevMode && "Injector has already been destroyed.");
1297
1622
  }
1298
- signalSetFn(node, updater(node.value));
1299
1623
  }
1300
- var SIGNAL_NODE = /* @__PURE__ */ (() => ({
1301
- ...REACTIVE_NODE,
1302
- equal: defaultEquals,
1303
- value: void 0,
1304
- kind: "signal"
1305
- }))();
1306
- function signalValueChanged(node) {
1307
- node.version++;
1308
- producerIncrementEpoch();
1309
- producerNotifyConsumers(node);
1310
- postSignalSetFn?.(node);
1624
+ function makeRecord(factory, value, multi = false) {
1625
+ return {
1626
+ factory,
1627
+ value,
1628
+ multi: multi ? [] : void 0
1629
+ };
1311
1630
  }
1312
-
1313
- // src/primitives/signals/src/linked_signal.ts
1314
- function createLinkedSignal(sourceFn, computationFn, equalityFn) {
1315
- const node = Object.create(LINKED_SIGNAL_NODE);
1316
- node.source = sourceFn;
1317
- node.computation = computationFn;
1318
- if (equalityFn != void 0) {
1319
- node.equal = equalityFn;
1320
- }
1321
- const linkedSignalGetter = () => {
1322
- producerUpdateValueVersion(node);
1323
- producerAccessed(node);
1324
- if (node.value === ERRORED) {
1325
- throw node.error;
1631
+ function hasDeps(value) {
1632
+ return !!value.deps;
1633
+ }
1634
+ function hasOnDestroy(value) {
1635
+ return value !== null && typeof value === "object" && typeof value.ngOnDestroy === "function";
1636
+ }
1637
+ function couldBeInjectableType(value) {
1638
+ return typeof value === "function" || typeof value === "object" && value.ngMetadataName === "InjectionToken";
1639
+ }
1640
+ function forEachSingleProvider(providers, fn) {
1641
+ for (const provider of providers) {
1642
+ if (Array.isArray(provider)) {
1643
+ forEachSingleProvider(provider, fn);
1644
+ } else if (provider && isEnvironmentProviders(provider)) {
1645
+ forEachSingleProvider(provider.ɵproviders, fn);
1646
+ } else {
1647
+ fn(provider);
1326
1648
  }
1327
- return node.value;
1328
- };
1329
- const getter = linkedSignalGetter;
1330
- getter[SIGNAL] = node;
1331
- if (false) {
1332
- const debugName = node.debugName ? " (" + node.debugName + ")" : "";
1333
- getter.toString = () => `[LinkedSignal${debugName}: ${node.value}]`;
1334
1649
  }
1335
- runPostProducerCreatedFn(node);
1336
- return getter;
1337
- }
1338
- function linkedSignalSetFn(node, newValue) {
1339
- producerUpdateValueVersion(node);
1340
- signalSetFn(node, newValue);
1341
- producerMarkClean(node);
1342
1650
  }
1343
- function linkedSignalUpdateFn(node, updater) {
1344
- producerUpdateValueVersion(node);
1345
- signalUpdateFn(node, updater);
1346
- producerMarkClean(node);
1651
+
1652
+ // src/import/util/closure.ts
1653
+ function noSideEffects(fn) {
1654
+ return { toString: fn }.toString();
1347
1655
  }
1348
- var LINKED_SIGNAL_NODE = /* @__PURE__ */ (() => ({
1349
- ...REACTIVE_NODE,
1350
- value: UNSET,
1351
- dirty: true,
1352
- error: null,
1353
- equal: defaultEquals,
1354
- kind: "linkedSignal",
1355
- producerMustRecompute(node) {
1356
- return node.value === UNSET || node.value === COMPUTING;
1357
- },
1358
- producerRecomputeValue(node) {
1359
- if (node.value === COMPUTING) {
1360
- throw new Error(false ? "Detected cycle in computations." : "");
1656
+
1657
+ // src/import/util/decorators.ts
1658
+ function makeMetadataCtor(props) {
1659
+ return function ctor(...args) {
1660
+ if (props) {
1661
+ const values = props(...args);
1662
+ for (const propName in values) {
1663
+ this[propName] = values[propName];
1664
+ }
1361
1665
  }
1362
- const oldValue = node.value;
1363
- node.value = COMPUTING;
1364
- const prevConsumer = consumerBeforeComputation(node);
1365
- let newValue;
1366
- try {
1367
- const newSourceValue = node.source();
1368
- const prev = oldValue === UNSET || oldValue === ERRORED ? void 0 : {
1369
- source: node.sourceValue,
1370
- value: oldValue
1371
- };
1372
- newValue = node.computation(newSourceValue, prev);
1373
- node.sourceValue = newSourceValue;
1374
- } catch (err) {
1375
- newValue = ERRORED;
1376
- node.error = err;
1377
- } finally {
1378
- consumerAfterComputation(node, prevConsumer);
1666
+ };
1667
+ }
1668
+ function makeParamDecorator(name, props, parentClass) {
1669
+ return noSideEffects(() => {
1670
+ const metaCtor = makeMetadataCtor(props);
1671
+ function ParamDecoratorFactory(...args) {
1672
+ metaCtor.apply(this, args);
1673
+ return this;
1379
1674
  }
1380
- if (oldValue !== UNSET && newValue !== ERRORED && node.equal(oldValue, newValue)) {
1381
- node.value = oldValue;
1382
- return;
1675
+ if (parentClass) {
1383
1676
  }
1384
- node.value = newValue;
1385
- node.version++;
1386
- }
1387
- }))();
1677
+ return ParamDecoratorFactory;
1678
+ });
1679
+ }
1388
1680
 
1389
- // src/primitives/signals/src/untracked.ts
1390
- function untracked(nonReactiveReadsFn) {
1391
- const prevConsumer = setActiveConsumer(null);
1392
- try {
1393
- return nonReactiveReadsFn();
1394
- } finally {
1395
- setActiveConsumer(prevConsumer);
1681
+ // src/import/di/metadata.ts
1682
+ var Inject = attachInjectFlag(
1683
+ // Disable tslint because `DecoratorFlags` is a const enum which gets inlined.
1684
+ makeParamDecorator("Inject", (token) => ({ token })),
1685
+ // tslint:disable-next-line: no-toplevel-property-access
1686
+ -1 /* Inject */
1687
+ );
1688
+ var Optional = (
1689
+ // Disable tslint because `InternalInjectFlags` is a const enum which gets inlined.
1690
+ // tslint:disable-next-line: no-toplevel-property-access
1691
+ attachInjectFlag(makeParamDecorator("Optional"), 8 /* Optional */)
1692
+ );
1693
+ var Self = (
1694
+ // Disable tslint because `InternalInjectFlags` is a const enum which gets inlined.
1695
+ // tslint:disable-next-line: no-toplevel-property-access
1696
+ attachInjectFlag(makeParamDecorator("Self"), 2 /* Self */)
1697
+ );
1698
+ var SkipSelf = (
1699
+ // Disable tslint because `InternalInjectFlags` is a const enum which gets inlined.
1700
+ // tslint:disable-next-line: no-toplevel-property-access
1701
+ attachInjectFlag(makeParamDecorator("SkipSelf"), 4 /* SkipSelf */)
1702
+ );
1703
+
1704
+ // src/import/di/create_injector.ts
1705
+ function createInjector(defType, parent = null, additionalProviders = null, name) {
1706
+ const injector = createInjectorWithoutInjectorInstances(defType, parent, additionalProviders, name);
1707
+ injector.resolveInjectorInitializers();
1708
+ return injector;
1709
+ }
1710
+ function createInjectorWithoutInjectorInstances(defType, parent = null, additionalProviders = null, name, scopes = /* @__PURE__ */ new Set()) {
1711
+ const providers = [additionalProviders || EMPTY_ARRAY];
1712
+ let source = void 0;
1713
+ if (ngDevMode) {
1714
+ source = name || (typeof defType === "object" ? void 0 : stringify(defType));
1396
1715
  }
1716
+ return new R3Injector(providers, parent || getNullInjector(), source || null, scopes);
1397
1717
  }
1398
1718
 
1399
- // src/primitives/signals/src/effect.ts
1400
- var BASE_EFFECT_NODE = /* @__PURE__ */ (() => ({
1401
- ...REACTIVE_NODE,
1402
- consumerIsAlwaysLive: true,
1403
- consumerAllowSignalWrites: true,
1404
- dirty: true,
1405
- kind: "effect"
1406
- }))();
1407
- function runEffect(node) {
1408
- node.dirty = false;
1409
- if (node.version > 0 && !consumerPollProducersForChange(node)) {
1410
- return;
1719
+ // src/import/render3/debug/special_providers.ts
1720
+ var specialProviders = /* @__PURE__ */ new Set();
1721
+ function registerSpecialProvider(clazz) {
1722
+ if (typeof ngDevMode !== "undefined" && ngDevMode) {
1723
+ specialProviders.add(clazz);
1411
1724
  }
1412
- node.version++;
1413
- const prevNode = consumerBeforeComputation(node);
1414
- try {
1415
- node.cleanup();
1416
- node.fn();
1417
- } finally {
1418
- consumerAfterComputation(node, prevNode);
1725
+ }
1726
+
1727
+ // src/import/di/injector.ts
1728
+ var Injector = class _Injector {
1729
+ static THROW_IF_NOT_FOUND = THROW_IF_NOT_FOUND;
1730
+ static NULL = /* @__PURE__ */ new NullInjector();
1731
+ static create(options, parent) {
1732
+ if (Array.isArray(options)) {
1733
+ return createInjector({ name: "" }, parent, options, "");
1734
+ } else {
1735
+ const name = options.name ?? "";
1736
+ return createInjector({ name }, options.parent, options.providers, name);
1737
+ }
1419
1738
  }
1739
+ /** @nocollapse */
1740
+ static ɵprov = (
1741
+ /** @pureOrBreakMyCode */
1742
+ /* @__PURE__ */ ɵɵdefineInjectable({
1743
+ token: _Injector,
1744
+ providedIn: "any",
1745
+ factory: () => ɵɵinject(INJECTOR)
1746
+ })
1747
+ );
1748
+ /**
1749
+ * @internal
1750
+ * @nocollapse
1751
+ */
1752
+ static __NG_ELEMENT_ID__ = -1 /* Injector */;
1753
+ };
1754
+ if (typeof ngDevMode === "undefined" || ngDevMode) {
1755
+ registerSpecialProvider(Injector);
1420
1756
  }
1421
1757
 
1422
- // src/primitives/signals/index.ts
1423
- if (false) {
1424
- installDevToolsSignalFormatter();
1758
+ // src/import/render3/instructions/di.ts
1759
+ function ɵɵinvalidFactory() {
1760
+ const msg = ngDevMode ? `This constructor was not compatible with Dependency Injection.` : "invalid";
1761
+ throw new Error(msg);
1425
1762
  }
1426
1763
 
1427
1764
  // src/import/render3/reactivity/api.ts
1428
- function isSignal(value) {
1765
+ function isSignal2(value) {
1429
1766
  return typeof value === "function" && value[SIGNAL] !== void 0;
1430
1767
  }
1768
+ function isWritableSignal(value) {
1769
+ return isSignal2(value) && typeof value.set === "function";
1770
+ }
1431
1771
 
1432
1772
  // src/import/render3/reactivity/computed.ts
1433
1773
  function computed(computation, options) {
1434
1774
  const getter = createComputed(computation, options?.equal);
1435
- if (false) {
1775
+ if (typeof ngDevMode !== "undefined" && ngDevMode) {
1776
+ const debugName = options?.debugName;
1777
+ getter[SIGNAL].debugName = debugName;
1778
+ getter.toString = () => `[Computed${debugName ? " (" + debugName + ")" : ""}: ${getter()}]`;
1436
1779
  }
1437
1780
  return getter;
1438
1781
  }
@@ -1448,7 +1791,10 @@ function signal(initialValue, options) {
1448
1791
  signalFn.set = set;
1449
1792
  signalFn.update = update;
1450
1793
  signalFn.asReadonly = signalAsReadonlyFn.bind(signalFn);
1451
- if (false) {
1794
+ if (typeof ngDevMode !== "undefined" && ngDevMode) {
1795
+ const debugName = options?.debugName;
1796
+ node.debugName = debugName;
1797
+ signalFn.toString = () => `[Signal${debugName ? " (" + debugName + ")" : ""}: ${signalFn()}]`;
1452
1798
  }
1453
1799
  return signalFn;
1454
1800
  }
@@ -1474,7 +1820,9 @@ function linkedSignal(optionsOrComputation, options) {
1474
1820
  }
1475
1821
  }
1476
1822
  function upgradeLinkedSignalGetter(getter, debugName) {
1477
- if (false) {
1823
+ if (typeof ngDevMode !== "undefined" && ngDevMode) {
1824
+ getter[SIGNAL].debugName = debugName;
1825
+ getter.toString = () => `[LinkedSignal${debugName ? " (" + debugName + ")" : ""}: ${getter()}]`;
1478
1826
  }
1479
1827
  const node = getter[SIGNAL];
1480
1828
  const upgradedGetter = getter;
@@ -1492,7 +1840,45 @@ function untracked2(nonReactiveReadsFn) {
1492
1840
  // src/import/render3/reactivity/asserts.ts
1493
1841
  function assertNotInReactiveContext(debugFn, extraContext) {
1494
1842
  if (getActiveConsumer() !== null) {
1495
- throw new RuntimeError(-602 /* ASSERTION_NOT_INSIDE_REACTIVE_CONTEXT */, void 0);
1843
+ throw new RuntimeError(
1844
+ -602 /* ASSERTION_NOT_INSIDE_REACTIVE_CONTEXT */,
1845
+ ngDevMode && `${debugFn.name}() cannot be called from within a reactive context.${extraContext ? ` ${extraContext}` : ""}`
1846
+ );
1847
+ }
1848
+ }
1849
+
1850
+ // src/import/di/contextual.ts
1851
+ function runInInjectionContext(injector, fn) {
1852
+ let internalInjector;
1853
+ if (injector instanceof R3Injector) {
1854
+ assertNotDestroyed(injector);
1855
+ internalInjector = injector;
1856
+ } else {
1857
+ internalInjector = new RetrievingInjector(injector);
1858
+ }
1859
+ let prevInjectorProfilerContext;
1860
+ if (ngDevMode) {
1861
+ prevInjectorProfilerContext = setInjectorProfilerContext({ injector, token: null });
1862
+ }
1863
+ const prevInjector = setCurrentInjector(internalInjector);
1864
+ const previousInjectImplementation = setInjectImplementation(void 0);
1865
+ try {
1866
+ return fn();
1867
+ } finally {
1868
+ setCurrentInjector(prevInjector);
1869
+ ngDevMode && setInjectorProfilerContext(prevInjectorProfilerContext);
1870
+ setInjectImplementation(previousInjectImplementation);
1871
+ }
1872
+ }
1873
+ function isInInjectionContext() {
1874
+ return getInjectImplementation() !== void 0 || getCurrentInjector() != null;
1875
+ }
1876
+ function assertInInjectionContext(debugFn) {
1877
+ if (!isInInjectionContext()) {
1878
+ throw new RuntimeError(
1879
+ -203 /* MISSING_INJECTION_CONTEXT */,
1880
+ ngDevMode && debugFn.name + "() can only be used within an injection context such as a constructor, a factory function, a field initializer, or a function used with `runInInjectionContext`"
1881
+ );
1496
1882
  }
1497
1883
  }
1498
1884
 
@@ -1508,9 +1894,8 @@ var DestroyRef = class {
1508
1894
  */
1509
1895
  static __NG_ENV_ID__ = (injector) => injector;
1510
1896
  };
1511
-
1512
- // src/import/util/noop.ts
1513
- function noop(...args) {
1897
+ if (typeof ngDevMode === "undefined" || ngDevMode) {
1898
+ registerSpecialProvider(DestroyRef);
1514
1899
  }
1515
1900
 
1516
1901
  // src/import/change_detection/scheduling/zoneless_scheduling.ts
@@ -1533,10 +1918,6 @@ var NotificationSource = /* @__PURE__ */ ((NotificationSource2) => {
1533
1918
  })(NotificationSource || {});
1534
1919
  var ChangeDetectionScheduler = class {
1535
1920
  };
1536
- var ZONELESS_ENABLED = new InjectionToken("", { providedIn: "root", factory: () => false });
1537
- var PROVIDED_ZONELESS = new InjectionToken("", { providedIn: "root", factory: () => false });
1538
- var ZONELESS_SCHEDULER_DISABLED = new InjectionToken("");
1539
- var SCHEDULE_IN_ROOT_ZONE = new InjectionToken("");
1540
1921
 
1541
1922
  // src/import/render3/reactivity/root_effect_scheduler.ts
1542
1923
  var EffectScheduler = class _EffectScheduler {
@@ -1631,10 +2012,11 @@ var EffectRefImpl = class {
1631
2012
  }
1632
2013
  };
1633
2014
  function effect(effectFn, options) {
1634
- if (false) {
2015
+ ngDevMode && assertNotInReactiveContext(effect, "Call `effect` outside of a reactive context. For example, schedule the effect inside the component constructor.");
2016
+ if (ngDevMode && !options?.injector) {
1635
2017
  assertInInjectionContext(effect);
1636
2018
  }
1637
- if (false) {
2019
+ if (ngDevMode && options?.allowSignalWrites !== void 0) {
1638
2020
  console.warn(`The 'allowSignalWrites' flag is deprecated and no longer impacts effect() (writes are always allowed)`);
1639
2021
  }
1640
2022
  const injector = options?.injector ?? inject2(Injector);
@@ -1644,18 +2026,27 @@ function effect(effectFn, options) {
1644
2026
  node = createRootEffect(effectFn, injector.get(EffectScheduler), notifier);
1645
2027
  node.injector = injector;
1646
2028
  if (destroyRef !== null) {
1647
- node.onDestroyFn = destroyRef.onDestroy(() => node.destroy());
2029
+ node.onDestroyFns = [destroyRef.onDestroy(() => node.destroy())];
1648
2030
  }
1649
2031
  const effectRef = new EffectRefImpl(node);
2032
+ if (ngDevMode) {
2033
+ node.debugName = options?.debugName ?? "";
2034
+ const prevInjectorProfilerContext = setInjectorProfilerContext({ injector, token: null });
2035
+ try {
2036
+ emitEffectCreatedEvent(effectRef);
2037
+ } finally {
2038
+ setInjectorProfilerContext(prevInjectorProfilerContext);
2039
+ }
2040
+ }
1650
2041
  return effectRef;
1651
2042
  }
1652
2043
  var EFFECT_NODE = /* @__PURE__ */ (() => ({
1653
2044
  ...BASE_EFFECT_NODE,
1654
2045
  cleanupFns: void 0,
1655
2046
  zone: null,
1656
- onDestroyFn: noop,
2047
+ onDestroyFns: null,
1657
2048
  run() {
1658
- if (false) {
2049
+ if (ngDevMode && isInNotificationPhase()) {
1659
2050
  throw new Error(`Schedulers cannot synchronously execute watches while scheduling.`);
1660
2051
  }
1661
2052
  try {
@@ -1686,7 +2077,11 @@ var ROOT_EFFECT_NODE = /* @__PURE__ */ (() => ({
1686
2077
  },
1687
2078
  destroy() {
1688
2079
  consumerDestroy(this);
1689
- this.onDestroyFn();
2080
+ if (this.onDestroyFns !== null) {
2081
+ for (const fn of this.onDestroyFns) {
2082
+ fn();
2083
+ }
2084
+ }
1690
2085
  this.cleanup();
1691
2086
  this.scheduler.remove(this);
1692
2087
  }
@@ -1707,6 +2102,10 @@ function createEffectFn(node, fn) {
1707
2102
  };
1708
2103
  }
1709
2104
 
2105
+ // src/import/util/noop.ts
2106
+ function noop(...args) {
2107
+ }
2108
+
1710
2109
  // src/import/util/callback_scheduler.ts
1711
2110
  function scheduleCallbackWithMicrotask(callback) {
1712
2111
  queueMicrotask(() => callback());
@@ -1732,48 +2131,124 @@ var ChangeDetectionSchedulerImpl = class {
1732
2131
  this.cancelScheduledCallback?.();
1733
2132
  this.cancelScheduledCallback = null;
1734
2133
  }
1735
- ngOnDestroy() {
1736
- this.cleanup();
2134
+ ngOnDestroy() {
2135
+ this.cleanup();
2136
+ }
2137
+ };
2138
+
2139
+ // src/import/resource/api.ts
2140
+ var ResourceDependencyError = class extends Error {
2141
+ /** The dependency that errored. */
2142
+ dependency;
2143
+ constructor(dependency) {
2144
+ super("Dependency error", { cause: dependency.error() });
2145
+ this.name = "ResourceDependencyError";
2146
+ this.dependency = dependency;
2147
+ }
2148
+ };
2149
+ var ResourceParamsStatus = class _ResourceParamsStatus extends Error {
2150
+ _brand;
2151
+ constructor(msg) {
2152
+ super(msg);
2153
+ }
2154
+ /** Status code that transitions the resource to `idle` status. */
2155
+ static IDLE = new _ResourceParamsStatus("IDLE");
2156
+ /** Status code that transitions the resource to `loading` status. */
2157
+ static LOADING = new _ResourceParamsStatus("LOADING");
2158
+ };
2159
+
2160
+ // src/import/defer/idle_service.ts
2161
+ var _requestIdleCallback = () => (typeof requestIdleCallback !== "undefined" ? requestIdleCallback : (cb) => setTimeout(cb)).bind(globalThis);
2162
+ var _cancelIdleCallback = () => (typeof requestIdleCallback !== "undefined" ? cancelIdleCallback : clearTimeout).bind(globalThis);
2163
+ var IDLE_SERVICE = new InjectionToken(ngDevMode ? "IDLE_SERVICE" : "", {
2164
+ factory: () => new RequestIdleCallbackService()
2165
+ });
2166
+ function provideIdleServiceWith(useExisting) {
2167
+ return makeEnvironmentProviders([
2168
+ {
2169
+ provide: IDLE_SERVICE,
2170
+ useExisting
2171
+ }
2172
+ ]);
2173
+ }
2174
+ var RequestIdleCallbackService = class {
2175
+ requestIdleCallback = _requestIdleCallback();
2176
+ cancelIdleCallback = _cancelIdleCallback();
2177
+ requestOnIdle(callback, options) {
2178
+ return this.requestIdleCallback(callback, options);
2179
+ }
2180
+ cancelOnIdle(id) {
2181
+ return this.cancelIdleCallback(id);
1737
2182
  }
1738
2183
  };
1739
2184
 
1740
- // src/import/pending_tasks.ts
1741
- var import_rxjs = require("rxjs");
2185
+ // src/import/util/default_export.ts
2186
+ function maybeUnwrapDefaultExport(input) {
2187
+ return isWrappedDefaultExport(input) ? input["default"] : input;
2188
+ }
2189
+ function isWrappedDefaultExport(value) {
2190
+ return value && typeof value === "object" && "default" in value;
2191
+ }
1742
2192
 
1743
- // src/import/error_handler.ts
1744
- var ErrorHandler = class {
1745
- /**
1746
- * @internal
1747
- */
1748
- _console = console;
1749
- handleError(error) {
1750
- this._console.error("ERROR", error);
2193
+ // src/import/util/promise_with_resolvers.ts
2194
+ function promiseWithResolvers() {
2195
+ let resolve;
2196
+ let reject;
2197
+ const promise = new Promise((res, rej) => {
2198
+ resolve = res;
2199
+ reject = rej;
2200
+ });
2201
+ return { promise, resolve, reject };
2202
+ }
2203
+
2204
+ // src/import/di/inject_async.ts
2205
+ function injectAsync(loader, options) {
2206
+ if (ngDevMode) {
2207
+ assertInInjectionContext(injectAsync);
2208
+ }
2209
+ const injector = inject2(Injector);
2210
+ let loadedPromise = null;
2211
+ const load = () => {
2212
+ if (!loadedPromise) {
2213
+ loadedPromise = loader();
2214
+ }
2215
+ return loadedPromise;
2216
+ };
2217
+ if (options?.prefetch) {
2218
+ options.prefetch().then(() => load()).catch(() => {
2219
+ });
1751
2220
  }
1752
- };
1753
- var INTERNAL_APPLICATION_ERROR_HANDLER = new InjectionToken("", {
1754
- providedIn: "root",
1755
- factory: () => {
1756
- const injector = inject2(EnvironmentInjector);
1757
- let userErrorHandler;
1758
- return (e) => {
1759
- if (injector.destroyed && !userErrorHandler) {
1760
- setTimeout(() => {
1761
- throw e;
1762
- });
1763
- } else {
1764
- userErrorHandler ??= injector.get(ErrorHandler);
1765
- userErrorHandler.handleError(e);
1766
- }
1767
- };
2221
+ return () => load().then((loadedToken) => injector.get(maybeUnwrapDefaultExport(loadedToken)));
2222
+ }
2223
+ function onIdle(options) {
2224
+ if (ngDevMode) {
2225
+ assertInInjectionContext(onIdle);
1768
2226
  }
1769
- });
2227
+ const idleService = inject2(IDLE_SERVICE);
2228
+ const { promise, resolve } = promiseWithResolvers();
2229
+ idleService.requestOnIdle(() => resolve(), options);
2230
+ return promise;
2231
+ }
1770
2232
 
1771
- // src/import/pending_tasks.ts
2233
+ // src/import/hydration/cache.ts
2234
+ var CACHE_ACTIVE = new InjectionToken(typeof ngDevMode !== "undefined" && ngDevMode ? "STATE_CACHE_ACTIVE" : "");
2235
+
2236
+ // src/import/event_emitter.ts
2237
+ var import_rxjs2 = require("rxjs");
2238
+
2239
+ // src/import/pending_tasks_internal.ts
2240
+ var import_rxjs = require("rxjs");
2241
+
2242
+ // src/import/application/stability_debug.ts
2243
+ var DEBUG_TASK_TRACKER = new InjectionToken(typeof ngDevMode !== "undefined" && ngDevMode ? "DEBUG_TASK_TRACKER" : "");
2244
+
2245
+ // src/import/pending_tasks_internal.ts
1772
2246
  var PendingTasksInternal = class _PendingTasksInternal {
1773
2247
  taskId = 0;
1774
2248
  pendingTasks = /* @__PURE__ */ new Set();
1775
2249
  destroyed = false;
1776
2250
  pendingTask = new import_rxjs.BehaviorSubject(false);
2251
+ debugTaskTracker = inject2(DEBUG_TASK_TRACKER, { optional: true });
1777
2252
  get hasPendingTasks() {
1778
2253
  return this.destroyed ? false : this.pendingTask.value;
1779
2254
  }
@@ -1796,6 +2271,7 @@ var PendingTasksInternal = class _PendingTasksInternal {
1796
2271
  }
1797
2272
  const taskId = this.taskId++;
1798
2273
  this.pendingTasks.add(taskId);
2274
+ this.debugTaskTracker?.add(taskId);
1799
2275
  return taskId;
1800
2276
  }
1801
2277
  has(taskId) {
@@ -1803,6 +2279,7 @@ var PendingTasksInternal = class _PendingTasksInternal {
1803
2279
  }
1804
2280
  remove(taskId) {
1805
2281
  this.pendingTasks.delete(taskId);
2282
+ this.debugTaskTracker?.remove(taskId);
1806
2283
  if (this.pendingTasks.size === 0 && this.hasPendingTasks) {
1807
2284
  this.pendingTask.next(false);
1808
2285
  }
@@ -1825,6 +2302,232 @@ var PendingTasksInternal = class _PendingTasksInternal {
1825
2302
  })
1826
2303
  );
1827
2304
  };
2305
+
2306
+ // src/import/event_emitter.ts
2307
+ var EventEmitter_ = class extends import_rxjs2.Subject {
2308
+ // tslint:disable-next-line:require-internal-with-underscore
2309
+ __isAsync;
2310
+ destroyRef = void 0;
2311
+ pendingTasks = void 0;
2312
+ constructor(isAsync = false) {
2313
+ super();
2314
+ this.__isAsync = isAsync;
2315
+ if (isInInjectionContext()) {
2316
+ this.destroyRef = inject2(DestroyRef, { optional: true }) ?? void 0;
2317
+ this.pendingTasks = inject2(PendingTasksInternal, { optional: true }) ?? void 0;
2318
+ }
2319
+ }
2320
+ emit(value) {
2321
+ const prevConsumer = setActiveConsumer(null);
2322
+ try {
2323
+ super.next(value);
2324
+ } finally {
2325
+ setActiveConsumer(prevConsumer);
2326
+ }
2327
+ }
2328
+ subscribe(observerOrNext, error, complete) {
2329
+ let nextFn = observerOrNext;
2330
+ let errorFn = error || (() => null);
2331
+ let completeFn = complete;
2332
+ if (observerOrNext && typeof observerOrNext === "object") {
2333
+ const observer = observerOrNext;
2334
+ nextFn = observer.next?.bind(observer);
2335
+ errorFn = observer.error?.bind(observer);
2336
+ completeFn = observer.complete?.bind(observer);
2337
+ }
2338
+ if (this.__isAsync) {
2339
+ errorFn = this.wrapInTimeout(errorFn);
2340
+ if (nextFn) {
2341
+ nextFn = this.wrapInTimeout(nextFn);
2342
+ }
2343
+ if (completeFn) {
2344
+ completeFn = this.wrapInTimeout(completeFn);
2345
+ }
2346
+ }
2347
+ const sink = super.subscribe({ next: nextFn, error: errorFn, complete: completeFn });
2348
+ if (observerOrNext instanceof import_rxjs2.Subscription) {
2349
+ observerOrNext.add(sink);
2350
+ }
2351
+ return sink;
2352
+ }
2353
+ wrapInTimeout(fn) {
2354
+ return (value) => {
2355
+ const taskId = this.pendingTasks?.add();
2356
+ setTimeout(() => {
2357
+ try {
2358
+ fn(value);
2359
+ } finally {
2360
+ if (taskId !== void 0) {
2361
+ this.pendingTasks?.remove(taskId);
2362
+ }
2363
+ }
2364
+ });
2365
+ };
2366
+ }
2367
+ };
2368
+ var EventEmitter = EventEmitter_;
2369
+
2370
+ // src/import/zone/ng_zone.ts
2371
+ var isAngularZoneProperty = "isAngularZone";
2372
+ var angularZoneInstanceIdProperty = isAngularZoneProperty + "_ID";
2373
+ var NgZone = class _NgZone {
2374
+ hasPendingMacrotasks = false;
2375
+ hasPendingMicrotasks = false;
2376
+ /**
2377
+ * Whether there are no outstanding microtasks or macrotasks.
2378
+ */
2379
+ isStable = true;
2380
+ /**
2381
+ * Notifies when code enters Angular Zone. This gets fired first on VM Turn.
2382
+ */
2383
+ onUnstable = new EventEmitter(false);
2384
+ /**
2385
+ * Notifies when there is no more microtasks enqueued in the current VM Turn.
2386
+ * This is a hint for Angular to do change detection, which may enqueue more microtasks.
2387
+ * For this reason this event can fire multiple times per VM Turn.
2388
+ */
2389
+ onMicrotaskEmpty = new EventEmitter(false);
2390
+ /**
2391
+ * Notifies when the last `onMicrotaskEmpty` has run and there are no more microtasks, which
2392
+ * implies we are about to relinquish VM turn.
2393
+ * This event gets called just once.
2394
+ */
2395
+ onStable = new EventEmitter(false);
2396
+ /**
2397
+ * Notifies that an error has been delivered.
2398
+ */
2399
+ onError = new EventEmitter(false);
2400
+ constructor(options) {
2401
+ }
2402
+ /**
2403
+ This method checks whether the method call happens within an Angular Zone instance.
2404
+ */
2405
+ /**
2406
+ Assures that the method is called within the Angular Zone, otherwise throws an error.
2407
+ */
2408
+ /**
2409
+ Assures that the method is called outside of the Angular Zone, otherwise throws an error.
2410
+ */
2411
+ /**
2412
+ * Executes the `fn` function synchronously within the Angular zone and returns value returned by
2413
+ * the function.
2414
+ *
2415
+ * Running functions via `run` allows you to reenter Angular zone from a task that was executed
2416
+ * outside of the Angular zone (typically started via {@link #runOutsideAngular}).
2417
+ *
2418
+ * Any future tasks or microtasks scheduled from within this function will continue executing from
2419
+ * within the Angular zone.
2420
+ *
2421
+ * If a synchronous error happens it will be rethrown and not reported via `onError`.
2422
+ */
2423
+ run(fn, applyThis, applyArgs) {
2424
+ return this._inner.run(fn, applyThis, applyArgs);
2425
+ }
2426
+ /**
2427
+ * Executes the `fn` function synchronously within the Angular zone as a task and returns value
2428
+ * returned by the function.
2429
+ *
2430
+ * Running functions via `runTask` allows you to reenter Angular zone from a task that was executed
2431
+ * outside of the Angular zone (typically started via {@link #runOutsideAngular}).
2432
+ *
2433
+ * Any future tasks or microtasks scheduled from within this function will continue executing from
2434
+ * within the Angular zone.
2435
+ *
2436
+ * If a synchronous error happens it will be rethrown and not reported via `onError`.
2437
+ */
2438
+ runTask(fn, applyThis, applyArgs, name) {
2439
+ const zone = this._inner;
2440
+ const task = zone.scheduleEventTask("NgZoneEvent: " + name, fn, EMPTY_PAYLOAD, noop, noop);
2441
+ try {
2442
+ return zone.runTask(task, applyThis, applyArgs);
2443
+ } finally {
2444
+ zone.cancelTask(task);
2445
+ }
2446
+ }
2447
+ /**
2448
+ * Same as `run`, except that synchronous errors are caught and forwarded via `onError` and not
2449
+ * rethrown.
2450
+ */
2451
+ runGuarded(fn, applyThis, applyArgs) {
2452
+ return this._inner.runGuarded(fn, applyThis, applyArgs);
2453
+ }
2454
+ /**
2455
+ * Executes the `fn` function synchronously in Angular's parent zone and returns value returned by
2456
+ * the function.
2457
+ *
2458
+ * Running functions via {@link #runOutsideAngular} allows you to escape Angular's zone and do
2459
+ * work that
2460
+ * doesn't trigger Angular change-detection or is subject to Angular's error handling.
2461
+ *
2462
+ * Any future tasks or microtasks scheduled from within this function will continue executing from
2463
+ * outside of the Angular zone.
2464
+ *
2465
+ * Use {@link #run} to reenter the Angular zone and do work that updates the application model.
2466
+ */
2467
+ runOutsideAngular(fn) {
2468
+ return this._outer.run(fn);
2469
+ }
2470
+ /** @nocollapse */
2471
+ static ɵprov = ɵɵdefineInjectable({
2472
+ token: _NgZone,
2473
+ providedIn: "root",
2474
+ factory: () => new NoopNgZone()
2475
+ });
2476
+ };
2477
+ var EMPTY_PAYLOAD = {};
2478
+ var NoopNgZone = class {
2479
+ hasPendingMicrotasks = false;
2480
+ hasPendingMacrotasks = false;
2481
+ isStable = true;
2482
+ onUnstable = new EventEmitter();
2483
+ onMicrotaskEmpty = new EventEmitter();
2484
+ onStable = new EventEmitter();
2485
+ onError = new EventEmitter();
2486
+ run(fn, applyThis, applyArgs) {
2487
+ return fn.apply(applyThis, applyArgs);
2488
+ }
2489
+ runGuarded(fn, applyThis, applyArgs) {
2490
+ return fn.apply(applyThis, applyArgs);
2491
+ }
2492
+ runOutsideAngular(fn) {
2493
+ return fn();
2494
+ }
2495
+ runTask(fn, applyThis, applyArgs, name) {
2496
+ return fn.apply(applyThis, applyArgs);
2497
+ }
2498
+ };
2499
+
2500
+ // src/import/error_handler.ts
2501
+ var ErrorHandler = class {
2502
+ /**
2503
+ * @internal
2504
+ */
2505
+ _console = console;
2506
+ handleError(error) {
2507
+ this._console.error("ERROR", error);
2508
+ }
2509
+ };
2510
+ var INTERNAL_APPLICATION_ERROR_HANDLER = new InjectionToken(typeof ngDevMode === "undefined" || ngDevMode ? "internal error handler" : "", {
2511
+ factory: () => {
2512
+ const zone = inject2(NgZone);
2513
+ const injector = inject2(EnvironmentInjector);
2514
+ let userErrorHandler;
2515
+ return (e) => {
2516
+ zone.runOutsideAngular(() => {
2517
+ if (injector.destroyed && !userErrorHandler) {
2518
+ setTimeout(() => {
2519
+ throw e;
2520
+ });
2521
+ } else {
2522
+ userErrorHandler ??= injector.get(ErrorHandler);
2523
+ userErrorHandler.handleError(e);
2524
+ }
2525
+ });
2526
+ };
2527
+ }
2528
+ });
2529
+
2530
+ // src/import/pending_tasks.ts
1828
2531
  var PendingTasks = class _PendingTasks {
1829
2532
  internalPendingTasks = inject2(PendingTasksInternal);
1830
2533
  scheduler = inject2(ChangeDetectionScheduler);
@@ -1858,7 +2561,12 @@ var PendingTasks = class _PendingTasks {
1858
2561
  */
1859
2562
  run(fn) {
1860
2563
  const removeTask = this.add();
1861
- fn().catch(this.errorHandler).finally(removeTask);
2564
+ try {
2565
+ fn().catch(this.errorHandler).finally(removeTask);
2566
+ } catch (err) {
2567
+ this.errorHandler(err);
2568
+ removeTask();
2569
+ }
1862
2570
  }
1863
2571
  /** @nocollapse */
1864
2572
  static ɵprov = (
@@ -1871,27 +2579,122 @@ var PendingTasks = class _PendingTasks {
1871
2579
  );
1872
2580
  };
1873
2581
 
2582
+ // src/import/application/application_tokens.ts
2583
+ var APP_ID = new InjectionToken(typeof ngDevMode !== "undefined" && ngDevMode ? "AppId" : "", {
2584
+ factory: () => DEFAULT_APP_ID
2585
+ });
2586
+ var DEFAULT_APP_ID = "ng";
2587
+
2588
+ // src/import/document.ts
2589
+ var DOCUMENT = new InjectionToken(typeof ngDevMode !== "undefined" && ngDevMode ? "DocumentToken" : "");
2590
+
2591
+ // src/import/transfer_state.ts
2592
+ function makeStateKey(key) {
2593
+ return key;
2594
+ }
2595
+ var TransferState = class _TransferState {
2596
+ /** @nocollapse */
2597
+ static ɵprov = (
2598
+ /** @pureOrBreakMyCode */
2599
+ /* @__PURE__ */ ɵɵdefineInjectable({
2600
+ token: _TransferState,
2601
+ providedIn: "root",
2602
+ factory: () => {
2603
+ const transferState = new _TransferState();
2604
+ if (false) {
2605
+ transferState.store = retrieveTransferredState(inject3(DOCUMENT2), inject3(APP_ID2));
2606
+ }
2607
+ return transferState;
2608
+ }
2609
+ })
2610
+ );
2611
+ /** @internal */
2612
+ store = {};
2613
+ onSerializeCallbacks = {};
2614
+ /**
2615
+ * Get the value corresponding to a key. Return `defaultValue` if key is not found.
2616
+ */
2617
+ get(key, defaultValue) {
2618
+ return this.store[key] !== void 0 ? this.store[key] : defaultValue;
2619
+ }
2620
+ /**
2621
+ * Set the value corresponding to a key.
2622
+ */
2623
+ set(key, value) {
2624
+ this.store[key] = value;
2625
+ }
2626
+ /**
2627
+ * Remove a key from the store.
2628
+ */
2629
+ remove(key) {
2630
+ delete this.store[key];
2631
+ }
2632
+ /**
2633
+ * Test whether a key exists in the store.
2634
+ */
2635
+ hasKey(key) {
2636
+ return this.store.hasOwnProperty(key);
2637
+ }
2638
+ /**
2639
+ * Indicates whether the state is empty.
2640
+ */
2641
+ get isEmpty() {
2642
+ return Object.keys(this.store).length === 0;
2643
+ }
2644
+ /**
2645
+ * Register a callback to provide the value for a key when `toJson` is called.
2646
+ */
2647
+ onSerialize(key, callback) {
2648
+ this.onSerializeCallbacks[key] = callback;
2649
+ }
2650
+ /**
2651
+ * Serialize the current state of the store to JSON.
2652
+ */
2653
+ toJson() {
2654
+ for (const key in this.onSerializeCallbacks) {
2655
+ if (this.onSerializeCallbacks.hasOwnProperty(key)) {
2656
+ try {
2657
+ this.store[key] = this.onSerializeCallbacks[key]();
2658
+ } catch (e) {
2659
+ console.warn("Exception in onSerialize callback: ", e);
2660
+ }
2661
+ }
2662
+ }
2663
+ return JSON.stringify(this.store).replace(/</g, "\\u003C").replace(/\//g, "\\u002F");
2664
+ }
2665
+ };
2666
+
1874
2667
  // src/import/resource/resource.ts
1875
2668
  function resource(options) {
1876
- if (false) {
2669
+ if (ngDevMode && !options?.injector) {
2670
+ assertInInjectionContext(resource);
1877
2671
  }
1878
2672
  const oldNameForParams = options.request;
1879
2673
  const params = options.params ?? oldNameForParams ?? (() => null);
1880
- return new ResourceImpl(params, getLoader(options), options.defaultValue, options.equal ? wrapEqualityFn(options.equal) : void 0, options.injector ?? inject2(Injector));
2674
+ return new ResourceImpl(
2675
+ params,
2676
+ getLoader(options),
2677
+ options.defaultValue,
2678
+ options.equal ? wrapEqualityFn(options.equal) : void 0,
2679
+ options.debugName,
2680
+ options.injector ?? inject2(Injector),
2681
+ options.id
2682
+ );
1881
2683
  }
1882
2684
  var BaseWritableResource = class {
1883
2685
  value;
1884
- constructor(value) {
2686
+ isLoading;
2687
+ constructor(value, debugName) {
1885
2688
  this.value = value;
1886
2689
  this.value.set = this.set.bind(this);
1887
2690
  this.value.update = this.update.bind(this);
1888
2691
  this.value.asReadonly = signalAsReadonlyFn;
2692
+ this.isLoading = computed(() => this.status() === "loading" || this.status() === "reloading", ngDevMode ? createDebugNameObject(debugName, "isLoading") : void 0);
1889
2693
  }
1890
2694
  isError = computed(() => this.status() === "error");
1891
2695
  update(updateFn) {
1892
2696
  this.set(updateFn(untracked2(this.value)));
1893
2697
  }
1894
- isLoading = computed(() => this.status() === "loading" || this.status() === "reloading");
1895
2698
  // Use a computed here to avoid triggering reactive consumers if the value changes while staying
1896
2699
  // either defined or undefined.
1897
2700
  isValueDefined = computed(() => {
@@ -1900,6 +2703,17 @@ var BaseWritableResource = class {
1900
2703
  }
1901
2704
  return this.value() !== void 0;
1902
2705
  });
2706
+ _snapshot;
2707
+ get snapshot() {
2708
+ return this._snapshot ??= computed(() => {
2709
+ const status = this.status();
2710
+ if (status === "error") {
2711
+ return { status: "error", error: this.error() };
2712
+ } else {
2713
+ return { status, value: this.value() };
2714
+ }
2715
+ });
2716
+ }
1903
2717
  hasValue() {
1904
2718
  return this.isValueDefined();
1905
2719
  }
@@ -1908,7 +2722,10 @@ var BaseWritableResource = class {
1908
2722
  }
1909
2723
  };
1910
2724
  var ResourceImpl = class extends BaseWritableResource {
1911
- constructor(request, loaderFn, defaultValue, equal, injector) {
2725
+ constructor(request, loaderFn, defaultValue, equal, debugName, injector, transferCacheKey, getInitialStream) {
2726
+ if (isInParamsFunction()) {
2727
+ throw invalidResourceCreationInParams();
2728
+ }
1912
2729
  super(
1913
2730
  // Feed a computed signal for the value to `BaseWritableResource`, which will upgrade it to a
1914
2731
  // `WritableSignal` that delegates to `ResourceImpl.set`.
@@ -1926,45 +2743,91 @@ var ResourceImpl = class extends BaseWritableResource {
1926
2743
  }
1927
2744
  return streamValue.value;
1928
2745
  },
1929
- { equal }
1930
- )
2746
+ { equal, ...ngDevMode ? createDebugNameObject(debugName, "value") : void 0 }
2747
+ ),
2748
+ debugName
1931
2749
  );
1932
2750
  this.loaderFn = loaderFn;
1933
2751
  this.equal = equal;
1934
- this.extRequest = linkedSignal({
1935
- source: request,
1936
- computation: (request2) => ({ request: request2, reload: 0 })
1937
- });
2752
+ this.debugName = debugName;
2753
+ this.transferCacheKey = transferCacheKey;
2754
+ const cacheState = injector.get(CACHE_ACTIVE, void 0, { optional: true }) ?? { isActive: false };
2755
+ this.transferState = injector.get(TransferState, void 0, { optional: true }) ?? void 0;
2756
+ this.extRequest = linkedSignal(
2757
+ () => {
2758
+ try {
2759
+ setInParamsFunction(true);
2760
+ return { request: request(paramsContext), reload: 0 };
2761
+ } catch (error) {
2762
+ rethrowFatalErrors(error);
2763
+ if (error === ResourceParamsStatus.IDLE) {
2764
+ return { status: "idle", reload: 0 };
2765
+ } else if (error === ResourceParamsStatus.LOADING) {
2766
+ return { status: "loading", reload: 0 };
2767
+ }
2768
+ return { error, reload: 0 };
2769
+ } finally {
2770
+ setInParamsFunction(false);
2771
+ }
2772
+ },
2773
+ ngDevMode ? createDebugNameObject(debugName, "extRequest") : void 0
2774
+ );
1938
2775
  this.state = linkedSignal({
1939
2776
  // Whenever the request changes,
1940
2777
  source: this.extRequest,
1941
2778
  // Compute the state of the resource given a change in status.
1942
2779
  computation: (extRequest, previous) => {
1943
- const status = extRequest.request === void 0 ? "idle" : "loading";
1944
- if (!previous) {
1945
- return {
1946
- extRequest,
1947
- status,
1948
- previousStatus: "idle",
1949
- stream: void 0
1950
- };
1951
- } else {
1952
- return {
1953
- extRequest,
1954
- status,
1955
- previousStatus: projectStatusOfState(previous.value),
1956
- // If the request hasn't changed, keep the previous stream.
1957
- stream: previous.value.extRequest.request === extRequest.request ? previous.value.stream : void 0
1958
- };
2780
+ let { request: request2, status, error } = extRequest;
2781
+ let stream;
2782
+ if (error) {
2783
+ status = "resolved";
2784
+ stream = signal({ error: encapsulateResourceError(error) }, ngDevMode ? createDebugNameObject(this.debugName, "stream") : void 0);
2785
+ } else if (!status) {
2786
+ if (!previous) {
2787
+ const transferState = this.transferState;
2788
+ const cacheKey = this.transferCacheKey;
2789
+ if (cacheState.isActive && cacheKey && transferState && request2 !== void 0) {
2790
+ const key = this.transferCacheKey;
2791
+ if (transferState.hasKey(cacheKey)) {
2792
+ stream = signal({ value: transferState.get(cacheKey, defaultValue) }, ngDevMode ? createDebugNameObject(this.debugName, "stream") : void 0);
2793
+ }
2794
+ }
2795
+ if (!stream) {
2796
+ stream = getInitialStream?.(extRequest.request);
2797
+ }
2798
+ getInitialStream = void 0;
2799
+ status = request2 === void 0 ? "idle" : stream ? "resolved" : "loading";
2800
+ } else {
2801
+ status = request2 === void 0 ? "idle" : "loading";
2802
+ if (previous.value.extRequest.request === request2) {
2803
+ stream = previous.value.stream;
2804
+ }
2805
+ }
1959
2806
  }
1960
- }
2807
+ return {
2808
+ extRequest,
2809
+ status,
2810
+ previousStatus: previous ? projectStatusOfState(previous.value) : "idle",
2811
+ stream
2812
+ };
2813
+ },
2814
+ ...ngDevMode ? createDebugNameObject(debugName, "state") : void 0
1961
2815
  });
1962
2816
  this.effectRef = effect(this.loadEffect.bind(this), {
1963
2817
  injector,
1964
- manualCleanup: true
2818
+ manualCleanup: true,
2819
+ ...ngDevMode ? createDebugNameObject(debugName, "loadEffect") : void 0
1965
2820
  });
1966
2821
  this.pendingTasks = injector.get(PendingTasks);
1967
2822
  this.unregisterOnDestroy = injector.get(DestroyRef).onDestroy(() => this.destroy());
2823
+ this.status = computed(() => projectStatusOfState(this.state()), ngDevMode ? createDebugNameObject(debugName, "status") : void 0);
2824
+ this.error = computed(
2825
+ () => {
2826
+ const stream = this.state().stream?.();
2827
+ return stream && !isResolved(stream) ? stream.error : void 0;
2828
+ },
2829
+ ngDevMode ? createDebugNameObject(debugName, "error") : void 0
2830
+ );
1968
2831
  }
1969
2832
  pendingTasks;
1970
2833
  /**
@@ -1981,11 +2844,9 @@ var ResourceImpl = class extends BaseWritableResource {
1981
2844
  resolvePendingTask = void 0;
1982
2845
  destroyed = false;
1983
2846
  unregisterOnDestroy;
1984
- status = computed(() => projectStatusOfState(this.state()));
1985
- error = computed(() => {
1986
- const stream = this.state().stream?.();
1987
- return stream && !isResolved(stream) ? stream.error : void 0;
1988
- });
2847
+ status;
2848
+ error;
2849
+ transferState;
1989
2850
  /**
1990
2851
  * Called either directly via `WritableResource.set` or via `.value.set()`.
1991
2852
  */
@@ -2005,7 +2866,7 @@ var ResourceImpl = class extends BaseWritableResource {
2005
2866
  extRequest: state.extRequest,
2006
2867
  status: "local",
2007
2868
  previousStatus: "local",
2008
- stream: signal({ value })
2869
+ stream: signal({ value }, ngDevMode ? createDebugNameObject(this.debugName, "stream") : void 0)
2009
2870
  });
2010
2871
  this.abortInProgressLoad();
2011
2872
  }
@@ -2041,27 +2902,48 @@ var ResourceImpl = class extends BaseWritableResource {
2041
2902
  let resolvePendingTask = this.resolvePendingTask = this.pendingTasks.add();
2042
2903
  const { signal: abortSignal } = this.pendingController = new AbortController();
2043
2904
  try {
2044
- const stream = await untracked2(
2905
+ const stream = untracked2(
2045
2906
  () => this.loaderFn({
2046
2907
  params: extRequest.request,
2047
- // TODO(alxhub): cleanup after g3 removal of `request` alias.
2048
- request: extRequest.request,
2049
2908
  abortSignal,
2050
2909
  previous: {
2051
2910
  status: previousStatus
2052
2911
  }
2053
2912
  })
2054
2913
  );
2055
- if (abortSignal.aborted || untracked2(this.extRequest) !== extRequest) {
2056
- return;
2914
+ const shouldDiscard = () => abortSignal.aborted || untracked2(this.extRequest) !== extRequest;
2915
+ if (isSignal2(stream)) {
2916
+ if (shouldDiscard()) {
2917
+ return;
2918
+ }
2919
+ this.state.set({
2920
+ extRequest,
2921
+ status: "resolved",
2922
+ previousStatus: "resolved",
2923
+ stream
2924
+ });
2925
+ const result = untracked2(stream);
2926
+ if (true) {
2927
+ saveToTransferState(result, this.transferCacheKey, this.transferState);
2928
+ }
2929
+ } else {
2930
+ const resolvedStream = await stream;
2931
+ if (shouldDiscard()) {
2932
+ return;
2933
+ }
2934
+ this.state.set({
2935
+ extRequest,
2936
+ status: "resolved",
2937
+ previousStatus: "resolved",
2938
+ stream: resolvedStream
2939
+ });
2940
+ const result = resolvedStream ? untracked2(resolvedStream) : void 0;
2941
+ if (true) {
2942
+ saveToTransferState(result, this.transferCacheKey, this.transferState);
2943
+ }
2057
2944
  }
2058
- this.state.set({
2059
- extRequest,
2060
- status: "resolved",
2061
- previousStatus: "resolved",
2062
- stream
2063
- });
2064
2945
  } catch (err) {
2946
+ rethrowFatalErrors(err);
2065
2947
  if (abortSignal.aborted || untracked2(this.extRequest) !== extRequest) {
2066
2948
  return;
2067
2949
  }
@@ -2069,7 +2951,7 @@ var ResourceImpl = class extends BaseWritableResource {
2069
2951
  extRequest,
2070
2952
  status: "resolved",
2071
2953
  previousStatus: "error",
2072
- stream: signal({ error: encapsulateResourceError(err) })
2954
+ stream: signal({ error: encapsulateResourceError(err) }, ngDevMode ? createDebugNameObject(this.debugName, "stream") : void 0)
2073
2955
  });
2074
2956
  } finally {
2075
2957
  resolvePendingTask?.();
@@ -2083,6 +2965,11 @@ var ResourceImpl = class extends BaseWritableResource {
2083
2965
  this.resolvePendingTask = void 0;
2084
2966
  }
2085
2967
  };
2968
+ function saveToTransferState(result, transferCacheKey, transferState) {
2969
+ if (transferCacheKey && transferState && result && isResolved(result)) {
2970
+ transferState.set(transferCacheKey, result.value);
2971
+ }
2972
+ }
2086
2973
  function wrapEqualityFn(equal) {
2087
2974
  return (a, b) => a === void 0 || b === void 0 ? a === b : equal(a, b);
2088
2975
  }
@@ -2092,9 +2979,9 @@ function getLoader(options) {
2092
2979
  }
2093
2980
  return async (params) => {
2094
2981
  try {
2095
- return signal({ value: await options.loader(params) });
2982
+ return signal({ value: await options.loader(params) }, ngDevMode ? createDebugNameObject(options.debugName, "stream") : void 0);
2096
2983
  } catch (err) {
2097
- return signal({ error: encapsulateResourceError(err) });
2984
+ return signal({ error: encapsulateResourceError(err) }, ngDevMode ? createDebugNameObject(options.debugName, "stream") : void 0);
2098
2985
  }
2099
2986
  };
2100
2987
  }
@@ -2114,23 +3001,171 @@ function projectStatusOfState(state) {
2114
3001
  function isResolved(state) {
2115
3002
  return state.error === void 0;
2116
3003
  }
3004
+ function createDebugNameObject(resourceDebugName, internalSignalDebugName) {
3005
+ return {
3006
+ debugName: `Resource${resourceDebugName ? "#" + resourceDebugName : ""}.${internalSignalDebugName}`
3007
+ };
3008
+ }
2117
3009
  function encapsulateResourceError(error) {
2118
- if (error instanceof Error) {
3010
+ if (isErrorLike(error)) {
2119
3011
  return error;
2120
3012
  }
2121
3013
  return new ResourceWrappedError(error);
2122
3014
  }
3015
+ function isErrorLike(error) {
3016
+ return error instanceof Error || typeof error === "object" && typeof error.name === "string" && typeof error.message === "string";
3017
+ }
2123
3018
  var ResourceValueError = class extends Error {
2124
3019
  constructor(error) {
2125
- super(error.message, { cause: error });
3020
+ super(ngDevMode ? `Resource is currently in an error state (see Error.cause for details): ${error.message}` : error.message, { cause: error });
2126
3021
  }
2127
3022
  };
2128
3023
  var ResourceWrappedError = class extends Error {
2129
3024
  constructor(error) {
2130
- super(String(error), { cause: error });
3025
+ super(ngDevMode ? `Resource returned an error that's not an Error instance: ${String(error)}. Check this error's .cause for the actual error.` : String(error), { cause: error });
3026
+ }
3027
+ };
3028
+ function chain(resource2) {
3029
+ switch (resource2.status()) {
3030
+ case "idle":
3031
+ throw ResourceParamsStatus.IDLE;
3032
+ case "error":
3033
+ throw new ResourceDependencyError(resource2);
3034
+ case "loading":
3035
+ case "reloading":
3036
+ throw ResourceParamsStatus.LOADING;
3037
+ }
3038
+ return resource2.value();
3039
+ }
3040
+ var paramsContext = {
3041
+ chain
3042
+ };
3043
+ var inParamsFunction = false;
3044
+ function isInParamsFunction() {
3045
+ return inParamsFunction;
3046
+ }
3047
+ function setInParamsFunction(value) {
3048
+ inParamsFunction = value;
3049
+ }
3050
+ function invalidResourceCreationInParams() {
3051
+ return new RuntimeError(992 /* INVALID_RESOURCE_CREATION_IN_PARAMS */, ngDevMode && `Cannot create a resource inside the \`params\` of another resource`);
3052
+ }
3053
+ function rethrowFatalErrors(error) {
3054
+ if (error instanceof RuntimeError && error.code === 992 /* INVALID_RESOURCE_CREATION_IN_PARAMS */) {
3055
+ throw error;
3056
+ }
3057
+ }
3058
+
3059
+ // src/import/resource/from_snapshots.ts
3060
+ function resourceFromSnapshots(source) {
3061
+ return new SnapshotResource(isSignal2(source) ? source : computed(source));
3062
+ }
3063
+ var SnapshotResource = class {
3064
+ constructor(snapshot) {
3065
+ this.snapshot = snapshot;
3066
+ }
3067
+ get state() {
3068
+ return this.snapshot();
3069
+ }
3070
+ value = computed(() => {
3071
+ if (this.state.status === "error") {
3072
+ throw new ResourceValueError(this.state.error);
3073
+ }
3074
+ return this.state.value;
3075
+ });
3076
+ status = computed(() => this.state.status);
3077
+ error = computed(() => this.state.status === "error" ? this.state.error : void 0);
3078
+ isLoading = computed(() => this.state.status === "loading" || this.state.status === "reloading");
3079
+ isValueDefined = computed(() => this.state.status !== "error" && this.state.value !== void 0);
3080
+ hasValue() {
3081
+ return this.isValueDefined();
2131
3082
  }
2132
3083
  };
2133
3084
 
3085
+ // src/import/resource/debounce.ts
3086
+ function debounced(source, wait, options) {
3087
+ if (isInParamsFunction()) {
3088
+ throw invalidResourceCreationInParams();
3089
+ }
3090
+ if (ngDevMode && !options?.injector) {
3091
+ assertInInjectionContext(debounced);
3092
+ }
3093
+ const injector = options?.injector ?? inject2(Injector);
3094
+ let active;
3095
+ let pendingValue;
3096
+ injector.get(DestroyRef).onDestroy(() => {
3097
+ active = void 0;
3098
+ });
3099
+ const state = linkedSignal({
3100
+ source: () => {
3101
+ try {
3102
+ setInParamsFunction(true);
3103
+ return { value: source(), thrown: false };
3104
+ } catch (err) {
3105
+ rethrowFatalErrors(err);
3106
+ return { error: err, thrown: true };
3107
+ } finally {
3108
+ setInParamsFunction(false);
3109
+ }
3110
+ },
3111
+ computation: (res, previous) => {
3112
+ if (previous !== void 0) {
3113
+ return previous.value;
3114
+ }
3115
+ if (res.thrown) {
3116
+ return { status: "error", error: res.error };
3117
+ }
3118
+ return { status: "resolved", value: res.value };
3119
+ }
3120
+ });
3121
+ effect(
3122
+ () => {
3123
+ let value;
3124
+ try {
3125
+ setInParamsFunction(true);
3126
+ value = source();
3127
+ } catch (err) {
3128
+ rethrowFatalErrors(err);
3129
+ state.set({ status: "error", error: err });
3130
+ active = pendingValue = void 0;
3131
+ return;
3132
+ } finally {
3133
+ setInParamsFunction(false);
3134
+ }
3135
+ const currentState = untracked2(state);
3136
+ const equal = options?.equal ?? Object.is;
3137
+ if (currentState.status === "reloading" || currentState.status === "loading") {
3138
+ if (equal(value, pendingValue)) return;
3139
+ } else if (currentState.status === "resolved") {
3140
+ if (equal(value, currentState.value)) return;
3141
+ }
3142
+ const waitFn = typeof wait === "number" ? () => new Promise((resolve) => setTimeout(resolve, wait)) : wait;
3143
+ const result = waitFn(value, currentState);
3144
+ if (result === void 0) {
3145
+ state.set({ status: "resolved", value });
3146
+ active = pendingValue = void 0;
3147
+ } else {
3148
+ if (currentState.status !== "loading" && currentState.status !== "error") {
3149
+ state.set({ status: "loading", value: currentState.value });
3150
+ }
3151
+ active = result;
3152
+ pendingValue = value;
3153
+ result.then(() => {
3154
+ if (active === result) {
3155
+ state.set({ status: "resolved", value });
3156
+ active = pendingValue = void 0;
3157
+ }
3158
+ });
3159
+ }
3160
+ },
3161
+ { injector }
3162
+ );
3163
+ return resourceFromSnapshots(state);
3164
+ }
3165
+
3166
+ // src/import/interface/type.ts
3167
+ var Type = Function;
3168
+
2134
3169
  // src/import/index.ts
2135
3170
  function Injectable(args) {
2136
3171
  return (constructor) => {
@@ -2163,6 +3198,7 @@ function createRootInjector(options) {
2163
3198
  }
2164
3199
  // Annotate the CommonJS export names for ESM import in node:
2165
3200
  0 && (module.exports = {
3201
+ APP_ID,
2166
3202
  ChangeDetectionScheduler,
2167
3203
  ChangeDetectionSchedulerImpl,
2168
3204
  DecoratorFlags,
@@ -2170,6 +3206,7 @@ function createRootInjector(options) {
2170
3206
  EffectScheduler,
2171
3207
  EnvironmentInjector,
2172
3208
  ErrorHandler,
3209
+ EventEmitter,
2173
3210
  INJECTOR_SCOPE,
2174
3211
  INTERNAL_APPLICATION_ERROR_HANDLER,
2175
3212
  Inject,
@@ -2183,20 +3220,20 @@ function createRootInjector(options) {
2183
3220
  NotificationSource,
2184
3221
  NullInjector,
2185
3222
  Optional,
2186
- PROVIDED_ZONELESS,
2187
3223
  PendingTasks,
2188
- PendingTasksInternal,
2189
3224
  R3Injector,
3225
+ ResourceDependencyError,
3226
+ ResourceParamsStatus,
2190
3227
  RetrievingInjector,
2191
3228
  RootStaticInjectOptions,
2192
- SCHEDULE_IN_ROOT_ZONE,
2193
3229
  SOURCE,
2194
3230
  Self,
2195
3231
  SkipSelf,
2196
3232
  StaticInjectOptions,
2197
3233
  THROW_IF_NOT_FOUND,
2198
- ZONELESS_ENABLED,
2199
- ZONELESS_SCHEDULER_DISABLED,
3234
+ TransferState,
3235
+ Type,
3236
+ assertInInjectionContext,
2200
3237
  assertNotDestroyed,
2201
3238
  assertNotInReactiveContext,
2202
3239
  attachInjectFlag,
@@ -2204,8 +3241,9 @@ function createRootInjector(options) {
2204
3241
  convertToBitFlags,
2205
3242
  createInjector,
2206
3243
  createRootInjector,
3244
+ debounced,
2207
3245
  effect,
2208
- formatError,
3246
+ forwardRef,
2209
3247
  getCurrentInjector,
2210
3248
  getInheritedInjectableDef,
2211
3249
  getInjectFlag,
@@ -2214,12 +3252,20 @@ function createRootInjector(options) {
2214
3252
  getNullInjector,
2215
3253
  inject,
2216
3254
  injectArgs,
3255
+ injectAsync,
2217
3256
  injectInjectorOnly,
2218
3257
  isInjectable,
2219
3258
  isSignal,
3259
+ isWritableSignal,
2220
3260
  linkedSignal,
3261
+ makeStateKey,
3262
+ onIdle,
3263
+ provideIdleServiceWith,
2221
3264
  providerToFactory,
3265
+ resolveForwardRef,
2222
3266
  resource,
3267
+ resourceFromSnapshots,
3268
+ runInInjectionContext,
2223
3269
  setCurrentInjector,
2224
3270
  signal,
2225
3271
  untracked,
@@ -2239,11 +3285,4 @@ function createRootInjector(options) {
2239
3285
  * Use of this source code is governed by an MIT-style license that can be
2240
3286
  * found in the LICENSE file at https://angular.dev/license
2241
3287
  */
2242
- /**
2243
- * @license
2244
- * Copyright Google LLC All Rights Reserved.
2245
- *
2246
- * Use of this source code is governed by an MIT-style license that can be
2247
- * found in the LICENSE file at https://angular.io/license
2248
- */
2249
3288
  //# sourceMappingURL=index.js.map