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