static-injector 6.0.3 → 6.1.1

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 (42) hide show
  1. package/import/change_detection/scheduling/zoneless_scheduling.d.ts +1 -1
  2. package/import/core_reactivity_export_internal.d.ts +3 -4
  3. package/import/di/forward_ref.d.ts +9 -7
  4. package/import/di/inject_switch.d.ts +4 -4
  5. package/import/di/injector.d.ts +12 -17
  6. package/import/di/injector_compatibility.d.ts +24 -18
  7. package/import/di/interface/injector.d.ts +13 -17
  8. package/import/di/metadata.d.ts +7 -0
  9. package/import/di/provider_collection.d.ts +2 -42
  10. package/import/di/r3_injector.d.ts +10 -11
  11. package/import/error_handler.d.ts +5 -0
  12. package/import/errors.d.ts +11 -1
  13. package/import/index.d.ts +4 -0
  14. package/import/linker/destroy_ref.d.ts +2 -0
  15. package/import/pending_tasks.d.ts +15 -16
  16. package/import/render3/errors_di.d.ts +2 -0
  17. package/import/render3/reactivity/api.d.ts +5 -1
  18. package/import/render3/reactivity/asserts.d.ts +1 -1
  19. package/import/render3/reactivity/effect.d.ts +10 -22
  20. package/import/render3/reactivity/linked_signal.d.ts +3 -3
  21. package/import/render3/reactivity/root_effect_scheduler.d.ts +4 -1
  22. package/import/render3/reactivity/signal.d.ts +3 -1
  23. package/import/resource/api.d.ts +35 -50
  24. package/import/resource/resource.d.ts +9 -7
  25. package/index.js +466 -623
  26. package/index.js.map +4 -4
  27. package/index.mjs +459 -619
  28. package/index.mjs.map +4 -4
  29. package/package.json +2 -2
  30. package/primitives/di/index.d.ts +12 -0
  31. package/primitives/di/src/injection_token.d.ts +63 -0
  32. package/primitives/di/src/injector.d.ts +14 -0
  33. package/primitives/di/src/not_found.d.ts +28 -0
  34. package/primitives/di/src/type.d.ts +61 -0
  35. package/primitives/signals/index.d.ts +5 -4
  36. package/primitives/signals/src/computed.d.ts +1 -1
  37. package/primitives/signals/src/graph.d.ts +3 -0
  38. package/primitives/signals/src/linked_signal.d.ts +2 -29
  39. package/primitives/signals/src/signal.d.ts +8 -6
  40. package/{import/render3/reactivity/patch.d.ts → primitives/signals/src/untracked.d.ts} +3 -2
  41. package/readme.md +1 -1
  42. package/import/render3/reactivity/microtask_effect.d.ts +0 -21
package/index.js CHANGED
@@ -23,10 +23,13 @@ __export(import_exports, {
23
23
  ChangeDetectionScheduler: () => ChangeDetectionScheduler,
24
24
  ChangeDetectionSchedulerImpl: () => ChangeDetectionSchedulerImpl,
25
25
  DecoratorFlags: () => DecoratorFlags,
26
+ DestroyRef: () => DestroyRef,
26
27
  EnvironmentInjector: () => EnvironmentInjector,
28
+ ErrorHandler: () => ErrorHandler,
27
29
  INJECTOR_SCOPE: () => INJECTOR_SCOPE,
30
+ INTERNAL_APPLICATION_ERROR_HANDLER: () => INTERNAL_APPLICATION_ERROR_HANDLER,
28
31
  Inject: () => Inject,
29
- InjectFlags: () => InjectFlags,
32
+ Injectable: () => Injectable,
30
33
  InjectionToken: () => InjectionToken,
31
34
  Injector: () => Injector,
32
35
  InternalInjectFlags: () => InternalInjectFlags,
@@ -37,8 +40,10 @@ __export(import_exports, {
37
40
  NullInjector: () => NullInjector,
38
41
  Optional: () => Optional,
39
42
  PROVIDED_ZONELESS: () => PROVIDED_ZONELESS,
43
+ PendingTasks: () => PendingTasks,
44
+ PendingTasksInternal: () => PendingTasksInternal,
40
45
  R3Injector: () => R3Injector,
41
- ResourceStatus: () => ResourceStatus,
46
+ RetrievingInjector: () => RetrievingInjector,
42
47
  RootStaticInjectOptions: () => RootStaticInjectOptions,
43
48
  SCHEDULE_IN_ROOT_ZONE: () => SCHEDULE_IN_ROOT_ZONE,
44
49
  SOURCE: () => SOURCE,
@@ -56,7 +61,7 @@ __export(import_exports, {
56
61
  convertToBitFlags: () => convertToBitFlags,
57
62
  createInjector: () => createInjector2,
58
63
  createRootInjector: () => createRootInjector,
59
- effect: () => effect2,
64
+ effect: () => effect,
60
65
  formatError: () => formatError,
61
66
  getCurrentInjector: () => getCurrentInjector,
62
67
  getInheritedInjectableDef: () => getInheritedInjectableDef,
@@ -74,11 +79,9 @@ __export(import_exports, {
74
79
  resource: () => resource,
75
80
  setCurrentInjector: () => setCurrentInjector,
76
81
  signal: () => signal,
77
- untracked: () => untracked,
82
+ untracked: () => untracked2,
78
83
  ɵEffectScheduler: () => EffectScheduler,
79
- ɵMicrotaskEffectScheduler: () => MicrotaskEffectScheduler,
80
84
  ɵSIGNAL: () => SIGNAL,
81
- ɵmicrotaskEffect: () => microtaskEffect,
82
85
  ɵunwrapWritableSignal: () => ɵunwrapWritableSignal,
83
86
  ɵɵdefineInjectable: () => ɵɵdefineInjectable,
84
87
  ɵɵdefineInjector: () => ɵɵdefineInjector,
@@ -100,8 +103,11 @@ var RuntimeError = class extends Error {
100
103
  this.code = code;
101
104
  }
102
105
  };
106
+ function formatRuntimeErrorCode(code) {
107
+ return `NG0${Math.abs(code)}`;
108
+ }
103
109
  function formatRuntimeError(code, message) {
104
- const fullCode = `NG0${Math.abs(code)}`;
110
+ const fullCode = formatRuntimeErrorCode(code);
105
111
  const errorMessage = `${fullCode}${message ? ": " + message : ""}`;
106
112
  if (false) {
107
113
  }
@@ -113,6 +119,15 @@ function getFactoryDef(type, throwNotFound) {
113
119
  return () => new type();
114
120
  }
115
121
 
122
+ // src/import/render3/errors_di.ts
123
+ function throwCyclicDependencyError(token, path) {
124
+ throw new RuntimeError(-200 /* CYCLIC_DI_DEPENDENCY */, token);
125
+ }
126
+ function throwProviderNotFoundError(token, injectorName) {
127
+ const errorMessage = void 0;
128
+ throw new RuntimeError(-201 /* PROVIDER_NOT_FOUND */, errorMessage);
129
+ }
130
+
116
131
  // src/import/util/property.ts
117
132
  function getClosureSafeProperty(objWithPropertyToExtract) {
118
133
  for (const key in objWithPropertyToExtract) {
@@ -120,16 +135,12 @@ function getClosureSafeProperty(objWithPropertyToExtract) {
120
135
  return key;
121
136
  }
122
137
  }
123
- throw Error("Could not find renamed property on target object.");
138
+ throw Error("");
124
139
  }
125
140
 
126
141
  // src/import/render3/fields.ts
127
- var NG_FACTORY_DEF = getClosureSafeProperty({
128
- ɵfac: getClosureSafeProperty
129
- });
130
- var NG_ENV_ID = getClosureSafeProperty({
131
- __NG_ENV_ID__: getClosureSafeProperty
132
- });
142
+ var NG_FACTORY_DEF = getClosureSafeProperty({ ɵfac: getClosureSafeProperty });
143
+ var NG_ENV_ID = getClosureSafeProperty({ __NG_ENV_ID__: getClosureSafeProperty });
133
144
 
134
145
  // src/import/util/empty.ts
135
146
  var EMPTY_ARRAY = [];
@@ -160,9 +171,7 @@ function stringify(token) {
160
171
  }
161
172
 
162
173
  // src/import/di/forward_ref.ts
163
- var __forward_ref__ = getClosureSafeProperty({
164
- __forward_ref__: getClosureSafeProperty
165
- });
174
+ var __forward_ref__ = getClosureSafeProperty({ __forward_ref__: getClosureSafeProperty });
166
175
  function forwardRef(forwardRefFn) {
167
176
  forwardRefFn.__forward_ref__ = forwardRef;
168
177
  forwardRefFn.toString = function() {
@@ -190,20 +199,16 @@ function ɵɵdefineInjector(options) {
190
199
  return { providers: options.providers || [], imports: options.imports || [] };
191
200
  }
192
201
  function getInjectableDef(type) {
193
- return getOwnDefinition(type, NG_PROV_DEF) || {
194
- token: type,
195
- factory: () => new type(),
196
- ...type.injectOptions
197
- };
202
+ return getOwnDefinition(type, NG_PROV_DEF) || { token: type, factory: () => new type(), ...type.injectOptions };
198
203
  }
199
204
  function isInjectable(type) {
200
205
  return getInjectableDef(type) !== null;
201
206
  }
202
207
  function getOwnDefinition(type, field) {
203
- return type.hasOwnProperty(field) ? type[field] : null;
208
+ return type.hasOwnProperty(field) && type[field] || null;
204
209
  }
205
210
  function getInheritedInjectableDef(type) {
206
- const def = type && (type[NG_PROV_DEF] || null);
211
+ const def = type?.[NG_PROV_DEF] ?? null;
207
212
  if (def) {
208
213
  return def;
209
214
  } else {
@@ -211,14 +216,10 @@ function getInheritedInjectableDef(type) {
211
216
  }
212
217
  }
213
218
  function getInjectorDef(type) {
214
- return type && (type.hasOwnProperty(NG_INJ_DEF) || false) ? type[NG_INJ_DEF] : null;
219
+ return type && type.hasOwnProperty(NG_INJ_DEF) ? type[NG_INJ_DEF] : null;
215
220
  }
216
- var NG_PROV_DEF = getClosureSafeProperty({
217
- ɵprov: getClosureSafeProperty
218
- });
219
- var NG_INJ_DEF = getClosureSafeProperty({
220
- ɵinj: getClosureSafeProperty
221
- });
221
+ var NG_PROV_DEF = getClosureSafeProperty({ ɵprov: getClosureSafeProperty });
222
+ var NG_INJ_DEF = getClosureSafeProperty({ ɵinj: getClosureSafeProperty });
222
223
 
223
224
  // src/import/di/injection_token.ts
224
225
  var InjectionToken = class {
@@ -257,29 +258,18 @@ var InjectionToken = class {
257
258
  // src/import/di/initializer_token.ts
258
259
  var ENVIRONMENT_INITIALIZER = new InjectionToken("");
259
260
 
260
- // src/import/render3/errors_di.ts
261
- function throwProviderNotFoundError(token, injectorName) {
262
- const errorMessage = null;
263
- throw new RuntimeError(-201 /* PROVIDER_NOT_FOUND */, errorMessage);
264
- }
265
-
266
261
  // src/import/di/interface/injector.ts
267
262
  var DecoratorFlags = /* @__PURE__ */ ((DecoratorFlags2) => {
268
263
  DecoratorFlags2[DecoratorFlags2["Inject"] = -1] = "Inject";
269
264
  return DecoratorFlags2;
270
265
  })(DecoratorFlags || {});
271
- var InjectFlags = /* @__PURE__ */ ((InjectFlags2) => {
272
- InjectFlags2[InjectFlags2["Default"] = 0] = "Default";
273
- InjectFlags2[InjectFlags2["Self"] = 2] = "Self";
274
- InjectFlags2[InjectFlags2["SkipSelf"] = 4] = "SkipSelf";
275
- InjectFlags2[InjectFlags2["Optional"] = 8] = "Optional";
276
- return InjectFlags2;
277
- })(InjectFlags || {});
278
266
  var InternalInjectFlags = /* @__PURE__ */ ((InternalInjectFlags2) => {
279
267
  InternalInjectFlags2[InternalInjectFlags2["Default"] = 0] = "Default";
268
+ InternalInjectFlags2[InternalInjectFlags2["Host"] = 1] = "Host";
280
269
  InternalInjectFlags2[InternalInjectFlags2["Self"] = 2] = "Self";
281
270
  InternalInjectFlags2[InternalInjectFlags2["SkipSelf"] = 4] = "SkipSelf";
282
271
  InternalInjectFlags2[InternalInjectFlags2["Optional"] = 8] = "Optional";
272
+ InternalInjectFlags2[InternalInjectFlags2["ForPipe"] = 16] = "ForPipe";
283
273
  return InternalInjectFlags2;
284
274
  })(InternalInjectFlags || {});
285
275
 
@@ -303,15 +293,7 @@ function injectRootLimpMode(token, notFoundValue, flags) {
303
293
  throwProviderNotFoundError(token, "Injector");
304
294
  }
305
295
 
306
- // src/import/di/injector_compatibility.ts
307
- var _THROW_IF_NOT_FOUND = {};
308
- var THROW_IF_NOT_FOUND = _THROW_IF_NOT_FOUND;
309
- var DI_DECORATOR_FLAG = "__NG_DI_FLAG__";
310
- var NG_TEMP_TOKEN_PATH = "ngTempTokenPath";
311
- var NG_TOKEN_PATH = "ngTokenPath";
312
- var NEW_LINE = /\n/gm;
313
- var NO_NEW_LINE = "ɵ";
314
- var SOURCE = "__source";
296
+ // src/primitives/di/src/injector.ts
315
297
  var _currentInjector = void 0;
316
298
  function getCurrentInjector() {
317
299
  return _currentInjector;
@@ -321,31 +303,75 @@ function setCurrentInjector(injector) {
321
303
  _currentInjector = injector;
322
304
  return former;
323
305
  }
306
+
307
+ // src/primitives/di/src/not_found.ts
308
+ var NOT_FOUND = Symbol("NotFound");
309
+ var NotFoundError = class extends Error {
310
+ name = "ɵNotFound";
311
+ constructor(message) {
312
+ super(message);
313
+ }
314
+ };
315
+ function isNotFound(e) {
316
+ return e === NOT_FOUND || e?.name === "ɵNotFound";
317
+ }
318
+
319
+ // src/import/di/injector_compatibility.ts
320
+ var _THROW_IF_NOT_FOUND = {};
321
+ var THROW_IF_NOT_FOUND = _THROW_IF_NOT_FOUND;
322
+ var DI_DECORATOR_FLAG = "__NG_DI_FLAG__";
323
+ var RetrievingInjector = class {
324
+ constructor(injector) {
325
+ this.injector = injector;
326
+ }
327
+ retrieve(token, options) {
328
+ const flags = convertToBitFlags(options) || 0 /* Default */;
329
+ try {
330
+ return this.injector.get(
331
+ token,
332
+ // When a dependency is requested with an optional flag, DI returns null as the default value.
333
+ flags & 8 /* Optional */ ? null : THROW_IF_NOT_FOUND,
334
+ flags
335
+ );
336
+ } catch (e) {
337
+ if (isNotFound(e)) {
338
+ return e;
339
+ }
340
+ throw e;
341
+ }
342
+ }
343
+ };
344
+ var NG_TEMP_TOKEN_PATH = "ngTempTokenPath";
345
+ var NG_TOKEN_PATH = "ngTokenPath";
346
+ var NEW_LINE = /\n/gm;
347
+ var NO_NEW_LINE = "ɵ";
348
+ var SOURCE = "__source";
324
349
  function injectInjectorOnly(token, flags = 0 /* Default */) {
325
- if (_currentInjector === void 0) {
326
- throw new RuntimeError(-203 /* MISSING_INJECTION_CONTEXT */, null);
327
- } else if (_currentInjector === null) {
350
+ const currentInjector = getCurrentInjector();
351
+ if (currentInjector === void 0) {
352
+ throw new RuntimeError(-203 /* MISSING_INJECTION_CONTEXT */, void 0);
353
+ } else if (currentInjector === null) {
328
354
  return injectRootLimpMode(token, void 0, flags);
329
355
  } else {
330
- const value = _currentInjector.get(
331
- token,
332
- flags & 8 /* Optional */ ? null : void 0,
333
- flags
334
- );
356
+ const options = convertToInjectOptions(flags);
357
+ const value = currentInjector.retrieve(token, options);
358
+ if (isNotFound(value)) {
359
+ if (options.optional) {
360
+ return null;
361
+ }
362
+ throw value;
363
+ }
335
364
  return value;
336
365
  }
337
366
  }
338
367
  function ɵɵinject(token, flags = 0 /* Default */) {
339
- return (getInjectImplementation() || injectInjectorOnly)(
340
- resolveForwardRef(token),
341
- flags
342
- );
368
+ return (getInjectImplementation() || injectInjectorOnly)(resolveForwardRef(token), flags);
343
369
  }
344
370
  function ɵɵinvalidFactoryDep(index) {
345
- throw new RuntimeError(202 /* INVALID_FACTORY_DEPENDENCY */, null);
371
+ throw new RuntimeError(202 /* INVALID_FACTORY_DEPENDENCY */, void 0);
346
372
  }
347
- function inject(token, flags = 0 /* Default */) {
348
- return ɵɵinject(token, convertToBitFlags(flags));
373
+ function inject(token, options) {
374
+ return ɵɵinject(token, convertToBitFlags(options));
349
375
  }
350
376
  function convertToBitFlags(flags) {
351
377
  if (typeof flags === "undefined" || typeof flags === "number") {
@@ -354,13 +380,21 @@ function convertToBitFlags(flags) {
354
380
  return 0 /* Default */ | // comment to force a line break in the formatter
355
381
  (flags.optional && 8 /* Optional */) | 0 | (flags.self && 2 /* Self */) | (flags.skipSelf && 4 /* SkipSelf */);
356
382
  }
383
+ function convertToInjectOptions(flags) {
384
+ return {
385
+ optional: !!(flags & 8 /* Optional */),
386
+ host: !!(flags & 1 /* Host */),
387
+ self: !!(flags & 2 /* Self */),
388
+ skipSelf: !!(flags & 4 /* SkipSelf */)
389
+ };
390
+ }
357
391
  function injectArgs(types) {
358
392
  const args = [];
359
393
  for (let i = 0; i < types.length; i++) {
360
394
  const arg = resolveForwardRef(types[i]);
361
395
  if (Array.isArray(arg)) {
362
396
  if (arg.length === 0) {
363
- throw new RuntimeError(900 /* INVALID_DIFFER_INPUT */, null);
397
+ throw new RuntimeError(900 /* INVALID_DIFFER_INPUT */, void 0);
364
398
  }
365
399
  let type = void 0;
366
400
  let flags = 0 /* Default */;
@@ -397,12 +431,7 @@ function catchInjectorError(e, token, injectorErrorName, source) {
397
431
  if (token[SOURCE]) {
398
432
  tokenPath.unshift(token[SOURCE]);
399
433
  }
400
- e.message = formatError(
401
- "\n" + e.message,
402
- tokenPath,
403
- injectorErrorName,
404
- source
405
- );
434
+ e.message = formatError("\n" + e.message, tokenPath, injectorErrorName, source);
406
435
  e[NG_TOKEN_PATH] = tokenPath;
407
436
  e[NG_TEMP_TOKEN_PATH] = null;
408
437
  throw e;
@@ -417,17 +446,12 @@ function formatError(text, obj, injectorErrorName, source = null) {
417
446
  for (const key in obj) {
418
447
  if (obj.hasOwnProperty(key)) {
419
448
  const value = obj[key];
420
- parts.push(
421
- key + ":" + (typeof value === "string" ? JSON.stringify(value) : stringify(value))
422
- );
449
+ parts.push(key + ":" + (typeof value === "string" ? JSON.stringify(value) : stringify(value)));
423
450
  }
424
451
  }
425
452
  context = `{${parts.join(", ")}}`;
426
453
  }
427
- return `${injectorErrorName}${source ? "(" + source + ")" : ""}[${context}]: ${text.replace(
428
- NEW_LINE,
429
- "\n "
430
- )}`;
454
+ return `${injectorErrorName}${source ? "(" + source + ")" : ""}[${context}]: ${text.replace(NEW_LINE, "\n ")}`;
431
455
  }
432
456
 
433
457
  // src/import/di/injector_token.ts
@@ -446,10 +470,7 @@ var INJECTOR_DEF_TYPES = new InjectionToken("");
446
470
  var NullInjector = class {
447
471
  get(token, notFoundValue = THROW_IF_NOT_FOUND) {
448
472
  if (notFoundValue === THROW_IF_NOT_FOUND) {
449
- const error = new Error(
450
- `NullInjectorError: No provider for ${stringify(token)}!`
451
- );
452
- error.name = "NullInjectorError";
473
+ const error = new NotFoundError(`NullInjectorError: No provider for ${stringify(token)}!`);
453
474
  throw error;
454
475
  }
455
476
  return notFoundValue;
@@ -457,32 +478,6 @@ var NullInjector = class {
457
478
  };
458
479
 
459
480
  // src/import/di/provider_collection.ts
460
- function importProvidersFrom(...sources) {
461
- return {
462
- ɵproviders: internalImportProvidersFrom(true, sources),
463
- ɵfromNgModule: true
464
- };
465
- }
466
- function internalImportProvidersFrom(checkForStandaloneCmp, ...sources) {
467
- const providersOut = [];
468
- const dedup = /* @__PURE__ */ new Set();
469
- let injectorTypesWithProviders;
470
- const collectProviders = (provider) => {
471
- providersOut.push(provider);
472
- };
473
- if (injectorTypesWithProviders !== void 0) {
474
- processInjectorTypesWithProviders(
475
- injectorTypesWithProviders,
476
- collectProviders
477
- );
478
- }
479
- return providersOut;
480
- }
481
- function processInjectorTypesWithProviders(typesWithProviders, visitor) {
482
- for (let i = 0; i < typesWithProviders.length; i++) {
483
- const { ngModule, providers } = typesWithProviders[i];
484
- }
485
- }
486
481
  var USE_VALUE = getClosureSafeProperty({
487
482
  provide: String,
488
483
  useValue: getClosureSafeProperty
@@ -521,23 +516,16 @@ var R3Injector = class extends EnvironmentInjector {
521
516
  this.parent = parent;
522
517
  this.source = source;
523
518
  this.scopes = scopes;
524
- forEachSingleProvider(
525
- providers,
526
- (provider) => this.processProvider(provider)
527
- );
519
+ forEachSingleProvider(providers, (provider) => this.processProvider(provider));
528
520
  this.records.set(INJECTOR, makeRecord(void 0, this));
529
521
  if (scopes.has("environment")) {
530
522
  this.records.set(EnvironmentInjector, makeRecord(void 0, this));
531
523
  }
532
- const record = this.records.get(
533
- INJECTOR_SCOPE
534
- );
524
+ const record = this.records.get(INJECTOR_SCOPE);
535
525
  if (record != null && typeof record.value === "string") {
536
526
  this.scopes.add(record.value);
537
527
  }
538
- this.injectorDefTypes = new Set(
539
- this.get(INJECTOR_DEF_TYPES, EMPTY_ARRAY, 2 /* Self */)
540
- );
528
+ this.injectorDefTypes = new Set(this.get(INJECTOR_DEF_TYPES, EMPTY_ARRAY, { self: true }));
541
529
  }
542
530
  /**
543
531
  * Map of tokens to records which contain the instances of those tokens.
@@ -558,6 +546,22 @@ var R3Injector = class extends EnvironmentInjector {
558
546
  }
559
547
  _destroyed = false;
560
548
  injectorDefTypes;
549
+ retrieve(token, options) {
550
+ const flags = convertToBitFlags(options) || 0 /* Default */;
551
+ try {
552
+ return this.get(
553
+ token,
554
+ // When a dependency is requested with an optional flag, DI returns null as the default value.
555
+ THROW_IF_NOT_FOUND,
556
+ flags
557
+ );
558
+ } catch (e) {
559
+ if (isNotFound(e)) {
560
+ return e;
561
+ }
562
+ throw e;
563
+ }
564
+ }
561
565
  /**
562
566
  * Destroy the injector and release references to every instance or provider associated with it.
563
567
  *
@@ -600,12 +604,12 @@ var R3Injector = class extends EnvironmentInjector {
600
604
  setInjectImplementation(previousInjectImplementation);
601
605
  }
602
606
  }
603
- get(token, notFoundValue = THROW_IF_NOT_FOUND, flags = 0 /* Default */) {
607
+ get(token, notFoundValue = THROW_IF_NOT_FOUND, options) {
604
608
  assertNotDestroyed(this);
605
609
  if (token.hasOwnProperty(NG_ENV_ID)) {
606
610
  return token[NG_ENV_ID](this);
607
611
  }
608
- flags = convertToBitFlags(flags);
612
+ const flags = convertToBitFlags(options);
609
613
  if (false) {
610
614
  }
611
615
  const previousInjector = setCurrentInjector(this);
@@ -618,10 +622,7 @@ var R3Injector = class extends EnvironmentInjector {
618
622
  if (def && this.injectableDefInScope(def)) {
619
623
  if (false) {
620
624
  }
621
- record = makeRecord(
622
- injectableDefOrInjectorDefFactory(token),
623
- NOT_YET
624
- );
625
+ record = makeRecord(injectableDefOrInjectorDefFactory(token), NOT_YET);
625
626
  } else {
626
627
  record = null;
627
628
  }
@@ -635,7 +636,7 @@ var R3Injector = class extends EnvironmentInjector {
635
636
  notFoundValue = flags & 8 /* Optional */ && notFoundValue === THROW_IF_NOT_FOUND ? null : notFoundValue;
636
637
  return nextInjector.get(token, notFoundValue);
637
638
  } catch (e) {
638
- if (e.name === "NullInjectorError") {
639
+ if (isNotFound(e)) {
639
640
  const path = e[NG_TEMP_TOKEN_PATH] = e[NG_TEMP_TOKEN_PATH] || [];
640
641
  path.unshift(stringify(token));
641
642
  if (previousInjector) {
@@ -658,11 +659,7 @@ var R3Injector = class extends EnvironmentInjector {
658
659
  if (false) {
659
660
  }
660
661
  try {
661
- const initializers = this.get(
662
- ENVIRONMENT_INITIALIZER,
663
- EMPTY_ARRAY,
664
- 2 /* Self */
665
- );
662
+ const initializers = this.get(ENVIRONMENT_INITIALIZER, EMPTY_ARRAY, { self: true });
666
663
  if (false) {
667
664
  }
668
665
  for (const initializer of initializers) {
@@ -710,7 +707,8 @@ var R3Injector = class extends EnvironmentInjector {
710
707
  }
711
708
  hydrate(token, record) {
712
709
  try {
713
- if (false) {
710
+ if (record.value === CIRCULAR) {
711
+ throwCyclicDependencyError(stringify(token));
714
712
  } else if (record.value === NOT_YET) {
715
713
  record.value = CIRCULAR;
716
714
  if (false) {
@@ -750,17 +748,17 @@ function injectableDefOrInjectorDefFactory(token) {
750
748
  return factory;
751
749
  }
752
750
  if (token instanceof InjectionToken) {
753
- throw new RuntimeError(204 /* INVALID_INJECTION_TOKEN */, null);
751
+ throw new RuntimeError(204 /* INVALID_INJECTION_TOKEN */, void 0);
754
752
  }
755
753
  if (token instanceof Function) {
756
754
  return getUndecoratedInjectableFactory(token);
757
755
  }
758
- throw new RuntimeError(204 /* INVALID_INJECTION_TOKEN */, null);
756
+ throw new RuntimeError(204 /* INVALID_INJECTION_TOKEN */, void 0);
759
757
  }
760
758
  function getUndecoratedInjectableFactory(token) {
761
759
  const paramLength = token.length;
762
760
  if (paramLength > 0) {
763
- throw new RuntimeError(204 /* INVALID_INJECTION_TOKEN */, null);
761
+ throw new RuntimeError(204 /* INVALID_INJECTION_TOKEN */, void 0);
764
762
  }
765
763
  const inheritedInjectableDef = getInheritedInjectableDef(token);
766
764
  if (inheritedInjectableDef !== null) {
@@ -792,9 +790,7 @@ function providerToFactory(provider, ngModuleType, providers) {
792
790
  } else if (isExistingProvider(provider)) {
793
791
  factory = () => ɵɵinject(resolveForwardRef(provider.useExisting));
794
792
  } else {
795
- const classRef = resolveForwardRef(
796
- provider && (provider.useClass || provider.provide)
797
- );
793
+ const classRef = resolveForwardRef(provider && (provider.useClass || provider.provide));
798
794
  if (false) {
799
795
  }
800
796
  if (hasDeps(provider)) {
@@ -808,7 +804,7 @@ function providerToFactory(provider, ngModuleType, providers) {
808
804
  }
809
805
  function assertNotDestroyed(injector) {
810
806
  if (injector.destroyed) {
811
- throw new RuntimeError(205 /* INJECTOR_ALREADY_DESTROYED */, null);
807
+ throw new RuntimeError(205 /* INJECTOR_ALREADY_DESTROYED */, void 0);
812
808
  }
813
809
  }
814
810
  function makeRecord(factory, value, multi = false) {
@@ -825,7 +821,7 @@ function hasOnDestroy(value) {
825
821
  return value !== null && typeof value === "object" && typeof value.ngOnDestroy === "function";
826
822
  }
827
823
  function couldBeInjectableType(value) {
828
- return typeof value === "function" || typeof value === "object" && value instanceof InjectionToken;
824
+ return typeof value === "function" || typeof value === "object" && value.ngMetadataName === "InjectionToken";
829
825
  }
830
826
  function forEachSingleProvider(providers, fn) {
831
827
  for (const provider of providers) {
@@ -878,10 +874,7 @@ var Inject = attachInjectFlag(
878
874
  var Optional = (
879
875
  // Disable tslint because `InternalInjectFlags` is a const enum which gets inlined.
880
876
  // tslint:disable-next-line: no-toplevel-property-access
881
- attachInjectFlag(
882
- makeParamDecorator("Optional"),
883
- 8 /* Optional */
884
- )
877
+ attachInjectFlag(makeParamDecorator("Optional"), 8 /* Optional */)
885
878
  );
886
879
  var Self = (
887
880
  // Disable tslint because `InternalInjectFlags` is a const enum which gets inlined.
@@ -891,35 +884,19 @@ var Self = (
891
884
  var SkipSelf = (
892
885
  // Disable tslint because `InternalInjectFlags` is a const enum which gets inlined.
893
886
  // tslint:disable-next-line: no-toplevel-property-access
894
- attachInjectFlag(
895
- makeParamDecorator("SkipSelf"),
896
- 4 /* SkipSelf */
897
- )
887
+ attachInjectFlag(makeParamDecorator("SkipSelf"), 4 /* SkipSelf */)
898
888
  );
899
889
 
900
890
  // src/import/di/create_injector.ts
901
891
  function createInjector(defType, parent = null, additionalProviders = null, name) {
902
- const injector = createInjectorWithoutInjectorInstances(
903
- defType,
904
- parent,
905
- additionalProviders,
906
- name
907
- );
892
+ const injector = createInjectorWithoutInjectorInstances(defType, parent, additionalProviders, name);
908
893
  injector.resolveInjectorInitializers();
909
894
  return injector;
910
895
  }
911
896
  function createInjectorWithoutInjectorInstances(defType, parent = null, additionalProviders = null, name, scopes = /* @__PURE__ */ new Set()) {
912
- const providers = [
913
- additionalProviders || EMPTY_ARRAY,
914
- importProvidersFrom(defType)
915
- ];
897
+ const providers = [additionalProviders || EMPTY_ARRAY];
916
898
  name = name || (typeof defType === "object" ? void 0 : stringify(defType));
917
- return new R3Injector(
918
- providers,
919
- parent || getNullInjector(),
920
- name || null,
921
- scopes
922
- );
899
+ return new R3Injector(providers, parent || getNullInjector(), name || null, scopes);
923
900
  }
924
901
 
925
902
  // src/import/di/injector.ts
@@ -965,6 +942,7 @@ function defaultEquals(a, b) {
965
942
  var activeConsumer = null;
966
943
  var inNotificationPhase = false;
967
944
  var epoch = 1;
945
+ var postProducerCreatedFn = null;
968
946
  var SIGNAL = /* @__PURE__ */ Symbol("SIGNAL");
969
947
  function setActiveConsumer(consumer) {
970
948
  const prev = activeConsumer;
@@ -974,9 +952,6 @@ function setActiveConsumer(consumer) {
974
952
  function getActiveConsumer() {
975
953
  return activeConsumer;
976
954
  }
977
- function isInNotificationPhase() {
978
- return inNotificationPhase;
979
- }
980
955
  var REACTIVE_NODE = {
981
956
  version: 0,
982
957
  lastCleanEpoch: 0,
@@ -1000,9 +975,7 @@ var REACTIVE_NODE = {
1000
975
  };
1001
976
  function producerAccessed(node) {
1002
977
  if (inNotificationPhase) {
1003
- throw new Error(
1004
- false ? `Assertion error: signal read during notification phase` : ""
1005
- );
978
+ throw new Error(false ? `Assertion error: signal read during notification phase` : "");
1006
979
  }
1007
980
  if (activeConsumer === null) {
1008
981
  return;
@@ -1013,10 +986,7 @@ function producerAccessed(node) {
1013
986
  if (idx < activeConsumer.producerNode.length && activeConsumer.producerNode[idx] !== node) {
1014
987
  if (consumerIsLive(activeConsumer)) {
1015
988
  const staleProducer = activeConsumer.producerNode[idx];
1016
- producerRemoveLiveConsumerAtIndex(
1017
- staleProducer,
1018
- activeConsumer.producerIndexOfThis[idx]
1019
- );
989
+ producerRemoveLiveConsumerAtIndex(staleProducer, activeConsumer.producerIndexOfThis[idx]);
1020
990
  }
1021
991
  }
1022
992
  if (activeConsumer.producerNode[idx] !== node) {
@@ -1081,10 +1051,7 @@ function consumerAfterComputation(node, prevConsumer) {
1081
1051
  }
1082
1052
  if (consumerIsLive(node)) {
1083
1053
  for (let i = node.nextProducerIndex; i < node.producerNode.length; i++) {
1084
- producerRemoveLiveConsumerAtIndex(
1085
- node.producerNode[i],
1086
- node.producerIndexOfThis[i]
1087
- );
1054
+ producerRemoveLiveConsumerAtIndex(node.producerNode[i], node.producerIndexOfThis[i]);
1088
1055
  }
1089
1056
  }
1090
1057
  while (node.producerNode.length > node.nextProducerIndex) {
@@ -1112,10 +1079,7 @@ function consumerDestroy(node) {
1112
1079
  assertConsumerNode(node);
1113
1080
  if (consumerIsLive(node)) {
1114
1081
  for (let i = 0; i < node.producerNode.length; i++) {
1115
- producerRemoveLiveConsumerAtIndex(
1116
- node.producerNode[i],
1117
- node.producerIndexOfThis[i]
1118
- );
1082
+ producerRemoveLiveConsumerAtIndex(node.producerNode[i], node.producerIndexOfThis[i]);
1119
1083
  }
1120
1084
  }
1121
1085
  node.producerNode.length = node.producerLastReadVersion.length = node.producerIndexOfThis.length = 0;
@@ -1127,11 +1091,7 @@ function producerAddLiveConsumer(node, consumer, indexOfThis) {
1127
1091
  assertProducerNode(node);
1128
1092
  if (node.liveConsumerNode.length === 0 && isConsumerNode(node)) {
1129
1093
  for (let i = 0; i < node.producerNode.length; i++) {
1130
- node.producerIndexOfThis[i] = producerAddLiveConsumer(
1131
- node.producerNode[i],
1132
- node,
1133
- i
1134
- );
1094
+ node.producerIndexOfThis[i] = producerAddLiveConsumer(node.producerNode[i], node, i);
1135
1095
  }
1136
1096
  }
1137
1097
  node.liveConsumerIndexOfThis.push(indexOfThis);
@@ -1140,16 +1100,11 @@ function producerAddLiveConsumer(node, consumer, indexOfThis) {
1140
1100
  function producerRemoveLiveConsumerAtIndex(node, idx) {
1141
1101
  assertProducerNode(node);
1142
1102
  if (false) {
1143
- throw new Error(
1144
- `Assertion error: active consumer index ${idx} is out of bounds of ${node.liveConsumerNode.length} consumers)`
1145
- );
1103
+ throw new Error(`Assertion error: active consumer index ${idx} is out of bounds of ${node.liveConsumerNode.length} consumers)`);
1146
1104
  }
1147
1105
  if (node.liveConsumerNode.length === 1 && isConsumerNode(node)) {
1148
1106
  for (let i = 0; i < node.producerNode.length; i++) {
1149
- producerRemoveLiveConsumerAtIndex(
1150
- node.producerNode[i],
1151
- node.producerIndexOfThis[i]
1152
- );
1107
+ producerRemoveLiveConsumerAtIndex(node.producerNode[i], node.producerIndexOfThis[i]);
1153
1108
  }
1154
1109
  }
1155
1110
  const lastIdx = node.liveConsumerNode.length - 1;
@@ -1179,11 +1134,17 @@ function assertProducerNode(node) {
1179
1134
  function isConsumerNode(node) {
1180
1135
  return node.producerNode !== void 0;
1181
1136
  }
1137
+ function runPostProducerCreatedFn(node) {
1138
+ postProducerCreatedFn?.(node);
1139
+ }
1182
1140
 
1183
1141
  // src/primitives/signals/src/computed.ts
1184
- function createComputed(computation) {
1142
+ function createComputed(computation, equal) {
1185
1143
  const node = Object.create(COMPUTED_NODE);
1186
1144
  node.computation = computation;
1145
+ if (equal !== void 0) {
1146
+ node.equal = equal;
1147
+ }
1187
1148
  const computed2 = () => {
1188
1149
  producerUpdateValueVersion(node);
1189
1150
  producerAccessed(node);
@@ -1193,6 +1154,11 @@ function createComputed(computation) {
1193
1154
  return node.value;
1194
1155
  };
1195
1156
  computed2[SIGNAL] = node;
1157
+ if (false) {
1158
+ const debugName = node.debugName ? " (" + node.debugName + ")" : "";
1159
+ computed2.toString = () => `[Computed${debugName}: ${node.value}]`;
1160
+ }
1161
+ runPostProducerCreatedFn(node);
1196
1162
  return computed2;
1197
1163
  }
1198
1164
  var UNSET = /* @__PURE__ */ Symbol("UNSET");
@@ -1210,7 +1176,7 @@ var COMPUTED_NODE = /* @__PURE__ */ (() => ({
1210
1176
  },
1211
1177
  producerRecomputeValue(node) {
1212
1178
  if (node.value === COMPUTING) {
1213
- throw new Error("Detected cycle in computations.");
1179
+ throw new Error(false ? "Detected cycle in computations." : "");
1214
1180
  }
1215
1181
  const oldValue = node.value;
1216
1182
  node.value = COMPUTING;
@@ -1247,15 +1213,26 @@ function throwInvalidWriteToSignalError(node) {
1247
1213
 
1248
1214
  // src/primitives/signals/src/signal.ts
1249
1215
  var postSignalSetFn = null;
1250
- function createSignal(initialValue) {
1216
+ function createSignal(initialValue, equal) {
1251
1217
  const node = Object.create(SIGNAL_NODE);
1252
1218
  node.value = initialValue;
1253
- const getter = () => {
1254
- producerAccessed(node);
1255
- return node.value;
1256
- };
1219
+ if (equal !== void 0) {
1220
+ node.equal = equal;
1221
+ }
1222
+ const getter = () => signalGetFn(node);
1257
1223
  getter[SIGNAL] = node;
1258
- return getter;
1224
+ if (false) {
1225
+ const debugName = node.debugName ? " (" + node.debugName + ")" : "";
1226
+ getter.toString = () => `[Signal${debugName}: ${node.value}]`;
1227
+ }
1228
+ runPostProducerCreatedFn(node);
1229
+ const set = (newValue) => signalSetFn(node, newValue);
1230
+ const update = (updateFn) => signalUpdateFn(node, updateFn);
1231
+ return [getter, set, update];
1232
+ }
1233
+ function signalGetFn(node) {
1234
+ producerAccessed(node);
1235
+ return node.value;
1259
1236
  }
1260
1237
  function signalSetFn(node, newValue) {
1261
1238
  if (!producerUpdatesAllowed()) {
@@ -1282,7 +1259,7 @@ function signalValueChanged(node) {
1282
1259
  node.version++;
1283
1260
  producerIncrementEpoch();
1284
1261
  producerNotifyConsumers(node);
1285
- postSignalSetFn?.();
1262
+ postSignalSetFn?.(node);
1286
1263
  }
1287
1264
 
1288
1265
  // src/primitives/signals/src/linked_signal.ts
@@ -1303,6 +1280,11 @@ function createLinkedSignal(sourceFn, computationFn, equalityFn) {
1303
1280
  };
1304
1281
  const getter = linkedSignalGetter;
1305
1282
  getter[SIGNAL] = node;
1283
+ if (false) {
1284
+ const debugName = node.debugName ? " (" + node.debugName + ")" : "";
1285
+ getter.toString = () => `[LinkedSignal${debugName}: ${node.value}]`;
1286
+ }
1287
+ runPostProducerCreatedFn(node);
1306
1288
  return getter;
1307
1289
  }
1308
1290
  function linkedSignalSetFn(node, newValue) {
@@ -1321,12 +1303,13 @@ var LINKED_SIGNAL_NODE = /* @__PURE__ */ (() => ({
1321
1303
  dirty: true,
1322
1304
  error: null,
1323
1305
  equal: defaultEquals,
1306
+ kind: "linkedSignal",
1324
1307
  producerMustRecompute(node) {
1325
1308
  return node.value === UNSET || node.value === COMPUTING;
1326
1309
  },
1327
1310
  producerRecomputeValue(node) {
1328
1311
  if (node.value === COMPUTING) {
1329
- throw new Error("Detected cycle in computations.");
1312
+ throw new Error(false ? "Detected cycle in computations." : "");
1330
1313
  }
1331
1314
  const oldValue = node.value;
1332
1315
  node.value = COMPUTING;
@@ -1355,75 +1338,15 @@ var LINKED_SIGNAL_NODE = /* @__PURE__ */ (() => ({
1355
1338
  }
1356
1339
  }))();
1357
1340
 
1358
- // src/primitives/signals/src/watch.ts
1359
- function createWatch(fn, schedule, allowSignalWrites) {
1360
- const node = Object.create(WATCH_NODE);
1361
- if (allowSignalWrites) {
1362
- node.consumerAllowSignalWrites = true;
1363
- }
1364
- node.fn = fn;
1365
- node.schedule = schedule;
1366
- const registerOnCleanup = (cleanupFn) => {
1367
- node.cleanupFn = cleanupFn;
1368
- };
1369
- function isWatchNodeDestroyed(node2) {
1370
- return node2.fn === null && node2.schedule === null;
1371
- }
1372
- function destroyWatchNode(node2) {
1373
- if (!isWatchNodeDestroyed(node2)) {
1374
- consumerDestroy(node2);
1375
- node2.cleanupFn();
1376
- node2.fn = null;
1377
- node2.schedule = null;
1378
- node2.cleanupFn = NOOP_CLEANUP_FN;
1379
- }
1341
+ // src/primitives/signals/src/untracked.ts
1342
+ function untracked(nonReactiveReadsFn) {
1343
+ const prevConsumer = setActiveConsumer(null);
1344
+ try {
1345
+ return nonReactiveReadsFn();
1346
+ } finally {
1347
+ setActiveConsumer(prevConsumer);
1380
1348
  }
1381
- const run = () => {
1382
- if (node.fn === null) {
1383
- return;
1384
- }
1385
- if (isInNotificationPhase()) {
1386
- throw new Error(
1387
- `Schedulers cannot synchronously execute watches while scheduling.`
1388
- );
1389
- }
1390
- node.dirty = false;
1391
- if (node.hasRun && !consumerPollProducersForChange(node)) {
1392
- return;
1393
- }
1394
- node.hasRun = true;
1395
- const prevConsumer = consumerBeforeComputation(node);
1396
- try {
1397
- node.cleanupFn();
1398
- node.cleanupFn = NOOP_CLEANUP_FN;
1399
- node.fn(registerOnCleanup);
1400
- } finally {
1401
- consumerAfterComputation(node, prevConsumer);
1402
- }
1403
- };
1404
- node.ref = {
1405
- notify: () => consumerMarkDirty(node),
1406
- run,
1407
- cleanup: () => node.cleanupFn(),
1408
- destroy: () => destroyWatchNode(node),
1409
- [SIGNAL]: node
1410
- };
1411
- return node.ref;
1412
1349
  }
1413
- var NOOP_CLEANUP_FN = () => {
1414
- };
1415
- var WATCH_NODE = /* @__PURE__ */ (() => ({
1416
- ...REACTIVE_NODE,
1417
- consumerIsAlwaysLive: true,
1418
- consumerAllowSignalWrites: false,
1419
- consumerMarkedDirty: (node) => {
1420
- if (node.schedule !== null) {
1421
- node.schedule(node.ref);
1422
- }
1423
- },
1424
- hasRun: false,
1425
- cleanupFn: NOOP_CLEANUP_FN
1426
- }))();
1427
1350
 
1428
1351
  // src/import/render3/reactivity/api.ts
1429
1352
  function isSignal(value) {
@@ -1432,10 +1355,7 @@ function isSignal(value) {
1432
1355
 
1433
1356
  // src/import/render3/reactivity/computed.ts
1434
1357
  function computed(computation, options) {
1435
- const getter = createComputed(computation);
1436
- if (options?.equal) {
1437
- getter[SIGNAL].equal = options.equal;
1438
- }
1358
+ const getter = createComputed(computation, options?.equal);
1439
1359
  if (false) {
1440
1360
  }
1441
1361
  return getter;
@@ -1446,16 +1366,12 @@ function ɵunwrapWritableSignal(value) {
1446
1366
  return null;
1447
1367
  }
1448
1368
  function signal(initialValue, options) {
1449
- const signalFn = createSignal(initialValue);
1369
+ const [get, set, update] = createSignal(initialValue, options?.equal);
1370
+ const signalFn = get;
1450
1371
  const node = signalFn[SIGNAL];
1451
- if (options?.equal) {
1452
- node.equal = options.equal;
1453
- }
1454
- signalFn.set = (newValue) => signalSetFn(node, newValue);
1455
- signalFn.update = (updateFn) => signalUpdateFn(node, updateFn);
1456
- signalFn.asReadonly = signalAsReadonlyFn.bind(
1457
- signalFn
1458
- );
1372
+ signalFn.set = set;
1373
+ signalFn.update = update;
1374
+ signalFn.asReadonly = signalAsReadonlyFn.bind(signalFn);
1459
1375
  if (false) {
1460
1376
  }
1461
1377
  return signalFn;
@@ -1474,18 +1390,10 @@ function signalAsReadonlyFn() {
1474
1390
  var identityFn = (v) => v;
1475
1391
  function linkedSignal(optionsOrComputation, options) {
1476
1392
  if (typeof optionsOrComputation === "function") {
1477
- const getter = createLinkedSignal(
1478
- optionsOrComputation,
1479
- identityFn,
1480
- options?.equal
1481
- );
1393
+ const getter = createLinkedSignal(optionsOrComputation, identityFn, options?.equal);
1482
1394
  return upgradeLinkedSignalGetter(getter);
1483
1395
  } else {
1484
- const getter = createLinkedSignal(
1485
- optionsOrComputation.source,
1486
- optionsOrComputation.computation,
1487
- optionsOrComputation.equal
1488
- );
1396
+ const getter = createLinkedSignal(optionsOrComputation.source, optionsOrComputation.computation, optionsOrComputation.equal);
1489
1397
  return upgradeLinkedSignalGetter(getter);
1490
1398
  }
1491
1399
  }
@@ -1496,39 +1404,19 @@ function upgradeLinkedSignalGetter(getter) {
1496
1404
  const upgradedGetter = getter;
1497
1405
  upgradedGetter.set = (newValue) => linkedSignalSetFn(node, newValue);
1498
1406
  upgradedGetter.update = (updateFn) => linkedSignalUpdateFn(node, updateFn);
1499
- upgradedGetter.asReadonly = signalAsReadonlyFn.bind(
1500
- getter
1501
- );
1407
+ upgradedGetter.asReadonly = signalAsReadonlyFn.bind(getter);
1502
1408
  return upgradedGetter;
1503
1409
  }
1504
1410
 
1505
1411
  // src/import/render3/reactivity/untracked.ts
1506
- function untracked(nonReactiveReadsFn) {
1507
- const prevConsumer = setActiveConsumer(null);
1508
- try {
1509
- return nonReactiveReadsFn();
1510
- } finally {
1511
- setActiveConsumer(prevConsumer);
1512
- }
1412
+ function untracked2(nonReactiveReadsFn) {
1413
+ return untracked(nonReactiveReadsFn);
1513
1414
  }
1514
1415
 
1515
1416
  // src/import/render3/reactivity/asserts.ts
1516
1417
  function assertNotInReactiveContext(debugFn, extraContext) {
1517
1418
  if (getActiveConsumer() !== null) {
1518
- throw new RuntimeError(
1519
- -602 /* ASSERTION_NOT_INSIDE_REACTIVE_CONTEXT */,
1520
- null
1521
- );
1522
- }
1523
- }
1524
-
1525
- // src/import/di/contextual.ts
1526
- function isInInjectionContext() {
1527
- return getInjectImplementation() !== void 0 || getCurrentInjector() != null;
1528
- }
1529
- function assertInInjectionContext(debugFn) {
1530
- if (!isInInjectionContext()) {
1531
- throw new RuntimeError(-203 /* MISSING_INJECTION_CONTEXT */, null);
1419
+ throw new RuntimeError(-602 /* ASSERTION_NOT_INSIDE_REACTIVE_CONTEXT */, void 0);
1532
1420
  }
1533
1421
  }
1534
1422
 
@@ -1569,20 +1457,10 @@ var NotificationSource = /* @__PURE__ */ ((NotificationSource2) => {
1569
1457
  })(NotificationSource || {});
1570
1458
  var ChangeDetectionScheduler = class {
1571
1459
  };
1572
- var ZONELESS_ENABLED = new InjectionToken(
1573
- false ? "Zoneless enabled" : "",
1574
- { providedIn: "root", factory: () => false }
1575
- );
1576
- var PROVIDED_ZONELESS = new InjectionToken(
1577
- false ? "Zoneless provided" : "",
1578
- { providedIn: "root", factory: () => false }
1579
- );
1580
- var ZONELESS_SCHEDULER_DISABLED = new InjectionToken(
1581
- false ? "scheduler disabled" : ""
1582
- );
1583
- var SCHEDULE_IN_ROOT_ZONE = new InjectionToken(
1584
- false ? "run changes outside zone in root" : ""
1585
- );
1460
+ var ZONELESS_ENABLED = new InjectionToken("", { providedIn: "root", factory: () => false });
1461
+ var PROVIDED_ZONELESS = new InjectionToken("", { providedIn: "root", factory: () => false });
1462
+ var ZONELESS_SCHEDULER_DISABLED = new InjectionToken("");
1463
+ var SCHEDULE_IN_ROOT_ZONE = new InjectionToken("");
1586
1464
 
1587
1465
  // src/import/render3/reactivity/root_effect_scheduler.ts
1588
1466
  var EffectScheduler = class _EffectScheduler {
@@ -1597,10 +1475,17 @@ var EffectScheduler = class _EffectScheduler {
1597
1475
  );
1598
1476
  };
1599
1477
  var ZoneAwareEffectScheduler = class {
1600
- queuedEffectCount = 0;
1478
+ dirtyEffectCount = 0;
1601
1479
  queues = /* @__PURE__ */ new Map();
1602
- schedule(handle) {
1480
+ add(handle) {
1603
1481
  this.enqueue(handle);
1482
+ this.schedule(handle);
1483
+ }
1484
+ schedule(handle) {
1485
+ if (!handle.dirty) {
1486
+ return;
1487
+ }
1488
+ this.dirtyEffectCount++;
1604
1489
  }
1605
1490
  remove(handle) {
1606
1491
  const zone = handle.zone;
@@ -1609,7 +1494,9 @@ var ZoneAwareEffectScheduler = class {
1609
1494
  return;
1610
1495
  }
1611
1496
  queue.delete(handle);
1612
- this.queuedEffectCount--;
1497
+ if (handle.dirty) {
1498
+ this.dirtyEffectCount--;
1499
+ }
1613
1500
  }
1614
1501
  enqueue(handle) {
1615
1502
  const zone = handle.zone;
@@ -1620,7 +1507,6 @@ var ZoneAwareEffectScheduler = class {
1620
1507
  if (queue.has(handle)) {
1621
1508
  return;
1622
1509
  }
1623
- this.queuedEffectCount++;
1624
1510
  queue.add(handle);
1625
1511
  }
1626
1512
  /**
@@ -1630,224 +1516,35 @@ var ZoneAwareEffectScheduler = class {
1630
1516
  * ordering guarantee between effects scheduled in different zones.
1631
1517
  */
1632
1518
  flush() {
1633
- while (this.queuedEffectCount > 0) {
1519
+ while (this.dirtyEffectCount > 0) {
1520
+ let ranOneEffect = false;
1634
1521
  for (const [zone, queue] of this.queues) {
1635
1522
  if (zone === null) {
1636
- this.flushQueue(queue);
1523
+ ranOneEffect ||= this.flushQueue(queue);
1637
1524
  } else {
1638
- zone.run(() => this.flushQueue(queue));
1525
+ ranOneEffect ||= zone.run(() => this.flushQueue(queue));
1639
1526
  }
1640
1527
  }
1528
+ if (!ranOneEffect) {
1529
+ this.dirtyEffectCount = 0;
1530
+ }
1641
1531
  }
1642
1532
  }
1643
1533
  flushQueue(queue) {
1534
+ let ranOneEffect = false;
1644
1535
  for (const handle of queue) {
1645
- queue.delete(handle);
1646
- this.queuedEffectCount--;
1647
- handle.run();
1648
- }
1649
- }
1650
- };
1651
-
1652
- // src/import/render3/reactivity/patch.ts
1653
- var USE_MICROTASK_EFFECT_BY_DEFAULT = false;
1654
-
1655
- // src/import/error_handler.ts
1656
- var ErrorHandler = class {
1657
- /**
1658
- * @internal
1659
- */
1660
- _console = console;
1661
- handleError(error) {
1662
- this._console.error("ERROR", error);
1663
- }
1664
- };
1665
-
1666
- // src/import/pending_tasks.ts
1667
- var import_rxjs = require("rxjs");
1668
- var PendingTasksInternal = class _PendingTasksInternal {
1669
- taskId = 0;
1670
- pendingTasks = /* @__PURE__ */ new Set();
1671
- get _hasPendingTasks() {
1672
- return this.hasPendingTasks.value;
1673
- }
1674
- hasPendingTasks = new import_rxjs.BehaviorSubject(false);
1675
- add() {
1676
- if (!this._hasPendingTasks) {
1677
- this.hasPendingTasks.next(true);
1678
- }
1679
- const taskId = this.taskId++;
1680
- this.pendingTasks.add(taskId);
1681
- return taskId;
1682
- }
1683
- has(taskId) {
1684
- return this.pendingTasks.has(taskId);
1685
- }
1686
- remove(taskId) {
1687
- this.pendingTasks.delete(taskId);
1688
- if (this.pendingTasks.size === 0 && this._hasPendingTasks) {
1689
- this.hasPendingTasks.next(false);
1690
- }
1691
- }
1692
- ngOnDestroy() {
1693
- this.pendingTasks.clear();
1694
- if (this._hasPendingTasks) {
1695
- this.hasPendingTasks.next(false);
1696
- }
1697
- }
1698
- /** @nocollapse */
1699
- static ɵprov = (
1700
- /** @pureOrBreakMyCode */
1701
- /* @__PURE__ */ ɵɵdefineInjectable({
1702
- token: _PendingTasksInternal,
1703
- providedIn: "root",
1704
- factory: () => new _PendingTasksInternal()
1705
- })
1706
- );
1707
- };
1708
- var PendingTasks = class _PendingTasks {
1709
- internalPendingTasks = inject(PendingTasksInternal);
1710
- scheduler = inject(ChangeDetectionScheduler);
1711
- /**
1712
- * Adds a new task that should block application's stability.
1713
- * @returns A cleanup function that removes a task when called.
1714
- */
1715
- add() {
1716
- const taskId = this.internalPendingTasks.add();
1717
- return () => {
1718
- if (!this.internalPendingTasks.has(taskId)) {
1719
- return;
1720
- }
1721
- this.scheduler.notify(11 /* PendingTaskRemoved */);
1722
- this.internalPendingTasks.remove(taskId);
1723
- };
1724
- }
1725
- /**
1726
- * Runs an asynchronous function and blocks the application's stability until the function completes.
1727
- *
1728
- * ```ts
1729
- * pendingTasks.run(async () => {
1730
- * const userData = await fetch('/api/user');
1731
- * this.userData.set(userData);
1732
- * });
1733
- * ```
1734
- *
1735
- * Application stability is at least delayed until the next tick after the `run` method resolves
1736
- * so it is safe to make additional updates to application state that would require UI synchronization:
1737
- *
1738
- * ```ts
1739
- * const userData = await pendingTasks.run(() => fetch('/api/user'));
1740
- * this.userData.set(userData);
1741
- * ```
1742
- *
1743
- * @param fn The asynchronous function to execute
1744
- */
1745
- async run(fn) {
1746
- const removeTask = this.add();
1747
- try {
1748
- return await fn();
1749
- } finally {
1750
- removeTask();
1751
- }
1752
- }
1753
- /** @nocollapse */
1754
- static ɵprov = (
1755
- /** @pureOrBreakMyCode */
1756
- /* @__PURE__ */ ɵɵdefineInjectable({
1757
- token: _PendingTasks,
1758
- providedIn: "root",
1759
- factory: () => new _PendingTasks()
1760
- })
1761
- );
1762
- };
1763
-
1764
- // src/import/render3/reactivity/microtask_effect.ts
1765
- var MicrotaskEffectScheduler = class _MicrotaskEffectScheduler extends ZoneAwareEffectScheduler {
1766
- pendingTasks = inject(PendingTasksInternal);
1767
- taskId = null;
1768
- schedule(effect3) {
1769
- super.schedule(effect3);
1770
- if (this.taskId === null) {
1771
- this.taskId = this.pendingTasks.add();
1772
- queueMicrotask(() => this.flush());
1773
- }
1774
- }
1775
- flush() {
1776
- try {
1777
- super.flush();
1778
- } finally {
1779
- if (this.taskId !== null) {
1780
- this.pendingTasks.remove(this.taskId);
1781
- this.taskId = null;
1536
+ if (!handle.dirty) {
1537
+ continue;
1782
1538
  }
1539
+ this.dirtyEffectCount--;
1540
+ ranOneEffect = true;
1541
+ handle.run();
1783
1542
  }
1543
+ return ranOneEffect;
1784
1544
  }
1785
- /** @nocollapse */
1786
- static ɵprov = (
1787
- /** @pureOrBreakMyCode */
1788
- /* @__PURE__ */ ɵɵdefineInjectable({
1789
- token: _MicrotaskEffectScheduler,
1790
- providedIn: "root",
1791
- factory: () => new _MicrotaskEffectScheduler()
1792
- })
1793
- );
1794
1545
  };
1795
- var EffectHandle = class {
1796
- constructor(scheduler, effectFn, zone, destroyRef, injector, allowSignalWrites) {
1797
- this.scheduler = scheduler;
1798
- this.effectFn = effectFn;
1799
- this.zone = zone;
1800
- this.injector = injector;
1801
- this.watcher = createWatch(
1802
- (onCleanup) => this.runEffect(onCleanup),
1803
- () => this.schedule(),
1804
- allowSignalWrites
1805
- );
1806
- this.unregisterOnDestroy = destroyRef?.onDestroy(() => this.destroy());
1807
- }
1808
- unregisterOnDestroy;
1809
- watcher;
1810
- runEffect(onCleanup) {
1811
- try {
1812
- this.effectFn(onCleanup);
1813
- } catch (err) {
1814
- const errorHandler = this.injector.get(ErrorHandler, null, {
1815
- optional: true
1816
- });
1817
- errorHandler?.handleError(err);
1818
- }
1819
- }
1820
- run() {
1821
- this.watcher.run();
1822
- }
1823
- schedule() {
1824
- this.scheduler.schedule(this);
1825
- }
1826
- destroy() {
1827
- this.watcher.destroy();
1828
- this.unregisterOnDestroy?.();
1829
- }
1830
- };
1831
- function effect() {
1832
- }
1833
- function microtaskEffect(effectFn, options) {
1834
- !options?.injector && assertInInjectionContext(effect);
1835
- const injector = options?.injector ?? inject(Injector);
1836
- const destroyRef = options?.manualCleanup !== true ? injector.get(DestroyRef) : null;
1837
- const handle = new EffectHandle(
1838
- injector.get(MicrotaskEffectScheduler),
1839
- effectFn,
1840
- true ? null : (void 0).current,
1841
- destroyRef,
1842
- injector,
1843
- options?.allowSignalWrites ?? false
1844
- );
1845
- handle.watcher.notify();
1846
- return handle;
1847
- }
1848
1546
 
1849
1547
  // src/import/render3/reactivity/effect.ts
1850
- var useMicrotaskEffectsByDefault = USE_MICROTASK_EFFECT_BY_DEFAULT;
1851
1548
  var EffectRefImpl = class {
1852
1549
  [SIGNAL];
1853
1550
  constructor(node) {
@@ -1857,20 +1554,12 @@ var EffectRefImpl = class {
1857
1554
  this[SIGNAL].destroy();
1858
1555
  }
1859
1556
  };
1860
- function effect2(effectFn, options) {
1861
- if (useMicrotaskEffectsByDefault) {
1862
- if (false) {
1863
- throw new Error(
1864
- `Cannot use 'forceRoot' option with microtask effects on`
1865
- );
1866
- }
1867
- return microtaskEffect(effectFn, options);
1557
+ function effect(effectFn, options) {
1558
+ if (false) {
1559
+ assertInInjectionContext(effect);
1868
1560
  }
1869
- !options?.injector && assertInInjectionContext(effect2);
1870
1561
  if (false) {
1871
- console.warn(
1872
- `The 'allowSignalWrites' flag is deprecated and no longer impacts effect() (writes are always allowed)`
1873
- );
1562
+ console.warn(`The 'allowSignalWrites' flag is deprecated and no longer impacts effect() (writes are always allowed)`);
1874
1563
  }
1875
1564
  const injector = options?.injector ?? inject(Injector);
1876
1565
  const destroyRef = options?.manualCleanup !== true ? injector.get(DestroyRef) : null;
@@ -1897,9 +1586,7 @@ var BASE_EFFECT_NODE = /* @__PURE__ */ (() => ({
1897
1586
  run() {
1898
1587
  this.dirty = false;
1899
1588
  if (false) {
1900
- throw new Error(
1901
- `Schedulers cannot synchronously execute watches while scheduling.`
1902
- );
1589
+ throw new Error(`Schedulers cannot synchronously execute watches while scheduling.`);
1903
1590
  }
1904
1591
  if (this.hasRun && !consumerPollProducersForChange(this)) {
1905
1592
  return;
@@ -1918,12 +1605,14 @@ var BASE_EFFECT_NODE = /* @__PURE__ */ (() => ({
1918
1605
  if (!this.cleanupFns?.length) {
1919
1606
  return;
1920
1607
  }
1608
+ const prevConsumer = setActiveConsumer(null);
1921
1609
  try {
1922
1610
  while (this.cleanupFns.length) {
1923
1611
  this.cleanupFns.pop()();
1924
1612
  }
1925
1613
  } finally {
1926
1614
  this.cleanupFns = [];
1615
+ setActiveConsumer(prevConsumer);
1927
1616
  }
1928
1617
  }
1929
1618
  }))();
@@ -1946,7 +1635,7 @@ function createRootEffect(fn, scheduler, notifier) {
1946
1635
  node.scheduler = scheduler;
1947
1636
  node.notifier = notifier;
1948
1637
  node.zone = false ? (void 0).current : null;
1949
- node.scheduler.schedule(node);
1638
+ node.scheduler.add(node);
1950
1639
  node.notifier.notify(12 /* RootEffect */);
1951
1640
  return node;
1952
1641
  }
@@ -2000,27 +1689,148 @@ var ChangeDetectionSchedulerImpl = class {
2000
1689
  }
2001
1690
  };
2002
1691
 
2003
- // src/import/resource/api.ts
2004
- var ResourceStatus = /* @__PURE__ */ ((ResourceStatus2) => {
2005
- ResourceStatus2[ResourceStatus2["Idle"] = 0] = "Idle";
2006
- ResourceStatus2[ResourceStatus2["Error"] = 1] = "Error";
2007
- ResourceStatus2[ResourceStatus2["Loading"] = 2] = "Loading";
2008
- ResourceStatus2[ResourceStatus2["Reloading"] = 3] = "Reloading";
2009
- ResourceStatus2[ResourceStatus2["Resolved"] = 4] = "Resolved";
2010
- ResourceStatus2[ResourceStatus2["Local"] = 5] = "Local";
2011
- return ResourceStatus2;
2012
- })(ResourceStatus || {});
1692
+ // src/import/pending_tasks.ts
1693
+ var import_rxjs = require("rxjs");
1694
+
1695
+ // src/import/error_handler.ts
1696
+ var ErrorHandler = class {
1697
+ /**
1698
+ * @internal
1699
+ */
1700
+ _console = console;
1701
+ handleError(error) {
1702
+ this._console.error("ERROR", error);
1703
+ }
1704
+ };
1705
+ var INTERNAL_APPLICATION_ERROR_HANDLER = new InjectionToken("", {
1706
+ providedIn: "root",
1707
+ factory: () => {
1708
+ const injector = inject(EnvironmentInjector);
1709
+ let userErrorHandler;
1710
+ return (e) => {
1711
+ userErrorHandler ??= injector.get(ErrorHandler);
1712
+ userErrorHandler.handleError(e);
1713
+ };
1714
+ }
1715
+ });
1716
+
1717
+ // src/import/pending_tasks.ts
1718
+ var PendingTasksInternal = class _PendingTasksInternal {
1719
+ taskId = 0;
1720
+ pendingTasks = /* @__PURE__ */ new Set();
1721
+ destroyed = false;
1722
+ pendingTask = new import_rxjs.BehaviorSubject(false);
1723
+ get hasPendingTasks() {
1724
+ return this.destroyed ? false : this.pendingTask.value;
1725
+ }
1726
+ /**
1727
+ * In case the service is about to be destroyed, return a self-completing observable.
1728
+ * Otherwise, return the observable that emits the current state of pending tasks.
1729
+ */
1730
+ get hasPendingTasksObservable() {
1731
+ if (this.destroyed) {
1732
+ return new import_rxjs.Observable((subscriber) => {
1733
+ subscriber.next(false);
1734
+ subscriber.complete();
1735
+ });
1736
+ }
1737
+ return this.pendingTask;
1738
+ }
1739
+ add() {
1740
+ if (!this.hasPendingTasks && !this.destroyed) {
1741
+ this.pendingTask.next(true);
1742
+ }
1743
+ const taskId = this.taskId++;
1744
+ this.pendingTasks.add(taskId);
1745
+ return taskId;
1746
+ }
1747
+ has(taskId) {
1748
+ return this.pendingTasks.has(taskId);
1749
+ }
1750
+ remove(taskId) {
1751
+ this.pendingTasks.delete(taskId);
1752
+ if (this.pendingTasks.size === 0 && this.hasPendingTasks) {
1753
+ this.pendingTask.next(false);
1754
+ }
1755
+ }
1756
+ ngOnDestroy() {
1757
+ this.pendingTasks.clear();
1758
+ if (this.hasPendingTasks) {
1759
+ this.pendingTask.next(false);
1760
+ }
1761
+ this.destroyed = true;
1762
+ this.pendingTask.unsubscribe();
1763
+ }
1764
+ /** @nocollapse */
1765
+ static ɵprov = (
1766
+ /** @pureOrBreakMyCode */
1767
+ /* @__PURE__ */ ɵɵdefineInjectable({
1768
+ token: _PendingTasksInternal,
1769
+ providedIn: "root",
1770
+ factory: () => new _PendingTasksInternal()
1771
+ })
1772
+ );
1773
+ };
1774
+ var PendingTasks = class _PendingTasks {
1775
+ internalPendingTasks = inject(PendingTasksInternal);
1776
+ scheduler = inject(ChangeDetectionScheduler);
1777
+ errorHandler = inject(INTERNAL_APPLICATION_ERROR_HANDLER);
1778
+ /**
1779
+ * Adds a new task that should block application's stability.
1780
+ * @returns A cleanup function that removes a task when called.
1781
+ */
1782
+ add() {
1783
+ const taskId = this.internalPendingTasks.add();
1784
+ return () => {
1785
+ if (!this.internalPendingTasks.has(taskId)) {
1786
+ return;
1787
+ }
1788
+ this.scheduler.notify(11 /* PendingTaskRemoved */);
1789
+ this.internalPendingTasks.remove(taskId);
1790
+ };
1791
+ }
1792
+ /**
1793
+ * Runs an asynchronous function and blocks the application's stability until the function completes.
1794
+ *
1795
+ * ```ts
1796
+ * pendingTasks.run(async () => {
1797
+ * const userData = await fetch('/api/user');
1798
+ * this.userData.set(userData);
1799
+ * });
1800
+ * ```
1801
+ *
1802
+ * @param fn The asynchronous function to execute
1803
+ * @developerPreview 19.0
1804
+ */
1805
+ run(fn) {
1806
+ const removeTask = this.add();
1807
+ fn().catch(this.errorHandler).finally(removeTask);
1808
+ }
1809
+ /** @nocollapse */
1810
+ static ɵprov = (
1811
+ /** @pureOrBreakMyCode */
1812
+ /* @__PURE__ */ ɵɵdefineInjectable({
1813
+ token: _PendingTasks,
1814
+ providedIn: "root",
1815
+ factory: () => new _PendingTasks()
1816
+ })
1817
+ );
1818
+ };
2013
1819
 
2014
1820
  // src/import/resource/resource.ts
1821
+ var RESOURCE_VALUE_THROWS_ERRORS_DEFAULT = true;
2015
1822
  function resource(options) {
2016
- options?.injector || assertInInjectionContext(resource);
2017
- const request = options.request ?? (() => null);
1823
+ if (false) {
1824
+ }
1825
+ const oldNameForParams = options.request;
1826
+ const params = options.params ?? oldNameForParams ?? (() => null);
2018
1827
  return new ResourceImpl(
2019
- request,
1828
+ params,
2020
1829
  getLoader(options),
2021
1830
  options.defaultValue,
2022
1831
  options.equal ? wrapEqualityFn(options.equal) : void 0,
2023
- options.injector ?? inject(Injector)
1832
+ options.injector ?? inject(Injector),
1833
+ RESOURCE_VALUE_THROWS_ERRORS_DEFAULT
2024
1834
  );
2025
1835
  }
2026
1836
  var BaseWritableResource = class {
@@ -2031,13 +1841,15 @@ var BaseWritableResource = class {
2031
1841
  this.value.update = this.update.bind(this);
2032
1842
  this.value.asReadonly = signalAsReadonlyFn;
2033
1843
  }
1844
+ isError = computed(() => this.status() === "error");
2034
1845
  update(updateFn) {
2035
- this.set(updateFn(untracked(this.value)));
1846
+ this.set(updateFn(untracked2(this.value)));
2036
1847
  }
2037
- isLoading = computed(
2038
- () => this.status() === 2 /* Loading */ || this.status() === 3 /* Reloading */
2039
- );
1848
+ isLoading = computed(() => this.status() === "loading" || this.status() === "reloading");
2040
1849
  hasValue() {
1850
+ if (this.isError()) {
1851
+ return false;
1852
+ }
2041
1853
  return this.value() !== void 0;
2042
1854
  }
2043
1855
  asReadonly() {
@@ -2045,20 +1857,32 @@ var BaseWritableResource = class {
2045
1857
  }
2046
1858
  };
2047
1859
  var ResourceImpl = class extends BaseWritableResource {
2048
- constructor(request, loaderFn, defaultValue, equal, injector) {
1860
+ constructor(request, loaderFn, defaultValue, equal, injector, throwErrorsFromValue = RESOURCE_VALUE_THROWS_ERRORS_DEFAULT) {
2049
1861
  super(
2050
1862
  // Feed a computed signal for the value to `BaseWritableResource`, which will upgrade it to a
2051
1863
  // `WritableSignal` that delegates to `ResourceImpl.set`.
2052
1864
  computed(
2053
1865
  () => {
2054
1866
  const streamValue = this.state().stream?.();
2055
- return streamValue && isResolved(streamValue) ? streamValue.value : this.defaultValue;
1867
+ if (!streamValue) {
1868
+ return defaultValue;
1869
+ }
1870
+ if (this.state().status === "loading" && this.error()) {
1871
+ return defaultValue;
1872
+ }
1873
+ if (!isResolved(streamValue)) {
1874
+ if (throwErrorsFromValue) {
1875
+ throw new ResourceValueError(this.error());
1876
+ } else {
1877
+ return defaultValue;
1878
+ }
1879
+ }
1880
+ return streamValue.value;
2056
1881
  },
2057
1882
  { equal }
2058
1883
  )
2059
1884
  );
2060
1885
  this.loaderFn = loaderFn;
2061
- this.defaultValue = defaultValue;
2062
1886
  this.equal = equal;
2063
1887
  this.extRequest = linkedSignal({
2064
1888
  source: request,
@@ -2069,12 +1893,12 @@ var ResourceImpl = class extends BaseWritableResource {
2069
1893
  source: this.extRequest,
2070
1894
  // Compute the state of the resource given a change in status.
2071
1895
  computation: (extRequest, previous) => {
2072
- const status = extRequest.request === void 0 ? 0 /* Idle */ : 2 /* Loading */;
1896
+ const status = extRequest.request === void 0 ? "idle" : "loading";
2073
1897
  if (!previous) {
2074
1898
  return {
2075
1899
  extRequest,
2076
1900
  status,
2077
- previousStatus: 0 /* Idle */,
1901
+ previousStatus: "idle",
2078
1902
  stream: void 0
2079
1903
  };
2080
1904
  } else {
@@ -2088,12 +1912,12 @@ var ResourceImpl = class extends BaseWritableResource {
2088
1912
  }
2089
1913
  }
2090
1914
  });
2091
- this.effectRef = effect2(this.loadEffect.bind(this), {
1915
+ this.effectRef = effect(this.loadEffect.bind(this), {
2092
1916
  injector,
2093
1917
  manualCleanup: true
2094
1918
  });
2095
1919
  this.pendingTasks = injector.get(PendingTasks);
2096
- injector.get(DestroyRef).onDestroy(() => this.destroy());
1920
+ this.unregisterOnDestroy = injector.get(DestroyRef).onDestroy(() => this.destroy());
2097
1921
  }
2098
1922
  pendingTasks;
2099
1923
  /**
@@ -2109,6 +1933,7 @@ var ResourceImpl = class extends BaseWritableResource {
2109
1933
  pendingController;
2110
1934
  resolvePendingTask = void 0;
2111
1935
  destroyed = false;
1936
+ unregisterOnDestroy;
2112
1937
  status = computed(() => projectStatusOfState(this.state()));
2113
1938
  error = computed(() => {
2114
1939
  const stream = this.state().stream?.();
@@ -2121,55 +1946,55 @@ var ResourceImpl = class extends BaseWritableResource {
2121
1946
  if (this.destroyed) {
2122
1947
  return;
2123
1948
  }
2124
- const current = untracked(this.value);
2125
- const state = untracked(this.state);
2126
- if (state.status === 5 /* Local */ && (this.equal ? this.equal(current, value) : current === value)) {
1949
+ const current = untracked2(this.value);
1950
+ const state = untracked2(this.state);
1951
+ if (state.status === "local" && (this.equal ? this.equal(current, value) : current === value)) {
2127
1952
  return;
2128
1953
  }
2129
1954
  this.state.set({
2130
1955
  extRequest: state.extRequest,
2131
- status: 5 /* Local */,
2132
- previousStatus: 5 /* Local */,
1956
+ status: "local",
1957
+ previousStatus: "local",
2133
1958
  stream: signal({ value })
2134
1959
  });
2135
1960
  this.abortInProgressLoad();
2136
1961
  }
2137
1962
  reload() {
2138
- const { status } = untracked(this.state);
2139
- if (status === 0 /* Idle */ || status === 2 /* Loading */) {
1963
+ const { status } = untracked2(this.state);
1964
+ if (status === "idle" || status === "loading") {
2140
1965
  return false;
2141
1966
  }
2142
- this.extRequest.update(({ request, reload }) => ({
2143
- request,
2144
- reload: reload + 1
2145
- }));
1967
+ this.extRequest.update(({ request, reload }) => ({ request, reload: reload + 1 }));
2146
1968
  return true;
2147
1969
  }
2148
1970
  destroy() {
2149
1971
  this.destroyed = true;
1972
+ this.unregisterOnDestroy();
2150
1973
  this.effectRef.destroy();
2151
1974
  this.abortInProgressLoad();
2152
1975
  this.state.set({
2153
1976
  extRequest: { request: void 0, reload: 0 },
2154
- status: 0 /* Idle */,
2155
- previousStatus: 0 /* Idle */,
1977
+ status: "idle",
1978
+ previousStatus: "idle",
2156
1979
  stream: void 0
2157
1980
  });
2158
1981
  }
2159
1982
  async loadEffect() {
2160
1983
  const extRequest = this.extRequest();
2161
- const { status: currentStatus, previousStatus } = untracked(this.state);
1984
+ const { status: currentStatus, previousStatus } = untracked2(this.state);
2162
1985
  if (extRequest.request === void 0) {
2163
1986
  return;
2164
- } else if (currentStatus !== 2 /* Loading */) {
1987
+ } else if (currentStatus !== "loading") {
2165
1988
  return;
2166
1989
  }
2167
1990
  this.abortInProgressLoad();
2168
1991
  let resolvePendingTask = this.resolvePendingTask = this.pendingTasks.add();
2169
1992
  const { signal: abortSignal } = this.pendingController = new AbortController();
2170
1993
  try {
2171
- const stream = await untracked(
1994
+ const stream = await untracked2(
2172
1995
  () => this.loaderFn({
1996
+ params: extRequest.request,
1997
+ // TODO(alxhub): cleanup after g3 removal of `request` alias.
2173
1998
  request: extRequest.request,
2174
1999
  abortSignal,
2175
2000
  previous: {
@@ -2177,24 +2002,24 @@ var ResourceImpl = class extends BaseWritableResource {
2177
2002
  }
2178
2003
  })
2179
2004
  );
2180
- if (abortSignal.aborted || untracked(this.extRequest) !== extRequest) {
2005
+ if (abortSignal.aborted || untracked2(this.extRequest) !== extRequest) {
2181
2006
  return;
2182
2007
  }
2183
2008
  this.state.set({
2184
2009
  extRequest,
2185
- status: 4 /* Resolved */,
2186
- previousStatus: 4 /* Resolved */,
2010
+ status: "resolved",
2011
+ previousStatus: "resolved",
2187
2012
  stream
2188
2013
  });
2189
2014
  } catch (err) {
2190
- if (abortSignal.aborted || untracked(this.extRequest) !== extRequest) {
2015
+ if (abortSignal.aborted || untracked2(this.extRequest) !== extRequest) {
2191
2016
  return;
2192
2017
  }
2193
2018
  this.state.set({
2194
2019
  extRequest,
2195
- status: 4 /* Resolved */,
2196
- previousStatus: 1 /* Error */,
2197
- stream: signal({ error: err })
2020
+ status: "resolved",
2021
+ previousStatus: "error",
2022
+ stream: signal({ error: encapsulateResourceError(err) })
2198
2023
  });
2199
2024
  } finally {
2200
2025
  resolvePendingTask?.();
@@ -2202,7 +2027,7 @@ var ResourceImpl = class extends BaseWritableResource {
2202
2027
  }
2203
2028
  }
2204
2029
  abortInProgressLoad() {
2205
- untracked(() => this.pendingController?.abort());
2030
+ untracked2(() => this.pendingController?.abort());
2206
2031
  this.pendingController = void 0;
2207
2032
  this.resolvePendingTask?.();
2208
2033
  this.resolvePendingTask = void 0;
@@ -2219,7 +2044,7 @@ function getLoader(options) {
2219
2044
  try {
2220
2045
  return signal({ value: await options.loader(params) });
2221
2046
  } catch (err) {
2222
- return signal({ error: err });
2047
+ return signal({ error: encapsulateResourceError(err) });
2223
2048
  }
2224
2049
  };
2225
2050
  }
@@ -2228,10 +2053,10 @@ function isStreamingResourceOptions(options) {
2228
2053
  }
2229
2054
  function projectStatusOfState(state) {
2230
2055
  switch (state.status) {
2231
- case 2 /* Loading */:
2232
- return state.extRequest.reload === 0 ? 2 /* Loading */ : 3 /* Reloading */;
2233
- case 4 /* Resolved */:
2234
- return isResolved(untracked(state.stream)) ? 4 /* Resolved */ : 1 /* Error */;
2056
+ case "loading":
2057
+ return state.extRequest.reload === 0 ? "loading" : "reloading";
2058
+ case "resolved":
2059
+ return isResolved(state.stream()) ? "resolved" : "error";
2235
2060
  default:
2236
2061
  return state.status;
2237
2062
  }
@@ -2239,8 +2064,28 @@ function projectStatusOfState(state) {
2239
2064
  function isResolved(state) {
2240
2065
  return state.error === void 0;
2241
2066
  }
2067
+ function encapsulateResourceError(error) {
2068
+ if (error instanceof Error) {
2069
+ return error;
2070
+ }
2071
+ return new ResourceWrappedError(error);
2072
+ }
2073
+ var ResourceValueError = class extends Error {
2074
+ constructor(error) {
2075
+ super(error.message, { cause: error });
2076
+ }
2077
+ };
2078
+ var ResourceWrappedError = class extends Error {
2079
+ constructor(error) {
2080
+ super(String(error), { cause: error });
2081
+ }
2082
+ };
2242
2083
 
2243
2084
  // src/import/index.ts
2085
+ function Injectable(args) {
2086
+ return (constructor) => {
2087
+ };
2088
+ }
2244
2089
  var StaticInjectOptions = class {
2245
2090
  static injectOptions;
2246
2091
  };
@@ -2250,12 +2095,7 @@ var RootStaticInjectOptions = class {
2250
2095
  };
2251
2096
  };
2252
2097
  function createInjector2(options) {
2253
- return new R3Injector(
2254
- options.providers,
2255
- options.parent ?? getNullInjector(),
2256
- options.name ?? "",
2257
- options.scopes ?? /* @__PURE__ */ new Set([])
2258
- );
2098
+ return new R3Injector(options.providers, options.parent ?? getNullInjector(), options.name ?? "", options.scopes ?? /* @__PURE__ */ new Set([]));
2259
2099
  }
2260
2100
  function createRootInjector(options) {
2261
2101
  return new R3Injector(
@@ -2268,7 +2108,7 @@ function createRootInjector(options) {
2268
2108
  ],
2269
2109
  getNullInjector(),
2270
2110
  options.name ?? "",
2271
- options.scopes ?? /* @__PURE__ */ new Set([])
2111
+ options.scopes ?? /* @__PURE__ */ new Set(["environment"])
2272
2112
  );
2273
2113
  }
2274
2114
  // Annotate the CommonJS export names for ESM import in node:
@@ -2276,10 +2116,13 @@ function createRootInjector(options) {
2276
2116
  ChangeDetectionScheduler,
2277
2117
  ChangeDetectionSchedulerImpl,
2278
2118
  DecoratorFlags,
2119
+ DestroyRef,
2279
2120
  EnvironmentInjector,
2121
+ ErrorHandler,
2280
2122
  INJECTOR_SCOPE,
2123
+ INTERNAL_APPLICATION_ERROR_HANDLER,
2281
2124
  Inject,
2282
- InjectFlags,
2125
+ Injectable,
2283
2126
  InjectionToken,
2284
2127
  Injector,
2285
2128
  InternalInjectFlags,
@@ -2290,8 +2133,10 @@ function createRootInjector(options) {
2290
2133
  NullInjector,
2291
2134
  Optional,
2292
2135
  PROVIDED_ZONELESS,
2136
+ PendingTasks,
2137
+ PendingTasksInternal,
2293
2138
  R3Injector,
2294
- ResourceStatus,
2139
+ RetrievingInjector,
2295
2140
  RootStaticInjectOptions,
2296
2141
  SCHEDULE_IN_ROOT_ZONE,
2297
2142
  SOURCE,
@@ -2329,9 +2174,7 @@ function createRootInjector(options) {
2329
2174
  signal,
2330
2175
  untracked,
2331
2176
  ɵEffectScheduler,
2332
- ɵMicrotaskEffectScheduler,
2333
2177
  ɵSIGNAL,
2334
- ɵmicrotaskEffect,
2335
2178
  ɵunwrapWritableSignal,
2336
2179
  ɵɵdefineInjectable,
2337
2180
  ɵɵdefineInjector,