static-injector 6.0.2 → 6.1.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/change_detection/scheduling/zoneless_scheduling.d.ts +1 -1
- package/import/core_reactivity_export_internal.d.ts +3 -4
- package/import/di/forward_ref.d.ts +9 -7
- package/import/di/inject_switch.d.ts +4 -4
- package/import/di/injector.d.ts +12 -17
- package/import/di/injector_compatibility.d.ts +24 -18
- package/import/di/interface/injector.d.ts +13 -17
- package/import/di/metadata.d.ts +7 -0
- package/import/di/provider_collection.d.ts +2 -42
- package/import/di/r3_injector.d.ts +10 -11
- package/import/error_handler.d.ts +5 -0
- package/import/errors.d.ts +11 -1
- package/import/index.d.ts +4 -0
- package/import/linker/destroy_ref.d.ts +2 -0
- package/import/pending_tasks.d.ts +15 -16
- package/import/render3/errors_di.d.ts +2 -0
- package/import/render3/reactivity/api.d.ts +5 -1
- package/import/render3/reactivity/asserts.d.ts +1 -1
- package/import/render3/reactivity/effect.d.ts +10 -22
- package/import/render3/reactivity/linked_signal.d.ts +3 -3
- package/import/render3/reactivity/root_effect_scheduler.d.ts +4 -1
- package/import/render3/reactivity/signal.d.ts +3 -1
- package/import/resource/api.d.ts +35 -50
- package/import/resource/resource.d.ts +9 -7
- package/index.js +464 -623
- package/index.js.map +4 -4
- package/index.mjs +458 -619
- package/index.mjs.map +4 -4
- package/package.json +2 -2
- package/primitives/di/index.d.ts +12 -0
- package/primitives/di/src/injection_token.d.ts +63 -0
- package/primitives/di/src/injector.d.ts +14 -0
- package/primitives/di/src/not_found.d.ts +28 -0
- package/primitives/di/src/type.d.ts +61 -0
- package/primitives/signals/index.d.ts +5 -4
- package/primitives/signals/src/computed.d.ts +1 -1
- package/primitives/signals/src/graph.d.ts +3 -0
- package/primitives/signals/src/linked_signal.d.ts +2 -29
- package/primitives/signals/src/signal.d.ts +8 -6
- package/{import/render3/reactivity/patch.d.ts → primitives/signals/src/untracked.d.ts} +3 -2
- package/readme.md +1 -1
- package/import/render3/reactivity/microtask_effect.d.ts +0 -21
package/index.mjs
CHANGED
|
@@ -10,8 +10,11 @@ var RuntimeError = class extends Error {
|
|
|
10
10
|
this.code = code;
|
|
11
11
|
}
|
|
12
12
|
};
|
|
13
|
+
function formatRuntimeErrorCode(code) {
|
|
14
|
+
return `NG0${Math.abs(code)}`;
|
|
15
|
+
}
|
|
13
16
|
function formatRuntimeError(code, message) {
|
|
14
|
-
const fullCode =
|
|
17
|
+
const fullCode = formatRuntimeErrorCode(code);
|
|
15
18
|
const errorMessage = `${fullCode}${message ? ": " + message : ""}`;
|
|
16
19
|
if (false) {
|
|
17
20
|
}
|
|
@@ -23,6 +26,15 @@ function getFactoryDef(type, throwNotFound) {
|
|
|
23
26
|
return () => new type();
|
|
24
27
|
}
|
|
25
28
|
|
|
29
|
+
// src/import/render3/errors_di.ts
|
|
30
|
+
function throwCyclicDependencyError(token, path) {
|
|
31
|
+
throw new RuntimeError(-200 /* CYCLIC_DI_DEPENDENCY */, token);
|
|
32
|
+
}
|
|
33
|
+
function throwProviderNotFoundError(token, injectorName) {
|
|
34
|
+
const errorMessage = void 0;
|
|
35
|
+
throw new RuntimeError(-201 /* PROVIDER_NOT_FOUND */, errorMessage);
|
|
36
|
+
}
|
|
37
|
+
|
|
26
38
|
// src/import/util/property.ts
|
|
27
39
|
function getClosureSafeProperty(objWithPropertyToExtract) {
|
|
28
40
|
for (const key in objWithPropertyToExtract) {
|
|
@@ -30,16 +42,12 @@ function getClosureSafeProperty(objWithPropertyToExtract) {
|
|
|
30
42
|
return key;
|
|
31
43
|
}
|
|
32
44
|
}
|
|
33
|
-
throw Error("
|
|
45
|
+
throw Error("");
|
|
34
46
|
}
|
|
35
47
|
|
|
36
48
|
// src/import/render3/fields.ts
|
|
37
|
-
var NG_FACTORY_DEF = getClosureSafeProperty({
|
|
38
|
-
|
|
39
|
-
});
|
|
40
|
-
var NG_ENV_ID = getClosureSafeProperty({
|
|
41
|
-
__NG_ENV_ID__: getClosureSafeProperty
|
|
42
|
-
});
|
|
49
|
+
var NG_FACTORY_DEF = getClosureSafeProperty({ ɵfac: getClosureSafeProperty });
|
|
50
|
+
var NG_ENV_ID = getClosureSafeProperty({ __NG_ENV_ID__: getClosureSafeProperty });
|
|
43
51
|
|
|
44
52
|
// src/import/util/empty.ts
|
|
45
53
|
var EMPTY_ARRAY = [];
|
|
@@ -70,9 +78,7 @@ function stringify(token) {
|
|
|
70
78
|
}
|
|
71
79
|
|
|
72
80
|
// src/import/di/forward_ref.ts
|
|
73
|
-
var __forward_ref__ = getClosureSafeProperty({
|
|
74
|
-
__forward_ref__: getClosureSafeProperty
|
|
75
|
-
});
|
|
81
|
+
var __forward_ref__ = getClosureSafeProperty({ __forward_ref__: getClosureSafeProperty });
|
|
76
82
|
function forwardRef(forwardRefFn) {
|
|
77
83
|
forwardRefFn.__forward_ref__ = forwardRef;
|
|
78
84
|
forwardRefFn.toString = function() {
|
|
@@ -100,20 +106,16 @@ function ɵɵdefineInjector(options) {
|
|
|
100
106
|
return { providers: options.providers || [], imports: options.imports || [] };
|
|
101
107
|
}
|
|
102
108
|
function getInjectableDef(type) {
|
|
103
|
-
return getOwnDefinition(type, NG_PROV_DEF) || {
|
|
104
|
-
token: type,
|
|
105
|
-
factory: () => new type(),
|
|
106
|
-
...type.injectOptions
|
|
107
|
-
};
|
|
109
|
+
return getOwnDefinition(type, NG_PROV_DEF) || { token: type, factory: () => new type(), ...type.injectOptions };
|
|
108
110
|
}
|
|
109
111
|
function isInjectable(type) {
|
|
110
112
|
return getInjectableDef(type) !== null;
|
|
111
113
|
}
|
|
112
114
|
function getOwnDefinition(type, field) {
|
|
113
|
-
return type.hasOwnProperty(field)
|
|
115
|
+
return type.hasOwnProperty(field) && type[field] || null;
|
|
114
116
|
}
|
|
115
117
|
function getInheritedInjectableDef(type) {
|
|
116
|
-
const def = type
|
|
118
|
+
const def = type?.[NG_PROV_DEF] ?? null;
|
|
117
119
|
if (def) {
|
|
118
120
|
return def;
|
|
119
121
|
} else {
|
|
@@ -121,14 +123,10 @@ function getInheritedInjectableDef(type) {
|
|
|
121
123
|
}
|
|
122
124
|
}
|
|
123
125
|
function getInjectorDef(type) {
|
|
124
|
-
return type &&
|
|
126
|
+
return type && type.hasOwnProperty(NG_INJ_DEF) ? type[NG_INJ_DEF] : null;
|
|
125
127
|
}
|
|
126
|
-
var NG_PROV_DEF = getClosureSafeProperty({
|
|
127
|
-
|
|
128
|
-
});
|
|
129
|
-
var NG_INJ_DEF = getClosureSafeProperty({
|
|
130
|
-
ɵinj: getClosureSafeProperty
|
|
131
|
-
});
|
|
128
|
+
var NG_PROV_DEF = getClosureSafeProperty({ ɵprov: getClosureSafeProperty });
|
|
129
|
+
var NG_INJ_DEF = getClosureSafeProperty({ ɵinj: getClosureSafeProperty });
|
|
132
130
|
|
|
133
131
|
// src/import/di/injection_token.ts
|
|
134
132
|
var InjectionToken = class {
|
|
@@ -167,29 +165,18 @@ var InjectionToken = class {
|
|
|
167
165
|
// src/import/di/initializer_token.ts
|
|
168
166
|
var ENVIRONMENT_INITIALIZER = new InjectionToken("");
|
|
169
167
|
|
|
170
|
-
// src/import/render3/errors_di.ts
|
|
171
|
-
function throwProviderNotFoundError(token, injectorName) {
|
|
172
|
-
const errorMessage = null;
|
|
173
|
-
throw new RuntimeError(-201 /* PROVIDER_NOT_FOUND */, errorMessage);
|
|
174
|
-
}
|
|
175
|
-
|
|
176
168
|
// src/import/di/interface/injector.ts
|
|
177
169
|
var DecoratorFlags = /* @__PURE__ */ ((DecoratorFlags2) => {
|
|
178
170
|
DecoratorFlags2[DecoratorFlags2["Inject"] = -1] = "Inject";
|
|
179
171
|
return DecoratorFlags2;
|
|
180
172
|
})(DecoratorFlags || {});
|
|
181
|
-
var InjectFlags = /* @__PURE__ */ ((InjectFlags2) => {
|
|
182
|
-
InjectFlags2[InjectFlags2["Default"] = 0] = "Default";
|
|
183
|
-
InjectFlags2[InjectFlags2["Self"] = 2] = "Self";
|
|
184
|
-
InjectFlags2[InjectFlags2["SkipSelf"] = 4] = "SkipSelf";
|
|
185
|
-
InjectFlags2[InjectFlags2["Optional"] = 8] = "Optional";
|
|
186
|
-
return InjectFlags2;
|
|
187
|
-
})(InjectFlags || {});
|
|
188
173
|
var InternalInjectFlags = /* @__PURE__ */ ((InternalInjectFlags2) => {
|
|
189
174
|
InternalInjectFlags2[InternalInjectFlags2["Default"] = 0] = "Default";
|
|
175
|
+
InternalInjectFlags2[InternalInjectFlags2["Host"] = 1] = "Host";
|
|
190
176
|
InternalInjectFlags2[InternalInjectFlags2["Self"] = 2] = "Self";
|
|
191
177
|
InternalInjectFlags2[InternalInjectFlags2["SkipSelf"] = 4] = "SkipSelf";
|
|
192
178
|
InternalInjectFlags2[InternalInjectFlags2["Optional"] = 8] = "Optional";
|
|
179
|
+
InternalInjectFlags2[InternalInjectFlags2["ForPipe"] = 16] = "ForPipe";
|
|
193
180
|
return InternalInjectFlags2;
|
|
194
181
|
})(InternalInjectFlags || {});
|
|
195
182
|
|
|
@@ -213,15 +200,7 @@ function injectRootLimpMode(token, notFoundValue, flags) {
|
|
|
213
200
|
throwProviderNotFoundError(token, "Injector");
|
|
214
201
|
}
|
|
215
202
|
|
|
216
|
-
// src/
|
|
217
|
-
var _THROW_IF_NOT_FOUND = {};
|
|
218
|
-
var THROW_IF_NOT_FOUND = _THROW_IF_NOT_FOUND;
|
|
219
|
-
var DI_DECORATOR_FLAG = "__NG_DI_FLAG__";
|
|
220
|
-
var NG_TEMP_TOKEN_PATH = "ngTempTokenPath";
|
|
221
|
-
var NG_TOKEN_PATH = "ngTokenPath";
|
|
222
|
-
var NEW_LINE = /\n/gm;
|
|
223
|
-
var NO_NEW_LINE = "ɵ";
|
|
224
|
-
var SOURCE = "__source";
|
|
203
|
+
// src/primitives/di/src/injector.ts
|
|
225
204
|
var _currentInjector = void 0;
|
|
226
205
|
function getCurrentInjector() {
|
|
227
206
|
return _currentInjector;
|
|
@@ -231,31 +210,75 @@ function setCurrentInjector(injector) {
|
|
|
231
210
|
_currentInjector = injector;
|
|
232
211
|
return former;
|
|
233
212
|
}
|
|
213
|
+
|
|
214
|
+
// src/primitives/di/src/not_found.ts
|
|
215
|
+
var NOT_FOUND = Symbol("NotFound");
|
|
216
|
+
var NotFoundError = class extends Error {
|
|
217
|
+
name = "ɵNotFound";
|
|
218
|
+
constructor(message) {
|
|
219
|
+
super(message);
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
function isNotFound(e) {
|
|
223
|
+
return e === NOT_FOUND || e?.name === "ɵNotFound";
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// src/import/di/injector_compatibility.ts
|
|
227
|
+
var _THROW_IF_NOT_FOUND = {};
|
|
228
|
+
var THROW_IF_NOT_FOUND = _THROW_IF_NOT_FOUND;
|
|
229
|
+
var DI_DECORATOR_FLAG = "__NG_DI_FLAG__";
|
|
230
|
+
var RetrievingInjector = class {
|
|
231
|
+
constructor(injector) {
|
|
232
|
+
this.injector = injector;
|
|
233
|
+
}
|
|
234
|
+
retrieve(token, options) {
|
|
235
|
+
const flags = convertToBitFlags(options) || 0 /* Default */;
|
|
236
|
+
try {
|
|
237
|
+
return this.injector.get(
|
|
238
|
+
token,
|
|
239
|
+
// When a dependency is requested with an optional flag, DI returns null as the default value.
|
|
240
|
+
flags & 8 /* Optional */ ? null : THROW_IF_NOT_FOUND,
|
|
241
|
+
flags
|
|
242
|
+
);
|
|
243
|
+
} catch (e) {
|
|
244
|
+
if (isNotFound(e)) {
|
|
245
|
+
return e;
|
|
246
|
+
}
|
|
247
|
+
throw e;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
var NG_TEMP_TOKEN_PATH = "ngTempTokenPath";
|
|
252
|
+
var NG_TOKEN_PATH = "ngTokenPath";
|
|
253
|
+
var NEW_LINE = /\n/gm;
|
|
254
|
+
var NO_NEW_LINE = "ɵ";
|
|
255
|
+
var SOURCE = "__source";
|
|
234
256
|
function injectInjectorOnly(token, flags = 0 /* Default */) {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
257
|
+
const currentInjector = getCurrentInjector();
|
|
258
|
+
if (currentInjector === void 0) {
|
|
259
|
+
throw new RuntimeError(-203 /* MISSING_INJECTION_CONTEXT */, void 0);
|
|
260
|
+
} else if (currentInjector === null) {
|
|
238
261
|
return injectRootLimpMode(token, void 0, flags);
|
|
239
262
|
} else {
|
|
240
|
-
const
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
263
|
+
const options = convertToInjectOptions(flags);
|
|
264
|
+
const value = currentInjector.retrieve(token, options);
|
|
265
|
+
if (isNotFound(value)) {
|
|
266
|
+
if (options.optional) {
|
|
267
|
+
return null;
|
|
268
|
+
}
|
|
269
|
+
throw value;
|
|
270
|
+
}
|
|
245
271
|
return value;
|
|
246
272
|
}
|
|
247
273
|
}
|
|
248
274
|
function ɵɵinject(token, flags = 0 /* Default */) {
|
|
249
|
-
return (getInjectImplementation() || injectInjectorOnly)(
|
|
250
|
-
resolveForwardRef(token),
|
|
251
|
-
flags
|
|
252
|
-
);
|
|
275
|
+
return (getInjectImplementation() || injectInjectorOnly)(resolveForwardRef(token), flags);
|
|
253
276
|
}
|
|
254
277
|
function ɵɵinvalidFactoryDep(index) {
|
|
255
|
-
throw new RuntimeError(202 /* INVALID_FACTORY_DEPENDENCY */,
|
|
278
|
+
throw new RuntimeError(202 /* INVALID_FACTORY_DEPENDENCY */, void 0);
|
|
256
279
|
}
|
|
257
|
-
function inject(token,
|
|
258
|
-
return ɵɵinject(token, convertToBitFlags(
|
|
280
|
+
function inject(token, options) {
|
|
281
|
+
return ɵɵinject(token, convertToBitFlags(options));
|
|
259
282
|
}
|
|
260
283
|
function convertToBitFlags(flags) {
|
|
261
284
|
if (typeof flags === "undefined" || typeof flags === "number") {
|
|
@@ -264,13 +287,21 @@ function convertToBitFlags(flags) {
|
|
|
264
287
|
return 0 /* Default */ | // comment to force a line break in the formatter
|
|
265
288
|
(flags.optional && 8 /* Optional */) | 0 | (flags.self && 2 /* Self */) | (flags.skipSelf && 4 /* SkipSelf */);
|
|
266
289
|
}
|
|
290
|
+
function convertToInjectOptions(flags) {
|
|
291
|
+
return {
|
|
292
|
+
optional: !!(flags & 8 /* Optional */),
|
|
293
|
+
host: !!(flags & 1 /* Host */),
|
|
294
|
+
self: !!(flags & 2 /* Self */),
|
|
295
|
+
skipSelf: !!(flags & 4 /* SkipSelf */)
|
|
296
|
+
};
|
|
297
|
+
}
|
|
267
298
|
function injectArgs(types) {
|
|
268
299
|
const args = [];
|
|
269
300
|
for (let i = 0; i < types.length; i++) {
|
|
270
301
|
const arg = resolveForwardRef(types[i]);
|
|
271
302
|
if (Array.isArray(arg)) {
|
|
272
303
|
if (arg.length === 0) {
|
|
273
|
-
throw new RuntimeError(900 /* INVALID_DIFFER_INPUT */,
|
|
304
|
+
throw new RuntimeError(900 /* INVALID_DIFFER_INPUT */, void 0);
|
|
274
305
|
}
|
|
275
306
|
let type = void 0;
|
|
276
307
|
let flags = 0 /* Default */;
|
|
@@ -307,12 +338,7 @@ function catchInjectorError(e, token, injectorErrorName, source) {
|
|
|
307
338
|
if (token[SOURCE]) {
|
|
308
339
|
tokenPath.unshift(token[SOURCE]);
|
|
309
340
|
}
|
|
310
|
-
e.message = formatError(
|
|
311
|
-
"\n" + e.message,
|
|
312
|
-
tokenPath,
|
|
313
|
-
injectorErrorName,
|
|
314
|
-
source
|
|
315
|
-
);
|
|
341
|
+
e.message = formatError("\n" + e.message, tokenPath, injectorErrorName, source);
|
|
316
342
|
e[NG_TOKEN_PATH] = tokenPath;
|
|
317
343
|
e[NG_TEMP_TOKEN_PATH] = null;
|
|
318
344
|
throw e;
|
|
@@ -327,17 +353,12 @@ function formatError(text, obj, injectorErrorName, source = null) {
|
|
|
327
353
|
for (const key in obj) {
|
|
328
354
|
if (obj.hasOwnProperty(key)) {
|
|
329
355
|
const value = obj[key];
|
|
330
|
-
parts.push(
|
|
331
|
-
key + ":" + (typeof value === "string" ? JSON.stringify(value) : stringify(value))
|
|
332
|
-
);
|
|
356
|
+
parts.push(key + ":" + (typeof value === "string" ? JSON.stringify(value) : stringify(value)));
|
|
333
357
|
}
|
|
334
358
|
}
|
|
335
359
|
context = `{${parts.join(", ")}}`;
|
|
336
360
|
}
|
|
337
|
-
return `${injectorErrorName}${source ? "(" + source + ")" : ""}[${context}]: ${text.replace(
|
|
338
|
-
NEW_LINE,
|
|
339
|
-
"\n "
|
|
340
|
-
)}`;
|
|
361
|
+
return `${injectorErrorName}${source ? "(" + source + ")" : ""}[${context}]: ${text.replace(NEW_LINE, "\n ")}`;
|
|
341
362
|
}
|
|
342
363
|
|
|
343
364
|
// src/import/di/injector_token.ts
|
|
@@ -356,10 +377,7 @@ var INJECTOR_DEF_TYPES = new InjectionToken("");
|
|
|
356
377
|
var NullInjector = class {
|
|
357
378
|
get(token, notFoundValue = THROW_IF_NOT_FOUND) {
|
|
358
379
|
if (notFoundValue === THROW_IF_NOT_FOUND) {
|
|
359
|
-
const error = new
|
|
360
|
-
`NullInjectorError: No provider for ${stringify(token)}!`
|
|
361
|
-
);
|
|
362
|
-
error.name = "NullInjectorError";
|
|
380
|
+
const error = new NotFoundError(`NullInjectorError: No provider for ${stringify(token)}!`);
|
|
363
381
|
throw error;
|
|
364
382
|
}
|
|
365
383
|
return notFoundValue;
|
|
@@ -367,32 +385,6 @@ var NullInjector = class {
|
|
|
367
385
|
};
|
|
368
386
|
|
|
369
387
|
// src/import/di/provider_collection.ts
|
|
370
|
-
function importProvidersFrom(...sources) {
|
|
371
|
-
return {
|
|
372
|
-
ɵproviders: internalImportProvidersFrom(true, sources),
|
|
373
|
-
ɵfromNgModule: true
|
|
374
|
-
};
|
|
375
|
-
}
|
|
376
|
-
function internalImportProvidersFrom(checkForStandaloneCmp, ...sources) {
|
|
377
|
-
const providersOut = [];
|
|
378
|
-
const dedup = /* @__PURE__ */ new Set();
|
|
379
|
-
let injectorTypesWithProviders;
|
|
380
|
-
const collectProviders = (provider) => {
|
|
381
|
-
providersOut.push(provider);
|
|
382
|
-
};
|
|
383
|
-
if (injectorTypesWithProviders !== void 0) {
|
|
384
|
-
processInjectorTypesWithProviders(
|
|
385
|
-
injectorTypesWithProviders,
|
|
386
|
-
collectProviders
|
|
387
|
-
);
|
|
388
|
-
}
|
|
389
|
-
return providersOut;
|
|
390
|
-
}
|
|
391
|
-
function processInjectorTypesWithProviders(typesWithProviders, visitor) {
|
|
392
|
-
for (let i = 0; i < typesWithProviders.length; i++) {
|
|
393
|
-
const { ngModule, providers } = typesWithProviders[i];
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
388
|
var USE_VALUE = getClosureSafeProperty({
|
|
397
389
|
provide: String,
|
|
398
390
|
useValue: getClosureSafeProperty
|
|
@@ -431,23 +423,16 @@ var R3Injector = class extends EnvironmentInjector {
|
|
|
431
423
|
this.parent = parent;
|
|
432
424
|
this.source = source;
|
|
433
425
|
this.scopes = scopes;
|
|
434
|
-
forEachSingleProvider(
|
|
435
|
-
providers,
|
|
436
|
-
(provider) => this.processProvider(provider)
|
|
437
|
-
);
|
|
426
|
+
forEachSingleProvider(providers, (provider) => this.processProvider(provider));
|
|
438
427
|
this.records.set(INJECTOR, makeRecord(void 0, this));
|
|
439
428
|
if (scopes.has("environment")) {
|
|
440
429
|
this.records.set(EnvironmentInjector, makeRecord(void 0, this));
|
|
441
430
|
}
|
|
442
|
-
const record = this.records.get(
|
|
443
|
-
INJECTOR_SCOPE
|
|
444
|
-
);
|
|
431
|
+
const record = this.records.get(INJECTOR_SCOPE);
|
|
445
432
|
if (record != null && typeof record.value === "string") {
|
|
446
433
|
this.scopes.add(record.value);
|
|
447
434
|
}
|
|
448
|
-
this.injectorDefTypes = new Set(
|
|
449
|
-
this.get(INJECTOR_DEF_TYPES, EMPTY_ARRAY, 2 /* Self */)
|
|
450
|
-
);
|
|
435
|
+
this.injectorDefTypes = new Set(this.get(INJECTOR_DEF_TYPES, EMPTY_ARRAY, { self: true }));
|
|
451
436
|
}
|
|
452
437
|
/**
|
|
453
438
|
* Map of tokens to records which contain the instances of those tokens.
|
|
@@ -468,6 +453,22 @@ var R3Injector = class extends EnvironmentInjector {
|
|
|
468
453
|
}
|
|
469
454
|
_destroyed = false;
|
|
470
455
|
injectorDefTypes;
|
|
456
|
+
retrieve(token, options) {
|
|
457
|
+
const flags = convertToBitFlags(options) || 0 /* Default */;
|
|
458
|
+
try {
|
|
459
|
+
return this.get(
|
|
460
|
+
token,
|
|
461
|
+
// When a dependency is requested with an optional flag, DI returns null as the default value.
|
|
462
|
+
THROW_IF_NOT_FOUND,
|
|
463
|
+
flags
|
|
464
|
+
);
|
|
465
|
+
} catch (e) {
|
|
466
|
+
if (isNotFound(e)) {
|
|
467
|
+
return e;
|
|
468
|
+
}
|
|
469
|
+
throw e;
|
|
470
|
+
}
|
|
471
|
+
}
|
|
471
472
|
/**
|
|
472
473
|
* Destroy the injector and release references to every instance or provider associated with it.
|
|
473
474
|
*
|
|
@@ -510,12 +511,12 @@ var R3Injector = class extends EnvironmentInjector {
|
|
|
510
511
|
setInjectImplementation(previousInjectImplementation);
|
|
511
512
|
}
|
|
512
513
|
}
|
|
513
|
-
get(token, notFoundValue = THROW_IF_NOT_FOUND,
|
|
514
|
+
get(token, notFoundValue = THROW_IF_NOT_FOUND, options) {
|
|
514
515
|
assertNotDestroyed(this);
|
|
515
516
|
if (token.hasOwnProperty(NG_ENV_ID)) {
|
|
516
517
|
return token[NG_ENV_ID](this);
|
|
517
518
|
}
|
|
518
|
-
flags = convertToBitFlags(
|
|
519
|
+
const flags = convertToBitFlags(options);
|
|
519
520
|
if (false) {
|
|
520
521
|
}
|
|
521
522
|
const previousInjector = setCurrentInjector(this);
|
|
@@ -528,10 +529,7 @@ var R3Injector = class extends EnvironmentInjector {
|
|
|
528
529
|
if (def && this.injectableDefInScope(def)) {
|
|
529
530
|
if (false) {
|
|
530
531
|
}
|
|
531
|
-
record = makeRecord(
|
|
532
|
-
injectableDefOrInjectorDefFactory(token),
|
|
533
|
-
NOT_YET
|
|
534
|
-
);
|
|
532
|
+
record = makeRecord(injectableDefOrInjectorDefFactory(token), NOT_YET);
|
|
535
533
|
} else {
|
|
536
534
|
record = null;
|
|
537
535
|
}
|
|
@@ -545,7 +543,7 @@ var R3Injector = class extends EnvironmentInjector {
|
|
|
545
543
|
notFoundValue = flags & 8 /* Optional */ && notFoundValue === THROW_IF_NOT_FOUND ? null : notFoundValue;
|
|
546
544
|
return nextInjector.get(token, notFoundValue);
|
|
547
545
|
} catch (e) {
|
|
548
|
-
if (e
|
|
546
|
+
if (isNotFound(e)) {
|
|
549
547
|
const path = e[NG_TEMP_TOKEN_PATH] = e[NG_TEMP_TOKEN_PATH] || [];
|
|
550
548
|
path.unshift(stringify(token));
|
|
551
549
|
if (previousInjector) {
|
|
@@ -568,11 +566,7 @@ var R3Injector = class extends EnvironmentInjector {
|
|
|
568
566
|
if (false) {
|
|
569
567
|
}
|
|
570
568
|
try {
|
|
571
|
-
const initializers = this.get(
|
|
572
|
-
ENVIRONMENT_INITIALIZER,
|
|
573
|
-
EMPTY_ARRAY,
|
|
574
|
-
2 /* Self */
|
|
575
|
-
);
|
|
569
|
+
const initializers = this.get(ENVIRONMENT_INITIALIZER, EMPTY_ARRAY, { self: true });
|
|
576
570
|
if (false) {
|
|
577
571
|
}
|
|
578
572
|
for (const initializer of initializers) {
|
|
@@ -620,7 +614,8 @@ var R3Injector = class extends EnvironmentInjector {
|
|
|
620
614
|
}
|
|
621
615
|
hydrate(token, record) {
|
|
622
616
|
try {
|
|
623
|
-
if (
|
|
617
|
+
if (record.value === CIRCULAR) {
|
|
618
|
+
throwCyclicDependencyError(stringify(token));
|
|
624
619
|
} else if (record.value === NOT_YET) {
|
|
625
620
|
record.value = CIRCULAR;
|
|
626
621
|
if (false) {
|
|
@@ -660,17 +655,17 @@ function injectableDefOrInjectorDefFactory(token) {
|
|
|
660
655
|
return factory;
|
|
661
656
|
}
|
|
662
657
|
if (token instanceof InjectionToken) {
|
|
663
|
-
throw new RuntimeError(204 /* INVALID_INJECTION_TOKEN */,
|
|
658
|
+
throw new RuntimeError(204 /* INVALID_INJECTION_TOKEN */, void 0);
|
|
664
659
|
}
|
|
665
660
|
if (token instanceof Function) {
|
|
666
661
|
return getUndecoratedInjectableFactory(token);
|
|
667
662
|
}
|
|
668
|
-
throw new RuntimeError(204 /* INVALID_INJECTION_TOKEN */,
|
|
663
|
+
throw new RuntimeError(204 /* INVALID_INJECTION_TOKEN */, void 0);
|
|
669
664
|
}
|
|
670
665
|
function getUndecoratedInjectableFactory(token) {
|
|
671
666
|
const paramLength = token.length;
|
|
672
667
|
if (paramLength > 0) {
|
|
673
|
-
throw new RuntimeError(204 /* INVALID_INJECTION_TOKEN */,
|
|
668
|
+
throw new RuntimeError(204 /* INVALID_INJECTION_TOKEN */, void 0);
|
|
674
669
|
}
|
|
675
670
|
const inheritedInjectableDef = getInheritedInjectableDef(token);
|
|
676
671
|
if (inheritedInjectableDef !== null) {
|
|
@@ -702,9 +697,7 @@ function providerToFactory(provider, ngModuleType, providers) {
|
|
|
702
697
|
} else if (isExistingProvider(provider)) {
|
|
703
698
|
factory = () => ɵɵinject(resolveForwardRef(provider.useExisting));
|
|
704
699
|
} else {
|
|
705
|
-
const classRef = resolveForwardRef(
|
|
706
|
-
provider && (provider.useClass || provider.provide)
|
|
707
|
-
);
|
|
700
|
+
const classRef = resolveForwardRef(provider && (provider.useClass || provider.provide));
|
|
708
701
|
if (false) {
|
|
709
702
|
}
|
|
710
703
|
if (hasDeps(provider)) {
|
|
@@ -718,7 +711,7 @@ function providerToFactory(provider, ngModuleType, providers) {
|
|
|
718
711
|
}
|
|
719
712
|
function assertNotDestroyed(injector) {
|
|
720
713
|
if (injector.destroyed) {
|
|
721
|
-
throw new RuntimeError(205 /* INJECTOR_ALREADY_DESTROYED */,
|
|
714
|
+
throw new RuntimeError(205 /* INJECTOR_ALREADY_DESTROYED */, void 0);
|
|
722
715
|
}
|
|
723
716
|
}
|
|
724
717
|
function makeRecord(factory, value, multi = false) {
|
|
@@ -735,7 +728,7 @@ function hasOnDestroy(value) {
|
|
|
735
728
|
return value !== null && typeof value === "object" && typeof value.ngOnDestroy === "function";
|
|
736
729
|
}
|
|
737
730
|
function couldBeInjectableType(value) {
|
|
738
|
-
return typeof value === "function" || typeof value === "object" && value
|
|
731
|
+
return typeof value === "function" || typeof value === "object" && value.ngMetadataName === "InjectionToken";
|
|
739
732
|
}
|
|
740
733
|
function forEachSingleProvider(providers, fn) {
|
|
741
734
|
for (const provider of providers) {
|
|
@@ -788,10 +781,7 @@ var Inject = attachInjectFlag(
|
|
|
788
781
|
var Optional = (
|
|
789
782
|
// Disable tslint because `InternalInjectFlags` is a const enum which gets inlined.
|
|
790
783
|
// tslint:disable-next-line: no-toplevel-property-access
|
|
791
|
-
attachInjectFlag(
|
|
792
|
-
makeParamDecorator("Optional"),
|
|
793
|
-
8 /* Optional */
|
|
794
|
-
)
|
|
784
|
+
attachInjectFlag(makeParamDecorator("Optional"), 8 /* Optional */)
|
|
795
785
|
);
|
|
796
786
|
var Self = (
|
|
797
787
|
// Disable tslint because `InternalInjectFlags` is a const enum which gets inlined.
|
|
@@ -801,35 +791,19 @@ var Self = (
|
|
|
801
791
|
var SkipSelf = (
|
|
802
792
|
// Disable tslint because `InternalInjectFlags` is a const enum which gets inlined.
|
|
803
793
|
// tslint:disable-next-line: no-toplevel-property-access
|
|
804
|
-
attachInjectFlag(
|
|
805
|
-
makeParamDecorator("SkipSelf"),
|
|
806
|
-
4 /* SkipSelf */
|
|
807
|
-
)
|
|
794
|
+
attachInjectFlag(makeParamDecorator("SkipSelf"), 4 /* SkipSelf */)
|
|
808
795
|
);
|
|
809
796
|
|
|
810
797
|
// src/import/di/create_injector.ts
|
|
811
798
|
function createInjector(defType, parent = null, additionalProviders = null, name) {
|
|
812
|
-
const injector = createInjectorWithoutInjectorInstances(
|
|
813
|
-
defType,
|
|
814
|
-
parent,
|
|
815
|
-
additionalProviders,
|
|
816
|
-
name
|
|
817
|
-
);
|
|
799
|
+
const injector = createInjectorWithoutInjectorInstances(defType, parent, additionalProviders, name);
|
|
818
800
|
injector.resolveInjectorInitializers();
|
|
819
801
|
return injector;
|
|
820
802
|
}
|
|
821
803
|
function createInjectorWithoutInjectorInstances(defType, parent = null, additionalProviders = null, name, scopes = /* @__PURE__ */ new Set()) {
|
|
822
|
-
const providers = [
|
|
823
|
-
additionalProviders || EMPTY_ARRAY,
|
|
824
|
-
importProvidersFrom(defType)
|
|
825
|
-
];
|
|
804
|
+
const providers = [additionalProviders || EMPTY_ARRAY];
|
|
826
805
|
name = name || (typeof defType === "object" ? void 0 : stringify(defType));
|
|
827
|
-
return new R3Injector(
|
|
828
|
-
providers,
|
|
829
|
-
parent || getNullInjector(),
|
|
830
|
-
name || null,
|
|
831
|
-
scopes
|
|
832
|
-
);
|
|
806
|
+
return new R3Injector(providers, parent || getNullInjector(), name || null, scopes);
|
|
833
807
|
}
|
|
834
808
|
|
|
835
809
|
// src/import/di/injector.ts
|
|
@@ -875,6 +849,7 @@ function defaultEquals(a, b) {
|
|
|
875
849
|
var activeConsumer = null;
|
|
876
850
|
var inNotificationPhase = false;
|
|
877
851
|
var epoch = 1;
|
|
852
|
+
var postProducerCreatedFn = null;
|
|
878
853
|
var SIGNAL = /* @__PURE__ */ Symbol("SIGNAL");
|
|
879
854
|
function setActiveConsumer(consumer) {
|
|
880
855
|
const prev = activeConsumer;
|
|
@@ -884,9 +859,6 @@ function setActiveConsumer(consumer) {
|
|
|
884
859
|
function getActiveConsumer() {
|
|
885
860
|
return activeConsumer;
|
|
886
861
|
}
|
|
887
|
-
function isInNotificationPhase() {
|
|
888
|
-
return inNotificationPhase;
|
|
889
|
-
}
|
|
890
862
|
var REACTIVE_NODE = {
|
|
891
863
|
version: 0,
|
|
892
864
|
lastCleanEpoch: 0,
|
|
@@ -910,9 +882,7 @@ var REACTIVE_NODE = {
|
|
|
910
882
|
};
|
|
911
883
|
function producerAccessed(node) {
|
|
912
884
|
if (inNotificationPhase) {
|
|
913
|
-
throw new Error(
|
|
914
|
-
false ? `Assertion error: signal read during notification phase` : ""
|
|
915
|
-
);
|
|
885
|
+
throw new Error(false ? `Assertion error: signal read during notification phase` : "");
|
|
916
886
|
}
|
|
917
887
|
if (activeConsumer === null) {
|
|
918
888
|
return;
|
|
@@ -923,10 +893,7 @@ function producerAccessed(node) {
|
|
|
923
893
|
if (idx < activeConsumer.producerNode.length && activeConsumer.producerNode[idx] !== node) {
|
|
924
894
|
if (consumerIsLive(activeConsumer)) {
|
|
925
895
|
const staleProducer = activeConsumer.producerNode[idx];
|
|
926
|
-
producerRemoveLiveConsumerAtIndex(
|
|
927
|
-
staleProducer,
|
|
928
|
-
activeConsumer.producerIndexOfThis[idx]
|
|
929
|
-
);
|
|
896
|
+
producerRemoveLiveConsumerAtIndex(staleProducer, activeConsumer.producerIndexOfThis[idx]);
|
|
930
897
|
}
|
|
931
898
|
}
|
|
932
899
|
if (activeConsumer.producerNode[idx] !== node) {
|
|
@@ -991,10 +958,7 @@ function consumerAfterComputation(node, prevConsumer) {
|
|
|
991
958
|
}
|
|
992
959
|
if (consumerIsLive(node)) {
|
|
993
960
|
for (let i = node.nextProducerIndex; i < node.producerNode.length; i++) {
|
|
994
|
-
producerRemoveLiveConsumerAtIndex(
|
|
995
|
-
node.producerNode[i],
|
|
996
|
-
node.producerIndexOfThis[i]
|
|
997
|
-
);
|
|
961
|
+
producerRemoveLiveConsumerAtIndex(node.producerNode[i], node.producerIndexOfThis[i]);
|
|
998
962
|
}
|
|
999
963
|
}
|
|
1000
964
|
while (node.producerNode.length > node.nextProducerIndex) {
|
|
@@ -1022,10 +986,7 @@ function consumerDestroy(node) {
|
|
|
1022
986
|
assertConsumerNode(node);
|
|
1023
987
|
if (consumerIsLive(node)) {
|
|
1024
988
|
for (let i = 0; i < node.producerNode.length; i++) {
|
|
1025
|
-
producerRemoveLiveConsumerAtIndex(
|
|
1026
|
-
node.producerNode[i],
|
|
1027
|
-
node.producerIndexOfThis[i]
|
|
1028
|
-
);
|
|
989
|
+
producerRemoveLiveConsumerAtIndex(node.producerNode[i], node.producerIndexOfThis[i]);
|
|
1029
990
|
}
|
|
1030
991
|
}
|
|
1031
992
|
node.producerNode.length = node.producerLastReadVersion.length = node.producerIndexOfThis.length = 0;
|
|
@@ -1037,11 +998,7 @@ function producerAddLiveConsumer(node, consumer, indexOfThis) {
|
|
|
1037
998
|
assertProducerNode(node);
|
|
1038
999
|
if (node.liveConsumerNode.length === 0 && isConsumerNode(node)) {
|
|
1039
1000
|
for (let i = 0; i < node.producerNode.length; i++) {
|
|
1040
|
-
node.producerIndexOfThis[i] = producerAddLiveConsumer(
|
|
1041
|
-
node.producerNode[i],
|
|
1042
|
-
node,
|
|
1043
|
-
i
|
|
1044
|
-
);
|
|
1001
|
+
node.producerIndexOfThis[i] = producerAddLiveConsumer(node.producerNode[i], node, i);
|
|
1045
1002
|
}
|
|
1046
1003
|
}
|
|
1047
1004
|
node.liveConsumerIndexOfThis.push(indexOfThis);
|
|
@@ -1050,16 +1007,11 @@ function producerAddLiveConsumer(node, consumer, indexOfThis) {
|
|
|
1050
1007
|
function producerRemoveLiveConsumerAtIndex(node, idx) {
|
|
1051
1008
|
assertProducerNode(node);
|
|
1052
1009
|
if (false) {
|
|
1053
|
-
throw new Error(
|
|
1054
|
-
`Assertion error: active consumer index ${idx} is out of bounds of ${node.liveConsumerNode.length} consumers)`
|
|
1055
|
-
);
|
|
1010
|
+
throw new Error(`Assertion error: active consumer index ${idx} is out of bounds of ${node.liveConsumerNode.length} consumers)`);
|
|
1056
1011
|
}
|
|
1057
1012
|
if (node.liveConsumerNode.length === 1 && isConsumerNode(node)) {
|
|
1058
1013
|
for (let i = 0; i < node.producerNode.length; i++) {
|
|
1059
|
-
producerRemoveLiveConsumerAtIndex(
|
|
1060
|
-
node.producerNode[i],
|
|
1061
|
-
node.producerIndexOfThis[i]
|
|
1062
|
-
);
|
|
1014
|
+
producerRemoveLiveConsumerAtIndex(node.producerNode[i], node.producerIndexOfThis[i]);
|
|
1063
1015
|
}
|
|
1064
1016
|
}
|
|
1065
1017
|
const lastIdx = node.liveConsumerNode.length - 1;
|
|
@@ -1089,11 +1041,17 @@ function assertProducerNode(node) {
|
|
|
1089
1041
|
function isConsumerNode(node) {
|
|
1090
1042
|
return node.producerNode !== void 0;
|
|
1091
1043
|
}
|
|
1044
|
+
function runPostProducerCreatedFn(node) {
|
|
1045
|
+
postProducerCreatedFn?.(node);
|
|
1046
|
+
}
|
|
1092
1047
|
|
|
1093
1048
|
// src/primitives/signals/src/computed.ts
|
|
1094
|
-
function createComputed(computation) {
|
|
1049
|
+
function createComputed(computation, equal) {
|
|
1095
1050
|
const node = Object.create(COMPUTED_NODE);
|
|
1096
1051
|
node.computation = computation;
|
|
1052
|
+
if (equal !== void 0) {
|
|
1053
|
+
node.equal = equal;
|
|
1054
|
+
}
|
|
1097
1055
|
const computed2 = () => {
|
|
1098
1056
|
producerUpdateValueVersion(node);
|
|
1099
1057
|
producerAccessed(node);
|
|
@@ -1103,6 +1061,11 @@ function createComputed(computation) {
|
|
|
1103
1061
|
return node.value;
|
|
1104
1062
|
};
|
|
1105
1063
|
computed2[SIGNAL] = node;
|
|
1064
|
+
if (false) {
|
|
1065
|
+
const debugName = node.debugName ? " (" + node.debugName + ")" : "";
|
|
1066
|
+
computed2.toString = () => `[Computed${debugName}: ${node.value}]`;
|
|
1067
|
+
}
|
|
1068
|
+
runPostProducerCreatedFn(node);
|
|
1106
1069
|
return computed2;
|
|
1107
1070
|
}
|
|
1108
1071
|
var UNSET = /* @__PURE__ */ Symbol("UNSET");
|
|
@@ -1120,7 +1083,7 @@ var COMPUTED_NODE = /* @__PURE__ */ (() => ({
|
|
|
1120
1083
|
},
|
|
1121
1084
|
producerRecomputeValue(node) {
|
|
1122
1085
|
if (node.value === COMPUTING) {
|
|
1123
|
-
throw new Error("Detected cycle in computations.");
|
|
1086
|
+
throw new Error(false ? "Detected cycle in computations." : "");
|
|
1124
1087
|
}
|
|
1125
1088
|
const oldValue = node.value;
|
|
1126
1089
|
node.value = COMPUTING;
|
|
@@ -1157,15 +1120,26 @@ function throwInvalidWriteToSignalError(node) {
|
|
|
1157
1120
|
|
|
1158
1121
|
// src/primitives/signals/src/signal.ts
|
|
1159
1122
|
var postSignalSetFn = null;
|
|
1160
|
-
function createSignal(initialValue) {
|
|
1123
|
+
function createSignal(initialValue, equal) {
|
|
1161
1124
|
const node = Object.create(SIGNAL_NODE);
|
|
1162
1125
|
node.value = initialValue;
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1126
|
+
if (equal !== void 0) {
|
|
1127
|
+
node.equal = equal;
|
|
1128
|
+
}
|
|
1129
|
+
const getter = () => signalGetFn(node);
|
|
1167
1130
|
getter[SIGNAL] = node;
|
|
1168
|
-
|
|
1131
|
+
if (false) {
|
|
1132
|
+
const debugName = node.debugName ? " (" + node.debugName + ")" : "";
|
|
1133
|
+
getter.toString = () => `[Signal${debugName}: ${node.value}]`;
|
|
1134
|
+
}
|
|
1135
|
+
runPostProducerCreatedFn(node);
|
|
1136
|
+
const set = (newValue) => signalSetFn(node, newValue);
|
|
1137
|
+
const update = (updateFn) => signalUpdateFn(node, updateFn);
|
|
1138
|
+
return [getter, set, update];
|
|
1139
|
+
}
|
|
1140
|
+
function signalGetFn(node) {
|
|
1141
|
+
producerAccessed(node);
|
|
1142
|
+
return node.value;
|
|
1169
1143
|
}
|
|
1170
1144
|
function signalSetFn(node, newValue) {
|
|
1171
1145
|
if (!producerUpdatesAllowed()) {
|
|
@@ -1192,7 +1166,7 @@ function signalValueChanged(node) {
|
|
|
1192
1166
|
node.version++;
|
|
1193
1167
|
producerIncrementEpoch();
|
|
1194
1168
|
producerNotifyConsumers(node);
|
|
1195
|
-
postSignalSetFn?.();
|
|
1169
|
+
postSignalSetFn?.(node);
|
|
1196
1170
|
}
|
|
1197
1171
|
|
|
1198
1172
|
// src/primitives/signals/src/linked_signal.ts
|
|
@@ -1213,6 +1187,11 @@ function createLinkedSignal(sourceFn, computationFn, equalityFn) {
|
|
|
1213
1187
|
};
|
|
1214
1188
|
const getter = linkedSignalGetter;
|
|
1215
1189
|
getter[SIGNAL] = node;
|
|
1190
|
+
if (false) {
|
|
1191
|
+
const debugName = node.debugName ? " (" + node.debugName + ")" : "";
|
|
1192
|
+
getter.toString = () => `[LinkedSignal${debugName}: ${node.value}]`;
|
|
1193
|
+
}
|
|
1194
|
+
runPostProducerCreatedFn(node);
|
|
1216
1195
|
return getter;
|
|
1217
1196
|
}
|
|
1218
1197
|
function linkedSignalSetFn(node, newValue) {
|
|
@@ -1231,12 +1210,13 @@ var LINKED_SIGNAL_NODE = /* @__PURE__ */ (() => ({
|
|
|
1231
1210
|
dirty: true,
|
|
1232
1211
|
error: null,
|
|
1233
1212
|
equal: defaultEquals,
|
|
1213
|
+
kind: "linkedSignal",
|
|
1234
1214
|
producerMustRecompute(node) {
|
|
1235
1215
|
return node.value === UNSET || node.value === COMPUTING;
|
|
1236
1216
|
},
|
|
1237
1217
|
producerRecomputeValue(node) {
|
|
1238
1218
|
if (node.value === COMPUTING) {
|
|
1239
|
-
throw new Error("Detected cycle in computations.");
|
|
1219
|
+
throw new Error(false ? "Detected cycle in computations." : "");
|
|
1240
1220
|
}
|
|
1241
1221
|
const oldValue = node.value;
|
|
1242
1222
|
node.value = COMPUTING;
|
|
@@ -1265,75 +1245,15 @@ var LINKED_SIGNAL_NODE = /* @__PURE__ */ (() => ({
|
|
|
1265
1245
|
}
|
|
1266
1246
|
}))();
|
|
1267
1247
|
|
|
1268
|
-
// src/primitives/signals/src/
|
|
1269
|
-
function
|
|
1270
|
-
const
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
}
|
|
1274
|
-
|
|
1275
|
-
node.schedule = schedule;
|
|
1276
|
-
const registerOnCleanup = (cleanupFn) => {
|
|
1277
|
-
node.cleanupFn = cleanupFn;
|
|
1278
|
-
};
|
|
1279
|
-
function isWatchNodeDestroyed(node2) {
|
|
1280
|
-
return node2.fn === null && node2.schedule === null;
|
|
1281
|
-
}
|
|
1282
|
-
function destroyWatchNode(node2) {
|
|
1283
|
-
if (!isWatchNodeDestroyed(node2)) {
|
|
1284
|
-
consumerDestroy(node2);
|
|
1285
|
-
node2.cleanupFn();
|
|
1286
|
-
node2.fn = null;
|
|
1287
|
-
node2.schedule = null;
|
|
1288
|
-
node2.cleanupFn = NOOP_CLEANUP_FN;
|
|
1289
|
-
}
|
|
1248
|
+
// src/primitives/signals/src/untracked.ts
|
|
1249
|
+
function untracked(nonReactiveReadsFn) {
|
|
1250
|
+
const prevConsumer = setActiveConsumer(null);
|
|
1251
|
+
try {
|
|
1252
|
+
return nonReactiveReadsFn();
|
|
1253
|
+
} finally {
|
|
1254
|
+
setActiveConsumer(prevConsumer);
|
|
1290
1255
|
}
|
|
1291
|
-
const run = () => {
|
|
1292
|
-
if (node.fn === null) {
|
|
1293
|
-
return;
|
|
1294
|
-
}
|
|
1295
|
-
if (isInNotificationPhase()) {
|
|
1296
|
-
throw new Error(
|
|
1297
|
-
`Schedulers cannot synchronously execute watches while scheduling.`
|
|
1298
|
-
);
|
|
1299
|
-
}
|
|
1300
|
-
node.dirty = false;
|
|
1301
|
-
if (node.hasRun && !consumerPollProducersForChange(node)) {
|
|
1302
|
-
return;
|
|
1303
|
-
}
|
|
1304
|
-
node.hasRun = true;
|
|
1305
|
-
const prevConsumer = consumerBeforeComputation(node);
|
|
1306
|
-
try {
|
|
1307
|
-
node.cleanupFn();
|
|
1308
|
-
node.cleanupFn = NOOP_CLEANUP_FN;
|
|
1309
|
-
node.fn(registerOnCleanup);
|
|
1310
|
-
} finally {
|
|
1311
|
-
consumerAfterComputation(node, prevConsumer);
|
|
1312
|
-
}
|
|
1313
|
-
};
|
|
1314
|
-
node.ref = {
|
|
1315
|
-
notify: () => consumerMarkDirty(node),
|
|
1316
|
-
run,
|
|
1317
|
-
cleanup: () => node.cleanupFn(),
|
|
1318
|
-
destroy: () => destroyWatchNode(node),
|
|
1319
|
-
[SIGNAL]: node
|
|
1320
|
-
};
|
|
1321
|
-
return node.ref;
|
|
1322
1256
|
}
|
|
1323
|
-
var NOOP_CLEANUP_FN = () => {
|
|
1324
|
-
};
|
|
1325
|
-
var WATCH_NODE = /* @__PURE__ */ (() => ({
|
|
1326
|
-
...REACTIVE_NODE,
|
|
1327
|
-
consumerIsAlwaysLive: true,
|
|
1328
|
-
consumerAllowSignalWrites: false,
|
|
1329
|
-
consumerMarkedDirty: (node) => {
|
|
1330
|
-
if (node.schedule !== null) {
|
|
1331
|
-
node.schedule(node.ref);
|
|
1332
|
-
}
|
|
1333
|
-
},
|
|
1334
|
-
hasRun: false,
|
|
1335
|
-
cleanupFn: NOOP_CLEANUP_FN
|
|
1336
|
-
}))();
|
|
1337
1257
|
|
|
1338
1258
|
// src/import/render3/reactivity/api.ts
|
|
1339
1259
|
function isSignal(value) {
|
|
@@ -1342,10 +1262,7 @@ function isSignal(value) {
|
|
|
1342
1262
|
|
|
1343
1263
|
// src/import/render3/reactivity/computed.ts
|
|
1344
1264
|
function computed(computation, options) {
|
|
1345
|
-
const getter = createComputed(computation);
|
|
1346
|
-
if (options?.equal) {
|
|
1347
|
-
getter[SIGNAL].equal = options.equal;
|
|
1348
|
-
}
|
|
1265
|
+
const getter = createComputed(computation, options?.equal);
|
|
1349
1266
|
if (false) {
|
|
1350
1267
|
}
|
|
1351
1268
|
return getter;
|
|
@@ -1356,16 +1273,12 @@ function ɵunwrapWritableSignal(value) {
|
|
|
1356
1273
|
return null;
|
|
1357
1274
|
}
|
|
1358
1275
|
function signal(initialValue, options) {
|
|
1359
|
-
const
|
|
1276
|
+
const [get, set, update] = createSignal(initialValue, options?.equal);
|
|
1277
|
+
const signalFn = get;
|
|
1360
1278
|
const node = signalFn[SIGNAL];
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
signalFn.set = (newValue) => signalSetFn(node, newValue);
|
|
1365
|
-
signalFn.update = (updateFn) => signalUpdateFn(node, updateFn);
|
|
1366
|
-
signalFn.asReadonly = signalAsReadonlyFn.bind(
|
|
1367
|
-
signalFn
|
|
1368
|
-
);
|
|
1279
|
+
signalFn.set = set;
|
|
1280
|
+
signalFn.update = update;
|
|
1281
|
+
signalFn.asReadonly = signalAsReadonlyFn.bind(signalFn);
|
|
1369
1282
|
if (false) {
|
|
1370
1283
|
}
|
|
1371
1284
|
return signalFn;
|
|
@@ -1384,18 +1297,10 @@ function signalAsReadonlyFn() {
|
|
|
1384
1297
|
var identityFn = (v) => v;
|
|
1385
1298
|
function linkedSignal(optionsOrComputation, options) {
|
|
1386
1299
|
if (typeof optionsOrComputation === "function") {
|
|
1387
|
-
const getter = createLinkedSignal(
|
|
1388
|
-
optionsOrComputation,
|
|
1389
|
-
identityFn,
|
|
1390
|
-
options?.equal
|
|
1391
|
-
);
|
|
1300
|
+
const getter = createLinkedSignal(optionsOrComputation, identityFn, options?.equal);
|
|
1392
1301
|
return upgradeLinkedSignalGetter(getter);
|
|
1393
1302
|
} else {
|
|
1394
|
-
const getter = createLinkedSignal(
|
|
1395
|
-
optionsOrComputation.source,
|
|
1396
|
-
optionsOrComputation.computation,
|
|
1397
|
-
optionsOrComputation.equal
|
|
1398
|
-
);
|
|
1303
|
+
const getter = createLinkedSignal(optionsOrComputation.source, optionsOrComputation.computation, optionsOrComputation.equal);
|
|
1399
1304
|
return upgradeLinkedSignalGetter(getter);
|
|
1400
1305
|
}
|
|
1401
1306
|
}
|
|
@@ -1406,39 +1311,19 @@ function upgradeLinkedSignalGetter(getter) {
|
|
|
1406
1311
|
const upgradedGetter = getter;
|
|
1407
1312
|
upgradedGetter.set = (newValue) => linkedSignalSetFn(node, newValue);
|
|
1408
1313
|
upgradedGetter.update = (updateFn) => linkedSignalUpdateFn(node, updateFn);
|
|
1409
|
-
upgradedGetter.asReadonly = signalAsReadonlyFn.bind(
|
|
1410
|
-
getter
|
|
1411
|
-
);
|
|
1314
|
+
upgradedGetter.asReadonly = signalAsReadonlyFn.bind(getter);
|
|
1412
1315
|
return upgradedGetter;
|
|
1413
1316
|
}
|
|
1414
1317
|
|
|
1415
1318
|
// src/import/render3/reactivity/untracked.ts
|
|
1416
|
-
function
|
|
1417
|
-
|
|
1418
|
-
try {
|
|
1419
|
-
return nonReactiveReadsFn();
|
|
1420
|
-
} finally {
|
|
1421
|
-
setActiveConsumer(prevConsumer);
|
|
1422
|
-
}
|
|
1319
|
+
function untracked2(nonReactiveReadsFn) {
|
|
1320
|
+
return untracked(nonReactiveReadsFn);
|
|
1423
1321
|
}
|
|
1424
1322
|
|
|
1425
1323
|
// src/import/render3/reactivity/asserts.ts
|
|
1426
1324
|
function assertNotInReactiveContext(debugFn, extraContext) {
|
|
1427
1325
|
if (getActiveConsumer() !== null) {
|
|
1428
|
-
throw new RuntimeError(
|
|
1429
|
-
-602 /* ASSERTION_NOT_INSIDE_REACTIVE_CONTEXT */,
|
|
1430
|
-
null
|
|
1431
|
-
);
|
|
1432
|
-
}
|
|
1433
|
-
}
|
|
1434
|
-
|
|
1435
|
-
// src/import/di/contextual.ts
|
|
1436
|
-
function isInInjectionContext() {
|
|
1437
|
-
return getInjectImplementation() !== void 0 || getCurrentInjector() != null;
|
|
1438
|
-
}
|
|
1439
|
-
function assertInInjectionContext(debugFn) {
|
|
1440
|
-
if (!isInInjectionContext()) {
|
|
1441
|
-
throw new RuntimeError(-203 /* MISSING_INJECTION_CONTEXT */, null);
|
|
1326
|
+
throw new RuntimeError(-602 /* ASSERTION_NOT_INSIDE_REACTIVE_CONTEXT */, void 0);
|
|
1442
1327
|
}
|
|
1443
1328
|
}
|
|
1444
1329
|
|
|
@@ -1479,20 +1364,10 @@ var NotificationSource = /* @__PURE__ */ ((NotificationSource2) => {
|
|
|
1479
1364
|
})(NotificationSource || {});
|
|
1480
1365
|
var ChangeDetectionScheduler = class {
|
|
1481
1366
|
};
|
|
1482
|
-
var ZONELESS_ENABLED = new InjectionToken(
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
);
|
|
1486
|
-
var PROVIDED_ZONELESS = new InjectionToken(
|
|
1487
|
-
false ? "Zoneless provided" : "",
|
|
1488
|
-
{ providedIn: "root", factory: () => false }
|
|
1489
|
-
);
|
|
1490
|
-
var ZONELESS_SCHEDULER_DISABLED = new InjectionToken(
|
|
1491
|
-
false ? "scheduler disabled" : ""
|
|
1492
|
-
);
|
|
1493
|
-
var SCHEDULE_IN_ROOT_ZONE = new InjectionToken(
|
|
1494
|
-
false ? "run changes outside zone in root" : ""
|
|
1495
|
-
);
|
|
1367
|
+
var ZONELESS_ENABLED = new InjectionToken("", { providedIn: "root", factory: () => false });
|
|
1368
|
+
var PROVIDED_ZONELESS = new InjectionToken("", { providedIn: "root", factory: () => false });
|
|
1369
|
+
var ZONELESS_SCHEDULER_DISABLED = new InjectionToken("");
|
|
1370
|
+
var SCHEDULE_IN_ROOT_ZONE = new InjectionToken("");
|
|
1496
1371
|
|
|
1497
1372
|
// src/import/render3/reactivity/root_effect_scheduler.ts
|
|
1498
1373
|
var EffectScheduler = class _EffectScheduler {
|
|
@@ -1507,10 +1382,17 @@ var EffectScheduler = class _EffectScheduler {
|
|
|
1507
1382
|
);
|
|
1508
1383
|
};
|
|
1509
1384
|
var ZoneAwareEffectScheduler = class {
|
|
1510
|
-
|
|
1385
|
+
dirtyEffectCount = 0;
|
|
1511
1386
|
queues = /* @__PURE__ */ new Map();
|
|
1512
|
-
|
|
1387
|
+
add(handle) {
|
|
1513
1388
|
this.enqueue(handle);
|
|
1389
|
+
this.schedule(handle);
|
|
1390
|
+
}
|
|
1391
|
+
schedule(handle) {
|
|
1392
|
+
if (!handle.dirty) {
|
|
1393
|
+
return;
|
|
1394
|
+
}
|
|
1395
|
+
this.dirtyEffectCount++;
|
|
1514
1396
|
}
|
|
1515
1397
|
remove(handle) {
|
|
1516
1398
|
const zone = handle.zone;
|
|
@@ -1519,7 +1401,9 @@ var ZoneAwareEffectScheduler = class {
|
|
|
1519
1401
|
return;
|
|
1520
1402
|
}
|
|
1521
1403
|
queue.delete(handle);
|
|
1522
|
-
|
|
1404
|
+
if (handle.dirty) {
|
|
1405
|
+
this.dirtyEffectCount--;
|
|
1406
|
+
}
|
|
1523
1407
|
}
|
|
1524
1408
|
enqueue(handle) {
|
|
1525
1409
|
const zone = handle.zone;
|
|
@@ -1530,7 +1414,6 @@ var ZoneAwareEffectScheduler = class {
|
|
|
1530
1414
|
if (queue.has(handle)) {
|
|
1531
1415
|
return;
|
|
1532
1416
|
}
|
|
1533
|
-
this.queuedEffectCount++;
|
|
1534
1417
|
queue.add(handle);
|
|
1535
1418
|
}
|
|
1536
1419
|
/**
|
|
@@ -1540,224 +1423,35 @@ var ZoneAwareEffectScheduler = class {
|
|
|
1540
1423
|
* ordering guarantee between effects scheduled in different zones.
|
|
1541
1424
|
*/
|
|
1542
1425
|
flush() {
|
|
1543
|
-
while (this.
|
|
1426
|
+
while (this.dirtyEffectCount > 0) {
|
|
1427
|
+
let ranOneEffect = false;
|
|
1544
1428
|
for (const [zone, queue] of this.queues) {
|
|
1545
1429
|
if (zone === null) {
|
|
1546
|
-
this.flushQueue(queue);
|
|
1430
|
+
ranOneEffect ||= this.flushQueue(queue);
|
|
1547
1431
|
} else {
|
|
1548
|
-
zone.run(() => this.flushQueue(queue));
|
|
1432
|
+
ranOneEffect ||= zone.run(() => this.flushQueue(queue));
|
|
1549
1433
|
}
|
|
1550
1434
|
}
|
|
1435
|
+
if (!ranOneEffect) {
|
|
1436
|
+
this.dirtyEffectCount = 0;
|
|
1437
|
+
}
|
|
1551
1438
|
}
|
|
1552
1439
|
}
|
|
1553
1440
|
flushQueue(queue) {
|
|
1441
|
+
let ranOneEffect = false;
|
|
1554
1442
|
for (const handle of queue) {
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
handle.run();
|
|
1558
|
-
}
|
|
1559
|
-
}
|
|
1560
|
-
};
|
|
1561
|
-
|
|
1562
|
-
// src/import/render3/reactivity/patch.ts
|
|
1563
|
-
var USE_MICROTASK_EFFECT_BY_DEFAULT = false;
|
|
1564
|
-
|
|
1565
|
-
// src/import/error_handler.ts
|
|
1566
|
-
var ErrorHandler = class {
|
|
1567
|
-
/**
|
|
1568
|
-
* @internal
|
|
1569
|
-
*/
|
|
1570
|
-
_console = console;
|
|
1571
|
-
handleError(error) {
|
|
1572
|
-
this._console.error("ERROR", error);
|
|
1573
|
-
}
|
|
1574
|
-
};
|
|
1575
|
-
|
|
1576
|
-
// src/import/pending_tasks.ts
|
|
1577
|
-
import { BehaviorSubject } from "rxjs";
|
|
1578
|
-
var PendingTasksInternal = class _PendingTasksInternal {
|
|
1579
|
-
taskId = 0;
|
|
1580
|
-
pendingTasks = /* @__PURE__ */ new Set();
|
|
1581
|
-
get _hasPendingTasks() {
|
|
1582
|
-
return this.hasPendingTasks.value;
|
|
1583
|
-
}
|
|
1584
|
-
hasPendingTasks = new BehaviorSubject(false);
|
|
1585
|
-
add() {
|
|
1586
|
-
if (!this._hasPendingTasks) {
|
|
1587
|
-
this.hasPendingTasks.next(true);
|
|
1588
|
-
}
|
|
1589
|
-
const taskId = this.taskId++;
|
|
1590
|
-
this.pendingTasks.add(taskId);
|
|
1591
|
-
return taskId;
|
|
1592
|
-
}
|
|
1593
|
-
has(taskId) {
|
|
1594
|
-
return this.pendingTasks.has(taskId);
|
|
1595
|
-
}
|
|
1596
|
-
remove(taskId) {
|
|
1597
|
-
this.pendingTasks.delete(taskId);
|
|
1598
|
-
if (this.pendingTasks.size === 0 && this._hasPendingTasks) {
|
|
1599
|
-
this.hasPendingTasks.next(false);
|
|
1600
|
-
}
|
|
1601
|
-
}
|
|
1602
|
-
ngOnDestroy() {
|
|
1603
|
-
this.pendingTasks.clear();
|
|
1604
|
-
if (this._hasPendingTasks) {
|
|
1605
|
-
this.hasPendingTasks.next(false);
|
|
1606
|
-
}
|
|
1607
|
-
}
|
|
1608
|
-
/** @nocollapse */
|
|
1609
|
-
static ɵprov = (
|
|
1610
|
-
/** @pureOrBreakMyCode */
|
|
1611
|
-
/* @__PURE__ */ ɵɵdefineInjectable({
|
|
1612
|
-
token: _PendingTasksInternal,
|
|
1613
|
-
providedIn: "root",
|
|
1614
|
-
factory: () => new _PendingTasksInternal()
|
|
1615
|
-
})
|
|
1616
|
-
);
|
|
1617
|
-
};
|
|
1618
|
-
var PendingTasks = class _PendingTasks {
|
|
1619
|
-
internalPendingTasks = inject(PendingTasksInternal);
|
|
1620
|
-
scheduler = inject(ChangeDetectionScheduler);
|
|
1621
|
-
/**
|
|
1622
|
-
* Adds a new task that should block application's stability.
|
|
1623
|
-
* @returns A cleanup function that removes a task when called.
|
|
1624
|
-
*/
|
|
1625
|
-
add() {
|
|
1626
|
-
const taskId = this.internalPendingTasks.add();
|
|
1627
|
-
return () => {
|
|
1628
|
-
if (!this.internalPendingTasks.has(taskId)) {
|
|
1629
|
-
return;
|
|
1630
|
-
}
|
|
1631
|
-
this.scheduler.notify(11 /* PendingTaskRemoved */);
|
|
1632
|
-
this.internalPendingTasks.remove(taskId);
|
|
1633
|
-
};
|
|
1634
|
-
}
|
|
1635
|
-
/**
|
|
1636
|
-
* Runs an asynchronous function and blocks the application's stability until the function completes.
|
|
1637
|
-
*
|
|
1638
|
-
* ```ts
|
|
1639
|
-
* pendingTasks.run(async () => {
|
|
1640
|
-
* const userData = await fetch('/api/user');
|
|
1641
|
-
* this.userData.set(userData);
|
|
1642
|
-
* });
|
|
1643
|
-
* ```
|
|
1644
|
-
*
|
|
1645
|
-
* Application stability is at least delayed until the next tick after the `run` method resolves
|
|
1646
|
-
* so it is safe to make additional updates to application state that would require UI synchronization:
|
|
1647
|
-
*
|
|
1648
|
-
* ```ts
|
|
1649
|
-
* const userData = await pendingTasks.run(() => fetch('/api/user'));
|
|
1650
|
-
* this.userData.set(userData);
|
|
1651
|
-
* ```
|
|
1652
|
-
*
|
|
1653
|
-
* @param fn The asynchronous function to execute
|
|
1654
|
-
*/
|
|
1655
|
-
async run(fn) {
|
|
1656
|
-
const removeTask = this.add();
|
|
1657
|
-
try {
|
|
1658
|
-
return await fn();
|
|
1659
|
-
} finally {
|
|
1660
|
-
removeTask();
|
|
1661
|
-
}
|
|
1662
|
-
}
|
|
1663
|
-
/** @nocollapse */
|
|
1664
|
-
static ɵprov = (
|
|
1665
|
-
/** @pureOrBreakMyCode */
|
|
1666
|
-
/* @__PURE__ */ ɵɵdefineInjectable({
|
|
1667
|
-
token: _PendingTasks,
|
|
1668
|
-
providedIn: "root",
|
|
1669
|
-
factory: () => new _PendingTasks()
|
|
1670
|
-
})
|
|
1671
|
-
);
|
|
1672
|
-
};
|
|
1673
|
-
|
|
1674
|
-
// src/import/render3/reactivity/microtask_effect.ts
|
|
1675
|
-
var MicrotaskEffectScheduler = class _MicrotaskEffectScheduler extends ZoneAwareEffectScheduler {
|
|
1676
|
-
pendingTasks = inject(PendingTasksInternal);
|
|
1677
|
-
taskId = null;
|
|
1678
|
-
schedule(effect3) {
|
|
1679
|
-
super.schedule(effect3);
|
|
1680
|
-
if (this.taskId === null) {
|
|
1681
|
-
this.taskId = this.pendingTasks.add();
|
|
1682
|
-
queueMicrotask(() => this.flush());
|
|
1683
|
-
}
|
|
1684
|
-
}
|
|
1685
|
-
flush() {
|
|
1686
|
-
try {
|
|
1687
|
-
super.flush();
|
|
1688
|
-
} finally {
|
|
1689
|
-
if (this.taskId !== null) {
|
|
1690
|
-
this.pendingTasks.remove(this.taskId);
|
|
1691
|
-
this.taskId = null;
|
|
1443
|
+
if (!handle.dirty) {
|
|
1444
|
+
continue;
|
|
1692
1445
|
}
|
|
1446
|
+
this.dirtyEffectCount--;
|
|
1447
|
+
ranOneEffect = true;
|
|
1448
|
+
handle.run();
|
|
1693
1449
|
}
|
|
1450
|
+
return ranOneEffect;
|
|
1694
1451
|
}
|
|
1695
|
-
/** @nocollapse */
|
|
1696
|
-
static ɵprov = (
|
|
1697
|
-
/** @pureOrBreakMyCode */
|
|
1698
|
-
/* @__PURE__ */ ɵɵdefineInjectable({
|
|
1699
|
-
token: _MicrotaskEffectScheduler,
|
|
1700
|
-
providedIn: "root",
|
|
1701
|
-
factory: () => new _MicrotaskEffectScheduler()
|
|
1702
|
-
})
|
|
1703
|
-
);
|
|
1704
1452
|
};
|
|
1705
|
-
var EffectHandle = class {
|
|
1706
|
-
constructor(scheduler, effectFn, zone, destroyRef, injector, allowSignalWrites) {
|
|
1707
|
-
this.scheduler = scheduler;
|
|
1708
|
-
this.effectFn = effectFn;
|
|
1709
|
-
this.zone = zone;
|
|
1710
|
-
this.injector = injector;
|
|
1711
|
-
this.watcher = createWatch(
|
|
1712
|
-
(onCleanup) => this.runEffect(onCleanup),
|
|
1713
|
-
() => this.schedule(),
|
|
1714
|
-
allowSignalWrites
|
|
1715
|
-
);
|
|
1716
|
-
this.unregisterOnDestroy = destroyRef?.onDestroy(() => this.destroy());
|
|
1717
|
-
}
|
|
1718
|
-
unregisterOnDestroy;
|
|
1719
|
-
watcher;
|
|
1720
|
-
runEffect(onCleanup) {
|
|
1721
|
-
try {
|
|
1722
|
-
this.effectFn(onCleanup);
|
|
1723
|
-
} catch (err) {
|
|
1724
|
-
const errorHandler = this.injector.get(ErrorHandler, null, {
|
|
1725
|
-
optional: true
|
|
1726
|
-
});
|
|
1727
|
-
errorHandler?.handleError(err);
|
|
1728
|
-
}
|
|
1729
|
-
}
|
|
1730
|
-
run() {
|
|
1731
|
-
this.watcher.run();
|
|
1732
|
-
}
|
|
1733
|
-
schedule() {
|
|
1734
|
-
this.scheduler.schedule(this);
|
|
1735
|
-
}
|
|
1736
|
-
destroy() {
|
|
1737
|
-
this.watcher.destroy();
|
|
1738
|
-
this.unregisterOnDestroy?.();
|
|
1739
|
-
}
|
|
1740
|
-
};
|
|
1741
|
-
function effect() {
|
|
1742
|
-
}
|
|
1743
|
-
function microtaskEffect(effectFn, options) {
|
|
1744
|
-
!options?.injector && assertInInjectionContext(effect);
|
|
1745
|
-
const injector = options?.injector ?? inject(Injector);
|
|
1746
|
-
const destroyRef = options?.manualCleanup !== true ? injector.get(DestroyRef) : null;
|
|
1747
|
-
const handle = new EffectHandle(
|
|
1748
|
-
injector.get(MicrotaskEffectScheduler),
|
|
1749
|
-
effectFn,
|
|
1750
|
-
true ? null : (void 0).current,
|
|
1751
|
-
destroyRef,
|
|
1752
|
-
injector,
|
|
1753
|
-
options?.allowSignalWrites ?? false
|
|
1754
|
-
);
|
|
1755
|
-
handle.watcher.notify();
|
|
1756
|
-
return handle;
|
|
1757
|
-
}
|
|
1758
1453
|
|
|
1759
1454
|
// src/import/render3/reactivity/effect.ts
|
|
1760
|
-
var useMicrotaskEffectsByDefault = USE_MICROTASK_EFFECT_BY_DEFAULT;
|
|
1761
1455
|
var EffectRefImpl = class {
|
|
1762
1456
|
[SIGNAL];
|
|
1763
1457
|
constructor(node) {
|
|
@@ -1767,20 +1461,12 @@ var EffectRefImpl = class {
|
|
|
1767
1461
|
this[SIGNAL].destroy();
|
|
1768
1462
|
}
|
|
1769
1463
|
};
|
|
1770
|
-
function
|
|
1771
|
-
if (
|
|
1772
|
-
|
|
1773
|
-
throw new Error(
|
|
1774
|
-
`Cannot use 'forceRoot' option with microtask effects on`
|
|
1775
|
-
);
|
|
1776
|
-
}
|
|
1777
|
-
return microtaskEffect(effectFn, options);
|
|
1464
|
+
function effect(effectFn, options) {
|
|
1465
|
+
if (false) {
|
|
1466
|
+
assertInInjectionContext(effect);
|
|
1778
1467
|
}
|
|
1779
|
-
!options?.injector && assertInInjectionContext(effect2);
|
|
1780
1468
|
if (false) {
|
|
1781
|
-
console.warn(
|
|
1782
|
-
`The 'allowSignalWrites' flag is deprecated and no longer impacts effect() (writes are always allowed)`
|
|
1783
|
-
);
|
|
1469
|
+
console.warn(`The 'allowSignalWrites' flag is deprecated and no longer impacts effect() (writes are always allowed)`);
|
|
1784
1470
|
}
|
|
1785
1471
|
const injector = options?.injector ?? inject(Injector);
|
|
1786
1472
|
const destroyRef = options?.manualCleanup !== true ? injector.get(DestroyRef) : null;
|
|
@@ -1807,9 +1493,7 @@ var BASE_EFFECT_NODE = /* @__PURE__ */ (() => ({
|
|
|
1807
1493
|
run() {
|
|
1808
1494
|
this.dirty = false;
|
|
1809
1495
|
if (false) {
|
|
1810
|
-
throw new Error(
|
|
1811
|
-
`Schedulers cannot synchronously execute watches while scheduling.`
|
|
1812
|
-
);
|
|
1496
|
+
throw new Error(`Schedulers cannot synchronously execute watches while scheduling.`);
|
|
1813
1497
|
}
|
|
1814
1498
|
if (this.hasRun && !consumerPollProducersForChange(this)) {
|
|
1815
1499
|
return;
|
|
@@ -1828,12 +1512,14 @@ var BASE_EFFECT_NODE = /* @__PURE__ */ (() => ({
|
|
|
1828
1512
|
if (!this.cleanupFns?.length) {
|
|
1829
1513
|
return;
|
|
1830
1514
|
}
|
|
1515
|
+
const prevConsumer = setActiveConsumer(null);
|
|
1831
1516
|
try {
|
|
1832
1517
|
while (this.cleanupFns.length) {
|
|
1833
1518
|
this.cleanupFns.pop()();
|
|
1834
1519
|
}
|
|
1835
1520
|
} finally {
|
|
1836
1521
|
this.cleanupFns = [];
|
|
1522
|
+
setActiveConsumer(prevConsumer);
|
|
1837
1523
|
}
|
|
1838
1524
|
}
|
|
1839
1525
|
}))();
|
|
@@ -1856,7 +1542,7 @@ function createRootEffect(fn, scheduler, notifier) {
|
|
|
1856
1542
|
node.scheduler = scheduler;
|
|
1857
1543
|
node.notifier = notifier;
|
|
1858
1544
|
node.zone = false ? (void 0).current : null;
|
|
1859
|
-
node.scheduler.
|
|
1545
|
+
node.scheduler.add(node);
|
|
1860
1546
|
node.notifier.notify(12 /* RootEffect */);
|
|
1861
1547
|
return node;
|
|
1862
1548
|
}
|
|
@@ -1910,27 +1596,148 @@ var ChangeDetectionSchedulerImpl = class {
|
|
|
1910
1596
|
}
|
|
1911
1597
|
};
|
|
1912
1598
|
|
|
1913
|
-
// src/import/
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1599
|
+
// src/import/pending_tasks.ts
|
|
1600
|
+
import { BehaviorSubject, Observable } from "rxjs";
|
|
1601
|
+
|
|
1602
|
+
// src/import/error_handler.ts
|
|
1603
|
+
var ErrorHandler = class {
|
|
1604
|
+
/**
|
|
1605
|
+
* @internal
|
|
1606
|
+
*/
|
|
1607
|
+
_console = console;
|
|
1608
|
+
handleError(error) {
|
|
1609
|
+
this._console.error("ERROR", error);
|
|
1610
|
+
}
|
|
1611
|
+
};
|
|
1612
|
+
var INTERNAL_APPLICATION_ERROR_HANDLER = new InjectionToken("", {
|
|
1613
|
+
providedIn: "root",
|
|
1614
|
+
factory: () => {
|
|
1615
|
+
const injector = inject(EnvironmentInjector);
|
|
1616
|
+
let userErrorHandler;
|
|
1617
|
+
return (e) => {
|
|
1618
|
+
userErrorHandler ??= injector.get(ErrorHandler);
|
|
1619
|
+
userErrorHandler.handleError(e);
|
|
1620
|
+
};
|
|
1621
|
+
}
|
|
1622
|
+
});
|
|
1623
|
+
|
|
1624
|
+
// src/import/pending_tasks.ts
|
|
1625
|
+
var PendingTasksInternal = class _PendingTasksInternal {
|
|
1626
|
+
taskId = 0;
|
|
1627
|
+
pendingTasks = /* @__PURE__ */ new Set();
|
|
1628
|
+
destroyed = false;
|
|
1629
|
+
pendingTask = new BehaviorSubject(false);
|
|
1630
|
+
get hasPendingTasks() {
|
|
1631
|
+
return this.destroyed ? false : this.pendingTask.value;
|
|
1632
|
+
}
|
|
1633
|
+
/**
|
|
1634
|
+
* In case the service is about to be destroyed, return a self-completing observable.
|
|
1635
|
+
* Otherwise, return the observable that emits the current state of pending tasks.
|
|
1636
|
+
*/
|
|
1637
|
+
get hasPendingTasksObservable() {
|
|
1638
|
+
if (this.destroyed) {
|
|
1639
|
+
return new Observable((subscriber) => {
|
|
1640
|
+
subscriber.next(false);
|
|
1641
|
+
subscriber.complete();
|
|
1642
|
+
});
|
|
1643
|
+
}
|
|
1644
|
+
return this.pendingTask;
|
|
1645
|
+
}
|
|
1646
|
+
add() {
|
|
1647
|
+
if (!this.hasPendingTasks && !this.destroyed) {
|
|
1648
|
+
this.pendingTask.next(true);
|
|
1649
|
+
}
|
|
1650
|
+
const taskId = this.taskId++;
|
|
1651
|
+
this.pendingTasks.add(taskId);
|
|
1652
|
+
return taskId;
|
|
1653
|
+
}
|
|
1654
|
+
has(taskId) {
|
|
1655
|
+
return this.pendingTasks.has(taskId);
|
|
1656
|
+
}
|
|
1657
|
+
remove(taskId) {
|
|
1658
|
+
this.pendingTasks.delete(taskId);
|
|
1659
|
+
if (this.pendingTasks.size === 0 && this.hasPendingTasks) {
|
|
1660
|
+
this.pendingTask.next(false);
|
|
1661
|
+
}
|
|
1662
|
+
}
|
|
1663
|
+
ngOnDestroy() {
|
|
1664
|
+
this.pendingTasks.clear();
|
|
1665
|
+
if (this.hasPendingTasks) {
|
|
1666
|
+
this.pendingTask.next(false);
|
|
1667
|
+
}
|
|
1668
|
+
this.destroyed = true;
|
|
1669
|
+
this.pendingTask.unsubscribe();
|
|
1670
|
+
}
|
|
1671
|
+
/** @nocollapse */
|
|
1672
|
+
static ɵprov = (
|
|
1673
|
+
/** @pureOrBreakMyCode */
|
|
1674
|
+
/* @__PURE__ */ ɵɵdefineInjectable({
|
|
1675
|
+
token: _PendingTasksInternal,
|
|
1676
|
+
providedIn: "root",
|
|
1677
|
+
factory: () => new _PendingTasksInternal()
|
|
1678
|
+
})
|
|
1679
|
+
);
|
|
1680
|
+
};
|
|
1681
|
+
var PendingTasks = class _PendingTasks {
|
|
1682
|
+
internalPendingTasks = inject(PendingTasksInternal);
|
|
1683
|
+
scheduler = inject(ChangeDetectionScheduler);
|
|
1684
|
+
errorHandler = inject(INTERNAL_APPLICATION_ERROR_HANDLER);
|
|
1685
|
+
/**
|
|
1686
|
+
* Adds a new task that should block application's stability.
|
|
1687
|
+
* @returns A cleanup function that removes a task when called.
|
|
1688
|
+
*/
|
|
1689
|
+
add() {
|
|
1690
|
+
const taskId = this.internalPendingTasks.add();
|
|
1691
|
+
return () => {
|
|
1692
|
+
if (!this.internalPendingTasks.has(taskId)) {
|
|
1693
|
+
return;
|
|
1694
|
+
}
|
|
1695
|
+
this.scheduler.notify(11 /* PendingTaskRemoved */);
|
|
1696
|
+
this.internalPendingTasks.remove(taskId);
|
|
1697
|
+
};
|
|
1698
|
+
}
|
|
1699
|
+
/**
|
|
1700
|
+
* Runs an asynchronous function and blocks the application's stability until the function completes.
|
|
1701
|
+
*
|
|
1702
|
+
* ```ts
|
|
1703
|
+
* pendingTasks.run(async () => {
|
|
1704
|
+
* const userData = await fetch('/api/user');
|
|
1705
|
+
* this.userData.set(userData);
|
|
1706
|
+
* });
|
|
1707
|
+
* ```
|
|
1708
|
+
*
|
|
1709
|
+
* @param fn The asynchronous function to execute
|
|
1710
|
+
* @developerPreview 19.0
|
|
1711
|
+
*/
|
|
1712
|
+
run(fn) {
|
|
1713
|
+
const removeTask = this.add();
|
|
1714
|
+
fn().catch(this.errorHandler).finally(removeTask);
|
|
1715
|
+
}
|
|
1716
|
+
/** @nocollapse */
|
|
1717
|
+
static ɵprov = (
|
|
1718
|
+
/** @pureOrBreakMyCode */
|
|
1719
|
+
/* @__PURE__ */ ɵɵdefineInjectable({
|
|
1720
|
+
token: _PendingTasks,
|
|
1721
|
+
providedIn: "root",
|
|
1722
|
+
factory: () => new _PendingTasks()
|
|
1723
|
+
})
|
|
1724
|
+
);
|
|
1725
|
+
};
|
|
1923
1726
|
|
|
1924
1727
|
// src/import/resource/resource.ts
|
|
1728
|
+
var RESOURCE_VALUE_THROWS_ERRORS_DEFAULT = true;
|
|
1925
1729
|
function resource(options) {
|
|
1926
|
-
|
|
1927
|
-
|
|
1730
|
+
if (false) {
|
|
1731
|
+
}
|
|
1732
|
+
const oldNameForParams = options.request;
|
|
1733
|
+
const params = options.params ?? oldNameForParams ?? (() => null);
|
|
1928
1734
|
return new ResourceImpl(
|
|
1929
|
-
|
|
1735
|
+
params,
|
|
1930
1736
|
getLoader(options),
|
|
1931
1737
|
options.defaultValue,
|
|
1932
1738
|
options.equal ? wrapEqualityFn(options.equal) : void 0,
|
|
1933
|
-
options.injector ?? inject(Injector)
|
|
1739
|
+
options.injector ?? inject(Injector),
|
|
1740
|
+
RESOURCE_VALUE_THROWS_ERRORS_DEFAULT
|
|
1934
1741
|
);
|
|
1935
1742
|
}
|
|
1936
1743
|
var BaseWritableResource = class {
|
|
@@ -1941,13 +1748,15 @@ var BaseWritableResource = class {
|
|
|
1941
1748
|
this.value.update = this.update.bind(this);
|
|
1942
1749
|
this.value.asReadonly = signalAsReadonlyFn;
|
|
1943
1750
|
}
|
|
1751
|
+
isError = computed(() => this.status() === "error");
|
|
1944
1752
|
update(updateFn) {
|
|
1945
|
-
this.set(updateFn(
|
|
1753
|
+
this.set(updateFn(untracked2(this.value)));
|
|
1946
1754
|
}
|
|
1947
|
-
isLoading = computed(
|
|
1948
|
-
() => this.status() === 2 /* Loading */ || this.status() === 3 /* Reloading */
|
|
1949
|
-
);
|
|
1755
|
+
isLoading = computed(() => this.status() === "loading" || this.status() === "reloading");
|
|
1950
1756
|
hasValue() {
|
|
1757
|
+
if (this.isError()) {
|
|
1758
|
+
return false;
|
|
1759
|
+
}
|
|
1951
1760
|
return this.value() !== void 0;
|
|
1952
1761
|
}
|
|
1953
1762
|
asReadonly() {
|
|
@@ -1955,20 +1764,32 @@ var BaseWritableResource = class {
|
|
|
1955
1764
|
}
|
|
1956
1765
|
};
|
|
1957
1766
|
var ResourceImpl = class extends BaseWritableResource {
|
|
1958
|
-
constructor(request, loaderFn, defaultValue, equal, injector) {
|
|
1767
|
+
constructor(request, loaderFn, defaultValue, equal, injector, throwErrorsFromValue = RESOURCE_VALUE_THROWS_ERRORS_DEFAULT) {
|
|
1959
1768
|
super(
|
|
1960
1769
|
// Feed a computed signal for the value to `BaseWritableResource`, which will upgrade it to a
|
|
1961
1770
|
// `WritableSignal` that delegates to `ResourceImpl.set`.
|
|
1962
1771
|
computed(
|
|
1963
1772
|
() => {
|
|
1964
1773
|
const streamValue = this.state().stream?.();
|
|
1965
|
-
|
|
1774
|
+
if (!streamValue) {
|
|
1775
|
+
return defaultValue;
|
|
1776
|
+
}
|
|
1777
|
+
if (this.state().status === "loading" && this.error()) {
|
|
1778
|
+
return defaultValue;
|
|
1779
|
+
}
|
|
1780
|
+
if (!isResolved(streamValue)) {
|
|
1781
|
+
if (throwErrorsFromValue) {
|
|
1782
|
+
throw new ResourceValueError(this.error());
|
|
1783
|
+
} else {
|
|
1784
|
+
return defaultValue;
|
|
1785
|
+
}
|
|
1786
|
+
}
|
|
1787
|
+
return streamValue.value;
|
|
1966
1788
|
},
|
|
1967
1789
|
{ equal }
|
|
1968
1790
|
)
|
|
1969
1791
|
);
|
|
1970
1792
|
this.loaderFn = loaderFn;
|
|
1971
|
-
this.defaultValue = defaultValue;
|
|
1972
1793
|
this.equal = equal;
|
|
1973
1794
|
this.extRequest = linkedSignal({
|
|
1974
1795
|
source: request,
|
|
@@ -1979,12 +1800,12 @@ var ResourceImpl = class extends BaseWritableResource {
|
|
|
1979
1800
|
source: this.extRequest,
|
|
1980
1801
|
// Compute the state of the resource given a change in status.
|
|
1981
1802
|
computation: (extRequest, previous) => {
|
|
1982
|
-
const status = extRequest.request === void 0 ?
|
|
1803
|
+
const status = extRequest.request === void 0 ? "idle" : "loading";
|
|
1983
1804
|
if (!previous) {
|
|
1984
1805
|
return {
|
|
1985
1806
|
extRequest,
|
|
1986
1807
|
status,
|
|
1987
|
-
previousStatus:
|
|
1808
|
+
previousStatus: "idle",
|
|
1988
1809
|
stream: void 0
|
|
1989
1810
|
};
|
|
1990
1811
|
} else {
|
|
@@ -1998,12 +1819,12 @@ var ResourceImpl = class extends BaseWritableResource {
|
|
|
1998
1819
|
}
|
|
1999
1820
|
}
|
|
2000
1821
|
});
|
|
2001
|
-
this.effectRef =
|
|
1822
|
+
this.effectRef = effect(this.loadEffect.bind(this), {
|
|
2002
1823
|
injector,
|
|
2003
1824
|
manualCleanup: true
|
|
2004
1825
|
});
|
|
2005
1826
|
this.pendingTasks = injector.get(PendingTasks);
|
|
2006
|
-
injector.get(DestroyRef).onDestroy(() => this.destroy());
|
|
1827
|
+
this.unregisterOnDestroy = injector.get(DestroyRef).onDestroy(() => this.destroy());
|
|
2007
1828
|
}
|
|
2008
1829
|
pendingTasks;
|
|
2009
1830
|
/**
|
|
@@ -2019,6 +1840,7 @@ var ResourceImpl = class extends BaseWritableResource {
|
|
|
2019
1840
|
pendingController;
|
|
2020
1841
|
resolvePendingTask = void 0;
|
|
2021
1842
|
destroyed = false;
|
|
1843
|
+
unregisterOnDestroy;
|
|
2022
1844
|
status = computed(() => projectStatusOfState(this.state()));
|
|
2023
1845
|
error = computed(() => {
|
|
2024
1846
|
const stream = this.state().stream?.();
|
|
@@ -2031,55 +1853,55 @@ var ResourceImpl = class extends BaseWritableResource {
|
|
|
2031
1853
|
if (this.destroyed) {
|
|
2032
1854
|
return;
|
|
2033
1855
|
}
|
|
2034
|
-
const current =
|
|
2035
|
-
const state =
|
|
2036
|
-
if (state.status ===
|
|
1856
|
+
const current = untracked2(this.value);
|
|
1857
|
+
const state = untracked2(this.state);
|
|
1858
|
+
if (state.status === "local" && (this.equal ? this.equal(current, value) : current === value)) {
|
|
2037
1859
|
return;
|
|
2038
1860
|
}
|
|
2039
1861
|
this.state.set({
|
|
2040
1862
|
extRequest: state.extRequest,
|
|
2041
|
-
status:
|
|
2042
|
-
previousStatus:
|
|
1863
|
+
status: "local",
|
|
1864
|
+
previousStatus: "local",
|
|
2043
1865
|
stream: signal({ value })
|
|
2044
1866
|
});
|
|
2045
1867
|
this.abortInProgressLoad();
|
|
2046
1868
|
}
|
|
2047
1869
|
reload() {
|
|
2048
|
-
const { status } =
|
|
2049
|
-
if (status ===
|
|
1870
|
+
const { status } = untracked2(this.state);
|
|
1871
|
+
if (status === "idle" || status === "loading") {
|
|
2050
1872
|
return false;
|
|
2051
1873
|
}
|
|
2052
|
-
this.extRequest.update(({ request, reload }) => ({
|
|
2053
|
-
request,
|
|
2054
|
-
reload: reload + 1
|
|
2055
|
-
}));
|
|
1874
|
+
this.extRequest.update(({ request, reload }) => ({ request, reload: reload + 1 }));
|
|
2056
1875
|
return true;
|
|
2057
1876
|
}
|
|
2058
1877
|
destroy() {
|
|
2059
1878
|
this.destroyed = true;
|
|
1879
|
+
this.unregisterOnDestroy();
|
|
2060
1880
|
this.effectRef.destroy();
|
|
2061
1881
|
this.abortInProgressLoad();
|
|
2062
1882
|
this.state.set({
|
|
2063
1883
|
extRequest: { request: void 0, reload: 0 },
|
|
2064
|
-
status:
|
|
2065
|
-
previousStatus:
|
|
1884
|
+
status: "idle",
|
|
1885
|
+
previousStatus: "idle",
|
|
2066
1886
|
stream: void 0
|
|
2067
1887
|
});
|
|
2068
1888
|
}
|
|
2069
1889
|
async loadEffect() {
|
|
2070
1890
|
const extRequest = this.extRequest();
|
|
2071
|
-
const { status: currentStatus, previousStatus } =
|
|
1891
|
+
const { status: currentStatus, previousStatus } = untracked2(this.state);
|
|
2072
1892
|
if (extRequest.request === void 0) {
|
|
2073
1893
|
return;
|
|
2074
|
-
} else if (currentStatus !==
|
|
1894
|
+
} else if (currentStatus !== "loading") {
|
|
2075
1895
|
return;
|
|
2076
1896
|
}
|
|
2077
1897
|
this.abortInProgressLoad();
|
|
2078
1898
|
let resolvePendingTask = this.resolvePendingTask = this.pendingTasks.add();
|
|
2079
1899
|
const { signal: abortSignal } = this.pendingController = new AbortController();
|
|
2080
1900
|
try {
|
|
2081
|
-
const stream = await
|
|
1901
|
+
const stream = await untracked2(
|
|
2082
1902
|
() => this.loaderFn({
|
|
1903
|
+
params: extRequest.request,
|
|
1904
|
+
// TODO(alxhub): cleanup after g3 removal of `request` alias.
|
|
2083
1905
|
request: extRequest.request,
|
|
2084
1906
|
abortSignal,
|
|
2085
1907
|
previous: {
|
|
@@ -2087,24 +1909,24 @@ var ResourceImpl = class extends BaseWritableResource {
|
|
|
2087
1909
|
}
|
|
2088
1910
|
})
|
|
2089
1911
|
);
|
|
2090
|
-
if (abortSignal.aborted ||
|
|
1912
|
+
if (abortSignal.aborted || untracked2(this.extRequest) !== extRequest) {
|
|
2091
1913
|
return;
|
|
2092
1914
|
}
|
|
2093
1915
|
this.state.set({
|
|
2094
1916
|
extRequest,
|
|
2095
|
-
status:
|
|
2096
|
-
previousStatus:
|
|
1917
|
+
status: "resolved",
|
|
1918
|
+
previousStatus: "resolved",
|
|
2097
1919
|
stream
|
|
2098
1920
|
});
|
|
2099
1921
|
} catch (err) {
|
|
2100
|
-
if (abortSignal.aborted ||
|
|
1922
|
+
if (abortSignal.aborted || untracked2(this.extRequest) !== extRequest) {
|
|
2101
1923
|
return;
|
|
2102
1924
|
}
|
|
2103
1925
|
this.state.set({
|
|
2104
1926
|
extRequest,
|
|
2105
|
-
status:
|
|
2106
|
-
previousStatus:
|
|
2107
|
-
stream: signal({ error: err })
|
|
1927
|
+
status: "resolved",
|
|
1928
|
+
previousStatus: "error",
|
|
1929
|
+
stream: signal({ error: encapsulateResourceError(err) })
|
|
2108
1930
|
});
|
|
2109
1931
|
} finally {
|
|
2110
1932
|
resolvePendingTask?.();
|
|
@@ -2112,7 +1934,7 @@ var ResourceImpl = class extends BaseWritableResource {
|
|
|
2112
1934
|
}
|
|
2113
1935
|
}
|
|
2114
1936
|
abortInProgressLoad() {
|
|
2115
|
-
|
|
1937
|
+
untracked2(() => this.pendingController?.abort());
|
|
2116
1938
|
this.pendingController = void 0;
|
|
2117
1939
|
this.resolvePendingTask?.();
|
|
2118
1940
|
this.resolvePendingTask = void 0;
|
|
@@ -2129,7 +1951,7 @@ function getLoader(options) {
|
|
|
2129
1951
|
try {
|
|
2130
1952
|
return signal({ value: await options.loader(params) });
|
|
2131
1953
|
} catch (err) {
|
|
2132
|
-
return signal({ error: err });
|
|
1954
|
+
return signal({ error: encapsulateResourceError(err) });
|
|
2133
1955
|
}
|
|
2134
1956
|
};
|
|
2135
1957
|
}
|
|
@@ -2138,10 +1960,10 @@ function isStreamingResourceOptions(options) {
|
|
|
2138
1960
|
}
|
|
2139
1961
|
function projectStatusOfState(state) {
|
|
2140
1962
|
switch (state.status) {
|
|
2141
|
-
case
|
|
2142
|
-
return state.extRequest.reload === 0 ?
|
|
2143
|
-
case
|
|
2144
|
-
return isResolved(
|
|
1963
|
+
case "loading":
|
|
1964
|
+
return state.extRequest.reload === 0 ? "loading" : "reloading";
|
|
1965
|
+
case "resolved":
|
|
1966
|
+
return isResolved(state.stream()) ? "resolved" : "error";
|
|
2145
1967
|
default:
|
|
2146
1968
|
return state.status;
|
|
2147
1969
|
}
|
|
@@ -2149,8 +1971,28 @@ function projectStatusOfState(state) {
|
|
|
2149
1971
|
function isResolved(state) {
|
|
2150
1972
|
return state.error === void 0;
|
|
2151
1973
|
}
|
|
1974
|
+
function encapsulateResourceError(error) {
|
|
1975
|
+
if (error instanceof Error) {
|
|
1976
|
+
return error;
|
|
1977
|
+
}
|
|
1978
|
+
return new ResourceWrappedError(error);
|
|
1979
|
+
}
|
|
1980
|
+
var ResourceValueError = class extends Error {
|
|
1981
|
+
constructor(error) {
|
|
1982
|
+
super(error.message, { cause: error });
|
|
1983
|
+
}
|
|
1984
|
+
};
|
|
1985
|
+
var ResourceWrappedError = class extends Error {
|
|
1986
|
+
constructor(error) {
|
|
1987
|
+
super(String(error), { cause: error });
|
|
1988
|
+
}
|
|
1989
|
+
};
|
|
2152
1990
|
|
|
2153
1991
|
// src/import/index.ts
|
|
1992
|
+
function Injectable(args) {
|
|
1993
|
+
return (constructor) => {
|
|
1994
|
+
};
|
|
1995
|
+
}
|
|
2154
1996
|
var StaticInjectOptions = class {
|
|
2155
1997
|
static injectOptions;
|
|
2156
1998
|
};
|
|
@@ -2160,12 +2002,7 @@ var RootStaticInjectOptions = class {
|
|
|
2160
2002
|
};
|
|
2161
2003
|
};
|
|
2162
2004
|
function createInjector2(options) {
|
|
2163
|
-
return new R3Injector(
|
|
2164
|
-
options.providers,
|
|
2165
|
-
options.parent ?? getNullInjector(),
|
|
2166
|
-
options.name ?? "",
|
|
2167
|
-
options.scopes ?? /* @__PURE__ */ new Set([])
|
|
2168
|
-
);
|
|
2005
|
+
return new R3Injector(options.providers, options.parent ?? getNullInjector(), options.name ?? "", options.scopes ?? /* @__PURE__ */ new Set([]));
|
|
2169
2006
|
}
|
|
2170
2007
|
function createRootInjector(options) {
|
|
2171
2008
|
return new R3Injector(
|
|
@@ -2178,7 +2015,7 @@ function createRootInjector(options) {
|
|
|
2178
2015
|
],
|
|
2179
2016
|
getNullInjector(),
|
|
2180
2017
|
options.name ?? "",
|
|
2181
|
-
options.scopes ?? /* @__PURE__ */ new Set([])
|
|
2018
|
+
options.scopes ?? /* @__PURE__ */ new Set(["environment"])
|
|
2182
2019
|
);
|
|
2183
2020
|
}
|
|
2184
2021
|
export {
|
|
@@ -2186,9 +2023,11 @@ export {
|
|
|
2186
2023
|
ChangeDetectionSchedulerImpl,
|
|
2187
2024
|
DecoratorFlags,
|
|
2188
2025
|
EnvironmentInjector,
|
|
2026
|
+
ErrorHandler,
|
|
2189
2027
|
INJECTOR_SCOPE,
|
|
2028
|
+
INTERNAL_APPLICATION_ERROR_HANDLER,
|
|
2190
2029
|
Inject,
|
|
2191
|
-
|
|
2030
|
+
Injectable,
|
|
2192
2031
|
InjectionToken,
|
|
2193
2032
|
Injector,
|
|
2194
2033
|
InternalInjectFlags,
|
|
@@ -2199,8 +2038,10 @@ export {
|
|
|
2199
2038
|
NullInjector,
|
|
2200
2039
|
Optional,
|
|
2201
2040
|
PROVIDED_ZONELESS,
|
|
2041
|
+
PendingTasks,
|
|
2042
|
+
PendingTasksInternal,
|
|
2202
2043
|
R3Injector,
|
|
2203
|
-
|
|
2044
|
+
RetrievingInjector,
|
|
2204
2045
|
RootStaticInjectOptions,
|
|
2205
2046
|
SCHEDULE_IN_ROOT_ZONE,
|
|
2206
2047
|
SOURCE,
|
|
@@ -2218,7 +2059,7 @@ export {
|
|
|
2218
2059
|
convertToBitFlags,
|
|
2219
2060
|
createInjector2 as createInjector,
|
|
2220
2061
|
createRootInjector,
|
|
2221
|
-
|
|
2062
|
+
effect,
|
|
2222
2063
|
formatError,
|
|
2223
2064
|
getCurrentInjector,
|
|
2224
2065
|
getInheritedInjectableDef,
|
|
@@ -2236,11 +2077,9 @@ export {
|
|
|
2236
2077
|
resource,
|
|
2237
2078
|
setCurrentInjector,
|
|
2238
2079
|
signal,
|
|
2239
|
-
untracked,
|
|
2080
|
+
untracked2 as untracked,
|
|
2240
2081
|
EffectScheduler as ɵEffectScheduler,
|
|
2241
|
-
MicrotaskEffectScheduler as ɵMicrotaskEffectScheduler,
|
|
2242
2082
|
SIGNAL as ɵSIGNAL,
|
|
2243
|
-
microtaskEffect as ɵmicrotaskEffect,
|
|
2244
2083
|
ɵunwrapWritableSignal,
|
|
2245
2084
|
ɵɵdefineInjectable,
|
|
2246
2085
|
ɵɵdefineInjector,
|