static-injector 6.3.1 → 6.4.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/di/index.d.ts +1 -0
- package/import/render3/debug/injector_profiler.d.ts +133 -0
- package/import/render3/errors_di.d.ts +25 -0
- package/import/render3/util/stringify_utils.d.ts +21 -0
- package/import/util/array_utils.d.ts +132 -0
- package/import/util/assert.d.ts +28 -0
- package/index.js +1502 -1142
- package/index.js.map +4 -4
- package/index.mjs +1502 -1142
- package/index.mjs.map +4 -4
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -73,7 +73,7 @@ __export(import_exports, {
|
|
|
73
73
|
injectArgs: () => injectArgs,
|
|
74
74
|
injectInjectorOnly: () => injectInjectorOnly,
|
|
75
75
|
isInjectable: () => isInjectable,
|
|
76
|
-
isSignal: () =>
|
|
76
|
+
isSignal: () => isSignal2,
|
|
77
77
|
linkedSignal: () => linkedSignal,
|
|
78
78
|
providerToFactory: () => providerToFactory,
|
|
79
79
|
resource: () => resource,
|
|
@@ -91,6 +91,9 @@ __export(import_exports, {
|
|
|
91
91
|
});
|
|
92
92
|
module.exports = __toCommonJS(import_exports);
|
|
93
93
|
|
|
94
|
+
// script/shim.js
|
|
95
|
+
var ngDevMode = typeof ngDevMode === "undefined" ? true : ngDevMode;
|
|
96
|
+
|
|
94
97
|
// src/import/di/interface/provider.ts
|
|
95
98
|
function isEnvironmentProviders(value) {
|
|
96
99
|
return value && !!value.ɵproviders;
|
|
@@ -108,17 +111,15 @@ function formatRuntimeErrorCode(code) {
|
|
|
108
111
|
}
|
|
109
112
|
function formatRuntimeError(code, message) {
|
|
110
113
|
const fullCode = formatRuntimeErrorCode(code);
|
|
111
|
-
|
|
112
|
-
if (
|
|
114
|
+
let errorMessage = `${fullCode}${message ? ": " + message : ""}`;
|
|
115
|
+
if (ngDevMode && code < 0) {
|
|
116
|
+
const addPeriodSeparator = !errorMessage.match(/[.,;!?\n]$/);
|
|
117
|
+
const separator = addPeriodSeparator ? "." : "";
|
|
118
|
+
errorMessage = `${errorMessage}${separator} Find more at ${"https://v20.angular.dev/errors"}/${fullCode}`;
|
|
113
119
|
}
|
|
114
120
|
return errorMessage;
|
|
115
121
|
}
|
|
116
122
|
|
|
117
|
-
// src/import/render3/definition_factory.ts
|
|
118
|
-
function getFactoryDef(type, throwNotFound) {
|
|
119
|
-
return () => new type();
|
|
120
|
-
}
|
|
121
|
-
|
|
122
123
|
// src/import/util/property.ts
|
|
123
124
|
function getClosureSafeProperty(objWithPropertyToExtract) {
|
|
124
125
|
for (const key in objWithPropertyToExtract) {
|
|
@@ -126,41 +127,7 @@ function getClosureSafeProperty(objWithPropertyToExtract) {
|
|
|
126
127
|
return key;
|
|
127
128
|
}
|
|
128
129
|
}
|
|
129
|
-
throw Error("");
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
// src/import/render3/errors_di.ts
|
|
133
|
-
var NG_RUNTIME_ERROR_CODE = getClosureSafeProperty({ ngErrorCode: getClosureSafeProperty });
|
|
134
|
-
var NG_RUNTIME_ERROR_MESSAGE = getClosureSafeProperty({ ngErrorMessage: getClosureSafeProperty });
|
|
135
|
-
var NG_TOKEN_PATH = getClosureSafeProperty({ ngTokenPath: getClosureSafeProperty });
|
|
136
|
-
function cyclicDependencyError(token, path) {
|
|
137
|
-
const message = "";
|
|
138
|
-
return createRuntimeError(message, -200 /* CYCLIC_DI_DEPENDENCY */, path);
|
|
139
|
-
}
|
|
140
|
-
function throwProviderNotFoundError(token, injectorName) {
|
|
141
|
-
const errorMessage = void 0;
|
|
142
|
-
throw new RuntimeError(-201 /* PROVIDER_NOT_FOUND */, errorMessage);
|
|
143
|
-
}
|
|
144
|
-
function createRuntimeError(message, code, path) {
|
|
145
|
-
const error = new RuntimeError(code, message);
|
|
146
|
-
error[NG_RUNTIME_ERROR_CODE] = code;
|
|
147
|
-
error[NG_RUNTIME_ERROR_MESSAGE] = message;
|
|
148
|
-
if (path) {
|
|
149
|
-
error[NG_TOKEN_PATH] = path;
|
|
150
|
-
}
|
|
151
|
-
return error;
|
|
152
|
-
}
|
|
153
|
-
function getRuntimeErrorCode(error) {
|
|
154
|
-
return error[NG_RUNTIME_ERROR_CODE];
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
// src/import/render3/fields.ts
|
|
158
|
-
var NG_FACTORY_DEF = getClosureSafeProperty({ ɵfac: getClosureSafeProperty });
|
|
159
|
-
var NG_ENV_ID = getClosureSafeProperty({ __NG_ENV_ID__: getClosureSafeProperty });
|
|
160
|
-
|
|
161
|
-
// src/import/util/empty.ts
|
|
162
|
-
var EMPTY_ARRAY = [];
|
|
163
|
-
if (false) {
|
|
130
|
+
throw Error(typeof ngDevMode !== "undefined" && ngDevMode ? "Could not find renamed property on target object." : "");
|
|
164
131
|
}
|
|
165
132
|
|
|
166
133
|
// src/import/util/stringify.ts
|
|
@@ -202,1237 +169,1599 @@ function isForwardRef(fn) {
|
|
|
202
169
|
return typeof fn === "function" && fn.hasOwnProperty(__forward_ref__) && fn.__forward_ref__ === forwardRef;
|
|
203
170
|
}
|
|
204
171
|
|
|
205
|
-
// src/
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
return { providers: options.providers || [], imports: options.imports || [] };
|
|
216
|
-
}
|
|
217
|
-
function getInjectableDef(type) {
|
|
218
|
-
return getOwnDefinition(type, NG_PROV_DEF) || { token: type, factory: () => new type(), ...type.injectOptions };
|
|
172
|
+
// src/primitives/signals/src/graph.ts
|
|
173
|
+
var activeConsumer = null;
|
|
174
|
+
var inNotificationPhase = false;
|
|
175
|
+
var epoch = 1;
|
|
176
|
+
var postProducerCreatedFn = null;
|
|
177
|
+
var SIGNAL = /* @__PURE__ */ Symbol("SIGNAL");
|
|
178
|
+
function setActiveConsumer(consumer) {
|
|
179
|
+
const prev = activeConsumer;
|
|
180
|
+
activeConsumer = consumer;
|
|
181
|
+
return prev;
|
|
219
182
|
}
|
|
220
|
-
function
|
|
221
|
-
return
|
|
183
|
+
function getActiveConsumer() {
|
|
184
|
+
return activeConsumer;
|
|
222
185
|
}
|
|
223
|
-
function
|
|
224
|
-
return
|
|
186
|
+
function isInNotificationPhase() {
|
|
187
|
+
return inNotificationPhase;
|
|
225
188
|
}
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
189
|
+
var REACTIVE_NODE = {
|
|
190
|
+
version: 0,
|
|
191
|
+
lastCleanEpoch: 0,
|
|
192
|
+
dirty: false,
|
|
193
|
+
producers: void 0,
|
|
194
|
+
producersTail: void 0,
|
|
195
|
+
consumers: void 0,
|
|
196
|
+
consumersTail: void 0,
|
|
197
|
+
recomputing: false,
|
|
198
|
+
consumerAllowSignalWrites: false,
|
|
199
|
+
consumerIsAlwaysLive: false,
|
|
200
|
+
kind: "unknown",
|
|
201
|
+
producerMustRecompute: () => false,
|
|
202
|
+
producerRecomputeValue: () => {
|
|
203
|
+
},
|
|
204
|
+
consumerMarkedDirty: () => {
|
|
205
|
+
},
|
|
206
|
+
consumerOnSignalRead: () => {
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
function producerAccessed(node) {
|
|
210
|
+
if (inNotificationPhase) {
|
|
211
|
+
throw new Error(typeof ngDevMode !== "undefined" && ngDevMode ? `Assertion error: signal read during notification phase` : "");
|
|
212
|
+
}
|
|
213
|
+
if (activeConsumer === null) {
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
activeConsumer.consumerOnSignalRead(node);
|
|
217
|
+
const prevProducerLink = activeConsumer.producersTail;
|
|
218
|
+
if (prevProducerLink !== void 0 && prevProducerLink.producer === node) {
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
let nextProducerLink = void 0;
|
|
222
|
+
const isRecomputing = activeConsumer.recomputing;
|
|
223
|
+
if (isRecomputing) {
|
|
224
|
+
nextProducerLink = prevProducerLink !== void 0 ? prevProducerLink.nextProducer : activeConsumer.producers;
|
|
225
|
+
if (nextProducerLink !== void 0 && nextProducerLink.producer === node) {
|
|
226
|
+
activeConsumer.producersTail = nextProducerLink;
|
|
227
|
+
nextProducerLink.lastReadVersion = node.version;
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
const prevConsumerLink = node.consumersTail;
|
|
232
|
+
if (prevConsumerLink !== void 0 && prevConsumerLink.consumer === activeConsumer && // However, we have to make sure that the link we've discovered isn't from a node that is incrementally rebuilding its producer list
|
|
233
|
+
(!isRecomputing || isValidLink(prevConsumerLink, activeConsumer))) {
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
const isLive = consumerIsLive(activeConsumer);
|
|
237
|
+
const newLink = {
|
|
238
|
+
producer: node,
|
|
239
|
+
consumer: activeConsumer,
|
|
240
|
+
// instead of eagerly destroying the previous link, we delay until we've finished recomputing
|
|
241
|
+
// the producers list, so that we can destroy all of the old links at once.
|
|
242
|
+
nextProducer: nextProducerLink,
|
|
243
|
+
prevConsumer: prevConsumerLink,
|
|
244
|
+
lastReadVersion: node.version,
|
|
245
|
+
nextConsumer: void 0
|
|
246
|
+
};
|
|
247
|
+
activeConsumer.producersTail = newLink;
|
|
248
|
+
if (prevProducerLink !== void 0) {
|
|
249
|
+
prevProducerLink.nextProducer = newLink;
|
|
230
250
|
} else {
|
|
231
|
-
|
|
251
|
+
activeConsumer.producers = newLink;
|
|
252
|
+
}
|
|
253
|
+
if (isLive) {
|
|
254
|
+
producerAddLiveConsumer(node, newLink);
|
|
232
255
|
}
|
|
233
256
|
}
|
|
234
|
-
function
|
|
235
|
-
|
|
257
|
+
function producerIncrementEpoch() {
|
|
258
|
+
epoch++;
|
|
236
259
|
}
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
// src/import/di/injection_token.ts
|
|
241
|
-
var InjectionToken = class {
|
|
242
|
-
/**
|
|
243
|
-
* @param _desc Description for the token,
|
|
244
|
-
* used only for debugging purposes,
|
|
245
|
-
* it should but does not need to be unique
|
|
246
|
-
* @param options Options for the token's usage, as described above
|
|
247
|
-
*/
|
|
248
|
-
constructor(_desc, options) {
|
|
249
|
-
this._desc = _desc;
|
|
250
|
-
this.ɵprov = void 0;
|
|
251
|
-
if (typeof options === "number") {
|
|
252
|
-
} else if (options !== void 0) {
|
|
253
|
-
this.ɵprov = ɵɵdefineInjectable({
|
|
254
|
-
token: this,
|
|
255
|
-
providedIn: options.providedIn || "root",
|
|
256
|
-
factory: options.factory
|
|
257
|
-
});
|
|
258
|
-
}
|
|
260
|
+
function producerUpdateValueVersion(node) {
|
|
261
|
+
if (consumerIsLive(node) && !node.dirty) {
|
|
262
|
+
return;
|
|
259
263
|
}
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
ɵprov;
|
|
263
|
-
/**
|
|
264
|
-
* @internal
|
|
265
|
-
*/
|
|
266
|
-
get multi() {
|
|
267
|
-
return this;
|
|
264
|
+
if (!node.dirty && node.lastCleanEpoch === epoch) {
|
|
265
|
+
return;
|
|
268
266
|
}
|
|
269
|
-
|
|
270
|
-
|
|
267
|
+
if (!node.producerMustRecompute(node) && !consumerPollProducersForChange(node)) {
|
|
268
|
+
producerMarkClean(node);
|
|
269
|
+
return;
|
|
271
270
|
}
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
// src/import/di/initializer_token.ts
|
|
275
|
-
var ENVIRONMENT_INITIALIZER = new InjectionToken("");
|
|
276
|
-
|
|
277
|
-
// src/import/di/interface/injector.ts
|
|
278
|
-
var DecoratorFlags = /* @__PURE__ */ ((DecoratorFlags2) => {
|
|
279
|
-
DecoratorFlags2[DecoratorFlags2["Inject"] = -1] = "Inject";
|
|
280
|
-
return DecoratorFlags2;
|
|
281
|
-
})(DecoratorFlags || {});
|
|
282
|
-
var InternalInjectFlags = /* @__PURE__ */ ((InternalInjectFlags2) => {
|
|
283
|
-
InternalInjectFlags2[InternalInjectFlags2["Default"] = 0] = "Default";
|
|
284
|
-
InternalInjectFlags2[InternalInjectFlags2["Host"] = 1] = "Host";
|
|
285
|
-
InternalInjectFlags2[InternalInjectFlags2["Self"] = 2] = "Self";
|
|
286
|
-
InternalInjectFlags2[InternalInjectFlags2["SkipSelf"] = 4] = "SkipSelf";
|
|
287
|
-
InternalInjectFlags2[InternalInjectFlags2["Optional"] = 8] = "Optional";
|
|
288
|
-
InternalInjectFlags2[InternalInjectFlags2["ForPipe"] = 16] = "ForPipe";
|
|
289
|
-
return InternalInjectFlags2;
|
|
290
|
-
})(InternalInjectFlags || {});
|
|
291
|
-
|
|
292
|
-
// src/import/di/inject_switch.ts
|
|
293
|
-
var _injectImplementation;
|
|
294
|
-
function getInjectImplementation() {
|
|
295
|
-
return _injectImplementation;
|
|
296
|
-
}
|
|
297
|
-
function setInjectImplementation(impl) {
|
|
298
|
-
const previous = _injectImplementation;
|
|
299
|
-
_injectImplementation = impl;
|
|
300
|
-
return previous;
|
|
271
|
+
node.producerRecomputeValue(node);
|
|
272
|
+
producerMarkClean(node);
|
|
301
273
|
}
|
|
302
|
-
function
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
274
|
+
function producerNotifyConsumers(node) {
|
|
275
|
+
if (node.consumers === void 0) {
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
const prev = inNotificationPhase;
|
|
279
|
+
inNotificationPhase = true;
|
|
280
|
+
try {
|
|
281
|
+
for (let link = node.consumers; link !== void 0; link = link.nextConsumer) {
|
|
282
|
+
const consumer = link.consumer;
|
|
283
|
+
if (!consumer.dirty) {
|
|
284
|
+
consumerMarkDirty(consumer);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
} finally {
|
|
288
|
+
inNotificationPhase = prev;
|
|
306
289
|
}
|
|
307
|
-
if (flags & 8 /* Optional */) return null;
|
|
308
|
-
if (notFoundValue !== void 0) return notFoundValue;
|
|
309
|
-
throwProviderNotFoundError(token, "Injector");
|
|
310
290
|
}
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
var _currentInjector = void 0;
|
|
314
|
-
function getCurrentInjector() {
|
|
315
|
-
return _currentInjector;
|
|
291
|
+
function producerUpdatesAllowed() {
|
|
292
|
+
return activeConsumer?.consumerAllowSignalWrites !== false;
|
|
316
293
|
}
|
|
317
|
-
function
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
294
|
+
function consumerMarkDirty(node) {
|
|
295
|
+
node.dirty = true;
|
|
296
|
+
producerNotifyConsumers(node);
|
|
297
|
+
node.consumerMarkedDirty?.(node);
|
|
321
298
|
}
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
function isNotFound(e) {
|
|
326
|
-
return e === NOT_FOUND || e?.name === "ɵNotFound";
|
|
299
|
+
function producerMarkClean(node) {
|
|
300
|
+
node.dirty = false;
|
|
301
|
+
node.lastCleanEpoch = epoch;
|
|
327
302
|
}
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
303
|
+
function consumerBeforeComputation(node) {
|
|
304
|
+
if (node) resetConsumerBeforeComputation(node);
|
|
305
|
+
return setActiveConsumer(node);
|
|
306
|
+
}
|
|
307
|
+
function resetConsumerBeforeComputation(node) {
|
|
308
|
+
node.producersTail = void 0;
|
|
309
|
+
node.recomputing = true;
|
|
310
|
+
}
|
|
311
|
+
function consumerAfterComputation(node, prevConsumer) {
|
|
312
|
+
setActiveConsumer(prevConsumer);
|
|
313
|
+
if (node) finalizeConsumerAfterComputation(node);
|
|
314
|
+
}
|
|
315
|
+
function finalizeConsumerAfterComputation(node) {
|
|
316
|
+
node.recomputing = false;
|
|
317
|
+
const producersTail = node.producersTail;
|
|
318
|
+
let toRemove = producersTail !== void 0 ? producersTail.nextProducer : node.producers;
|
|
319
|
+
if (toRemove !== void 0) {
|
|
320
|
+
if (consumerIsLive(node)) {
|
|
321
|
+
do {
|
|
322
|
+
toRemove = producerRemoveLiveConsumerLink(toRemove);
|
|
323
|
+
} while (toRemove !== void 0);
|
|
324
|
+
}
|
|
325
|
+
if (producersTail !== void 0) {
|
|
326
|
+
producersTail.nextProducer = void 0;
|
|
327
|
+
} else {
|
|
328
|
+
node.producers = void 0;
|
|
329
|
+
}
|
|
336
330
|
}
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
return e;
|
|
349
|
-
}
|
|
350
|
-
throw e;
|
|
331
|
+
}
|
|
332
|
+
function consumerPollProducersForChange(node) {
|
|
333
|
+
for (let link = node.producers; link !== void 0; link = link.nextProducer) {
|
|
334
|
+
const producer = link.producer;
|
|
335
|
+
const seenVersion = link.lastReadVersion;
|
|
336
|
+
if (seenVersion !== producer.version) {
|
|
337
|
+
return true;
|
|
338
|
+
}
|
|
339
|
+
producerUpdateValueVersion(producer);
|
|
340
|
+
if (seenVersion !== producer.version) {
|
|
341
|
+
return true;
|
|
351
342
|
}
|
|
352
343
|
}
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
344
|
+
return false;
|
|
345
|
+
}
|
|
346
|
+
function consumerDestroy(node) {
|
|
347
|
+
if (consumerIsLive(node)) {
|
|
348
|
+
let link = node.producers;
|
|
349
|
+
while (link !== void 0) {
|
|
350
|
+
link = producerRemoveLiveConsumerLink(link);
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
node.producers = void 0;
|
|
354
|
+
node.producersTail = void 0;
|
|
355
|
+
node.consumers = void 0;
|
|
356
|
+
node.consumersTail = void 0;
|
|
357
|
+
}
|
|
358
|
+
function producerAddLiveConsumer(node, link) {
|
|
359
|
+
const consumersTail = node.consumersTail;
|
|
360
|
+
const wasLive = consumerIsLive(node);
|
|
361
|
+
if (consumersTail !== void 0) {
|
|
362
|
+
link.nextConsumer = consumersTail.nextConsumer;
|
|
363
|
+
consumersTail.nextConsumer = link;
|
|
364
364
|
} else {
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
365
|
+
link.nextConsumer = void 0;
|
|
366
|
+
node.consumers = link;
|
|
367
|
+
}
|
|
368
|
+
link.prevConsumer = consumersTail;
|
|
369
|
+
node.consumersTail = link;
|
|
370
|
+
if (!wasLive) {
|
|
371
|
+
for (let link2 = node.producers; link2 !== void 0; link2 = link2.nextProducer) {
|
|
372
|
+
producerAddLiveConsumer(link2.producer, link2);
|
|
372
373
|
}
|
|
373
|
-
return value;
|
|
374
374
|
}
|
|
375
375
|
}
|
|
376
|
-
function
|
|
377
|
-
|
|
376
|
+
function producerRemoveLiveConsumerLink(link) {
|
|
377
|
+
const producer = link.producer;
|
|
378
|
+
const nextProducer = link.nextProducer;
|
|
379
|
+
const nextConsumer = link.nextConsumer;
|
|
380
|
+
const prevConsumer = link.prevConsumer;
|
|
381
|
+
link.nextConsumer = void 0;
|
|
382
|
+
link.prevConsumer = void 0;
|
|
383
|
+
if (nextConsumer !== void 0) {
|
|
384
|
+
nextConsumer.prevConsumer = prevConsumer;
|
|
385
|
+
} else {
|
|
386
|
+
producer.consumersTail = prevConsumer;
|
|
387
|
+
}
|
|
388
|
+
if (prevConsumer !== void 0) {
|
|
389
|
+
prevConsumer.nextConsumer = nextConsumer;
|
|
390
|
+
} else {
|
|
391
|
+
producer.consumers = nextConsumer;
|
|
392
|
+
if (!consumerIsLive(producer)) {
|
|
393
|
+
let producerLink = producer.producers;
|
|
394
|
+
while (producerLink !== void 0) {
|
|
395
|
+
producerLink = producerRemoveLiveConsumerLink(producerLink);
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
return nextProducer;
|
|
378
400
|
}
|
|
379
|
-
function
|
|
380
|
-
|
|
401
|
+
function consumerIsLive(node) {
|
|
402
|
+
return node.consumerIsAlwaysLive || node.consumers !== void 0;
|
|
381
403
|
}
|
|
382
|
-
function
|
|
383
|
-
|
|
404
|
+
function runPostProducerCreatedFn(node) {
|
|
405
|
+
postProducerCreatedFn?.(node);
|
|
384
406
|
}
|
|
385
|
-
function
|
|
386
|
-
|
|
387
|
-
|
|
407
|
+
function isValidLink(checkLink, consumer) {
|
|
408
|
+
const producersTail = consumer.producersTail;
|
|
409
|
+
if (producersTail !== void 0) {
|
|
410
|
+
let link = consumer.producers;
|
|
411
|
+
do {
|
|
412
|
+
if (link === checkLink) {
|
|
413
|
+
return true;
|
|
414
|
+
}
|
|
415
|
+
if (link === producersTail) {
|
|
416
|
+
break;
|
|
417
|
+
}
|
|
418
|
+
link = link.nextProducer;
|
|
419
|
+
} while (link !== void 0);
|
|
388
420
|
}
|
|
389
|
-
return
|
|
390
|
-
(flags.optional && 8 /* Optional */) | 0 | (flags.self && 2 /* Self */) | (flags.skipSelf && 4 /* SkipSelf */);
|
|
391
|
-
}
|
|
392
|
-
function convertToInjectOptions(flags) {
|
|
393
|
-
return {
|
|
394
|
-
optional: !!(flags & 8 /* Optional */),
|
|
395
|
-
host: !!(flags & 1 /* Host */),
|
|
396
|
-
self: !!(flags & 2 /* Self */),
|
|
397
|
-
skipSelf: !!(flags & 4 /* SkipSelf */)
|
|
398
|
-
};
|
|
421
|
+
return false;
|
|
399
422
|
}
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
423
|
+
|
|
424
|
+
// src/primitives/signals/src/formatter.ts
|
|
425
|
+
var formatter = {
|
|
426
|
+
/**
|
|
427
|
+
* If the function returns `null`, the formatter is not used for this reference
|
|
428
|
+
*/
|
|
429
|
+
header: (sig, config) => {
|
|
430
|
+
if (!isSignal(sig) || config?.ngSkipFormatting) return null;
|
|
431
|
+
let value;
|
|
432
|
+
try {
|
|
433
|
+
value = sig();
|
|
434
|
+
} catch {
|
|
435
|
+
return ["span", "Signal(⚠️ Error)"];
|
|
436
|
+
}
|
|
437
|
+
const kind = "computation" in sig[SIGNAL] ? "Computed" : "Signal";
|
|
438
|
+
const isPrimitive = value === null || !Array.isArray(value) && typeof value !== "object";
|
|
439
|
+
return [
|
|
440
|
+
"span",
|
|
441
|
+
{},
|
|
442
|
+
["span", {}, `${kind}(`],
|
|
443
|
+
(() => {
|
|
444
|
+
if (isSignal(value)) {
|
|
445
|
+
return formatter.header(value, config);
|
|
446
|
+
} else if (isPrimitive && value !== void 0 && typeof value !== "function") {
|
|
447
|
+
return ["object", { object: value }];
|
|
419
448
|
} else {
|
|
420
|
-
|
|
449
|
+
return prettifyPreview(value);
|
|
421
450
|
}
|
|
451
|
+
})(),
|
|
452
|
+
["span", {}, `)`]
|
|
453
|
+
];
|
|
454
|
+
},
|
|
455
|
+
hasBody: (sig, config) => {
|
|
456
|
+
if (!isSignal(sig)) return false;
|
|
457
|
+
try {
|
|
458
|
+
sig();
|
|
459
|
+
} catch {
|
|
460
|
+
return false;
|
|
461
|
+
}
|
|
462
|
+
return !config?.ngSkipFormatting;
|
|
463
|
+
},
|
|
464
|
+
body: (sig, config) => {
|
|
465
|
+
const color = "var(--sys-color-primary)";
|
|
466
|
+
return [
|
|
467
|
+
"div",
|
|
468
|
+
{ style: `background: #FFFFFF10; padding-left: 4px; padding-top: 2px; padding-bottom: 2px;` },
|
|
469
|
+
["div", { style: `color: ${color}` }, "Signal value: "],
|
|
470
|
+
["div", { style: `padding-left: .5rem;` }, ["object", { object: sig(), config }]],
|
|
471
|
+
["div", { style: `color: ${color}` }, "Signal function: "],
|
|
472
|
+
["div", { style: `padding-left: .5rem;` }, ["object", { object: sig, config: { ...config, skipFormatting: true } }]]
|
|
473
|
+
];
|
|
474
|
+
}
|
|
475
|
+
};
|
|
476
|
+
function prettifyPreview(value) {
|
|
477
|
+
if (value === null) return "null";
|
|
478
|
+
if (Array.isArray(value)) return `Array(${value.length})`;
|
|
479
|
+
if (value instanceof Element) return `<${value.tagName.toLowerCase()}>`;
|
|
480
|
+
if (value instanceof URL) return `URL`;
|
|
481
|
+
switch (typeof value) {
|
|
482
|
+
case "undefined": {
|
|
483
|
+
return "undefined";
|
|
484
|
+
}
|
|
485
|
+
case "function": {
|
|
486
|
+
if ("prototype" in value) {
|
|
487
|
+
return "class";
|
|
488
|
+
} else {
|
|
489
|
+
return "() => {…}";
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
case "object": {
|
|
493
|
+
if (value.constructor.name === "Object") {
|
|
494
|
+
return "{…}";
|
|
495
|
+
} else {
|
|
496
|
+
return `${value.constructor.name} {}`;
|
|
422
497
|
}
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
498
|
+
}
|
|
499
|
+
default: {
|
|
500
|
+
return ["object", { object: value, config: { skipFormatting: true } }];
|
|
426
501
|
}
|
|
427
502
|
}
|
|
428
|
-
return args;
|
|
429
|
-
}
|
|
430
|
-
function attachInjectFlag(decorator, flag) {
|
|
431
|
-
decorator[DI_DECORATOR_FLAG] = flag;
|
|
432
|
-
decorator.prototype[DI_DECORATOR_FLAG] = flag;
|
|
433
|
-
return decorator;
|
|
434
503
|
}
|
|
435
|
-
function
|
|
436
|
-
return
|
|
504
|
+
function isSignal(value) {
|
|
505
|
+
return value[SIGNAL] !== void 0;
|
|
437
506
|
}
|
|
438
|
-
function
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
context = obj.map(stringify).join(" -> ");
|
|
443
|
-
} else if (typeof obj === "object") {
|
|
444
|
-
const parts = [];
|
|
445
|
-
for (const key in obj) {
|
|
446
|
-
if (obj.hasOwnProperty(key)) {
|
|
447
|
-
const value = obj[key];
|
|
448
|
-
parts.push(key + ":" + (typeof value === "string" ? JSON.stringify(value) : stringify(value)));
|
|
449
|
-
}
|
|
450
|
-
}
|
|
451
|
-
context = `{${parts.join(", ")}}`;
|
|
507
|
+
function installDevToolsSignalFormatter() {
|
|
508
|
+
globalThis.devtoolsFormatters ??= [];
|
|
509
|
+
if (!globalThis.devtoolsFormatters.some((f) => f === formatter)) {
|
|
510
|
+
globalThis.devtoolsFormatters.push(formatter);
|
|
452
511
|
}
|
|
453
|
-
return `${injectorErrorName}${source ? "(" + source + ")" : ""}[${context}]: ${text.replace(NEW_LINE, "\n ")}`;
|
|
454
512
|
}
|
|
455
513
|
|
|
456
|
-
// src/
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
// tslint:disable-next-line: no-toplevel-property-access
|
|
461
|
-
-1 /* Injector */
|
|
462
|
-
// Special value used by Ivy to identify `Injector`.
|
|
463
|
-
);
|
|
464
|
-
|
|
465
|
-
// src/import/di/internal_tokens.ts
|
|
466
|
-
var INJECTOR_DEF_TYPES = new InjectionToken("");
|
|
514
|
+
// src/primitives/signals/src/equality.ts
|
|
515
|
+
function defaultEquals(a, b) {
|
|
516
|
+
return Object.is(a, b);
|
|
517
|
+
}
|
|
467
518
|
|
|
468
|
-
// src/
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
error.name = "ɵNotFound";
|
|
475
|
-
throw error;
|
|
476
|
-
}
|
|
477
|
-
return notFoundValue;
|
|
519
|
+
// src/primitives/signals/src/computed.ts
|
|
520
|
+
function createComputed(computation, equal) {
|
|
521
|
+
const node = Object.create(COMPUTED_NODE);
|
|
522
|
+
node.computation = computation;
|
|
523
|
+
if (equal !== void 0) {
|
|
524
|
+
node.equal = equal;
|
|
478
525
|
}
|
|
479
|
-
|
|
526
|
+
const computed2 = () => {
|
|
527
|
+
producerUpdateValueVersion(node);
|
|
528
|
+
producerAccessed(node);
|
|
529
|
+
if (node.value === ERRORED) {
|
|
530
|
+
throw node.error;
|
|
531
|
+
}
|
|
532
|
+
return node.value;
|
|
533
|
+
};
|
|
534
|
+
computed2[SIGNAL] = node;
|
|
535
|
+
if (typeof ngDevMode !== "undefined" && ngDevMode) {
|
|
536
|
+
const debugName = node.debugName ? " (" + node.debugName + ")" : "";
|
|
537
|
+
computed2.toString = () => `[Computed${debugName}: ${node.value}]`;
|
|
538
|
+
}
|
|
539
|
+
runPostProducerCreatedFn(node);
|
|
540
|
+
return computed2;
|
|
541
|
+
}
|
|
542
|
+
var UNSET = /* @__PURE__ */ Symbol("UNSET");
|
|
543
|
+
var COMPUTING = /* @__PURE__ */ Symbol("COMPUTING");
|
|
544
|
+
var ERRORED = /* @__PURE__ */ Symbol("ERRORED");
|
|
545
|
+
var COMPUTED_NODE = /* @__PURE__ */ (() => ({
|
|
546
|
+
...REACTIVE_NODE,
|
|
547
|
+
value: UNSET,
|
|
548
|
+
dirty: true,
|
|
549
|
+
error: null,
|
|
550
|
+
equal: defaultEquals,
|
|
551
|
+
kind: "computed",
|
|
552
|
+
producerMustRecompute(node) {
|
|
553
|
+
return node.value === UNSET || node.value === COMPUTING;
|
|
554
|
+
},
|
|
555
|
+
producerRecomputeValue(node) {
|
|
556
|
+
if (node.value === COMPUTING) {
|
|
557
|
+
throw new Error(typeof ngDevMode !== "undefined" && ngDevMode ? "Detected cycle in computations." : "");
|
|
558
|
+
}
|
|
559
|
+
const oldValue = node.value;
|
|
560
|
+
node.value = COMPUTING;
|
|
561
|
+
const prevConsumer = consumerBeforeComputation(node);
|
|
562
|
+
let newValue;
|
|
563
|
+
let wasEqual = false;
|
|
564
|
+
try {
|
|
565
|
+
newValue = node.computation();
|
|
566
|
+
setActiveConsumer(null);
|
|
567
|
+
wasEqual = oldValue !== UNSET && oldValue !== ERRORED && newValue !== ERRORED && node.equal(oldValue, newValue);
|
|
568
|
+
} catch (err) {
|
|
569
|
+
newValue = ERRORED;
|
|
570
|
+
node.error = err;
|
|
571
|
+
} finally {
|
|
572
|
+
consumerAfterComputation(node, prevConsumer);
|
|
573
|
+
}
|
|
574
|
+
if (wasEqual) {
|
|
575
|
+
node.value = oldValue;
|
|
576
|
+
return;
|
|
577
|
+
}
|
|
578
|
+
node.value = newValue;
|
|
579
|
+
node.version++;
|
|
580
|
+
}
|
|
581
|
+
}))();
|
|
480
582
|
|
|
481
|
-
// src/
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
useValue: getClosureSafeProperty
|
|
485
|
-
});
|
|
486
|
-
function isValueProvider(value) {
|
|
487
|
-
return value !== null && typeof value === "object" && USE_VALUE in value;
|
|
583
|
+
// src/primitives/signals/src/errors.ts
|
|
584
|
+
function defaultThrowError() {
|
|
585
|
+
throw new Error();
|
|
488
586
|
}
|
|
489
|
-
|
|
490
|
-
|
|
587
|
+
var throwInvalidWriteToSignalErrorFn = defaultThrowError;
|
|
588
|
+
function throwInvalidWriteToSignalError(node) {
|
|
589
|
+
throwInvalidWriteToSignalErrorFn(node);
|
|
491
590
|
}
|
|
492
|
-
|
|
493
|
-
|
|
591
|
+
|
|
592
|
+
// src/primitives/signals/src/signal.ts
|
|
593
|
+
var postSignalSetFn = null;
|
|
594
|
+
function createSignal(initialValue, equal) {
|
|
595
|
+
const node = Object.create(SIGNAL_NODE);
|
|
596
|
+
node.value = initialValue;
|
|
597
|
+
if (equal !== void 0) {
|
|
598
|
+
node.equal = equal;
|
|
599
|
+
}
|
|
600
|
+
const getter = () => signalGetFn(node);
|
|
601
|
+
getter[SIGNAL] = node;
|
|
602
|
+
if (typeof ngDevMode !== "undefined" && ngDevMode) {
|
|
603
|
+
const debugName = node.debugName ? " (" + node.debugName + ")" : "";
|
|
604
|
+
getter.toString = () => `[Signal${debugName}: ${node.value}]`;
|
|
605
|
+
}
|
|
606
|
+
runPostProducerCreatedFn(node);
|
|
607
|
+
const set = (newValue) => signalSetFn(node, newValue);
|
|
608
|
+
const update = (updateFn) => signalUpdateFn(node, updateFn);
|
|
609
|
+
return [getter, set, update];
|
|
494
610
|
}
|
|
495
|
-
function
|
|
496
|
-
|
|
611
|
+
function signalGetFn(node) {
|
|
612
|
+
producerAccessed(node);
|
|
613
|
+
return node.value;
|
|
497
614
|
}
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
var NULL_INJECTOR = void 0;
|
|
506
|
-
function getNullInjector() {
|
|
507
|
-
if (NULL_INJECTOR === void 0) {
|
|
508
|
-
NULL_INJECTOR = new NullInjector();
|
|
615
|
+
function signalSetFn(node, newValue) {
|
|
616
|
+
if (!producerUpdatesAllowed()) {
|
|
617
|
+
throwInvalidWriteToSignalError(node);
|
|
618
|
+
}
|
|
619
|
+
if (!node.equal(node.value, newValue)) {
|
|
620
|
+
node.value = newValue;
|
|
621
|
+
signalValueChanged(node);
|
|
509
622
|
}
|
|
510
|
-
return NULL_INJECTOR;
|
|
511
623
|
}
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
constructor(providers, parent, source, scopes) {
|
|
516
|
-
super();
|
|
517
|
-
this.parent = parent;
|
|
518
|
-
this.source = source;
|
|
519
|
-
this.scopes = scopes;
|
|
520
|
-
forEachSingleProvider(providers, (provider) => this.processProvider(provider));
|
|
521
|
-
this.records.set(INJECTOR, makeRecord(void 0, this));
|
|
522
|
-
if (scopes.has("environment")) {
|
|
523
|
-
this.records.set(EnvironmentInjector, makeRecord(void 0, this));
|
|
524
|
-
}
|
|
525
|
-
const record = this.records.get(INJECTOR_SCOPE);
|
|
526
|
-
if (record != null && typeof record.value === "string") {
|
|
527
|
-
this.scopes.add(record.value);
|
|
528
|
-
}
|
|
529
|
-
this.injectorDefTypes = new Set(this.get(INJECTOR_DEF_TYPES, EMPTY_ARRAY, { self: true }));
|
|
624
|
+
function signalUpdateFn(node, updater) {
|
|
625
|
+
if (!producerUpdatesAllowed()) {
|
|
626
|
+
throwInvalidWriteToSignalError(node);
|
|
530
627
|
}
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
628
|
+
signalSetFn(node, updater(node.value));
|
|
629
|
+
}
|
|
630
|
+
var SIGNAL_NODE = /* @__PURE__ */ (() => ({
|
|
631
|
+
...REACTIVE_NODE,
|
|
632
|
+
equal: defaultEquals,
|
|
633
|
+
value: void 0,
|
|
634
|
+
kind: "signal"
|
|
635
|
+
}))();
|
|
636
|
+
function signalValueChanged(node) {
|
|
637
|
+
node.version++;
|
|
638
|
+
producerIncrementEpoch();
|
|
639
|
+
producerNotifyConsumers(node);
|
|
640
|
+
postSignalSetFn?.(node);
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
// src/primitives/signals/src/linked_signal.ts
|
|
644
|
+
function createLinkedSignal(sourceFn, computationFn, equalityFn) {
|
|
645
|
+
const node = Object.create(LINKED_SIGNAL_NODE);
|
|
646
|
+
node.source = sourceFn;
|
|
647
|
+
node.computation = computationFn;
|
|
648
|
+
if (equalityFn != void 0) {
|
|
649
|
+
node.equal = equalityFn;
|
|
547
650
|
}
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
return this.get(
|
|
554
|
-
token,
|
|
555
|
-
// When a dependency is requested with an optional flag, DI returns null as the default value.
|
|
556
|
-
THROW_IF_NOT_FOUND,
|
|
557
|
-
flags
|
|
558
|
-
);
|
|
559
|
-
} catch (e) {
|
|
560
|
-
if (isNotFound(e)) {
|
|
561
|
-
return e;
|
|
562
|
-
}
|
|
563
|
-
throw e;
|
|
651
|
+
const linkedSignalGetter = () => {
|
|
652
|
+
producerUpdateValueVersion(node);
|
|
653
|
+
producerAccessed(node);
|
|
654
|
+
if (node.value === ERRORED) {
|
|
655
|
+
throw node.error;
|
|
564
656
|
}
|
|
657
|
+
return node.value;
|
|
658
|
+
};
|
|
659
|
+
const getter = linkedSignalGetter;
|
|
660
|
+
getter[SIGNAL] = node;
|
|
661
|
+
if (typeof ngDevMode !== "undefined" && ngDevMode) {
|
|
662
|
+
const debugName = node.debugName ? " (" + node.debugName + ")" : "";
|
|
663
|
+
getter.toString = () => `[LinkedSignal${debugName}: ${node.value}]`;
|
|
565
664
|
}
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
665
|
+
runPostProducerCreatedFn(node);
|
|
666
|
+
return getter;
|
|
667
|
+
}
|
|
668
|
+
function linkedSignalSetFn(node, newValue) {
|
|
669
|
+
producerUpdateValueVersion(node);
|
|
670
|
+
signalSetFn(node, newValue);
|
|
671
|
+
producerMarkClean(node);
|
|
672
|
+
}
|
|
673
|
+
function linkedSignalUpdateFn(node, updater) {
|
|
674
|
+
producerUpdateValueVersion(node);
|
|
675
|
+
signalUpdateFn(node, updater);
|
|
676
|
+
producerMarkClean(node);
|
|
677
|
+
}
|
|
678
|
+
var LINKED_SIGNAL_NODE = /* @__PURE__ */ (() => ({
|
|
679
|
+
...REACTIVE_NODE,
|
|
680
|
+
value: UNSET,
|
|
681
|
+
dirty: true,
|
|
682
|
+
error: null,
|
|
683
|
+
equal: defaultEquals,
|
|
684
|
+
kind: "linkedSignal",
|
|
685
|
+
producerMustRecompute(node) {
|
|
686
|
+
return node.value === UNSET || node.value === COMPUTING;
|
|
687
|
+
},
|
|
688
|
+
producerRecomputeValue(node) {
|
|
689
|
+
if (node.value === COMPUTING) {
|
|
690
|
+
throw new Error(typeof ngDevMode !== "undefined" && ngDevMode ? "Detected cycle in computations." : "");
|
|
691
|
+
}
|
|
692
|
+
const oldValue = node.value;
|
|
693
|
+
node.value = COMPUTING;
|
|
694
|
+
const prevConsumer = consumerBeforeComputation(node);
|
|
695
|
+
let newValue;
|
|
575
696
|
try {
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
697
|
+
const newSourceValue = node.source();
|
|
698
|
+
const prev = oldValue === UNSET || oldValue === ERRORED ? void 0 : {
|
|
699
|
+
source: node.sourceValue,
|
|
700
|
+
value: oldValue
|
|
701
|
+
};
|
|
702
|
+
newValue = node.computation(newSourceValue, prev);
|
|
703
|
+
node.sourceValue = newSourceValue;
|
|
704
|
+
} catch (err) {
|
|
705
|
+
newValue = ERRORED;
|
|
706
|
+
node.error = err;
|
|
584
707
|
} finally {
|
|
585
|
-
|
|
586
|
-
this._ngOnDestroyHooks.clear();
|
|
587
|
-
this.injectorDefTypes.clear();
|
|
588
|
-
}
|
|
589
|
-
}
|
|
590
|
-
onDestroy(callback) {
|
|
591
|
-
assertNotDestroyed(this);
|
|
592
|
-
this._onDestroyHooks.push(callback);
|
|
593
|
-
return () => this.removeOnDestroy(callback);
|
|
594
|
-
}
|
|
595
|
-
runInContext(fn) {
|
|
596
|
-
assertNotDestroyed(this);
|
|
597
|
-
const previousInjector = setCurrentInjector(this);
|
|
598
|
-
const previousInjectImplementation = setInjectImplementation(void 0);
|
|
599
|
-
if (false) {
|
|
600
|
-
}
|
|
601
|
-
try {
|
|
602
|
-
return fn();
|
|
603
|
-
} finally {
|
|
604
|
-
setCurrentInjector(previousInjector);
|
|
605
|
-
setInjectImplementation(previousInjectImplementation);
|
|
606
|
-
}
|
|
607
|
-
}
|
|
608
|
-
get(token, notFoundValue = THROW_IF_NOT_FOUND, options) {
|
|
609
|
-
assertNotDestroyed(this);
|
|
610
|
-
if (token.hasOwnProperty(NG_ENV_ID)) {
|
|
611
|
-
return token[NG_ENV_ID](this);
|
|
612
|
-
}
|
|
613
|
-
const flags = convertToBitFlags(options);
|
|
614
|
-
if (false) {
|
|
615
|
-
}
|
|
616
|
-
const previousInjector = setCurrentInjector(this);
|
|
617
|
-
const previousInjectImplementation = setInjectImplementation(void 0);
|
|
618
|
-
try {
|
|
619
|
-
if (!(flags & 4 /* SkipSelf */)) {
|
|
620
|
-
let record = this.records.get(token);
|
|
621
|
-
if (record === void 0) {
|
|
622
|
-
const def = couldBeInjectableType(token) && getInjectableDef(token);
|
|
623
|
-
if (def && this.injectableDefInScope(def)) {
|
|
624
|
-
if (false) {
|
|
625
|
-
}
|
|
626
|
-
record = makeRecord(injectableDefOrInjectorDefFactory(token), NOT_YET);
|
|
627
|
-
} else {
|
|
628
|
-
record = null;
|
|
629
|
-
}
|
|
630
|
-
this.records.set(token, record);
|
|
631
|
-
}
|
|
632
|
-
if (record != null) {
|
|
633
|
-
return this.hydrate(token, record, flags);
|
|
634
|
-
}
|
|
635
|
-
}
|
|
636
|
-
const nextInjector = !(flags & 2 /* Self */) ? this.parent : getNullInjector();
|
|
637
|
-
notFoundValue = flags & 8 /* Optional */ && notFoundValue === THROW_IF_NOT_FOUND ? null : notFoundValue;
|
|
638
|
-
return nextInjector.get(token, notFoundValue);
|
|
639
|
-
} catch (error) {
|
|
640
|
-
const errorCode = getRuntimeErrorCode(error);
|
|
641
|
-
if (errorCode === -200 /* CYCLIC_DI_DEPENDENCY */ || errorCode === -201 /* PROVIDER_NOT_FOUND */) {
|
|
642
|
-
if (false) {
|
|
643
|
-
} else {
|
|
644
|
-
throw new RuntimeError(errorCode, null);
|
|
645
|
-
}
|
|
646
|
-
} else {
|
|
647
|
-
throw error;
|
|
648
|
-
}
|
|
649
|
-
} finally {
|
|
650
|
-
setInjectImplementation(previousInjectImplementation);
|
|
651
|
-
setCurrentInjector(previousInjector);
|
|
652
|
-
}
|
|
653
|
-
}
|
|
654
|
-
/** @internal */
|
|
655
|
-
resolveInjectorInitializers() {
|
|
656
|
-
const previousInjector = setCurrentInjector(this);
|
|
657
|
-
const previousInjectImplementation = setInjectImplementation(void 0);
|
|
658
|
-
if (false) {
|
|
659
|
-
}
|
|
660
|
-
try {
|
|
661
|
-
const initializers = this.get(ENVIRONMENT_INITIALIZER, EMPTY_ARRAY, { self: true });
|
|
662
|
-
if (false) {
|
|
663
|
-
}
|
|
664
|
-
for (const initializer of initializers) {
|
|
665
|
-
initializer();
|
|
666
|
-
}
|
|
667
|
-
} finally {
|
|
668
|
-
setCurrentInjector(previousInjector);
|
|
669
|
-
setInjectImplementation(previousInjectImplementation);
|
|
670
|
-
}
|
|
671
|
-
}
|
|
672
|
-
toString() {
|
|
673
|
-
const tokens = [];
|
|
674
|
-
const records = this.records;
|
|
675
|
-
for (const token of records.keys()) {
|
|
676
|
-
tokens.push(stringify(token));
|
|
677
|
-
}
|
|
678
|
-
return `R3Injector[${tokens.join(", ")}]`;
|
|
679
|
-
}
|
|
680
|
-
/**
|
|
681
|
-
* Process a `SingleProvider` and add it.
|
|
682
|
-
*/
|
|
683
|
-
processProvider(provider) {
|
|
684
|
-
provider = resolveForwardRef(provider);
|
|
685
|
-
let token = isTypeProvider(provider) ? provider : resolveForwardRef(provider && provider.provide);
|
|
686
|
-
const record = providerToRecord(provider);
|
|
687
|
-
if (false) {
|
|
688
|
-
}
|
|
689
|
-
if (!isTypeProvider(provider) && provider.multi === true) {
|
|
690
|
-
let multiRecord = this.records.get(token);
|
|
691
|
-
if (multiRecord) {
|
|
692
|
-
if (false) {
|
|
693
|
-
}
|
|
694
|
-
} else {
|
|
695
|
-
multiRecord = makeRecord(void 0, NOT_YET, true);
|
|
696
|
-
multiRecord.factory = () => injectArgs(multiRecord.multi);
|
|
697
|
-
this.records.set(token, multiRecord);
|
|
698
|
-
}
|
|
699
|
-
token = provider;
|
|
700
|
-
multiRecord.multi.push(provider);
|
|
701
|
-
} else {
|
|
702
|
-
if (false) {
|
|
703
|
-
}
|
|
704
|
-
}
|
|
705
|
-
this.records.set(token, record);
|
|
706
|
-
}
|
|
707
|
-
hydrate(token, record, flags) {
|
|
708
|
-
try {
|
|
709
|
-
if (record.value === CIRCULAR) {
|
|
710
|
-
throw cyclicDependencyError(stringify(token));
|
|
711
|
-
} else if (record.value === NOT_YET) {
|
|
712
|
-
record.value = CIRCULAR;
|
|
713
|
-
if (false) {
|
|
714
|
-
} else {
|
|
715
|
-
record.value = record.factory(void 0, flags);
|
|
716
|
-
}
|
|
717
|
-
}
|
|
718
|
-
if (typeof record.value === "object" && record.value && hasOnDestroy(record.value)) {
|
|
719
|
-
this._ngOnDestroyHooks.add(record.value);
|
|
720
|
-
}
|
|
721
|
-
return record.value;
|
|
722
|
-
} finally {
|
|
723
|
-
}
|
|
724
|
-
}
|
|
725
|
-
injectableDefInScope(def) {
|
|
726
|
-
if (!def.providedIn) {
|
|
727
|
-
return false;
|
|
728
|
-
}
|
|
729
|
-
const providedIn = resolveForwardRef(def.providedIn);
|
|
730
|
-
if (typeof providedIn === "string") {
|
|
731
|
-
return providedIn === "any" || this.scopes.has(providedIn);
|
|
732
|
-
} else {
|
|
733
|
-
return this.injectorDefTypes.has(providedIn);
|
|
708
|
+
consumerAfterComputation(node, prevConsumer);
|
|
734
709
|
}
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
if (destroyCBIdx !== -1) {
|
|
739
|
-
this._onDestroyHooks.splice(destroyCBIdx, 1);
|
|
710
|
+
if (oldValue !== UNSET && newValue !== ERRORED && node.equal(oldValue, newValue)) {
|
|
711
|
+
node.value = oldValue;
|
|
712
|
+
return;
|
|
740
713
|
}
|
|
714
|
+
node.value = newValue;
|
|
715
|
+
node.version++;
|
|
741
716
|
}
|
|
742
|
-
};
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
}
|
|
752
|
-
if (token instanceof Function) {
|
|
753
|
-
return getUndecoratedInjectableFactory(token);
|
|
717
|
+
}))();
|
|
718
|
+
|
|
719
|
+
// src/primitives/signals/src/untracked.ts
|
|
720
|
+
function untracked(nonReactiveReadsFn) {
|
|
721
|
+
const prevConsumer = setActiveConsumer(null);
|
|
722
|
+
try {
|
|
723
|
+
return nonReactiveReadsFn();
|
|
724
|
+
} finally {
|
|
725
|
+
setActiveConsumer(prevConsumer);
|
|
754
726
|
}
|
|
755
|
-
throw new RuntimeError(204 /* INVALID_INJECTION_TOKEN */, void 0);
|
|
756
727
|
}
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
728
|
+
|
|
729
|
+
// src/primitives/signals/src/effect.ts
|
|
730
|
+
var BASE_EFFECT_NODE = /* @__PURE__ */ (() => ({
|
|
731
|
+
...REACTIVE_NODE,
|
|
732
|
+
consumerIsAlwaysLive: true,
|
|
733
|
+
consumerAllowSignalWrites: true,
|
|
734
|
+
dirty: true,
|
|
735
|
+
kind: "effect"
|
|
736
|
+
}))();
|
|
737
|
+
function runEffect(node) {
|
|
738
|
+
node.dirty = false;
|
|
739
|
+
if (node.version > 0 && !consumerPollProducersForChange(node)) {
|
|
740
|
+
return;
|
|
761
741
|
}
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
742
|
+
node.version++;
|
|
743
|
+
const prevNode = consumerBeforeComputation(node);
|
|
744
|
+
try {
|
|
745
|
+
node.cleanup();
|
|
746
|
+
node.fn();
|
|
747
|
+
} finally {
|
|
748
|
+
consumerAfterComputation(node, prevNode);
|
|
767
749
|
}
|
|
768
750
|
}
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
const factory = providerToFactory(provider);
|
|
774
|
-
return makeRecord(factory, NOT_YET);
|
|
775
|
-
}
|
|
751
|
+
|
|
752
|
+
// src/primitives/signals/index.ts
|
|
753
|
+
if (typeof ngDevMode !== "undefined" && ngDevMode) {
|
|
754
|
+
installDevToolsSignalFormatter();
|
|
776
755
|
}
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
const unwrappedProvider = resolveForwardRef(provider);
|
|
783
|
-
return getFactoryDef(unwrappedProvider) || injectableDefOrInjectorDefFactory(unwrappedProvider);
|
|
784
|
-
} else {
|
|
785
|
-
if (isValueProvider(provider)) {
|
|
786
|
-
factory = () => resolveForwardRef(provider.useValue);
|
|
787
|
-
} else if (isFactoryProvider(provider)) {
|
|
788
|
-
factory = () => provider.useFactory(...injectArgs(provider.deps || []));
|
|
789
|
-
} else if (isExistingProvider(provider)) {
|
|
790
|
-
factory = (_, flags) => ɵɵinject(resolveForwardRef(provider.useExisting), flags !== void 0 && flags & 8 /* Optional */ ? 8 /* Optional */ : void 0);
|
|
791
|
-
} else {
|
|
792
|
-
const classRef = resolveForwardRef(provider && (provider.useClass || provider.provide));
|
|
793
|
-
if (false) {
|
|
794
|
-
}
|
|
795
|
-
if (hasDeps(provider)) {
|
|
796
|
-
factory = () => new classRef(...injectArgs(provider.deps));
|
|
797
|
-
} else {
|
|
798
|
-
return getFactoryDef(classRef) || injectableDefOrInjectorDefFactory(classRef);
|
|
799
|
-
}
|
|
800
|
-
}
|
|
756
|
+
|
|
757
|
+
// src/import/util/assert.ts
|
|
758
|
+
function assertLessThan(actual, expected, msg) {
|
|
759
|
+
if (!(actual < expected)) {
|
|
760
|
+
throwError(msg, actual, expected, "<");
|
|
801
761
|
}
|
|
802
|
-
return factory;
|
|
803
762
|
}
|
|
804
|
-
function
|
|
805
|
-
if (
|
|
806
|
-
|
|
763
|
+
function assertDefined(actual, msg) {
|
|
764
|
+
if (actual == null) {
|
|
765
|
+
throwError(msg, actual, null, "!=");
|
|
807
766
|
}
|
|
808
767
|
}
|
|
809
|
-
function
|
|
768
|
+
function throwError(msg, actual, expected, comparison) {
|
|
769
|
+
throw new Error(`ASSERTION ERROR: ${msg}` + (comparison == null ? "" : ` [Expected=> ${expected} ${comparison} ${actual} <=Actual]`));
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
// src/import/di/interface/defs.ts
|
|
773
|
+
function ɵɵdefineInjectable(opts) {
|
|
810
774
|
return {
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
775
|
+
token: opts.token,
|
|
776
|
+
providedIn: opts.providedIn || null,
|
|
777
|
+
factory: opts.factory,
|
|
778
|
+
value: void 0
|
|
814
779
|
};
|
|
815
780
|
}
|
|
816
|
-
function
|
|
817
|
-
return
|
|
818
|
-
}
|
|
819
|
-
function hasOnDestroy(value) {
|
|
820
|
-
return value !== null && typeof value === "object" && typeof value.ngOnDestroy === "function";
|
|
781
|
+
function ɵɵdefineInjector(options) {
|
|
782
|
+
return { providers: options.providers || [], imports: options.imports || [] };
|
|
821
783
|
}
|
|
822
|
-
function
|
|
823
|
-
return
|
|
784
|
+
function getInjectableDef(type) {
|
|
785
|
+
return getOwnDefinition(type, NG_PROV_DEF) || { token: type, factory: () => new type(), ...type.injectOptions };
|
|
824
786
|
}
|
|
825
|
-
function
|
|
826
|
-
|
|
827
|
-
if (Array.isArray(provider)) {
|
|
828
|
-
forEachSingleProvider(provider, fn);
|
|
829
|
-
} else if (provider && isEnvironmentProviders(provider)) {
|
|
830
|
-
forEachSingleProvider(provider.ɵproviders, fn);
|
|
831
|
-
} else {
|
|
832
|
-
fn(provider);
|
|
833
|
-
}
|
|
834
|
-
}
|
|
835
|
-
}
|
|
836
|
-
|
|
837
|
-
// src/import/util/closure.ts
|
|
838
|
-
function noSideEffects(fn) {
|
|
839
|
-
return { toString: fn }.toString();
|
|
840
|
-
}
|
|
841
|
-
|
|
842
|
-
// src/import/util/decorators.ts
|
|
843
|
-
function makeMetadataCtor(props) {
|
|
844
|
-
return function ctor(...args) {
|
|
845
|
-
if (props) {
|
|
846
|
-
const values = props(...args);
|
|
847
|
-
for (const propName in values) {
|
|
848
|
-
this[propName] = values[propName];
|
|
849
|
-
}
|
|
850
|
-
}
|
|
851
|
-
};
|
|
787
|
+
function isInjectable(type) {
|
|
788
|
+
return getInjectableDef(type) !== null;
|
|
852
789
|
}
|
|
853
|
-
function
|
|
854
|
-
return
|
|
855
|
-
const metaCtor = makeMetadataCtor(props);
|
|
856
|
-
function ParamDecoratorFactory(...args) {
|
|
857
|
-
metaCtor.apply(this, args);
|
|
858
|
-
return this;
|
|
859
|
-
}
|
|
860
|
-
if (parentClass) {
|
|
861
|
-
}
|
|
862
|
-
return ParamDecoratorFactory;
|
|
863
|
-
});
|
|
790
|
+
function getOwnDefinition(type, field) {
|
|
791
|
+
return type.hasOwnProperty(field) && type[field] || null;
|
|
864
792
|
}
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
attachInjectFlag(makeParamDecorator("Optional"), 8 /* Optional */)
|
|
877
|
-
);
|
|
878
|
-
var Self = (
|
|
879
|
-
// Disable tslint because `InternalInjectFlags` is a const enum which gets inlined.
|
|
880
|
-
// tslint:disable-next-line: no-toplevel-property-access
|
|
881
|
-
attachInjectFlag(makeParamDecorator("Self"), 2 /* Self */)
|
|
882
|
-
);
|
|
883
|
-
var SkipSelf = (
|
|
884
|
-
// Disable tslint because `InternalInjectFlags` is a const enum which gets inlined.
|
|
885
|
-
// tslint:disable-next-line: no-toplevel-property-access
|
|
886
|
-
attachInjectFlag(makeParamDecorator("SkipSelf"), 4 /* SkipSelf */)
|
|
887
|
-
);
|
|
888
|
-
|
|
889
|
-
// src/import/di/create_injector.ts
|
|
890
|
-
function createInjector(defType, parent = null, additionalProviders = null, name) {
|
|
891
|
-
const injector = createInjectorWithoutInjectorInstances(defType, parent, additionalProviders, name);
|
|
892
|
-
injector.resolveInjectorInitializers();
|
|
893
|
-
return injector;
|
|
793
|
+
function getInheritedInjectableDef(type) {
|
|
794
|
+
const def = type?.[NG_PROV_DEF] ?? null;
|
|
795
|
+
if (def) {
|
|
796
|
+
ngDevMode && console.warn(
|
|
797
|
+
`DEPRECATED: DI is instantiating a token "${type.name}" that inherits its @Injectable decorator but does not provide one itself.
|
|
798
|
+
This will become an error in a future version of Angular. Please add @Injectable() to the "${type.name}" class.`
|
|
799
|
+
);
|
|
800
|
+
return def;
|
|
801
|
+
} else {
|
|
802
|
+
return null;
|
|
803
|
+
}
|
|
894
804
|
}
|
|
895
|
-
function
|
|
896
|
-
|
|
897
|
-
name = name || (typeof defType === "object" ? void 0 : stringify(defType));
|
|
898
|
-
return new R3Injector(providers, parent || getNullInjector(), name || null, scopes);
|
|
805
|
+
function getInjectorDef(type) {
|
|
806
|
+
return type && type.hasOwnProperty(NG_INJ_DEF) ? type[NG_INJ_DEF] : null;
|
|
899
807
|
}
|
|
808
|
+
var NG_PROV_DEF = getClosureSafeProperty({ ɵprov: getClosureSafeProperty });
|
|
809
|
+
var NG_INJ_DEF = getClosureSafeProperty({ ɵinj: getClosureSafeProperty });
|
|
900
810
|
|
|
901
|
-
// src/import/di/
|
|
902
|
-
var
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
811
|
+
// src/import/di/injection_token.ts
|
|
812
|
+
var InjectionToken = class {
|
|
813
|
+
/**
|
|
814
|
+
* @param _desc Description for the token,
|
|
815
|
+
* used only for debugging purposes,
|
|
816
|
+
* it should but does not need to be unique
|
|
817
|
+
* @param options Options for the token's usage, as described above
|
|
818
|
+
*/
|
|
819
|
+
constructor(_desc, options) {
|
|
820
|
+
this._desc = _desc;
|
|
821
|
+
this.ɵprov = void 0;
|
|
822
|
+
if (typeof options === "number") {
|
|
823
|
+
(typeof ngDevMode === "undefined" || ngDevMode) && assertLessThan(options, 0, "Only negative numbers are supported here");
|
|
824
|
+
} else if (options !== void 0) {
|
|
825
|
+
this.ɵprov = ɵɵdefineInjectable({
|
|
826
|
+
token: this,
|
|
827
|
+
providedIn: options.providedIn || "root",
|
|
828
|
+
factory: options.factory
|
|
829
|
+
});
|
|
911
830
|
}
|
|
912
831
|
}
|
|
913
|
-
/** @
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
/* @__PURE__ */ ɵɵdefineInjectable({
|
|
917
|
-
token: _Injector,
|
|
918
|
-
providedIn: "any",
|
|
919
|
-
factory: () => ɵɵinject(INJECTOR)
|
|
920
|
-
})
|
|
921
|
-
);
|
|
832
|
+
/** @internal */
|
|
833
|
+
ngMetadataName = "InjectionToken";
|
|
834
|
+
ɵprov;
|
|
922
835
|
/**
|
|
923
836
|
* @internal
|
|
924
|
-
* @nocollapse
|
|
925
837
|
*/
|
|
926
|
-
|
|
838
|
+
get multi() {
|
|
839
|
+
return this;
|
|
840
|
+
}
|
|
841
|
+
toString() {
|
|
842
|
+
return `InjectionToken ${this._desc}`;
|
|
843
|
+
}
|
|
927
844
|
};
|
|
928
845
|
|
|
929
|
-
// src/import/render3/
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
var SIGNAL = /* @__PURE__ */ Symbol("SIGNAL");
|
|
941
|
-
function setActiveConsumer(consumer) {
|
|
942
|
-
const prev = activeConsumer;
|
|
943
|
-
activeConsumer = consumer;
|
|
944
|
-
return prev;
|
|
945
|
-
}
|
|
946
|
-
function getActiveConsumer() {
|
|
947
|
-
return activeConsumer;
|
|
846
|
+
// src/import/render3/debug/injector_profiler.ts
|
|
847
|
+
var _injectorProfilerContext;
|
|
848
|
+
function getInjectorProfilerContext() {
|
|
849
|
+
!ngDevMode && throwError("getInjectorProfilerContext should never be called in production mode");
|
|
850
|
+
return _injectorProfilerContext;
|
|
851
|
+
}
|
|
852
|
+
function setInjectorProfilerContext(context) {
|
|
853
|
+
!ngDevMode && throwError("setInjectorProfilerContext should never be called in production mode");
|
|
854
|
+
const previous = _injectorProfilerContext;
|
|
855
|
+
_injectorProfilerContext = context;
|
|
856
|
+
return previous;
|
|
948
857
|
}
|
|
949
|
-
var
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
consumerOnSignalRead: () => {
|
|
858
|
+
var injectorProfilerCallbacks = [];
|
|
859
|
+
function injectorProfiler(event) {
|
|
860
|
+
!ngDevMode && throwError("Injector profiler should never be called in production mode");
|
|
861
|
+
for (let i = 0; i < injectorProfilerCallbacks.length; i++) {
|
|
862
|
+
const injectorProfilerCallback = injectorProfilerCallbacks[i];
|
|
863
|
+
injectorProfilerCallback(event);
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
function emitProviderConfiguredEvent(eventProvider, isViewProvider = false) {
|
|
867
|
+
!ngDevMode && throwError("Injector profiler should never be called in production mode");
|
|
868
|
+
let token;
|
|
869
|
+
if (typeof eventProvider === "function") {
|
|
870
|
+
token = eventProvider;
|
|
871
|
+
} else if (eventProvider instanceof InjectionToken) {
|
|
872
|
+
token = eventProvider;
|
|
873
|
+
} else {
|
|
874
|
+
token = resolveForwardRef(eventProvider.provide);
|
|
967
875
|
}
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
throw new Error(false ? `Assertion error: signal read during notification phase` : "");
|
|
876
|
+
let provider = eventProvider;
|
|
877
|
+
if (eventProvider instanceof InjectionToken) {
|
|
878
|
+
provider = eventProvider.ɵprov || eventProvider;
|
|
972
879
|
}
|
|
973
|
-
|
|
974
|
-
|
|
880
|
+
injectorProfiler({
|
|
881
|
+
type: 2 /* ProviderConfigured */,
|
|
882
|
+
context: getInjectorProfilerContext(),
|
|
883
|
+
providerRecord: { token, provider, isViewProvider }
|
|
884
|
+
});
|
|
885
|
+
}
|
|
886
|
+
function emitInjectorToCreateInstanceEvent(token) {
|
|
887
|
+
!ngDevMode && throwError("Injector profiler should never be called in production mode");
|
|
888
|
+
injectorProfiler({
|
|
889
|
+
type: 4 /* InjectorToCreateInstanceEvent */,
|
|
890
|
+
context: getInjectorProfilerContext(),
|
|
891
|
+
token
|
|
892
|
+
});
|
|
893
|
+
}
|
|
894
|
+
function emitInstanceCreatedByInjectorEvent(instance) {
|
|
895
|
+
!ngDevMode && throwError("Injector profiler should never be called in production mode");
|
|
896
|
+
injectorProfiler({
|
|
897
|
+
type: 1 /* InstanceCreatedByInjector */,
|
|
898
|
+
context: getInjectorProfilerContext(),
|
|
899
|
+
instance: { value: instance }
|
|
900
|
+
});
|
|
901
|
+
}
|
|
902
|
+
function emitInjectEvent(token, value, flags) {
|
|
903
|
+
!ngDevMode && throwError("Injector profiler should never be called in production mode");
|
|
904
|
+
injectorProfiler({
|
|
905
|
+
type: 0 /* Inject */,
|
|
906
|
+
context: getInjectorProfilerContext(),
|
|
907
|
+
service: { token, value, flags }
|
|
908
|
+
});
|
|
909
|
+
}
|
|
910
|
+
function emitEffectCreatedEvent(effect2) {
|
|
911
|
+
!ngDevMode && throwError("Injector profiler should never be called in production mode");
|
|
912
|
+
injectorProfiler({
|
|
913
|
+
type: 3 /* EffectCreated */,
|
|
914
|
+
context: getInjectorProfilerContext(),
|
|
915
|
+
effect: effect2
|
|
916
|
+
});
|
|
917
|
+
}
|
|
918
|
+
function runInInjectorProfilerContext(injector, token, callback) {
|
|
919
|
+
!ngDevMode && throwError("runInInjectorProfilerContext should never be called in production mode");
|
|
920
|
+
const prevInjectContext = setInjectorProfilerContext({ injector, token });
|
|
921
|
+
try {
|
|
922
|
+
callback();
|
|
923
|
+
} finally {
|
|
924
|
+
setInjectorProfilerContext(prevInjectContext);
|
|
975
925
|
}
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
926
|
+
}
|
|
927
|
+
|
|
928
|
+
// src/import/render3/definition_factory.ts
|
|
929
|
+
function getFactoryDef(type, throwNotFound) {
|
|
930
|
+
return () => new type();
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
// src/import/render3/util/stringify_utils.ts
|
|
934
|
+
function renderStringify(value) {
|
|
935
|
+
if (typeof value === "string") return value;
|
|
936
|
+
if (value == null) return "";
|
|
937
|
+
return String(value);
|
|
938
|
+
}
|
|
939
|
+
function stringifyForError(value) {
|
|
940
|
+
if (typeof value === "function") return value.name || value.toString();
|
|
941
|
+
if (typeof value === "object" && value != null && typeof value.type === "function") {
|
|
942
|
+
return value.type.name || value.type.toString();
|
|
980
943
|
}
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
944
|
+
return renderStringify(value);
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
// src/import/render3/errors_di.ts
|
|
948
|
+
var NG_RUNTIME_ERROR_CODE = getClosureSafeProperty({ ngErrorCode: getClosureSafeProperty });
|
|
949
|
+
var NG_RUNTIME_ERROR_MESSAGE = getClosureSafeProperty({ ngErrorMessage: getClosureSafeProperty });
|
|
950
|
+
var NG_TOKEN_PATH = getClosureSafeProperty({ ngTokenPath: getClosureSafeProperty });
|
|
951
|
+
function cyclicDependencyError(token, path) {
|
|
952
|
+
const message = ngDevMode ? `Circular dependency detected for \`${token}\`.` : "";
|
|
953
|
+
return createRuntimeError(message, -200 /* CYCLIC_DI_DEPENDENCY */, path);
|
|
954
|
+
}
|
|
955
|
+
function throwMixedMultiProviderError() {
|
|
956
|
+
throw new Error(`Cannot mix multi providers and regular providers`);
|
|
957
|
+
}
|
|
958
|
+
function throwInvalidProviderError(ngModuleType, providers, provider) {
|
|
959
|
+
if (ngModuleType && providers) {
|
|
960
|
+
const providerDetail = providers.map((v) => v == provider ? "?" + provider + "?" : "...");
|
|
961
|
+
throw new Error(`Invalid provider for the NgModule '${stringify(ngModuleType)}' - only instances of Provider and Type are allowed, got: [${providerDetail.join(", ")}]`);
|
|
962
|
+
} else if (isEnvironmentProviders(provider)) {
|
|
963
|
+
if (provider.ɵfromNgModule) {
|
|
964
|
+
throw new RuntimeError(
|
|
965
|
+
207 /* PROVIDER_IN_WRONG_CONTEXT */,
|
|
966
|
+
`Invalid providers from 'importProvidersFrom' present in a non-environment injector. 'importProvidersFrom' can't be used for component providers.`
|
|
967
|
+
);
|
|
968
|
+
} else {
|
|
969
|
+
throw new RuntimeError(207 /* PROVIDER_IN_WRONG_CONTEXT */, `Invalid providers present in a non-environment injector. 'EnvironmentProviders' can't be used for component providers.`);
|
|
989
970
|
}
|
|
990
|
-
}
|
|
991
|
-
const prevConsumerLink = node.consumersTail;
|
|
992
|
-
if (prevConsumerLink !== void 0 && prevConsumerLink.consumer === activeConsumer && // However, we have to make sure that the link we've discovered isn't from a node that is incrementally rebuilding its producer list
|
|
993
|
-
(!isRecomputing || isValidLink(prevConsumerLink, activeConsumer))) {
|
|
994
|
-
return;
|
|
995
|
-
}
|
|
996
|
-
const isLive = consumerIsLive(activeConsumer);
|
|
997
|
-
const newLink = {
|
|
998
|
-
producer: node,
|
|
999
|
-
consumer: activeConsumer,
|
|
1000
|
-
// instead of eagerly destroying the previous link, we delay until we've finished recomputing
|
|
1001
|
-
// the producers list, so that we can destroy all of the old links at once.
|
|
1002
|
-
nextProducer: nextProducerLink,
|
|
1003
|
-
prevConsumer: prevConsumerLink,
|
|
1004
|
-
lastReadVersion: node.version,
|
|
1005
|
-
nextConsumer: void 0
|
|
1006
|
-
};
|
|
1007
|
-
activeConsumer.producersTail = newLink;
|
|
1008
|
-
if (prevProducerLink !== void 0) {
|
|
1009
|
-
prevProducerLink.nextProducer = newLink;
|
|
1010
971
|
} else {
|
|
1011
|
-
|
|
1012
|
-
}
|
|
1013
|
-
if (isLive) {
|
|
1014
|
-
producerAddLiveConsumer(node, newLink);
|
|
972
|
+
throw new Error("Invalid provider");
|
|
1015
973
|
}
|
|
1016
974
|
}
|
|
1017
|
-
function
|
|
1018
|
-
|
|
975
|
+
function throwProviderNotFoundError(token, injectorName) {
|
|
976
|
+
const errorMessage = ngDevMode && `No provider for ${stringifyForError(token)} found${injectorName ? ` in ${injectorName}` : ""}`;
|
|
977
|
+
throw new RuntimeError(-201 /* PROVIDER_NOT_FOUND */, errorMessage);
|
|
1019
978
|
}
|
|
1020
|
-
function
|
|
1021
|
-
|
|
1022
|
-
|
|
979
|
+
function prependTokenToDependencyPath(error, token) {
|
|
980
|
+
error[NG_TOKEN_PATH] ??= [];
|
|
981
|
+
const currentPath = error[NG_TOKEN_PATH];
|
|
982
|
+
let pathStr;
|
|
983
|
+
if (typeof token === "object" && "multi" in token && token?.multi === true) {
|
|
984
|
+
assertDefined(token.provide, "Token with multi: true should have a provide property");
|
|
985
|
+
pathStr = stringifyForError(token.provide);
|
|
986
|
+
} else {
|
|
987
|
+
pathStr = stringifyForError(token);
|
|
1023
988
|
}
|
|
1024
|
-
if (
|
|
1025
|
-
|
|
989
|
+
if (currentPath[0] !== pathStr) {
|
|
990
|
+
error[NG_TOKEN_PATH].unshift(pathStr);
|
|
1026
991
|
}
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
992
|
+
}
|
|
993
|
+
function augmentRuntimeError(error, source) {
|
|
994
|
+
const tokenPath = error[NG_TOKEN_PATH];
|
|
995
|
+
const errorCode = error[NG_RUNTIME_ERROR_CODE];
|
|
996
|
+
const message = error[NG_RUNTIME_ERROR_MESSAGE] || error.message;
|
|
997
|
+
error.message = formatErrorMessage(message, errorCode, tokenPath, source);
|
|
998
|
+
return error;
|
|
999
|
+
}
|
|
1000
|
+
function createRuntimeError(message, code, path) {
|
|
1001
|
+
const error = new RuntimeError(code, message);
|
|
1002
|
+
error[NG_RUNTIME_ERROR_CODE] = code;
|
|
1003
|
+
error[NG_RUNTIME_ERROR_MESSAGE] = message;
|
|
1004
|
+
if (path) {
|
|
1005
|
+
error[NG_TOKEN_PATH] = path;
|
|
1030
1006
|
}
|
|
1031
|
-
|
|
1032
|
-
producerMarkClean(node);
|
|
1007
|
+
return error;
|
|
1033
1008
|
}
|
|
1034
|
-
function
|
|
1035
|
-
|
|
1036
|
-
|
|
1009
|
+
function getRuntimeErrorCode(error) {
|
|
1010
|
+
return error[NG_RUNTIME_ERROR_CODE];
|
|
1011
|
+
}
|
|
1012
|
+
function formatErrorMessage(text, code, path = [], source = null) {
|
|
1013
|
+
let pathDetails = "";
|
|
1014
|
+
if (path && path.length > 1) {
|
|
1015
|
+
pathDetails = ` Path: ${path.join(" -> ")}.`;
|
|
1037
1016
|
}
|
|
1038
|
-
const
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1017
|
+
const sourceDetails = source ? ` Source: ${source}.` : "";
|
|
1018
|
+
return formatRuntimeError(code, `${text}${sourceDetails}${pathDetails}`);
|
|
1019
|
+
}
|
|
1020
|
+
|
|
1021
|
+
// src/import/render3/fields.ts
|
|
1022
|
+
var NG_FACTORY_DEF = getClosureSafeProperty({ ɵfac: getClosureSafeProperty });
|
|
1023
|
+
var NG_ENV_ID = getClosureSafeProperty({ __NG_ENV_ID__: getClosureSafeProperty });
|
|
1024
|
+
|
|
1025
|
+
// src/import/util/array_utils.ts
|
|
1026
|
+
function newArray(size, value) {
|
|
1027
|
+
const list = [];
|
|
1028
|
+
for (let i = 0; i < size; i++) {
|
|
1029
|
+
list.push(value);
|
|
1030
|
+
}
|
|
1031
|
+
return list;
|
|
1032
|
+
}
|
|
1033
|
+
|
|
1034
|
+
// src/import/util/empty.ts
|
|
1035
|
+
var EMPTY_OBJ = {};
|
|
1036
|
+
var EMPTY_ARRAY = [];
|
|
1037
|
+
if ((typeof ngDevMode === "undefined" || ngDevMode) && true) {
|
|
1038
|
+
Object.freeze(EMPTY_OBJ);
|
|
1039
|
+
Object.freeze(EMPTY_ARRAY);
|
|
1040
|
+
}
|
|
1041
|
+
|
|
1042
|
+
// src/import/di/initializer_token.ts
|
|
1043
|
+
var ENVIRONMENT_INITIALIZER = new InjectionToken(ngDevMode ? "ENVIRONMENT_INITIALIZER" : "");
|
|
1044
|
+
|
|
1045
|
+
// src/import/di/interface/injector.ts
|
|
1046
|
+
var DecoratorFlags = /* @__PURE__ */ ((DecoratorFlags2) => {
|
|
1047
|
+
DecoratorFlags2[DecoratorFlags2["Inject"] = -1] = "Inject";
|
|
1048
|
+
return DecoratorFlags2;
|
|
1049
|
+
})(DecoratorFlags || {});
|
|
1050
|
+
var InternalInjectFlags = /* @__PURE__ */ ((InternalInjectFlags2) => {
|
|
1051
|
+
InternalInjectFlags2[InternalInjectFlags2["Default"] = 0] = "Default";
|
|
1052
|
+
InternalInjectFlags2[InternalInjectFlags2["Host"] = 1] = "Host";
|
|
1053
|
+
InternalInjectFlags2[InternalInjectFlags2["Self"] = 2] = "Self";
|
|
1054
|
+
InternalInjectFlags2[InternalInjectFlags2["SkipSelf"] = 4] = "SkipSelf";
|
|
1055
|
+
InternalInjectFlags2[InternalInjectFlags2["Optional"] = 8] = "Optional";
|
|
1056
|
+
InternalInjectFlags2[InternalInjectFlags2["ForPipe"] = 16] = "ForPipe";
|
|
1057
|
+
return InternalInjectFlags2;
|
|
1058
|
+
})(InternalInjectFlags || {});
|
|
1059
|
+
|
|
1060
|
+
// src/import/di/inject_switch.ts
|
|
1061
|
+
var _injectImplementation;
|
|
1062
|
+
function getInjectImplementation() {
|
|
1063
|
+
return _injectImplementation;
|
|
1064
|
+
}
|
|
1065
|
+
function setInjectImplementation(impl) {
|
|
1066
|
+
const previous = _injectImplementation;
|
|
1067
|
+
_injectImplementation = impl;
|
|
1068
|
+
return previous;
|
|
1069
|
+
}
|
|
1070
|
+
function injectRootLimpMode(token, notFoundValue, flags) {
|
|
1071
|
+
const injectableDef = getInjectableDef(token);
|
|
1072
|
+
if (injectableDef && injectableDef.providedIn == "root") {
|
|
1073
|
+
return injectableDef.value === void 0 ? injectableDef.value = injectableDef.factory() : injectableDef.value;
|
|
1074
|
+
}
|
|
1075
|
+
if (flags & 8 /* Optional */) return null;
|
|
1076
|
+
if (notFoundValue !== void 0) return notFoundValue;
|
|
1077
|
+
throwProviderNotFoundError(token, "Injector");
|
|
1078
|
+
}
|
|
1079
|
+
|
|
1080
|
+
// src/primitives/di/src/injector.ts
|
|
1081
|
+
var _currentInjector = void 0;
|
|
1082
|
+
function getCurrentInjector() {
|
|
1083
|
+
return _currentInjector;
|
|
1084
|
+
}
|
|
1085
|
+
function setCurrentInjector(injector) {
|
|
1086
|
+
const former = _currentInjector;
|
|
1087
|
+
_currentInjector = injector;
|
|
1088
|
+
return former;
|
|
1089
|
+
}
|
|
1090
|
+
|
|
1091
|
+
// src/primitives/di/src/not_found.ts
|
|
1092
|
+
var NOT_FOUND = Symbol("NotFound");
|
|
1093
|
+
function isNotFound(e) {
|
|
1094
|
+
return e === NOT_FOUND || e?.name === "ɵNotFound";
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
// src/import/di/injector_compatibility.ts
|
|
1098
|
+
var _THROW_IF_NOT_FOUND = {};
|
|
1099
|
+
var THROW_IF_NOT_FOUND = _THROW_IF_NOT_FOUND;
|
|
1100
|
+
var DI_DECORATOR_FLAG = "__NG_DI_FLAG__";
|
|
1101
|
+
var RetrievingInjector = class {
|
|
1102
|
+
constructor(injector) {
|
|
1103
|
+
this.injector = injector;
|
|
1104
|
+
}
|
|
1105
|
+
retrieve(token, options) {
|
|
1106
|
+
const flags = convertToBitFlags(options) || 0 /* Default */;
|
|
1107
|
+
try {
|
|
1108
|
+
return this.injector.get(
|
|
1109
|
+
token,
|
|
1110
|
+
// When a dependency is requested with an optional flag, DI returns null as the default value.
|
|
1111
|
+
flags & 8 /* Optional */ ? null : THROW_IF_NOT_FOUND,
|
|
1112
|
+
flags
|
|
1113
|
+
);
|
|
1114
|
+
} catch (e) {
|
|
1115
|
+
if (isNotFound(e)) {
|
|
1116
|
+
return e;
|
|
1117
|
+
}
|
|
1118
|
+
throw e;
|
|
1119
|
+
}
|
|
1120
|
+
}
|
|
1121
|
+
};
|
|
1122
|
+
var NG_TEMP_TOKEN_PATH = "ngTempTokenPath";
|
|
1123
|
+
var NEW_LINE = /\n/gm;
|
|
1124
|
+
var NO_NEW_LINE = "ɵ";
|
|
1125
|
+
var SOURCE = "__source";
|
|
1126
|
+
function injectInjectorOnly(token, flags = 0 /* Default */) {
|
|
1127
|
+
const currentInjector = getCurrentInjector();
|
|
1128
|
+
if (currentInjector === void 0) {
|
|
1129
|
+
throw new RuntimeError(
|
|
1130
|
+
-203 /* MISSING_INJECTION_CONTEXT */,
|
|
1131
|
+
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\`.`
|
|
1132
|
+
);
|
|
1133
|
+
} else if (currentInjector === null) {
|
|
1134
|
+
return injectRootLimpMode(token, void 0, flags);
|
|
1135
|
+
} else {
|
|
1136
|
+
const options = convertToInjectOptions(flags);
|
|
1137
|
+
const value = currentInjector.retrieve(token, options);
|
|
1138
|
+
ngDevMode && emitInjectEvent(token, value, flags);
|
|
1139
|
+
if (isNotFound(value)) {
|
|
1140
|
+
if (options.optional) {
|
|
1141
|
+
return null;
|
|
1142
|
+
}
|
|
1143
|
+
throw value;
|
|
1144
|
+
}
|
|
1145
|
+
return value;
|
|
1146
|
+
}
|
|
1147
|
+
}
|
|
1148
|
+
function ɵɵinject(token, flags = 0 /* Default */) {
|
|
1149
|
+
return (getInjectImplementation() || injectInjectorOnly)(resolveForwardRef(token), flags);
|
|
1150
|
+
}
|
|
1151
|
+
function ɵɵinvalidFactoryDep(index) {
|
|
1152
|
+
throw new RuntimeError(
|
|
1153
|
+
202 /* INVALID_FACTORY_DEPENDENCY */,
|
|
1154
|
+
ngDevMode && `This constructor is not compatible with Angular Dependency Injection because its dependency at index ${index} of the parameter list is invalid.
|
|
1155
|
+
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.
|
|
1156
|
+
|
|
1157
|
+
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.`
|
|
1158
|
+
);
|
|
1159
|
+
}
|
|
1160
|
+
function inject2(token, options) {
|
|
1161
|
+
return ɵɵinject(token, convertToBitFlags(options));
|
|
1162
|
+
}
|
|
1163
|
+
function convertToBitFlags(flags) {
|
|
1164
|
+
if (typeof flags === "undefined" || typeof flags === "number") {
|
|
1165
|
+
return flags;
|
|
1166
|
+
}
|
|
1167
|
+
return 0 /* Default */ | // comment to force a line break in the formatter
|
|
1168
|
+
(flags.optional && 8 /* Optional */) | 0 | (flags.self && 2 /* Self */) | (flags.skipSelf && 4 /* SkipSelf */);
|
|
1169
|
+
}
|
|
1170
|
+
function convertToInjectOptions(flags) {
|
|
1171
|
+
return {
|
|
1172
|
+
optional: !!(flags & 8 /* Optional */),
|
|
1173
|
+
host: !!(flags & 1 /* Host */),
|
|
1174
|
+
self: !!(flags & 2 /* Self */),
|
|
1175
|
+
skipSelf: !!(flags & 4 /* SkipSelf */)
|
|
1176
|
+
};
|
|
1177
|
+
}
|
|
1178
|
+
function injectArgs(types) {
|
|
1179
|
+
const args = [];
|
|
1180
|
+
for (let i = 0; i < types.length; i++) {
|
|
1181
|
+
const arg = resolveForwardRef(types[i]);
|
|
1182
|
+
if (Array.isArray(arg)) {
|
|
1183
|
+
if (arg.length === 0) {
|
|
1184
|
+
throw new RuntimeError(900 /* INVALID_DIFFER_INPUT */, ngDevMode && "Arguments array must have arguments.");
|
|
1185
|
+
}
|
|
1186
|
+
let type = void 0;
|
|
1187
|
+
let flags = 0 /* Default */;
|
|
1188
|
+
for (let j = 0; j < arg.length; j++) {
|
|
1189
|
+
const meta = arg[j];
|
|
1190
|
+
const flag = getInjectFlag(meta);
|
|
1191
|
+
if (typeof flag === "number") {
|
|
1192
|
+
if (flag === -1 /* Inject */) {
|
|
1193
|
+
type = meta.token;
|
|
1194
|
+
} else {
|
|
1195
|
+
flags |= flag;
|
|
1196
|
+
}
|
|
1197
|
+
} else {
|
|
1198
|
+
type = meta;
|
|
1199
|
+
}
|
|
1200
|
+
}
|
|
1201
|
+
args.push(ɵɵinject(type, flags));
|
|
1202
|
+
} else {
|
|
1203
|
+
args.push(ɵɵinject(arg));
|
|
1204
|
+
}
|
|
1205
|
+
}
|
|
1206
|
+
return args;
|
|
1207
|
+
}
|
|
1208
|
+
function attachInjectFlag(decorator, flag) {
|
|
1209
|
+
decorator[DI_DECORATOR_FLAG] = flag;
|
|
1210
|
+
decorator.prototype[DI_DECORATOR_FLAG] = flag;
|
|
1211
|
+
return decorator;
|
|
1212
|
+
}
|
|
1213
|
+
function getInjectFlag(token) {
|
|
1214
|
+
return token[DI_DECORATOR_FLAG];
|
|
1215
|
+
}
|
|
1216
|
+
function formatError(text, obj, injectorErrorName, source = null) {
|
|
1217
|
+
text = text && text.charAt(0) === "\n" && text.charAt(1) == NO_NEW_LINE ? text.slice(2) : text;
|
|
1218
|
+
let context = stringify(obj);
|
|
1219
|
+
if (Array.isArray(obj)) {
|
|
1220
|
+
context = obj.map(stringify).join(" -> ");
|
|
1221
|
+
} else if (typeof obj === "object") {
|
|
1222
|
+
const parts = [];
|
|
1223
|
+
for (const key in obj) {
|
|
1224
|
+
if (obj.hasOwnProperty(key)) {
|
|
1225
|
+
const value = obj[key];
|
|
1226
|
+
parts.push(key + ":" + (typeof value === "string" ? JSON.stringify(value) : stringify(value)));
|
|
1227
|
+
}
|
|
1228
|
+
}
|
|
1229
|
+
context = `{${parts.join(", ")}}`;
|
|
1230
|
+
}
|
|
1231
|
+
return `${injectorErrorName}${source ? "(" + source + ")" : ""}[${context}]: ${text.replace(NEW_LINE, "\n ")}`;
|
|
1232
|
+
}
|
|
1233
|
+
|
|
1234
|
+
// src/import/di/injector_token.ts
|
|
1235
|
+
var INJECTOR = new InjectionToken(
|
|
1236
|
+
ngDevMode ? "INJECTOR" : "",
|
|
1237
|
+
// Disable tslint because this is const enum which gets inlined not top level prop access.
|
|
1238
|
+
// tslint:disable-next-line: no-toplevel-property-access
|
|
1239
|
+
-1 /* Injector */
|
|
1240
|
+
// Special value used by Ivy to identify `Injector`.
|
|
1241
|
+
);
|
|
1242
|
+
|
|
1243
|
+
// src/import/di/internal_tokens.ts
|
|
1244
|
+
var INJECTOR_DEF_TYPES = new InjectionToken(ngDevMode ? "INJECTOR_DEF_TYPES" : "");
|
|
1245
|
+
|
|
1246
|
+
// src/import/di/null_injector.ts
|
|
1247
|
+
var NullInjector = class {
|
|
1248
|
+
get(token, notFoundValue = THROW_IF_NOT_FOUND) {
|
|
1249
|
+
if (notFoundValue === THROW_IF_NOT_FOUND) {
|
|
1250
|
+
const message = ngDevMode ? `No provider found for \`${stringify(token)}\`.` : "";
|
|
1251
|
+
const error = createRuntimeError(message, -201 /* PROVIDER_NOT_FOUND */);
|
|
1252
|
+
error.name = "ɵNotFound";
|
|
1253
|
+
throw error;
|
|
1254
|
+
}
|
|
1255
|
+
return notFoundValue;
|
|
1256
|
+
}
|
|
1257
|
+
};
|
|
1258
|
+
|
|
1259
|
+
// src/import/di/provider_collection.ts
|
|
1260
|
+
var USE_VALUE = getClosureSafeProperty({
|
|
1261
|
+
provide: String,
|
|
1262
|
+
useValue: getClosureSafeProperty
|
|
1263
|
+
});
|
|
1264
|
+
function isValueProvider(value) {
|
|
1265
|
+
return value !== null && typeof value === "object" && USE_VALUE in value;
|
|
1266
|
+
}
|
|
1267
|
+
function isExistingProvider(value) {
|
|
1268
|
+
return !!(value && value.useExisting);
|
|
1269
|
+
}
|
|
1270
|
+
function isFactoryProvider(value) {
|
|
1271
|
+
return !!(value && value.useFactory);
|
|
1272
|
+
}
|
|
1273
|
+
function isTypeProvider(value) {
|
|
1274
|
+
return typeof value === "function";
|
|
1275
|
+
}
|
|
1276
|
+
|
|
1277
|
+
// src/import/di/scope.ts
|
|
1278
|
+
var INJECTOR_SCOPE = new InjectionToken(ngDevMode ? "Set Injector scope." : "");
|
|
1279
|
+
|
|
1280
|
+
// src/import/di/r3_injector.ts
|
|
1281
|
+
var NOT_YET = {};
|
|
1282
|
+
var CIRCULAR = {};
|
|
1283
|
+
var NULL_INJECTOR = void 0;
|
|
1284
|
+
function getNullInjector() {
|
|
1285
|
+
if (NULL_INJECTOR === void 0) {
|
|
1286
|
+
NULL_INJECTOR = new NullInjector();
|
|
1287
|
+
}
|
|
1288
|
+
return NULL_INJECTOR;
|
|
1289
|
+
}
|
|
1290
|
+
var EnvironmentInjector = class {
|
|
1291
|
+
};
|
|
1292
|
+
var R3Injector = class extends EnvironmentInjector {
|
|
1293
|
+
constructor(providers, parent, source, scopes) {
|
|
1294
|
+
super();
|
|
1295
|
+
this.parent = parent;
|
|
1296
|
+
this.source = source;
|
|
1297
|
+
this.scopes = scopes;
|
|
1298
|
+
forEachSingleProvider(providers, (provider) => this.processProvider(provider));
|
|
1299
|
+
this.records.set(INJECTOR, makeRecord(void 0, this));
|
|
1300
|
+
if (scopes.has("environment")) {
|
|
1301
|
+
this.records.set(EnvironmentInjector, makeRecord(void 0, this));
|
|
1302
|
+
}
|
|
1303
|
+
const record = this.records.get(INJECTOR_SCOPE);
|
|
1304
|
+
if (record != null && typeof record.value === "string") {
|
|
1305
|
+
this.scopes.add(record.value);
|
|
1306
|
+
}
|
|
1307
|
+
this.injectorDefTypes = new Set(this.get(INJECTOR_DEF_TYPES, EMPTY_ARRAY, { self: true }));
|
|
1308
|
+
}
|
|
1309
|
+
/**
|
|
1310
|
+
* Map of tokens to records which contain the instances of those tokens.
|
|
1311
|
+
* - `null` value implies that we don't have the record. Used by tree-shakable injectors
|
|
1312
|
+
* to prevent further searches.
|
|
1313
|
+
*/
|
|
1314
|
+
records = /* @__PURE__ */ new Map();
|
|
1315
|
+
/**
|
|
1316
|
+
* Set of values instantiated by this injector which contain `ngOnDestroy` lifecycle hooks.
|
|
1317
|
+
*/
|
|
1318
|
+
_ngOnDestroyHooks = /* @__PURE__ */ new Set();
|
|
1319
|
+
_onDestroyHooks = [];
|
|
1320
|
+
/**
|
|
1321
|
+
* Flag indicating that this injector was previously destroyed.
|
|
1322
|
+
*/
|
|
1323
|
+
get destroyed() {
|
|
1324
|
+
return this._destroyed;
|
|
1325
|
+
}
|
|
1326
|
+
_destroyed = false;
|
|
1327
|
+
injectorDefTypes;
|
|
1328
|
+
retrieve(token, options) {
|
|
1329
|
+
const flags = convertToBitFlags(options) || 0 /* Default */;
|
|
1330
|
+
try {
|
|
1331
|
+
return this.get(
|
|
1332
|
+
token,
|
|
1333
|
+
// When a dependency is requested with an optional flag, DI returns null as the default value.
|
|
1334
|
+
THROW_IF_NOT_FOUND,
|
|
1335
|
+
flags
|
|
1336
|
+
);
|
|
1337
|
+
} catch (e) {
|
|
1338
|
+
if (isNotFound(e)) {
|
|
1339
|
+
return e;
|
|
1340
|
+
}
|
|
1341
|
+
throw e;
|
|
1342
|
+
}
|
|
1343
|
+
}
|
|
1344
|
+
/**
|
|
1345
|
+
* Destroy the injector and release references to every instance or provider associated with it.
|
|
1346
|
+
*
|
|
1347
|
+
* Also calls the `OnDestroy` lifecycle hooks of every instance that was created for which a
|
|
1348
|
+
* hook was found.
|
|
1349
|
+
*/
|
|
1350
|
+
destroy() {
|
|
1351
|
+
assertNotDestroyed(this);
|
|
1352
|
+
this._destroyed = true;
|
|
1353
|
+
try {
|
|
1354
|
+
for (const service of this._ngOnDestroyHooks) {
|
|
1355
|
+
service.ngOnDestroy();
|
|
1356
|
+
}
|
|
1357
|
+
const onDestroyHooks = this._onDestroyHooks;
|
|
1358
|
+
this._onDestroyHooks = [];
|
|
1359
|
+
for (const hook of onDestroyHooks) {
|
|
1360
|
+
hook();
|
|
1361
|
+
}
|
|
1362
|
+
} finally {
|
|
1363
|
+
this.records.clear();
|
|
1364
|
+
this._ngOnDestroyHooks.clear();
|
|
1365
|
+
this.injectorDefTypes.clear();
|
|
1366
|
+
}
|
|
1367
|
+
}
|
|
1368
|
+
onDestroy(callback) {
|
|
1369
|
+
assertNotDestroyed(this);
|
|
1370
|
+
this._onDestroyHooks.push(callback);
|
|
1371
|
+
return () => this.removeOnDestroy(callback);
|
|
1372
|
+
}
|
|
1373
|
+
runInContext(fn) {
|
|
1374
|
+
assertNotDestroyed(this);
|
|
1375
|
+
const previousInjector = setCurrentInjector(this);
|
|
1376
|
+
const previousInjectImplementation = setInjectImplementation(void 0);
|
|
1377
|
+
let prevInjectContext;
|
|
1378
|
+
if (ngDevMode) {
|
|
1379
|
+
prevInjectContext = setInjectorProfilerContext({ injector: this, token: null });
|
|
1380
|
+
}
|
|
1381
|
+
try {
|
|
1382
|
+
return fn();
|
|
1383
|
+
} finally {
|
|
1384
|
+
setCurrentInjector(previousInjector);
|
|
1385
|
+
setInjectImplementation(previousInjectImplementation);
|
|
1386
|
+
ngDevMode && setInjectorProfilerContext(prevInjectContext);
|
|
1387
|
+
}
|
|
1388
|
+
}
|
|
1389
|
+
get(token, notFoundValue = THROW_IF_NOT_FOUND, options) {
|
|
1390
|
+
assertNotDestroyed(this);
|
|
1391
|
+
if (token.hasOwnProperty(NG_ENV_ID)) {
|
|
1392
|
+
return token[NG_ENV_ID](this);
|
|
1393
|
+
}
|
|
1394
|
+
const flags = convertToBitFlags(options);
|
|
1395
|
+
let prevInjectContext;
|
|
1396
|
+
if (ngDevMode) {
|
|
1397
|
+
prevInjectContext = setInjectorProfilerContext({ injector: this, token });
|
|
1398
|
+
}
|
|
1399
|
+
const previousInjector = setCurrentInjector(this);
|
|
1400
|
+
const previousInjectImplementation = setInjectImplementation(void 0);
|
|
1401
|
+
try {
|
|
1402
|
+
if (!(flags & 4 /* SkipSelf */)) {
|
|
1403
|
+
let record = this.records.get(token);
|
|
1404
|
+
if (record === void 0) {
|
|
1405
|
+
const def = couldBeInjectableType(token) && getInjectableDef(token);
|
|
1406
|
+
if (def && this.injectableDefInScope(def)) {
|
|
1407
|
+
if (ngDevMode) {
|
|
1408
|
+
runInInjectorProfilerContext(this, token, () => {
|
|
1409
|
+
emitProviderConfiguredEvent(token);
|
|
1410
|
+
});
|
|
1411
|
+
}
|
|
1412
|
+
record = makeRecord(injectableDefOrInjectorDefFactory(token), NOT_YET);
|
|
1413
|
+
} else {
|
|
1414
|
+
record = null;
|
|
1415
|
+
}
|
|
1416
|
+
this.records.set(token, record);
|
|
1417
|
+
}
|
|
1418
|
+
if (record != null) {
|
|
1419
|
+
return this.hydrate(token, record, flags);
|
|
1420
|
+
}
|
|
1421
|
+
}
|
|
1422
|
+
const nextInjector = !(flags & 2 /* Self */) ? this.parent : getNullInjector();
|
|
1423
|
+
notFoundValue = flags & 8 /* Optional */ && notFoundValue === THROW_IF_NOT_FOUND ? null : notFoundValue;
|
|
1424
|
+
return nextInjector.get(token, notFoundValue);
|
|
1425
|
+
} catch (error) {
|
|
1426
|
+
const errorCode = getRuntimeErrorCode(error);
|
|
1427
|
+
if (errorCode === -200 /* CYCLIC_DI_DEPENDENCY */ || errorCode === -201 /* PROVIDER_NOT_FOUND */) {
|
|
1428
|
+
if (ngDevMode) {
|
|
1429
|
+
prependTokenToDependencyPath(error, token);
|
|
1430
|
+
if (previousInjector) {
|
|
1431
|
+
throw error;
|
|
1432
|
+
} else {
|
|
1433
|
+
throw augmentRuntimeError(error, this.source);
|
|
1434
|
+
}
|
|
1435
|
+
} else {
|
|
1436
|
+
throw new RuntimeError(errorCode, null);
|
|
1437
|
+
}
|
|
1438
|
+
} else {
|
|
1439
|
+
throw error;
|
|
1440
|
+
}
|
|
1441
|
+
} finally {
|
|
1442
|
+
setInjectImplementation(previousInjectImplementation);
|
|
1443
|
+
setCurrentInjector(previousInjector);
|
|
1444
|
+
ngDevMode && setInjectorProfilerContext(prevInjectContext);
|
|
1445
|
+
}
|
|
1446
|
+
}
|
|
1447
|
+
/** @internal */
|
|
1448
|
+
resolveInjectorInitializers() {
|
|
1449
|
+
const previousInjector = setCurrentInjector(this);
|
|
1450
|
+
const previousInjectImplementation = setInjectImplementation(void 0);
|
|
1451
|
+
let prevInjectContext;
|
|
1452
|
+
if (ngDevMode) {
|
|
1453
|
+
prevInjectContext = setInjectorProfilerContext({ injector: this, token: null });
|
|
1454
|
+
}
|
|
1455
|
+
try {
|
|
1456
|
+
const initializers = this.get(ENVIRONMENT_INITIALIZER, EMPTY_ARRAY, { self: true });
|
|
1457
|
+
if (ngDevMode && !Array.isArray(initializers)) {
|
|
1458
|
+
throw new RuntimeError(
|
|
1459
|
+
-209 /* INVALID_MULTI_PROVIDER */,
|
|
1460
|
+
`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.`
|
|
1461
|
+
);
|
|
1462
|
+
}
|
|
1463
|
+
for (const initializer of initializers) {
|
|
1464
|
+
initializer();
|
|
1465
|
+
}
|
|
1466
|
+
} finally {
|
|
1467
|
+
setCurrentInjector(previousInjector);
|
|
1468
|
+
setInjectImplementation(previousInjectImplementation);
|
|
1469
|
+
ngDevMode && setInjectorProfilerContext(prevInjectContext);
|
|
1470
|
+
}
|
|
1471
|
+
}
|
|
1472
|
+
toString() {
|
|
1473
|
+
const tokens = [];
|
|
1474
|
+
const records = this.records;
|
|
1475
|
+
for (const token of records.keys()) {
|
|
1476
|
+
tokens.push(stringify(token));
|
|
1477
|
+
}
|
|
1478
|
+
return `R3Injector[${tokens.join(", ")}]`;
|
|
1479
|
+
}
|
|
1480
|
+
/**
|
|
1481
|
+
* Process a `SingleProvider` and add it.
|
|
1482
|
+
*/
|
|
1483
|
+
processProvider(provider) {
|
|
1484
|
+
provider = resolveForwardRef(provider);
|
|
1485
|
+
let token = isTypeProvider(provider) ? provider : resolveForwardRef(provider && provider.provide);
|
|
1486
|
+
const record = providerToRecord(provider);
|
|
1487
|
+
if (ngDevMode) {
|
|
1488
|
+
runInInjectorProfilerContext(this, token, () => {
|
|
1489
|
+
if (isValueProvider(provider)) {
|
|
1490
|
+
emitInjectorToCreateInstanceEvent(token);
|
|
1491
|
+
emitInstanceCreatedByInjectorEvent(provider.useValue);
|
|
1492
|
+
}
|
|
1493
|
+
emitProviderConfiguredEvent(provider);
|
|
1494
|
+
});
|
|
1495
|
+
}
|
|
1496
|
+
if (!isTypeProvider(provider) && provider.multi === true) {
|
|
1497
|
+
let multiRecord = this.records.get(token);
|
|
1498
|
+
if (multiRecord) {
|
|
1499
|
+
if (ngDevMode && multiRecord.multi === void 0) {
|
|
1500
|
+
throwMixedMultiProviderError();
|
|
1501
|
+
}
|
|
1502
|
+
} else {
|
|
1503
|
+
multiRecord = makeRecord(void 0, NOT_YET, true);
|
|
1504
|
+
multiRecord.factory = () => injectArgs(multiRecord.multi);
|
|
1505
|
+
this.records.set(token, multiRecord);
|
|
1506
|
+
}
|
|
1507
|
+
token = provider;
|
|
1508
|
+
multiRecord.multi.push(provider);
|
|
1509
|
+
} else {
|
|
1510
|
+
if (ngDevMode) {
|
|
1511
|
+
const existing = this.records.get(token);
|
|
1512
|
+
if (existing && existing.multi !== void 0) {
|
|
1513
|
+
throwMixedMultiProviderError();
|
|
1514
|
+
}
|
|
1515
|
+
}
|
|
1516
|
+
}
|
|
1517
|
+
this.records.set(token, record);
|
|
1518
|
+
}
|
|
1519
|
+
hydrate(token, record, flags) {
|
|
1520
|
+
try {
|
|
1521
|
+
if (record.value === CIRCULAR) {
|
|
1522
|
+
throw cyclicDependencyError(stringify(token));
|
|
1523
|
+
} else if (record.value === NOT_YET) {
|
|
1524
|
+
record.value = CIRCULAR;
|
|
1525
|
+
if (ngDevMode) {
|
|
1526
|
+
runInInjectorProfilerContext(this, token, () => {
|
|
1527
|
+
emitInjectorToCreateInstanceEvent(token);
|
|
1528
|
+
record.value = record.factory(void 0, flags);
|
|
1529
|
+
emitInstanceCreatedByInjectorEvent(record.value);
|
|
1530
|
+
});
|
|
1531
|
+
} else {
|
|
1532
|
+
record.value = record.factory(void 0, flags);
|
|
1533
|
+
}
|
|
1534
|
+
}
|
|
1535
|
+
if (typeof record.value === "object" && record.value && hasOnDestroy(record.value)) {
|
|
1536
|
+
this._ngOnDestroyHooks.add(record.value);
|
|
1045
1537
|
}
|
|
1538
|
+
return record.value;
|
|
1539
|
+
} finally {
|
|
1046
1540
|
}
|
|
1047
|
-
} finally {
|
|
1048
|
-
inNotificationPhase = prev;
|
|
1049
1541
|
}
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
}
|
|
1054
|
-
function consumerMarkDirty(node) {
|
|
1055
|
-
node.dirty = true;
|
|
1056
|
-
producerNotifyConsumers(node);
|
|
1057
|
-
node.consumerMarkedDirty?.(node);
|
|
1058
|
-
}
|
|
1059
|
-
function producerMarkClean(node) {
|
|
1060
|
-
node.dirty = false;
|
|
1061
|
-
node.lastCleanEpoch = epoch;
|
|
1062
|
-
}
|
|
1063
|
-
function consumerBeforeComputation(node) {
|
|
1064
|
-
if (node) resetConsumerBeforeComputation(node);
|
|
1065
|
-
return setActiveConsumer(node);
|
|
1066
|
-
}
|
|
1067
|
-
function resetConsumerBeforeComputation(node) {
|
|
1068
|
-
node.producersTail = void 0;
|
|
1069
|
-
node.recomputing = true;
|
|
1070
|
-
}
|
|
1071
|
-
function consumerAfterComputation(node, prevConsumer) {
|
|
1072
|
-
setActiveConsumer(prevConsumer);
|
|
1073
|
-
if (node) finalizeConsumerAfterComputation(node);
|
|
1074
|
-
}
|
|
1075
|
-
function finalizeConsumerAfterComputation(node) {
|
|
1076
|
-
node.recomputing = false;
|
|
1077
|
-
const producersTail = node.producersTail;
|
|
1078
|
-
let toRemove = producersTail !== void 0 ? producersTail.nextProducer : node.producers;
|
|
1079
|
-
if (toRemove !== void 0) {
|
|
1080
|
-
if (consumerIsLive(node)) {
|
|
1081
|
-
do {
|
|
1082
|
-
toRemove = producerRemoveLiveConsumerLink(toRemove);
|
|
1083
|
-
} while (toRemove !== void 0);
|
|
1542
|
+
injectableDefInScope(def) {
|
|
1543
|
+
if (!def.providedIn) {
|
|
1544
|
+
return false;
|
|
1084
1545
|
}
|
|
1085
|
-
|
|
1086
|
-
|
|
1546
|
+
const providedIn = resolveForwardRef(def.providedIn);
|
|
1547
|
+
if (typeof providedIn === "string") {
|
|
1548
|
+
return providedIn === "any" || this.scopes.has(providedIn);
|
|
1087
1549
|
} else {
|
|
1088
|
-
|
|
1550
|
+
return this.injectorDefTypes.has(providedIn);
|
|
1089
1551
|
}
|
|
1090
1552
|
}
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
const seenVersion = link.lastReadVersion;
|
|
1096
|
-
if (seenVersion !== producer.version) {
|
|
1097
|
-
return true;
|
|
1098
|
-
}
|
|
1099
|
-
producerUpdateValueVersion(producer);
|
|
1100
|
-
if (seenVersion !== producer.version) {
|
|
1101
|
-
return true;
|
|
1553
|
+
removeOnDestroy(callback) {
|
|
1554
|
+
const destroyCBIdx = this._onDestroyHooks.indexOf(callback);
|
|
1555
|
+
if (destroyCBIdx !== -1) {
|
|
1556
|
+
this._onDestroyHooks.splice(destroyCBIdx, 1);
|
|
1102
1557
|
}
|
|
1103
1558
|
}
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
link = producerRemoveLiveConsumerLink(link);
|
|
1111
|
-
}
|
|
1559
|
+
};
|
|
1560
|
+
function injectableDefOrInjectorDefFactory(token) {
|
|
1561
|
+
const injectableDef = getInjectableDef(token);
|
|
1562
|
+
const factory = injectableDef !== null ? injectableDef.factory : getFactoryDef(token);
|
|
1563
|
+
if (factory !== null) {
|
|
1564
|
+
return factory;
|
|
1112
1565
|
}
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
node.consumers = void 0;
|
|
1116
|
-
node.consumersTail = void 0;
|
|
1117
|
-
}
|
|
1118
|
-
function producerAddLiveConsumer(node, link) {
|
|
1119
|
-
const consumersTail = node.consumersTail;
|
|
1120
|
-
const wasLive = consumerIsLive(node);
|
|
1121
|
-
if (consumersTail !== void 0) {
|
|
1122
|
-
link.nextConsumer = consumersTail.nextConsumer;
|
|
1123
|
-
consumersTail.nextConsumer = link;
|
|
1124
|
-
} else {
|
|
1125
|
-
link.nextConsumer = void 0;
|
|
1126
|
-
node.consumers = link;
|
|
1566
|
+
if (token instanceof InjectionToken) {
|
|
1567
|
+
throw new RuntimeError(204 /* INVALID_INJECTION_TOKEN */, ngDevMode && `Token ${stringify(token)} is missing a ɵprov definition.`);
|
|
1127
1568
|
}
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
if (!wasLive) {
|
|
1131
|
-
for (let link2 = node.producers; link2 !== void 0; link2 = link2.nextProducer) {
|
|
1132
|
-
producerAddLiveConsumer(link2.producer, link2);
|
|
1133
|
-
}
|
|
1569
|
+
if (token instanceof Function) {
|
|
1570
|
+
return getUndecoratedInjectableFactory(token);
|
|
1134
1571
|
}
|
|
1572
|
+
throw new RuntimeError(204 /* INVALID_INJECTION_TOKEN */, ngDevMode && "unreachable");
|
|
1135
1573
|
}
|
|
1136
|
-
function
|
|
1137
|
-
const
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
const prevConsumer = link.prevConsumer;
|
|
1141
|
-
link.nextConsumer = void 0;
|
|
1142
|
-
link.prevConsumer = void 0;
|
|
1143
|
-
if (nextConsumer !== void 0) {
|
|
1144
|
-
nextConsumer.prevConsumer = prevConsumer;
|
|
1145
|
-
} else {
|
|
1146
|
-
producer.consumersTail = prevConsumer;
|
|
1574
|
+
function getUndecoratedInjectableFactory(token) {
|
|
1575
|
+
const paramLength = token.length;
|
|
1576
|
+
if (paramLength > 0) {
|
|
1577
|
+
throw new RuntimeError(204 /* INVALID_INJECTION_TOKEN */, ngDevMode && `Can't resolve all parameters for ${stringify(token)}: (${newArray(paramLength, "?").join(", ")}).`);
|
|
1147
1578
|
}
|
|
1148
|
-
|
|
1149
|
-
|
|
1579
|
+
const inheritedInjectableDef = getInheritedInjectableDef(token);
|
|
1580
|
+
if (inheritedInjectableDef !== null) {
|
|
1581
|
+
return () => inheritedInjectableDef.factory(token);
|
|
1150
1582
|
} else {
|
|
1151
|
-
|
|
1152
|
-
if (!consumerIsLive(producer)) {
|
|
1153
|
-
let producerLink = producer.producers;
|
|
1154
|
-
while (producerLink !== void 0) {
|
|
1155
|
-
producerLink = producerRemoveLiveConsumerLink(producerLink);
|
|
1156
|
-
}
|
|
1157
|
-
}
|
|
1158
|
-
}
|
|
1159
|
-
return nextProducer;
|
|
1160
|
-
}
|
|
1161
|
-
function consumerIsLive(node) {
|
|
1162
|
-
return node.consumerIsAlwaysLive || node.consumers !== void 0;
|
|
1163
|
-
}
|
|
1164
|
-
function runPostProducerCreatedFn(node) {
|
|
1165
|
-
postProducerCreatedFn?.(node);
|
|
1166
|
-
}
|
|
1167
|
-
function isValidLink(checkLink, consumer) {
|
|
1168
|
-
const producersTail = consumer.producersTail;
|
|
1169
|
-
if (producersTail !== void 0) {
|
|
1170
|
-
let link = consumer.producers;
|
|
1171
|
-
do {
|
|
1172
|
-
if (link === checkLink) {
|
|
1173
|
-
return true;
|
|
1174
|
-
}
|
|
1175
|
-
if (link === producersTail) {
|
|
1176
|
-
break;
|
|
1177
|
-
}
|
|
1178
|
-
link = link.nextProducer;
|
|
1179
|
-
} while (link !== void 0);
|
|
1583
|
+
return () => new token();
|
|
1180
1584
|
}
|
|
1181
|
-
return false;
|
|
1182
|
-
}
|
|
1183
|
-
|
|
1184
|
-
// src/primitives/signals/src/equality.ts
|
|
1185
|
-
function defaultEquals(a, b) {
|
|
1186
|
-
return Object.is(a, b);
|
|
1187
1585
|
}
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
node.equal = equal;
|
|
1195
|
-
}
|
|
1196
|
-
const computed2 = () => {
|
|
1197
|
-
producerUpdateValueVersion(node);
|
|
1198
|
-
producerAccessed(node);
|
|
1199
|
-
if (node.value === ERRORED) {
|
|
1200
|
-
throw node.error;
|
|
1201
|
-
}
|
|
1202
|
-
return node.value;
|
|
1203
|
-
};
|
|
1204
|
-
computed2[SIGNAL] = node;
|
|
1205
|
-
if (false) {
|
|
1206
|
-
const debugName = node.debugName ? " (" + node.debugName + ")" : "";
|
|
1207
|
-
computed2.toString = () => `[Computed${debugName}: ${node.value}]`;
|
|
1586
|
+
function providerToRecord(provider) {
|
|
1587
|
+
if (isValueProvider(provider)) {
|
|
1588
|
+
return makeRecord(void 0, provider.useValue);
|
|
1589
|
+
} else {
|
|
1590
|
+
const factory = providerToFactory(provider);
|
|
1591
|
+
return makeRecord(factory, NOT_YET);
|
|
1208
1592
|
}
|
|
1209
|
-
runPostProducerCreatedFn(node);
|
|
1210
|
-
return computed2;
|
|
1211
1593
|
}
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
...REACTIVE_NODE,
|
|
1217
|
-
value: UNSET,
|
|
1218
|
-
dirty: true,
|
|
1219
|
-
error: null,
|
|
1220
|
-
equal: defaultEquals,
|
|
1221
|
-
kind: "computed",
|
|
1222
|
-
producerMustRecompute(node) {
|
|
1223
|
-
return node.value === UNSET || node.value === COMPUTING;
|
|
1224
|
-
},
|
|
1225
|
-
producerRecomputeValue(node) {
|
|
1226
|
-
if (node.value === COMPUTING) {
|
|
1227
|
-
throw new Error(false ? "Detected cycle in computations." : "");
|
|
1228
|
-
}
|
|
1229
|
-
const oldValue = node.value;
|
|
1230
|
-
node.value = COMPUTING;
|
|
1231
|
-
const prevConsumer = consumerBeforeComputation(node);
|
|
1232
|
-
let newValue;
|
|
1233
|
-
let wasEqual = false;
|
|
1234
|
-
try {
|
|
1235
|
-
newValue = node.computation();
|
|
1236
|
-
setActiveConsumer(null);
|
|
1237
|
-
wasEqual = oldValue !== UNSET && oldValue !== ERRORED && newValue !== ERRORED && node.equal(oldValue, newValue);
|
|
1238
|
-
} catch (err) {
|
|
1239
|
-
newValue = ERRORED;
|
|
1240
|
-
node.error = err;
|
|
1241
|
-
} finally {
|
|
1242
|
-
consumerAfterComputation(node, prevConsumer);
|
|
1243
|
-
}
|
|
1244
|
-
if (wasEqual) {
|
|
1245
|
-
node.value = oldValue;
|
|
1246
|
-
return;
|
|
1247
|
-
}
|
|
1248
|
-
node.value = newValue;
|
|
1249
|
-
node.version++;
|
|
1594
|
+
function providerToFactory(provider, ngModuleType, providers) {
|
|
1595
|
+
let factory = void 0;
|
|
1596
|
+
if (ngDevMode && isEnvironmentProviders(provider)) {
|
|
1597
|
+
throwInvalidProviderError(void 0, providers, provider);
|
|
1250
1598
|
}
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1599
|
+
if (isTypeProvider(provider)) {
|
|
1600
|
+
const unwrappedProvider = resolveForwardRef(provider);
|
|
1601
|
+
return getFactoryDef(unwrappedProvider) || injectableDefOrInjectorDefFactory(unwrappedProvider);
|
|
1602
|
+
} else {
|
|
1603
|
+
if (isValueProvider(provider)) {
|
|
1604
|
+
factory = () => resolveForwardRef(provider.useValue);
|
|
1605
|
+
} else if (isFactoryProvider(provider)) {
|
|
1606
|
+
factory = () => provider.useFactory(...injectArgs(provider.deps || []));
|
|
1607
|
+
} else if (isExistingProvider(provider)) {
|
|
1608
|
+
factory = (_, flags) => ɵɵinject(resolveForwardRef(provider.useExisting), flags !== void 0 && flags & 8 /* Optional */ ? 8 /* Optional */ : void 0);
|
|
1609
|
+
} else {
|
|
1610
|
+
const classRef = resolveForwardRef(provider && (provider.useClass || provider.provide));
|
|
1611
|
+
if (ngDevMode && !classRef) {
|
|
1612
|
+
throwInvalidProviderError(ngModuleType, providers, provider);
|
|
1613
|
+
}
|
|
1614
|
+
if (hasDeps(provider)) {
|
|
1615
|
+
factory = () => new classRef(...injectArgs(provider.deps));
|
|
1616
|
+
} else {
|
|
1617
|
+
return getFactoryDef(classRef) || injectableDefOrInjectorDefFactory(classRef);
|
|
1618
|
+
}
|
|
1619
|
+
}
|
|
1269
1620
|
}
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1621
|
+
return factory;
|
|
1622
|
+
}
|
|
1623
|
+
function assertNotDestroyed(injector) {
|
|
1624
|
+
if (injector.destroyed) {
|
|
1625
|
+
throw new RuntimeError(205 /* INJECTOR_ALREADY_DESTROYED */, ngDevMode && "Injector has already been destroyed.");
|
|
1275
1626
|
}
|
|
1276
|
-
runPostProducerCreatedFn(node);
|
|
1277
|
-
const set = (newValue) => signalSetFn(node, newValue);
|
|
1278
|
-
const update = (updateFn) => signalUpdateFn(node, updateFn);
|
|
1279
|
-
return [getter, set, update];
|
|
1280
1627
|
}
|
|
1281
|
-
function
|
|
1282
|
-
|
|
1283
|
-
|
|
1628
|
+
function makeRecord(factory, value, multi = false) {
|
|
1629
|
+
return {
|
|
1630
|
+
factory,
|
|
1631
|
+
value,
|
|
1632
|
+
multi: multi ? [] : void 0
|
|
1633
|
+
};
|
|
1284
1634
|
}
|
|
1285
|
-
function
|
|
1286
|
-
|
|
1287
|
-
throwInvalidWriteToSignalError(node);
|
|
1288
|
-
}
|
|
1289
|
-
if (!node.equal(node.value, newValue)) {
|
|
1290
|
-
node.value = newValue;
|
|
1291
|
-
signalValueChanged(node);
|
|
1292
|
-
}
|
|
1635
|
+
function hasDeps(value) {
|
|
1636
|
+
return !!value.deps;
|
|
1293
1637
|
}
|
|
1294
|
-
function
|
|
1295
|
-
|
|
1296
|
-
throwInvalidWriteToSignalError(node);
|
|
1297
|
-
}
|
|
1298
|
-
signalSetFn(node, updater(node.value));
|
|
1638
|
+
function hasOnDestroy(value) {
|
|
1639
|
+
return value !== null && typeof value === "object" && typeof value.ngOnDestroy === "function";
|
|
1299
1640
|
}
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
equal: defaultEquals,
|
|
1303
|
-
value: void 0,
|
|
1304
|
-
kind: "signal"
|
|
1305
|
-
}))();
|
|
1306
|
-
function signalValueChanged(node) {
|
|
1307
|
-
node.version++;
|
|
1308
|
-
producerIncrementEpoch();
|
|
1309
|
-
producerNotifyConsumers(node);
|
|
1310
|
-
postSignalSetFn?.(node);
|
|
1641
|
+
function couldBeInjectableType(value) {
|
|
1642
|
+
return typeof value === "function" || typeof value === "object" && value.ngMetadataName === "InjectionToken";
|
|
1311
1643
|
}
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
}
|
|
1321
|
-
const linkedSignalGetter = () => {
|
|
1322
|
-
producerUpdateValueVersion(node);
|
|
1323
|
-
producerAccessed(node);
|
|
1324
|
-
if (node.value === ERRORED) {
|
|
1325
|
-
throw node.error;
|
|
1644
|
+
function forEachSingleProvider(providers, fn) {
|
|
1645
|
+
for (const provider of providers) {
|
|
1646
|
+
if (Array.isArray(provider)) {
|
|
1647
|
+
forEachSingleProvider(provider, fn);
|
|
1648
|
+
} else if (provider && isEnvironmentProviders(provider)) {
|
|
1649
|
+
forEachSingleProvider(provider.ɵproviders, fn);
|
|
1650
|
+
} else {
|
|
1651
|
+
fn(provider);
|
|
1326
1652
|
}
|
|
1327
|
-
return node.value;
|
|
1328
|
-
};
|
|
1329
|
-
const getter = linkedSignalGetter;
|
|
1330
|
-
getter[SIGNAL] = node;
|
|
1331
|
-
if (false) {
|
|
1332
|
-
const debugName = node.debugName ? " (" + node.debugName + ")" : "";
|
|
1333
|
-
getter.toString = () => `[LinkedSignal${debugName}: ${node.value}]`;
|
|
1334
1653
|
}
|
|
1335
|
-
runPostProducerCreatedFn(node);
|
|
1336
|
-
return getter;
|
|
1337
|
-
}
|
|
1338
|
-
function linkedSignalSetFn(node, newValue) {
|
|
1339
|
-
producerUpdateValueVersion(node);
|
|
1340
|
-
signalSetFn(node, newValue);
|
|
1341
|
-
producerMarkClean(node);
|
|
1342
1654
|
}
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1655
|
+
|
|
1656
|
+
// src/import/util/closure.ts
|
|
1657
|
+
function noSideEffects(fn) {
|
|
1658
|
+
return { toString: fn }.toString();
|
|
1347
1659
|
}
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
},
|
|
1358
|
-
producerRecomputeValue(node) {
|
|
1359
|
-
if (node.value === COMPUTING) {
|
|
1360
|
-
throw new Error(false ? "Detected cycle in computations." : "");
|
|
1660
|
+
|
|
1661
|
+
// src/import/util/decorators.ts
|
|
1662
|
+
function makeMetadataCtor(props) {
|
|
1663
|
+
return function ctor(...args) {
|
|
1664
|
+
if (props) {
|
|
1665
|
+
const values = props(...args);
|
|
1666
|
+
for (const propName in values) {
|
|
1667
|
+
this[propName] = values[propName];
|
|
1668
|
+
}
|
|
1361
1669
|
}
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
value: oldValue
|
|
1371
|
-
};
|
|
1372
|
-
newValue = node.computation(newSourceValue, prev);
|
|
1373
|
-
node.sourceValue = newSourceValue;
|
|
1374
|
-
} catch (err) {
|
|
1375
|
-
newValue = ERRORED;
|
|
1376
|
-
node.error = err;
|
|
1377
|
-
} finally {
|
|
1378
|
-
consumerAfterComputation(node, prevConsumer);
|
|
1670
|
+
};
|
|
1671
|
+
}
|
|
1672
|
+
function makeParamDecorator(name, props, parentClass) {
|
|
1673
|
+
return noSideEffects(() => {
|
|
1674
|
+
const metaCtor = makeMetadataCtor(props);
|
|
1675
|
+
function ParamDecoratorFactory(...args) {
|
|
1676
|
+
metaCtor.apply(this, args);
|
|
1677
|
+
return this;
|
|
1379
1678
|
}
|
|
1380
|
-
if (
|
|
1381
|
-
node.value = oldValue;
|
|
1382
|
-
return;
|
|
1679
|
+
if (parentClass) {
|
|
1383
1680
|
}
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
}))();
|
|
1681
|
+
return ParamDecoratorFactory;
|
|
1682
|
+
});
|
|
1683
|
+
}
|
|
1388
1684
|
|
|
1389
|
-
// src/
|
|
1390
|
-
|
|
1391
|
-
const
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1685
|
+
// src/import/di/metadata.ts
|
|
1686
|
+
var Inject = attachInjectFlag(
|
|
1687
|
+
// Disable tslint because `DecoratorFlags` is a const enum which gets inlined.
|
|
1688
|
+
makeParamDecorator("Inject", (token) => ({ token })),
|
|
1689
|
+
// tslint:disable-next-line: no-toplevel-property-access
|
|
1690
|
+
-1 /* Inject */
|
|
1691
|
+
);
|
|
1692
|
+
var Optional = (
|
|
1693
|
+
// Disable tslint because `InternalInjectFlags` is a const enum which gets inlined.
|
|
1694
|
+
// tslint:disable-next-line: no-toplevel-property-access
|
|
1695
|
+
attachInjectFlag(makeParamDecorator("Optional"), 8 /* Optional */)
|
|
1696
|
+
);
|
|
1697
|
+
var Self = (
|
|
1698
|
+
// Disable tslint because `InternalInjectFlags` is a const enum which gets inlined.
|
|
1699
|
+
// tslint:disable-next-line: no-toplevel-property-access
|
|
1700
|
+
attachInjectFlag(makeParamDecorator("Self"), 2 /* Self */)
|
|
1701
|
+
);
|
|
1702
|
+
var SkipSelf = (
|
|
1703
|
+
// Disable tslint because `InternalInjectFlags` is a const enum which gets inlined.
|
|
1704
|
+
// tslint:disable-next-line: no-toplevel-property-access
|
|
1705
|
+
attachInjectFlag(makeParamDecorator("SkipSelf"), 4 /* SkipSelf */)
|
|
1706
|
+
);
|
|
1707
|
+
|
|
1708
|
+
// src/import/di/create_injector.ts
|
|
1709
|
+
function createInjector(defType, parent = null, additionalProviders = null, name) {
|
|
1710
|
+
const injector = createInjectorWithoutInjectorInstances(defType, parent, additionalProviders, name);
|
|
1711
|
+
injector.resolveInjectorInitializers();
|
|
1712
|
+
return injector;
|
|
1713
|
+
}
|
|
1714
|
+
function createInjectorWithoutInjectorInstances(defType, parent = null, additionalProviders = null, name, scopes = /* @__PURE__ */ new Set()) {
|
|
1715
|
+
const providers = [additionalProviders || EMPTY_ARRAY];
|
|
1716
|
+
name = name || (typeof defType === "object" ? void 0 : stringify(defType));
|
|
1717
|
+
return new R3Injector(providers, parent || getNullInjector(), name || null, scopes);
|
|
1397
1718
|
}
|
|
1398
1719
|
|
|
1399
|
-
// src/
|
|
1400
|
-
var
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
}
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
return;
|
|
1411
|
-
}
|
|
1412
|
-
node.version++;
|
|
1413
|
-
const prevNode = consumerBeforeComputation(node);
|
|
1414
|
-
try {
|
|
1415
|
-
node.cleanup();
|
|
1416
|
-
node.fn();
|
|
1417
|
-
} finally {
|
|
1418
|
-
consumerAfterComputation(node, prevNode);
|
|
1720
|
+
// src/import/di/injector.ts
|
|
1721
|
+
var Injector = class _Injector {
|
|
1722
|
+
static THROW_IF_NOT_FOUND = THROW_IF_NOT_FOUND;
|
|
1723
|
+
static NULL = /* @__PURE__ */ new NullInjector();
|
|
1724
|
+
static create(options, parent) {
|
|
1725
|
+
if (Array.isArray(options)) {
|
|
1726
|
+
return createInjector({ name: "" }, parent, options, "");
|
|
1727
|
+
} else {
|
|
1728
|
+
const name = options.name ?? "";
|
|
1729
|
+
return createInjector({ name }, options.parent, options.providers, name);
|
|
1730
|
+
}
|
|
1419
1731
|
}
|
|
1420
|
-
|
|
1732
|
+
/** @nocollapse */
|
|
1733
|
+
static ɵprov = (
|
|
1734
|
+
/** @pureOrBreakMyCode */
|
|
1735
|
+
/* @__PURE__ */ ɵɵdefineInjectable({
|
|
1736
|
+
token: _Injector,
|
|
1737
|
+
providedIn: "any",
|
|
1738
|
+
factory: () => ɵɵinject(INJECTOR)
|
|
1739
|
+
})
|
|
1740
|
+
);
|
|
1741
|
+
/**
|
|
1742
|
+
* @internal
|
|
1743
|
+
* @nocollapse
|
|
1744
|
+
*/
|
|
1745
|
+
static __NG_ELEMENT_ID__ = -1 /* Injector */;
|
|
1746
|
+
};
|
|
1421
1747
|
|
|
1422
|
-
// src/
|
|
1423
|
-
|
|
1424
|
-
|
|
1748
|
+
// src/import/render3/instructions/di.ts
|
|
1749
|
+
function ɵɵinvalidFactory() {
|
|
1750
|
+
const msg = ngDevMode ? `This constructor was not compatible with Dependency Injection.` : "invalid";
|
|
1751
|
+
throw new Error(msg);
|
|
1425
1752
|
}
|
|
1426
1753
|
|
|
1427
1754
|
// src/import/render3/reactivity/api.ts
|
|
1428
|
-
function
|
|
1755
|
+
function isSignal2(value) {
|
|
1429
1756
|
return typeof value === "function" && value[SIGNAL] !== void 0;
|
|
1430
1757
|
}
|
|
1431
1758
|
|
|
1432
1759
|
// src/import/render3/reactivity/computed.ts
|
|
1433
1760
|
function computed(computation, options) {
|
|
1434
1761
|
const getter = createComputed(computation, options?.equal);
|
|
1435
|
-
if (
|
|
1762
|
+
if (ngDevMode) {
|
|
1763
|
+
getter.toString = () => `[Computed: ${getter()}]`;
|
|
1764
|
+
getter[SIGNAL].debugName = options?.debugName;
|
|
1436
1765
|
}
|
|
1437
1766
|
return getter;
|
|
1438
1767
|
}
|
|
@@ -1448,7 +1777,9 @@ function signal(initialValue, options) {
|
|
|
1448
1777
|
signalFn.set = set;
|
|
1449
1778
|
signalFn.update = update;
|
|
1450
1779
|
signalFn.asReadonly = signalAsReadonlyFn.bind(signalFn);
|
|
1451
|
-
if (
|
|
1780
|
+
if (ngDevMode) {
|
|
1781
|
+
signalFn.toString = () => `[Signal: ${signalFn()}]`;
|
|
1782
|
+
node.debugName = options?.debugName;
|
|
1452
1783
|
}
|
|
1453
1784
|
return signalFn;
|
|
1454
1785
|
}
|
|
@@ -1474,7 +1805,9 @@ function linkedSignal(optionsOrComputation, options) {
|
|
|
1474
1805
|
}
|
|
1475
1806
|
}
|
|
1476
1807
|
function upgradeLinkedSignalGetter(getter, debugName) {
|
|
1477
|
-
if (
|
|
1808
|
+
if (ngDevMode) {
|
|
1809
|
+
getter.toString = () => `[LinkedSignal: ${getter()}]`;
|
|
1810
|
+
getter[SIGNAL].debugName = debugName;
|
|
1478
1811
|
}
|
|
1479
1812
|
const node = getter[SIGNAL];
|
|
1480
1813
|
const upgradedGetter = getter;
|
|
@@ -1492,7 +1825,23 @@ function untracked2(nonReactiveReadsFn) {
|
|
|
1492
1825
|
// src/import/render3/reactivity/asserts.ts
|
|
1493
1826
|
function assertNotInReactiveContext(debugFn, extraContext) {
|
|
1494
1827
|
if (getActiveConsumer() !== null) {
|
|
1495
|
-
throw new RuntimeError(
|
|
1828
|
+
throw new RuntimeError(
|
|
1829
|
+
-602 /* ASSERTION_NOT_INSIDE_REACTIVE_CONTEXT */,
|
|
1830
|
+
ngDevMode && `${debugFn.name}() cannot be called from within a reactive context.${extraContext ? ` ${extraContext}` : ""}`
|
|
1831
|
+
);
|
|
1832
|
+
}
|
|
1833
|
+
}
|
|
1834
|
+
|
|
1835
|
+
// src/import/di/contextual.ts
|
|
1836
|
+
function isInInjectionContext() {
|
|
1837
|
+
return getInjectImplementation() !== void 0 || getCurrentInjector() != null;
|
|
1838
|
+
}
|
|
1839
|
+
function assertInInjectionContext(debugFn) {
|
|
1840
|
+
if (!isInInjectionContext()) {
|
|
1841
|
+
throw new RuntimeError(
|
|
1842
|
+
-203 /* MISSING_INJECTION_CONTEXT */,
|
|
1843
|
+
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`"
|
|
1844
|
+
);
|
|
1496
1845
|
}
|
|
1497
1846
|
}
|
|
1498
1847
|
|
|
@@ -1533,10 +1882,10 @@ var NotificationSource = /* @__PURE__ */ ((NotificationSource2) => {
|
|
|
1533
1882
|
})(NotificationSource || {});
|
|
1534
1883
|
var ChangeDetectionScheduler = class {
|
|
1535
1884
|
};
|
|
1536
|
-
var ZONELESS_ENABLED = new InjectionToken("", { providedIn: "root", factory: () => false });
|
|
1537
|
-
var PROVIDED_ZONELESS = new InjectionToken("", { providedIn: "root", factory: () => false });
|
|
1538
|
-
var ZONELESS_SCHEDULER_DISABLED = new InjectionToken("");
|
|
1539
|
-
var SCHEDULE_IN_ROOT_ZONE = new InjectionToken("");
|
|
1885
|
+
var ZONELESS_ENABLED = new InjectionToken(typeof ngDevMode === "undefined" || ngDevMode ? "Zoneless enabled" : "", { providedIn: "root", factory: () => false });
|
|
1886
|
+
var PROVIDED_ZONELESS = new InjectionToken(typeof ngDevMode === "undefined" || ngDevMode ? "Zoneless provided" : "", { providedIn: "root", factory: () => false });
|
|
1887
|
+
var ZONELESS_SCHEDULER_DISABLED = new InjectionToken(typeof ngDevMode === "undefined" || ngDevMode ? "scheduler disabled" : "");
|
|
1888
|
+
var SCHEDULE_IN_ROOT_ZONE = new InjectionToken(typeof ngDevMode === "undefined" || ngDevMode ? "run changes outside zone in root" : "");
|
|
1540
1889
|
|
|
1541
1890
|
// src/import/render3/reactivity/root_effect_scheduler.ts
|
|
1542
1891
|
var EffectScheduler = class _EffectScheduler {
|
|
@@ -1631,10 +1980,11 @@ var EffectRefImpl = class {
|
|
|
1631
1980
|
}
|
|
1632
1981
|
};
|
|
1633
1982
|
function effect(effectFn, options) {
|
|
1634
|
-
|
|
1983
|
+
ngDevMode && assertNotInReactiveContext(effect, "Call `effect` outside of a reactive context. For example, schedule the effect inside the component constructor.");
|
|
1984
|
+
if (ngDevMode && !options?.injector) {
|
|
1635
1985
|
assertInInjectionContext(effect);
|
|
1636
1986
|
}
|
|
1637
|
-
if (
|
|
1987
|
+
if (ngDevMode && options?.allowSignalWrites !== void 0) {
|
|
1638
1988
|
console.warn(`The 'allowSignalWrites' flag is deprecated and no longer impacts effect() (writes are always allowed)`);
|
|
1639
1989
|
}
|
|
1640
1990
|
const injector = options?.injector ?? inject2(Injector);
|
|
@@ -1647,6 +1997,15 @@ function effect(effectFn, options) {
|
|
|
1647
1997
|
node.onDestroyFn = destroyRef.onDestroy(() => node.destroy());
|
|
1648
1998
|
}
|
|
1649
1999
|
const effectRef = new EffectRefImpl(node);
|
|
2000
|
+
if (ngDevMode) {
|
|
2001
|
+
node.debugName = options?.debugName ?? "";
|
|
2002
|
+
const prevInjectorProfilerContext = setInjectorProfilerContext({ injector, token: null });
|
|
2003
|
+
try {
|
|
2004
|
+
emitEffectCreatedEvent(effectRef);
|
|
2005
|
+
} finally {
|
|
2006
|
+
setInjectorProfilerContext(prevInjectorProfilerContext);
|
|
2007
|
+
}
|
|
2008
|
+
}
|
|
1650
2009
|
return effectRef;
|
|
1651
2010
|
}
|
|
1652
2011
|
var EFFECT_NODE = /* @__PURE__ */ (() => ({
|
|
@@ -1655,7 +2014,7 @@ var EFFECT_NODE = /* @__PURE__ */ (() => ({
|
|
|
1655
2014
|
zone: null,
|
|
1656
2015
|
onDestroyFn: noop,
|
|
1657
2016
|
run() {
|
|
1658
|
-
if (
|
|
2017
|
+
if (ngDevMode && isInNotificationPhase()) {
|
|
1659
2018
|
throw new Error(`Schedulers cannot synchronously execute watches while scheduling.`);
|
|
1660
2019
|
}
|
|
1661
2020
|
try {
|
|
@@ -1750,7 +2109,7 @@ var ErrorHandler = class {
|
|
|
1750
2109
|
this._console.error("ERROR", error);
|
|
1751
2110
|
}
|
|
1752
2111
|
};
|
|
1753
|
-
var INTERNAL_APPLICATION_ERROR_HANDLER = new InjectionToken("", {
|
|
2112
|
+
var INTERNAL_APPLICATION_ERROR_HANDLER = new InjectionToken(typeof ngDevMode === "undefined" || ngDevMode ? "internal error handler" : "", {
|
|
1754
2113
|
providedIn: "root",
|
|
1755
2114
|
factory: () => {
|
|
1756
2115
|
const injector = inject2(EnvironmentInjector);
|
|
@@ -1873,7 +2232,8 @@ var PendingTasks = class _PendingTasks {
|
|
|
1873
2232
|
|
|
1874
2233
|
// src/import/resource/resource.ts
|
|
1875
2234
|
function resource(options) {
|
|
1876
|
-
if (
|
|
2235
|
+
if (ngDevMode && !options?.injector) {
|
|
2236
|
+
assertInInjectionContext(resource);
|
|
1877
2237
|
}
|
|
1878
2238
|
const oldNameForParams = options.request;
|
|
1879
2239
|
const params = options.params ?? oldNameForParams ?? (() => null);
|
|
@@ -2122,12 +2482,12 @@ function encapsulateResourceError(error) {
|
|
|
2122
2482
|
}
|
|
2123
2483
|
var ResourceValueError = class extends Error {
|
|
2124
2484
|
constructor(error) {
|
|
2125
|
-
super(error.message, { cause: error });
|
|
2485
|
+
super(ngDevMode ? `Resource is currently in an error state (see Error.cause for details): ${error.message}` : error.message, { cause: error });
|
|
2126
2486
|
}
|
|
2127
2487
|
};
|
|
2128
2488
|
var ResourceWrappedError = class extends Error {
|
|
2129
2489
|
constructor(error) {
|
|
2130
|
-
super(String(error), { cause: error });
|
|
2490
|
+
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 });
|
|
2131
2491
|
}
|
|
2132
2492
|
};
|
|
2133
2493
|
|