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.
- package/import/application/application_tokens.d.ts +58 -0
- package/import/application/stability_debug.d.ts +13 -0
- package/import/authoring/output/output_ref.d.ts +37 -0
- package/import/change_detection/scheduling/zoneless_scheduling.d.ts +0 -7
- package/import/core_reactivity_export_internal.d.ts +1 -1
- package/import/defer/idle_service.d.ts +42 -0
- package/import/di/create_injector.d.ts +2 -2
- package/import/di/forward_ref.d.ts +2 -2
- package/import/di/index.d.ts +4 -0
- package/import/di/inject_async.d.ts +91 -0
- package/import/di/injectable.d.ts +7 -1
- package/import/di/injection_token.d.ts +7 -0
- package/import/di/injector.d.ts +1 -1
- package/import/di/injector_compatibility.d.ts +0 -1
- package/import/di/interface/defs.d.ts +2 -2
- package/import/di/interface/provider.d.ts +0 -15
- package/import/document.d.ts +18 -0
- package/import/errors.d.ts +13 -9
- package/import/event_emitter.d.ts +101 -0
- package/import/hydration/cache.d.ts +14 -0
- package/import/index.d.ts +16 -0
- package/import/linker.d.ts +1 -0
- package/import/pending_tasks.d.ts +1 -24
- package/import/pending_tasks_internal.d.ts +31 -0
- package/import/render3/debug/injector_profiler.d.ts +10 -4
- package/import/render3/debug/special_providers.d.ts +17 -0
- package/import/render3/reactivity/api.d.ts +15 -0
- package/import/render3/reactivity/asserts.d.ts +1 -0
- package/import/render3/reactivity/effect.d.ts +3 -1
- package/import/render3/reactivity/root_effect_scheduler.d.ts +1 -1
- package/import/render3/reactivity/signal.d.ts +0 -4
- package/import/render3/util/stringify_utils.d.ts +1 -1
- package/import/resource/api.d.ts +101 -15
- package/import/resource/debounce.d.ts +21 -0
- package/import/resource/from_snapshots.d.ts +16 -0
- package/import/resource/index.d.ts +2 -0
- package/import/resource/resource.d.ts +32 -8
- package/import/transfer_state.d.ts +89 -0
- package/import/util/default_export.d.ts +24 -0
- package/import/util/promise_with_resolvers.d.ts +38 -0
- package/import/zone/ng_zone.d.ts +261 -0
- package/index.js +875 -196
- package/index.js.map +4 -4
- package/index.mjs +858 -190
- package/index.mjs.map +4 -4
- package/package.json +2 -2
- package/primitives/signals/index.d.ts +1 -1
- package/primitives/signals/src/formatter.d.ts +2 -1
- package/primitives/signals/src/graph.d.ts +8 -1
- package/primitives/signals/src/linked_signal.d.ts +1 -1
- package/readme.md +1 -1
- /package/import/{interface → change_detection}/lifecycle_hooks.d.ts +0 -0
package/index.mjs
CHANGED
|
@@ -22,7 +22,7 @@ function formatRuntimeError(code, message) {
|
|
|
22
22
|
if (ngDevMode && code < 0) {
|
|
23
23
|
const addPeriodSeparator = !errorMessage.match(/[.,;!?\n]$/);
|
|
24
24
|
const separator = addPeriodSeparator ? "." : "";
|
|
25
|
-
errorMessage = `${errorMessage}${separator} Find more at ${"https://
|
|
25
|
+
errorMessage = `${errorMessage}${separator} Find more at ${"https://v22.angular.dev/errors"}/${fullCode}`;
|
|
26
26
|
}
|
|
27
27
|
return errorMessage;
|
|
28
28
|
}
|
|
@@ -64,9 +64,11 @@ function stringify(token) {
|
|
|
64
64
|
var __forward_ref__ = getClosureSafeProperty({ __forward_ref__: getClosureSafeProperty });
|
|
65
65
|
function forwardRef(forwardRefFn) {
|
|
66
66
|
forwardRefFn.__forward_ref__ = forwardRef;
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
if (ngDevMode) {
|
|
68
|
+
forwardRefFn.toString = function() {
|
|
69
|
+
return stringify(this());
|
|
70
|
+
};
|
|
71
|
+
}
|
|
70
72
|
return forwardRefFn;
|
|
71
73
|
}
|
|
72
74
|
function resolveForwardRef(type) {
|
|
@@ -132,12 +134,12 @@ function producerAccessed(node) {
|
|
|
132
134
|
if (nextProducerLink !== void 0 && nextProducerLink.producer === node) {
|
|
133
135
|
activeConsumer.producersTail = nextProducerLink;
|
|
134
136
|
nextProducerLink.lastReadVersion = node.version;
|
|
137
|
+
nextProducerLink.knownValidAtEpoch = epoch;
|
|
135
138
|
return;
|
|
136
139
|
}
|
|
137
140
|
}
|
|
138
141
|
const prevConsumerLink = node.consumersTail;
|
|
139
|
-
if (prevConsumerLink !== void 0 && prevConsumerLink.consumer === activeConsumer &&
|
|
140
|
-
(!isRecomputing || isValidLink(prevConsumerLink, activeConsumer))) {
|
|
142
|
+
if (prevConsumerLink !== void 0 && prevConsumerLink.consumer === activeConsumer && (!isRecomputing || prevConsumerLink.knownValidAtEpoch === epoch)) {
|
|
141
143
|
return;
|
|
142
144
|
}
|
|
143
145
|
const isLive = consumerIsLive(activeConsumer);
|
|
@@ -147,7 +149,12 @@ function producerAccessed(node) {
|
|
|
147
149
|
// instead of eagerly destroying the previous link, we delay until we've finished recomputing
|
|
148
150
|
// the producers list, so that we can destroy all of the old links at once.
|
|
149
151
|
nextProducer: nextProducerLink,
|
|
150
|
-
prevConsumer
|
|
152
|
+
// Don't set prevConsumer here — it's only meaningful when the link is part of
|
|
153
|
+
// the producer's consumer list. producerAddLiveConsumer sets it correctly when
|
|
154
|
+
// the link is actually inserted. Setting it eagerly would create a dangling
|
|
155
|
+
// reference into the consumer list that prevents GC of removed entries.
|
|
156
|
+
prevConsumer: void 0,
|
|
157
|
+
knownValidAtEpoch: epoch,
|
|
151
158
|
lastReadVersion: node.version,
|
|
152
159
|
nextConsumer: void 0
|
|
153
160
|
};
|
|
@@ -212,6 +219,13 @@ function consumerBeforeComputation(node) {
|
|
|
212
219
|
return setActiveConsumer(node);
|
|
213
220
|
}
|
|
214
221
|
function resetConsumerBeforeComputation(node) {
|
|
222
|
+
if (node.producersTail?.knownValidAtEpoch === epoch) {
|
|
223
|
+
let producer = node.producers;
|
|
224
|
+
while (producer !== void 0) {
|
|
225
|
+
producer.knownValidAtEpoch = null;
|
|
226
|
+
producer = producer.nextProducer;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
215
229
|
node.producersTail = void 0;
|
|
216
230
|
node.recomputing = true;
|
|
217
231
|
}
|
|
@@ -311,22 +325,6 @@ function consumerIsLive(node) {
|
|
|
311
325
|
function runPostProducerCreatedFn(node) {
|
|
312
326
|
postProducerCreatedFn?.(node);
|
|
313
327
|
}
|
|
314
|
-
function isValidLink(checkLink, consumer) {
|
|
315
|
-
const producersTail = consumer.producersTail;
|
|
316
|
-
if (producersTail !== void 0) {
|
|
317
|
-
let link = consumer.producers;
|
|
318
|
-
do {
|
|
319
|
-
if (link === checkLink) {
|
|
320
|
-
return true;
|
|
321
|
-
}
|
|
322
|
-
if (link === producersTail) {
|
|
323
|
-
break;
|
|
324
|
-
}
|
|
325
|
-
link = link.nextProducer;
|
|
326
|
-
} while (link !== void 0);
|
|
327
|
-
}
|
|
328
|
-
return false;
|
|
329
|
-
}
|
|
330
328
|
|
|
331
329
|
// src/primitives/signals/src/formatter.ts
|
|
332
330
|
var formatter = {
|
|
@@ -338,8 +336,8 @@ var formatter = {
|
|
|
338
336
|
let value;
|
|
339
337
|
try {
|
|
340
338
|
value = sig();
|
|
341
|
-
} catch {
|
|
342
|
-
return ["span",
|
|
339
|
+
} catch (e) {
|
|
340
|
+
return ["span", `Signal(⚠️ Error)${e.message ? `: ${e.message}` : ""}`];
|
|
343
341
|
}
|
|
344
342
|
const kind = "computation" in sig[SIGNAL] ? "Computed" : "Signal";
|
|
345
343
|
const isPrimitive = value === null || !Array.isArray(value) && typeof value !== "object";
|
|
@@ -376,7 +374,7 @@ var formatter = {
|
|
|
376
374
|
["div", { style: `color: ${color}` }, "Signal value: "],
|
|
377
375
|
["div", { style: `padding-left: .5rem;` }, ["object", { object: sig(), config }]],
|
|
378
376
|
["div", { style: `color: ${color}` }, "Signal function: "],
|
|
379
|
-
["div", { style: `padding-left: .5rem;` }, ["object", { object: sig, config: { ...config,
|
|
377
|
+
["div", { style: `padding-left: .5rem;` }, ["object", { object: sig, config: { ...config, ngSkipFormatting: true } }]]
|
|
380
378
|
];
|
|
381
379
|
}
|
|
382
380
|
};
|
|
@@ -404,7 +402,7 @@ function prettifyPreview(value) {
|
|
|
404
402
|
}
|
|
405
403
|
}
|
|
406
404
|
default: {
|
|
407
|
-
return ["object", { object: value, config: {
|
|
405
|
+
return ["object", { object: value, config: { ngSkipFormatting: true } }];
|
|
408
406
|
}
|
|
409
407
|
}
|
|
410
408
|
}
|
|
@@ -440,8 +438,7 @@ function createComputed(computation, equal) {
|
|
|
440
438
|
};
|
|
441
439
|
computed2[SIGNAL] = node;
|
|
442
440
|
if (typeof ngDevMode !== "undefined" && ngDevMode) {
|
|
443
|
-
|
|
444
|
-
computed2.toString = () => `[Computed${debugName}: ${node.value}]`;
|
|
441
|
+
computed2.toString = () => `[Computed${node.debugName ? " (" + node.debugName + ")" : ""}: ${String(node.value)}]`;
|
|
445
442
|
}
|
|
446
443
|
runPostProducerCreatedFn(node);
|
|
447
444
|
return computed2;
|
|
@@ -507,8 +504,7 @@ function createSignal(initialValue, equal) {
|
|
|
507
504
|
const getter = () => signalGetFn(node);
|
|
508
505
|
getter[SIGNAL] = node;
|
|
509
506
|
if (typeof ngDevMode !== "undefined" && ngDevMode) {
|
|
510
|
-
|
|
511
|
-
getter.toString = () => `[Signal${debugName}: ${node.value}]`;
|
|
507
|
+
getter.toString = () => `[Signal${node.debugName ? " (" + node.debugName + ")" : ""}: ${String(node.value)}]`;
|
|
512
508
|
}
|
|
513
509
|
runPostProducerCreatedFn(node);
|
|
514
510
|
const set = (newValue) => signalSetFn(node, newValue);
|
|
@@ -566,8 +562,7 @@ function createLinkedSignal(sourceFn, computationFn, equalityFn) {
|
|
|
566
562
|
const getter = linkedSignalGetter;
|
|
567
563
|
getter[SIGNAL] = node;
|
|
568
564
|
if (typeof ngDevMode !== "undefined" && ngDevMode) {
|
|
569
|
-
|
|
570
|
-
getter.toString = () => `[LinkedSignal${debugName}: ${node.value}]`;
|
|
565
|
+
getter.toString = () => `[LinkedSignal${node.debugName ? " (" + node.debugName + ")" : ""}: ${String(node.value)}]`;
|
|
571
566
|
}
|
|
572
567
|
runPostProducerCreatedFn(node);
|
|
573
568
|
return getter;
|
|
@@ -579,6 +574,9 @@ function linkedSignalSetFn(node, newValue) {
|
|
|
579
574
|
}
|
|
580
575
|
function linkedSignalUpdateFn(node, updater) {
|
|
581
576
|
producerUpdateValueVersion(node);
|
|
577
|
+
if (node.value === ERRORED) {
|
|
578
|
+
throw node.error;
|
|
579
|
+
}
|
|
582
580
|
signalUpdateFn(node, updater);
|
|
583
581
|
producerMarkClean(node);
|
|
584
582
|
}
|
|
@@ -600,21 +598,25 @@ var LINKED_SIGNAL_NODE = /* @__PURE__ */ (() => ({
|
|
|
600
598
|
node.value = COMPUTING;
|
|
601
599
|
const prevConsumer = consumerBeforeComputation(node);
|
|
602
600
|
let newValue;
|
|
601
|
+
let wasEqual = false;
|
|
603
602
|
try {
|
|
604
603
|
const newSourceValue = node.source();
|
|
605
|
-
const
|
|
604
|
+
const oldValueValid = oldValue !== UNSET && oldValue !== ERRORED;
|
|
605
|
+
const prev = oldValueValid ? {
|
|
606
606
|
source: node.sourceValue,
|
|
607
607
|
value: oldValue
|
|
608
|
-
};
|
|
608
|
+
} : void 0;
|
|
609
609
|
newValue = node.computation(newSourceValue, prev);
|
|
610
610
|
node.sourceValue = newSourceValue;
|
|
611
|
+
setActiveConsumer(null);
|
|
612
|
+
wasEqual = oldValueValid && newValue !== ERRORED && node.equal(oldValue, newValue);
|
|
611
613
|
} catch (err) {
|
|
612
614
|
newValue = ERRORED;
|
|
613
615
|
node.error = err;
|
|
614
616
|
} finally {
|
|
615
617
|
consumerAfterComputation(node, prevConsumer);
|
|
616
618
|
}
|
|
617
|
-
if (
|
|
619
|
+
if (wasEqual) {
|
|
618
620
|
node.value = oldValue;
|
|
619
621
|
return;
|
|
620
622
|
}
|
|
@@ -657,7 +659,7 @@ function runEffect(node) {
|
|
|
657
659
|
}
|
|
658
660
|
|
|
659
661
|
// src/primitives/signals/index.ts
|
|
660
|
-
if (typeof ngDevMode
|
|
662
|
+
if (typeof ngDevMode === "undefined" || ngDevMode) {
|
|
661
663
|
installDevToolsSignalFormatter();
|
|
662
664
|
}
|
|
663
665
|
|
|
@@ -717,12 +719,6 @@ var NG_INJ_DEF = getClosureSafeProperty({ ɵinj: getClosureSafeProperty });
|
|
|
717
719
|
|
|
718
720
|
// src/import/di/injection_token.ts
|
|
719
721
|
var InjectionToken = class {
|
|
720
|
-
/**
|
|
721
|
-
* @param _desc Description for the token,
|
|
722
|
-
* used only for debugging purposes,
|
|
723
|
-
* it should but does not need to be unique
|
|
724
|
-
* @param options Options for the token's usage, as described above
|
|
725
|
-
*/
|
|
726
722
|
constructor(_desc, options) {
|
|
727
723
|
this._desc = _desc;
|
|
728
724
|
this.ɵprov = void 0;
|
|
@@ -793,7 +789,7 @@ function emitProviderConfiguredEvent(eventProvider, isViewProvider = false) {
|
|
|
793
789
|
function emitInjectorToCreateInstanceEvent(token) {
|
|
794
790
|
!ngDevMode && throwError("Injector profiler should never be called in production mode");
|
|
795
791
|
injectorProfiler({
|
|
796
|
-
type:
|
|
792
|
+
type: 5 /* InjectorToCreateInstanceEvent */,
|
|
797
793
|
context: getInjectorProfilerContext(),
|
|
798
794
|
token
|
|
799
795
|
});
|
|
@@ -869,11 +865,11 @@ function throwInvalidProviderError(ngModuleType, providers, provider) {
|
|
|
869
865
|
} else if (isEnvironmentProviders(provider)) {
|
|
870
866
|
if (provider.ɵfromNgModule) {
|
|
871
867
|
throw new RuntimeError(
|
|
872
|
-
207 /* PROVIDER_IN_WRONG_CONTEXT */,
|
|
868
|
+
-207 /* PROVIDER_IN_WRONG_CONTEXT */,
|
|
873
869
|
`Invalid providers from 'importProvidersFrom' present in a non-environment injector. 'importProvidersFrom' can't be used for component providers.`
|
|
874
870
|
);
|
|
875
871
|
} else {
|
|
876
|
-
throw new RuntimeError(207 /* PROVIDER_IN_WRONG_CONTEXT */, `Invalid providers present in a non-environment injector. 'EnvironmentProviders' can't be used for component providers.`);
|
|
872
|
+
throw new RuntimeError(-207 /* PROVIDER_IN_WRONG_CONTEXT */, `Invalid providers present in a non-environment injector. 'EnvironmentProviders' can't be used for component providers.`);
|
|
877
873
|
}
|
|
878
874
|
} else {
|
|
879
875
|
throw new Error("Invalid provider");
|
|
@@ -947,7 +943,7 @@ if ((typeof ngDevMode === "undefined" || ngDevMode) && true) {
|
|
|
947
943
|
}
|
|
948
944
|
|
|
949
945
|
// src/import/di/initializer_token.ts
|
|
950
|
-
var ENVIRONMENT_INITIALIZER = new InjectionToken(ngDevMode ? "ENVIRONMENT_INITIALIZER" : "");
|
|
946
|
+
var ENVIRONMENT_INITIALIZER = new InjectionToken(typeof ngDevMode !== "undefined" && ngDevMode ? "ENVIRONMENT_INITIALIZER" : "");
|
|
951
947
|
|
|
952
948
|
// src/import/di/interface/injector.ts
|
|
953
949
|
var DecoratorFlags = /* @__PURE__ */ ((DecoratorFlags2) => {
|
|
@@ -981,7 +977,7 @@ function injectRootLimpMode(token, notFoundValue, flags) {
|
|
|
981
977
|
}
|
|
982
978
|
if (flags & 8 /* Optional */) return null;
|
|
983
979
|
if (notFoundValue !== void 0) return notFoundValue;
|
|
984
|
-
throwProviderNotFoundError(token, "Injector");
|
|
980
|
+
throwProviderNotFoundError(token, typeof ngDevMode !== "undefined" && ngDevMode ? "Injector" : "");
|
|
985
981
|
}
|
|
986
982
|
|
|
987
983
|
// src/primitives/di/src/injector.ts
|
|
@@ -1027,8 +1023,6 @@ var RetrievingInjector = class {
|
|
|
1027
1023
|
}
|
|
1028
1024
|
};
|
|
1029
1025
|
var NG_TEMP_TOKEN_PATH = "ngTempTokenPath";
|
|
1030
|
-
var NEW_LINE = /\n/gm;
|
|
1031
|
-
var NO_NEW_LINE = "ɵ";
|
|
1032
1026
|
var SOURCE = "__source";
|
|
1033
1027
|
function injectInjectorOnly(token, flags = 0 /* Default */) {
|
|
1034
1028
|
const currentInjector = getCurrentInjector();
|
|
@@ -1120,27 +1114,10 @@ function attachInjectFlag(decorator, flag) {
|
|
|
1120
1114
|
function getInjectFlag(token) {
|
|
1121
1115
|
return token[DI_DECORATOR_FLAG];
|
|
1122
1116
|
}
|
|
1123
|
-
function formatError(text, obj, injectorErrorName, source = null) {
|
|
1124
|
-
text = text && text.charAt(0) === "\n" && text.charAt(1) == NO_NEW_LINE ? text.slice(2) : text;
|
|
1125
|
-
let context = stringify(obj);
|
|
1126
|
-
if (Array.isArray(obj)) {
|
|
1127
|
-
context = obj.map(stringify).join(" -> ");
|
|
1128
|
-
} else if (typeof obj === "object") {
|
|
1129
|
-
const parts = [];
|
|
1130
|
-
for (const key in obj) {
|
|
1131
|
-
if (obj.hasOwnProperty(key)) {
|
|
1132
|
-
const value = obj[key];
|
|
1133
|
-
parts.push(key + ":" + (typeof value === "string" ? JSON.stringify(value) : stringify(value)));
|
|
1134
|
-
}
|
|
1135
|
-
}
|
|
1136
|
-
context = `{${parts.join(", ")}}`;
|
|
1137
|
-
}
|
|
1138
|
-
return `${injectorErrorName}${source ? "(" + source + ")" : ""}[${context}]: ${text.replace(NEW_LINE, "\n ")}`;
|
|
1139
|
-
}
|
|
1140
1117
|
|
|
1141
1118
|
// src/import/di/injector_token.ts
|
|
1142
1119
|
var INJECTOR = new InjectionToken(
|
|
1143
|
-
ngDevMode ? "INJECTOR" : "",
|
|
1120
|
+
typeof ngDevMode !== "undefined" && ngDevMode ? "INJECTOR" : "",
|
|
1144
1121
|
// Disable tslint because this is const enum which gets inlined not top level prop access.
|
|
1145
1122
|
// tslint:disable-next-line: no-toplevel-property-access
|
|
1146
1123
|
-1 /* Injector */
|
|
@@ -1148,7 +1125,7 @@ var INJECTOR = new InjectionToken(
|
|
|
1148
1125
|
);
|
|
1149
1126
|
|
|
1150
1127
|
// src/import/di/internal_tokens.ts
|
|
1151
|
-
var INJECTOR_DEF_TYPES = new InjectionToken(ngDevMode ? "INJECTOR_DEF_TYPES" : "");
|
|
1128
|
+
var INJECTOR_DEF_TYPES = new InjectionToken(typeof ngDevMode !== "undefined" && ngDevMode ? "INJECTOR_DEF_TYPES" : "");
|
|
1152
1129
|
|
|
1153
1130
|
// src/import/di/null_injector.ts
|
|
1154
1131
|
var NullInjector = class {
|
|
@@ -1164,6 +1141,11 @@ var NullInjector = class {
|
|
|
1164
1141
|
};
|
|
1165
1142
|
|
|
1166
1143
|
// src/import/di/provider_collection.ts
|
|
1144
|
+
function makeEnvironmentProviders(providers) {
|
|
1145
|
+
return {
|
|
1146
|
+
ɵproviders: providers
|
|
1147
|
+
};
|
|
1148
|
+
}
|
|
1167
1149
|
var USE_VALUE = getClosureSafeProperty({
|
|
1168
1150
|
provide: String,
|
|
1169
1151
|
useValue: getClosureSafeProperty
|
|
@@ -1182,7 +1164,7 @@ function isTypeProvider(value) {
|
|
|
1182
1164
|
}
|
|
1183
1165
|
|
|
1184
1166
|
// src/import/di/scope.ts
|
|
1185
|
-
var INJECTOR_SCOPE = new InjectionToken(ngDevMode ? "Set Injector scope." : "");
|
|
1167
|
+
var INJECTOR_SCOPE = new InjectionToken(typeof ngDevMode !== "undefined" && ngDevMode ? "Set Injector scope." : "");
|
|
1186
1168
|
|
|
1187
1169
|
// src/import/di/r3_injector.ts
|
|
1188
1170
|
var NOT_YET = {};
|
|
@@ -1377,12 +1359,15 @@ var R3Injector = class extends EnvironmentInjector {
|
|
|
1377
1359
|
}
|
|
1378
1360
|
}
|
|
1379
1361
|
toString() {
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1362
|
+
if (ngDevMode) {
|
|
1363
|
+
const tokens = [];
|
|
1364
|
+
const records = this.records;
|
|
1365
|
+
for (const token of records.keys()) {
|
|
1366
|
+
tokens.push(stringify(token));
|
|
1367
|
+
}
|
|
1368
|
+
return `R3Injector[${tokens.join(", ")}]`;
|
|
1384
1369
|
}
|
|
1385
|
-
return
|
|
1370
|
+
return "R3Injector[...]";
|
|
1386
1371
|
}
|
|
1387
1372
|
/**
|
|
1388
1373
|
* Process a `SingleProvider` and add it.
|
|
@@ -1426,7 +1411,7 @@ var R3Injector = class extends EnvironmentInjector {
|
|
|
1426
1411
|
hydrate(token, record, flags) {
|
|
1427
1412
|
try {
|
|
1428
1413
|
if (record.value === CIRCULAR) {
|
|
1429
|
-
throw cyclicDependencyError(stringify(token));
|
|
1414
|
+
throw cyclicDependencyError(ngDevMode ? stringify(token) : "");
|
|
1430
1415
|
} else if (record.value === NOT_YET) {
|
|
1431
1416
|
record.value = CIRCULAR;
|
|
1432
1417
|
if (ngDevMode) {
|
|
@@ -1471,17 +1456,17 @@ function injectableDefOrInjectorDefFactory(token) {
|
|
|
1471
1456
|
return factory;
|
|
1472
1457
|
}
|
|
1473
1458
|
if (token instanceof InjectionToken) {
|
|
1474
|
-
throw new RuntimeError(204 /* INVALID_INJECTION_TOKEN */, ngDevMode && `Token ${stringify(token)} is missing a ɵprov definition.`);
|
|
1459
|
+
throw new RuntimeError(-204 /* INVALID_INJECTION_TOKEN */, ngDevMode && `Token ${stringify(token)} is missing a ɵprov definition.`);
|
|
1475
1460
|
}
|
|
1476
1461
|
if (token instanceof Function) {
|
|
1477
1462
|
return getUndecoratedInjectableFactory(token);
|
|
1478
1463
|
}
|
|
1479
|
-
throw new RuntimeError(204 /* INVALID_INJECTION_TOKEN */, ngDevMode && "unreachable");
|
|
1464
|
+
throw new RuntimeError(-204 /* INVALID_INJECTION_TOKEN */, ngDevMode && "unreachable");
|
|
1480
1465
|
}
|
|
1481
1466
|
function getUndecoratedInjectableFactory(token) {
|
|
1482
1467
|
const paramLength = token.length;
|
|
1483
1468
|
if (paramLength > 0) {
|
|
1484
|
-
throw new RuntimeError(204 /* INVALID_INJECTION_TOKEN */, ngDevMode && `Can't resolve all parameters for ${stringify(token)}: (${newArray(paramLength, "?").join(", ")}).`);
|
|
1469
|
+
throw new RuntimeError(-204 /* INVALID_INJECTION_TOKEN */, ngDevMode && `Can't resolve all parameters for ${stringify(token)}: (${newArray(paramLength, "?").join(", ")}).`);
|
|
1485
1470
|
}
|
|
1486
1471
|
const inheritedInjectableDef = getInheritedInjectableDef(token);
|
|
1487
1472
|
if (inheritedInjectableDef !== null) {
|
|
@@ -1529,7 +1514,7 @@ function providerToFactory(provider, ngModuleType, providers) {
|
|
|
1529
1514
|
}
|
|
1530
1515
|
function assertNotDestroyed(injector) {
|
|
1531
1516
|
if (injector.destroyed) {
|
|
1532
|
-
throw new RuntimeError(205 /* INJECTOR_ALREADY_DESTROYED */, ngDevMode && "Injector has already been destroyed.");
|
|
1517
|
+
throw new RuntimeError(-205 /* INJECTOR_ALREADY_DESTROYED */, ngDevMode && "Injector has already been destroyed.");
|
|
1533
1518
|
}
|
|
1534
1519
|
}
|
|
1535
1520
|
function makeRecord(factory, value, multi = false) {
|
|
@@ -1620,8 +1605,19 @@ function createInjector(defType, parent = null, additionalProviders = null, name
|
|
|
1620
1605
|
}
|
|
1621
1606
|
function createInjectorWithoutInjectorInstances(defType, parent = null, additionalProviders = null, name, scopes = /* @__PURE__ */ new Set()) {
|
|
1622
1607
|
const providers = [additionalProviders || EMPTY_ARRAY];
|
|
1623
|
-
|
|
1624
|
-
|
|
1608
|
+
let source = void 0;
|
|
1609
|
+
if (ngDevMode) {
|
|
1610
|
+
source = name || (typeof defType === "object" ? void 0 : stringify(defType));
|
|
1611
|
+
}
|
|
1612
|
+
return new R3Injector(providers, parent || getNullInjector(), source || null, scopes);
|
|
1613
|
+
}
|
|
1614
|
+
|
|
1615
|
+
// src/import/render3/debug/special_providers.ts
|
|
1616
|
+
var specialProviders = /* @__PURE__ */ new Set();
|
|
1617
|
+
function registerSpecialProvider(clazz) {
|
|
1618
|
+
if (typeof ngDevMode !== "undefined" && ngDevMode) {
|
|
1619
|
+
specialProviders.add(clazz);
|
|
1620
|
+
}
|
|
1625
1621
|
}
|
|
1626
1622
|
|
|
1627
1623
|
// src/import/di/injector.ts
|
|
@@ -1651,6 +1647,9 @@ var Injector = class _Injector {
|
|
|
1651
1647
|
*/
|
|
1652
1648
|
static __NG_ELEMENT_ID__ = -1 /* Injector */;
|
|
1653
1649
|
};
|
|
1650
|
+
if (typeof ngDevMode === "undefined" || ngDevMode) {
|
|
1651
|
+
registerSpecialProvider(Injector);
|
|
1652
|
+
}
|
|
1654
1653
|
|
|
1655
1654
|
// src/import/render3/instructions/di.ts
|
|
1656
1655
|
function ɵɵinvalidFactory() {
|
|
@@ -1662,13 +1661,17 @@ function ɵɵinvalidFactory() {
|
|
|
1662
1661
|
function isSignal2(value) {
|
|
1663
1662
|
return typeof value === "function" && value[SIGNAL] !== void 0;
|
|
1664
1663
|
}
|
|
1664
|
+
function isWritableSignal(value) {
|
|
1665
|
+
return isSignal2(value) && typeof value.set === "function";
|
|
1666
|
+
}
|
|
1665
1667
|
|
|
1666
1668
|
// src/import/render3/reactivity/computed.ts
|
|
1667
1669
|
function computed(computation, options) {
|
|
1668
1670
|
const getter = createComputed(computation, options?.equal);
|
|
1669
|
-
if (ngDevMode) {
|
|
1670
|
-
|
|
1671
|
-
getter[SIGNAL].debugName =
|
|
1671
|
+
if (typeof ngDevMode !== "undefined" && ngDevMode) {
|
|
1672
|
+
const debugName = options?.debugName;
|
|
1673
|
+
getter[SIGNAL].debugName = debugName;
|
|
1674
|
+
getter.toString = () => `[Computed${debugName ? " (" + debugName + ")" : ""}: ${getter()}]`;
|
|
1672
1675
|
}
|
|
1673
1676
|
return getter;
|
|
1674
1677
|
}
|
|
@@ -1684,9 +1687,10 @@ function signal(initialValue, options) {
|
|
|
1684
1687
|
signalFn.set = set;
|
|
1685
1688
|
signalFn.update = update;
|
|
1686
1689
|
signalFn.asReadonly = signalAsReadonlyFn.bind(signalFn);
|
|
1687
|
-
if (ngDevMode) {
|
|
1688
|
-
|
|
1689
|
-
node.debugName =
|
|
1690
|
+
if (typeof ngDevMode !== "undefined" && ngDevMode) {
|
|
1691
|
+
const debugName = options?.debugName;
|
|
1692
|
+
node.debugName = debugName;
|
|
1693
|
+
signalFn.toString = () => `[Signal${debugName ? " (" + debugName + ")" : ""}: ${signalFn()}]`;
|
|
1690
1694
|
}
|
|
1691
1695
|
return signalFn;
|
|
1692
1696
|
}
|
|
@@ -1712,9 +1716,9 @@ function linkedSignal(optionsOrComputation, options) {
|
|
|
1712
1716
|
}
|
|
1713
1717
|
}
|
|
1714
1718
|
function upgradeLinkedSignalGetter(getter, debugName) {
|
|
1715
|
-
if (ngDevMode) {
|
|
1716
|
-
getter.toString = () => `[LinkedSignal: ${getter()}]`;
|
|
1719
|
+
if (typeof ngDevMode !== "undefined" && ngDevMode) {
|
|
1717
1720
|
getter[SIGNAL].debugName = debugName;
|
|
1721
|
+
getter.toString = () => `[LinkedSignal${debugName ? " (" + debugName + ")" : ""}: ${getter()}]`;
|
|
1718
1722
|
}
|
|
1719
1723
|
const node = getter[SIGNAL];
|
|
1720
1724
|
const upgradedGetter = getter;
|
|
@@ -1740,6 +1744,28 @@ function assertNotInReactiveContext(debugFn, extraContext) {
|
|
|
1740
1744
|
}
|
|
1741
1745
|
|
|
1742
1746
|
// src/import/di/contextual.ts
|
|
1747
|
+
function runInInjectionContext(injector, fn) {
|
|
1748
|
+
let internalInjector;
|
|
1749
|
+
if (injector instanceof R3Injector) {
|
|
1750
|
+
assertNotDestroyed(injector);
|
|
1751
|
+
internalInjector = injector;
|
|
1752
|
+
} else {
|
|
1753
|
+
internalInjector = new RetrievingInjector(injector);
|
|
1754
|
+
}
|
|
1755
|
+
let prevInjectorProfilerContext;
|
|
1756
|
+
if (ngDevMode) {
|
|
1757
|
+
prevInjectorProfilerContext = setInjectorProfilerContext({ injector, token: null });
|
|
1758
|
+
}
|
|
1759
|
+
const prevInjector = setCurrentInjector(internalInjector);
|
|
1760
|
+
const previousInjectImplementation = setInjectImplementation(void 0);
|
|
1761
|
+
try {
|
|
1762
|
+
return fn();
|
|
1763
|
+
} finally {
|
|
1764
|
+
setCurrentInjector(prevInjector);
|
|
1765
|
+
ngDevMode && setInjectorProfilerContext(prevInjectorProfilerContext);
|
|
1766
|
+
setInjectImplementation(previousInjectImplementation);
|
|
1767
|
+
}
|
|
1768
|
+
}
|
|
1743
1769
|
function isInInjectionContext() {
|
|
1744
1770
|
return getInjectImplementation() !== void 0 || getCurrentInjector() != null;
|
|
1745
1771
|
}
|
|
@@ -1764,9 +1790,8 @@ var DestroyRef = class {
|
|
|
1764
1790
|
*/
|
|
1765
1791
|
static __NG_ENV_ID__ = (injector) => injector;
|
|
1766
1792
|
};
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
function noop(...args) {
|
|
1793
|
+
if (typeof ngDevMode === "undefined" || ngDevMode) {
|
|
1794
|
+
registerSpecialProvider(DestroyRef);
|
|
1770
1795
|
}
|
|
1771
1796
|
|
|
1772
1797
|
// src/import/change_detection/scheduling/zoneless_scheduling.ts
|
|
@@ -1789,10 +1814,6 @@ var NotificationSource = /* @__PURE__ */ ((NotificationSource2) => {
|
|
|
1789
1814
|
})(NotificationSource || {});
|
|
1790
1815
|
var ChangeDetectionScheduler = class {
|
|
1791
1816
|
};
|
|
1792
|
-
var ZONELESS_ENABLED = new InjectionToken(typeof ngDevMode === "undefined" || ngDevMode ? "Zoneless enabled" : "", { providedIn: "root", factory: () => false });
|
|
1793
|
-
var PROVIDED_ZONELESS = new InjectionToken(typeof ngDevMode === "undefined" || ngDevMode ? "Zoneless provided" : "", { providedIn: "root", factory: () => false });
|
|
1794
|
-
var ZONELESS_SCHEDULER_DISABLED = new InjectionToken(typeof ngDevMode === "undefined" || ngDevMode ? "scheduler disabled" : "");
|
|
1795
|
-
var SCHEDULE_IN_ROOT_ZONE = new InjectionToken(typeof ngDevMode === "undefined" || ngDevMode ? "run changes outside zone in root" : "");
|
|
1796
1817
|
|
|
1797
1818
|
// src/import/render3/reactivity/root_effect_scheduler.ts
|
|
1798
1819
|
var EffectScheduler = class _EffectScheduler {
|
|
@@ -1901,7 +1922,7 @@ function effect(effectFn, options) {
|
|
|
1901
1922
|
node = createRootEffect(effectFn, injector.get(EffectScheduler), notifier);
|
|
1902
1923
|
node.injector = injector;
|
|
1903
1924
|
if (destroyRef !== null) {
|
|
1904
|
-
node.
|
|
1925
|
+
node.onDestroyFns = [destroyRef.onDestroy(() => node.destroy())];
|
|
1905
1926
|
}
|
|
1906
1927
|
const effectRef = new EffectRefImpl(node);
|
|
1907
1928
|
if (ngDevMode) {
|
|
@@ -1919,7 +1940,7 @@ var EFFECT_NODE = /* @__PURE__ */ (() => ({
|
|
|
1919
1940
|
...BASE_EFFECT_NODE,
|
|
1920
1941
|
cleanupFns: void 0,
|
|
1921
1942
|
zone: null,
|
|
1922
|
-
|
|
1943
|
+
onDestroyFns: null,
|
|
1923
1944
|
run() {
|
|
1924
1945
|
if (ngDevMode && isInNotificationPhase()) {
|
|
1925
1946
|
throw new Error(`Schedulers cannot synchronously execute watches while scheduling.`);
|
|
@@ -1952,7 +1973,11 @@ var ROOT_EFFECT_NODE = /* @__PURE__ */ (() => ({
|
|
|
1952
1973
|
},
|
|
1953
1974
|
destroy() {
|
|
1954
1975
|
consumerDestroy(this);
|
|
1955
|
-
this.
|
|
1976
|
+
if (this.onDestroyFns !== null) {
|
|
1977
|
+
for (const fn of this.onDestroyFns) {
|
|
1978
|
+
fn();
|
|
1979
|
+
}
|
|
1980
|
+
}
|
|
1956
1981
|
this.cleanup();
|
|
1957
1982
|
this.scheduler.remove(this);
|
|
1958
1983
|
}
|
|
@@ -1973,6 +1998,10 @@ function createEffectFn(node, fn) {
|
|
|
1973
1998
|
};
|
|
1974
1999
|
}
|
|
1975
2000
|
|
|
2001
|
+
// src/import/util/noop.ts
|
|
2002
|
+
function noop(...args) {
|
|
2003
|
+
}
|
|
2004
|
+
|
|
1976
2005
|
// src/import/util/callback_scheduler.ts
|
|
1977
2006
|
function scheduleCallbackWithMicrotask(callback) {
|
|
1978
2007
|
queueMicrotask(() => callback());
|
|
@@ -2003,43 +2032,119 @@ var ChangeDetectionSchedulerImpl = class {
|
|
|
2003
2032
|
}
|
|
2004
2033
|
};
|
|
2005
2034
|
|
|
2006
|
-
// src/import/
|
|
2007
|
-
|
|
2035
|
+
// src/import/resource/api.ts
|
|
2036
|
+
var ResourceDependencyError = class extends Error {
|
|
2037
|
+
/** The dependency that errored. */
|
|
2038
|
+
dependency;
|
|
2039
|
+
constructor(dependency) {
|
|
2040
|
+
super("Dependency error", { cause: dependency.error() });
|
|
2041
|
+
this.name = "ResourceDependencyError";
|
|
2042
|
+
this.dependency = dependency;
|
|
2043
|
+
}
|
|
2044
|
+
};
|
|
2045
|
+
var ResourceParamsStatus = class _ResourceParamsStatus extends Error {
|
|
2046
|
+
_brand;
|
|
2047
|
+
constructor(msg) {
|
|
2048
|
+
super(msg);
|
|
2049
|
+
}
|
|
2050
|
+
/** Status code that transitions the resource to `idle` status. */
|
|
2051
|
+
static IDLE = new _ResourceParamsStatus("IDLE");
|
|
2052
|
+
/** Status code that transitions the resource to `loading` status. */
|
|
2053
|
+
static LOADING = new _ResourceParamsStatus("LOADING");
|
|
2054
|
+
};
|
|
2008
2055
|
|
|
2009
|
-
// src/import/
|
|
2010
|
-
var
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2056
|
+
// src/import/defer/idle_service.ts
|
|
2057
|
+
var _requestIdleCallback = () => (typeof requestIdleCallback !== "undefined" ? requestIdleCallback : (cb) => setTimeout(cb)).bind(globalThis);
|
|
2058
|
+
var _cancelIdleCallback = () => (typeof requestIdleCallback !== "undefined" ? cancelIdleCallback : clearTimeout).bind(globalThis);
|
|
2059
|
+
var IDLE_SERVICE = new InjectionToken(ngDevMode ? "IDLE_SERVICE" : "", {
|
|
2060
|
+
factory: () => new RequestIdleCallbackService()
|
|
2061
|
+
});
|
|
2062
|
+
function provideIdleServiceWith(useExisting) {
|
|
2063
|
+
return makeEnvironmentProviders([
|
|
2064
|
+
{
|
|
2065
|
+
provide: IDLE_SERVICE,
|
|
2066
|
+
useExisting
|
|
2067
|
+
}
|
|
2068
|
+
]);
|
|
2069
|
+
}
|
|
2070
|
+
var RequestIdleCallbackService = class {
|
|
2071
|
+
requestIdleCallback = _requestIdleCallback();
|
|
2072
|
+
cancelIdleCallback = _cancelIdleCallback();
|
|
2073
|
+
requestOnIdle(callback, options) {
|
|
2074
|
+
return this.requestIdleCallback(callback, options);
|
|
2075
|
+
}
|
|
2076
|
+
cancelOnIdle(id) {
|
|
2077
|
+
return this.cancelIdleCallback(id);
|
|
2017
2078
|
}
|
|
2018
2079
|
};
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2080
|
+
|
|
2081
|
+
// src/import/util/default_export.ts
|
|
2082
|
+
function maybeUnwrapDefaultExport(input) {
|
|
2083
|
+
return isWrappedDefaultExport(input) ? input["default"] : input;
|
|
2084
|
+
}
|
|
2085
|
+
function isWrappedDefaultExport(value) {
|
|
2086
|
+
return value && typeof value === "object" && "default" in value;
|
|
2087
|
+
}
|
|
2088
|
+
|
|
2089
|
+
// src/import/util/promise_with_resolvers.ts
|
|
2090
|
+
function promiseWithResolvers() {
|
|
2091
|
+
let resolve;
|
|
2092
|
+
let reject;
|
|
2093
|
+
const promise = new Promise((res, rej) => {
|
|
2094
|
+
resolve = res;
|
|
2095
|
+
reject = rej;
|
|
2096
|
+
});
|
|
2097
|
+
return { promise, resolve, reject };
|
|
2098
|
+
}
|
|
2099
|
+
|
|
2100
|
+
// src/import/di/inject_async.ts
|
|
2101
|
+
function injectAsync(loader, options) {
|
|
2102
|
+
if (ngDevMode) {
|
|
2103
|
+
assertInInjectionContext(injectAsync);
|
|
2034
2104
|
}
|
|
2035
|
-
|
|
2105
|
+
const injector = inject2(Injector);
|
|
2106
|
+
let loadedPromise = null;
|
|
2107
|
+
const load = () => {
|
|
2108
|
+
if (!loadedPromise) {
|
|
2109
|
+
loadedPromise = loader();
|
|
2110
|
+
}
|
|
2111
|
+
return loadedPromise;
|
|
2112
|
+
};
|
|
2113
|
+
if (options?.prefetch) {
|
|
2114
|
+
options.prefetch().then(() => load()).catch(() => {
|
|
2115
|
+
});
|
|
2116
|
+
}
|
|
2117
|
+
return () => load().then((loadedToken) => injector.get(maybeUnwrapDefaultExport(loadedToken)));
|
|
2118
|
+
}
|
|
2119
|
+
function onIdle(options) {
|
|
2120
|
+
if (ngDevMode) {
|
|
2121
|
+
assertInInjectionContext(onIdle);
|
|
2122
|
+
}
|
|
2123
|
+
const idleService = inject2(IDLE_SERVICE);
|
|
2124
|
+
const { promise, resolve } = promiseWithResolvers();
|
|
2125
|
+
idleService.requestOnIdle(() => resolve(), options);
|
|
2126
|
+
return promise;
|
|
2127
|
+
}
|
|
2036
2128
|
|
|
2037
|
-
// src/import/
|
|
2129
|
+
// src/import/hydration/cache.ts
|
|
2130
|
+
var CACHE_ACTIVE = new InjectionToken(typeof ngDevMode !== "undefined" && ngDevMode ? "STATE_CACHE_ACTIVE" : "");
|
|
2131
|
+
|
|
2132
|
+
// src/import/event_emitter.ts
|
|
2133
|
+
import { Subject, Subscription } from "rxjs";
|
|
2134
|
+
|
|
2135
|
+
// src/import/pending_tasks_internal.ts
|
|
2136
|
+
import { BehaviorSubject, Observable } from "rxjs";
|
|
2137
|
+
|
|
2138
|
+
// src/import/application/stability_debug.ts
|
|
2139
|
+
var DEBUG_TASK_TRACKER = new InjectionToken(typeof ngDevMode !== "undefined" && ngDevMode ? "DEBUG_TASK_TRACKER" : "");
|
|
2140
|
+
|
|
2141
|
+
// src/import/pending_tasks_internal.ts
|
|
2038
2142
|
var PendingTasksInternal = class _PendingTasksInternal {
|
|
2039
2143
|
taskId = 0;
|
|
2040
2144
|
pendingTasks = /* @__PURE__ */ new Set();
|
|
2041
2145
|
destroyed = false;
|
|
2042
2146
|
pendingTask = new BehaviorSubject(false);
|
|
2147
|
+
debugTaskTracker = inject2(DEBUG_TASK_TRACKER, { optional: true });
|
|
2043
2148
|
get hasPendingTasks() {
|
|
2044
2149
|
return this.destroyed ? false : this.pendingTask.value;
|
|
2045
2150
|
}
|
|
@@ -2062,6 +2167,7 @@ var PendingTasksInternal = class _PendingTasksInternal {
|
|
|
2062
2167
|
}
|
|
2063
2168
|
const taskId = this.taskId++;
|
|
2064
2169
|
this.pendingTasks.add(taskId);
|
|
2170
|
+
this.debugTaskTracker?.add(taskId);
|
|
2065
2171
|
return taskId;
|
|
2066
2172
|
}
|
|
2067
2173
|
has(taskId) {
|
|
@@ -2069,6 +2175,7 @@ var PendingTasksInternal = class _PendingTasksInternal {
|
|
|
2069
2175
|
}
|
|
2070
2176
|
remove(taskId) {
|
|
2071
2177
|
this.pendingTasks.delete(taskId);
|
|
2178
|
+
this.debugTaskTracker?.remove(taskId);
|
|
2072
2179
|
if (this.pendingTasks.size === 0 && this.hasPendingTasks) {
|
|
2073
2180
|
this.pendingTask.next(false);
|
|
2074
2181
|
}
|
|
@@ -2091,6 +2198,232 @@ var PendingTasksInternal = class _PendingTasksInternal {
|
|
|
2091
2198
|
})
|
|
2092
2199
|
);
|
|
2093
2200
|
};
|
|
2201
|
+
|
|
2202
|
+
// src/import/event_emitter.ts
|
|
2203
|
+
var EventEmitter_ = class extends Subject {
|
|
2204
|
+
// tslint:disable-next-line:require-internal-with-underscore
|
|
2205
|
+
__isAsync;
|
|
2206
|
+
destroyRef = void 0;
|
|
2207
|
+
pendingTasks = void 0;
|
|
2208
|
+
constructor(isAsync = false) {
|
|
2209
|
+
super();
|
|
2210
|
+
this.__isAsync = isAsync;
|
|
2211
|
+
if (isInInjectionContext()) {
|
|
2212
|
+
this.destroyRef = inject2(DestroyRef, { optional: true }) ?? void 0;
|
|
2213
|
+
this.pendingTasks = inject2(PendingTasksInternal, { optional: true }) ?? void 0;
|
|
2214
|
+
}
|
|
2215
|
+
}
|
|
2216
|
+
emit(value) {
|
|
2217
|
+
const prevConsumer = setActiveConsumer(null);
|
|
2218
|
+
try {
|
|
2219
|
+
super.next(value);
|
|
2220
|
+
} finally {
|
|
2221
|
+
setActiveConsumer(prevConsumer);
|
|
2222
|
+
}
|
|
2223
|
+
}
|
|
2224
|
+
subscribe(observerOrNext, error, complete) {
|
|
2225
|
+
let nextFn = observerOrNext;
|
|
2226
|
+
let errorFn = error || (() => null);
|
|
2227
|
+
let completeFn = complete;
|
|
2228
|
+
if (observerOrNext && typeof observerOrNext === "object") {
|
|
2229
|
+
const observer = observerOrNext;
|
|
2230
|
+
nextFn = observer.next?.bind(observer);
|
|
2231
|
+
errorFn = observer.error?.bind(observer);
|
|
2232
|
+
completeFn = observer.complete?.bind(observer);
|
|
2233
|
+
}
|
|
2234
|
+
if (this.__isAsync) {
|
|
2235
|
+
errorFn = this.wrapInTimeout(errorFn);
|
|
2236
|
+
if (nextFn) {
|
|
2237
|
+
nextFn = this.wrapInTimeout(nextFn);
|
|
2238
|
+
}
|
|
2239
|
+
if (completeFn) {
|
|
2240
|
+
completeFn = this.wrapInTimeout(completeFn);
|
|
2241
|
+
}
|
|
2242
|
+
}
|
|
2243
|
+
const sink = super.subscribe({ next: nextFn, error: errorFn, complete: completeFn });
|
|
2244
|
+
if (observerOrNext instanceof Subscription) {
|
|
2245
|
+
observerOrNext.add(sink);
|
|
2246
|
+
}
|
|
2247
|
+
return sink;
|
|
2248
|
+
}
|
|
2249
|
+
wrapInTimeout(fn) {
|
|
2250
|
+
return (value) => {
|
|
2251
|
+
const taskId = this.pendingTasks?.add();
|
|
2252
|
+
setTimeout(() => {
|
|
2253
|
+
try {
|
|
2254
|
+
fn(value);
|
|
2255
|
+
} finally {
|
|
2256
|
+
if (taskId !== void 0) {
|
|
2257
|
+
this.pendingTasks?.remove(taskId);
|
|
2258
|
+
}
|
|
2259
|
+
}
|
|
2260
|
+
});
|
|
2261
|
+
};
|
|
2262
|
+
}
|
|
2263
|
+
};
|
|
2264
|
+
var EventEmitter = EventEmitter_;
|
|
2265
|
+
|
|
2266
|
+
// src/import/zone/ng_zone.ts
|
|
2267
|
+
var isAngularZoneProperty = "isAngularZone";
|
|
2268
|
+
var angularZoneInstanceIdProperty = isAngularZoneProperty + "_ID";
|
|
2269
|
+
var NgZone = class _NgZone {
|
|
2270
|
+
hasPendingMacrotasks = false;
|
|
2271
|
+
hasPendingMicrotasks = false;
|
|
2272
|
+
/**
|
|
2273
|
+
* Whether there are no outstanding microtasks or macrotasks.
|
|
2274
|
+
*/
|
|
2275
|
+
isStable = true;
|
|
2276
|
+
/**
|
|
2277
|
+
* Notifies when code enters Angular Zone. This gets fired first on VM Turn.
|
|
2278
|
+
*/
|
|
2279
|
+
onUnstable = new EventEmitter(false);
|
|
2280
|
+
/**
|
|
2281
|
+
* Notifies when there is no more microtasks enqueued in the current VM Turn.
|
|
2282
|
+
* This is a hint for Angular to do change detection, which may enqueue more microtasks.
|
|
2283
|
+
* For this reason this event can fire multiple times per VM Turn.
|
|
2284
|
+
*/
|
|
2285
|
+
onMicrotaskEmpty = new EventEmitter(false);
|
|
2286
|
+
/**
|
|
2287
|
+
* Notifies when the last `onMicrotaskEmpty` has run and there are no more microtasks, which
|
|
2288
|
+
* implies we are about to relinquish VM turn.
|
|
2289
|
+
* This event gets called just once.
|
|
2290
|
+
*/
|
|
2291
|
+
onStable = new EventEmitter(false);
|
|
2292
|
+
/**
|
|
2293
|
+
* Notifies that an error has been delivered.
|
|
2294
|
+
*/
|
|
2295
|
+
onError = new EventEmitter(false);
|
|
2296
|
+
constructor(options) {
|
|
2297
|
+
}
|
|
2298
|
+
/**
|
|
2299
|
+
This method checks whether the method call happens within an Angular Zone instance.
|
|
2300
|
+
*/
|
|
2301
|
+
/**
|
|
2302
|
+
Assures that the method is called within the Angular Zone, otherwise throws an error.
|
|
2303
|
+
*/
|
|
2304
|
+
/**
|
|
2305
|
+
Assures that the method is called outside of the Angular Zone, otherwise throws an error.
|
|
2306
|
+
*/
|
|
2307
|
+
/**
|
|
2308
|
+
* Executes the `fn` function synchronously within the Angular zone and returns value returned by
|
|
2309
|
+
* the function.
|
|
2310
|
+
*
|
|
2311
|
+
* Running functions via `run` allows you to reenter Angular zone from a task that was executed
|
|
2312
|
+
* outside of the Angular zone (typically started via {@link #runOutsideAngular}).
|
|
2313
|
+
*
|
|
2314
|
+
* Any future tasks or microtasks scheduled from within this function will continue executing from
|
|
2315
|
+
* within the Angular zone.
|
|
2316
|
+
*
|
|
2317
|
+
* If a synchronous error happens it will be rethrown and not reported via `onError`.
|
|
2318
|
+
*/
|
|
2319
|
+
run(fn, applyThis, applyArgs) {
|
|
2320
|
+
return this._inner.run(fn, applyThis, applyArgs);
|
|
2321
|
+
}
|
|
2322
|
+
/**
|
|
2323
|
+
* Executes the `fn` function synchronously within the Angular zone as a task and returns value
|
|
2324
|
+
* returned by the function.
|
|
2325
|
+
*
|
|
2326
|
+
* Running functions via `runTask` allows you to reenter Angular zone from a task that was executed
|
|
2327
|
+
* outside of the Angular zone (typically started via {@link #runOutsideAngular}).
|
|
2328
|
+
*
|
|
2329
|
+
* Any future tasks or microtasks scheduled from within this function will continue executing from
|
|
2330
|
+
* within the Angular zone.
|
|
2331
|
+
*
|
|
2332
|
+
* If a synchronous error happens it will be rethrown and not reported via `onError`.
|
|
2333
|
+
*/
|
|
2334
|
+
runTask(fn, applyThis, applyArgs, name) {
|
|
2335
|
+
const zone = this._inner;
|
|
2336
|
+
const task = zone.scheduleEventTask("NgZoneEvent: " + name, fn, EMPTY_PAYLOAD, noop, noop);
|
|
2337
|
+
try {
|
|
2338
|
+
return zone.runTask(task, applyThis, applyArgs);
|
|
2339
|
+
} finally {
|
|
2340
|
+
zone.cancelTask(task);
|
|
2341
|
+
}
|
|
2342
|
+
}
|
|
2343
|
+
/**
|
|
2344
|
+
* Same as `run`, except that synchronous errors are caught and forwarded via `onError` and not
|
|
2345
|
+
* rethrown.
|
|
2346
|
+
*/
|
|
2347
|
+
runGuarded(fn, applyThis, applyArgs) {
|
|
2348
|
+
return this._inner.runGuarded(fn, applyThis, applyArgs);
|
|
2349
|
+
}
|
|
2350
|
+
/**
|
|
2351
|
+
* Executes the `fn` function synchronously in Angular's parent zone and returns value returned by
|
|
2352
|
+
* the function.
|
|
2353
|
+
*
|
|
2354
|
+
* Running functions via {@link #runOutsideAngular} allows you to escape Angular's zone and do
|
|
2355
|
+
* work that
|
|
2356
|
+
* doesn't trigger Angular change-detection or is subject to Angular's error handling.
|
|
2357
|
+
*
|
|
2358
|
+
* Any future tasks or microtasks scheduled from within this function will continue executing from
|
|
2359
|
+
* outside of the Angular zone.
|
|
2360
|
+
*
|
|
2361
|
+
* Use {@link #run} to reenter the Angular zone and do work that updates the application model.
|
|
2362
|
+
*/
|
|
2363
|
+
runOutsideAngular(fn) {
|
|
2364
|
+
return this._outer.run(fn);
|
|
2365
|
+
}
|
|
2366
|
+
/** @nocollapse */
|
|
2367
|
+
static ɵprov = ɵɵdefineInjectable({
|
|
2368
|
+
token: _NgZone,
|
|
2369
|
+
providedIn: "root",
|
|
2370
|
+
factory: () => new NoopNgZone()
|
|
2371
|
+
});
|
|
2372
|
+
};
|
|
2373
|
+
var EMPTY_PAYLOAD = {};
|
|
2374
|
+
var NoopNgZone = class {
|
|
2375
|
+
hasPendingMicrotasks = false;
|
|
2376
|
+
hasPendingMacrotasks = false;
|
|
2377
|
+
isStable = true;
|
|
2378
|
+
onUnstable = new EventEmitter();
|
|
2379
|
+
onMicrotaskEmpty = new EventEmitter();
|
|
2380
|
+
onStable = new EventEmitter();
|
|
2381
|
+
onError = new EventEmitter();
|
|
2382
|
+
run(fn, applyThis, applyArgs) {
|
|
2383
|
+
return fn.apply(applyThis, applyArgs);
|
|
2384
|
+
}
|
|
2385
|
+
runGuarded(fn, applyThis, applyArgs) {
|
|
2386
|
+
return fn.apply(applyThis, applyArgs);
|
|
2387
|
+
}
|
|
2388
|
+
runOutsideAngular(fn) {
|
|
2389
|
+
return fn();
|
|
2390
|
+
}
|
|
2391
|
+
runTask(fn, applyThis, applyArgs, name) {
|
|
2392
|
+
return fn.apply(applyThis, applyArgs);
|
|
2393
|
+
}
|
|
2394
|
+
};
|
|
2395
|
+
|
|
2396
|
+
// src/import/error_handler.ts
|
|
2397
|
+
var ErrorHandler = class {
|
|
2398
|
+
/**
|
|
2399
|
+
* @internal
|
|
2400
|
+
*/
|
|
2401
|
+
_console = console;
|
|
2402
|
+
handleError(error) {
|
|
2403
|
+
this._console.error("ERROR", error);
|
|
2404
|
+
}
|
|
2405
|
+
};
|
|
2406
|
+
var INTERNAL_APPLICATION_ERROR_HANDLER = new InjectionToken(typeof ngDevMode === "undefined" || ngDevMode ? "internal error handler" : "", {
|
|
2407
|
+
factory: () => {
|
|
2408
|
+
const zone = inject2(NgZone);
|
|
2409
|
+
const injector = inject2(EnvironmentInjector);
|
|
2410
|
+
let userErrorHandler;
|
|
2411
|
+
return (e) => {
|
|
2412
|
+
zone.runOutsideAngular(() => {
|
|
2413
|
+
if (injector.destroyed && !userErrorHandler) {
|
|
2414
|
+
setTimeout(() => {
|
|
2415
|
+
throw e;
|
|
2416
|
+
});
|
|
2417
|
+
} else {
|
|
2418
|
+
userErrorHandler ??= injector.get(ErrorHandler);
|
|
2419
|
+
userErrorHandler.handleError(e);
|
|
2420
|
+
}
|
|
2421
|
+
});
|
|
2422
|
+
};
|
|
2423
|
+
}
|
|
2424
|
+
});
|
|
2425
|
+
|
|
2426
|
+
// src/import/pending_tasks.ts
|
|
2094
2427
|
var PendingTasks = class _PendingTasks {
|
|
2095
2428
|
internalPendingTasks = inject2(PendingTasksInternal);
|
|
2096
2429
|
scheduler = inject2(ChangeDetectionScheduler);
|
|
@@ -2124,7 +2457,12 @@ var PendingTasks = class _PendingTasks {
|
|
|
2124
2457
|
*/
|
|
2125
2458
|
run(fn) {
|
|
2126
2459
|
const removeTask = this.add();
|
|
2127
|
-
|
|
2460
|
+
try {
|
|
2461
|
+
fn().catch(this.errorHandler).finally(removeTask);
|
|
2462
|
+
} catch (err) {
|
|
2463
|
+
this.errorHandler(err);
|
|
2464
|
+
removeTask();
|
|
2465
|
+
}
|
|
2128
2466
|
}
|
|
2129
2467
|
/** @nocollapse */
|
|
2130
2468
|
static ɵprov = (
|
|
@@ -2137,6 +2475,91 @@ var PendingTasks = class _PendingTasks {
|
|
|
2137
2475
|
);
|
|
2138
2476
|
};
|
|
2139
2477
|
|
|
2478
|
+
// src/import/application/application_tokens.ts
|
|
2479
|
+
var APP_ID = new InjectionToken(typeof ngDevMode !== "undefined" && ngDevMode ? "AppId" : "", {
|
|
2480
|
+
factory: () => DEFAULT_APP_ID
|
|
2481
|
+
});
|
|
2482
|
+
var DEFAULT_APP_ID = "ng";
|
|
2483
|
+
|
|
2484
|
+
// src/import/document.ts
|
|
2485
|
+
var DOCUMENT = new InjectionToken(typeof ngDevMode !== "undefined" && ngDevMode ? "DocumentToken" : "");
|
|
2486
|
+
|
|
2487
|
+
// src/import/transfer_state.ts
|
|
2488
|
+
function makeStateKey(key) {
|
|
2489
|
+
return key;
|
|
2490
|
+
}
|
|
2491
|
+
var TransferState = class _TransferState {
|
|
2492
|
+
/** @nocollapse */
|
|
2493
|
+
static ɵprov = (
|
|
2494
|
+
/** @pureOrBreakMyCode */
|
|
2495
|
+
/* @__PURE__ */ ɵɵdefineInjectable({
|
|
2496
|
+
token: _TransferState,
|
|
2497
|
+
providedIn: "root",
|
|
2498
|
+
factory: () => {
|
|
2499
|
+
const transferState = new _TransferState();
|
|
2500
|
+
if (false) {
|
|
2501
|
+
transferState.store = retrieveTransferredState(inject3(DOCUMENT2), inject3(APP_ID2));
|
|
2502
|
+
}
|
|
2503
|
+
return transferState;
|
|
2504
|
+
}
|
|
2505
|
+
})
|
|
2506
|
+
);
|
|
2507
|
+
/** @internal */
|
|
2508
|
+
store = {};
|
|
2509
|
+
onSerializeCallbacks = {};
|
|
2510
|
+
/**
|
|
2511
|
+
* Get the value corresponding to a key. Return `defaultValue` if key is not found.
|
|
2512
|
+
*/
|
|
2513
|
+
get(key, defaultValue) {
|
|
2514
|
+
return this.store[key] !== void 0 ? this.store[key] : defaultValue;
|
|
2515
|
+
}
|
|
2516
|
+
/**
|
|
2517
|
+
* Set the value corresponding to a key.
|
|
2518
|
+
*/
|
|
2519
|
+
set(key, value) {
|
|
2520
|
+
this.store[key] = value;
|
|
2521
|
+
}
|
|
2522
|
+
/**
|
|
2523
|
+
* Remove a key from the store.
|
|
2524
|
+
*/
|
|
2525
|
+
remove(key) {
|
|
2526
|
+
delete this.store[key];
|
|
2527
|
+
}
|
|
2528
|
+
/**
|
|
2529
|
+
* Test whether a key exists in the store.
|
|
2530
|
+
*/
|
|
2531
|
+
hasKey(key) {
|
|
2532
|
+
return this.store.hasOwnProperty(key);
|
|
2533
|
+
}
|
|
2534
|
+
/**
|
|
2535
|
+
* Indicates whether the state is empty.
|
|
2536
|
+
*/
|
|
2537
|
+
get isEmpty() {
|
|
2538
|
+
return Object.keys(this.store).length === 0;
|
|
2539
|
+
}
|
|
2540
|
+
/**
|
|
2541
|
+
* Register a callback to provide the value for a key when `toJson` is called.
|
|
2542
|
+
*/
|
|
2543
|
+
onSerialize(key, callback) {
|
|
2544
|
+
this.onSerializeCallbacks[key] = callback;
|
|
2545
|
+
}
|
|
2546
|
+
/**
|
|
2547
|
+
* Serialize the current state of the store to JSON.
|
|
2548
|
+
*/
|
|
2549
|
+
toJson() {
|
|
2550
|
+
for (const key in this.onSerializeCallbacks) {
|
|
2551
|
+
if (this.onSerializeCallbacks.hasOwnProperty(key)) {
|
|
2552
|
+
try {
|
|
2553
|
+
this.store[key] = this.onSerializeCallbacks[key]();
|
|
2554
|
+
} catch (e) {
|
|
2555
|
+
console.warn("Exception in onSerialize callback: ", e);
|
|
2556
|
+
}
|
|
2557
|
+
}
|
|
2558
|
+
}
|
|
2559
|
+
return JSON.stringify(this.store).replace(/</g, "\\u003C").replace(/\//g, "\\u002F");
|
|
2560
|
+
}
|
|
2561
|
+
};
|
|
2562
|
+
|
|
2140
2563
|
// src/import/resource/resource.ts
|
|
2141
2564
|
function resource(options) {
|
|
2142
2565
|
if (ngDevMode && !options?.injector) {
|
|
@@ -2144,21 +2567,30 @@ function resource(options) {
|
|
|
2144
2567
|
}
|
|
2145
2568
|
const oldNameForParams = options.request;
|
|
2146
2569
|
const params = options.params ?? oldNameForParams ?? (() => null);
|
|
2147
|
-
return new ResourceImpl(
|
|
2570
|
+
return new ResourceImpl(
|
|
2571
|
+
params,
|
|
2572
|
+
getLoader(options),
|
|
2573
|
+
options.defaultValue,
|
|
2574
|
+
options.equal ? wrapEqualityFn(options.equal) : void 0,
|
|
2575
|
+
options.debugName,
|
|
2576
|
+
options.injector ?? inject2(Injector),
|
|
2577
|
+
options.id
|
|
2578
|
+
);
|
|
2148
2579
|
}
|
|
2149
2580
|
var BaseWritableResource = class {
|
|
2150
2581
|
value;
|
|
2151
|
-
|
|
2582
|
+
isLoading;
|
|
2583
|
+
constructor(value, debugName) {
|
|
2152
2584
|
this.value = value;
|
|
2153
2585
|
this.value.set = this.set.bind(this);
|
|
2154
2586
|
this.value.update = this.update.bind(this);
|
|
2155
2587
|
this.value.asReadonly = signalAsReadonlyFn;
|
|
2588
|
+
this.isLoading = computed(() => this.status() === "loading" || this.status() === "reloading", ngDevMode ? createDebugNameObject(debugName, "isLoading") : void 0);
|
|
2156
2589
|
}
|
|
2157
2590
|
isError = computed(() => this.status() === "error");
|
|
2158
2591
|
update(updateFn) {
|
|
2159
2592
|
this.set(updateFn(untracked2(this.value)));
|
|
2160
2593
|
}
|
|
2161
|
-
isLoading = computed(() => this.status() === "loading" || this.status() === "reloading");
|
|
2162
2594
|
// Use a computed here to avoid triggering reactive consumers if the value changes while staying
|
|
2163
2595
|
// either defined or undefined.
|
|
2164
2596
|
isValueDefined = computed(() => {
|
|
@@ -2167,6 +2599,17 @@ var BaseWritableResource = class {
|
|
|
2167
2599
|
}
|
|
2168
2600
|
return this.value() !== void 0;
|
|
2169
2601
|
});
|
|
2602
|
+
_snapshot;
|
|
2603
|
+
get snapshot() {
|
|
2604
|
+
return this._snapshot ??= computed(() => {
|
|
2605
|
+
const status = this.status();
|
|
2606
|
+
if (status === "error") {
|
|
2607
|
+
return { status: "error", error: this.error() };
|
|
2608
|
+
} else {
|
|
2609
|
+
return { status, value: this.value() };
|
|
2610
|
+
}
|
|
2611
|
+
});
|
|
2612
|
+
}
|
|
2170
2613
|
hasValue() {
|
|
2171
2614
|
return this.isValueDefined();
|
|
2172
2615
|
}
|
|
@@ -2175,7 +2618,10 @@ var BaseWritableResource = class {
|
|
|
2175
2618
|
}
|
|
2176
2619
|
};
|
|
2177
2620
|
var ResourceImpl = class extends BaseWritableResource {
|
|
2178
|
-
constructor(request, loaderFn, defaultValue, equal, injector) {
|
|
2621
|
+
constructor(request, loaderFn, defaultValue, equal, debugName, injector, transferCacheKey, getInitialStream) {
|
|
2622
|
+
if (isInParamsFunction()) {
|
|
2623
|
+
throw invalidResourceCreationInParams();
|
|
2624
|
+
}
|
|
2179
2625
|
super(
|
|
2180
2626
|
// Feed a computed signal for the value to `BaseWritableResource`, which will upgrade it to a
|
|
2181
2627
|
// `WritableSignal` that delegates to `ResourceImpl.set`.
|
|
@@ -2193,45 +2639,91 @@ var ResourceImpl = class extends BaseWritableResource {
|
|
|
2193
2639
|
}
|
|
2194
2640
|
return streamValue.value;
|
|
2195
2641
|
},
|
|
2196
|
-
{ equal }
|
|
2197
|
-
)
|
|
2642
|
+
{ equal, ...ngDevMode ? createDebugNameObject(debugName, "value") : void 0 }
|
|
2643
|
+
),
|
|
2644
|
+
debugName
|
|
2198
2645
|
);
|
|
2199
2646
|
this.loaderFn = loaderFn;
|
|
2200
2647
|
this.equal = equal;
|
|
2201
|
-
this.
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
});
|
|
2648
|
+
this.debugName = debugName;
|
|
2649
|
+
this.transferCacheKey = transferCacheKey;
|
|
2650
|
+
const cacheState = injector.get(CACHE_ACTIVE, void 0, { optional: true }) ?? { isActive: false };
|
|
2651
|
+
this.transferState = injector.get(TransferState, void 0, { optional: true }) ?? void 0;
|
|
2652
|
+
this.extRequest = linkedSignal(
|
|
2653
|
+
() => {
|
|
2654
|
+
try {
|
|
2655
|
+
setInParamsFunction(true);
|
|
2656
|
+
return { request: request(paramsContext), reload: 0 };
|
|
2657
|
+
} catch (error) {
|
|
2658
|
+
rethrowFatalErrors(error);
|
|
2659
|
+
if (error === ResourceParamsStatus.IDLE) {
|
|
2660
|
+
return { status: "idle", reload: 0 };
|
|
2661
|
+
} else if (error === ResourceParamsStatus.LOADING) {
|
|
2662
|
+
return { status: "loading", reload: 0 };
|
|
2663
|
+
}
|
|
2664
|
+
return { error, reload: 0 };
|
|
2665
|
+
} finally {
|
|
2666
|
+
setInParamsFunction(false);
|
|
2667
|
+
}
|
|
2668
|
+
},
|
|
2669
|
+
ngDevMode ? createDebugNameObject(debugName, "extRequest") : void 0
|
|
2670
|
+
);
|
|
2205
2671
|
this.state = linkedSignal({
|
|
2206
2672
|
// Whenever the request changes,
|
|
2207
2673
|
source: this.extRequest,
|
|
2208
2674
|
// Compute the state of the resource given a change in status.
|
|
2209
2675
|
computation: (extRequest, previous) => {
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2676
|
+
let { request: request2, status, error } = extRequest;
|
|
2677
|
+
let stream;
|
|
2678
|
+
if (error) {
|
|
2679
|
+
status = "resolved";
|
|
2680
|
+
stream = signal({ error: encapsulateResourceError(error) }, ngDevMode ? createDebugNameObject(this.debugName, "stream") : void 0);
|
|
2681
|
+
} else if (!status) {
|
|
2682
|
+
if (!previous) {
|
|
2683
|
+
const transferState = this.transferState;
|
|
2684
|
+
const cacheKey = this.transferCacheKey;
|
|
2685
|
+
if (cacheState.isActive && cacheKey && transferState && request2 !== void 0) {
|
|
2686
|
+
const key = this.transferCacheKey;
|
|
2687
|
+
if (transferState.hasKey(cacheKey)) {
|
|
2688
|
+
stream = signal({ value: transferState.get(cacheKey, defaultValue) }, ngDevMode ? createDebugNameObject(this.debugName, "stream") : void 0);
|
|
2689
|
+
}
|
|
2690
|
+
}
|
|
2691
|
+
if (!stream) {
|
|
2692
|
+
stream = getInitialStream?.(extRequest.request);
|
|
2693
|
+
}
|
|
2694
|
+
getInitialStream = void 0;
|
|
2695
|
+
status = request2 === void 0 ? "idle" : stream ? "resolved" : "loading";
|
|
2696
|
+
} else {
|
|
2697
|
+
status = request2 === void 0 ? "idle" : "loading";
|
|
2698
|
+
if (previous.value.extRequest.request === request2) {
|
|
2699
|
+
stream = previous.value.stream;
|
|
2700
|
+
}
|
|
2701
|
+
}
|
|
2226
2702
|
}
|
|
2227
|
-
|
|
2703
|
+
return {
|
|
2704
|
+
extRequest,
|
|
2705
|
+
status,
|
|
2706
|
+
previousStatus: previous ? projectStatusOfState(previous.value) : "idle",
|
|
2707
|
+
stream
|
|
2708
|
+
};
|
|
2709
|
+
},
|
|
2710
|
+
...ngDevMode ? createDebugNameObject(debugName, "state") : void 0
|
|
2228
2711
|
});
|
|
2229
2712
|
this.effectRef = effect(this.loadEffect.bind(this), {
|
|
2230
2713
|
injector,
|
|
2231
|
-
manualCleanup: true
|
|
2714
|
+
manualCleanup: true,
|
|
2715
|
+
...ngDevMode ? createDebugNameObject(debugName, "loadEffect") : void 0
|
|
2232
2716
|
});
|
|
2233
2717
|
this.pendingTasks = injector.get(PendingTasks);
|
|
2234
2718
|
this.unregisterOnDestroy = injector.get(DestroyRef).onDestroy(() => this.destroy());
|
|
2719
|
+
this.status = computed(() => projectStatusOfState(this.state()), ngDevMode ? createDebugNameObject(debugName, "status") : void 0);
|
|
2720
|
+
this.error = computed(
|
|
2721
|
+
() => {
|
|
2722
|
+
const stream = this.state().stream?.();
|
|
2723
|
+
return stream && !isResolved(stream) ? stream.error : void 0;
|
|
2724
|
+
},
|
|
2725
|
+
ngDevMode ? createDebugNameObject(debugName, "error") : void 0
|
|
2726
|
+
);
|
|
2235
2727
|
}
|
|
2236
2728
|
pendingTasks;
|
|
2237
2729
|
/**
|
|
@@ -2248,11 +2740,9 @@ var ResourceImpl = class extends BaseWritableResource {
|
|
|
2248
2740
|
resolvePendingTask = void 0;
|
|
2249
2741
|
destroyed = false;
|
|
2250
2742
|
unregisterOnDestroy;
|
|
2251
|
-
status
|
|
2252
|
-
error
|
|
2253
|
-
|
|
2254
|
-
return stream && !isResolved(stream) ? stream.error : void 0;
|
|
2255
|
-
});
|
|
2743
|
+
status;
|
|
2744
|
+
error;
|
|
2745
|
+
transferState;
|
|
2256
2746
|
/**
|
|
2257
2747
|
* Called either directly via `WritableResource.set` or via `.value.set()`.
|
|
2258
2748
|
*/
|
|
@@ -2272,7 +2762,7 @@ var ResourceImpl = class extends BaseWritableResource {
|
|
|
2272
2762
|
extRequest: state.extRequest,
|
|
2273
2763
|
status: "local",
|
|
2274
2764
|
previousStatus: "local",
|
|
2275
|
-
stream: signal({ value })
|
|
2765
|
+
stream: signal({ value }, ngDevMode ? createDebugNameObject(this.debugName, "stream") : void 0)
|
|
2276
2766
|
});
|
|
2277
2767
|
this.abortInProgressLoad();
|
|
2278
2768
|
}
|
|
@@ -2308,27 +2798,48 @@ var ResourceImpl = class extends BaseWritableResource {
|
|
|
2308
2798
|
let resolvePendingTask = this.resolvePendingTask = this.pendingTasks.add();
|
|
2309
2799
|
const { signal: abortSignal } = this.pendingController = new AbortController();
|
|
2310
2800
|
try {
|
|
2311
|
-
const stream =
|
|
2801
|
+
const stream = untracked2(
|
|
2312
2802
|
() => this.loaderFn({
|
|
2313
2803
|
params: extRequest.request,
|
|
2314
|
-
// TODO(alxhub): cleanup after g3 removal of `request` alias.
|
|
2315
|
-
request: extRequest.request,
|
|
2316
2804
|
abortSignal,
|
|
2317
2805
|
previous: {
|
|
2318
2806
|
status: previousStatus
|
|
2319
2807
|
}
|
|
2320
2808
|
})
|
|
2321
2809
|
);
|
|
2322
|
-
|
|
2323
|
-
|
|
2810
|
+
const shouldDiscard = () => abortSignal.aborted || untracked2(this.extRequest) !== extRequest;
|
|
2811
|
+
if (isSignal2(stream)) {
|
|
2812
|
+
if (shouldDiscard()) {
|
|
2813
|
+
return;
|
|
2814
|
+
}
|
|
2815
|
+
this.state.set({
|
|
2816
|
+
extRequest,
|
|
2817
|
+
status: "resolved",
|
|
2818
|
+
previousStatus: "resolved",
|
|
2819
|
+
stream
|
|
2820
|
+
});
|
|
2821
|
+
const result = untracked2(stream);
|
|
2822
|
+
if (true) {
|
|
2823
|
+
saveToTransferState(result, this.transferCacheKey, this.transferState);
|
|
2824
|
+
}
|
|
2825
|
+
} else {
|
|
2826
|
+
const resolvedStream = await stream;
|
|
2827
|
+
if (shouldDiscard()) {
|
|
2828
|
+
return;
|
|
2829
|
+
}
|
|
2830
|
+
this.state.set({
|
|
2831
|
+
extRequest,
|
|
2832
|
+
status: "resolved",
|
|
2833
|
+
previousStatus: "resolved",
|
|
2834
|
+
stream: resolvedStream
|
|
2835
|
+
});
|
|
2836
|
+
const result = resolvedStream ? untracked2(resolvedStream) : void 0;
|
|
2837
|
+
if (true) {
|
|
2838
|
+
saveToTransferState(result, this.transferCacheKey, this.transferState);
|
|
2839
|
+
}
|
|
2324
2840
|
}
|
|
2325
|
-
this.state.set({
|
|
2326
|
-
extRequest,
|
|
2327
|
-
status: "resolved",
|
|
2328
|
-
previousStatus: "resolved",
|
|
2329
|
-
stream
|
|
2330
|
-
});
|
|
2331
2841
|
} catch (err) {
|
|
2842
|
+
rethrowFatalErrors(err);
|
|
2332
2843
|
if (abortSignal.aborted || untracked2(this.extRequest) !== extRequest) {
|
|
2333
2844
|
return;
|
|
2334
2845
|
}
|
|
@@ -2336,7 +2847,7 @@ var ResourceImpl = class extends BaseWritableResource {
|
|
|
2336
2847
|
extRequest,
|
|
2337
2848
|
status: "resolved",
|
|
2338
2849
|
previousStatus: "error",
|
|
2339
|
-
stream: signal({ error: encapsulateResourceError(err) })
|
|
2850
|
+
stream: signal({ error: encapsulateResourceError(err) }, ngDevMode ? createDebugNameObject(this.debugName, "stream") : void 0)
|
|
2340
2851
|
});
|
|
2341
2852
|
} finally {
|
|
2342
2853
|
resolvePendingTask?.();
|
|
@@ -2350,6 +2861,11 @@ var ResourceImpl = class extends BaseWritableResource {
|
|
|
2350
2861
|
this.resolvePendingTask = void 0;
|
|
2351
2862
|
}
|
|
2352
2863
|
};
|
|
2864
|
+
function saveToTransferState(result, transferCacheKey, transferState) {
|
|
2865
|
+
if (transferCacheKey && transferState && result && isResolved(result)) {
|
|
2866
|
+
transferState.set(transferCacheKey, result.value);
|
|
2867
|
+
}
|
|
2868
|
+
}
|
|
2353
2869
|
function wrapEqualityFn(equal) {
|
|
2354
2870
|
return (a, b) => a === void 0 || b === void 0 ? a === b : equal(a, b);
|
|
2355
2871
|
}
|
|
@@ -2359,9 +2875,9 @@ function getLoader(options) {
|
|
|
2359
2875
|
}
|
|
2360
2876
|
return async (params) => {
|
|
2361
2877
|
try {
|
|
2362
|
-
return signal({ value: await options.loader(params) });
|
|
2878
|
+
return signal({ value: await options.loader(params) }, ngDevMode ? createDebugNameObject(options.debugName, "stream") : void 0);
|
|
2363
2879
|
} catch (err) {
|
|
2364
|
-
return signal({ error: encapsulateResourceError(err) });
|
|
2880
|
+
return signal({ error: encapsulateResourceError(err) }, ngDevMode ? createDebugNameObject(options.debugName, "stream") : void 0);
|
|
2365
2881
|
}
|
|
2366
2882
|
};
|
|
2367
2883
|
}
|
|
@@ -2381,12 +2897,20 @@ function projectStatusOfState(state) {
|
|
|
2381
2897
|
function isResolved(state) {
|
|
2382
2898
|
return state.error === void 0;
|
|
2383
2899
|
}
|
|
2900
|
+
function createDebugNameObject(resourceDebugName, internalSignalDebugName) {
|
|
2901
|
+
return {
|
|
2902
|
+
debugName: `Resource${resourceDebugName ? "#" + resourceDebugName : ""}.${internalSignalDebugName}`
|
|
2903
|
+
};
|
|
2904
|
+
}
|
|
2384
2905
|
function encapsulateResourceError(error) {
|
|
2385
|
-
if (error
|
|
2906
|
+
if (isErrorLike(error)) {
|
|
2386
2907
|
return error;
|
|
2387
2908
|
}
|
|
2388
2909
|
return new ResourceWrappedError(error);
|
|
2389
2910
|
}
|
|
2911
|
+
function isErrorLike(error) {
|
|
2912
|
+
return error instanceof Error || typeof error === "object" && typeof error.name === "string" && typeof error.message === "string";
|
|
2913
|
+
}
|
|
2390
2914
|
var ResourceValueError = class extends Error {
|
|
2391
2915
|
constructor(error) {
|
|
2392
2916
|
super(ngDevMode ? `Resource is currently in an error state (see Error.cause for details): ${error.message}` : error.message, { cause: error });
|
|
@@ -2397,6 +2921,146 @@ var ResourceWrappedError = class extends Error {
|
|
|
2397
2921
|
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 });
|
|
2398
2922
|
}
|
|
2399
2923
|
};
|
|
2924
|
+
function chain(resource2) {
|
|
2925
|
+
switch (resource2.status()) {
|
|
2926
|
+
case "idle":
|
|
2927
|
+
throw ResourceParamsStatus.IDLE;
|
|
2928
|
+
case "error":
|
|
2929
|
+
throw new ResourceDependencyError(resource2);
|
|
2930
|
+
case "loading":
|
|
2931
|
+
case "reloading":
|
|
2932
|
+
throw ResourceParamsStatus.LOADING;
|
|
2933
|
+
}
|
|
2934
|
+
return resource2.value();
|
|
2935
|
+
}
|
|
2936
|
+
var paramsContext = {
|
|
2937
|
+
chain
|
|
2938
|
+
};
|
|
2939
|
+
var inParamsFunction = false;
|
|
2940
|
+
function isInParamsFunction() {
|
|
2941
|
+
return inParamsFunction;
|
|
2942
|
+
}
|
|
2943
|
+
function setInParamsFunction(value) {
|
|
2944
|
+
inParamsFunction = value;
|
|
2945
|
+
}
|
|
2946
|
+
function invalidResourceCreationInParams() {
|
|
2947
|
+
return new RuntimeError(992 /* INVALID_RESOURCE_CREATION_IN_PARAMS */, ngDevMode && `Cannot create a resource inside the \`params\` of another resource`);
|
|
2948
|
+
}
|
|
2949
|
+
function rethrowFatalErrors(error) {
|
|
2950
|
+
if (error instanceof RuntimeError && error.code === 992 /* INVALID_RESOURCE_CREATION_IN_PARAMS */) {
|
|
2951
|
+
throw error;
|
|
2952
|
+
}
|
|
2953
|
+
}
|
|
2954
|
+
|
|
2955
|
+
// src/import/resource/from_snapshots.ts
|
|
2956
|
+
function resourceFromSnapshots(source) {
|
|
2957
|
+
return new SnapshotResource(isSignal2(source) ? source : computed(source));
|
|
2958
|
+
}
|
|
2959
|
+
var SnapshotResource = class {
|
|
2960
|
+
constructor(snapshot) {
|
|
2961
|
+
this.snapshot = snapshot;
|
|
2962
|
+
}
|
|
2963
|
+
get state() {
|
|
2964
|
+
return this.snapshot();
|
|
2965
|
+
}
|
|
2966
|
+
value = computed(() => {
|
|
2967
|
+
if (this.state.status === "error") {
|
|
2968
|
+
throw new ResourceValueError(this.state.error);
|
|
2969
|
+
}
|
|
2970
|
+
return this.state.value;
|
|
2971
|
+
});
|
|
2972
|
+
status = computed(() => this.state.status);
|
|
2973
|
+
error = computed(() => this.state.status === "error" ? this.state.error : void 0);
|
|
2974
|
+
isLoading = computed(() => this.state.status === "loading" || this.state.status === "reloading");
|
|
2975
|
+
isValueDefined = computed(() => this.state.status !== "error" && this.state.value !== void 0);
|
|
2976
|
+
hasValue() {
|
|
2977
|
+
return this.isValueDefined();
|
|
2978
|
+
}
|
|
2979
|
+
};
|
|
2980
|
+
|
|
2981
|
+
// src/import/resource/debounce.ts
|
|
2982
|
+
function debounced(source, wait, options) {
|
|
2983
|
+
if (isInParamsFunction()) {
|
|
2984
|
+
throw invalidResourceCreationInParams();
|
|
2985
|
+
}
|
|
2986
|
+
if (ngDevMode && !options?.injector) {
|
|
2987
|
+
assertInInjectionContext(debounced);
|
|
2988
|
+
}
|
|
2989
|
+
const injector = options?.injector ?? inject2(Injector);
|
|
2990
|
+
let active;
|
|
2991
|
+
let pendingValue;
|
|
2992
|
+
injector.get(DestroyRef).onDestroy(() => {
|
|
2993
|
+
active = void 0;
|
|
2994
|
+
});
|
|
2995
|
+
const state = linkedSignal({
|
|
2996
|
+
source: () => {
|
|
2997
|
+
try {
|
|
2998
|
+
setInParamsFunction(true);
|
|
2999
|
+
return { value: source(), thrown: false };
|
|
3000
|
+
} catch (err) {
|
|
3001
|
+
rethrowFatalErrors(err);
|
|
3002
|
+
return { error: err, thrown: true };
|
|
3003
|
+
} finally {
|
|
3004
|
+
setInParamsFunction(false);
|
|
3005
|
+
}
|
|
3006
|
+
},
|
|
3007
|
+
computation: (res, previous) => {
|
|
3008
|
+
if (previous !== void 0) {
|
|
3009
|
+
return previous.value;
|
|
3010
|
+
}
|
|
3011
|
+
if (res.thrown) {
|
|
3012
|
+
return { status: "error", error: res.error };
|
|
3013
|
+
}
|
|
3014
|
+
return { status: "resolved", value: res.value };
|
|
3015
|
+
}
|
|
3016
|
+
});
|
|
3017
|
+
effect(
|
|
3018
|
+
() => {
|
|
3019
|
+
let value;
|
|
3020
|
+
try {
|
|
3021
|
+
setInParamsFunction(true);
|
|
3022
|
+
value = source();
|
|
3023
|
+
} catch (err) {
|
|
3024
|
+
rethrowFatalErrors(err);
|
|
3025
|
+
state.set({ status: "error", error: err });
|
|
3026
|
+
active = pendingValue = void 0;
|
|
3027
|
+
return;
|
|
3028
|
+
} finally {
|
|
3029
|
+
setInParamsFunction(false);
|
|
3030
|
+
}
|
|
3031
|
+
const currentState = untracked2(state);
|
|
3032
|
+
const equal = options?.equal ?? Object.is;
|
|
3033
|
+
if (currentState.status === "reloading" || currentState.status === "loading") {
|
|
3034
|
+
if (equal(value, pendingValue)) return;
|
|
3035
|
+
} else if (currentState.status === "resolved") {
|
|
3036
|
+
if (equal(value, currentState.value)) return;
|
|
3037
|
+
}
|
|
3038
|
+
const waitFn = typeof wait === "number" ? () => new Promise((resolve) => setTimeout(resolve, wait)) : wait;
|
|
3039
|
+
const result = waitFn(value, currentState);
|
|
3040
|
+
if (result === void 0) {
|
|
3041
|
+
state.set({ status: "resolved", value });
|
|
3042
|
+
active = pendingValue = void 0;
|
|
3043
|
+
} else {
|
|
3044
|
+
if (currentState.status !== "loading" && currentState.status !== "error") {
|
|
3045
|
+
state.set({ status: "loading", value: currentState.value });
|
|
3046
|
+
}
|
|
3047
|
+
active = result;
|
|
3048
|
+
pendingValue = value;
|
|
3049
|
+
result.then(() => {
|
|
3050
|
+
if (active === result) {
|
|
3051
|
+
state.set({ status: "resolved", value });
|
|
3052
|
+
active = pendingValue = void 0;
|
|
3053
|
+
}
|
|
3054
|
+
});
|
|
3055
|
+
}
|
|
3056
|
+
},
|
|
3057
|
+
{ injector }
|
|
3058
|
+
);
|
|
3059
|
+
return resourceFromSnapshots(state);
|
|
3060
|
+
}
|
|
3061
|
+
|
|
3062
|
+
// src/import/interface/type.ts
|
|
3063
|
+
var Type = Function;
|
|
2400
3064
|
|
|
2401
3065
|
// src/import/index.ts
|
|
2402
3066
|
function Injectable(args) {
|
|
@@ -2429,6 +3093,7 @@ function createRootInjector(options) {
|
|
|
2429
3093
|
);
|
|
2430
3094
|
}
|
|
2431
3095
|
export {
|
|
3096
|
+
APP_ID,
|
|
2432
3097
|
ChangeDetectionScheduler,
|
|
2433
3098
|
ChangeDetectionSchedulerImpl,
|
|
2434
3099
|
DecoratorFlags,
|
|
@@ -2436,6 +3101,7 @@ export {
|
|
|
2436
3101
|
EffectScheduler,
|
|
2437
3102
|
EnvironmentInjector,
|
|
2438
3103
|
ErrorHandler,
|
|
3104
|
+
EventEmitter,
|
|
2439
3105
|
INJECTOR_SCOPE,
|
|
2440
3106
|
INTERNAL_APPLICATION_ERROR_HANDLER,
|
|
2441
3107
|
Inject,
|
|
@@ -2449,20 +3115,20 @@ export {
|
|
|
2449
3115
|
NotificationSource,
|
|
2450
3116
|
NullInjector,
|
|
2451
3117
|
Optional,
|
|
2452
|
-
PROVIDED_ZONELESS,
|
|
2453
3118
|
PendingTasks,
|
|
2454
|
-
PendingTasksInternal,
|
|
2455
3119
|
R3Injector,
|
|
3120
|
+
ResourceDependencyError,
|
|
3121
|
+
ResourceParamsStatus,
|
|
2456
3122
|
RetrievingInjector,
|
|
2457
3123
|
RootStaticInjectOptions,
|
|
2458
|
-
SCHEDULE_IN_ROOT_ZONE,
|
|
2459
3124
|
SOURCE,
|
|
2460
3125
|
Self,
|
|
2461
3126
|
SkipSelf,
|
|
2462
3127
|
StaticInjectOptions,
|
|
2463
3128
|
THROW_IF_NOT_FOUND,
|
|
2464
|
-
|
|
2465
|
-
|
|
3129
|
+
TransferState,
|
|
3130
|
+
Type,
|
|
3131
|
+
assertInInjectionContext,
|
|
2466
3132
|
assertNotDestroyed,
|
|
2467
3133
|
assertNotInReactiveContext,
|
|
2468
3134
|
attachInjectFlag,
|
|
@@ -2470,8 +3136,9 @@ export {
|
|
|
2470
3136
|
convertToBitFlags,
|
|
2471
3137
|
createInjector2 as createInjector,
|
|
2472
3138
|
createRootInjector,
|
|
3139
|
+
debounced,
|
|
2473
3140
|
effect,
|
|
2474
|
-
|
|
3141
|
+
forwardRef,
|
|
2475
3142
|
getCurrentInjector,
|
|
2476
3143
|
getInheritedInjectableDef,
|
|
2477
3144
|
getInjectFlag,
|
|
@@ -2480,12 +3147,20 @@ export {
|
|
|
2480
3147
|
getNullInjector,
|
|
2481
3148
|
inject2 as inject,
|
|
2482
3149
|
injectArgs,
|
|
3150
|
+
injectAsync,
|
|
2483
3151
|
injectInjectorOnly,
|
|
2484
3152
|
isInjectable,
|
|
2485
3153
|
isSignal2 as isSignal,
|
|
3154
|
+
isWritableSignal,
|
|
2486
3155
|
linkedSignal,
|
|
3156
|
+
makeStateKey,
|
|
3157
|
+
onIdle,
|
|
3158
|
+
provideIdleServiceWith,
|
|
2487
3159
|
providerToFactory,
|
|
3160
|
+
resolveForwardRef,
|
|
2488
3161
|
resource,
|
|
3162
|
+
resourceFromSnapshots,
|
|
3163
|
+
runInInjectionContext,
|
|
2489
3164
|
setCurrentInjector,
|
|
2490
3165
|
signal,
|
|
2491
3166
|
untracked2 as untracked,
|
|
@@ -2505,11 +3180,4 @@ export {
|
|
|
2505
3180
|
* Use of this source code is governed by an MIT-style license that can be
|
|
2506
3181
|
* found in the LICENSE file at https://angular.dev/license
|
|
2507
3182
|
*/
|
|
2508
|
-
/**
|
|
2509
|
-
* @license
|
|
2510
|
-
* Copyright Google LLC All Rights Reserved.
|
|
2511
|
-
*
|
|
2512
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
2513
|
-
* found in the LICENSE file at https://angular.io/license
|
|
2514
|
-
*/
|
|
2515
3183
|
//# sourceMappingURL=index.mjs.map
|