static-injector 6.3.1 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +5 -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 +139 -0
- package/import/render3/debug/special_providers.d.ts +17 -0
- package/import/render3/errors_di.d.ts +25 -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 +21 -0
- 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/array_utils.d.ts +132 -0
- package/import/util/assert.d.ts +28 -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 +2263 -1224
- package/index.js.map +4 -4
- package/index.mjs +2246 -1218
- 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
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
// script/shim.js
|
|
2
|
+
var ngDevMode = typeof ngDevMode === "undefined" ? true : ngDevMode;
|
|
3
|
+
|
|
1
4
|
// src/import/di/interface/provider.ts
|
|
2
5
|
function isEnvironmentProviders(value) {
|
|
3
6
|
return value && !!value.ɵproviders;
|
|
@@ -15,17 +18,15 @@ function formatRuntimeErrorCode(code) {
|
|
|
15
18
|
}
|
|
16
19
|
function formatRuntimeError(code, message) {
|
|
17
20
|
const fullCode = formatRuntimeErrorCode(code);
|
|
18
|
-
|
|
19
|
-
if (
|
|
21
|
+
let errorMessage = `${fullCode}${message ? ": " + message : ""}`;
|
|
22
|
+
if (ngDevMode && code < 0) {
|
|
23
|
+
const addPeriodSeparator = !errorMessage.match(/[.,;!?\n]$/);
|
|
24
|
+
const separator = addPeriodSeparator ? "." : "";
|
|
25
|
+
errorMessage = `${errorMessage}${separator} Find more at ${"https://v22.angular.dev/errors"}/${fullCode}`;
|
|
20
26
|
}
|
|
21
27
|
return errorMessage;
|
|
22
28
|
}
|
|
23
29
|
|
|
24
|
-
// src/import/render3/definition_factory.ts
|
|
25
|
-
function getFactoryDef(type, throwNotFound) {
|
|
26
|
-
return () => new type();
|
|
27
|
-
}
|
|
28
|
-
|
|
29
30
|
// src/import/util/property.ts
|
|
30
31
|
function getClosureSafeProperty(objWithPropertyToExtract) {
|
|
31
32
|
for (const key in objWithPropertyToExtract) {
|
|
@@ -33,41 +34,7 @@ function getClosureSafeProperty(objWithPropertyToExtract) {
|
|
|
33
34
|
return key;
|
|
34
35
|
}
|
|
35
36
|
}
|
|
36
|
-
throw Error("");
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// src/import/render3/errors_di.ts
|
|
40
|
-
var NG_RUNTIME_ERROR_CODE = getClosureSafeProperty({ ngErrorCode: getClosureSafeProperty });
|
|
41
|
-
var NG_RUNTIME_ERROR_MESSAGE = getClosureSafeProperty({ ngErrorMessage: getClosureSafeProperty });
|
|
42
|
-
var NG_TOKEN_PATH = getClosureSafeProperty({ ngTokenPath: getClosureSafeProperty });
|
|
43
|
-
function cyclicDependencyError(token, path) {
|
|
44
|
-
const message = "";
|
|
45
|
-
return createRuntimeError(message, -200 /* CYCLIC_DI_DEPENDENCY */, path);
|
|
46
|
-
}
|
|
47
|
-
function throwProviderNotFoundError(token, injectorName) {
|
|
48
|
-
const errorMessage = void 0;
|
|
49
|
-
throw new RuntimeError(-201 /* PROVIDER_NOT_FOUND */, errorMessage);
|
|
50
|
-
}
|
|
51
|
-
function createRuntimeError(message, code, path) {
|
|
52
|
-
const error = new RuntimeError(code, message);
|
|
53
|
-
error[NG_RUNTIME_ERROR_CODE] = code;
|
|
54
|
-
error[NG_RUNTIME_ERROR_MESSAGE] = message;
|
|
55
|
-
if (path) {
|
|
56
|
-
error[NG_TOKEN_PATH] = path;
|
|
57
|
-
}
|
|
58
|
-
return error;
|
|
59
|
-
}
|
|
60
|
-
function getRuntimeErrorCode(error) {
|
|
61
|
-
return error[NG_RUNTIME_ERROR_CODE];
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// src/import/render3/fields.ts
|
|
65
|
-
var NG_FACTORY_DEF = getClosureSafeProperty({ ɵfac: getClosureSafeProperty });
|
|
66
|
-
var NG_ENV_ID = getClosureSafeProperty({ __NG_ENV_ID__: getClosureSafeProperty });
|
|
67
|
-
|
|
68
|
-
// src/import/util/empty.ts
|
|
69
|
-
var EMPTY_ARRAY = [];
|
|
70
|
-
if (false) {
|
|
37
|
+
throw Error(typeof ngDevMode !== "undefined" && ngDevMode ? "Could not find renamed property on target object." : "");
|
|
71
38
|
}
|
|
72
39
|
|
|
73
40
|
// src/import/util/stringify.ts
|
|
@@ -97,9 +64,11 @@ function stringify(token) {
|
|
|
97
64
|
var __forward_ref__ = getClosureSafeProperty({ __forward_ref__: getClosureSafeProperty });
|
|
98
65
|
function forwardRef(forwardRefFn) {
|
|
99
66
|
forwardRefFn.__forward_ref__ = forwardRef;
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
67
|
+
if (ngDevMode) {
|
|
68
|
+
forwardRefFn.toString = function() {
|
|
69
|
+
return stringify(this());
|
|
70
|
+
};
|
|
71
|
+
}
|
|
103
72
|
return forwardRefFn;
|
|
104
73
|
}
|
|
105
74
|
function resolveForwardRef(type) {
|
|
@@ -109,1237 +78,1600 @@ function isForwardRef(fn) {
|
|
|
109
78
|
return typeof fn === "function" && fn.hasOwnProperty(__forward_ref__) && fn.__forward_ref__ === forwardRef;
|
|
110
79
|
}
|
|
111
80
|
|
|
112
|
-
// src/
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
return { providers: options.providers || [], imports: options.imports || [] };
|
|
123
|
-
}
|
|
124
|
-
function getInjectableDef(type) {
|
|
125
|
-
return getOwnDefinition(type, NG_PROV_DEF) || { token: type, factory: () => new type(), ...type.injectOptions };
|
|
81
|
+
// src/primitives/signals/src/graph.ts
|
|
82
|
+
var activeConsumer = null;
|
|
83
|
+
var inNotificationPhase = false;
|
|
84
|
+
var epoch = 1;
|
|
85
|
+
var postProducerCreatedFn = null;
|
|
86
|
+
var SIGNAL = /* @__PURE__ */ Symbol("SIGNAL");
|
|
87
|
+
function setActiveConsumer(consumer) {
|
|
88
|
+
const prev = activeConsumer;
|
|
89
|
+
activeConsumer = consumer;
|
|
90
|
+
return prev;
|
|
126
91
|
}
|
|
127
|
-
function
|
|
128
|
-
return
|
|
92
|
+
function getActiveConsumer() {
|
|
93
|
+
return activeConsumer;
|
|
129
94
|
}
|
|
130
|
-
function
|
|
131
|
-
return
|
|
95
|
+
function isInNotificationPhase() {
|
|
96
|
+
return inNotificationPhase;
|
|
132
97
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
98
|
+
var REACTIVE_NODE = {
|
|
99
|
+
version: 0,
|
|
100
|
+
lastCleanEpoch: 0,
|
|
101
|
+
dirty: false,
|
|
102
|
+
producers: void 0,
|
|
103
|
+
producersTail: void 0,
|
|
104
|
+
consumers: void 0,
|
|
105
|
+
consumersTail: void 0,
|
|
106
|
+
recomputing: false,
|
|
107
|
+
consumerAllowSignalWrites: false,
|
|
108
|
+
consumerIsAlwaysLive: false,
|
|
109
|
+
kind: "unknown",
|
|
110
|
+
producerMustRecompute: () => false,
|
|
111
|
+
producerRecomputeValue: () => {
|
|
112
|
+
},
|
|
113
|
+
consumerMarkedDirty: () => {
|
|
114
|
+
},
|
|
115
|
+
consumerOnSignalRead: () => {
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
function producerAccessed(node) {
|
|
119
|
+
if (inNotificationPhase) {
|
|
120
|
+
throw new Error(typeof ngDevMode !== "undefined" && ngDevMode ? `Assertion error: signal read during notification phase` : "");
|
|
121
|
+
}
|
|
122
|
+
if (activeConsumer === null) {
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
activeConsumer.consumerOnSignalRead(node);
|
|
126
|
+
const prevProducerLink = activeConsumer.producersTail;
|
|
127
|
+
if (prevProducerLink !== void 0 && prevProducerLink.producer === node) {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
let nextProducerLink = void 0;
|
|
131
|
+
const isRecomputing = activeConsumer.recomputing;
|
|
132
|
+
if (isRecomputing) {
|
|
133
|
+
nextProducerLink = prevProducerLink !== void 0 ? prevProducerLink.nextProducer : activeConsumer.producers;
|
|
134
|
+
if (nextProducerLink !== void 0 && nextProducerLink.producer === node) {
|
|
135
|
+
activeConsumer.producersTail = nextProducerLink;
|
|
136
|
+
nextProducerLink.lastReadVersion = node.version;
|
|
137
|
+
nextProducerLink.knownValidAtEpoch = epoch;
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
const prevConsumerLink = node.consumersTail;
|
|
142
|
+
if (prevConsumerLink !== void 0 && prevConsumerLink.consumer === activeConsumer && (!isRecomputing || prevConsumerLink.knownValidAtEpoch === epoch)) {
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
const isLive = consumerIsLive(activeConsumer);
|
|
146
|
+
const newLink = {
|
|
147
|
+
producer: node,
|
|
148
|
+
consumer: activeConsumer,
|
|
149
|
+
// instead of eagerly destroying the previous link, we delay until we've finished recomputing
|
|
150
|
+
// the producers list, so that we can destroy all of the old links at once.
|
|
151
|
+
nextProducer: nextProducerLink,
|
|
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,
|
|
158
|
+
lastReadVersion: node.version,
|
|
159
|
+
nextConsumer: void 0
|
|
160
|
+
};
|
|
161
|
+
activeConsumer.producersTail = newLink;
|
|
162
|
+
if (prevProducerLink !== void 0) {
|
|
163
|
+
prevProducerLink.nextProducer = newLink;
|
|
137
164
|
} else {
|
|
138
|
-
|
|
165
|
+
activeConsumer.producers = newLink;
|
|
166
|
+
}
|
|
167
|
+
if (isLive) {
|
|
168
|
+
producerAddLiveConsumer(node, newLink);
|
|
139
169
|
}
|
|
140
170
|
}
|
|
141
|
-
function
|
|
142
|
-
|
|
171
|
+
function producerIncrementEpoch() {
|
|
172
|
+
epoch++;
|
|
143
173
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
// src/import/di/injection_token.ts
|
|
148
|
-
var InjectionToken = class {
|
|
149
|
-
/**
|
|
150
|
-
* @param _desc Description for the token,
|
|
151
|
-
* used only for debugging purposes,
|
|
152
|
-
* it should but does not need to be unique
|
|
153
|
-
* @param options Options for the token's usage, as described above
|
|
154
|
-
*/
|
|
155
|
-
constructor(_desc, options) {
|
|
156
|
-
this._desc = _desc;
|
|
157
|
-
this.ɵprov = void 0;
|
|
158
|
-
if (typeof options === "number") {
|
|
159
|
-
} else if (options !== void 0) {
|
|
160
|
-
this.ɵprov = ɵɵdefineInjectable({
|
|
161
|
-
token: this,
|
|
162
|
-
providedIn: options.providedIn || "root",
|
|
163
|
-
factory: options.factory
|
|
164
|
-
});
|
|
165
|
-
}
|
|
174
|
+
function producerUpdateValueVersion(node) {
|
|
175
|
+
if (consumerIsLive(node) && !node.dirty) {
|
|
176
|
+
return;
|
|
166
177
|
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
ɵprov;
|
|
170
|
-
/**
|
|
171
|
-
* @internal
|
|
172
|
-
*/
|
|
173
|
-
get multi() {
|
|
174
|
-
return this;
|
|
178
|
+
if (!node.dirty && node.lastCleanEpoch === epoch) {
|
|
179
|
+
return;
|
|
175
180
|
}
|
|
176
|
-
|
|
177
|
-
|
|
181
|
+
if (!node.producerMustRecompute(node) && !consumerPollProducersForChange(node)) {
|
|
182
|
+
producerMarkClean(node);
|
|
183
|
+
return;
|
|
178
184
|
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
// src/import/di/initializer_token.ts
|
|
182
|
-
var ENVIRONMENT_INITIALIZER = new InjectionToken("");
|
|
183
|
-
|
|
184
|
-
// src/import/di/interface/injector.ts
|
|
185
|
-
var DecoratorFlags = /* @__PURE__ */ ((DecoratorFlags2) => {
|
|
186
|
-
DecoratorFlags2[DecoratorFlags2["Inject"] = -1] = "Inject";
|
|
187
|
-
return DecoratorFlags2;
|
|
188
|
-
})(DecoratorFlags || {});
|
|
189
|
-
var InternalInjectFlags = /* @__PURE__ */ ((InternalInjectFlags2) => {
|
|
190
|
-
InternalInjectFlags2[InternalInjectFlags2["Default"] = 0] = "Default";
|
|
191
|
-
InternalInjectFlags2[InternalInjectFlags2["Host"] = 1] = "Host";
|
|
192
|
-
InternalInjectFlags2[InternalInjectFlags2["Self"] = 2] = "Self";
|
|
193
|
-
InternalInjectFlags2[InternalInjectFlags2["SkipSelf"] = 4] = "SkipSelf";
|
|
194
|
-
InternalInjectFlags2[InternalInjectFlags2["Optional"] = 8] = "Optional";
|
|
195
|
-
InternalInjectFlags2[InternalInjectFlags2["ForPipe"] = 16] = "ForPipe";
|
|
196
|
-
return InternalInjectFlags2;
|
|
197
|
-
})(InternalInjectFlags || {});
|
|
198
|
-
|
|
199
|
-
// src/import/di/inject_switch.ts
|
|
200
|
-
var _injectImplementation;
|
|
201
|
-
function getInjectImplementation() {
|
|
202
|
-
return _injectImplementation;
|
|
203
|
-
}
|
|
204
|
-
function setInjectImplementation(impl) {
|
|
205
|
-
const previous = _injectImplementation;
|
|
206
|
-
_injectImplementation = impl;
|
|
207
|
-
return previous;
|
|
185
|
+
node.producerRecomputeValue(node);
|
|
186
|
+
producerMarkClean(node);
|
|
208
187
|
}
|
|
209
|
-
function
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
188
|
+
function producerNotifyConsumers(node) {
|
|
189
|
+
if (node.consumers === void 0) {
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
const prev = inNotificationPhase;
|
|
193
|
+
inNotificationPhase = true;
|
|
194
|
+
try {
|
|
195
|
+
for (let link = node.consumers; link !== void 0; link = link.nextConsumer) {
|
|
196
|
+
const consumer = link.consumer;
|
|
197
|
+
if (!consumer.dirty) {
|
|
198
|
+
consumerMarkDirty(consumer);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
} finally {
|
|
202
|
+
inNotificationPhase = prev;
|
|
213
203
|
}
|
|
214
|
-
if (flags & 8 /* Optional */) return null;
|
|
215
|
-
if (notFoundValue !== void 0) return notFoundValue;
|
|
216
|
-
throwProviderNotFoundError(token, "Injector");
|
|
217
204
|
}
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
var _currentInjector = void 0;
|
|
221
|
-
function getCurrentInjector() {
|
|
222
|
-
return _currentInjector;
|
|
205
|
+
function producerUpdatesAllowed() {
|
|
206
|
+
return activeConsumer?.consumerAllowSignalWrites !== false;
|
|
223
207
|
}
|
|
224
|
-
function
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
208
|
+
function consumerMarkDirty(node) {
|
|
209
|
+
node.dirty = true;
|
|
210
|
+
producerNotifyConsumers(node);
|
|
211
|
+
node.consumerMarkedDirty?.(node);
|
|
228
212
|
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
function isNotFound(e) {
|
|
233
|
-
return e === NOT_FOUND || e?.name === "ɵNotFound";
|
|
213
|
+
function producerMarkClean(node) {
|
|
214
|
+
node.dirty = false;
|
|
215
|
+
node.lastCleanEpoch = epoch;
|
|
234
216
|
}
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
const flags = convertToBitFlags(options) || 0 /* Default */;
|
|
246
|
-
try {
|
|
247
|
-
return this.injector.get(
|
|
248
|
-
token,
|
|
249
|
-
// When a dependency is requested with an optional flag, DI returns null as the default value.
|
|
250
|
-
flags & 8 /* Optional */ ? null : THROW_IF_NOT_FOUND,
|
|
251
|
-
flags
|
|
252
|
-
);
|
|
253
|
-
} catch (e) {
|
|
254
|
-
if (isNotFound(e)) {
|
|
255
|
-
return e;
|
|
256
|
-
}
|
|
257
|
-
throw e;
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
};
|
|
261
|
-
var NG_TEMP_TOKEN_PATH = "ngTempTokenPath";
|
|
262
|
-
var NEW_LINE = /\n/gm;
|
|
263
|
-
var NO_NEW_LINE = "ɵ";
|
|
264
|
-
var SOURCE = "__source";
|
|
265
|
-
function injectInjectorOnly(token, flags = 0 /* Default */) {
|
|
266
|
-
const currentInjector = getCurrentInjector();
|
|
267
|
-
if (currentInjector === void 0) {
|
|
268
|
-
throw new RuntimeError(-203 /* MISSING_INJECTION_CONTEXT */, void 0);
|
|
269
|
-
} else if (currentInjector === null) {
|
|
270
|
-
return injectRootLimpMode(token, void 0, flags);
|
|
271
|
-
} else {
|
|
272
|
-
const options = convertToInjectOptions(flags);
|
|
273
|
-
const value = currentInjector.retrieve(token, options);
|
|
274
|
-
if (isNotFound(value)) {
|
|
275
|
-
if (options.optional) {
|
|
276
|
-
return null;
|
|
277
|
-
}
|
|
278
|
-
throw value;
|
|
217
|
+
function consumerBeforeComputation(node) {
|
|
218
|
+
if (node) resetConsumerBeforeComputation(node);
|
|
219
|
+
return setActiveConsumer(node);
|
|
220
|
+
}
|
|
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;
|
|
279
227
|
}
|
|
280
|
-
return value;
|
|
281
228
|
}
|
|
229
|
+
node.producersTail = void 0;
|
|
230
|
+
node.recomputing = true;
|
|
282
231
|
}
|
|
283
|
-
function
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
function ɵɵinvalidFactoryDep(index) {
|
|
287
|
-
throw new RuntimeError(202 /* INVALID_FACTORY_DEPENDENCY */, void 0);
|
|
288
|
-
}
|
|
289
|
-
function inject2(token, options) {
|
|
290
|
-
return ɵɵinject(token, convertToBitFlags(options));
|
|
232
|
+
function consumerAfterComputation(node, prevConsumer) {
|
|
233
|
+
setActiveConsumer(prevConsumer);
|
|
234
|
+
if (node) finalizeConsumerAfterComputation(node);
|
|
291
235
|
}
|
|
292
|
-
function
|
|
293
|
-
|
|
294
|
-
|
|
236
|
+
function finalizeConsumerAfterComputation(node) {
|
|
237
|
+
node.recomputing = false;
|
|
238
|
+
const producersTail = node.producersTail;
|
|
239
|
+
let toRemove = producersTail !== void 0 ? producersTail.nextProducer : node.producers;
|
|
240
|
+
if (toRemove !== void 0) {
|
|
241
|
+
if (consumerIsLive(node)) {
|
|
242
|
+
do {
|
|
243
|
+
toRemove = producerRemoveLiveConsumerLink(toRemove);
|
|
244
|
+
} while (toRemove !== void 0);
|
|
245
|
+
}
|
|
246
|
+
if (producersTail !== void 0) {
|
|
247
|
+
producersTail.nextProducer = void 0;
|
|
248
|
+
} else {
|
|
249
|
+
node.producers = void 0;
|
|
250
|
+
}
|
|
295
251
|
}
|
|
296
|
-
return 0 /* Default */ | // comment to force a line break in the formatter
|
|
297
|
-
(flags.optional && 8 /* Optional */) | 0 | (flags.self && 2 /* Self */) | (flags.skipSelf && 4 /* SkipSelf */);
|
|
298
|
-
}
|
|
299
|
-
function convertToInjectOptions(flags) {
|
|
300
|
-
return {
|
|
301
|
-
optional: !!(flags & 8 /* Optional */),
|
|
302
|
-
host: !!(flags & 1 /* Host */),
|
|
303
|
-
self: !!(flags & 2 /* Self */),
|
|
304
|
-
skipSelf: !!(flags & 4 /* SkipSelf */)
|
|
305
|
-
};
|
|
306
252
|
}
|
|
307
|
-
function
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
const
|
|
311
|
-
if (
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
for (let j = 0; j < arg.length; j++) {
|
|
318
|
-
const meta = arg[j];
|
|
319
|
-
const flag = getInjectFlag(meta);
|
|
320
|
-
if (typeof flag === "number") {
|
|
321
|
-
if (flag === -1 /* Inject */) {
|
|
322
|
-
type = meta.token;
|
|
323
|
-
} else {
|
|
324
|
-
flags |= flag;
|
|
325
|
-
}
|
|
326
|
-
} else {
|
|
327
|
-
type = meta;
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
args.push(ɵɵinject(type, flags));
|
|
331
|
-
} else {
|
|
332
|
-
args.push(ɵɵinject(arg));
|
|
253
|
+
function consumerPollProducersForChange(node) {
|
|
254
|
+
for (let link = node.producers; link !== void 0; link = link.nextProducer) {
|
|
255
|
+
const producer = link.producer;
|
|
256
|
+
const seenVersion = link.lastReadVersion;
|
|
257
|
+
if (seenVersion !== producer.version) {
|
|
258
|
+
return true;
|
|
259
|
+
}
|
|
260
|
+
producerUpdateValueVersion(producer);
|
|
261
|
+
if (seenVersion !== producer.version) {
|
|
262
|
+
return true;
|
|
333
263
|
}
|
|
334
264
|
}
|
|
335
|
-
return
|
|
265
|
+
return false;
|
|
336
266
|
}
|
|
337
|
-
function
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
267
|
+
function consumerDestroy(node) {
|
|
268
|
+
if (consumerIsLive(node)) {
|
|
269
|
+
let link = node.producers;
|
|
270
|
+
while (link !== void 0) {
|
|
271
|
+
link = producerRemoveLiveConsumerLink(link);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
node.producers = void 0;
|
|
275
|
+
node.producersTail = void 0;
|
|
276
|
+
node.consumers = void 0;
|
|
277
|
+
node.consumersTail = void 0;
|
|
341
278
|
}
|
|
342
|
-
function
|
|
343
|
-
|
|
279
|
+
function producerAddLiveConsumer(node, link) {
|
|
280
|
+
const consumersTail = node.consumersTail;
|
|
281
|
+
const wasLive = consumerIsLive(node);
|
|
282
|
+
if (consumersTail !== void 0) {
|
|
283
|
+
link.nextConsumer = consumersTail.nextConsumer;
|
|
284
|
+
consumersTail.nextConsumer = link;
|
|
285
|
+
} else {
|
|
286
|
+
link.nextConsumer = void 0;
|
|
287
|
+
node.consumers = link;
|
|
288
|
+
}
|
|
289
|
+
link.prevConsumer = consumersTail;
|
|
290
|
+
node.consumersTail = link;
|
|
291
|
+
if (!wasLive) {
|
|
292
|
+
for (let link2 = node.producers; link2 !== void 0; link2 = link2.nextProducer) {
|
|
293
|
+
producerAddLiveConsumer(link2.producer, link2);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
344
296
|
}
|
|
345
|
-
function
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
297
|
+
function producerRemoveLiveConsumerLink(link) {
|
|
298
|
+
const producer = link.producer;
|
|
299
|
+
const nextProducer = link.nextProducer;
|
|
300
|
+
const nextConsumer = link.nextConsumer;
|
|
301
|
+
const prevConsumer = link.prevConsumer;
|
|
302
|
+
link.nextConsumer = void 0;
|
|
303
|
+
link.prevConsumer = void 0;
|
|
304
|
+
if (nextConsumer !== void 0) {
|
|
305
|
+
nextConsumer.prevConsumer = prevConsumer;
|
|
306
|
+
} else {
|
|
307
|
+
producer.consumersTail = prevConsumer;
|
|
308
|
+
}
|
|
309
|
+
if (prevConsumer !== void 0) {
|
|
310
|
+
prevConsumer.nextConsumer = nextConsumer;
|
|
311
|
+
} else {
|
|
312
|
+
producer.consumers = nextConsumer;
|
|
313
|
+
if (!consumerIsLive(producer)) {
|
|
314
|
+
let producerLink = producer.producers;
|
|
315
|
+
while (producerLink !== void 0) {
|
|
316
|
+
producerLink = producerRemoveLiveConsumerLink(producerLink);
|
|
356
317
|
}
|
|
357
318
|
}
|
|
358
|
-
context = `{${parts.join(", ")}}`;
|
|
359
319
|
}
|
|
360
|
-
return
|
|
320
|
+
return nextProducer;
|
|
321
|
+
}
|
|
322
|
+
function consumerIsLive(node) {
|
|
323
|
+
return node.consumerIsAlwaysLive || node.consumers !== void 0;
|
|
324
|
+
}
|
|
325
|
+
function runPostProducerCreatedFn(node) {
|
|
326
|
+
postProducerCreatedFn?.(node);
|
|
361
327
|
}
|
|
362
328
|
|
|
363
|
-
// src/
|
|
364
|
-
var
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
329
|
+
// src/primitives/signals/src/formatter.ts
|
|
330
|
+
var formatter = {
|
|
331
|
+
/**
|
|
332
|
+
* If the function returns `null`, the formatter is not used for this reference
|
|
333
|
+
*/
|
|
334
|
+
header: (sig, config) => {
|
|
335
|
+
if (!isSignal(sig) || config?.ngSkipFormatting) return null;
|
|
336
|
+
let value;
|
|
337
|
+
try {
|
|
338
|
+
value = sig();
|
|
339
|
+
} catch (e) {
|
|
340
|
+
return ["span", `Signal(⚠️ Error)${e.message ? `: ${e.message}` : ""}`];
|
|
341
|
+
}
|
|
342
|
+
const kind = "computation" in sig[SIGNAL] ? "Computed" : "Signal";
|
|
343
|
+
const isPrimitive = value === null || !Array.isArray(value) && typeof value !== "object";
|
|
344
|
+
return [
|
|
345
|
+
"span",
|
|
346
|
+
{},
|
|
347
|
+
["span", {}, `${kind}(`],
|
|
348
|
+
(() => {
|
|
349
|
+
if (isSignal(value)) {
|
|
350
|
+
return formatter.header(value, config);
|
|
351
|
+
} else if (isPrimitive && value !== void 0 && typeof value !== "function") {
|
|
352
|
+
return ["object", { object: value }];
|
|
353
|
+
} else {
|
|
354
|
+
return prettifyPreview(value);
|
|
355
|
+
}
|
|
356
|
+
})(),
|
|
357
|
+
["span", {}, `)`]
|
|
358
|
+
];
|
|
359
|
+
},
|
|
360
|
+
hasBody: (sig, config) => {
|
|
361
|
+
if (!isSignal(sig)) return false;
|
|
362
|
+
try {
|
|
363
|
+
sig();
|
|
364
|
+
} catch {
|
|
365
|
+
return false;
|
|
383
366
|
}
|
|
384
|
-
return
|
|
367
|
+
return !config?.ngSkipFormatting;
|
|
368
|
+
},
|
|
369
|
+
body: (sig, config) => {
|
|
370
|
+
const color = "var(--sys-color-primary)";
|
|
371
|
+
return [
|
|
372
|
+
"div",
|
|
373
|
+
{ style: `background: #FFFFFF10; padding-left: 4px; padding-top: 2px; padding-bottom: 2px;` },
|
|
374
|
+
["div", { style: `color: ${color}` }, "Signal value: "],
|
|
375
|
+
["div", { style: `padding-left: .5rem;` }, ["object", { object: sig(), config }]],
|
|
376
|
+
["div", { style: `color: ${color}` }, "Signal function: "],
|
|
377
|
+
["div", { style: `padding-left: .5rem;` }, ["object", { object: sig, config: { ...config, ngSkipFormatting: true } }]]
|
|
378
|
+
];
|
|
385
379
|
}
|
|
386
380
|
};
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
}
|
|
396
|
-
function
|
|
397
|
-
|
|
381
|
+
function prettifyPreview(value) {
|
|
382
|
+
if (value === null) return "null";
|
|
383
|
+
if (Array.isArray(value)) return `Array(${value.length})`;
|
|
384
|
+
if (value instanceof Element) return `<${value.tagName.toLowerCase()}>`;
|
|
385
|
+
if (value instanceof URL) return `URL`;
|
|
386
|
+
switch (typeof value) {
|
|
387
|
+
case "undefined": {
|
|
388
|
+
return "undefined";
|
|
389
|
+
}
|
|
390
|
+
case "function": {
|
|
391
|
+
if ("prototype" in value) {
|
|
392
|
+
return "class";
|
|
393
|
+
} else {
|
|
394
|
+
return "() => {…}";
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
case "object": {
|
|
398
|
+
if (value.constructor.name === "Object") {
|
|
399
|
+
return "{…}";
|
|
400
|
+
} else {
|
|
401
|
+
return `${value.constructor.name} {}`;
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
default: {
|
|
405
|
+
return ["object", { object: value, config: { ngSkipFormatting: true } }];
|
|
406
|
+
}
|
|
407
|
+
}
|
|
398
408
|
}
|
|
399
|
-
function
|
|
400
|
-
return
|
|
409
|
+
function isSignal(value) {
|
|
410
|
+
return value[SIGNAL] !== void 0;
|
|
401
411
|
}
|
|
402
|
-
function
|
|
403
|
-
|
|
412
|
+
function installDevToolsSignalFormatter() {
|
|
413
|
+
globalThis.devtoolsFormatters ??= [];
|
|
414
|
+
if (!globalThis.devtoolsFormatters.some((f) => f === formatter)) {
|
|
415
|
+
globalThis.devtoolsFormatters.push(formatter);
|
|
416
|
+
}
|
|
404
417
|
}
|
|
405
418
|
|
|
406
|
-
// src/
|
|
407
|
-
|
|
419
|
+
// src/primitives/signals/src/equality.ts
|
|
420
|
+
function defaultEquals(a, b) {
|
|
421
|
+
return Object.is(a, b);
|
|
422
|
+
}
|
|
408
423
|
|
|
409
|
-
// src/
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
NULL_INJECTOR = new NullInjector();
|
|
424
|
+
// src/primitives/signals/src/computed.ts
|
|
425
|
+
function createComputed(computation, equal) {
|
|
426
|
+
const node = Object.create(COMPUTED_NODE);
|
|
427
|
+
node.computation = computation;
|
|
428
|
+
if (equal !== void 0) {
|
|
429
|
+
node.equal = equal;
|
|
416
430
|
}
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
constructor(providers, parent, source, scopes) {
|
|
423
|
-
super();
|
|
424
|
-
this.parent = parent;
|
|
425
|
-
this.source = source;
|
|
426
|
-
this.scopes = scopes;
|
|
427
|
-
forEachSingleProvider(providers, (provider) => this.processProvider(provider));
|
|
428
|
-
this.records.set(INJECTOR, makeRecord(void 0, this));
|
|
429
|
-
if (scopes.has("environment")) {
|
|
430
|
-
this.records.set(EnvironmentInjector, makeRecord(void 0, this));
|
|
431
|
-
}
|
|
432
|
-
const record = this.records.get(INJECTOR_SCOPE);
|
|
433
|
-
if (record != null && typeof record.value === "string") {
|
|
434
|
-
this.scopes.add(record.value);
|
|
431
|
+
const computed2 = () => {
|
|
432
|
+
producerUpdateValueVersion(node);
|
|
433
|
+
producerAccessed(node);
|
|
434
|
+
if (node.value === ERRORED) {
|
|
435
|
+
throw node.error;
|
|
435
436
|
}
|
|
436
|
-
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
* to prevent further searches.
|
|
442
|
-
*/
|
|
443
|
-
records = /* @__PURE__ */ new Map();
|
|
444
|
-
/**
|
|
445
|
-
* Set of values instantiated by this injector which contain `ngOnDestroy` lifecycle hooks.
|
|
446
|
-
*/
|
|
447
|
-
_ngOnDestroyHooks = /* @__PURE__ */ new Set();
|
|
448
|
-
_onDestroyHooks = [];
|
|
449
|
-
/**
|
|
450
|
-
* Flag indicating that this injector was previously destroyed.
|
|
451
|
-
*/
|
|
452
|
-
get destroyed() {
|
|
453
|
-
return this._destroyed;
|
|
437
|
+
return node.value;
|
|
438
|
+
};
|
|
439
|
+
computed2[SIGNAL] = node;
|
|
440
|
+
if (typeof ngDevMode !== "undefined" && ngDevMode) {
|
|
441
|
+
computed2.toString = () => `[Computed${node.debugName ? " (" + node.debugName + ")" : ""}: ${String(node.value)}]`;
|
|
454
442
|
}
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
443
|
+
runPostProducerCreatedFn(node);
|
|
444
|
+
return computed2;
|
|
445
|
+
}
|
|
446
|
+
var UNSET = /* @__PURE__ */ Symbol("UNSET");
|
|
447
|
+
var COMPUTING = /* @__PURE__ */ Symbol("COMPUTING");
|
|
448
|
+
var ERRORED = /* @__PURE__ */ Symbol("ERRORED");
|
|
449
|
+
var COMPUTED_NODE = /* @__PURE__ */ (() => ({
|
|
450
|
+
...REACTIVE_NODE,
|
|
451
|
+
value: UNSET,
|
|
452
|
+
dirty: true,
|
|
453
|
+
error: null,
|
|
454
|
+
equal: defaultEquals,
|
|
455
|
+
kind: "computed",
|
|
456
|
+
producerMustRecompute(node) {
|
|
457
|
+
return node.value === UNSET || node.value === COMPUTING;
|
|
458
|
+
},
|
|
459
|
+
producerRecomputeValue(node) {
|
|
460
|
+
if (node.value === COMPUTING) {
|
|
461
|
+
throw new Error(typeof ngDevMode !== "undefined" && ngDevMode ? "Detected cycle in computations." : "");
|
|
471
462
|
}
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
* hook was found.
|
|
478
|
-
*/
|
|
479
|
-
destroy() {
|
|
480
|
-
assertNotDestroyed(this);
|
|
481
|
-
this._destroyed = true;
|
|
463
|
+
const oldValue = node.value;
|
|
464
|
+
node.value = COMPUTING;
|
|
465
|
+
const prevConsumer = consumerBeforeComputation(node);
|
|
466
|
+
let newValue;
|
|
467
|
+
let wasEqual = false;
|
|
482
468
|
try {
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
hook();
|
|
490
|
-
}
|
|
469
|
+
newValue = node.computation();
|
|
470
|
+
setActiveConsumer(null);
|
|
471
|
+
wasEqual = oldValue !== UNSET && oldValue !== ERRORED && newValue !== ERRORED && node.equal(oldValue, newValue);
|
|
472
|
+
} catch (err) {
|
|
473
|
+
newValue = ERRORED;
|
|
474
|
+
node.error = err;
|
|
491
475
|
} finally {
|
|
492
|
-
|
|
493
|
-
this._ngOnDestroyHooks.clear();
|
|
494
|
-
this.injectorDefTypes.clear();
|
|
495
|
-
}
|
|
496
|
-
}
|
|
497
|
-
onDestroy(callback) {
|
|
498
|
-
assertNotDestroyed(this);
|
|
499
|
-
this._onDestroyHooks.push(callback);
|
|
500
|
-
return () => this.removeOnDestroy(callback);
|
|
501
|
-
}
|
|
502
|
-
runInContext(fn) {
|
|
503
|
-
assertNotDestroyed(this);
|
|
504
|
-
const previousInjector = setCurrentInjector(this);
|
|
505
|
-
const previousInjectImplementation = setInjectImplementation(void 0);
|
|
506
|
-
if (false) {
|
|
476
|
+
consumerAfterComputation(node, prevConsumer);
|
|
507
477
|
}
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
setCurrentInjector(previousInjector);
|
|
512
|
-
setInjectImplementation(previousInjectImplementation);
|
|
478
|
+
if (wasEqual) {
|
|
479
|
+
node.value = oldValue;
|
|
480
|
+
return;
|
|
513
481
|
}
|
|
482
|
+
node.value = newValue;
|
|
483
|
+
node.version++;
|
|
514
484
|
}
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
record = makeRecord(injectableDefOrInjectorDefFactory(token), NOT_YET);
|
|
534
|
-
} else {
|
|
535
|
-
record = null;
|
|
536
|
-
}
|
|
537
|
-
this.records.set(token, record);
|
|
538
|
-
}
|
|
539
|
-
if (record != null) {
|
|
540
|
-
return this.hydrate(token, record, flags);
|
|
541
|
-
}
|
|
542
|
-
}
|
|
543
|
-
const nextInjector = !(flags & 2 /* Self */) ? this.parent : getNullInjector();
|
|
544
|
-
notFoundValue = flags & 8 /* Optional */ && notFoundValue === THROW_IF_NOT_FOUND ? null : notFoundValue;
|
|
545
|
-
return nextInjector.get(token, notFoundValue);
|
|
546
|
-
} catch (error) {
|
|
547
|
-
const errorCode = getRuntimeErrorCode(error);
|
|
548
|
-
if (errorCode === -200 /* CYCLIC_DI_DEPENDENCY */ || errorCode === -201 /* PROVIDER_NOT_FOUND */) {
|
|
549
|
-
if (false) {
|
|
550
|
-
} else {
|
|
551
|
-
throw new RuntimeError(errorCode, null);
|
|
552
|
-
}
|
|
553
|
-
} else {
|
|
554
|
-
throw error;
|
|
555
|
-
}
|
|
556
|
-
} finally {
|
|
557
|
-
setInjectImplementation(previousInjectImplementation);
|
|
558
|
-
setCurrentInjector(previousInjector);
|
|
559
|
-
}
|
|
485
|
+
}))();
|
|
486
|
+
|
|
487
|
+
// src/primitives/signals/src/errors.ts
|
|
488
|
+
function defaultThrowError() {
|
|
489
|
+
throw new Error();
|
|
490
|
+
}
|
|
491
|
+
var throwInvalidWriteToSignalErrorFn = defaultThrowError;
|
|
492
|
+
function throwInvalidWriteToSignalError(node) {
|
|
493
|
+
throwInvalidWriteToSignalErrorFn(node);
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
// src/primitives/signals/src/signal.ts
|
|
497
|
+
var postSignalSetFn = null;
|
|
498
|
+
function createSignal(initialValue, equal) {
|
|
499
|
+
const node = Object.create(SIGNAL_NODE);
|
|
500
|
+
node.value = initialValue;
|
|
501
|
+
if (equal !== void 0) {
|
|
502
|
+
node.equal = equal;
|
|
560
503
|
}
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
if (false) {
|
|
566
|
-
}
|
|
567
|
-
try {
|
|
568
|
-
const initializers = this.get(ENVIRONMENT_INITIALIZER, EMPTY_ARRAY, { self: true });
|
|
569
|
-
if (false) {
|
|
570
|
-
}
|
|
571
|
-
for (const initializer of initializers) {
|
|
572
|
-
initializer();
|
|
573
|
-
}
|
|
574
|
-
} finally {
|
|
575
|
-
setCurrentInjector(previousInjector);
|
|
576
|
-
setInjectImplementation(previousInjectImplementation);
|
|
577
|
-
}
|
|
504
|
+
const getter = () => signalGetFn(node);
|
|
505
|
+
getter[SIGNAL] = node;
|
|
506
|
+
if (typeof ngDevMode !== "undefined" && ngDevMode) {
|
|
507
|
+
getter.toString = () => `[Signal${node.debugName ? " (" + node.debugName + ")" : ""}: ${String(node.value)}]`;
|
|
578
508
|
}
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
509
|
+
runPostProducerCreatedFn(node);
|
|
510
|
+
const set = (newValue) => signalSetFn(node, newValue);
|
|
511
|
+
const update = (updateFn) => signalUpdateFn(node, updateFn);
|
|
512
|
+
return [getter, set, update];
|
|
513
|
+
}
|
|
514
|
+
function signalGetFn(node) {
|
|
515
|
+
producerAccessed(node);
|
|
516
|
+
return node.value;
|
|
517
|
+
}
|
|
518
|
+
function signalSetFn(node, newValue) {
|
|
519
|
+
if (!producerUpdatesAllowed()) {
|
|
520
|
+
throwInvalidWriteToSignalError(node);
|
|
586
521
|
}
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
processProvider(provider) {
|
|
591
|
-
provider = resolveForwardRef(provider);
|
|
592
|
-
let token = isTypeProvider(provider) ? provider : resolveForwardRef(provider && provider.provide);
|
|
593
|
-
const record = providerToRecord(provider);
|
|
594
|
-
if (false) {
|
|
595
|
-
}
|
|
596
|
-
if (!isTypeProvider(provider) && provider.multi === true) {
|
|
597
|
-
let multiRecord = this.records.get(token);
|
|
598
|
-
if (multiRecord) {
|
|
599
|
-
if (false) {
|
|
600
|
-
}
|
|
601
|
-
} else {
|
|
602
|
-
multiRecord = makeRecord(void 0, NOT_YET, true);
|
|
603
|
-
multiRecord.factory = () => injectArgs(multiRecord.multi);
|
|
604
|
-
this.records.set(token, multiRecord);
|
|
605
|
-
}
|
|
606
|
-
token = provider;
|
|
607
|
-
multiRecord.multi.push(provider);
|
|
608
|
-
} else {
|
|
609
|
-
if (false) {
|
|
610
|
-
}
|
|
611
|
-
}
|
|
612
|
-
this.records.set(token, record);
|
|
522
|
+
if (!node.equal(node.value, newValue)) {
|
|
523
|
+
node.value = newValue;
|
|
524
|
+
signalValueChanged(node);
|
|
613
525
|
}
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
} else if (record.value === NOT_YET) {
|
|
619
|
-
record.value = CIRCULAR;
|
|
620
|
-
if (false) {
|
|
621
|
-
} else {
|
|
622
|
-
record.value = record.factory(void 0, flags);
|
|
623
|
-
}
|
|
624
|
-
}
|
|
625
|
-
if (typeof record.value === "object" && record.value && hasOnDestroy(record.value)) {
|
|
626
|
-
this._ngOnDestroyHooks.add(record.value);
|
|
627
|
-
}
|
|
628
|
-
return record.value;
|
|
629
|
-
} finally {
|
|
630
|
-
}
|
|
526
|
+
}
|
|
527
|
+
function signalUpdateFn(node, updater) {
|
|
528
|
+
if (!producerUpdatesAllowed()) {
|
|
529
|
+
throwInvalidWriteToSignalError(node);
|
|
631
530
|
}
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
531
|
+
signalSetFn(node, updater(node.value));
|
|
532
|
+
}
|
|
533
|
+
var SIGNAL_NODE = /* @__PURE__ */ (() => ({
|
|
534
|
+
...REACTIVE_NODE,
|
|
535
|
+
equal: defaultEquals,
|
|
536
|
+
value: void 0,
|
|
537
|
+
kind: "signal"
|
|
538
|
+
}))();
|
|
539
|
+
function signalValueChanged(node) {
|
|
540
|
+
node.version++;
|
|
541
|
+
producerIncrementEpoch();
|
|
542
|
+
producerNotifyConsumers(node);
|
|
543
|
+
postSignalSetFn?.(node);
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
// src/primitives/signals/src/linked_signal.ts
|
|
547
|
+
function createLinkedSignal(sourceFn, computationFn, equalityFn) {
|
|
548
|
+
const node = Object.create(LINKED_SIGNAL_NODE);
|
|
549
|
+
node.source = sourceFn;
|
|
550
|
+
node.computation = computationFn;
|
|
551
|
+
if (equalityFn != void 0) {
|
|
552
|
+
node.equal = equalityFn;
|
|
642
553
|
}
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
554
|
+
const linkedSignalGetter = () => {
|
|
555
|
+
producerUpdateValueVersion(node);
|
|
556
|
+
producerAccessed(node);
|
|
557
|
+
if (node.value === ERRORED) {
|
|
558
|
+
throw node.error;
|
|
647
559
|
}
|
|
560
|
+
return node.value;
|
|
561
|
+
};
|
|
562
|
+
const getter = linkedSignalGetter;
|
|
563
|
+
getter[SIGNAL] = node;
|
|
564
|
+
if (typeof ngDevMode !== "undefined" && ngDevMode) {
|
|
565
|
+
getter.toString = () => `[LinkedSignal${node.debugName ? " (" + node.debugName + ")" : ""}: ${String(node.value)}]`;
|
|
648
566
|
}
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
567
|
+
runPostProducerCreatedFn(node);
|
|
568
|
+
return getter;
|
|
569
|
+
}
|
|
570
|
+
function linkedSignalSetFn(node, newValue) {
|
|
571
|
+
producerUpdateValueVersion(node);
|
|
572
|
+
signalSetFn(node, newValue);
|
|
573
|
+
producerMarkClean(node);
|
|
574
|
+
}
|
|
575
|
+
function linkedSignalUpdateFn(node, updater) {
|
|
576
|
+
producerUpdateValueVersion(node);
|
|
577
|
+
if (node.value === ERRORED) {
|
|
578
|
+
throw node.error;
|
|
655
579
|
}
|
|
656
|
-
|
|
657
|
-
|
|
580
|
+
signalUpdateFn(node, updater);
|
|
581
|
+
producerMarkClean(node);
|
|
582
|
+
}
|
|
583
|
+
var LINKED_SIGNAL_NODE = /* @__PURE__ */ (() => ({
|
|
584
|
+
...REACTIVE_NODE,
|
|
585
|
+
value: UNSET,
|
|
586
|
+
dirty: true,
|
|
587
|
+
error: null,
|
|
588
|
+
equal: defaultEquals,
|
|
589
|
+
kind: "linkedSignal",
|
|
590
|
+
producerMustRecompute(node) {
|
|
591
|
+
return node.value === UNSET || node.value === COMPUTING;
|
|
592
|
+
},
|
|
593
|
+
producerRecomputeValue(node) {
|
|
594
|
+
if (node.value === COMPUTING) {
|
|
595
|
+
throw new Error(typeof ngDevMode !== "undefined" && ngDevMode ? "Detected cycle in computations." : "");
|
|
596
|
+
}
|
|
597
|
+
const oldValue = node.value;
|
|
598
|
+
node.value = COMPUTING;
|
|
599
|
+
const prevConsumer = consumerBeforeComputation(node);
|
|
600
|
+
let newValue;
|
|
601
|
+
let wasEqual = false;
|
|
602
|
+
try {
|
|
603
|
+
const newSourceValue = node.source();
|
|
604
|
+
const oldValueValid = oldValue !== UNSET && oldValue !== ERRORED;
|
|
605
|
+
const prev = oldValueValid ? {
|
|
606
|
+
source: node.sourceValue,
|
|
607
|
+
value: oldValue
|
|
608
|
+
} : void 0;
|
|
609
|
+
newValue = node.computation(newSourceValue, prev);
|
|
610
|
+
node.sourceValue = newSourceValue;
|
|
611
|
+
setActiveConsumer(null);
|
|
612
|
+
wasEqual = oldValueValid && newValue !== ERRORED && node.equal(oldValue, newValue);
|
|
613
|
+
} catch (err) {
|
|
614
|
+
newValue = ERRORED;
|
|
615
|
+
node.error = err;
|
|
616
|
+
} finally {
|
|
617
|
+
consumerAfterComputation(node, prevConsumer);
|
|
618
|
+
}
|
|
619
|
+
if (wasEqual) {
|
|
620
|
+
node.value = oldValue;
|
|
621
|
+
return;
|
|
622
|
+
}
|
|
623
|
+
node.value = newValue;
|
|
624
|
+
node.version++;
|
|
658
625
|
}
|
|
659
|
-
|
|
660
|
-
|
|
626
|
+
}))();
|
|
627
|
+
|
|
628
|
+
// src/primitives/signals/src/untracked.ts
|
|
629
|
+
function untracked(nonReactiveReadsFn) {
|
|
630
|
+
const prevConsumer = setActiveConsumer(null);
|
|
631
|
+
try {
|
|
632
|
+
return nonReactiveReadsFn();
|
|
633
|
+
} finally {
|
|
634
|
+
setActiveConsumer(prevConsumer);
|
|
661
635
|
}
|
|
662
|
-
throw new RuntimeError(204 /* INVALID_INJECTION_TOKEN */, void 0);
|
|
663
636
|
}
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
637
|
+
|
|
638
|
+
// src/primitives/signals/src/effect.ts
|
|
639
|
+
var BASE_EFFECT_NODE = /* @__PURE__ */ (() => ({
|
|
640
|
+
...REACTIVE_NODE,
|
|
641
|
+
consumerIsAlwaysLive: true,
|
|
642
|
+
consumerAllowSignalWrites: true,
|
|
643
|
+
dirty: true,
|
|
644
|
+
kind: "effect"
|
|
645
|
+
}))();
|
|
646
|
+
function runEffect(node) {
|
|
647
|
+
node.dirty = false;
|
|
648
|
+
if (node.version > 0 && !consumerPollProducersForChange(node)) {
|
|
649
|
+
return;
|
|
668
650
|
}
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
651
|
+
node.version++;
|
|
652
|
+
const prevNode = consumerBeforeComputation(node);
|
|
653
|
+
try {
|
|
654
|
+
node.cleanup();
|
|
655
|
+
node.fn();
|
|
656
|
+
} finally {
|
|
657
|
+
consumerAfterComputation(node, prevNode);
|
|
674
658
|
}
|
|
675
659
|
}
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
const factory = providerToFactory(provider);
|
|
681
|
-
return makeRecord(factory, NOT_YET);
|
|
682
|
-
}
|
|
660
|
+
|
|
661
|
+
// src/primitives/signals/index.ts
|
|
662
|
+
if (typeof ngDevMode === "undefined" || ngDevMode) {
|
|
663
|
+
installDevToolsSignalFormatter();
|
|
683
664
|
}
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
const unwrappedProvider = resolveForwardRef(provider);
|
|
690
|
-
return getFactoryDef(unwrappedProvider) || injectableDefOrInjectorDefFactory(unwrappedProvider);
|
|
691
|
-
} else {
|
|
692
|
-
if (isValueProvider(provider)) {
|
|
693
|
-
factory = () => resolveForwardRef(provider.useValue);
|
|
694
|
-
} else if (isFactoryProvider(provider)) {
|
|
695
|
-
factory = () => provider.useFactory(...injectArgs(provider.deps || []));
|
|
696
|
-
} else if (isExistingProvider(provider)) {
|
|
697
|
-
factory = (_, flags) => ɵɵinject(resolveForwardRef(provider.useExisting), flags !== void 0 && flags & 8 /* Optional */ ? 8 /* Optional */ : void 0);
|
|
698
|
-
} else {
|
|
699
|
-
const classRef = resolveForwardRef(provider && (provider.useClass || provider.provide));
|
|
700
|
-
if (false) {
|
|
701
|
-
}
|
|
702
|
-
if (hasDeps(provider)) {
|
|
703
|
-
factory = () => new classRef(...injectArgs(provider.deps));
|
|
704
|
-
} else {
|
|
705
|
-
return getFactoryDef(classRef) || injectableDefOrInjectorDefFactory(classRef);
|
|
706
|
-
}
|
|
707
|
-
}
|
|
665
|
+
|
|
666
|
+
// src/import/util/assert.ts
|
|
667
|
+
function assertLessThan(actual, expected, msg) {
|
|
668
|
+
if (!(actual < expected)) {
|
|
669
|
+
throwError(msg, actual, expected, "<");
|
|
708
670
|
}
|
|
709
|
-
return factory;
|
|
710
671
|
}
|
|
711
|
-
function
|
|
712
|
-
if (
|
|
713
|
-
|
|
672
|
+
function assertDefined(actual, msg) {
|
|
673
|
+
if (actual == null) {
|
|
674
|
+
throwError(msg, actual, null, "!=");
|
|
714
675
|
}
|
|
715
676
|
}
|
|
716
|
-
function
|
|
677
|
+
function throwError(msg, actual, expected, comparison) {
|
|
678
|
+
throw new Error(`ASSERTION ERROR: ${msg}` + (comparison == null ? "" : ` [Expected=> ${expected} ${comparison} ${actual} <=Actual]`));
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
// src/import/di/interface/defs.ts
|
|
682
|
+
function ɵɵdefineInjectable(opts) {
|
|
717
683
|
return {
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
684
|
+
token: opts.token,
|
|
685
|
+
providedIn: opts.providedIn || null,
|
|
686
|
+
factory: opts.factory,
|
|
687
|
+
value: void 0
|
|
721
688
|
};
|
|
722
689
|
}
|
|
723
|
-
function
|
|
724
|
-
return
|
|
690
|
+
function ɵɵdefineInjector(options) {
|
|
691
|
+
return { providers: options.providers || [], imports: options.imports || [] };
|
|
725
692
|
}
|
|
726
|
-
function
|
|
727
|
-
return
|
|
693
|
+
function getInjectableDef(type) {
|
|
694
|
+
return getOwnDefinition(type, NG_PROV_DEF) || { token: type, factory: () => new type(), ...type.injectOptions };
|
|
728
695
|
}
|
|
729
|
-
function
|
|
730
|
-
return
|
|
696
|
+
function isInjectable(type) {
|
|
697
|
+
return getInjectableDef(type) !== null;
|
|
731
698
|
}
|
|
732
|
-
function
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
699
|
+
function getOwnDefinition(type, field) {
|
|
700
|
+
return type.hasOwnProperty(field) && type[field] || null;
|
|
701
|
+
}
|
|
702
|
+
function getInheritedInjectableDef(type) {
|
|
703
|
+
const def = type?.[NG_PROV_DEF] ?? null;
|
|
704
|
+
if (def) {
|
|
705
|
+
ngDevMode && console.warn(
|
|
706
|
+
`DEPRECATED: DI is instantiating a token "${type.name}" that inherits its @Injectable decorator but does not provide one itself.
|
|
707
|
+
This will become an error in a future version of Angular. Please add @Injectable() to the "${type.name}" class.`
|
|
708
|
+
);
|
|
709
|
+
return def;
|
|
710
|
+
} else {
|
|
711
|
+
return null;
|
|
741
712
|
}
|
|
742
713
|
}
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
function noSideEffects(fn) {
|
|
746
|
-
return { toString: fn }.toString();
|
|
714
|
+
function getInjectorDef(type) {
|
|
715
|
+
return type && type.hasOwnProperty(NG_INJ_DEF) ? type[NG_INJ_DEF] : null;
|
|
747
716
|
}
|
|
717
|
+
var NG_PROV_DEF = getClosureSafeProperty({ ɵprov: getClosureSafeProperty });
|
|
718
|
+
var NG_INJ_DEF = getClosureSafeProperty({ ɵinj: getClosureSafeProperty });
|
|
748
719
|
|
|
749
|
-
// src/import/
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
720
|
+
// src/import/di/injection_token.ts
|
|
721
|
+
var InjectionToken = class {
|
|
722
|
+
constructor(_desc, options) {
|
|
723
|
+
this._desc = _desc;
|
|
724
|
+
this.ɵprov = void 0;
|
|
725
|
+
if (typeof options === "number") {
|
|
726
|
+
(typeof ngDevMode === "undefined" || ngDevMode) && assertLessThan(options, 0, "Only negative numbers are supported here");
|
|
727
|
+
} else if (options !== void 0) {
|
|
728
|
+
this.ɵprov = ɵɵdefineInjectable({
|
|
729
|
+
token: this,
|
|
730
|
+
providedIn: options.providedIn || "root",
|
|
731
|
+
factory: options.factory
|
|
732
|
+
});
|
|
757
733
|
}
|
|
758
|
-
}
|
|
734
|
+
}
|
|
735
|
+
/** @internal */
|
|
736
|
+
ngMetadataName = "InjectionToken";
|
|
737
|
+
ɵprov;
|
|
738
|
+
/**
|
|
739
|
+
* @internal
|
|
740
|
+
*/
|
|
741
|
+
get multi() {
|
|
742
|
+
return this;
|
|
743
|
+
}
|
|
744
|
+
toString() {
|
|
745
|
+
return `InjectionToken ${this._desc}`;
|
|
746
|
+
}
|
|
747
|
+
};
|
|
748
|
+
|
|
749
|
+
// src/import/render3/debug/injector_profiler.ts
|
|
750
|
+
var _injectorProfilerContext;
|
|
751
|
+
function getInjectorProfilerContext() {
|
|
752
|
+
!ngDevMode && throwError("getInjectorProfilerContext should never be called in production mode");
|
|
753
|
+
return _injectorProfilerContext;
|
|
754
|
+
}
|
|
755
|
+
function setInjectorProfilerContext(context) {
|
|
756
|
+
!ngDevMode && throwError("setInjectorProfilerContext should never be called in production mode");
|
|
757
|
+
const previous = _injectorProfilerContext;
|
|
758
|
+
_injectorProfilerContext = context;
|
|
759
|
+
return previous;
|
|
759
760
|
}
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
761
|
+
var injectorProfilerCallbacks = [];
|
|
762
|
+
function injectorProfiler(event) {
|
|
763
|
+
!ngDevMode && throwError("Injector profiler should never be called in production mode");
|
|
764
|
+
for (let i = 0; i < injectorProfilerCallbacks.length; i++) {
|
|
765
|
+
const injectorProfilerCallback = injectorProfilerCallbacks[i];
|
|
766
|
+
injectorProfilerCallback(event);
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
function emitProviderConfiguredEvent(eventProvider, isViewProvider = false) {
|
|
770
|
+
!ngDevMode && throwError("Injector profiler should never be called in production mode");
|
|
771
|
+
let token;
|
|
772
|
+
if (typeof eventProvider === "function") {
|
|
773
|
+
token = eventProvider;
|
|
774
|
+
} else if (eventProvider instanceof InjectionToken) {
|
|
775
|
+
token = eventProvider;
|
|
776
|
+
} else {
|
|
777
|
+
token = resolveForwardRef(eventProvider.provide);
|
|
778
|
+
}
|
|
779
|
+
let provider = eventProvider;
|
|
780
|
+
if (eventProvider instanceof InjectionToken) {
|
|
781
|
+
provider = eventProvider.ɵprov || eventProvider;
|
|
782
|
+
}
|
|
783
|
+
injectorProfiler({
|
|
784
|
+
type: 2 /* ProviderConfigured */,
|
|
785
|
+
context: getInjectorProfilerContext(),
|
|
786
|
+
providerRecord: { token, provider, isViewProvider }
|
|
787
|
+
});
|
|
788
|
+
}
|
|
789
|
+
function emitInjectorToCreateInstanceEvent(token) {
|
|
790
|
+
!ngDevMode && throwError("Injector profiler should never be called in production mode");
|
|
791
|
+
injectorProfiler({
|
|
792
|
+
type: 5 /* InjectorToCreateInstanceEvent */,
|
|
793
|
+
context: getInjectorProfilerContext(),
|
|
794
|
+
token
|
|
770
795
|
});
|
|
771
796
|
}
|
|
797
|
+
function emitInstanceCreatedByInjectorEvent(instance) {
|
|
798
|
+
!ngDevMode && throwError("Injector profiler should never be called in production mode");
|
|
799
|
+
injectorProfiler({
|
|
800
|
+
type: 1 /* InstanceCreatedByInjector */,
|
|
801
|
+
context: getInjectorProfilerContext(),
|
|
802
|
+
instance: { value: instance }
|
|
803
|
+
});
|
|
804
|
+
}
|
|
805
|
+
function emitInjectEvent(token, value, flags) {
|
|
806
|
+
!ngDevMode && throwError("Injector profiler should never be called in production mode");
|
|
807
|
+
injectorProfiler({
|
|
808
|
+
type: 0 /* Inject */,
|
|
809
|
+
context: getInjectorProfilerContext(),
|
|
810
|
+
service: { token, value, flags }
|
|
811
|
+
});
|
|
812
|
+
}
|
|
813
|
+
function emitEffectCreatedEvent(effect2) {
|
|
814
|
+
!ngDevMode && throwError("Injector profiler should never be called in production mode");
|
|
815
|
+
injectorProfiler({
|
|
816
|
+
type: 3 /* EffectCreated */,
|
|
817
|
+
context: getInjectorProfilerContext(),
|
|
818
|
+
effect: effect2
|
|
819
|
+
});
|
|
820
|
+
}
|
|
821
|
+
function runInInjectorProfilerContext(injector, token, callback) {
|
|
822
|
+
!ngDevMode && throwError("runInInjectorProfilerContext should never be called in production mode");
|
|
823
|
+
const prevInjectContext = setInjectorProfilerContext({ injector, token });
|
|
824
|
+
try {
|
|
825
|
+
callback();
|
|
826
|
+
} finally {
|
|
827
|
+
setInjectorProfilerContext(prevInjectContext);
|
|
828
|
+
}
|
|
829
|
+
}
|
|
772
830
|
|
|
773
|
-
// src/import/
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
// tslint:disable-next-line: no-toplevel-property-access
|
|
778
|
-
-1 /* Inject */
|
|
779
|
-
);
|
|
780
|
-
var Optional = (
|
|
781
|
-
// Disable tslint because `InternalInjectFlags` is a const enum which gets inlined.
|
|
782
|
-
// tslint:disable-next-line: no-toplevel-property-access
|
|
783
|
-
attachInjectFlag(makeParamDecorator("Optional"), 8 /* Optional */)
|
|
784
|
-
);
|
|
785
|
-
var Self = (
|
|
786
|
-
// Disable tslint because `InternalInjectFlags` is a const enum which gets inlined.
|
|
787
|
-
// tslint:disable-next-line: no-toplevel-property-access
|
|
788
|
-
attachInjectFlag(makeParamDecorator("Self"), 2 /* Self */)
|
|
789
|
-
);
|
|
790
|
-
var SkipSelf = (
|
|
791
|
-
// Disable tslint because `InternalInjectFlags` is a const enum which gets inlined.
|
|
792
|
-
// tslint:disable-next-line: no-toplevel-property-access
|
|
793
|
-
attachInjectFlag(makeParamDecorator("SkipSelf"), 4 /* SkipSelf */)
|
|
794
|
-
);
|
|
831
|
+
// src/import/render3/definition_factory.ts
|
|
832
|
+
function getFactoryDef(type, throwNotFound) {
|
|
833
|
+
return () => new type();
|
|
834
|
+
}
|
|
795
835
|
|
|
796
|
-
// src/import/
|
|
797
|
-
function
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
return
|
|
836
|
+
// src/import/render3/util/stringify_utils.ts
|
|
837
|
+
function renderStringify(value) {
|
|
838
|
+
if (typeof value === "string") return value;
|
|
839
|
+
if (value == null) return "";
|
|
840
|
+
return String(value);
|
|
841
|
+
}
|
|
842
|
+
function stringifyForError(value) {
|
|
843
|
+
if (typeof value === "function") return value.name || value.toString();
|
|
844
|
+
if (typeof value === "object" && value != null && typeof value.type === "function") {
|
|
845
|
+
return value.type.name || value.type.toString();
|
|
846
|
+
}
|
|
847
|
+
return renderStringify(value);
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
// src/import/render3/errors_di.ts
|
|
851
|
+
var NG_RUNTIME_ERROR_CODE = getClosureSafeProperty({ ngErrorCode: getClosureSafeProperty });
|
|
852
|
+
var NG_RUNTIME_ERROR_MESSAGE = getClosureSafeProperty({ ngErrorMessage: getClosureSafeProperty });
|
|
853
|
+
var NG_TOKEN_PATH = getClosureSafeProperty({ ngTokenPath: getClosureSafeProperty });
|
|
854
|
+
function cyclicDependencyError(token, path) {
|
|
855
|
+
const message = ngDevMode ? `Circular dependency detected for \`${token}\`.` : "";
|
|
856
|
+
return createRuntimeError(message, -200 /* CYCLIC_DI_DEPENDENCY */, path);
|
|
857
|
+
}
|
|
858
|
+
function throwMixedMultiProviderError() {
|
|
859
|
+
throw new Error(`Cannot mix multi providers and regular providers`);
|
|
860
|
+
}
|
|
861
|
+
function throwInvalidProviderError(ngModuleType, providers, provider) {
|
|
862
|
+
if (ngModuleType && providers) {
|
|
863
|
+
const providerDetail = providers.map((v) => v == provider ? "?" + provider + "?" : "...");
|
|
864
|
+
throw new Error(`Invalid provider for the NgModule '${stringify(ngModuleType)}' - only instances of Provider and Type are allowed, got: [${providerDetail.join(", ")}]`);
|
|
865
|
+
} else if (isEnvironmentProviders(provider)) {
|
|
866
|
+
if (provider.ɵfromNgModule) {
|
|
867
|
+
throw new RuntimeError(
|
|
868
|
+
-207 /* PROVIDER_IN_WRONG_CONTEXT */,
|
|
869
|
+
`Invalid providers from 'importProvidersFrom' present in a non-environment injector. 'importProvidersFrom' can't be used for component providers.`
|
|
870
|
+
);
|
|
871
|
+
} else {
|
|
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.`);
|
|
873
|
+
}
|
|
874
|
+
} else {
|
|
875
|
+
throw new Error("Invalid provider");
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
function throwProviderNotFoundError(token, injectorName) {
|
|
879
|
+
const errorMessage = ngDevMode && `No provider for ${stringifyForError(token)} found${injectorName ? ` in ${injectorName}` : ""}`;
|
|
880
|
+
throw new RuntimeError(-201 /* PROVIDER_NOT_FOUND */, errorMessage);
|
|
881
|
+
}
|
|
882
|
+
function prependTokenToDependencyPath(error, token) {
|
|
883
|
+
error[NG_TOKEN_PATH] ??= [];
|
|
884
|
+
const currentPath = error[NG_TOKEN_PATH];
|
|
885
|
+
let pathStr;
|
|
886
|
+
if (typeof token === "object" && "multi" in token && token?.multi === true) {
|
|
887
|
+
assertDefined(token.provide, "Token with multi: true should have a provide property");
|
|
888
|
+
pathStr = stringifyForError(token.provide);
|
|
889
|
+
} else {
|
|
890
|
+
pathStr = stringifyForError(token);
|
|
891
|
+
}
|
|
892
|
+
if (currentPath[0] !== pathStr) {
|
|
893
|
+
error[NG_TOKEN_PATH].unshift(pathStr);
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
function augmentRuntimeError(error, source) {
|
|
897
|
+
const tokenPath = error[NG_TOKEN_PATH];
|
|
898
|
+
const errorCode = error[NG_RUNTIME_ERROR_CODE];
|
|
899
|
+
const message = error[NG_RUNTIME_ERROR_MESSAGE] || error.message;
|
|
900
|
+
error.message = formatErrorMessage(message, errorCode, tokenPath, source);
|
|
901
|
+
return error;
|
|
902
|
+
}
|
|
903
|
+
function createRuntimeError(message, code, path) {
|
|
904
|
+
const error = new RuntimeError(code, message);
|
|
905
|
+
error[NG_RUNTIME_ERROR_CODE] = code;
|
|
906
|
+
error[NG_RUNTIME_ERROR_MESSAGE] = message;
|
|
907
|
+
if (path) {
|
|
908
|
+
error[NG_TOKEN_PATH] = path;
|
|
909
|
+
}
|
|
910
|
+
return error;
|
|
801
911
|
}
|
|
802
|
-
function
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
912
|
+
function getRuntimeErrorCode(error) {
|
|
913
|
+
return error[NG_RUNTIME_ERROR_CODE];
|
|
914
|
+
}
|
|
915
|
+
function formatErrorMessage(text, code, path = [], source = null) {
|
|
916
|
+
let pathDetails = "";
|
|
917
|
+
if (path && path.length > 1) {
|
|
918
|
+
pathDetails = ` Path: ${path.join(" -> ")}.`;
|
|
919
|
+
}
|
|
920
|
+
const sourceDetails = source ? ` Source: ${source}.` : "";
|
|
921
|
+
return formatRuntimeError(code, `${text}${sourceDetails}${pathDetails}`);
|
|
806
922
|
}
|
|
807
923
|
|
|
808
|
-
// src/import/
|
|
809
|
-
var
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
return createInjector({ name }, options.parent, options.providers, name);
|
|
818
|
-
}
|
|
924
|
+
// src/import/render3/fields.ts
|
|
925
|
+
var NG_FACTORY_DEF = getClosureSafeProperty({ ɵfac: getClosureSafeProperty });
|
|
926
|
+
var NG_ENV_ID = getClosureSafeProperty({ __NG_ENV_ID__: getClosureSafeProperty });
|
|
927
|
+
|
|
928
|
+
// src/import/util/array_utils.ts
|
|
929
|
+
function newArray(size, value) {
|
|
930
|
+
const list = [];
|
|
931
|
+
for (let i = 0; i < size; i++) {
|
|
932
|
+
list.push(value);
|
|
819
933
|
}
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
/** @pureOrBreakMyCode */
|
|
823
|
-
/* @__PURE__ */ ɵɵdefineInjectable({
|
|
824
|
-
token: _Injector,
|
|
825
|
-
providedIn: "any",
|
|
826
|
-
factory: () => ɵɵinject(INJECTOR)
|
|
827
|
-
})
|
|
828
|
-
);
|
|
829
|
-
/**
|
|
830
|
-
* @internal
|
|
831
|
-
* @nocollapse
|
|
832
|
-
*/
|
|
833
|
-
static __NG_ELEMENT_ID__ = -1 /* Injector */;
|
|
834
|
-
};
|
|
934
|
+
return list;
|
|
935
|
+
}
|
|
835
936
|
|
|
836
|
-
// src/import/
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
937
|
+
// src/import/util/empty.ts
|
|
938
|
+
var EMPTY_OBJ = {};
|
|
939
|
+
var EMPTY_ARRAY = [];
|
|
940
|
+
if ((typeof ngDevMode === "undefined" || ngDevMode) && true) {
|
|
941
|
+
Object.freeze(EMPTY_OBJ);
|
|
942
|
+
Object.freeze(EMPTY_ARRAY);
|
|
840
943
|
}
|
|
841
944
|
|
|
842
|
-
// src/
|
|
843
|
-
var
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
var
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
945
|
+
// src/import/di/initializer_token.ts
|
|
946
|
+
var ENVIRONMENT_INITIALIZER = new InjectionToken(typeof ngDevMode !== "undefined" && ngDevMode ? "ENVIRONMENT_INITIALIZER" : "");
|
|
947
|
+
|
|
948
|
+
// src/import/di/interface/injector.ts
|
|
949
|
+
var DecoratorFlags = /* @__PURE__ */ ((DecoratorFlags2) => {
|
|
950
|
+
DecoratorFlags2[DecoratorFlags2["Inject"] = -1] = "Inject";
|
|
951
|
+
return DecoratorFlags2;
|
|
952
|
+
})(DecoratorFlags || {});
|
|
953
|
+
var InternalInjectFlags = /* @__PURE__ */ ((InternalInjectFlags2) => {
|
|
954
|
+
InternalInjectFlags2[InternalInjectFlags2["Default"] = 0] = "Default";
|
|
955
|
+
InternalInjectFlags2[InternalInjectFlags2["Host"] = 1] = "Host";
|
|
956
|
+
InternalInjectFlags2[InternalInjectFlags2["Self"] = 2] = "Self";
|
|
957
|
+
InternalInjectFlags2[InternalInjectFlags2["SkipSelf"] = 4] = "SkipSelf";
|
|
958
|
+
InternalInjectFlags2[InternalInjectFlags2["Optional"] = 8] = "Optional";
|
|
959
|
+
InternalInjectFlags2[InternalInjectFlags2["ForPipe"] = 16] = "ForPipe";
|
|
960
|
+
return InternalInjectFlags2;
|
|
961
|
+
})(InternalInjectFlags || {});
|
|
962
|
+
|
|
963
|
+
// src/import/di/inject_switch.ts
|
|
964
|
+
var _injectImplementation;
|
|
965
|
+
function getInjectImplementation() {
|
|
966
|
+
return _injectImplementation;
|
|
852
967
|
}
|
|
853
|
-
function
|
|
854
|
-
|
|
968
|
+
function setInjectImplementation(impl) {
|
|
969
|
+
const previous = _injectImplementation;
|
|
970
|
+
_injectImplementation = impl;
|
|
971
|
+
return previous;
|
|
855
972
|
}
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
producers: void 0,
|
|
861
|
-
producersTail: void 0,
|
|
862
|
-
consumers: void 0,
|
|
863
|
-
consumersTail: void 0,
|
|
864
|
-
recomputing: false,
|
|
865
|
-
consumerAllowSignalWrites: false,
|
|
866
|
-
consumerIsAlwaysLive: false,
|
|
867
|
-
kind: "unknown",
|
|
868
|
-
producerMustRecompute: () => false,
|
|
869
|
-
producerRecomputeValue: () => {
|
|
870
|
-
},
|
|
871
|
-
consumerMarkedDirty: () => {
|
|
872
|
-
},
|
|
873
|
-
consumerOnSignalRead: () => {
|
|
874
|
-
}
|
|
875
|
-
};
|
|
876
|
-
function producerAccessed(node) {
|
|
877
|
-
if (inNotificationPhase) {
|
|
878
|
-
throw new Error(false ? `Assertion error: signal read during notification phase` : "");
|
|
879
|
-
}
|
|
880
|
-
if (activeConsumer === null) {
|
|
881
|
-
return;
|
|
973
|
+
function injectRootLimpMode(token, notFoundValue, flags) {
|
|
974
|
+
const injectableDef = getInjectableDef(token);
|
|
975
|
+
if (injectableDef && injectableDef.providedIn == "root") {
|
|
976
|
+
return injectableDef.value === void 0 ? injectableDef.value = injectableDef.factory() : injectableDef.value;
|
|
882
977
|
}
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
978
|
+
if (flags & 8 /* Optional */) return null;
|
|
979
|
+
if (notFoundValue !== void 0) return notFoundValue;
|
|
980
|
+
throwProviderNotFoundError(token, typeof ngDevMode !== "undefined" && ngDevMode ? "Injector" : "");
|
|
981
|
+
}
|
|
982
|
+
|
|
983
|
+
// src/primitives/di/src/injector.ts
|
|
984
|
+
var _currentInjector = void 0;
|
|
985
|
+
function getCurrentInjector() {
|
|
986
|
+
return _currentInjector;
|
|
987
|
+
}
|
|
988
|
+
function setCurrentInjector(injector) {
|
|
989
|
+
const former = _currentInjector;
|
|
990
|
+
_currentInjector = injector;
|
|
991
|
+
return former;
|
|
992
|
+
}
|
|
993
|
+
|
|
994
|
+
// src/primitives/di/src/not_found.ts
|
|
995
|
+
var NOT_FOUND = Symbol("NotFound");
|
|
996
|
+
function isNotFound(e) {
|
|
997
|
+
return e === NOT_FOUND || e?.name === "ɵNotFound";
|
|
998
|
+
}
|
|
999
|
+
|
|
1000
|
+
// src/import/di/injector_compatibility.ts
|
|
1001
|
+
var _THROW_IF_NOT_FOUND = {};
|
|
1002
|
+
var THROW_IF_NOT_FOUND = _THROW_IF_NOT_FOUND;
|
|
1003
|
+
var DI_DECORATOR_FLAG = "__NG_DI_FLAG__";
|
|
1004
|
+
var RetrievingInjector = class {
|
|
1005
|
+
constructor(injector) {
|
|
1006
|
+
this.injector = injector;
|
|
887
1007
|
}
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
1008
|
+
retrieve(token, options) {
|
|
1009
|
+
const flags = convertToBitFlags(options) || 0 /* Default */;
|
|
1010
|
+
try {
|
|
1011
|
+
return this.injector.get(
|
|
1012
|
+
token,
|
|
1013
|
+
// When a dependency is requested with an optional flag, DI returns null as the default value.
|
|
1014
|
+
flags & 8 /* Optional */ ? null : THROW_IF_NOT_FOUND,
|
|
1015
|
+
flags
|
|
1016
|
+
);
|
|
1017
|
+
} catch (e) {
|
|
1018
|
+
if (isNotFound(e)) {
|
|
1019
|
+
return e;
|
|
1020
|
+
}
|
|
1021
|
+
throw e;
|
|
896
1022
|
}
|
|
897
1023
|
}
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
prevConsumer: prevConsumerLink,
|
|
911
|
-
lastReadVersion: node.version,
|
|
912
|
-
nextConsumer: void 0
|
|
913
|
-
};
|
|
914
|
-
activeConsumer.producersTail = newLink;
|
|
915
|
-
if (prevProducerLink !== void 0) {
|
|
916
|
-
prevProducerLink.nextProducer = newLink;
|
|
1024
|
+
};
|
|
1025
|
+
var NG_TEMP_TOKEN_PATH = "ngTempTokenPath";
|
|
1026
|
+
var SOURCE = "__source";
|
|
1027
|
+
function injectInjectorOnly(token, flags = 0 /* Default */) {
|
|
1028
|
+
const currentInjector = getCurrentInjector();
|
|
1029
|
+
if (currentInjector === void 0) {
|
|
1030
|
+
throw new RuntimeError(
|
|
1031
|
+
-203 /* MISSING_INJECTION_CONTEXT */,
|
|
1032
|
+
ngDevMode && `The \`${stringify(token)}\` token injection failed. \`inject()\` function must be called from an injection context such as a constructor, a factory function, a field initializer, or a function used with \`runInInjectionContext\`.`
|
|
1033
|
+
);
|
|
1034
|
+
} else if (currentInjector === null) {
|
|
1035
|
+
return injectRootLimpMode(token, void 0, flags);
|
|
917
1036
|
} else {
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
1037
|
+
const options = convertToInjectOptions(flags);
|
|
1038
|
+
const value = currentInjector.retrieve(token, options);
|
|
1039
|
+
ngDevMode && emitInjectEvent(token, value, flags);
|
|
1040
|
+
if (isNotFound(value)) {
|
|
1041
|
+
if (options.optional) {
|
|
1042
|
+
return null;
|
|
1043
|
+
}
|
|
1044
|
+
throw value;
|
|
1045
|
+
}
|
|
1046
|
+
return value;
|
|
922
1047
|
}
|
|
923
1048
|
}
|
|
924
|
-
function
|
|
925
|
-
|
|
1049
|
+
function ɵɵinject(token, flags = 0 /* Default */) {
|
|
1050
|
+
return (getInjectImplementation() || injectInjectorOnly)(resolveForwardRef(token), flags);
|
|
926
1051
|
}
|
|
927
|
-
function
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
producerMarkClean(node);
|
|
936
|
-
return;
|
|
937
|
-
}
|
|
938
|
-
node.producerRecomputeValue(node);
|
|
939
|
-
producerMarkClean(node);
|
|
1052
|
+
function ɵɵinvalidFactoryDep(index) {
|
|
1053
|
+
throw new RuntimeError(
|
|
1054
|
+
202 /* INVALID_FACTORY_DEPENDENCY */,
|
|
1055
|
+
ngDevMode && `This constructor is not compatible with Angular Dependency Injection because its dependency at index ${index} of the parameter list is invalid.
|
|
1056
|
+
This can happen if the dependency type is a primitive like a string or if an ancestor of this class is missing an Angular decorator.
|
|
1057
|
+
|
|
1058
|
+
Please check that 1) the type for the parameter at index ${index} is correct and 2) the correct Angular decorators are defined for this class and its ancestors.`
|
|
1059
|
+
);
|
|
940
1060
|
}
|
|
941
|
-
function
|
|
942
|
-
|
|
943
|
-
|
|
1061
|
+
function inject2(token, options) {
|
|
1062
|
+
return ɵɵinject(token, convertToBitFlags(options));
|
|
1063
|
+
}
|
|
1064
|
+
function convertToBitFlags(flags) {
|
|
1065
|
+
if (typeof flags === "undefined" || typeof flags === "number") {
|
|
1066
|
+
return flags;
|
|
944
1067
|
}
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
1068
|
+
return 0 /* Default */ | // comment to force a line break in the formatter
|
|
1069
|
+
(flags.optional && 8 /* Optional */) | 0 | (flags.self && 2 /* Self */) | (flags.skipSelf && 4 /* SkipSelf */);
|
|
1070
|
+
}
|
|
1071
|
+
function convertToInjectOptions(flags) {
|
|
1072
|
+
return {
|
|
1073
|
+
optional: !!(flags & 8 /* Optional */),
|
|
1074
|
+
host: !!(flags & 1 /* Host */),
|
|
1075
|
+
self: !!(flags & 2 /* Self */),
|
|
1076
|
+
skipSelf: !!(flags & 4 /* SkipSelf */)
|
|
1077
|
+
};
|
|
1078
|
+
}
|
|
1079
|
+
function injectArgs(types) {
|
|
1080
|
+
const args = [];
|
|
1081
|
+
for (let i = 0; i < types.length; i++) {
|
|
1082
|
+
const arg = resolveForwardRef(types[i]);
|
|
1083
|
+
if (Array.isArray(arg)) {
|
|
1084
|
+
if (arg.length === 0) {
|
|
1085
|
+
throw new RuntimeError(900 /* INVALID_DIFFER_INPUT */, ngDevMode && "Arguments array must have arguments.");
|
|
952
1086
|
}
|
|
1087
|
+
let type = void 0;
|
|
1088
|
+
let flags = 0 /* Default */;
|
|
1089
|
+
for (let j = 0; j < arg.length; j++) {
|
|
1090
|
+
const meta = arg[j];
|
|
1091
|
+
const flag = getInjectFlag(meta);
|
|
1092
|
+
if (typeof flag === "number") {
|
|
1093
|
+
if (flag === -1 /* Inject */) {
|
|
1094
|
+
type = meta.token;
|
|
1095
|
+
} else {
|
|
1096
|
+
flags |= flag;
|
|
1097
|
+
}
|
|
1098
|
+
} else {
|
|
1099
|
+
type = meta;
|
|
1100
|
+
}
|
|
1101
|
+
}
|
|
1102
|
+
args.push(ɵɵinject(type, flags));
|
|
1103
|
+
} else {
|
|
1104
|
+
args.push(ɵɵinject(arg));
|
|
953
1105
|
}
|
|
954
|
-
} finally {
|
|
955
|
-
inNotificationPhase = prev;
|
|
956
1106
|
}
|
|
1107
|
+
return args;
|
|
957
1108
|
}
|
|
958
|
-
function
|
|
959
|
-
|
|
1109
|
+
function attachInjectFlag(decorator, flag) {
|
|
1110
|
+
decorator[DI_DECORATOR_FLAG] = flag;
|
|
1111
|
+
decorator.prototype[DI_DECORATOR_FLAG] = flag;
|
|
1112
|
+
return decorator;
|
|
960
1113
|
}
|
|
961
|
-
function
|
|
962
|
-
|
|
963
|
-
producerNotifyConsumers(node);
|
|
964
|
-
node.consumerMarkedDirty?.(node);
|
|
1114
|
+
function getInjectFlag(token) {
|
|
1115
|
+
return token[DI_DECORATOR_FLAG];
|
|
965
1116
|
}
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
1117
|
+
|
|
1118
|
+
// src/import/di/injector_token.ts
|
|
1119
|
+
var INJECTOR = new InjectionToken(
|
|
1120
|
+
typeof ngDevMode !== "undefined" && ngDevMode ? "INJECTOR" : "",
|
|
1121
|
+
// Disable tslint because this is const enum which gets inlined not top level prop access.
|
|
1122
|
+
// tslint:disable-next-line: no-toplevel-property-access
|
|
1123
|
+
-1 /* Injector */
|
|
1124
|
+
// Special value used by Ivy to identify `Injector`.
|
|
1125
|
+
);
|
|
1126
|
+
|
|
1127
|
+
// src/import/di/internal_tokens.ts
|
|
1128
|
+
var INJECTOR_DEF_TYPES = new InjectionToken(typeof ngDevMode !== "undefined" && ngDevMode ? "INJECTOR_DEF_TYPES" : "");
|
|
1129
|
+
|
|
1130
|
+
// src/import/di/null_injector.ts
|
|
1131
|
+
var NullInjector = class {
|
|
1132
|
+
get(token, notFoundValue = THROW_IF_NOT_FOUND) {
|
|
1133
|
+
if (notFoundValue === THROW_IF_NOT_FOUND) {
|
|
1134
|
+
const message = ngDevMode ? `No provider found for \`${stringify(token)}\`.` : "";
|
|
1135
|
+
const error = createRuntimeError(message, -201 /* PROVIDER_NOT_FOUND */);
|
|
1136
|
+
error.name = "ɵNotFound";
|
|
1137
|
+
throw error;
|
|
1138
|
+
}
|
|
1139
|
+
return notFoundValue;
|
|
1140
|
+
}
|
|
1141
|
+
};
|
|
1142
|
+
|
|
1143
|
+
// src/import/di/provider_collection.ts
|
|
1144
|
+
function makeEnvironmentProviders(providers) {
|
|
1145
|
+
return {
|
|
1146
|
+
ɵproviders: providers
|
|
1147
|
+
};
|
|
969
1148
|
}
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
1149
|
+
var USE_VALUE = getClosureSafeProperty({
|
|
1150
|
+
provide: String,
|
|
1151
|
+
useValue: getClosureSafeProperty
|
|
1152
|
+
});
|
|
1153
|
+
function isValueProvider(value) {
|
|
1154
|
+
return value !== null && typeof value === "object" && USE_VALUE in value;
|
|
973
1155
|
}
|
|
974
|
-
function
|
|
975
|
-
|
|
976
|
-
node.recomputing = true;
|
|
1156
|
+
function isExistingProvider(value) {
|
|
1157
|
+
return !!(value && value.useExisting);
|
|
977
1158
|
}
|
|
978
|
-
function
|
|
979
|
-
|
|
980
|
-
if (node) finalizeConsumerAfterComputation(node);
|
|
1159
|
+
function isFactoryProvider(value) {
|
|
1160
|
+
return !!(value && value.useFactory);
|
|
981
1161
|
}
|
|
982
|
-
function
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
1162
|
+
function isTypeProvider(value) {
|
|
1163
|
+
return typeof value === "function";
|
|
1164
|
+
}
|
|
1165
|
+
|
|
1166
|
+
// src/import/di/scope.ts
|
|
1167
|
+
var INJECTOR_SCOPE = new InjectionToken(typeof ngDevMode !== "undefined" && ngDevMode ? "Set Injector scope." : "");
|
|
1168
|
+
|
|
1169
|
+
// src/import/di/r3_injector.ts
|
|
1170
|
+
var NOT_YET = {};
|
|
1171
|
+
var CIRCULAR = {};
|
|
1172
|
+
var NULL_INJECTOR = void 0;
|
|
1173
|
+
function getNullInjector() {
|
|
1174
|
+
if (NULL_INJECTOR === void 0) {
|
|
1175
|
+
NULL_INJECTOR = new NullInjector();
|
|
1176
|
+
}
|
|
1177
|
+
return NULL_INJECTOR;
|
|
1178
|
+
}
|
|
1179
|
+
var EnvironmentInjector = class {
|
|
1180
|
+
};
|
|
1181
|
+
var R3Injector = class extends EnvironmentInjector {
|
|
1182
|
+
constructor(providers, parent, source, scopes) {
|
|
1183
|
+
super();
|
|
1184
|
+
this.parent = parent;
|
|
1185
|
+
this.source = source;
|
|
1186
|
+
this.scopes = scopes;
|
|
1187
|
+
forEachSingleProvider(providers, (provider) => this.processProvider(provider));
|
|
1188
|
+
this.records.set(INJECTOR, makeRecord(void 0, this));
|
|
1189
|
+
if (scopes.has("environment")) {
|
|
1190
|
+
this.records.set(EnvironmentInjector, makeRecord(void 0, this));
|
|
991
1191
|
}
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
node.producers = void 0;
|
|
1192
|
+
const record = this.records.get(INJECTOR_SCOPE);
|
|
1193
|
+
if (record != null && typeof record.value === "string") {
|
|
1194
|
+
this.scopes.add(record.value);
|
|
996
1195
|
}
|
|
1196
|
+
this.injectorDefTypes = new Set(this.get(INJECTOR_DEF_TYPES, EMPTY_ARRAY, { self: true }));
|
|
997
1197
|
}
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1198
|
+
/**
|
|
1199
|
+
* Map of tokens to records which contain the instances of those tokens.
|
|
1200
|
+
* - `null` value implies that we don't have the record. Used by tree-shakable injectors
|
|
1201
|
+
* to prevent further searches.
|
|
1202
|
+
*/
|
|
1203
|
+
records = /* @__PURE__ */ new Map();
|
|
1204
|
+
/**
|
|
1205
|
+
* Set of values instantiated by this injector which contain `ngOnDestroy` lifecycle hooks.
|
|
1206
|
+
*/
|
|
1207
|
+
_ngOnDestroyHooks = /* @__PURE__ */ new Set();
|
|
1208
|
+
_onDestroyHooks = [];
|
|
1209
|
+
/**
|
|
1210
|
+
* Flag indicating that this injector was previously destroyed.
|
|
1211
|
+
*/
|
|
1212
|
+
get destroyed() {
|
|
1213
|
+
return this._destroyed;
|
|
1214
|
+
}
|
|
1215
|
+
_destroyed = false;
|
|
1216
|
+
injectorDefTypes;
|
|
1217
|
+
retrieve(token, options) {
|
|
1218
|
+
const flags = convertToBitFlags(options) || 0 /* Default */;
|
|
1219
|
+
try {
|
|
1220
|
+
return this.get(
|
|
1221
|
+
token,
|
|
1222
|
+
// When a dependency is requested with an optional flag, DI returns null as the default value.
|
|
1223
|
+
THROW_IF_NOT_FOUND,
|
|
1224
|
+
flags
|
|
1225
|
+
);
|
|
1226
|
+
} catch (e) {
|
|
1227
|
+
if (isNotFound(e)) {
|
|
1228
|
+
return e;
|
|
1229
|
+
}
|
|
1230
|
+
throw e;
|
|
1005
1231
|
}
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1232
|
+
}
|
|
1233
|
+
/**
|
|
1234
|
+
* Destroy the injector and release references to every instance or provider associated with it.
|
|
1235
|
+
*
|
|
1236
|
+
* Also calls the `OnDestroy` lifecycle hooks of every instance that was created for which a
|
|
1237
|
+
* hook was found.
|
|
1238
|
+
*/
|
|
1239
|
+
destroy() {
|
|
1240
|
+
assertNotDestroyed(this);
|
|
1241
|
+
this._destroyed = true;
|
|
1242
|
+
try {
|
|
1243
|
+
for (const service of this._ngOnDestroyHooks) {
|
|
1244
|
+
service.ngOnDestroy();
|
|
1245
|
+
}
|
|
1246
|
+
const onDestroyHooks = this._onDestroyHooks;
|
|
1247
|
+
this._onDestroyHooks = [];
|
|
1248
|
+
for (const hook of onDestroyHooks) {
|
|
1249
|
+
hook();
|
|
1250
|
+
}
|
|
1251
|
+
} finally {
|
|
1252
|
+
this.records.clear();
|
|
1253
|
+
this._ngOnDestroyHooks.clear();
|
|
1254
|
+
this.injectorDefTypes.clear();
|
|
1009
1255
|
}
|
|
1010
1256
|
}
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1257
|
+
onDestroy(callback) {
|
|
1258
|
+
assertNotDestroyed(this);
|
|
1259
|
+
this._onDestroyHooks.push(callback);
|
|
1260
|
+
return () => this.removeOnDestroy(callback);
|
|
1261
|
+
}
|
|
1262
|
+
runInContext(fn) {
|
|
1263
|
+
assertNotDestroyed(this);
|
|
1264
|
+
const previousInjector = setCurrentInjector(this);
|
|
1265
|
+
const previousInjectImplementation = setInjectImplementation(void 0);
|
|
1266
|
+
let prevInjectContext;
|
|
1267
|
+
if (ngDevMode) {
|
|
1268
|
+
prevInjectContext = setInjectorProfilerContext({ injector: this, token: null });
|
|
1269
|
+
}
|
|
1270
|
+
try {
|
|
1271
|
+
return fn();
|
|
1272
|
+
} finally {
|
|
1273
|
+
setCurrentInjector(previousInjector);
|
|
1274
|
+
setInjectImplementation(previousInjectImplementation);
|
|
1275
|
+
ngDevMode && setInjectorProfilerContext(prevInjectContext);
|
|
1276
|
+
}
|
|
1277
|
+
}
|
|
1278
|
+
get(token, notFoundValue = THROW_IF_NOT_FOUND, options) {
|
|
1279
|
+
assertNotDestroyed(this);
|
|
1280
|
+
if (token.hasOwnProperty(NG_ENV_ID)) {
|
|
1281
|
+
return token[NG_ENV_ID](this);
|
|
1282
|
+
}
|
|
1283
|
+
const flags = convertToBitFlags(options);
|
|
1284
|
+
let prevInjectContext;
|
|
1285
|
+
if (ngDevMode) {
|
|
1286
|
+
prevInjectContext = setInjectorProfilerContext({ injector: this, token });
|
|
1287
|
+
}
|
|
1288
|
+
const previousInjector = setCurrentInjector(this);
|
|
1289
|
+
const previousInjectImplementation = setInjectImplementation(void 0);
|
|
1290
|
+
try {
|
|
1291
|
+
if (!(flags & 4 /* SkipSelf */)) {
|
|
1292
|
+
let record = this.records.get(token);
|
|
1293
|
+
if (record === void 0) {
|
|
1294
|
+
const def = couldBeInjectableType(token) && getInjectableDef(token);
|
|
1295
|
+
if (def && this.injectableDefInScope(def)) {
|
|
1296
|
+
if (ngDevMode) {
|
|
1297
|
+
runInInjectorProfilerContext(this, token, () => {
|
|
1298
|
+
emitProviderConfiguredEvent(token);
|
|
1299
|
+
});
|
|
1300
|
+
}
|
|
1301
|
+
record = makeRecord(injectableDefOrInjectorDefFactory(token), NOT_YET);
|
|
1302
|
+
} else {
|
|
1303
|
+
record = null;
|
|
1304
|
+
}
|
|
1305
|
+
this.records.set(token, record);
|
|
1306
|
+
}
|
|
1307
|
+
if (record != null) {
|
|
1308
|
+
return this.hydrate(token, record, flags);
|
|
1309
|
+
}
|
|
1310
|
+
}
|
|
1311
|
+
const nextInjector = !(flags & 2 /* Self */) ? this.parent : getNullInjector();
|
|
1312
|
+
notFoundValue = flags & 8 /* Optional */ && notFoundValue === THROW_IF_NOT_FOUND ? null : notFoundValue;
|
|
1313
|
+
return nextInjector.get(token, notFoundValue);
|
|
1314
|
+
} catch (error) {
|
|
1315
|
+
const errorCode = getRuntimeErrorCode(error);
|
|
1316
|
+
if (errorCode === -200 /* CYCLIC_DI_DEPENDENCY */ || errorCode === -201 /* PROVIDER_NOT_FOUND */) {
|
|
1317
|
+
if (ngDevMode) {
|
|
1318
|
+
prependTokenToDependencyPath(error, token);
|
|
1319
|
+
if (previousInjector) {
|
|
1320
|
+
throw error;
|
|
1321
|
+
} else {
|
|
1322
|
+
throw augmentRuntimeError(error, this.source);
|
|
1323
|
+
}
|
|
1324
|
+
} else {
|
|
1325
|
+
throw new RuntimeError(errorCode, null);
|
|
1326
|
+
}
|
|
1327
|
+
} else {
|
|
1328
|
+
throw error;
|
|
1329
|
+
}
|
|
1330
|
+
} finally {
|
|
1331
|
+
setInjectImplementation(previousInjectImplementation);
|
|
1332
|
+
setCurrentInjector(previousInjector);
|
|
1333
|
+
ngDevMode && setInjectorProfilerContext(prevInjectContext);
|
|
1018
1334
|
}
|
|
1019
1335
|
}
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1336
|
+
/** @internal */
|
|
1337
|
+
resolveInjectorInitializers() {
|
|
1338
|
+
const previousInjector = setCurrentInjector(this);
|
|
1339
|
+
const previousInjectImplementation = setInjectImplementation(void 0);
|
|
1340
|
+
let prevInjectContext;
|
|
1341
|
+
if (ngDevMode) {
|
|
1342
|
+
prevInjectContext = setInjectorProfilerContext({ injector: this, token: null });
|
|
1343
|
+
}
|
|
1344
|
+
try {
|
|
1345
|
+
const initializers = this.get(ENVIRONMENT_INITIALIZER, EMPTY_ARRAY, { self: true });
|
|
1346
|
+
if (ngDevMode && !Array.isArray(initializers)) {
|
|
1347
|
+
throw new RuntimeError(
|
|
1348
|
+
-209 /* INVALID_MULTI_PROVIDER */,
|
|
1349
|
+
`Unexpected type of the \`ENVIRONMENT_INITIALIZER\` token value (expected an array, but got ${typeof initializers}). Please check that the \`ENVIRONMENT_INITIALIZER\` token is configured as a \`multi: true\` provider.`
|
|
1350
|
+
);
|
|
1351
|
+
}
|
|
1352
|
+
for (const initializer of initializers) {
|
|
1353
|
+
initializer();
|
|
1354
|
+
}
|
|
1355
|
+
} finally {
|
|
1356
|
+
setCurrentInjector(previousInjector);
|
|
1357
|
+
setInjectImplementation(previousInjectImplementation);
|
|
1358
|
+
ngDevMode && setInjectorProfilerContext(prevInjectContext);
|
|
1040
1359
|
}
|
|
1041
1360
|
}
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
link.nextConsumer = void 0;
|
|
1049
|
-
link.prevConsumer = void 0;
|
|
1050
|
-
if (nextConsumer !== void 0) {
|
|
1051
|
-
nextConsumer.prevConsumer = prevConsumer;
|
|
1052
|
-
} else {
|
|
1053
|
-
producer.consumersTail = prevConsumer;
|
|
1054
|
-
}
|
|
1055
|
-
if (prevConsumer !== void 0) {
|
|
1056
|
-
prevConsumer.nextConsumer = nextConsumer;
|
|
1057
|
-
} else {
|
|
1058
|
-
producer.consumers = nextConsumer;
|
|
1059
|
-
if (!consumerIsLive(producer)) {
|
|
1060
|
-
let producerLink = producer.producers;
|
|
1061
|
-
while (producerLink !== void 0) {
|
|
1062
|
-
producerLink = producerRemoveLiveConsumerLink(producerLink);
|
|
1361
|
+
toString() {
|
|
1362
|
+
if (ngDevMode) {
|
|
1363
|
+
const tokens = [];
|
|
1364
|
+
const records = this.records;
|
|
1365
|
+
for (const token of records.keys()) {
|
|
1366
|
+
tokens.push(stringify(token));
|
|
1063
1367
|
}
|
|
1368
|
+
return `R3Injector[${tokens.join(", ")}]`;
|
|
1064
1369
|
}
|
|
1370
|
+
return "R3Injector[...]";
|
|
1065
1371
|
}
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1372
|
+
/**
|
|
1373
|
+
* Process a `SingleProvider` and add it.
|
|
1374
|
+
*/
|
|
1375
|
+
processProvider(provider) {
|
|
1376
|
+
provider = resolveForwardRef(provider);
|
|
1377
|
+
let token = isTypeProvider(provider) ? provider : resolveForwardRef(provider && provider.provide);
|
|
1378
|
+
const record = providerToRecord(provider);
|
|
1379
|
+
if (ngDevMode) {
|
|
1380
|
+
runInInjectorProfilerContext(this, token, () => {
|
|
1381
|
+
if (isValueProvider(provider)) {
|
|
1382
|
+
emitInjectorToCreateInstanceEvent(token);
|
|
1383
|
+
emitInstanceCreatedByInjectorEvent(provider.useValue);
|
|
1384
|
+
}
|
|
1385
|
+
emitProviderConfiguredEvent(provider);
|
|
1386
|
+
});
|
|
1387
|
+
}
|
|
1388
|
+
if (!isTypeProvider(provider) && provider.multi === true) {
|
|
1389
|
+
let multiRecord = this.records.get(token);
|
|
1390
|
+
if (multiRecord) {
|
|
1391
|
+
if (ngDevMode && multiRecord.multi === void 0) {
|
|
1392
|
+
throwMixedMultiProviderError();
|
|
1393
|
+
}
|
|
1394
|
+
} else {
|
|
1395
|
+
multiRecord = makeRecord(void 0, NOT_YET, true);
|
|
1396
|
+
multiRecord.factory = () => injectArgs(multiRecord.multi);
|
|
1397
|
+
this.records.set(token, multiRecord);
|
|
1081
1398
|
}
|
|
1082
|
-
|
|
1083
|
-
|
|
1399
|
+
token = provider;
|
|
1400
|
+
multiRecord.multi.push(provider);
|
|
1401
|
+
} else {
|
|
1402
|
+
if (ngDevMode) {
|
|
1403
|
+
const existing = this.records.get(token);
|
|
1404
|
+
if (existing && existing.multi !== void 0) {
|
|
1405
|
+
throwMixedMultiProviderError();
|
|
1406
|
+
}
|
|
1084
1407
|
}
|
|
1085
|
-
link = link.nextProducer;
|
|
1086
|
-
} while (link !== void 0);
|
|
1087
|
-
}
|
|
1088
|
-
return false;
|
|
1089
|
-
}
|
|
1090
|
-
|
|
1091
|
-
// src/primitives/signals/src/equality.ts
|
|
1092
|
-
function defaultEquals(a, b) {
|
|
1093
|
-
return Object.is(a, b);
|
|
1094
|
-
}
|
|
1095
|
-
|
|
1096
|
-
// src/primitives/signals/src/computed.ts
|
|
1097
|
-
function createComputed(computation, equal) {
|
|
1098
|
-
const node = Object.create(COMPUTED_NODE);
|
|
1099
|
-
node.computation = computation;
|
|
1100
|
-
if (equal !== void 0) {
|
|
1101
|
-
node.equal = equal;
|
|
1102
|
-
}
|
|
1103
|
-
const computed2 = () => {
|
|
1104
|
-
producerUpdateValueVersion(node);
|
|
1105
|
-
producerAccessed(node);
|
|
1106
|
-
if (node.value === ERRORED) {
|
|
1107
|
-
throw node.error;
|
|
1108
1408
|
}
|
|
1109
|
-
|
|
1110
|
-
};
|
|
1111
|
-
computed2[SIGNAL] = node;
|
|
1112
|
-
if (false) {
|
|
1113
|
-
const debugName = node.debugName ? " (" + node.debugName + ")" : "";
|
|
1114
|
-
computed2.toString = () => `[Computed${debugName}: ${node.value}]`;
|
|
1409
|
+
this.records.set(token, record);
|
|
1115
1410
|
}
|
|
1116
|
-
|
|
1117
|
-
return computed2;
|
|
1118
|
-
}
|
|
1119
|
-
var UNSET = /* @__PURE__ */ Symbol("UNSET");
|
|
1120
|
-
var COMPUTING = /* @__PURE__ */ Symbol("COMPUTING");
|
|
1121
|
-
var ERRORED = /* @__PURE__ */ Symbol("ERRORED");
|
|
1122
|
-
var COMPUTED_NODE = /* @__PURE__ */ (() => ({
|
|
1123
|
-
...REACTIVE_NODE,
|
|
1124
|
-
value: UNSET,
|
|
1125
|
-
dirty: true,
|
|
1126
|
-
error: null,
|
|
1127
|
-
equal: defaultEquals,
|
|
1128
|
-
kind: "computed",
|
|
1129
|
-
producerMustRecompute(node) {
|
|
1130
|
-
return node.value === UNSET || node.value === COMPUTING;
|
|
1131
|
-
},
|
|
1132
|
-
producerRecomputeValue(node) {
|
|
1133
|
-
if (node.value === COMPUTING) {
|
|
1134
|
-
throw new Error(false ? "Detected cycle in computations." : "");
|
|
1135
|
-
}
|
|
1136
|
-
const oldValue = node.value;
|
|
1137
|
-
node.value = COMPUTING;
|
|
1138
|
-
const prevConsumer = consumerBeforeComputation(node);
|
|
1139
|
-
let newValue;
|
|
1140
|
-
let wasEqual = false;
|
|
1411
|
+
hydrate(token, record, flags) {
|
|
1141
1412
|
try {
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1413
|
+
if (record.value === CIRCULAR) {
|
|
1414
|
+
throw cyclicDependencyError(ngDevMode ? stringify(token) : "");
|
|
1415
|
+
} else if (record.value === NOT_YET) {
|
|
1416
|
+
record.value = CIRCULAR;
|
|
1417
|
+
if (ngDevMode) {
|
|
1418
|
+
runInInjectorProfilerContext(this, token, () => {
|
|
1419
|
+
emitInjectorToCreateInstanceEvent(token);
|
|
1420
|
+
record.value = record.factory(void 0, flags);
|
|
1421
|
+
emitInstanceCreatedByInjectorEvent(record.value);
|
|
1422
|
+
});
|
|
1423
|
+
} else {
|
|
1424
|
+
record.value = record.factory(void 0, flags);
|
|
1425
|
+
}
|
|
1426
|
+
}
|
|
1427
|
+
if (typeof record.value === "object" && record.value && hasOnDestroy(record.value)) {
|
|
1428
|
+
this._ngOnDestroyHooks.add(record.value);
|
|
1429
|
+
}
|
|
1430
|
+
return record.value;
|
|
1148
1431
|
} finally {
|
|
1149
|
-
consumerAfterComputation(node, prevConsumer);
|
|
1150
1432
|
}
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1433
|
+
}
|
|
1434
|
+
injectableDefInScope(def) {
|
|
1435
|
+
if (!def.providedIn) {
|
|
1436
|
+
return false;
|
|
1437
|
+
}
|
|
1438
|
+
const providedIn = resolveForwardRef(def.providedIn);
|
|
1439
|
+
if (typeof providedIn === "string") {
|
|
1440
|
+
return providedIn === "any" || this.scopes.has(providedIn);
|
|
1441
|
+
} else {
|
|
1442
|
+
return this.injectorDefTypes.has(providedIn);
|
|
1154
1443
|
}
|
|
1155
|
-
node.value = newValue;
|
|
1156
|
-
node.version++;
|
|
1157
1444
|
}
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
}
|
|
1164
|
-
|
|
1165
|
-
function
|
|
1166
|
-
|
|
1445
|
+
removeOnDestroy(callback) {
|
|
1446
|
+
const destroyCBIdx = this._onDestroyHooks.indexOf(callback);
|
|
1447
|
+
if (destroyCBIdx !== -1) {
|
|
1448
|
+
this._onDestroyHooks.splice(destroyCBIdx, 1);
|
|
1449
|
+
}
|
|
1450
|
+
}
|
|
1451
|
+
};
|
|
1452
|
+
function injectableDefOrInjectorDefFactory(token) {
|
|
1453
|
+
const injectableDef = getInjectableDef(token);
|
|
1454
|
+
const factory = injectableDef !== null ? injectableDef.factory : getFactoryDef(token);
|
|
1455
|
+
if (factory !== null) {
|
|
1456
|
+
return factory;
|
|
1457
|
+
}
|
|
1458
|
+
if (token instanceof InjectionToken) {
|
|
1459
|
+
throw new RuntimeError(-204 /* INVALID_INJECTION_TOKEN */, ngDevMode && `Token ${stringify(token)} is missing a ɵprov definition.`);
|
|
1460
|
+
}
|
|
1461
|
+
if (token instanceof Function) {
|
|
1462
|
+
return getUndecoratedInjectableFactory(token);
|
|
1463
|
+
}
|
|
1464
|
+
throw new RuntimeError(-204 /* INVALID_INJECTION_TOKEN */, ngDevMode && "unreachable");
|
|
1167
1465
|
}
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
const node = Object.create(SIGNAL_NODE);
|
|
1173
|
-
node.value = initialValue;
|
|
1174
|
-
if (equal !== void 0) {
|
|
1175
|
-
node.equal = equal;
|
|
1466
|
+
function getUndecoratedInjectableFactory(token) {
|
|
1467
|
+
const paramLength = token.length;
|
|
1468
|
+
if (paramLength > 0) {
|
|
1469
|
+
throw new RuntimeError(-204 /* INVALID_INJECTION_TOKEN */, ngDevMode && `Can't resolve all parameters for ${stringify(token)}: (${newArray(paramLength, "?").join(", ")}).`);
|
|
1176
1470
|
}
|
|
1177
|
-
const
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1471
|
+
const inheritedInjectableDef = getInheritedInjectableDef(token);
|
|
1472
|
+
if (inheritedInjectableDef !== null) {
|
|
1473
|
+
return () => inheritedInjectableDef.factory(token);
|
|
1474
|
+
} else {
|
|
1475
|
+
return () => new token();
|
|
1182
1476
|
}
|
|
1183
|
-
runPostProducerCreatedFn(node);
|
|
1184
|
-
const set = (newValue) => signalSetFn(node, newValue);
|
|
1185
|
-
const update = (updateFn) => signalUpdateFn(node, updateFn);
|
|
1186
|
-
return [getter, set, update];
|
|
1187
1477
|
}
|
|
1188
|
-
function
|
|
1189
|
-
|
|
1190
|
-
|
|
1478
|
+
function providerToRecord(provider) {
|
|
1479
|
+
if (isValueProvider(provider)) {
|
|
1480
|
+
return makeRecord(void 0, provider.useValue);
|
|
1481
|
+
} else {
|
|
1482
|
+
const factory = providerToFactory(provider);
|
|
1483
|
+
return makeRecord(factory, NOT_YET);
|
|
1484
|
+
}
|
|
1191
1485
|
}
|
|
1192
|
-
function
|
|
1193
|
-
|
|
1194
|
-
|
|
1486
|
+
function providerToFactory(provider, ngModuleType, providers) {
|
|
1487
|
+
let factory = void 0;
|
|
1488
|
+
if (ngDevMode && isEnvironmentProviders(provider)) {
|
|
1489
|
+
throwInvalidProviderError(void 0, providers, provider);
|
|
1195
1490
|
}
|
|
1196
|
-
if (
|
|
1197
|
-
|
|
1198
|
-
|
|
1491
|
+
if (isTypeProvider(provider)) {
|
|
1492
|
+
const unwrappedProvider = resolveForwardRef(provider);
|
|
1493
|
+
return getFactoryDef(unwrappedProvider) || injectableDefOrInjectorDefFactory(unwrappedProvider);
|
|
1494
|
+
} else {
|
|
1495
|
+
if (isValueProvider(provider)) {
|
|
1496
|
+
factory = () => resolveForwardRef(provider.useValue);
|
|
1497
|
+
} else if (isFactoryProvider(provider)) {
|
|
1498
|
+
factory = () => provider.useFactory(...injectArgs(provider.deps || []));
|
|
1499
|
+
} else if (isExistingProvider(provider)) {
|
|
1500
|
+
factory = (_, flags) => ɵɵinject(resolveForwardRef(provider.useExisting), flags !== void 0 && flags & 8 /* Optional */ ? 8 /* Optional */ : void 0);
|
|
1501
|
+
} else {
|
|
1502
|
+
const classRef = resolveForwardRef(provider && (provider.useClass || provider.provide));
|
|
1503
|
+
if (ngDevMode && !classRef) {
|
|
1504
|
+
throwInvalidProviderError(ngModuleType, providers, provider);
|
|
1505
|
+
}
|
|
1506
|
+
if (hasDeps(provider)) {
|
|
1507
|
+
factory = () => new classRef(...injectArgs(provider.deps));
|
|
1508
|
+
} else {
|
|
1509
|
+
return getFactoryDef(classRef) || injectableDefOrInjectorDefFactory(classRef);
|
|
1510
|
+
}
|
|
1511
|
+
}
|
|
1199
1512
|
}
|
|
1513
|
+
return factory;
|
|
1200
1514
|
}
|
|
1201
|
-
function
|
|
1202
|
-
if (
|
|
1203
|
-
|
|
1515
|
+
function assertNotDestroyed(injector) {
|
|
1516
|
+
if (injector.destroyed) {
|
|
1517
|
+
throw new RuntimeError(-205 /* INJECTOR_ALREADY_DESTROYED */, ngDevMode && "Injector has already been destroyed.");
|
|
1204
1518
|
}
|
|
1205
|
-
signalSetFn(node, updater(node.value));
|
|
1206
1519
|
}
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
}
|
|
1213
|
-
function signalValueChanged(node) {
|
|
1214
|
-
node.version++;
|
|
1215
|
-
producerIncrementEpoch();
|
|
1216
|
-
producerNotifyConsumers(node);
|
|
1217
|
-
postSignalSetFn?.(node);
|
|
1520
|
+
function makeRecord(factory, value, multi = false) {
|
|
1521
|
+
return {
|
|
1522
|
+
factory,
|
|
1523
|
+
value,
|
|
1524
|
+
multi: multi ? [] : void 0
|
|
1525
|
+
};
|
|
1218
1526
|
}
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1527
|
+
function hasDeps(value) {
|
|
1528
|
+
return !!value.deps;
|
|
1529
|
+
}
|
|
1530
|
+
function hasOnDestroy(value) {
|
|
1531
|
+
return value !== null && typeof value === "object" && typeof value.ngOnDestroy === "function";
|
|
1532
|
+
}
|
|
1533
|
+
function couldBeInjectableType(value) {
|
|
1534
|
+
return typeof value === "function" || typeof value === "object" && value.ngMetadataName === "InjectionToken";
|
|
1535
|
+
}
|
|
1536
|
+
function forEachSingleProvider(providers, fn) {
|
|
1537
|
+
for (const provider of providers) {
|
|
1538
|
+
if (Array.isArray(provider)) {
|
|
1539
|
+
forEachSingleProvider(provider, fn);
|
|
1540
|
+
} else if (provider && isEnvironmentProviders(provider)) {
|
|
1541
|
+
forEachSingleProvider(provider.ɵproviders, fn);
|
|
1542
|
+
} else {
|
|
1543
|
+
fn(provider);
|
|
1233
1544
|
}
|
|
1234
|
-
return node.value;
|
|
1235
|
-
};
|
|
1236
|
-
const getter = linkedSignalGetter;
|
|
1237
|
-
getter[SIGNAL] = node;
|
|
1238
|
-
if (false) {
|
|
1239
|
-
const debugName = node.debugName ? " (" + node.debugName + ")" : "";
|
|
1240
|
-
getter.toString = () => `[LinkedSignal${debugName}: ${node.value}]`;
|
|
1241
1545
|
}
|
|
1242
|
-
runPostProducerCreatedFn(node);
|
|
1243
|
-
return getter;
|
|
1244
|
-
}
|
|
1245
|
-
function linkedSignalSetFn(node, newValue) {
|
|
1246
|
-
producerUpdateValueVersion(node);
|
|
1247
|
-
signalSetFn(node, newValue);
|
|
1248
|
-
producerMarkClean(node);
|
|
1249
1546
|
}
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1547
|
+
|
|
1548
|
+
// src/import/util/closure.ts
|
|
1549
|
+
function noSideEffects(fn) {
|
|
1550
|
+
return { toString: fn }.toString();
|
|
1254
1551
|
}
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
},
|
|
1265
|
-
producerRecomputeValue(node) {
|
|
1266
|
-
if (node.value === COMPUTING) {
|
|
1267
|
-
throw new Error(false ? "Detected cycle in computations." : "");
|
|
1552
|
+
|
|
1553
|
+
// src/import/util/decorators.ts
|
|
1554
|
+
function makeMetadataCtor(props) {
|
|
1555
|
+
return function ctor(...args) {
|
|
1556
|
+
if (props) {
|
|
1557
|
+
const values = props(...args);
|
|
1558
|
+
for (const propName in values) {
|
|
1559
|
+
this[propName] = values[propName];
|
|
1560
|
+
}
|
|
1268
1561
|
}
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
value: oldValue
|
|
1278
|
-
};
|
|
1279
|
-
newValue = node.computation(newSourceValue, prev);
|
|
1280
|
-
node.sourceValue = newSourceValue;
|
|
1281
|
-
} catch (err) {
|
|
1282
|
-
newValue = ERRORED;
|
|
1283
|
-
node.error = err;
|
|
1284
|
-
} finally {
|
|
1285
|
-
consumerAfterComputation(node, prevConsumer);
|
|
1562
|
+
};
|
|
1563
|
+
}
|
|
1564
|
+
function makeParamDecorator(name, props, parentClass) {
|
|
1565
|
+
return noSideEffects(() => {
|
|
1566
|
+
const metaCtor = makeMetadataCtor(props);
|
|
1567
|
+
function ParamDecoratorFactory(...args) {
|
|
1568
|
+
metaCtor.apply(this, args);
|
|
1569
|
+
return this;
|
|
1286
1570
|
}
|
|
1287
|
-
if (
|
|
1288
|
-
node.value = oldValue;
|
|
1289
|
-
return;
|
|
1571
|
+
if (parentClass) {
|
|
1290
1572
|
}
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
}))();
|
|
1573
|
+
return ParamDecoratorFactory;
|
|
1574
|
+
});
|
|
1575
|
+
}
|
|
1295
1576
|
|
|
1296
|
-
// src/
|
|
1297
|
-
|
|
1298
|
-
const
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1577
|
+
// src/import/di/metadata.ts
|
|
1578
|
+
var Inject = attachInjectFlag(
|
|
1579
|
+
// Disable tslint because `DecoratorFlags` is a const enum which gets inlined.
|
|
1580
|
+
makeParamDecorator("Inject", (token) => ({ token })),
|
|
1581
|
+
// tslint:disable-next-line: no-toplevel-property-access
|
|
1582
|
+
-1 /* Inject */
|
|
1583
|
+
);
|
|
1584
|
+
var Optional = (
|
|
1585
|
+
// Disable tslint because `InternalInjectFlags` is a const enum which gets inlined.
|
|
1586
|
+
// tslint:disable-next-line: no-toplevel-property-access
|
|
1587
|
+
attachInjectFlag(makeParamDecorator("Optional"), 8 /* Optional */)
|
|
1588
|
+
);
|
|
1589
|
+
var Self = (
|
|
1590
|
+
// Disable tslint because `InternalInjectFlags` is a const enum which gets inlined.
|
|
1591
|
+
// tslint:disable-next-line: no-toplevel-property-access
|
|
1592
|
+
attachInjectFlag(makeParamDecorator("Self"), 2 /* Self */)
|
|
1593
|
+
);
|
|
1594
|
+
var SkipSelf = (
|
|
1595
|
+
// Disable tslint because `InternalInjectFlags` is a const enum which gets inlined.
|
|
1596
|
+
// tslint:disable-next-line: no-toplevel-property-access
|
|
1597
|
+
attachInjectFlag(makeParamDecorator("SkipSelf"), 4 /* SkipSelf */)
|
|
1598
|
+
);
|
|
1599
|
+
|
|
1600
|
+
// src/import/di/create_injector.ts
|
|
1601
|
+
function createInjector(defType, parent = null, additionalProviders = null, name) {
|
|
1602
|
+
const injector = createInjectorWithoutInjectorInstances(defType, parent, additionalProviders, name);
|
|
1603
|
+
injector.resolveInjectorInitializers();
|
|
1604
|
+
return injector;
|
|
1605
|
+
}
|
|
1606
|
+
function createInjectorWithoutInjectorInstances(defType, parent = null, additionalProviders = null, name, scopes = /* @__PURE__ */ new Set()) {
|
|
1607
|
+
const providers = [additionalProviders || EMPTY_ARRAY];
|
|
1608
|
+
let source = void 0;
|
|
1609
|
+
if (ngDevMode) {
|
|
1610
|
+
source = name || (typeof defType === "object" ? void 0 : stringify(defType));
|
|
1303
1611
|
}
|
|
1612
|
+
return new R3Injector(providers, parent || getNullInjector(), source || null, scopes);
|
|
1304
1613
|
}
|
|
1305
1614
|
|
|
1306
|
-
// src/
|
|
1307
|
-
var
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
dirty: true,
|
|
1312
|
-
kind: "effect"
|
|
1313
|
-
}))();
|
|
1314
|
-
function runEffect(node) {
|
|
1315
|
-
node.dirty = false;
|
|
1316
|
-
if (node.version > 0 && !consumerPollProducersForChange(node)) {
|
|
1317
|
-
return;
|
|
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);
|
|
1318
1620
|
}
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1621
|
+
}
|
|
1622
|
+
|
|
1623
|
+
// src/import/di/injector.ts
|
|
1624
|
+
var Injector = class _Injector {
|
|
1625
|
+
static THROW_IF_NOT_FOUND = THROW_IF_NOT_FOUND;
|
|
1626
|
+
static NULL = /* @__PURE__ */ new NullInjector();
|
|
1627
|
+
static create(options, parent) {
|
|
1628
|
+
if (Array.isArray(options)) {
|
|
1629
|
+
return createInjector({ name: "" }, parent, options, "");
|
|
1630
|
+
} else {
|
|
1631
|
+
const name = options.name ?? "";
|
|
1632
|
+
return createInjector({ name }, options.parent, options.providers, name);
|
|
1633
|
+
}
|
|
1326
1634
|
}
|
|
1635
|
+
/** @nocollapse */
|
|
1636
|
+
static ɵprov = (
|
|
1637
|
+
/** @pureOrBreakMyCode */
|
|
1638
|
+
/* @__PURE__ */ ɵɵdefineInjectable({
|
|
1639
|
+
token: _Injector,
|
|
1640
|
+
providedIn: "any",
|
|
1641
|
+
factory: () => ɵɵinject(INJECTOR)
|
|
1642
|
+
})
|
|
1643
|
+
);
|
|
1644
|
+
/**
|
|
1645
|
+
* @internal
|
|
1646
|
+
* @nocollapse
|
|
1647
|
+
*/
|
|
1648
|
+
static __NG_ELEMENT_ID__ = -1 /* Injector */;
|
|
1649
|
+
};
|
|
1650
|
+
if (typeof ngDevMode === "undefined" || ngDevMode) {
|
|
1651
|
+
registerSpecialProvider(Injector);
|
|
1327
1652
|
}
|
|
1328
1653
|
|
|
1329
|
-
// src/
|
|
1330
|
-
|
|
1331
|
-
|
|
1654
|
+
// src/import/render3/instructions/di.ts
|
|
1655
|
+
function ɵɵinvalidFactory() {
|
|
1656
|
+
const msg = ngDevMode ? `This constructor was not compatible with Dependency Injection.` : "invalid";
|
|
1657
|
+
throw new Error(msg);
|
|
1332
1658
|
}
|
|
1333
1659
|
|
|
1334
1660
|
// src/import/render3/reactivity/api.ts
|
|
1335
|
-
function
|
|
1661
|
+
function isSignal2(value) {
|
|
1336
1662
|
return typeof value === "function" && value[SIGNAL] !== void 0;
|
|
1337
1663
|
}
|
|
1664
|
+
function isWritableSignal(value) {
|
|
1665
|
+
return isSignal2(value) && typeof value.set === "function";
|
|
1666
|
+
}
|
|
1338
1667
|
|
|
1339
1668
|
// src/import/render3/reactivity/computed.ts
|
|
1340
1669
|
function computed(computation, options) {
|
|
1341
1670
|
const getter = createComputed(computation, options?.equal);
|
|
1342
|
-
if (
|
|
1671
|
+
if (typeof ngDevMode !== "undefined" && ngDevMode) {
|
|
1672
|
+
const debugName = options?.debugName;
|
|
1673
|
+
getter[SIGNAL].debugName = debugName;
|
|
1674
|
+
getter.toString = () => `[Computed${debugName ? " (" + debugName + ")" : ""}: ${getter()}]`;
|
|
1343
1675
|
}
|
|
1344
1676
|
return getter;
|
|
1345
1677
|
}
|
|
@@ -1355,7 +1687,10 @@ function signal(initialValue, options) {
|
|
|
1355
1687
|
signalFn.set = set;
|
|
1356
1688
|
signalFn.update = update;
|
|
1357
1689
|
signalFn.asReadonly = signalAsReadonlyFn.bind(signalFn);
|
|
1358
|
-
if (
|
|
1690
|
+
if (typeof ngDevMode !== "undefined" && ngDevMode) {
|
|
1691
|
+
const debugName = options?.debugName;
|
|
1692
|
+
node.debugName = debugName;
|
|
1693
|
+
signalFn.toString = () => `[Signal${debugName ? " (" + debugName + ")" : ""}: ${signalFn()}]`;
|
|
1359
1694
|
}
|
|
1360
1695
|
return signalFn;
|
|
1361
1696
|
}
|
|
@@ -1381,7 +1716,9 @@ function linkedSignal(optionsOrComputation, options) {
|
|
|
1381
1716
|
}
|
|
1382
1717
|
}
|
|
1383
1718
|
function upgradeLinkedSignalGetter(getter, debugName) {
|
|
1384
|
-
if (
|
|
1719
|
+
if (typeof ngDevMode !== "undefined" && ngDevMode) {
|
|
1720
|
+
getter[SIGNAL].debugName = debugName;
|
|
1721
|
+
getter.toString = () => `[LinkedSignal${debugName ? " (" + debugName + ")" : ""}: ${getter()}]`;
|
|
1385
1722
|
}
|
|
1386
1723
|
const node = getter[SIGNAL];
|
|
1387
1724
|
const upgradedGetter = getter;
|
|
@@ -1399,7 +1736,45 @@ function untracked2(nonReactiveReadsFn) {
|
|
|
1399
1736
|
// src/import/render3/reactivity/asserts.ts
|
|
1400
1737
|
function assertNotInReactiveContext(debugFn, extraContext) {
|
|
1401
1738
|
if (getActiveConsumer() !== null) {
|
|
1402
|
-
throw new RuntimeError(
|
|
1739
|
+
throw new RuntimeError(
|
|
1740
|
+
-602 /* ASSERTION_NOT_INSIDE_REACTIVE_CONTEXT */,
|
|
1741
|
+
ngDevMode && `${debugFn.name}() cannot be called from within a reactive context.${extraContext ? ` ${extraContext}` : ""}`
|
|
1742
|
+
);
|
|
1743
|
+
}
|
|
1744
|
+
}
|
|
1745
|
+
|
|
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
|
+
}
|
|
1769
|
+
function isInInjectionContext() {
|
|
1770
|
+
return getInjectImplementation() !== void 0 || getCurrentInjector() != null;
|
|
1771
|
+
}
|
|
1772
|
+
function assertInInjectionContext(debugFn) {
|
|
1773
|
+
if (!isInInjectionContext()) {
|
|
1774
|
+
throw new RuntimeError(
|
|
1775
|
+
-203 /* MISSING_INJECTION_CONTEXT */,
|
|
1776
|
+
ngDevMode && debugFn.name + "() can only be used within an injection context such as a constructor, a factory function, a field initializer, or a function used with `runInInjectionContext`"
|
|
1777
|
+
);
|
|
1403
1778
|
}
|
|
1404
1779
|
}
|
|
1405
1780
|
|
|
@@ -1415,9 +1790,8 @@ var DestroyRef = class {
|
|
|
1415
1790
|
*/
|
|
1416
1791
|
static __NG_ENV_ID__ = (injector) => injector;
|
|
1417
1792
|
};
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
function noop(...args) {
|
|
1793
|
+
if (typeof ngDevMode === "undefined" || ngDevMode) {
|
|
1794
|
+
registerSpecialProvider(DestroyRef);
|
|
1421
1795
|
}
|
|
1422
1796
|
|
|
1423
1797
|
// src/import/change_detection/scheduling/zoneless_scheduling.ts
|
|
@@ -1440,10 +1814,6 @@ var NotificationSource = /* @__PURE__ */ ((NotificationSource2) => {
|
|
|
1440
1814
|
})(NotificationSource || {});
|
|
1441
1815
|
var ChangeDetectionScheduler = class {
|
|
1442
1816
|
};
|
|
1443
|
-
var ZONELESS_ENABLED = new InjectionToken("", { providedIn: "root", factory: () => false });
|
|
1444
|
-
var PROVIDED_ZONELESS = new InjectionToken("", { providedIn: "root", factory: () => false });
|
|
1445
|
-
var ZONELESS_SCHEDULER_DISABLED = new InjectionToken("");
|
|
1446
|
-
var SCHEDULE_IN_ROOT_ZONE = new InjectionToken("");
|
|
1447
1817
|
|
|
1448
1818
|
// src/import/render3/reactivity/root_effect_scheduler.ts
|
|
1449
1819
|
var EffectScheduler = class _EffectScheduler {
|
|
@@ -1538,10 +1908,11 @@ var EffectRefImpl = class {
|
|
|
1538
1908
|
}
|
|
1539
1909
|
};
|
|
1540
1910
|
function effect(effectFn, options) {
|
|
1541
|
-
|
|
1911
|
+
ngDevMode && assertNotInReactiveContext(effect, "Call `effect` outside of a reactive context. For example, schedule the effect inside the component constructor.");
|
|
1912
|
+
if (ngDevMode && !options?.injector) {
|
|
1542
1913
|
assertInInjectionContext(effect);
|
|
1543
1914
|
}
|
|
1544
|
-
if (
|
|
1915
|
+
if (ngDevMode && options?.allowSignalWrites !== void 0) {
|
|
1545
1916
|
console.warn(`The 'allowSignalWrites' flag is deprecated and no longer impacts effect() (writes are always allowed)`);
|
|
1546
1917
|
}
|
|
1547
1918
|
const injector = options?.injector ?? inject2(Injector);
|
|
@@ -1551,18 +1922,27 @@ function effect(effectFn, options) {
|
|
|
1551
1922
|
node = createRootEffect(effectFn, injector.get(EffectScheduler), notifier);
|
|
1552
1923
|
node.injector = injector;
|
|
1553
1924
|
if (destroyRef !== null) {
|
|
1554
|
-
node.
|
|
1925
|
+
node.onDestroyFns = [destroyRef.onDestroy(() => node.destroy())];
|
|
1555
1926
|
}
|
|
1556
1927
|
const effectRef = new EffectRefImpl(node);
|
|
1928
|
+
if (ngDevMode) {
|
|
1929
|
+
node.debugName = options?.debugName ?? "";
|
|
1930
|
+
const prevInjectorProfilerContext = setInjectorProfilerContext({ injector, token: null });
|
|
1931
|
+
try {
|
|
1932
|
+
emitEffectCreatedEvent(effectRef);
|
|
1933
|
+
} finally {
|
|
1934
|
+
setInjectorProfilerContext(prevInjectorProfilerContext);
|
|
1935
|
+
}
|
|
1936
|
+
}
|
|
1557
1937
|
return effectRef;
|
|
1558
1938
|
}
|
|
1559
1939
|
var EFFECT_NODE = /* @__PURE__ */ (() => ({
|
|
1560
1940
|
...BASE_EFFECT_NODE,
|
|
1561
1941
|
cleanupFns: void 0,
|
|
1562
1942
|
zone: null,
|
|
1563
|
-
|
|
1943
|
+
onDestroyFns: null,
|
|
1564
1944
|
run() {
|
|
1565
|
-
if (
|
|
1945
|
+
if (ngDevMode && isInNotificationPhase()) {
|
|
1566
1946
|
throw new Error(`Schedulers cannot synchronously execute watches while scheduling.`);
|
|
1567
1947
|
}
|
|
1568
1948
|
try {
|
|
@@ -1593,7 +1973,11 @@ var ROOT_EFFECT_NODE = /* @__PURE__ */ (() => ({
|
|
|
1593
1973
|
},
|
|
1594
1974
|
destroy() {
|
|
1595
1975
|
consumerDestroy(this);
|
|
1596
|
-
this.
|
|
1976
|
+
if (this.onDestroyFns !== null) {
|
|
1977
|
+
for (const fn of this.onDestroyFns) {
|
|
1978
|
+
fn();
|
|
1979
|
+
}
|
|
1980
|
+
}
|
|
1597
1981
|
this.cleanup();
|
|
1598
1982
|
this.scheduler.remove(this);
|
|
1599
1983
|
}
|
|
@@ -1614,6 +1998,10 @@ function createEffectFn(node, fn) {
|
|
|
1614
1998
|
};
|
|
1615
1999
|
}
|
|
1616
2000
|
|
|
2001
|
+
// src/import/util/noop.ts
|
|
2002
|
+
function noop(...args) {
|
|
2003
|
+
}
|
|
2004
|
+
|
|
1617
2005
|
// src/import/util/callback_scheduler.ts
|
|
1618
2006
|
function scheduleCallbackWithMicrotask(callback) {
|
|
1619
2007
|
queueMicrotask(() => callback());
|
|
@@ -1639,48 +2027,124 @@ var ChangeDetectionSchedulerImpl = class {
|
|
|
1639
2027
|
this.cancelScheduledCallback?.();
|
|
1640
2028
|
this.cancelScheduledCallback = null;
|
|
1641
2029
|
}
|
|
1642
|
-
ngOnDestroy() {
|
|
1643
|
-
this.cleanup();
|
|
2030
|
+
ngOnDestroy() {
|
|
2031
|
+
this.cleanup();
|
|
2032
|
+
}
|
|
2033
|
+
};
|
|
2034
|
+
|
|
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
|
+
};
|
|
2055
|
+
|
|
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);
|
|
1644
2078
|
}
|
|
1645
2079
|
};
|
|
1646
2080
|
|
|
1647
|
-
// src/import/
|
|
1648
|
-
|
|
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
|
+
}
|
|
1649
2088
|
|
|
1650
|
-
// src/import/
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
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);
|
|
2104
|
+
}
|
|
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
|
+
});
|
|
1658
2116
|
}
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
let userErrorHandler;
|
|
1665
|
-
return (e) => {
|
|
1666
|
-
if (injector.destroyed && !userErrorHandler) {
|
|
1667
|
-
setTimeout(() => {
|
|
1668
|
-
throw e;
|
|
1669
|
-
});
|
|
1670
|
-
} else {
|
|
1671
|
-
userErrorHandler ??= injector.get(ErrorHandler);
|
|
1672
|
-
userErrorHandler.handleError(e);
|
|
1673
|
-
}
|
|
1674
|
-
};
|
|
2117
|
+
return () => load().then((loadedToken) => injector.get(maybeUnwrapDefaultExport(loadedToken)));
|
|
2118
|
+
}
|
|
2119
|
+
function onIdle(options) {
|
|
2120
|
+
if (ngDevMode) {
|
|
2121
|
+
assertInInjectionContext(onIdle);
|
|
1675
2122
|
}
|
|
1676
|
-
|
|
2123
|
+
const idleService = inject2(IDLE_SERVICE);
|
|
2124
|
+
const { promise, resolve } = promiseWithResolvers();
|
|
2125
|
+
idleService.requestOnIdle(() => resolve(), options);
|
|
2126
|
+
return promise;
|
|
2127
|
+
}
|
|
1677
2128
|
|
|
1678
|
-
// 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
|
|
1679
2142
|
var PendingTasksInternal = class _PendingTasksInternal {
|
|
1680
2143
|
taskId = 0;
|
|
1681
2144
|
pendingTasks = /* @__PURE__ */ new Set();
|
|
1682
2145
|
destroyed = false;
|
|
1683
2146
|
pendingTask = new BehaviorSubject(false);
|
|
2147
|
+
debugTaskTracker = inject2(DEBUG_TASK_TRACKER, { optional: true });
|
|
1684
2148
|
get hasPendingTasks() {
|
|
1685
2149
|
return this.destroyed ? false : this.pendingTask.value;
|
|
1686
2150
|
}
|
|
@@ -1703,6 +2167,7 @@ var PendingTasksInternal = class _PendingTasksInternal {
|
|
|
1703
2167
|
}
|
|
1704
2168
|
const taskId = this.taskId++;
|
|
1705
2169
|
this.pendingTasks.add(taskId);
|
|
2170
|
+
this.debugTaskTracker?.add(taskId);
|
|
1706
2171
|
return taskId;
|
|
1707
2172
|
}
|
|
1708
2173
|
has(taskId) {
|
|
@@ -1710,6 +2175,7 @@ var PendingTasksInternal = class _PendingTasksInternal {
|
|
|
1710
2175
|
}
|
|
1711
2176
|
remove(taskId) {
|
|
1712
2177
|
this.pendingTasks.delete(taskId);
|
|
2178
|
+
this.debugTaskTracker?.remove(taskId);
|
|
1713
2179
|
if (this.pendingTasks.size === 0 && this.hasPendingTasks) {
|
|
1714
2180
|
this.pendingTask.next(false);
|
|
1715
2181
|
}
|
|
@@ -1732,6 +2198,232 @@ var PendingTasksInternal = class _PendingTasksInternal {
|
|
|
1732
2198
|
})
|
|
1733
2199
|
);
|
|
1734
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
|
|
1735
2427
|
var PendingTasks = class _PendingTasks {
|
|
1736
2428
|
internalPendingTasks = inject2(PendingTasksInternal);
|
|
1737
2429
|
scheduler = inject2(ChangeDetectionScheduler);
|
|
@@ -1765,7 +2457,12 @@ var PendingTasks = class _PendingTasks {
|
|
|
1765
2457
|
*/
|
|
1766
2458
|
run(fn) {
|
|
1767
2459
|
const removeTask = this.add();
|
|
1768
|
-
|
|
2460
|
+
try {
|
|
2461
|
+
fn().catch(this.errorHandler).finally(removeTask);
|
|
2462
|
+
} catch (err) {
|
|
2463
|
+
this.errorHandler(err);
|
|
2464
|
+
removeTask();
|
|
2465
|
+
}
|
|
1769
2466
|
}
|
|
1770
2467
|
/** @nocollapse */
|
|
1771
2468
|
static ɵprov = (
|
|
@@ -1778,27 +2475,122 @@ var PendingTasks = class _PendingTasks {
|
|
|
1778
2475
|
);
|
|
1779
2476
|
};
|
|
1780
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
|
+
|
|
1781
2563
|
// src/import/resource/resource.ts
|
|
1782
2564
|
function resource(options) {
|
|
1783
|
-
if (
|
|
2565
|
+
if (ngDevMode && !options?.injector) {
|
|
2566
|
+
assertInInjectionContext(resource);
|
|
1784
2567
|
}
|
|
1785
2568
|
const oldNameForParams = options.request;
|
|
1786
2569
|
const params = options.params ?? oldNameForParams ?? (() => null);
|
|
1787
|
-
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
|
+
);
|
|
1788
2579
|
}
|
|
1789
2580
|
var BaseWritableResource = class {
|
|
1790
2581
|
value;
|
|
1791
|
-
|
|
2582
|
+
isLoading;
|
|
2583
|
+
constructor(value, debugName) {
|
|
1792
2584
|
this.value = value;
|
|
1793
2585
|
this.value.set = this.set.bind(this);
|
|
1794
2586
|
this.value.update = this.update.bind(this);
|
|
1795
2587
|
this.value.asReadonly = signalAsReadonlyFn;
|
|
2588
|
+
this.isLoading = computed(() => this.status() === "loading" || this.status() === "reloading", ngDevMode ? createDebugNameObject(debugName, "isLoading") : void 0);
|
|
1796
2589
|
}
|
|
1797
2590
|
isError = computed(() => this.status() === "error");
|
|
1798
2591
|
update(updateFn) {
|
|
1799
2592
|
this.set(updateFn(untracked2(this.value)));
|
|
1800
2593
|
}
|
|
1801
|
-
isLoading = computed(() => this.status() === "loading" || this.status() === "reloading");
|
|
1802
2594
|
// Use a computed here to avoid triggering reactive consumers if the value changes while staying
|
|
1803
2595
|
// either defined or undefined.
|
|
1804
2596
|
isValueDefined = computed(() => {
|
|
@@ -1807,6 +2599,17 @@ var BaseWritableResource = class {
|
|
|
1807
2599
|
}
|
|
1808
2600
|
return this.value() !== void 0;
|
|
1809
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
|
+
}
|
|
1810
2613
|
hasValue() {
|
|
1811
2614
|
return this.isValueDefined();
|
|
1812
2615
|
}
|
|
@@ -1815,7 +2618,10 @@ var BaseWritableResource = class {
|
|
|
1815
2618
|
}
|
|
1816
2619
|
};
|
|
1817
2620
|
var ResourceImpl = class extends BaseWritableResource {
|
|
1818
|
-
constructor(request, loaderFn, defaultValue, equal, injector) {
|
|
2621
|
+
constructor(request, loaderFn, defaultValue, equal, debugName, injector, transferCacheKey, getInitialStream) {
|
|
2622
|
+
if (isInParamsFunction()) {
|
|
2623
|
+
throw invalidResourceCreationInParams();
|
|
2624
|
+
}
|
|
1819
2625
|
super(
|
|
1820
2626
|
// Feed a computed signal for the value to `BaseWritableResource`, which will upgrade it to a
|
|
1821
2627
|
// `WritableSignal` that delegates to `ResourceImpl.set`.
|
|
@@ -1833,45 +2639,91 @@ var ResourceImpl = class extends BaseWritableResource {
|
|
|
1833
2639
|
}
|
|
1834
2640
|
return streamValue.value;
|
|
1835
2641
|
},
|
|
1836
|
-
{ equal }
|
|
1837
|
-
)
|
|
2642
|
+
{ equal, ...ngDevMode ? createDebugNameObject(debugName, "value") : void 0 }
|
|
2643
|
+
),
|
|
2644
|
+
debugName
|
|
1838
2645
|
);
|
|
1839
2646
|
this.loaderFn = loaderFn;
|
|
1840
2647
|
this.equal = equal;
|
|
1841
|
-
this.
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
});
|
|
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
|
+
);
|
|
1845
2671
|
this.state = linkedSignal({
|
|
1846
2672
|
// Whenever the request changes,
|
|
1847
2673
|
source: this.extRequest,
|
|
1848
2674
|
// Compute the state of the resource given a change in status.
|
|
1849
2675
|
computation: (extRequest, previous) => {
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
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
|
+
}
|
|
1866
2702
|
}
|
|
1867
|
-
|
|
2703
|
+
return {
|
|
2704
|
+
extRequest,
|
|
2705
|
+
status,
|
|
2706
|
+
previousStatus: previous ? projectStatusOfState(previous.value) : "idle",
|
|
2707
|
+
stream
|
|
2708
|
+
};
|
|
2709
|
+
},
|
|
2710
|
+
...ngDevMode ? createDebugNameObject(debugName, "state") : void 0
|
|
1868
2711
|
});
|
|
1869
2712
|
this.effectRef = effect(this.loadEffect.bind(this), {
|
|
1870
2713
|
injector,
|
|
1871
|
-
manualCleanup: true
|
|
2714
|
+
manualCleanup: true,
|
|
2715
|
+
...ngDevMode ? createDebugNameObject(debugName, "loadEffect") : void 0
|
|
1872
2716
|
});
|
|
1873
2717
|
this.pendingTasks = injector.get(PendingTasks);
|
|
1874
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
|
+
);
|
|
1875
2727
|
}
|
|
1876
2728
|
pendingTasks;
|
|
1877
2729
|
/**
|
|
@@ -1888,11 +2740,9 @@ var ResourceImpl = class extends BaseWritableResource {
|
|
|
1888
2740
|
resolvePendingTask = void 0;
|
|
1889
2741
|
destroyed = false;
|
|
1890
2742
|
unregisterOnDestroy;
|
|
1891
|
-
status
|
|
1892
|
-
error
|
|
1893
|
-
|
|
1894
|
-
return stream && !isResolved(stream) ? stream.error : void 0;
|
|
1895
|
-
});
|
|
2743
|
+
status;
|
|
2744
|
+
error;
|
|
2745
|
+
transferState;
|
|
1896
2746
|
/**
|
|
1897
2747
|
* Called either directly via `WritableResource.set` or via `.value.set()`.
|
|
1898
2748
|
*/
|
|
@@ -1912,7 +2762,7 @@ var ResourceImpl = class extends BaseWritableResource {
|
|
|
1912
2762
|
extRequest: state.extRequest,
|
|
1913
2763
|
status: "local",
|
|
1914
2764
|
previousStatus: "local",
|
|
1915
|
-
stream: signal({ value })
|
|
2765
|
+
stream: signal({ value }, ngDevMode ? createDebugNameObject(this.debugName, "stream") : void 0)
|
|
1916
2766
|
});
|
|
1917
2767
|
this.abortInProgressLoad();
|
|
1918
2768
|
}
|
|
@@ -1948,27 +2798,48 @@ var ResourceImpl = class extends BaseWritableResource {
|
|
|
1948
2798
|
let resolvePendingTask = this.resolvePendingTask = this.pendingTasks.add();
|
|
1949
2799
|
const { signal: abortSignal } = this.pendingController = new AbortController();
|
|
1950
2800
|
try {
|
|
1951
|
-
const stream =
|
|
2801
|
+
const stream = untracked2(
|
|
1952
2802
|
() => this.loaderFn({
|
|
1953
2803
|
params: extRequest.request,
|
|
1954
|
-
// TODO(alxhub): cleanup after g3 removal of `request` alias.
|
|
1955
|
-
request: extRequest.request,
|
|
1956
2804
|
abortSignal,
|
|
1957
2805
|
previous: {
|
|
1958
2806
|
status: previousStatus
|
|
1959
2807
|
}
|
|
1960
2808
|
})
|
|
1961
2809
|
);
|
|
1962
|
-
|
|
1963
|
-
|
|
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
|
+
}
|
|
1964
2840
|
}
|
|
1965
|
-
this.state.set({
|
|
1966
|
-
extRequest,
|
|
1967
|
-
status: "resolved",
|
|
1968
|
-
previousStatus: "resolved",
|
|
1969
|
-
stream
|
|
1970
|
-
});
|
|
1971
2841
|
} catch (err) {
|
|
2842
|
+
rethrowFatalErrors(err);
|
|
1972
2843
|
if (abortSignal.aborted || untracked2(this.extRequest) !== extRequest) {
|
|
1973
2844
|
return;
|
|
1974
2845
|
}
|
|
@@ -1976,7 +2847,7 @@ var ResourceImpl = class extends BaseWritableResource {
|
|
|
1976
2847
|
extRequest,
|
|
1977
2848
|
status: "resolved",
|
|
1978
2849
|
previousStatus: "error",
|
|
1979
|
-
stream: signal({ error: encapsulateResourceError(err) })
|
|
2850
|
+
stream: signal({ error: encapsulateResourceError(err) }, ngDevMode ? createDebugNameObject(this.debugName, "stream") : void 0)
|
|
1980
2851
|
});
|
|
1981
2852
|
} finally {
|
|
1982
2853
|
resolvePendingTask?.();
|
|
@@ -1990,6 +2861,11 @@ var ResourceImpl = class extends BaseWritableResource {
|
|
|
1990
2861
|
this.resolvePendingTask = void 0;
|
|
1991
2862
|
}
|
|
1992
2863
|
};
|
|
2864
|
+
function saveToTransferState(result, transferCacheKey, transferState) {
|
|
2865
|
+
if (transferCacheKey && transferState && result && isResolved(result)) {
|
|
2866
|
+
transferState.set(transferCacheKey, result.value);
|
|
2867
|
+
}
|
|
2868
|
+
}
|
|
1993
2869
|
function wrapEqualityFn(equal) {
|
|
1994
2870
|
return (a, b) => a === void 0 || b === void 0 ? a === b : equal(a, b);
|
|
1995
2871
|
}
|
|
@@ -1999,9 +2875,9 @@ function getLoader(options) {
|
|
|
1999
2875
|
}
|
|
2000
2876
|
return async (params) => {
|
|
2001
2877
|
try {
|
|
2002
|
-
return signal({ value: await options.loader(params) });
|
|
2878
|
+
return signal({ value: await options.loader(params) }, ngDevMode ? createDebugNameObject(options.debugName, "stream") : void 0);
|
|
2003
2879
|
} catch (err) {
|
|
2004
|
-
return signal({ error: encapsulateResourceError(err) });
|
|
2880
|
+
return signal({ error: encapsulateResourceError(err) }, ngDevMode ? createDebugNameObject(options.debugName, "stream") : void 0);
|
|
2005
2881
|
}
|
|
2006
2882
|
};
|
|
2007
2883
|
}
|
|
@@ -2021,23 +2897,171 @@ function projectStatusOfState(state) {
|
|
|
2021
2897
|
function isResolved(state) {
|
|
2022
2898
|
return state.error === void 0;
|
|
2023
2899
|
}
|
|
2900
|
+
function createDebugNameObject(resourceDebugName, internalSignalDebugName) {
|
|
2901
|
+
return {
|
|
2902
|
+
debugName: `Resource${resourceDebugName ? "#" + resourceDebugName : ""}.${internalSignalDebugName}`
|
|
2903
|
+
};
|
|
2904
|
+
}
|
|
2024
2905
|
function encapsulateResourceError(error) {
|
|
2025
|
-
if (error
|
|
2906
|
+
if (isErrorLike(error)) {
|
|
2026
2907
|
return error;
|
|
2027
2908
|
}
|
|
2028
2909
|
return new ResourceWrappedError(error);
|
|
2029
2910
|
}
|
|
2911
|
+
function isErrorLike(error) {
|
|
2912
|
+
return error instanceof Error || typeof error === "object" && typeof error.name === "string" && typeof error.message === "string";
|
|
2913
|
+
}
|
|
2030
2914
|
var ResourceValueError = class extends Error {
|
|
2031
2915
|
constructor(error) {
|
|
2032
|
-
super(error.message, { cause: error });
|
|
2916
|
+
super(ngDevMode ? `Resource is currently in an error state (see Error.cause for details): ${error.message}` : error.message, { cause: error });
|
|
2033
2917
|
}
|
|
2034
2918
|
};
|
|
2035
2919
|
var ResourceWrappedError = class extends Error {
|
|
2036
2920
|
constructor(error) {
|
|
2037
|
-
super(String(error), { cause: error });
|
|
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 });
|
|
2922
|
+
}
|
|
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();
|
|
2038
2978
|
}
|
|
2039
2979
|
};
|
|
2040
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;
|
|
3064
|
+
|
|
2041
3065
|
// src/import/index.ts
|
|
2042
3066
|
function Injectable(args) {
|
|
2043
3067
|
return (constructor) => {
|
|
@@ -2069,6 +3093,7 @@ function createRootInjector(options) {
|
|
|
2069
3093
|
);
|
|
2070
3094
|
}
|
|
2071
3095
|
export {
|
|
3096
|
+
APP_ID,
|
|
2072
3097
|
ChangeDetectionScheduler,
|
|
2073
3098
|
ChangeDetectionSchedulerImpl,
|
|
2074
3099
|
DecoratorFlags,
|
|
@@ -2076,6 +3101,7 @@ export {
|
|
|
2076
3101
|
EffectScheduler,
|
|
2077
3102
|
EnvironmentInjector,
|
|
2078
3103
|
ErrorHandler,
|
|
3104
|
+
EventEmitter,
|
|
2079
3105
|
INJECTOR_SCOPE,
|
|
2080
3106
|
INTERNAL_APPLICATION_ERROR_HANDLER,
|
|
2081
3107
|
Inject,
|
|
@@ -2089,20 +3115,20 @@ export {
|
|
|
2089
3115
|
NotificationSource,
|
|
2090
3116
|
NullInjector,
|
|
2091
3117
|
Optional,
|
|
2092
|
-
PROVIDED_ZONELESS,
|
|
2093
3118
|
PendingTasks,
|
|
2094
|
-
PendingTasksInternal,
|
|
2095
3119
|
R3Injector,
|
|
3120
|
+
ResourceDependencyError,
|
|
3121
|
+
ResourceParamsStatus,
|
|
2096
3122
|
RetrievingInjector,
|
|
2097
3123
|
RootStaticInjectOptions,
|
|
2098
|
-
SCHEDULE_IN_ROOT_ZONE,
|
|
2099
3124
|
SOURCE,
|
|
2100
3125
|
Self,
|
|
2101
3126
|
SkipSelf,
|
|
2102
3127
|
StaticInjectOptions,
|
|
2103
3128
|
THROW_IF_NOT_FOUND,
|
|
2104
|
-
|
|
2105
|
-
|
|
3129
|
+
TransferState,
|
|
3130
|
+
Type,
|
|
3131
|
+
assertInInjectionContext,
|
|
2106
3132
|
assertNotDestroyed,
|
|
2107
3133
|
assertNotInReactiveContext,
|
|
2108
3134
|
attachInjectFlag,
|
|
@@ -2110,8 +3136,9 @@ export {
|
|
|
2110
3136
|
convertToBitFlags,
|
|
2111
3137
|
createInjector2 as createInjector,
|
|
2112
3138
|
createRootInjector,
|
|
3139
|
+
debounced,
|
|
2113
3140
|
effect,
|
|
2114
|
-
|
|
3141
|
+
forwardRef,
|
|
2115
3142
|
getCurrentInjector,
|
|
2116
3143
|
getInheritedInjectableDef,
|
|
2117
3144
|
getInjectFlag,
|
|
@@ -2120,12 +3147,20 @@ export {
|
|
|
2120
3147
|
getNullInjector,
|
|
2121
3148
|
inject2 as inject,
|
|
2122
3149
|
injectArgs,
|
|
3150
|
+
injectAsync,
|
|
2123
3151
|
injectInjectorOnly,
|
|
2124
3152
|
isInjectable,
|
|
2125
|
-
isSignal,
|
|
3153
|
+
isSignal2 as isSignal,
|
|
3154
|
+
isWritableSignal,
|
|
2126
3155
|
linkedSignal,
|
|
3156
|
+
makeStateKey,
|
|
3157
|
+
onIdle,
|
|
3158
|
+
provideIdleServiceWith,
|
|
2127
3159
|
providerToFactory,
|
|
3160
|
+
resolveForwardRef,
|
|
2128
3161
|
resource,
|
|
3162
|
+
resourceFromSnapshots,
|
|
3163
|
+
runInInjectionContext,
|
|
2129
3164
|
setCurrentInjector,
|
|
2130
3165
|
signal,
|
|
2131
3166
|
untracked2 as untracked,
|
|
@@ -2145,11 +3180,4 @@ export {
|
|
|
2145
3180
|
* Use of this source code is governed by an MIT-style license that can be
|
|
2146
3181
|
* found in the LICENSE file at https://angular.dev/license
|
|
2147
3182
|
*/
|
|
2148
|
-
/**
|
|
2149
|
-
* @license
|
|
2150
|
-
* Copyright Google LLC All Rights Reserved.
|
|
2151
|
-
*
|
|
2152
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
2153
|
-
* found in the LICENSE file at https://angular.io/license
|
|
2154
|
-
*/
|
|
2155
3183
|
//# sourceMappingURL=index.mjs.map
|