static-injector 6.4.0 → 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 (52) 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 +4 -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 +10 -4
  26. package/import/render3/debug/special_providers.d.ts +17 -0
  27. package/import/render3/reactivity/api.d.ts +15 -0
  28. package/import/render3/reactivity/asserts.d.ts +1 -0
  29. package/import/render3/reactivity/effect.d.ts +3 -1
  30. package/import/render3/reactivity/root_effect_scheduler.d.ts +1 -1
  31. package/import/render3/reactivity/signal.d.ts +0 -4
  32. package/import/render3/util/stringify_utils.d.ts +1 -1
  33. package/import/resource/api.d.ts +101 -15
  34. package/import/resource/debounce.d.ts +21 -0
  35. package/import/resource/from_snapshots.d.ts +16 -0
  36. package/import/resource/index.d.ts +2 -0
  37. package/import/resource/resource.d.ts +32 -8
  38. package/import/transfer_state.d.ts +89 -0
  39. package/import/util/default_export.d.ts +24 -0
  40. package/import/util/promise_with_resolvers.d.ts +38 -0
  41. package/import/zone/ng_zone.d.ts +261 -0
  42. package/index.js +875 -196
  43. package/index.js.map +4 -4
  44. package/index.mjs +858 -190
  45. package/index.mjs.map +4 -4
  46. package/package.json +2 -2
  47. package/primitives/signals/index.d.ts +1 -1
  48. package/primitives/signals/src/formatter.d.ts +2 -1
  49. package/primitives/signals/src/graph.d.ts +8 -1
  50. package/primitives/signals/src/linked_signal.d.ts +1 -1
  51. package/readme.md +1 -1
  52. /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
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,
@@ -115,7 +126,7 @@ function formatRuntimeError(code, message) {
115
126
  if (ngDevMode && code < 0) {
116
127
  const addPeriodSeparator = !errorMessage.match(/[.,;!?\n]$/);
117
128
  const separator = addPeriodSeparator ? "." : "";
118
- errorMessage = `${errorMessage}${separator} Find more at ${"https://v20.angular.dev/errors"}/${fullCode}`;
129
+ errorMessage = `${errorMessage}${separator} Find more at ${"https://v22.angular.dev/errors"}/${fullCode}`;
119
130
  }
120
131
  return errorMessage;
121
132
  }
@@ -157,9 +168,11 @@ function stringify(token) {
157
168
  var __forward_ref__ = getClosureSafeProperty({ __forward_ref__: getClosureSafeProperty });
158
169
  function forwardRef(forwardRefFn) {
159
170
  forwardRefFn.__forward_ref__ = forwardRef;
160
- forwardRefFn.toString = function() {
161
- return stringify(this());
162
- };
171
+ if (ngDevMode) {
172
+ forwardRefFn.toString = function() {
173
+ return stringify(this());
174
+ };
175
+ }
163
176
  return forwardRefFn;
164
177
  }
165
178
  function resolveForwardRef(type) {
@@ -225,12 +238,12 @@ function producerAccessed(node) {
225
238
  if (nextProducerLink !== void 0 && nextProducerLink.producer === node) {
226
239
  activeConsumer.producersTail = nextProducerLink;
227
240
  nextProducerLink.lastReadVersion = node.version;
241
+ nextProducerLink.knownValidAtEpoch = epoch;
228
242
  return;
229
243
  }
230
244
  }
231
245
  const prevConsumerLink = node.consumersTail;
232
- 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
233
- (!isRecomputing || isValidLink(prevConsumerLink, activeConsumer))) {
246
+ if (prevConsumerLink !== void 0 && prevConsumerLink.consumer === activeConsumer && (!isRecomputing || prevConsumerLink.knownValidAtEpoch === epoch)) {
234
247
  return;
235
248
  }
236
249
  const isLive = consumerIsLive(activeConsumer);
@@ -240,7 +253,12 @@ function producerAccessed(node) {
240
253
  // instead of eagerly destroying the previous link, we delay until we've finished recomputing
241
254
  // the producers list, so that we can destroy all of the old links at once.
242
255
  nextProducer: nextProducerLink,
243
- prevConsumer: prevConsumerLink,
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,
244
262
  lastReadVersion: node.version,
245
263
  nextConsumer: void 0
246
264
  };
@@ -305,6 +323,13 @@ function consumerBeforeComputation(node) {
305
323
  return setActiveConsumer(node);
306
324
  }
307
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;
331
+ }
332
+ }
308
333
  node.producersTail = void 0;
309
334
  node.recomputing = true;
310
335
  }
@@ -404,22 +429,6 @@ function consumerIsLive(node) {
404
429
  function runPostProducerCreatedFn(node) {
405
430
  postProducerCreatedFn?.(node);
406
431
  }
407
- function isValidLink(checkLink, consumer) {
408
- const producersTail = consumer.producersTail;
409
- if (producersTail !== void 0) {
410
- let link = consumer.producers;
411
- do {
412
- if (link === checkLink) {
413
- return true;
414
- }
415
- if (link === producersTail) {
416
- break;
417
- }
418
- link = link.nextProducer;
419
- } while (link !== void 0);
420
- }
421
- return false;
422
- }
423
432
 
424
433
  // src/primitives/signals/src/formatter.ts
425
434
  var formatter = {
@@ -431,8 +440,8 @@ var formatter = {
431
440
  let value;
432
441
  try {
433
442
  value = sig();
434
- } catch {
435
- return ["span", "Signal(⚠️ Error)"];
443
+ } catch (e) {
444
+ return ["span", `Signal(⚠️ Error)${e.message ? `: ${e.message}` : ""}`];
436
445
  }
437
446
  const kind = "computation" in sig[SIGNAL] ? "Computed" : "Signal";
438
447
  const isPrimitive = value === null || !Array.isArray(value) && typeof value !== "object";
@@ -469,7 +478,7 @@ var formatter = {
469
478
  ["div", { style: `color: ${color}` }, "Signal value: "],
470
479
  ["div", { style: `padding-left: .5rem;` }, ["object", { object: sig(), config }]],
471
480
  ["div", { style: `color: ${color}` }, "Signal function: "],
472
- ["div", { style: `padding-left: .5rem;` }, ["object", { object: sig, config: { ...config, skipFormatting: true } }]]
481
+ ["div", { style: `padding-left: .5rem;` }, ["object", { object: sig, config: { ...config, ngSkipFormatting: true } }]]
473
482
  ];
474
483
  }
475
484
  };
@@ -497,7 +506,7 @@ function prettifyPreview(value) {
497
506
  }
498
507
  }
499
508
  default: {
500
- return ["object", { object: value, config: { skipFormatting: true } }];
509
+ return ["object", { object: value, config: { ngSkipFormatting: true } }];
501
510
  }
502
511
  }
503
512
  }
@@ -533,8 +542,7 @@ function createComputed(computation, equal) {
533
542
  };
534
543
  computed2[SIGNAL] = node;
535
544
  if (typeof ngDevMode !== "undefined" && ngDevMode) {
536
- const debugName = node.debugName ? " (" + node.debugName + ")" : "";
537
- computed2.toString = () => `[Computed${debugName}: ${node.value}]`;
545
+ computed2.toString = () => `[Computed${node.debugName ? " (" + node.debugName + ")" : ""}: ${String(node.value)}]`;
538
546
  }
539
547
  runPostProducerCreatedFn(node);
540
548
  return computed2;
@@ -600,8 +608,7 @@ function createSignal(initialValue, equal) {
600
608
  const getter = () => signalGetFn(node);
601
609
  getter[SIGNAL] = node;
602
610
  if (typeof ngDevMode !== "undefined" && ngDevMode) {
603
- const debugName = node.debugName ? " (" + node.debugName + ")" : "";
604
- getter.toString = () => `[Signal${debugName}: ${node.value}]`;
611
+ getter.toString = () => `[Signal${node.debugName ? " (" + node.debugName + ")" : ""}: ${String(node.value)}]`;
605
612
  }
606
613
  runPostProducerCreatedFn(node);
607
614
  const set = (newValue) => signalSetFn(node, newValue);
@@ -659,8 +666,7 @@ function createLinkedSignal(sourceFn, computationFn, equalityFn) {
659
666
  const getter = linkedSignalGetter;
660
667
  getter[SIGNAL] = node;
661
668
  if (typeof ngDevMode !== "undefined" && ngDevMode) {
662
- const debugName = node.debugName ? " (" + node.debugName + ")" : "";
663
- getter.toString = () => `[LinkedSignal${debugName}: ${node.value}]`;
669
+ getter.toString = () => `[LinkedSignal${node.debugName ? " (" + node.debugName + ")" : ""}: ${String(node.value)}]`;
664
670
  }
665
671
  runPostProducerCreatedFn(node);
666
672
  return getter;
@@ -672,6 +678,9 @@ function linkedSignalSetFn(node, newValue) {
672
678
  }
673
679
  function linkedSignalUpdateFn(node, updater) {
674
680
  producerUpdateValueVersion(node);
681
+ if (node.value === ERRORED) {
682
+ throw node.error;
683
+ }
675
684
  signalUpdateFn(node, updater);
676
685
  producerMarkClean(node);
677
686
  }
@@ -693,21 +702,25 @@ var LINKED_SIGNAL_NODE = /* @__PURE__ */ (() => ({
693
702
  node.value = COMPUTING;
694
703
  const prevConsumer = consumerBeforeComputation(node);
695
704
  let newValue;
705
+ let wasEqual = false;
696
706
  try {
697
707
  const newSourceValue = node.source();
698
- const prev = oldValue === UNSET || oldValue === ERRORED ? void 0 : {
708
+ const oldValueValid = oldValue !== UNSET && oldValue !== ERRORED;
709
+ const prev = oldValueValid ? {
699
710
  source: node.sourceValue,
700
711
  value: oldValue
701
- };
712
+ } : void 0;
702
713
  newValue = node.computation(newSourceValue, prev);
703
714
  node.sourceValue = newSourceValue;
715
+ setActiveConsumer(null);
716
+ wasEqual = oldValueValid && newValue !== ERRORED && node.equal(oldValue, newValue);
704
717
  } catch (err) {
705
718
  newValue = ERRORED;
706
719
  node.error = err;
707
720
  } finally {
708
721
  consumerAfterComputation(node, prevConsumer);
709
722
  }
710
- if (oldValue !== UNSET && newValue !== ERRORED && node.equal(oldValue, newValue)) {
723
+ if (wasEqual) {
711
724
  node.value = oldValue;
712
725
  return;
713
726
  }
@@ -750,7 +763,7 @@ function runEffect(node) {
750
763
  }
751
764
 
752
765
  // src/primitives/signals/index.ts
753
- if (typeof ngDevMode !== "undefined" && ngDevMode) {
766
+ if (typeof ngDevMode === "undefined" || ngDevMode) {
754
767
  installDevToolsSignalFormatter();
755
768
  }
756
769
 
@@ -810,12 +823,6 @@ var NG_INJ_DEF = getClosureSafeProperty({ ɵinj: getClosureSafeProperty });
810
823
 
811
824
  // src/import/di/injection_token.ts
812
825
  var InjectionToken = class {
813
- /**
814
- * @param _desc Description for the token,
815
- * used only for debugging purposes,
816
- * it should but does not need to be unique
817
- * @param options Options for the token's usage, as described above
818
- */
819
826
  constructor(_desc, options) {
820
827
  this._desc = _desc;
821
828
  this.ɵprov = void 0;
@@ -886,7 +893,7 @@ function emitProviderConfiguredEvent(eventProvider, isViewProvider = false) {
886
893
  function emitInjectorToCreateInstanceEvent(token) {
887
894
  !ngDevMode && throwError("Injector profiler should never be called in production mode");
888
895
  injectorProfiler({
889
- type: 4 /* InjectorToCreateInstanceEvent */,
896
+ type: 5 /* InjectorToCreateInstanceEvent */,
890
897
  context: getInjectorProfilerContext(),
891
898
  token
892
899
  });
@@ -962,11 +969,11 @@ function throwInvalidProviderError(ngModuleType, providers, provider) {
962
969
  } else if (isEnvironmentProviders(provider)) {
963
970
  if (provider.ɵfromNgModule) {
964
971
  throw new RuntimeError(
965
- 207 /* PROVIDER_IN_WRONG_CONTEXT */,
972
+ -207 /* PROVIDER_IN_WRONG_CONTEXT */,
966
973
  `Invalid providers from 'importProvidersFrom' present in a non-environment injector. 'importProvidersFrom' can't be used for component providers.`
967
974
  );
968
975
  } else {
969
- throw new RuntimeError(207 /* PROVIDER_IN_WRONG_CONTEXT */, `Invalid providers present in a non-environment injector. 'EnvironmentProviders' can't be used for component providers.`);
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.`);
970
977
  }
971
978
  } else {
972
979
  throw new Error("Invalid provider");
@@ -1040,7 +1047,7 @@ if ((typeof ngDevMode === "undefined" || ngDevMode) && true) {
1040
1047
  }
1041
1048
 
1042
1049
  // src/import/di/initializer_token.ts
1043
- var ENVIRONMENT_INITIALIZER = new InjectionToken(ngDevMode ? "ENVIRONMENT_INITIALIZER" : "");
1050
+ var ENVIRONMENT_INITIALIZER = new InjectionToken(typeof ngDevMode !== "undefined" && ngDevMode ? "ENVIRONMENT_INITIALIZER" : "");
1044
1051
 
1045
1052
  // src/import/di/interface/injector.ts
1046
1053
  var DecoratorFlags = /* @__PURE__ */ ((DecoratorFlags2) => {
@@ -1074,7 +1081,7 @@ function injectRootLimpMode(token, notFoundValue, flags) {
1074
1081
  }
1075
1082
  if (flags & 8 /* Optional */) return null;
1076
1083
  if (notFoundValue !== void 0) return notFoundValue;
1077
- throwProviderNotFoundError(token, "Injector");
1084
+ throwProviderNotFoundError(token, typeof ngDevMode !== "undefined" && ngDevMode ? "Injector" : "");
1078
1085
  }
1079
1086
 
1080
1087
  // src/primitives/di/src/injector.ts
@@ -1120,8 +1127,6 @@ var RetrievingInjector = class {
1120
1127
  }
1121
1128
  };
1122
1129
  var NG_TEMP_TOKEN_PATH = "ngTempTokenPath";
1123
- var NEW_LINE = /\n/gm;
1124
- var NO_NEW_LINE = "ɵ";
1125
1130
  var SOURCE = "__source";
1126
1131
  function injectInjectorOnly(token, flags = 0 /* Default */) {
1127
1132
  const currentInjector = getCurrentInjector();
@@ -1213,27 +1218,10 @@ function attachInjectFlag(decorator, flag) {
1213
1218
  function getInjectFlag(token) {
1214
1219
  return token[DI_DECORATOR_FLAG];
1215
1220
  }
1216
- function formatError(text, obj, injectorErrorName, source = null) {
1217
- text = text && text.charAt(0) === "\n" && text.charAt(1) == NO_NEW_LINE ? text.slice(2) : text;
1218
- let context = stringify(obj);
1219
- if (Array.isArray(obj)) {
1220
- context = obj.map(stringify).join(" -> ");
1221
- } else if (typeof obj === "object") {
1222
- const parts = [];
1223
- for (const key in obj) {
1224
- if (obj.hasOwnProperty(key)) {
1225
- const value = obj[key];
1226
- parts.push(key + ":" + (typeof value === "string" ? JSON.stringify(value) : stringify(value)));
1227
- }
1228
- }
1229
- context = `{${parts.join(", ")}}`;
1230
- }
1231
- return `${injectorErrorName}${source ? "(" + source + ")" : ""}[${context}]: ${text.replace(NEW_LINE, "\n ")}`;
1232
- }
1233
1221
 
1234
1222
  // src/import/di/injector_token.ts
1235
1223
  var INJECTOR = new InjectionToken(
1236
- ngDevMode ? "INJECTOR" : "",
1224
+ typeof ngDevMode !== "undefined" && ngDevMode ? "INJECTOR" : "",
1237
1225
  // Disable tslint because this is const enum which gets inlined not top level prop access.
1238
1226
  // tslint:disable-next-line: no-toplevel-property-access
1239
1227
  -1 /* Injector */
@@ -1241,7 +1229,7 @@ var INJECTOR = new InjectionToken(
1241
1229
  );
1242
1230
 
1243
1231
  // src/import/di/internal_tokens.ts
1244
- var INJECTOR_DEF_TYPES = new InjectionToken(ngDevMode ? "INJECTOR_DEF_TYPES" : "");
1232
+ var INJECTOR_DEF_TYPES = new InjectionToken(typeof ngDevMode !== "undefined" && ngDevMode ? "INJECTOR_DEF_TYPES" : "");
1245
1233
 
1246
1234
  // src/import/di/null_injector.ts
1247
1235
  var NullInjector = class {
@@ -1257,6 +1245,11 @@ var NullInjector = class {
1257
1245
  };
1258
1246
 
1259
1247
  // src/import/di/provider_collection.ts
1248
+ function makeEnvironmentProviders(providers) {
1249
+ return {
1250
+ ɵproviders: providers
1251
+ };
1252
+ }
1260
1253
  var USE_VALUE = getClosureSafeProperty({
1261
1254
  provide: String,
1262
1255
  useValue: getClosureSafeProperty
@@ -1275,7 +1268,7 @@ function isTypeProvider(value) {
1275
1268
  }
1276
1269
 
1277
1270
  // src/import/di/scope.ts
1278
- var INJECTOR_SCOPE = new InjectionToken(ngDevMode ? "Set Injector scope." : "");
1271
+ var INJECTOR_SCOPE = new InjectionToken(typeof ngDevMode !== "undefined" && ngDevMode ? "Set Injector scope." : "");
1279
1272
 
1280
1273
  // src/import/di/r3_injector.ts
1281
1274
  var NOT_YET = {};
@@ -1470,12 +1463,15 @@ var R3Injector = class extends EnvironmentInjector {
1470
1463
  }
1471
1464
  }
1472
1465
  toString() {
1473
- const tokens = [];
1474
- const records = this.records;
1475
- for (const token of records.keys()) {
1476
- tokens.push(stringify(token));
1466
+ if (ngDevMode) {
1467
+ const tokens = [];
1468
+ const records = this.records;
1469
+ for (const token of records.keys()) {
1470
+ tokens.push(stringify(token));
1471
+ }
1472
+ return `R3Injector[${tokens.join(", ")}]`;
1477
1473
  }
1478
- return `R3Injector[${tokens.join(", ")}]`;
1474
+ return "R3Injector[...]";
1479
1475
  }
1480
1476
  /**
1481
1477
  * Process a `SingleProvider` and add it.
@@ -1519,7 +1515,7 @@ var R3Injector = class extends EnvironmentInjector {
1519
1515
  hydrate(token, record, flags) {
1520
1516
  try {
1521
1517
  if (record.value === CIRCULAR) {
1522
- throw cyclicDependencyError(stringify(token));
1518
+ throw cyclicDependencyError(ngDevMode ? stringify(token) : "");
1523
1519
  } else if (record.value === NOT_YET) {
1524
1520
  record.value = CIRCULAR;
1525
1521
  if (ngDevMode) {
@@ -1564,17 +1560,17 @@ function injectableDefOrInjectorDefFactory(token) {
1564
1560
  return factory;
1565
1561
  }
1566
1562
  if (token instanceof InjectionToken) {
1567
- throw new RuntimeError(204 /* INVALID_INJECTION_TOKEN */, ngDevMode && `Token ${stringify(token)} is missing a ɵprov definition.`);
1563
+ throw new RuntimeError(-204 /* INVALID_INJECTION_TOKEN */, ngDevMode && `Token ${stringify(token)} is missing a ɵprov definition.`);
1568
1564
  }
1569
1565
  if (token instanceof Function) {
1570
1566
  return getUndecoratedInjectableFactory(token);
1571
1567
  }
1572
- throw new RuntimeError(204 /* INVALID_INJECTION_TOKEN */, ngDevMode && "unreachable");
1568
+ throw new RuntimeError(-204 /* INVALID_INJECTION_TOKEN */, ngDevMode && "unreachable");
1573
1569
  }
1574
1570
  function getUndecoratedInjectableFactory(token) {
1575
1571
  const paramLength = token.length;
1576
1572
  if (paramLength > 0) {
1577
- throw new RuntimeError(204 /* INVALID_INJECTION_TOKEN */, ngDevMode && `Can't resolve all parameters for ${stringify(token)}: (${newArray(paramLength, "?").join(", ")}).`);
1573
+ throw new RuntimeError(-204 /* INVALID_INJECTION_TOKEN */, ngDevMode && `Can't resolve all parameters for ${stringify(token)}: (${newArray(paramLength, "?").join(", ")}).`);
1578
1574
  }
1579
1575
  const inheritedInjectableDef = getInheritedInjectableDef(token);
1580
1576
  if (inheritedInjectableDef !== null) {
@@ -1622,7 +1618,7 @@ function providerToFactory(provider, ngModuleType, providers) {
1622
1618
  }
1623
1619
  function assertNotDestroyed(injector) {
1624
1620
  if (injector.destroyed) {
1625
- throw new RuntimeError(205 /* INJECTOR_ALREADY_DESTROYED */, ngDevMode && "Injector has already been destroyed.");
1621
+ throw new RuntimeError(-205 /* INJECTOR_ALREADY_DESTROYED */, ngDevMode && "Injector has already been destroyed.");
1626
1622
  }
1627
1623
  }
1628
1624
  function makeRecord(factory, value, multi = false) {
@@ -1713,8 +1709,19 @@ function createInjector(defType, parent = null, additionalProviders = null, name
1713
1709
  }
1714
1710
  function createInjectorWithoutInjectorInstances(defType, parent = null, additionalProviders = null, name, scopes = /* @__PURE__ */ new Set()) {
1715
1711
  const providers = [additionalProviders || EMPTY_ARRAY];
1716
- name = name || (typeof defType === "object" ? void 0 : stringify(defType));
1717
- return new R3Injector(providers, parent || getNullInjector(), name || null, scopes);
1712
+ let source = void 0;
1713
+ if (ngDevMode) {
1714
+ source = name || (typeof defType === "object" ? void 0 : stringify(defType));
1715
+ }
1716
+ return new R3Injector(providers, parent || getNullInjector(), source || null, scopes);
1717
+ }
1718
+
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);
1724
+ }
1718
1725
  }
1719
1726
 
1720
1727
  // src/import/di/injector.ts
@@ -1744,6 +1751,9 @@ var Injector = class _Injector {
1744
1751
  */
1745
1752
  static __NG_ELEMENT_ID__ = -1 /* Injector */;
1746
1753
  };
1754
+ if (typeof ngDevMode === "undefined" || ngDevMode) {
1755
+ registerSpecialProvider(Injector);
1756
+ }
1747
1757
 
1748
1758
  // src/import/render3/instructions/di.ts
1749
1759
  function ɵɵinvalidFactory() {
@@ -1755,13 +1765,17 @@ function ɵɵinvalidFactory() {
1755
1765
  function isSignal2(value) {
1756
1766
  return typeof value === "function" && value[SIGNAL] !== void 0;
1757
1767
  }
1768
+ function isWritableSignal(value) {
1769
+ return isSignal2(value) && typeof value.set === "function";
1770
+ }
1758
1771
 
1759
1772
  // src/import/render3/reactivity/computed.ts
1760
1773
  function computed(computation, options) {
1761
1774
  const getter = createComputed(computation, options?.equal);
1762
- if (ngDevMode) {
1763
- getter.toString = () => `[Computed: ${getter()}]`;
1764
- getter[SIGNAL].debugName = options?.debugName;
1775
+ if (typeof ngDevMode !== "undefined" && ngDevMode) {
1776
+ const debugName = options?.debugName;
1777
+ getter[SIGNAL].debugName = debugName;
1778
+ getter.toString = () => `[Computed${debugName ? " (" + debugName + ")" : ""}: ${getter()}]`;
1765
1779
  }
1766
1780
  return getter;
1767
1781
  }
@@ -1777,9 +1791,10 @@ function signal(initialValue, options) {
1777
1791
  signalFn.set = set;
1778
1792
  signalFn.update = update;
1779
1793
  signalFn.asReadonly = signalAsReadonlyFn.bind(signalFn);
1780
- if (ngDevMode) {
1781
- signalFn.toString = () => `[Signal: ${signalFn()}]`;
1782
- node.debugName = options?.debugName;
1794
+ if (typeof ngDevMode !== "undefined" && ngDevMode) {
1795
+ const debugName = options?.debugName;
1796
+ node.debugName = debugName;
1797
+ signalFn.toString = () => `[Signal${debugName ? " (" + debugName + ")" : ""}: ${signalFn()}]`;
1783
1798
  }
1784
1799
  return signalFn;
1785
1800
  }
@@ -1805,9 +1820,9 @@ function linkedSignal(optionsOrComputation, options) {
1805
1820
  }
1806
1821
  }
1807
1822
  function upgradeLinkedSignalGetter(getter, debugName) {
1808
- if (ngDevMode) {
1809
- getter.toString = () => `[LinkedSignal: ${getter()}]`;
1823
+ if (typeof ngDevMode !== "undefined" && ngDevMode) {
1810
1824
  getter[SIGNAL].debugName = debugName;
1825
+ getter.toString = () => `[LinkedSignal${debugName ? " (" + debugName + ")" : ""}: ${getter()}]`;
1811
1826
  }
1812
1827
  const node = getter[SIGNAL];
1813
1828
  const upgradedGetter = getter;
@@ -1833,6 +1848,28 @@ function assertNotInReactiveContext(debugFn, extraContext) {
1833
1848
  }
1834
1849
 
1835
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
+ }
1836
1873
  function isInInjectionContext() {
1837
1874
  return getInjectImplementation() !== void 0 || getCurrentInjector() != null;
1838
1875
  }
@@ -1857,9 +1894,8 @@ var DestroyRef = class {
1857
1894
  */
1858
1895
  static __NG_ENV_ID__ = (injector) => injector;
1859
1896
  };
1860
-
1861
- // src/import/util/noop.ts
1862
- function noop(...args) {
1897
+ if (typeof ngDevMode === "undefined" || ngDevMode) {
1898
+ registerSpecialProvider(DestroyRef);
1863
1899
  }
1864
1900
 
1865
1901
  // src/import/change_detection/scheduling/zoneless_scheduling.ts
@@ -1882,10 +1918,6 @@ var NotificationSource = /* @__PURE__ */ ((NotificationSource2) => {
1882
1918
  })(NotificationSource || {});
1883
1919
  var ChangeDetectionScheduler = class {
1884
1920
  };
1885
- var ZONELESS_ENABLED = new InjectionToken(typeof ngDevMode === "undefined" || ngDevMode ? "Zoneless enabled" : "", { providedIn: "root", factory: () => false });
1886
- var PROVIDED_ZONELESS = new InjectionToken(typeof ngDevMode === "undefined" || ngDevMode ? "Zoneless provided" : "", { providedIn: "root", factory: () => false });
1887
- var ZONELESS_SCHEDULER_DISABLED = new InjectionToken(typeof ngDevMode === "undefined" || ngDevMode ? "scheduler disabled" : "");
1888
- var SCHEDULE_IN_ROOT_ZONE = new InjectionToken(typeof ngDevMode === "undefined" || ngDevMode ? "run changes outside zone in root" : "");
1889
1921
 
1890
1922
  // src/import/render3/reactivity/root_effect_scheduler.ts
1891
1923
  var EffectScheduler = class _EffectScheduler {
@@ -1994,7 +2026,7 @@ function effect(effectFn, options) {
1994
2026
  node = createRootEffect(effectFn, injector.get(EffectScheduler), notifier);
1995
2027
  node.injector = injector;
1996
2028
  if (destroyRef !== null) {
1997
- node.onDestroyFn = destroyRef.onDestroy(() => node.destroy());
2029
+ node.onDestroyFns = [destroyRef.onDestroy(() => node.destroy())];
1998
2030
  }
1999
2031
  const effectRef = new EffectRefImpl(node);
2000
2032
  if (ngDevMode) {
@@ -2012,7 +2044,7 @@ var EFFECT_NODE = /* @__PURE__ */ (() => ({
2012
2044
  ...BASE_EFFECT_NODE,
2013
2045
  cleanupFns: void 0,
2014
2046
  zone: null,
2015
- onDestroyFn: noop,
2047
+ onDestroyFns: null,
2016
2048
  run() {
2017
2049
  if (ngDevMode && isInNotificationPhase()) {
2018
2050
  throw new Error(`Schedulers cannot synchronously execute watches while scheduling.`);
@@ -2045,7 +2077,11 @@ var ROOT_EFFECT_NODE = /* @__PURE__ */ (() => ({
2045
2077
  },
2046
2078
  destroy() {
2047
2079
  consumerDestroy(this);
2048
- this.onDestroyFn();
2080
+ if (this.onDestroyFns !== null) {
2081
+ for (const fn of this.onDestroyFns) {
2082
+ fn();
2083
+ }
2084
+ }
2049
2085
  this.cleanup();
2050
2086
  this.scheduler.remove(this);
2051
2087
  }
@@ -2066,6 +2102,10 @@ function createEffectFn(node, fn) {
2066
2102
  };
2067
2103
  }
2068
2104
 
2105
+ // src/import/util/noop.ts
2106
+ function noop(...args) {
2107
+ }
2108
+
2069
2109
  // src/import/util/callback_scheduler.ts
2070
2110
  function scheduleCallbackWithMicrotask(callback) {
2071
2111
  queueMicrotask(() => callback());
@@ -2096,43 +2136,119 @@ var ChangeDetectionSchedulerImpl = class {
2096
2136
  }
2097
2137
  };
2098
2138
 
2099
- // src/import/pending_tasks.ts
2100
- var import_rxjs = require("rxjs");
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
+ };
2101
2159
 
2102
- // src/import/error_handler.ts
2103
- var ErrorHandler = class {
2104
- /**
2105
- * @internal
2106
- */
2107
- _console = console;
2108
- handleError(error) {
2109
- this._console.error("ERROR", error);
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);
2110
2182
  }
2111
2183
  };
2112
- var INTERNAL_APPLICATION_ERROR_HANDLER = new InjectionToken(typeof ngDevMode === "undefined" || ngDevMode ? "internal error handler" : "", {
2113
- providedIn: "root",
2114
- factory: () => {
2115
- const injector = inject2(EnvironmentInjector);
2116
- let userErrorHandler;
2117
- return (e) => {
2118
- if (injector.destroyed && !userErrorHandler) {
2119
- setTimeout(() => {
2120
- throw e;
2121
- });
2122
- } else {
2123
- userErrorHandler ??= injector.get(ErrorHandler);
2124
- userErrorHandler.handleError(e);
2125
- }
2126
- };
2184
+
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
+ }
2192
+
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);
2127
2208
  }
2128
- });
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
+ });
2220
+ }
2221
+ return () => load().then((loadedToken) => injector.get(maybeUnwrapDefaultExport(loadedToken)));
2222
+ }
2223
+ function onIdle(options) {
2224
+ if (ngDevMode) {
2225
+ assertInInjectionContext(onIdle);
2226
+ }
2227
+ const idleService = inject2(IDLE_SERVICE);
2228
+ const { promise, resolve } = promiseWithResolvers();
2229
+ idleService.requestOnIdle(() => resolve(), options);
2230
+ return promise;
2231
+ }
2129
2232
 
2130
- // 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
2131
2246
  var PendingTasksInternal = class _PendingTasksInternal {
2132
2247
  taskId = 0;
2133
2248
  pendingTasks = /* @__PURE__ */ new Set();
2134
2249
  destroyed = false;
2135
2250
  pendingTask = new import_rxjs.BehaviorSubject(false);
2251
+ debugTaskTracker = inject2(DEBUG_TASK_TRACKER, { optional: true });
2136
2252
  get hasPendingTasks() {
2137
2253
  return this.destroyed ? false : this.pendingTask.value;
2138
2254
  }
@@ -2155,6 +2271,7 @@ var PendingTasksInternal = class _PendingTasksInternal {
2155
2271
  }
2156
2272
  const taskId = this.taskId++;
2157
2273
  this.pendingTasks.add(taskId);
2274
+ this.debugTaskTracker?.add(taskId);
2158
2275
  return taskId;
2159
2276
  }
2160
2277
  has(taskId) {
@@ -2162,6 +2279,7 @@ var PendingTasksInternal = class _PendingTasksInternal {
2162
2279
  }
2163
2280
  remove(taskId) {
2164
2281
  this.pendingTasks.delete(taskId);
2282
+ this.debugTaskTracker?.remove(taskId);
2165
2283
  if (this.pendingTasks.size === 0 && this.hasPendingTasks) {
2166
2284
  this.pendingTask.next(false);
2167
2285
  }
@@ -2184,6 +2302,232 @@ var PendingTasksInternal = class _PendingTasksInternal {
2184
2302
  })
2185
2303
  );
2186
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
2187
2531
  var PendingTasks = class _PendingTasks {
2188
2532
  internalPendingTasks = inject2(PendingTasksInternal);
2189
2533
  scheduler = inject2(ChangeDetectionScheduler);
@@ -2217,7 +2561,12 @@ var PendingTasks = class _PendingTasks {
2217
2561
  */
2218
2562
  run(fn) {
2219
2563
  const removeTask = this.add();
2220
- 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
+ }
2221
2570
  }
2222
2571
  /** @nocollapse */
2223
2572
  static ɵprov = (
@@ -2230,6 +2579,91 @@ var PendingTasks = class _PendingTasks {
2230
2579
  );
2231
2580
  };
2232
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
+
2233
2667
  // src/import/resource/resource.ts
2234
2668
  function resource(options) {
2235
2669
  if (ngDevMode && !options?.injector) {
@@ -2237,21 +2671,30 @@ function resource(options) {
2237
2671
  }
2238
2672
  const oldNameForParams = options.request;
2239
2673
  const params = options.params ?? oldNameForParams ?? (() => null);
2240
- 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
+ );
2241
2683
  }
2242
2684
  var BaseWritableResource = class {
2243
2685
  value;
2244
- constructor(value) {
2686
+ isLoading;
2687
+ constructor(value, debugName) {
2245
2688
  this.value = value;
2246
2689
  this.value.set = this.set.bind(this);
2247
2690
  this.value.update = this.update.bind(this);
2248
2691
  this.value.asReadonly = signalAsReadonlyFn;
2692
+ this.isLoading = computed(() => this.status() === "loading" || this.status() === "reloading", ngDevMode ? createDebugNameObject(debugName, "isLoading") : void 0);
2249
2693
  }
2250
2694
  isError = computed(() => this.status() === "error");
2251
2695
  update(updateFn) {
2252
2696
  this.set(updateFn(untracked2(this.value)));
2253
2697
  }
2254
- isLoading = computed(() => this.status() === "loading" || this.status() === "reloading");
2255
2698
  // Use a computed here to avoid triggering reactive consumers if the value changes while staying
2256
2699
  // either defined or undefined.
2257
2700
  isValueDefined = computed(() => {
@@ -2260,6 +2703,17 @@ var BaseWritableResource = class {
2260
2703
  }
2261
2704
  return this.value() !== void 0;
2262
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
+ }
2263
2717
  hasValue() {
2264
2718
  return this.isValueDefined();
2265
2719
  }
@@ -2268,7 +2722,10 @@ var BaseWritableResource = class {
2268
2722
  }
2269
2723
  };
2270
2724
  var ResourceImpl = class extends BaseWritableResource {
2271
- constructor(request, loaderFn, defaultValue, equal, injector) {
2725
+ constructor(request, loaderFn, defaultValue, equal, debugName, injector, transferCacheKey, getInitialStream) {
2726
+ if (isInParamsFunction()) {
2727
+ throw invalidResourceCreationInParams();
2728
+ }
2272
2729
  super(
2273
2730
  // Feed a computed signal for the value to `BaseWritableResource`, which will upgrade it to a
2274
2731
  // `WritableSignal` that delegates to `ResourceImpl.set`.
@@ -2286,45 +2743,91 @@ var ResourceImpl = class extends BaseWritableResource {
2286
2743
  }
2287
2744
  return streamValue.value;
2288
2745
  },
2289
- { equal }
2290
- )
2746
+ { equal, ...ngDevMode ? createDebugNameObject(debugName, "value") : void 0 }
2747
+ ),
2748
+ debugName
2291
2749
  );
2292
2750
  this.loaderFn = loaderFn;
2293
2751
  this.equal = equal;
2294
- this.extRequest = linkedSignal({
2295
- source: request,
2296
- computation: (request2) => ({ request: request2, reload: 0 })
2297
- });
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
+ );
2298
2775
  this.state = linkedSignal({
2299
2776
  // Whenever the request changes,
2300
2777
  source: this.extRequest,
2301
2778
  // Compute the state of the resource given a change in status.
2302
2779
  computation: (extRequest, previous) => {
2303
- const status = extRequest.request === void 0 ? "idle" : "loading";
2304
- if (!previous) {
2305
- return {
2306
- extRequest,
2307
- status,
2308
- previousStatus: "idle",
2309
- stream: void 0
2310
- };
2311
- } else {
2312
- return {
2313
- extRequest,
2314
- status,
2315
- previousStatus: projectStatusOfState(previous.value),
2316
- // If the request hasn't changed, keep the previous stream.
2317
- stream: previous.value.extRequest.request === extRequest.request ? previous.value.stream : void 0
2318
- };
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
+ }
2319
2806
  }
2320
- }
2807
+ return {
2808
+ extRequest,
2809
+ status,
2810
+ previousStatus: previous ? projectStatusOfState(previous.value) : "idle",
2811
+ stream
2812
+ };
2813
+ },
2814
+ ...ngDevMode ? createDebugNameObject(debugName, "state") : void 0
2321
2815
  });
2322
2816
  this.effectRef = effect(this.loadEffect.bind(this), {
2323
2817
  injector,
2324
- manualCleanup: true
2818
+ manualCleanup: true,
2819
+ ...ngDevMode ? createDebugNameObject(debugName, "loadEffect") : void 0
2325
2820
  });
2326
2821
  this.pendingTasks = injector.get(PendingTasks);
2327
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
+ );
2328
2831
  }
2329
2832
  pendingTasks;
2330
2833
  /**
@@ -2341,11 +2844,9 @@ var ResourceImpl = class extends BaseWritableResource {
2341
2844
  resolvePendingTask = void 0;
2342
2845
  destroyed = false;
2343
2846
  unregisterOnDestroy;
2344
- status = computed(() => projectStatusOfState(this.state()));
2345
- error = computed(() => {
2346
- const stream = this.state().stream?.();
2347
- return stream && !isResolved(stream) ? stream.error : void 0;
2348
- });
2847
+ status;
2848
+ error;
2849
+ transferState;
2349
2850
  /**
2350
2851
  * Called either directly via `WritableResource.set` or via `.value.set()`.
2351
2852
  */
@@ -2365,7 +2866,7 @@ var ResourceImpl = class extends BaseWritableResource {
2365
2866
  extRequest: state.extRequest,
2366
2867
  status: "local",
2367
2868
  previousStatus: "local",
2368
- stream: signal({ value })
2869
+ stream: signal({ value }, ngDevMode ? createDebugNameObject(this.debugName, "stream") : void 0)
2369
2870
  });
2370
2871
  this.abortInProgressLoad();
2371
2872
  }
@@ -2401,27 +2902,48 @@ var ResourceImpl = class extends BaseWritableResource {
2401
2902
  let resolvePendingTask = this.resolvePendingTask = this.pendingTasks.add();
2402
2903
  const { signal: abortSignal } = this.pendingController = new AbortController();
2403
2904
  try {
2404
- const stream = await untracked2(
2905
+ const stream = untracked2(
2405
2906
  () => this.loaderFn({
2406
2907
  params: extRequest.request,
2407
- // TODO(alxhub): cleanup after g3 removal of `request` alias.
2408
- request: extRequest.request,
2409
2908
  abortSignal,
2410
2909
  previous: {
2411
2910
  status: previousStatus
2412
2911
  }
2413
2912
  })
2414
2913
  );
2415
- if (abortSignal.aborted || untracked2(this.extRequest) !== extRequest) {
2416
- 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
+ }
2417
2944
  }
2418
- this.state.set({
2419
- extRequest,
2420
- status: "resolved",
2421
- previousStatus: "resolved",
2422
- stream
2423
- });
2424
2945
  } catch (err) {
2946
+ rethrowFatalErrors(err);
2425
2947
  if (abortSignal.aborted || untracked2(this.extRequest) !== extRequest) {
2426
2948
  return;
2427
2949
  }
@@ -2429,7 +2951,7 @@ var ResourceImpl = class extends BaseWritableResource {
2429
2951
  extRequest,
2430
2952
  status: "resolved",
2431
2953
  previousStatus: "error",
2432
- stream: signal({ error: encapsulateResourceError(err) })
2954
+ stream: signal({ error: encapsulateResourceError(err) }, ngDevMode ? createDebugNameObject(this.debugName, "stream") : void 0)
2433
2955
  });
2434
2956
  } finally {
2435
2957
  resolvePendingTask?.();
@@ -2443,6 +2965,11 @@ var ResourceImpl = class extends BaseWritableResource {
2443
2965
  this.resolvePendingTask = void 0;
2444
2966
  }
2445
2967
  };
2968
+ function saveToTransferState(result, transferCacheKey, transferState) {
2969
+ if (transferCacheKey && transferState && result && isResolved(result)) {
2970
+ transferState.set(transferCacheKey, result.value);
2971
+ }
2972
+ }
2446
2973
  function wrapEqualityFn(equal) {
2447
2974
  return (a, b) => a === void 0 || b === void 0 ? a === b : equal(a, b);
2448
2975
  }
@@ -2452,9 +2979,9 @@ function getLoader(options) {
2452
2979
  }
2453
2980
  return async (params) => {
2454
2981
  try {
2455
- return signal({ value: await options.loader(params) });
2982
+ return signal({ value: await options.loader(params) }, ngDevMode ? createDebugNameObject(options.debugName, "stream") : void 0);
2456
2983
  } catch (err) {
2457
- return signal({ error: encapsulateResourceError(err) });
2984
+ return signal({ error: encapsulateResourceError(err) }, ngDevMode ? createDebugNameObject(options.debugName, "stream") : void 0);
2458
2985
  }
2459
2986
  };
2460
2987
  }
@@ -2474,12 +3001,20 @@ function projectStatusOfState(state) {
2474
3001
  function isResolved(state) {
2475
3002
  return state.error === void 0;
2476
3003
  }
3004
+ function createDebugNameObject(resourceDebugName, internalSignalDebugName) {
3005
+ return {
3006
+ debugName: `Resource${resourceDebugName ? "#" + resourceDebugName : ""}.${internalSignalDebugName}`
3007
+ };
3008
+ }
2477
3009
  function encapsulateResourceError(error) {
2478
- if (error instanceof Error) {
3010
+ if (isErrorLike(error)) {
2479
3011
  return error;
2480
3012
  }
2481
3013
  return new ResourceWrappedError(error);
2482
3014
  }
3015
+ function isErrorLike(error) {
3016
+ return error instanceof Error || typeof error === "object" && typeof error.name === "string" && typeof error.message === "string";
3017
+ }
2483
3018
  var ResourceValueError = class extends Error {
2484
3019
  constructor(error) {
2485
3020
  super(ngDevMode ? `Resource is currently in an error state (see Error.cause for details): ${error.message}` : error.message, { cause: error });
@@ -2490,6 +3025,146 @@ var ResourceWrappedError = class extends Error {
2490
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 });
2491
3026
  }
2492
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();
3082
+ }
3083
+ };
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;
2493
3168
 
2494
3169
  // src/import/index.ts
2495
3170
  function Injectable(args) {
@@ -2523,6 +3198,7 @@ function createRootInjector(options) {
2523
3198
  }
2524
3199
  // Annotate the CommonJS export names for ESM import in node:
2525
3200
  0 && (module.exports = {
3201
+ APP_ID,
2526
3202
  ChangeDetectionScheduler,
2527
3203
  ChangeDetectionSchedulerImpl,
2528
3204
  DecoratorFlags,
@@ -2530,6 +3206,7 @@ function createRootInjector(options) {
2530
3206
  EffectScheduler,
2531
3207
  EnvironmentInjector,
2532
3208
  ErrorHandler,
3209
+ EventEmitter,
2533
3210
  INJECTOR_SCOPE,
2534
3211
  INTERNAL_APPLICATION_ERROR_HANDLER,
2535
3212
  Inject,
@@ -2543,20 +3220,20 @@ function createRootInjector(options) {
2543
3220
  NotificationSource,
2544
3221
  NullInjector,
2545
3222
  Optional,
2546
- PROVIDED_ZONELESS,
2547
3223
  PendingTasks,
2548
- PendingTasksInternal,
2549
3224
  R3Injector,
3225
+ ResourceDependencyError,
3226
+ ResourceParamsStatus,
2550
3227
  RetrievingInjector,
2551
3228
  RootStaticInjectOptions,
2552
- SCHEDULE_IN_ROOT_ZONE,
2553
3229
  SOURCE,
2554
3230
  Self,
2555
3231
  SkipSelf,
2556
3232
  StaticInjectOptions,
2557
3233
  THROW_IF_NOT_FOUND,
2558
- ZONELESS_ENABLED,
2559
- ZONELESS_SCHEDULER_DISABLED,
3234
+ TransferState,
3235
+ Type,
3236
+ assertInInjectionContext,
2560
3237
  assertNotDestroyed,
2561
3238
  assertNotInReactiveContext,
2562
3239
  attachInjectFlag,
@@ -2564,8 +3241,9 @@ function createRootInjector(options) {
2564
3241
  convertToBitFlags,
2565
3242
  createInjector,
2566
3243
  createRootInjector,
3244
+ debounced,
2567
3245
  effect,
2568
- formatError,
3246
+ forwardRef,
2569
3247
  getCurrentInjector,
2570
3248
  getInheritedInjectableDef,
2571
3249
  getInjectFlag,
@@ -2574,12 +3252,20 @@ function createRootInjector(options) {
2574
3252
  getNullInjector,
2575
3253
  inject,
2576
3254
  injectArgs,
3255
+ injectAsync,
2577
3256
  injectInjectorOnly,
2578
3257
  isInjectable,
2579
3258
  isSignal,
3259
+ isWritableSignal,
2580
3260
  linkedSignal,
3261
+ makeStateKey,
3262
+ onIdle,
3263
+ provideIdleServiceWith,
2581
3264
  providerToFactory,
3265
+ resolveForwardRef,
2582
3266
  resource,
3267
+ resourceFromSnapshots,
3268
+ runInInjectionContext,
2583
3269
  setCurrentInjector,
2584
3270
  signal,
2585
3271
  untracked,
@@ -2599,11 +3285,4 @@ function createRootInjector(options) {
2599
3285
  * Use of this source code is governed by an MIT-style license that can be
2600
3286
  * found in the LICENSE file at https://angular.dev/license
2601
3287
  */
2602
- /**
2603
- * @license
2604
- * Copyright Google LLC All Rights Reserved.
2605
- *
2606
- * Use of this source code is governed by an MIT-style license that can be
2607
- * found in the LICENSE file at https://angular.io/license
2608
- */
2609
3288
  //# sourceMappingURL=index.js.map