static-injector 6.0.3 → 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 +3 -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.js
CHANGED
|
@@ -24,9 +24,11 @@ __export(import_exports, {
|
|
|
24
24
|
ChangeDetectionSchedulerImpl: () => ChangeDetectionSchedulerImpl,
|
|
25
25
|
DecoratorFlags: () => DecoratorFlags,
|
|
26
26
|
EnvironmentInjector: () => EnvironmentInjector,
|
|
27
|
+
ErrorHandler: () => ErrorHandler,
|
|
27
28
|
INJECTOR_SCOPE: () => INJECTOR_SCOPE,
|
|
29
|
+
INTERNAL_APPLICATION_ERROR_HANDLER: () => INTERNAL_APPLICATION_ERROR_HANDLER,
|
|
28
30
|
Inject: () => Inject,
|
|
29
|
-
|
|
31
|
+
Injectable: () => Injectable,
|
|
30
32
|
InjectionToken: () => InjectionToken,
|
|
31
33
|
Injector: () => Injector,
|
|
32
34
|
InternalInjectFlags: () => InternalInjectFlags,
|
|
@@ -37,8 +39,10 @@ __export(import_exports, {
|
|
|
37
39
|
NullInjector: () => NullInjector,
|
|
38
40
|
Optional: () => Optional,
|
|
39
41
|
PROVIDED_ZONELESS: () => PROVIDED_ZONELESS,
|
|
42
|
+
PendingTasks: () => PendingTasks,
|
|
43
|
+
PendingTasksInternal: () => PendingTasksInternal,
|
|
40
44
|
R3Injector: () => R3Injector,
|
|
41
|
-
|
|
45
|
+
RetrievingInjector: () => RetrievingInjector,
|
|
42
46
|
RootStaticInjectOptions: () => RootStaticInjectOptions,
|
|
43
47
|
SCHEDULE_IN_ROOT_ZONE: () => SCHEDULE_IN_ROOT_ZONE,
|
|
44
48
|
SOURCE: () => SOURCE,
|
|
@@ -56,7 +60,7 @@ __export(import_exports, {
|
|
|
56
60
|
convertToBitFlags: () => convertToBitFlags,
|
|
57
61
|
createInjector: () => createInjector2,
|
|
58
62
|
createRootInjector: () => createRootInjector,
|
|
59
|
-
effect: () =>
|
|
63
|
+
effect: () => effect,
|
|
60
64
|
formatError: () => formatError,
|
|
61
65
|
getCurrentInjector: () => getCurrentInjector,
|
|
62
66
|
getInheritedInjectableDef: () => getInheritedInjectableDef,
|
|
@@ -74,11 +78,9 @@ __export(import_exports, {
|
|
|
74
78
|
resource: () => resource,
|
|
75
79
|
setCurrentInjector: () => setCurrentInjector,
|
|
76
80
|
signal: () => signal,
|
|
77
|
-
untracked: () =>
|
|
81
|
+
untracked: () => untracked2,
|
|
78
82
|
ɵEffectScheduler: () => EffectScheduler,
|
|
79
|
-
ɵMicrotaskEffectScheduler: () => MicrotaskEffectScheduler,
|
|
80
83
|
ɵSIGNAL: () => SIGNAL,
|
|
81
|
-
ɵmicrotaskEffect: () => microtaskEffect,
|
|
82
84
|
ɵunwrapWritableSignal: () => ɵunwrapWritableSignal,
|
|
83
85
|
ɵɵdefineInjectable: () => ɵɵdefineInjectable,
|
|
84
86
|
ɵɵdefineInjector: () => ɵɵdefineInjector,
|
|
@@ -100,8 +102,11 @@ var RuntimeError = class extends Error {
|
|
|
100
102
|
this.code = code;
|
|
101
103
|
}
|
|
102
104
|
};
|
|
105
|
+
function formatRuntimeErrorCode(code) {
|
|
106
|
+
return `NG0${Math.abs(code)}`;
|
|
107
|
+
}
|
|
103
108
|
function formatRuntimeError(code, message) {
|
|
104
|
-
const fullCode =
|
|
109
|
+
const fullCode = formatRuntimeErrorCode(code);
|
|
105
110
|
const errorMessage = `${fullCode}${message ? ": " + message : ""}`;
|
|
106
111
|
if (false) {
|
|
107
112
|
}
|
|
@@ -113,6 +118,15 @@ function getFactoryDef(type, throwNotFound) {
|
|
|
113
118
|
return () => new type();
|
|
114
119
|
}
|
|
115
120
|
|
|
121
|
+
// src/import/render3/errors_di.ts
|
|
122
|
+
function throwCyclicDependencyError(token, path) {
|
|
123
|
+
throw new RuntimeError(-200 /* CYCLIC_DI_DEPENDENCY */, token);
|
|
124
|
+
}
|
|
125
|
+
function throwProviderNotFoundError(token, injectorName) {
|
|
126
|
+
const errorMessage = void 0;
|
|
127
|
+
throw new RuntimeError(-201 /* PROVIDER_NOT_FOUND */, errorMessage);
|
|
128
|
+
}
|
|
129
|
+
|
|
116
130
|
// src/import/util/property.ts
|
|
117
131
|
function getClosureSafeProperty(objWithPropertyToExtract) {
|
|
118
132
|
for (const key in objWithPropertyToExtract) {
|
|
@@ -120,16 +134,12 @@ function getClosureSafeProperty(objWithPropertyToExtract) {
|
|
|
120
134
|
return key;
|
|
121
135
|
}
|
|
122
136
|
}
|
|
123
|
-
throw Error("
|
|
137
|
+
throw Error("");
|
|
124
138
|
}
|
|
125
139
|
|
|
126
140
|
// src/import/render3/fields.ts
|
|
127
|
-
var NG_FACTORY_DEF = getClosureSafeProperty({
|
|
128
|
-
|
|
129
|
-
});
|
|
130
|
-
var NG_ENV_ID = getClosureSafeProperty({
|
|
131
|
-
__NG_ENV_ID__: getClosureSafeProperty
|
|
132
|
-
});
|
|
141
|
+
var NG_FACTORY_DEF = getClosureSafeProperty({ ɵfac: getClosureSafeProperty });
|
|
142
|
+
var NG_ENV_ID = getClosureSafeProperty({ __NG_ENV_ID__: getClosureSafeProperty });
|
|
133
143
|
|
|
134
144
|
// src/import/util/empty.ts
|
|
135
145
|
var EMPTY_ARRAY = [];
|
|
@@ -160,9 +170,7 @@ function stringify(token) {
|
|
|
160
170
|
}
|
|
161
171
|
|
|
162
172
|
// src/import/di/forward_ref.ts
|
|
163
|
-
var __forward_ref__ = getClosureSafeProperty({
|
|
164
|
-
__forward_ref__: getClosureSafeProperty
|
|
165
|
-
});
|
|
173
|
+
var __forward_ref__ = getClosureSafeProperty({ __forward_ref__: getClosureSafeProperty });
|
|
166
174
|
function forwardRef(forwardRefFn) {
|
|
167
175
|
forwardRefFn.__forward_ref__ = forwardRef;
|
|
168
176
|
forwardRefFn.toString = function() {
|
|
@@ -190,20 +198,16 @@ function ɵɵdefineInjector(options) {
|
|
|
190
198
|
return { providers: options.providers || [], imports: options.imports || [] };
|
|
191
199
|
}
|
|
192
200
|
function getInjectableDef(type) {
|
|
193
|
-
return getOwnDefinition(type, NG_PROV_DEF) || {
|
|
194
|
-
token: type,
|
|
195
|
-
factory: () => new type(),
|
|
196
|
-
...type.injectOptions
|
|
197
|
-
};
|
|
201
|
+
return getOwnDefinition(type, NG_PROV_DEF) || { token: type, factory: () => new type(), ...type.injectOptions };
|
|
198
202
|
}
|
|
199
203
|
function isInjectable(type) {
|
|
200
204
|
return getInjectableDef(type) !== null;
|
|
201
205
|
}
|
|
202
206
|
function getOwnDefinition(type, field) {
|
|
203
|
-
return type.hasOwnProperty(field)
|
|
207
|
+
return type.hasOwnProperty(field) && type[field] || null;
|
|
204
208
|
}
|
|
205
209
|
function getInheritedInjectableDef(type) {
|
|
206
|
-
const def = type
|
|
210
|
+
const def = type?.[NG_PROV_DEF] ?? null;
|
|
207
211
|
if (def) {
|
|
208
212
|
return def;
|
|
209
213
|
} else {
|
|
@@ -211,14 +215,10 @@ function getInheritedInjectableDef(type) {
|
|
|
211
215
|
}
|
|
212
216
|
}
|
|
213
217
|
function getInjectorDef(type) {
|
|
214
|
-
return type &&
|
|
218
|
+
return type && type.hasOwnProperty(NG_INJ_DEF) ? type[NG_INJ_DEF] : null;
|
|
215
219
|
}
|
|
216
|
-
var NG_PROV_DEF = getClosureSafeProperty({
|
|
217
|
-
|
|
218
|
-
});
|
|
219
|
-
var NG_INJ_DEF = getClosureSafeProperty({
|
|
220
|
-
ɵinj: getClosureSafeProperty
|
|
221
|
-
});
|
|
220
|
+
var NG_PROV_DEF = getClosureSafeProperty({ ɵprov: getClosureSafeProperty });
|
|
221
|
+
var NG_INJ_DEF = getClosureSafeProperty({ ɵinj: getClosureSafeProperty });
|
|
222
222
|
|
|
223
223
|
// src/import/di/injection_token.ts
|
|
224
224
|
var InjectionToken = class {
|
|
@@ -257,29 +257,18 @@ var InjectionToken = class {
|
|
|
257
257
|
// src/import/di/initializer_token.ts
|
|
258
258
|
var ENVIRONMENT_INITIALIZER = new InjectionToken("");
|
|
259
259
|
|
|
260
|
-
// src/import/render3/errors_di.ts
|
|
261
|
-
function throwProviderNotFoundError(token, injectorName) {
|
|
262
|
-
const errorMessage = null;
|
|
263
|
-
throw new RuntimeError(-201 /* PROVIDER_NOT_FOUND */, errorMessage);
|
|
264
|
-
}
|
|
265
|
-
|
|
266
260
|
// src/import/di/interface/injector.ts
|
|
267
261
|
var DecoratorFlags = /* @__PURE__ */ ((DecoratorFlags2) => {
|
|
268
262
|
DecoratorFlags2[DecoratorFlags2["Inject"] = -1] = "Inject";
|
|
269
263
|
return DecoratorFlags2;
|
|
270
264
|
})(DecoratorFlags || {});
|
|
271
|
-
var InjectFlags = /* @__PURE__ */ ((InjectFlags2) => {
|
|
272
|
-
InjectFlags2[InjectFlags2["Default"] = 0] = "Default";
|
|
273
|
-
InjectFlags2[InjectFlags2["Self"] = 2] = "Self";
|
|
274
|
-
InjectFlags2[InjectFlags2["SkipSelf"] = 4] = "SkipSelf";
|
|
275
|
-
InjectFlags2[InjectFlags2["Optional"] = 8] = "Optional";
|
|
276
|
-
return InjectFlags2;
|
|
277
|
-
})(InjectFlags || {});
|
|
278
265
|
var InternalInjectFlags = /* @__PURE__ */ ((InternalInjectFlags2) => {
|
|
279
266
|
InternalInjectFlags2[InternalInjectFlags2["Default"] = 0] = "Default";
|
|
267
|
+
InternalInjectFlags2[InternalInjectFlags2["Host"] = 1] = "Host";
|
|
280
268
|
InternalInjectFlags2[InternalInjectFlags2["Self"] = 2] = "Self";
|
|
281
269
|
InternalInjectFlags2[InternalInjectFlags2["SkipSelf"] = 4] = "SkipSelf";
|
|
282
270
|
InternalInjectFlags2[InternalInjectFlags2["Optional"] = 8] = "Optional";
|
|
271
|
+
InternalInjectFlags2[InternalInjectFlags2["ForPipe"] = 16] = "ForPipe";
|
|
283
272
|
return InternalInjectFlags2;
|
|
284
273
|
})(InternalInjectFlags || {});
|
|
285
274
|
|
|
@@ -303,15 +292,7 @@ function injectRootLimpMode(token, notFoundValue, flags) {
|
|
|
303
292
|
throwProviderNotFoundError(token, "Injector");
|
|
304
293
|
}
|
|
305
294
|
|
|
306
|
-
// src/
|
|
307
|
-
var _THROW_IF_NOT_FOUND = {};
|
|
308
|
-
var THROW_IF_NOT_FOUND = _THROW_IF_NOT_FOUND;
|
|
309
|
-
var DI_DECORATOR_FLAG = "__NG_DI_FLAG__";
|
|
310
|
-
var NG_TEMP_TOKEN_PATH = "ngTempTokenPath";
|
|
311
|
-
var NG_TOKEN_PATH = "ngTokenPath";
|
|
312
|
-
var NEW_LINE = /\n/gm;
|
|
313
|
-
var NO_NEW_LINE = "ɵ";
|
|
314
|
-
var SOURCE = "__source";
|
|
295
|
+
// src/primitives/di/src/injector.ts
|
|
315
296
|
var _currentInjector = void 0;
|
|
316
297
|
function getCurrentInjector() {
|
|
317
298
|
return _currentInjector;
|
|
@@ -321,31 +302,75 @@ function setCurrentInjector(injector) {
|
|
|
321
302
|
_currentInjector = injector;
|
|
322
303
|
return former;
|
|
323
304
|
}
|
|
305
|
+
|
|
306
|
+
// src/primitives/di/src/not_found.ts
|
|
307
|
+
var NOT_FOUND = Symbol("NotFound");
|
|
308
|
+
var NotFoundError = class extends Error {
|
|
309
|
+
name = "ɵNotFound";
|
|
310
|
+
constructor(message) {
|
|
311
|
+
super(message);
|
|
312
|
+
}
|
|
313
|
+
};
|
|
314
|
+
function isNotFound(e) {
|
|
315
|
+
return e === NOT_FOUND || e?.name === "ɵNotFound";
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
// src/import/di/injector_compatibility.ts
|
|
319
|
+
var _THROW_IF_NOT_FOUND = {};
|
|
320
|
+
var THROW_IF_NOT_FOUND = _THROW_IF_NOT_FOUND;
|
|
321
|
+
var DI_DECORATOR_FLAG = "__NG_DI_FLAG__";
|
|
322
|
+
var RetrievingInjector = class {
|
|
323
|
+
constructor(injector) {
|
|
324
|
+
this.injector = injector;
|
|
325
|
+
}
|
|
326
|
+
retrieve(token, options) {
|
|
327
|
+
const flags = convertToBitFlags(options) || 0 /* Default */;
|
|
328
|
+
try {
|
|
329
|
+
return this.injector.get(
|
|
330
|
+
token,
|
|
331
|
+
// When a dependency is requested with an optional flag, DI returns null as the default value.
|
|
332
|
+
flags & 8 /* Optional */ ? null : THROW_IF_NOT_FOUND,
|
|
333
|
+
flags
|
|
334
|
+
);
|
|
335
|
+
} catch (e) {
|
|
336
|
+
if (isNotFound(e)) {
|
|
337
|
+
return e;
|
|
338
|
+
}
|
|
339
|
+
throw e;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
};
|
|
343
|
+
var NG_TEMP_TOKEN_PATH = "ngTempTokenPath";
|
|
344
|
+
var NG_TOKEN_PATH = "ngTokenPath";
|
|
345
|
+
var NEW_LINE = /\n/gm;
|
|
346
|
+
var NO_NEW_LINE = "ɵ";
|
|
347
|
+
var SOURCE = "__source";
|
|
324
348
|
function injectInjectorOnly(token, flags = 0 /* Default */) {
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
349
|
+
const currentInjector = getCurrentInjector();
|
|
350
|
+
if (currentInjector === void 0) {
|
|
351
|
+
throw new RuntimeError(-203 /* MISSING_INJECTION_CONTEXT */, void 0);
|
|
352
|
+
} else if (currentInjector === null) {
|
|
328
353
|
return injectRootLimpMode(token, void 0, flags);
|
|
329
354
|
} else {
|
|
330
|
-
const
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
355
|
+
const options = convertToInjectOptions(flags);
|
|
356
|
+
const value = currentInjector.retrieve(token, options);
|
|
357
|
+
if (isNotFound(value)) {
|
|
358
|
+
if (options.optional) {
|
|
359
|
+
return null;
|
|
360
|
+
}
|
|
361
|
+
throw value;
|
|
362
|
+
}
|
|
335
363
|
return value;
|
|
336
364
|
}
|
|
337
365
|
}
|
|
338
366
|
function ɵɵinject(token, flags = 0 /* Default */) {
|
|
339
|
-
return (getInjectImplementation() || injectInjectorOnly)(
|
|
340
|
-
resolveForwardRef(token),
|
|
341
|
-
flags
|
|
342
|
-
);
|
|
367
|
+
return (getInjectImplementation() || injectInjectorOnly)(resolveForwardRef(token), flags);
|
|
343
368
|
}
|
|
344
369
|
function ɵɵinvalidFactoryDep(index) {
|
|
345
|
-
throw new RuntimeError(202 /* INVALID_FACTORY_DEPENDENCY */,
|
|
370
|
+
throw new RuntimeError(202 /* INVALID_FACTORY_DEPENDENCY */, void 0);
|
|
346
371
|
}
|
|
347
|
-
function inject(token,
|
|
348
|
-
return ɵɵinject(token, convertToBitFlags(
|
|
372
|
+
function inject(token, options) {
|
|
373
|
+
return ɵɵinject(token, convertToBitFlags(options));
|
|
349
374
|
}
|
|
350
375
|
function convertToBitFlags(flags) {
|
|
351
376
|
if (typeof flags === "undefined" || typeof flags === "number") {
|
|
@@ -354,13 +379,21 @@ function convertToBitFlags(flags) {
|
|
|
354
379
|
return 0 /* Default */ | // comment to force a line break in the formatter
|
|
355
380
|
(flags.optional && 8 /* Optional */) | 0 | (flags.self && 2 /* Self */) | (flags.skipSelf && 4 /* SkipSelf */);
|
|
356
381
|
}
|
|
382
|
+
function convertToInjectOptions(flags) {
|
|
383
|
+
return {
|
|
384
|
+
optional: !!(flags & 8 /* Optional */),
|
|
385
|
+
host: !!(flags & 1 /* Host */),
|
|
386
|
+
self: !!(flags & 2 /* Self */),
|
|
387
|
+
skipSelf: !!(flags & 4 /* SkipSelf */)
|
|
388
|
+
};
|
|
389
|
+
}
|
|
357
390
|
function injectArgs(types) {
|
|
358
391
|
const args = [];
|
|
359
392
|
for (let i = 0; i < types.length; i++) {
|
|
360
393
|
const arg = resolveForwardRef(types[i]);
|
|
361
394
|
if (Array.isArray(arg)) {
|
|
362
395
|
if (arg.length === 0) {
|
|
363
|
-
throw new RuntimeError(900 /* INVALID_DIFFER_INPUT */,
|
|
396
|
+
throw new RuntimeError(900 /* INVALID_DIFFER_INPUT */, void 0);
|
|
364
397
|
}
|
|
365
398
|
let type = void 0;
|
|
366
399
|
let flags = 0 /* Default */;
|
|
@@ -397,12 +430,7 @@ function catchInjectorError(e, token, injectorErrorName, source) {
|
|
|
397
430
|
if (token[SOURCE]) {
|
|
398
431
|
tokenPath.unshift(token[SOURCE]);
|
|
399
432
|
}
|
|
400
|
-
e.message = formatError(
|
|
401
|
-
"\n" + e.message,
|
|
402
|
-
tokenPath,
|
|
403
|
-
injectorErrorName,
|
|
404
|
-
source
|
|
405
|
-
);
|
|
433
|
+
e.message = formatError("\n" + e.message, tokenPath, injectorErrorName, source);
|
|
406
434
|
e[NG_TOKEN_PATH] = tokenPath;
|
|
407
435
|
e[NG_TEMP_TOKEN_PATH] = null;
|
|
408
436
|
throw e;
|
|
@@ -417,17 +445,12 @@ function formatError(text, obj, injectorErrorName, source = null) {
|
|
|
417
445
|
for (const key in obj) {
|
|
418
446
|
if (obj.hasOwnProperty(key)) {
|
|
419
447
|
const value = obj[key];
|
|
420
|
-
parts.push(
|
|
421
|
-
key + ":" + (typeof value === "string" ? JSON.stringify(value) : stringify(value))
|
|
422
|
-
);
|
|
448
|
+
parts.push(key + ":" + (typeof value === "string" ? JSON.stringify(value) : stringify(value)));
|
|
423
449
|
}
|
|
424
450
|
}
|
|
425
451
|
context = `{${parts.join(", ")}}`;
|
|
426
452
|
}
|
|
427
|
-
return `${injectorErrorName}${source ? "(" + source + ")" : ""}[${context}]: ${text.replace(
|
|
428
|
-
NEW_LINE,
|
|
429
|
-
"\n "
|
|
430
|
-
)}`;
|
|
453
|
+
return `${injectorErrorName}${source ? "(" + source + ")" : ""}[${context}]: ${text.replace(NEW_LINE, "\n ")}`;
|
|
431
454
|
}
|
|
432
455
|
|
|
433
456
|
// src/import/di/injector_token.ts
|
|
@@ -446,10 +469,7 @@ var INJECTOR_DEF_TYPES = new InjectionToken("");
|
|
|
446
469
|
var NullInjector = class {
|
|
447
470
|
get(token, notFoundValue = THROW_IF_NOT_FOUND) {
|
|
448
471
|
if (notFoundValue === THROW_IF_NOT_FOUND) {
|
|
449
|
-
const error = new
|
|
450
|
-
`NullInjectorError: No provider for ${stringify(token)}!`
|
|
451
|
-
);
|
|
452
|
-
error.name = "NullInjectorError";
|
|
472
|
+
const error = new NotFoundError(`NullInjectorError: No provider for ${stringify(token)}!`);
|
|
453
473
|
throw error;
|
|
454
474
|
}
|
|
455
475
|
return notFoundValue;
|
|
@@ -457,32 +477,6 @@ var NullInjector = class {
|
|
|
457
477
|
};
|
|
458
478
|
|
|
459
479
|
// src/import/di/provider_collection.ts
|
|
460
|
-
function importProvidersFrom(...sources) {
|
|
461
|
-
return {
|
|
462
|
-
ɵproviders: internalImportProvidersFrom(true, sources),
|
|
463
|
-
ɵfromNgModule: true
|
|
464
|
-
};
|
|
465
|
-
}
|
|
466
|
-
function internalImportProvidersFrom(checkForStandaloneCmp, ...sources) {
|
|
467
|
-
const providersOut = [];
|
|
468
|
-
const dedup = /* @__PURE__ */ new Set();
|
|
469
|
-
let injectorTypesWithProviders;
|
|
470
|
-
const collectProviders = (provider) => {
|
|
471
|
-
providersOut.push(provider);
|
|
472
|
-
};
|
|
473
|
-
if (injectorTypesWithProviders !== void 0) {
|
|
474
|
-
processInjectorTypesWithProviders(
|
|
475
|
-
injectorTypesWithProviders,
|
|
476
|
-
collectProviders
|
|
477
|
-
);
|
|
478
|
-
}
|
|
479
|
-
return providersOut;
|
|
480
|
-
}
|
|
481
|
-
function processInjectorTypesWithProviders(typesWithProviders, visitor) {
|
|
482
|
-
for (let i = 0; i < typesWithProviders.length; i++) {
|
|
483
|
-
const { ngModule, providers } = typesWithProviders[i];
|
|
484
|
-
}
|
|
485
|
-
}
|
|
486
480
|
var USE_VALUE = getClosureSafeProperty({
|
|
487
481
|
provide: String,
|
|
488
482
|
useValue: getClosureSafeProperty
|
|
@@ -521,23 +515,16 @@ var R3Injector = class extends EnvironmentInjector {
|
|
|
521
515
|
this.parent = parent;
|
|
522
516
|
this.source = source;
|
|
523
517
|
this.scopes = scopes;
|
|
524
|
-
forEachSingleProvider(
|
|
525
|
-
providers,
|
|
526
|
-
(provider) => this.processProvider(provider)
|
|
527
|
-
);
|
|
518
|
+
forEachSingleProvider(providers, (provider) => this.processProvider(provider));
|
|
528
519
|
this.records.set(INJECTOR, makeRecord(void 0, this));
|
|
529
520
|
if (scopes.has("environment")) {
|
|
530
521
|
this.records.set(EnvironmentInjector, makeRecord(void 0, this));
|
|
531
522
|
}
|
|
532
|
-
const record = this.records.get(
|
|
533
|
-
INJECTOR_SCOPE
|
|
534
|
-
);
|
|
523
|
+
const record = this.records.get(INJECTOR_SCOPE);
|
|
535
524
|
if (record != null && typeof record.value === "string") {
|
|
536
525
|
this.scopes.add(record.value);
|
|
537
526
|
}
|
|
538
|
-
this.injectorDefTypes = new Set(
|
|
539
|
-
this.get(INJECTOR_DEF_TYPES, EMPTY_ARRAY, 2 /* Self */)
|
|
540
|
-
);
|
|
527
|
+
this.injectorDefTypes = new Set(this.get(INJECTOR_DEF_TYPES, EMPTY_ARRAY, { self: true }));
|
|
541
528
|
}
|
|
542
529
|
/**
|
|
543
530
|
* Map of tokens to records which contain the instances of those tokens.
|
|
@@ -558,6 +545,22 @@ var R3Injector = class extends EnvironmentInjector {
|
|
|
558
545
|
}
|
|
559
546
|
_destroyed = false;
|
|
560
547
|
injectorDefTypes;
|
|
548
|
+
retrieve(token, options) {
|
|
549
|
+
const flags = convertToBitFlags(options) || 0 /* Default */;
|
|
550
|
+
try {
|
|
551
|
+
return this.get(
|
|
552
|
+
token,
|
|
553
|
+
// When a dependency is requested with an optional flag, DI returns null as the default value.
|
|
554
|
+
THROW_IF_NOT_FOUND,
|
|
555
|
+
flags
|
|
556
|
+
);
|
|
557
|
+
} catch (e) {
|
|
558
|
+
if (isNotFound(e)) {
|
|
559
|
+
return e;
|
|
560
|
+
}
|
|
561
|
+
throw e;
|
|
562
|
+
}
|
|
563
|
+
}
|
|
561
564
|
/**
|
|
562
565
|
* Destroy the injector and release references to every instance or provider associated with it.
|
|
563
566
|
*
|
|
@@ -600,12 +603,12 @@ var R3Injector = class extends EnvironmentInjector {
|
|
|
600
603
|
setInjectImplementation(previousInjectImplementation);
|
|
601
604
|
}
|
|
602
605
|
}
|
|
603
|
-
get(token, notFoundValue = THROW_IF_NOT_FOUND,
|
|
606
|
+
get(token, notFoundValue = THROW_IF_NOT_FOUND, options) {
|
|
604
607
|
assertNotDestroyed(this);
|
|
605
608
|
if (token.hasOwnProperty(NG_ENV_ID)) {
|
|
606
609
|
return token[NG_ENV_ID](this);
|
|
607
610
|
}
|
|
608
|
-
flags = convertToBitFlags(
|
|
611
|
+
const flags = convertToBitFlags(options);
|
|
609
612
|
if (false) {
|
|
610
613
|
}
|
|
611
614
|
const previousInjector = setCurrentInjector(this);
|
|
@@ -618,10 +621,7 @@ var R3Injector = class extends EnvironmentInjector {
|
|
|
618
621
|
if (def && this.injectableDefInScope(def)) {
|
|
619
622
|
if (false) {
|
|
620
623
|
}
|
|
621
|
-
record = makeRecord(
|
|
622
|
-
injectableDefOrInjectorDefFactory(token),
|
|
623
|
-
NOT_YET
|
|
624
|
-
);
|
|
624
|
+
record = makeRecord(injectableDefOrInjectorDefFactory(token), NOT_YET);
|
|
625
625
|
} else {
|
|
626
626
|
record = null;
|
|
627
627
|
}
|
|
@@ -635,7 +635,7 @@ var R3Injector = class extends EnvironmentInjector {
|
|
|
635
635
|
notFoundValue = flags & 8 /* Optional */ && notFoundValue === THROW_IF_NOT_FOUND ? null : notFoundValue;
|
|
636
636
|
return nextInjector.get(token, notFoundValue);
|
|
637
637
|
} catch (e) {
|
|
638
|
-
if (e
|
|
638
|
+
if (isNotFound(e)) {
|
|
639
639
|
const path = e[NG_TEMP_TOKEN_PATH] = e[NG_TEMP_TOKEN_PATH] || [];
|
|
640
640
|
path.unshift(stringify(token));
|
|
641
641
|
if (previousInjector) {
|
|
@@ -658,11 +658,7 @@ var R3Injector = class extends EnvironmentInjector {
|
|
|
658
658
|
if (false) {
|
|
659
659
|
}
|
|
660
660
|
try {
|
|
661
|
-
const initializers = this.get(
|
|
662
|
-
ENVIRONMENT_INITIALIZER,
|
|
663
|
-
EMPTY_ARRAY,
|
|
664
|
-
2 /* Self */
|
|
665
|
-
);
|
|
661
|
+
const initializers = this.get(ENVIRONMENT_INITIALIZER, EMPTY_ARRAY, { self: true });
|
|
666
662
|
if (false) {
|
|
667
663
|
}
|
|
668
664
|
for (const initializer of initializers) {
|
|
@@ -710,7 +706,8 @@ var R3Injector = class extends EnvironmentInjector {
|
|
|
710
706
|
}
|
|
711
707
|
hydrate(token, record) {
|
|
712
708
|
try {
|
|
713
|
-
if (
|
|
709
|
+
if (record.value === CIRCULAR) {
|
|
710
|
+
throwCyclicDependencyError(stringify(token));
|
|
714
711
|
} else if (record.value === NOT_YET) {
|
|
715
712
|
record.value = CIRCULAR;
|
|
716
713
|
if (false) {
|
|
@@ -750,17 +747,17 @@ function injectableDefOrInjectorDefFactory(token) {
|
|
|
750
747
|
return factory;
|
|
751
748
|
}
|
|
752
749
|
if (token instanceof InjectionToken) {
|
|
753
|
-
throw new RuntimeError(204 /* INVALID_INJECTION_TOKEN */,
|
|
750
|
+
throw new RuntimeError(204 /* INVALID_INJECTION_TOKEN */, void 0);
|
|
754
751
|
}
|
|
755
752
|
if (token instanceof Function) {
|
|
756
753
|
return getUndecoratedInjectableFactory(token);
|
|
757
754
|
}
|
|
758
|
-
throw new RuntimeError(204 /* INVALID_INJECTION_TOKEN */,
|
|
755
|
+
throw new RuntimeError(204 /* INVALID_INJECTION_TOKEN */, void 0);
|
|
759
756
|
}
|
|
760
757
|
function getUndecoratedInjectableFactory(token) {
|
|
761
758
|
const paramLength = token.length;
|
|
762
759
|
if (paramLength > 0) {
|
|
763
|
-
throw new RuntimeError(204 /* INVALID_INJECTION_TOKEN */,
|
|
760
|
+
throw new RuntimeError(204 /* INVALID_INJECTION_TOKEN */, void 0);
|
|
764
761
|
}
|
|
765
762
|
const inheritedInjectableDef = getInheritedInjectableDef(token);
|
|
766
763
|
if (inheritedInjectableDef !== null) {
|
|
@@ -792,9 +789,7 @@ function providerToFactory(provider, ngModuleType, providers) {
|
|
|
792
789
|
} else if (isExistingProvider(provider)) {
|
|
793
790
|
factory = () => ɵɵinject(resolveForwardRef(provider.useExisting));
|
|
794
791
|
} else {
|
|
795
|
-
const classRef = resolveForwardRef(
|
|
796
|
-
provider && (provider.useClass || provider.provide)
|
|
797
|
-
);
|
|
792
|
+
const classRef = resolveForwardRef(provider && (provider.useClass || provider.provide));
|
|
798
793
|
if (false) {
|
|
799
794
|
}
|
|
800
795
|
if (hasDeps(provider)) {
|
|
@@ -808,7 +803,7 @@ function providerToFactory(provider, ngModuleType, providers) {
|
|
|
808
803
|
}
|
|
809
804
|
function assertNotDestroyed(injector) {
|
|
810
805
|
if (injector.destroyed) {
|
|
811
|
-
throw new RuntimeError(205 /* INJECTOR_ALREADY_DESTROYED */,
|
|
806
|
+
throw new RuntimeError(205 /* INJECTOR_ALREADY_DESTROYED */, void 0);
|
|
812
807
|
}
|
|
813
808
|
}
|
|
814
809
|
function makeRecord(factory, value, multi = false) {
|
|
@@ -825,7 +820,7 @@ function hasOnDestroy(value) {
|
|
|
825
820
|
return value !== null && typeof value === "object" && typeof value.ngOnDestroy === "function";
|
|
826
821
|
}
|
|
827
822
|
function couldBeInjectableType(value) {
|
|
828
|
-
return typeof value === "function" || typeof value === "object" && value
|
|
823
|
+
return typeof value === "function" || typeof value === "object" && value.ngMetadataName === "InjectionToken";
|
|
829
824
|
}
|
|
830
825
|
function forEachSingleProvider(providers, fn) {
|
|
831
826
|
for (const provider of providers) {
|
|
@@ -878,10 +873,7 @@ var Inject = attachInjectFlag(
|
|
|
878
873
|
var Optional = (
|
|
879
874
|
// Disable tslint because `InternalInjectFlags` is a const enum which gets inlined.
|
|
880
875
|
// tslint:disable-next-line: no-toplevel-property-access
|
|
881
|
-
attachInjectFlag(
|
|
882
|
-
makeParamDecorator("Optional"),
|
|
883
|
-
8 /* Optional */
|
|
884
|
-
)
|
|
876
|
+
attachInjectFlag(makeParamDecorator("Optional"), 8 /* Optional */)
|
|
885
877
|
);
|
|
886
878
|
var Self = (
|
|
887
879
|
// Disable tslint because `InternalInjectFlags` is a const enum which gets inlined.
|
|
@@ -891,35 +883,19 @@ var Self = (
|
|
|
891
883
|
var SkipSelf = (
|
|
892
884
|
// Disable tslint because `InternalInjectFlags` is a const enum which gets inlined.
|
|
893
885
|
// tslint:disable-next-line: no-toplevel-property-access
|
|
894
|
-
attachInjectFlag(
|
|
895
|
-
makeParamDecorator("SkipSelf"),
|
|
896
|
-
4 /* SkipSelf */
|
|
897
|
-
)
|
|
886
|
+
attachInjectFlag(makeParamDecorator("SkipSelf"), 4 /* SkipSelf */)
|
|
898
887
|
);
|
|
899
888
|
|
|
900
889
|
// src/import/di/create_injector.ts
|
|
901
890
|
function createInjector(defType, parent = null, additionalProviders = null, name) {
|
|
902
|
-
const injector = createInjectorWithoutInjectorInstances(
|
|
903
|
-
defType,
|
|
904
|
-
parent,
|
|
905
|
-
additionalProviders,
|
|
906
|
-
name
|
|
907
|
-
);
|
|
891
|
+
const injector = createInjectorWithoutInjectorInstances(defType, parent, additionalProviders, name);
|
|
908
892
|
injector.resolveInjectorInitializers();
|
|
909
893
|
return injector;
|
|
910
894
|
}
|
|
911
895
|
function createInjectorWithoutInjectorInstances(defType, parent = null, additionalProviders = null, name, scopes = /* @__PURE__ */ new Set()) {
|
|
912
|
-
const providers = [
|
|
913
|
-
additionalProviders || EMPTY_ARRAY,
|
|
914
|
-
importProvidersFrom(defType)
|
|
915
|
-
];
|
|
896
|
+
const providers = [additionalProviders || EMPTY_ARRAY];
|
|
916
897
|
name = name || (typeof defType === "object" ? void 0 : stringify(defType));
|
|
917
|
-
return new R3Injector(
|
|
918
|
-
providers,
|
|
919
|
-
parent || getNullInjector(),
|
|
920
|
-
name || null,
|
|
921
|
-
scopes
|
|
922
|
-
);
|
|
898
|
+
return new R3Injector(providers, parent || getNullInjector(), name || null, scopes);
|
|
923
899
|
}
|
|
924
900
|
|
|
925
901
|
// src/import/di/injector.ts
|
|
@@ -965,6 +941,7 @@ function defaultEquals(a, b) {
|
|
|
965
941
|
var activeConsumer = null;
|
|
966
942
|
var inNotificationPhase = false;
|
|
967
943
|
var epoch = 1;
|
|
944
|
+
var postProducerCreatedFn = null;
|
|
968
945
|
var SIGNAL = /* @__PURE__ */ Symbol("SIGNAL");
|
|
969
946
|
function setActiveConsumer(consumer) {
|
|
970
947
|
const prev = activeConsumer;
|
|
@@ -974,9 +951,6 @@ function setActiveConsumer(consumer) {
|
|
|
974
951
|
function getActiveConsumer() {
|
|
975
952
|
return activeConsumer;
|
|
976
953
|
}
|
|
977
|
-
function isInNotificationPhase() {
|
|
978
|
-
return inNotificationPhase;
|
|
979
|
-
}
|
|
980
954
|
var REACTIVE_NODE = {
|
|
981
955
|
version: 0,
|
|
982
956
|
lastCleanEpoch: 0,
|
|
@@ -1000,9 +974,7 @@ var REACTIVE_NODE = {
|
|
|
1000
974
|
};
|
|
1001
975
|
function producerAccessed(node) {
|
|
1002
976
|
if (inNotificationPhase) {
|
|
1003
|
-
throw new Error(
|
|
1004
|
-
false ? `Assertion error: signal read during notification phase` : ""
|
|
1005
|
-
);
|
|
977
|
+
throw new Error(false ? `Assertion error: signal read during notification phase` : "");
|
|
1006
978
|
}
|
|
1007
979
|
if (activeConsumer === null) {
|
|
1008
980
|
return;
|
|
@@ -1013,10 +985,7 @@ function producerAccessed(node) {
|
|
|
1013
985
|
if (idx < activeConsumer.producerNode.length && activeConsumer.producerNode[idx] !== node) {
|
|
1014
986
|
if (consumerIsLive(activeConsumer)) {
|
|
1015
987
|
const staleProducer = activeConsumer.producerNode[idx];
|
|
1016
|
-
producerRemoveLiveConsumerAtIndex(
|
|
1017
|
-
staleProducer,
|
|
1018
|
-
activeConsumer.producerIndexOfThis[idx]
|
|
1019
|
-
);
|
|
988
|
+
producerRemoveLiveConsumerAtIndex(staleProducer, activeConsumer.producerIndexOfThis[idx]);
|
|
1020
989
|
}
|
|
1021
990
|
}
|
|
1022
991
|
if (activeConsumer.producerNode[idx] !== node) {
|
|
@@ -1081,10 +1050,7 @@ function consumerAfterComputation(node, prevConsumer) {
|
|
|
1081
1050
|
}
|
|
1082
1051
|
if (consumerIsLive(node)) {
|
|
1083
1052
|
for (let i = node.nextProducerIndex; i < node.producerNode.length; i++) {
|
|
1084
|
-
producerRemoveLiveConsumerAtIndex(
|
|
1085
|
-
node.producerNode[i],
|
|
1086
|
-
node.producerIndexOfThis[i]
|
|
1087
|
-
);
|
|
1053
|
+
producerRemoveLiveConsumerAtIndex(node.producerNode[i], node.producerIndexOfThis[i]);
|
|
1088
1054
|
}
|
|
1089
1055
|
}
|
|
1090
1056
|
while (node.producerNode.length > node.nextProducerIndex) {
|
|
@@ -1112,10 +1078,7 @@ function consumerDestroy(node) {
|
|
|
1112
1078
|
assertConsumerNode(node);
|
|
1113
1079
|
if (consumerIsLive(node)) {
|
|
1114
1080
|
for (let i = 0; i < node.producerNode.length; i++) {
|
|
1115
|
-
producerRemoveLiveConsumerAtIndex(
|
|
1116
|
-
node.producerNode[i],
|
|
1117
|
-
node.producerIndexOfThis[i]
|
|
1118
|
-
);
|
|
1081
|
+
producerRemoveLiveConsumerAtIndex(node.producerNode[i], node.producerIndexOfThis[i]);
|
|
1119
1082
|
}
|
|
1120
1083
|
}
|
|
1121
1084
|
node.producerNode.length = node.producerLastReadVersion.length = node.producerIndexOfThis.length = 0;
|
|
@@ -1127,11 +1090,7 @@ function producerAddLiveConsumer(node, consumer, indexOfThis) {
|
|
|
1127
1090
|
assertProducerNode(node);
|
|
1128
1091
|
if (node.liveConsumerNode.length === 0 && isConsumerNode(node)) {
|
|
1129
1092
|
for (let i = 0; i < node.producerNode.length; i++) {
|
|
1130
|
-
node.producerIndexOfThis[i] = producerAddLiveConsumer(
|
|
1131
|
-
node.producerNode[i],
|
|
1132
|
-
node,
|
|
1133
|
-
i
|
|
1134
|
-
);
|
|
1093
|
+
node.producerIndexOfThis[i] = producerAddLiveConsumer(node.producerNode[i], node, i);
|
|
1135
1094
|
}
|
|
1136
1095
|
}
|
|
1137
1096
|
node.liveConsumerIndexOfThis.push(indexOfThis);
|
|
@@ -1140,16 +1099,11 @@ function producerAddLiveConsumer(node, consumer, indexOfThis) {
|
|
|
1140
1099
|
function producerRemoveLiveConsumerAtIndex(node, idx) {
|
|
1141
1100
|
assertProducerNode(node);
|
|
1142
1101
|
if (false) {
|
|
1143
|
-
throw new Error(
|
|
1144
|
-
`Assertion error: active consumer index ${idx} is out of bounds of ${node.liveConsumerNode.length} consumers)`
|
|
1145
|
-
);
|
|
1102
|
+
throw new Error(`Assertion error: active consumer index ${idx} is out of bounds of ${node.liveConsumerNode.length} consumers)`);
|
|
1146
1103
|
}
|
|
1147
1104
|
if (node.liveConsumerNode.length === 1 && isConsumerNode(node)) {
|
|
1148
1105
|
for (let i = 0; i < node.producerNode.length; i++) {
|
|
1149
|
-
producerRemoveLiveConsumerAtIndex(
|
|
1150
|
-
node.producerNode[i],
|
|
1151
|
-
node.producerIndexOfThis[i]
|
|
1152
|
-
);
|
|
1106
|
+
producerRemoveLiveConsumerAtIndex(node.producerNode[i], node.producerIndexOfThis[i]);
|
|
1153
1107
|
}
|
|
1154
1108
|
}
|
|
1155
1109
|
const lastIdx = node.liveConsumerNode.length - 1;
|
|
@@ -1179,11 +1133,17 @@ function assertProducerNode(node) {
|
|
|
1179
1133
|
function isConsumerNode(node) {
|
|
1180
1134
|
return node.producerNode !== void 0;
|
|
1181
1135
|
}
|
|
1136
|
+
function runPostProducerCreatedFn(node) {
|
|
1137
|
+
postProducerCreatedFn?.(node);
|
|
1138
|
+
}
|
|
1182
1139
|
|
|
1183
1140
|
// src/primitives/signals/src/computed.ts
|
|
1184
|
-
function createComputed(computation) {
|
|
1141
|
+
function createComputed(computation, equal) {
|
|
1185
1142
|
const node = Object.create(COMPUTED_NODE);
|
|
1186
1143
|
node.computation = computation;
|
|
1144
|
+
if (equal !== void 0) {
|
|
1145
|
+
node.equal = equal;
|
|
1146
|
+
}
|
|
1187
1147
|
const computed2 = () => {
|
|
1188
1148
|
producerUpdateValueVersion(node);
|
|
1189
1149
|
producerAccessed(node);
|
|
@@ -1193,6 +1153,11 @@ function createComputed(computation) {
|
|
|
1193
1153
|
return node.value;
|
|
1194
1154
|
};
|
|
1195
1155
|
computed2[SIGNAL] = node;
|
|
1156
|
+
if (false) {
|
|
1157
|
+
const debugName = node.debugName ? " (" + node.debugName + ")" : "";
|
|
1158
|
+
computed2.toString = () => `[Computed${debugName}: ${node.value}]`;
|
|
1159
|
+
}
|
|
1160
|
+
runPostProducerCreatedFn(node);
|
|
1196
1161
|
return computed2;
|
|
1197
1162
|
}
|
|
1198
1163
|
var UNSET = /* @__PURE__ */ Symbol("UNSET");
|
|
@@ -1210,7 +1175,7 @@ var COMPUTED_NODE = /* @__PURE__ */ (() => ({
|
|
|
1210
1175
|
},
|
|
1211
1176
|
producerRecomputeValue(node) {
|
|
1212
1177
|
if (node.value === COMPUTING) {
|
|
1213
|
-
throw new Error("Detected cycle in computations.");
|
|
1178
|
+
throw new Error(false ? "Detected cycle in computations." : "");
|
|
1214
1179
|
}
|
|
1215
1180
|
const oldValue = node.value;
|
|
1216
1181
|
node.value = COMPUTING;
|
|
@@ -1247,15 +1212,26 @@ function throwInvalidWriteToSignalError(node) {
|
|
|
1247
1212
|
|
|
1248
1213
|
// src/primitives/signals/src/signal.ts
|
|
1249
1214
|
var postSignalSetFn = null;
|
|
1250
|
-
function createSignal(initialValue) {
|
|
1215
|
+
function createSignal(initialValue, equal) {
|
|
1251
1216
|
const node = Object.create(SIGNAL_NODE);
|
|
1252
1217
|
node.value = initialValue;
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1218
|
+
if (equal !== void 0) {
|
|
1219
|
+
node.equal = equal;
|
|
1220
|
+
}
|
|
1221
|
+
const getter = () => signalGetFn(node);
|
|
1257
1222
|
getter[SIGNAL] = node;
|
|
1258
|
-
|
|
1223
|
+
if (false) {
|
|
1224
|
+
const debugName = node.debugName ? " (" + node.debugName + ")" : "";
|
|
1225
|
+
getter.toString = () => `[Signal${debugName}: ${node.value}]`;
|
|
1226
|
+
}
|
|
1227
|
+
runPostProducerCreatedFn(node);
|
|
1228
|
+
const set = (newValue) => signalSetFn(node, newValue);
|
|
1229
|
+
const update = (updateFn) => signalUpdateFn(node, updateFn);
|
|
1230
|
+
return [getter, set, update];
|
|
1231
|
+
}
|
|
1232
|
+
function signalGetFn(node) {
|
|
1233
|
+
producerAccessed(node);
|
|
1234
|
+
return node.value;
|
|
1259
1235
|
}
|
|
1260
1236
|
function signalSetFn(node, newValue) {
|
|
1261
1237
|
if (!producerUpdatesAllowed()) {
|
|
@@ -1282,7 +1258,7 @@ function signalValueChanged(node) {
|
|
|
1282
1258
|
node.version++;
|
|
1283
1259
|
producerIncrementEpoch();
|
|
1284
1260
|
producerNotifyConsumers(node);
|
|
1285
|
-
postSignalSetFn?.();
|
|
1261
|
+
postSignalSetFn?.(node);
|
|
1286
1262
|
}
|
|
1287
1263
|
|
|
1288
1264
|
// src/primitives/signals/src/linked_signal.ts
|
|
@@ -1303,6 +1279,11 @@ function createLinkedSignal(sourceFn, computationFn, equalityFn) {
|
|
|
1303
1279
|
};
|
|
1304
1280
|
const getter = linkedSignalGetter;
|
|
1305
1281
|
getter[SIGNAL] = node;
|
|
1282
|
+
if (false) {
|
|
1283
|
+
const debugName = node.debugName ? " (" + node.debugName + ")" : "";
|
|
1284
|
+
getter.toString = () => `[LinkedSignal${debugName}: ${node.value}]`;
|
|
1285
|
+
}
|
|
1286
|
+
runPostProducerCreatedFn(node);
|
|
1306
1287
|
return getter;
|
|
1307
1288
|
}
|
|
1308
1289
|
function linkedSignalSetFn(node, newValue) {
|
|
@@ -1321,12 +1302,13 @@ var LINKED_SIGNAL_NODE = /* @__PURE__ */ (() => ({
|
|
|
1321
1302
|
dirty: true,
|
|
1322
1303
|
error: null,
|
|
1323
1304
|
equal: defaultEquals,
|
|
1305
|
+
kind: "linkedSignal",
|
|
1324
1306
|
producerMustRecompute(node) {
|
|
1325
1307
|
return node.value === UNSET || node.value === COMPUTING;
|
|
1326
1308
|
},
|
|
1327
1309
|
producerRecomputeValue(node) {
|
|
1328
1310
|
if (node.value === COMPUTING) {
|
|
1329
|
-
throw new Error("Detected cycle in computations.");
|
|
1311
|
+
throw new Error(false ? "Detected cycle in computations." : "");
|
|
1330
1312
|
}
|
|
1331
1313
|
const oldValue = node.value;
|
|
1332
1314
|
node.value = COMPUTING;
|
|
@@ -1355,75 +1337,15 @@ var LINKED_SIGNAL_NODE = /* @__PURE__ */ (() => ({
|
|
|
1355
1337
|
}
|
|
1356
1338
|
}))();
|
|
1357
1339
|
|
|
1358
|
-
// src/primitives/signals/src/
|
|
1359
|
-
function
|
|
1360
|
-
const
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
}
|
|
1364
|
-
|
|
1365
|
-
node.schedule = schedule;
|
|
1366
|
-
const registerOnCleanup = (cleanupFn) => {
|
|
1367
|
-
node.cleanupFn = cleanupFn;
|
|
1368
|
-
};
|
|
1369
|
-
function isWatchNodeDestroyed(node2) {
|
|
1370
|
-
return node2.fn === null && node2.schedule === null;
|
|
1371
|
-
}
|
|
1372
|
-
function destroyWatchNode(node2) {
|
|
1373
|
-
if (!isWatchNodeDestroyed(node2)) {
|
|
1374
|
-
consumerDestroy(node2);
|
|
1375
|
-
node2.cleanupFn();
|
|
1376
|
-
node2.fn = null;
|
|
1377
|
-
node2.schedule = null;
|
|
1378
|
-
node2.cleanupFn = NOOP_CLEANUP_FN;
|
|
1379
|
-
}
|
|
1340
|
+
// src/primitives/signals/src/untracked.ts
|
|
1341
|
+
function untracked(nonReactiveReadsFn) {
|
|
1342
|
+
const prevConsumer = setActiveConsumer(null);
|
|
1343
|
+
try {
|
|
1344
|
+
return nonReactiveReadsFn();
|
|
1345
|
+
} finally {
|
|
1346
|
+
setActiveConsumer(prevConsumer);
|
|
1380
1347
|
}
|
|
1381
|
-
const run = () => {
|
|
1382
|
-
if (node.fn === null) {
|
|
1383
|
-
return;
|
|
1384
|
-
}
|
|
1385
|
-
if (isInNotificationPhase()) {
|
|
1386
|
-
throw new Error(
|
|
1387
|
-
`Schedulers cannot synchronously execute watches while scheduling.`
|
|
1388
|
-
);
|
|
1389
|
-
}
|
|
1390
|
-
node.dirty = false;
|
|
1391
|
-
if (node.hasRun && !consumerPollProducersForChange(node)) {
|
|
1392
|
-
return;
|
|
1393
|
-
}
|
|
1394
|
-
node.hasRun = true;
|
|
1395
|
-
const prevConsumer = consumerBeforeComputation(node);
|
|
1396
|
-
try {
|
|
1397
|
-
node.cleanupFn();
|
|
1398
|
-
node.cleanupFn = NOOP_CLEANUP_FN;
|
|
1399
|
-
node.fn(registerOnCleanup);
|
|
1400
|
-
} finally {
|
|
1401
|
-
consumerAfterComputation(node, prevConsumer);
|
|
1402
|
-
}
|
|
1403
|
-
};
|
|
1404
|
-
node.ref = {
|
|
1405
|
-
notify: () => consumerMarkDirty(node),
|
|
1406
|
-
run,
|
|
1407
|
-
cleanup: () => node.cleanupFn(),
|
|
1408
|
-
destroy: () => destroyWatchNode(node),
|
|
1409
|
-
[SIGNAL]: node
|
|
1410
|
-
};
|
|
1411
|
-
return node.ref;
|
|
1412
1348
|
}
|
|
1413
|
-
var NOOP_CLEANUP_FN = () => {
|
|
1414
|
-
};
|
|
1415
|
-
var WATCH_NODE = /* @__PURE__ */ (() => ({
|
|
1416
|
-
...REACTIVE_NODE,
|
|
1417
|
-
consumerIsAlwaysLive: true,
|
|
1418
|
-
consumerAllowSignalWrites: false,
|
|
1419
|
-
consumerMarkedDirty: (node) => {
|
|
1420
|
-
if (node.schedule !== null) {
|
|
1421
|
-
node.schedule(node.ref);
|
|
1422
|
-
}
|
|
1423
|
-
},
|
|
1424
|
-
hasRun: false,
|
|
1425
|
-
cleanupFn: NOOP_CLEANUP_FN
|
|
1426
|
-
}))();
|
|
1427
1349
|
|
|
1428
1350
|
// src/import/render3/reactivity/api.ts
|
|
1429
1351
|
function isSignal(value) {
|
|
@@ -1432,10 +1354,7 @@ function isSignal(value) {
|
|
|
1432
1354
|
|
|
1433
1355
|
// src/import/render3/reactivity/computed.ts
|
|
1434
1356
|
function computed(computation, options) {
|
|
1435
|
-
const getter = createComputed(computation);
|
|
1436
|
-
if (options?.equal) {
|
|
1437
|
-
getter[SIGNAL].equal = options.equal;
|
|
1438
|
-
}
|
|
1357
|
+
const getter = createComputed(computation, options?.equal);
|
|
1439
1358
|
if (false) {
|
|
1440
1359
|
}
|
|
1441
1360
|
return getter;
|
|
@@ -1446,16 +1365,12 @@ function ɵunwrapWritableSignal(value) {
|
|
|
1446
1365
|
return null;
|
|
1447
1366
|
}
|
|
1448
1367
|
function signal(initialValue, options) {
|
|
1449
|
-
const
|
|
1368
|
+
const [get, set, update] = createSignal(initialValue, options?.equal);
|
|
1369
|
+
const signalFn = get;
|
|
1450
1370
|
const node = signalFn[SIGNAL];
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
signalFn.set = (newValue) => signalSetFn(node, newValue);
|
|
1455
|
-
signalFn.update = (updateFn) => signalUpdateFn(node, updateFn);
|
|
1456
|
-
signalFn.asReadonly = signalAsReadonlyFn.bind(
|
|
1457
|
-
signalFn
|
|
1458
|
-
);
|
|
1371
|
+
signalFn.set = set;
|
|
1372
|
+
signalFn.update = update;
|
|
1373
|
+
signalFn.asReadonly = signalAsReadonlyFn.bind(signalFn);
|
|
1459
1374
|
if (false) {
|
|
1460
1375
|
}
|
|
1461
1376
|
return signalFn;
|
|
@@ -1474,18 +1389,10 @@ function signalAsReadonlyFn() {
|
|
|
1474
1389
|
var identityFn = (v) => v;
|
|
1475
1390
|
function linkedSignal(optionsOrComputation, options) {
|
|
1476
1391
|
if (typeof optionsOrComputation === "function") {
|
|
1477
|
-
const getter = createLinkedSignal(
|
|
1478
|
-
optionsOrComputation,
|
|
1479
|
-
identityFn,
|
|
1480
|
-
options?.equal
|
|
1481
|
-
);
|
|
1392
|
+
const getter = createLinkedSignal(optionsOrComputation, identityFn, options?.equal);
|
|
1482
1393
|
return upgradeLinkedSignalGetter(getter);
|
|
1483
1394
|
} else {
|
|
1484
|
-
const getter = createLinkedSignal(
|
|
1485
|
-
optionsOrComputation.source,
|
|
1486
|
-
optionsOrComputation.computation,
|
|
1487
|
-
optionsOrComputation.equal
|
|
1488
|
-
);
|
|
1395
|
+
const getter = createLinkedSignal(optionsOrComputation.source, optionsOrComputation.computation, optionsOrComputation.equal);
|
|
1489
1396
|
return upgradeLinkedSignalGetter(getter);
|
|
1490
1397
|
}
|
|
1491
1398
|
}
|
|
@@ -1496,39 +1403,19 @@ function upgradeLinkedSignalGetter(getter) {
|
|
|
1496
1403
|
const upgradedGetter = getter;
|
|
1497
1404
|
upgradedGetter.set = (newValue) => linkedSignalSetFn(node, newValue);
|
|
1498
1405
|
upgradedGetter.update = (updateFn) => linkedSignalUpdateFn(node, updateFn);
|
|
1499
|
-
upgradedGetter.asReadonly = signalAsReadonlyFn.bind(
|
|
1500
|
-
getter
|
|
1501
|
-
);
|
|
1406
|
+
upgradedGetter.asReadonly = signalAsReadonlyFn.bind(getter);
|
|
1502
1407
|
return upgradedGetter;
|
|
1503
1408
|
}
|
|
1504
1409
|
|
|
1505
1410
|
// src/import/render3/reactivity/untracked.ts
|
|
1506
|
-
function
|
|
1507
|
-
|
|
1508
|
-
try {
|
|
1509
|
-
return nonReactiveReadsFn();
|
|
1510
|
-
} finally {
|
|
1511
|
-
setActiveConsumer(prevConsumer);
|
|
1512
|
-
}
|
|
1411
|
+
function untracked2(nonReactiveReadsFn) {
|
|
1412
|
+
return untracked(nonReactiveReadsFn);
|
|
1513
1413
|
}
|
|
1514
1414
|
|
|
1515
1415
|
// src/import/render3/reactivity/asserts.ts
|
|
1516
1416
|
function assertNotInReactiveContext(debugFn, extraContext) {
|
|
1517
1417
|
if (getActiveConsumer() !== null) {
|
|
1518
|
-
throw new RuntimeError(
|
|
1519
|
-
-602 /* ASSERTION_NOT_INSIDE_REACTIVE_CONTEXT */,
|
|
1520
|
-
null
|
|
1521
|
-
);
|
|
1522
|
-
}
|
|
1523
|
-
}
|
|
1524
|
-
|
|
1525
|
-
// src/import/di/contextual.ts
|
|
1526
|
-
function isInInjectionContext() {
|
|
1527
|
-
return getInjectImplementation() !== void 0 || getCurrentInjector() != null;
|
|
1528
|
-
}
|
|
1529
|
-
function assertInInjectionContext(debugFn) {
|
|
1530
|
-
if (!isInInjectionContext()) {
|
|
1531
|
-
throw new RuntimeError(-203 /* MISSING_INJECTION_CONTEXT */, null);
|
|
1418
|
+
throw new RuntimeError(-602 /* ASSERTION_NOT_INSIDE_REACTIVE_CONTEXT */, void 0);
|
|
1532
1419
|
}
|
|
1533
1420
|
}
|
|
1534
1421
|
|
|
@@ -1569,20 +1456,10 @@ var NotificationSource = /* @__PURE__ */ ((NotificationSource2) => {
|
|
|
1569
1456
|
})(NotificationSource || {});
|
|
1570
1457
|
var ChangeDetectionScheduler = class {
|
|
1571
1458
|
};
|
|
1572
|
-
var ZONELESS_ENABLED = new InjectionToken(
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
);
|
|
1576
|
-
var PROVIDED_ZONELESS = new InjectionToken(
|
|
1577
|
-
false ? "Zoneless provided" : "",
|
|
1578
|
-
{ providedIn: "root", factory: () => false }
|
|
1579
|
-
);
|
|
1580
|
-
var ZONELESS_SCHEDULER_DISABLED = new InjectionToken(
|
|
1581
|
-
false ? "scheduler disabled" : ""
|
|
1582
|
-
);
|
|
1583
|
-
var SCHEDULE_IN_ROOT_ZONE = new InjectionToken(
|
|
1584
|
-
false ? "run changes outside zone in root" : ""
|
|
1585
|
-
);
|
|
1459
|
+
var ZONELESS_ENABLED = new InjectionToken("", { providedIn: "root", factory: () => false });
|
|
1460
|
+
var PROVIDED_ZONELESS = new InjectionToken("", { providedIn: "root", factory: () => false });
|
|
1461
|
+
var ZONELESS_SCHEDULER_DISABLED = new InjectionToken("");
|
|
1462
|
+
var SCHEDULE_IN_ROOT_ZONE = new InjectionToken("");
|
|
1586
1463
|
|
|
1587
1464
|
// src/import/render3/reactivity/root_effect_scheduler.ts
|
|
1588
1465
|
var EffectScheduler = class _EffectScheduler {
|
|
@@ -1597,10 +1474,17 @@ var EffectScheduler = class _EffectScheduler {
|
|
|
1597
1474
|
);
|
|
1598
1475
|
};
|
|
1599
1476
|
var ZoneAwareEffectScheduler = class {
|
|
1600
|
-
|
|
1477
|
+
dirtyEffectCount = 0;
|
|
1601
1478
|
queues = /* @__PURE__ */ new Map();
|
|
1602
|
-
|
|
1479
|
+
add(handle) {
|
|
1603
1480
|
this.enqueue(handle);
|
|
1481
|
+
this.schedule(handle);
|
|
1482
|
+
}
|
|
1483
|
+
schedule(handle) {
|
|
1484
|
+
if (!handle.dirty) {
|
|
1485
|
+
return;
|
|
1486
|
+
}
|
|
1487
|
+
this.dirtyEffectCount++;
|
|
1604
1488
|
}
|
|
1605
1489
|
remove(handle) {
|
|
1606
1490
|
const zone = handle.zone;
|
|
@@ -1609,7 +1493,9 @@ var ZoneAwareEffectScheduler = class {
|
|
|
1609
1493
|
return;
|
|
1610
1494
|
}
|
|
1611
1495
|
queue.delete(handle);
|
|
1612
|
-
|
|
1496
|
+
if (handle.dirty) {
|
|
1497
|
+
this.dirtyEffectCount--;
|
|
1498
|
+
}
|
|
1613
1499
|
}
|
|
1614
1500
|
enqueue(handle) {
|
|
1615
1501
|
const zone = handle.zone;
|
|
@@ -1620,7 +1506,6 @@ var ZoneAwareEffectScheduler = class {
|
|
|
1620
1506
|
if (queue.has(handle)) {
|
|
1621
1507
|
return;
|
|
1622
1508
|
}
|
|
1623
|
-
this.queuedEffectCount++;
|
|
1624
1509
|
queue.add(handle);
|
|
1625
1510
|
}
|
|
1626
1511
|
/**
|
|
@@ -1630,224 +1515,35 @@ var ZoneAwareEffectScheduler = class {
|
|
|
1630
1515
|
* ordering guarantee between effects scheduled in different zones.
|
|
1631
1516
|
*/
|
|
1632
1517
|
flush() {
|
|
1633
|
-
while (this.
|
|
1518
|
+
while (this.dirtyEffectCount > 0) {
|
|
1519
|
+
let ranOneEffect = false;
|
|
1634
1520
|
for (const [zone, queue] of this.queues) {
|
|
1635
1521
|
if (zone === null) {
|
|
1636
|
-
this.flushQueue(queue);
|
|
1522
|
+
ranOneEffect ||= this.flushQueue(queue);
|
|
1637
1523
|
} else {
|
|
1638
|
-
zone.run(() => this.flushQueue(queue));
|
|
1524
|
+
ranOneEffect ||= zone.run(() => this.flushQueue(queue));
|
|
1639
1525
|
}
|
|
1640
1526
|
}
|
|
1527
|
+
if (!ranOneEffect) {
|
|
1528
|
+
this.dirtyEffectCount = 0;
|
|
1529
|
+
}
|
|
1641
1530
|
}
|
|
1642
1531
|
}
|
|
1643
1532
|
flushQueue(queue) {
|
|
1533
|
+
let ranOneEffect = false;
|
|
1644
1534
|
for (const handle of queue) {
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
handle.run();
|
|
1648
|
-
}
|
|
1649
|
-
}
|
|
1650
|
-
};
|
|
1651
|
-
|
|
1652
|
-
// src/import/render3/reactivity/patch.ts
|
|
1653
|
-
var USE_MICROTASK_EFFECT_BY_DEFAULT = false;
|
|
1654
|
-
|
|
1655
|
-
// src/import/error_handler.ts
|
|
1656
|
-
var ErrorHandler = class {
|
|
1657
|
-
/**
|
|
1658
|
-
* @internal
|
|
1659
|
-
*/
|
|
1660
|
-
_console = console;
|
|
1661
|
-
handleError(error) {
|
|
1662
|
-
this._console.error("ERROR", error);
|
|
1663
|
-
}
|
|
1664
|
-
};
|
|
1665
|
-
|
|
1666
|
-
// src/import/pending_tasks.ts
|
|
1667
|
-
var import_rxjs = require("rxjs");
|
|
1668
|
-
var PendingTasksInternal = class _PendingTasksInternal {
|
|
1669
|
-
taskId = 0;
|
|
1670
|
-
pendingTasks = /* @__PURE__ */ new Set();
|
|
1671
|
-
get _hasPendingTasks() {
|
|
1672
|
-
return this.hasPendingTasks.value;
|
|
1673
|
-
}
|
|
1674
|
-
hasPendingTasks = new import_rxjs.BehaviorSubject(false);
|
|
1675
|
-
add() {
|
|
1676
|
-
if (!this._hasPendingTasks) {
|
|
1677
|
-
this.hasPendingTasks.next(true);
|
|
1678
|
-
}
|
|
1679
|
-
const taskId = this.taskId++;
|
|
1680
|
-
this.pendingTasks.add(taskId);
|
|
1681
|
-
return taskId;
|
|
1682
|
-
}
|
|
1683
|
-
has(taskId) {
|
|
1684
|
-
return this.pendingTasks.has(taskId);
|
|
1685
|
-
}
|
|
1686
|
-
remove(taskId) {
|
|
1687
|
-
this.pendingTasks.delete(taskId);
|
|
1688
|
-
if (this.pendingTasks.size === 0 && this._hasPendingTasks) {
|
|
1689
|
-
this.hasPendingTasks.next(false);
|
|
1690
|
-
}
|
|
1691
|
-
}
|
|
1692
|
-
ngOnDestroy() {
|
|
1693
|
-
this.pendingTasks.clear();
|
|
1694
|
-
if (this._hasPendingTasks) {
|
|
1695
|
-
this.hasPendingTasks.next(false);
|
|
1696
|
-
}
|
|
1697
|
-
}
|
|
1698
|
-
/** @nocollapse */
|
|
1699
|
-
static ɵprov = (
|
|
1700
|
-
/** @pureOrBreakMyCode */
|
|
1701
|
-
/* @__PURE__ */ ɵɵdefineInjectable({
|
|
1702
|
-
token: _PendingTasksInternal,
|
|
1703
|
-
providedIn: "root",
|
|
1704
|
-
factory: () => new _PendingTasksInternal()
|
|
1705
|
-
})
|
|
1706
|
-
);
|
|
1707
|
-
};
|
|
1708
|
-
var PendingTasks = class _PendingTasks {
|
|
1709
|
-
internalPendingTasks = inject(PendingTasksInternal);
|
|
1710
|
-
scheduler = inject(ChangeDetectionScheduler);
|
|
1711
|
-
/**
|
|
1712
|
-
* Adds a new task that should block application's stability.
|
|
1713
|
-
* @returns A cleanup function that removes a task when called.
|
|
1714
|
-
*/
|
|
1715
|
-
add() {
|
|
1716
|
-
const taskId = this.internalPendingTasks.add();
|
|
1717
|
-
return () => {
|
|
1718
|
-
if (!this.internalPendingTasks.has(taskId)) {
|
|
1719
|
-
return;
|
|
1720
|
-
}
|
|
1721
|
-
this.scheduler.notify(11 /* PendingTaskRemoved */);
|
|
1722
|
-
this.internalPendingTasks.remove(taskId);
|
|
1723
|
-
};
|
|
1724
|
-
}
|
|
1725
|
-
/**
|
|
1726
|
-
* Runs an asynchronous function and blocks the application's stability until the function completes.
|
|
1727
|
-
*
|
|
1728
|
-
* ```ts
|
|
1729
|
-
* pendingTasks.run(async () => {
|
|
1730
|
-
* const userData = await fetch('/api/user');
|
|
1731
|
-
* this.userData.set(userData);
|
|
1732
|
-
* });
|
|
1733
|
-
* ```
|
|
1734
|
-
*
|
|
1735
|
-
* Application stability is at least delayed until the next tick after the `run` method resolves
|
|
1736
|
-
* so it is safe to make additional updates to application state that would require UI synchronization:
|
|
1737
|
-
*
|
|
1738
|
-
* ```ts
|
|
1739
|
-
* const userData = await pendingTasks.run(() => fetch('/api/user'));
|
|
1740
|
-
* this.userData.set(userData);
|
|
1741
|
-
* ```
|
|
1742
|
-
*
|
|
1743
|
-
* @param fn The asynchronous function to execute
|
|
1744
|
-
*/
|
|
1745
|
-
async run(fn) {
|
|
1746
|
-
const removeTask = this.add();
|
|
1747
|
-
try {
|
|
1748
|
-
return await fn();
|
|
1749
|
-
} finally {
|
|
1750
|
-
removeTask();
|
|
1751
|
-
}
|
|
1752
|
-
}
|
|
1753
|
-
/** @nocollapse */
|
|
1754
|
-
static ɵprov = (
|
|
1755
|
-
/** @pureOrBreakMyCode */
|
|
1756
|
-
/* @__PURE__ */ ɵɵdefineInjectable({
|
|
1757
|
-
token: _PendingTasks,
|
|
1758
|
-
providedIn: "root",
|
|
1759
|
-
factory: () => new _PendingTasks()
|
|
1760
|
-
})
|
|
1761
|
-
);
|
|
1762
|
-
};
|
|
1763
|
-
|
|
1764
|
-
// src/import/render3/reactivity/microtask_effect.ts
|
|
1765
|
-
var MicrotaskEffectScheduler = class _MicrotaskEffectScheduler extends ZoneAwareEffectScheduler {
|
|
1766
|
-
pendingTasks = inject(PendingTasksInternal);
|
|
1767
|
-
taskId = null;
|
|
1768
|
-
schedule(effect3) {
|
|
1769
|
-
super.schedule(effect3);
|
|
1770
|
-
if (this.taskId === null) {
|
|
1771
|
-
this.taskId = this.pendingTasks.add();
|
|
1772
|
-
queueMicrotask(() => this.flush());
|
|
1773
|
-
}
|
|
1774
|
-
}
|
|
1775
|
-
flush() {
|
|
1776
|
-
try {
|
|
1777
|
-
super.flush();
|
|
1778
|
-
} finally {
|
|
1779
|
-
if (this.taskId !== null) {
|
|
1780
|
-
this.pendingTasks.remove(this.taskId);
|
|
1781
|
-
this.taskId = null;
|
|
1535
|
+
if (!handle.dirty) {
|
|
1536
|
+
continue;
|
|
1782
1537
|
}
|
|
1538
|
+
this.dirtyEffectCount--;
|
|
1539
|
+
ranOneEffect = true;
|
|
1540
|
+
handle.run();
|
|
1783
1541
|
}
|
|
1542
|
+
return ranOneEffect;
|
|
1784
1543
|
}
|
|
1785
|
-
/** @nocollapse */
|
|
1786
|
-
static ɵprov = (
|
|
1787
|
-
/** @pureOrBreakMyCode */
|
|
1788
|
-
/* @__PURE__ */ ɵɵdefineInjectable({
|
|
1789
|
-
token: _MicrotaskEffectScheduler,
|
|
1790
|
-
providedIn: "root",
|
|
1791
|
-
factory: () => new _MicrotaskEffectScheduler()
|
|
1792
|
-
})
|
|
1793
|
-
);
|
|
1794
1544
|
};
|
|
1795
|
-
var EffectHandle = class {
|
|
1796
|
-
constructor(scheduler, effectFn, zone, destroyRef, injector, allowSignalWrites) {
|
|
1797
|
-
this.scheduler = scheduler;
|
|
1798
|
-
this.effectFn = effectFn;
|
|
1799
|
-
this.zone = zone;
|
|
1800
|
-
this.injector = injector;
|
|
1801
|
-
this.watcher = createWatch(
|
|
1802
|
-
(onCleanup) => this.runEffect(onCleanup),
|
|
1803
|
-
() => this.schedule(),
|
|
1804
|
-
allowSignalWrites
|
|
1805
|
-
);
|
|
1806
|
-
this.unregisterOnDestroy = destroyRef?.onDestroy(() => this.destroy());
|
|
1807
|
-
}
|
|
1808
|
-
unregisterOnDestroy;
|
|
1809
|
-
watcher;
|
|
1810
|
-
runEffect(onCleanup) {
|
|
1811
|
-
try {
|
|
1812
|
-
this.effectFn(onCleanup);
|
|
1813
|
-
} catch (err) {
|
|
1814
|
-
const errorHandler = this.injector.get(ErrorHandler, null, {
|
|
1815
|
-
optional: true
|
|
1816
|
-
});
|
|
1817
|
-
errorHandler?.handleError(err);
|
|
1818
|
-
}
|
|
1819
|
-
}
|
|
1820
|
-
run() {
|
|
1821
|
-
this.watcher.run();
|
|
1822
|
-
}
|
|
1823
|
-
schedule() {
|
|
1824
|
-
this.scheduler.schedule(this);
|
|
1825
|
-
}
|
|
1826
|
-
destroy() {
|
|
1827
|
-
this.watcher.destroy();
|
|
1828
|
-
this.unregisterOnDestroy?.();
|
|
1829
|
-
}
|
|
1830
|
-
};
|
|
1831
|
-
function effect() {
|
|
1832
|
-
}
|
|
1833
|
-
function microtaskEffect(effectFn, options) {
|
|
1834
|
-
!options?.injector && assertInInjectionContext(effect);
|
|
1835
|
-
const injector = options?.injector ?? inject(Injector);
|
|
1836
|
-
const destroyRef = options?.manualCleanup !== true ? injector.get(DestroyRef) : null;
|
|
1837
|
-
const handle = new EffectHandle(
|
|
1838
|
-
injector.get(MicrotaskEffectScheduler),
|
|
1839
|
-
effectFn,
|
|
1840
|
-
true ? null : (void 0).current,
|
|
1841
|
-
destroyRef,
|
|
1842
|
-
injector,
|
|
1843
|
-
options?.allowSignalWrites ?? false
|
|
1844
|
-
);
|
|
1845
|
-
handle.watcher.notify();
|
|
1846
|
-
return handle;
|
|
1847
|
-
}
|
|
1848
1545
|
|
|
1849
1546
|
// src/import/render3/reactivity/effect.ts
|
|
1850
|
-
var useMicrotaskEffectsByDefault = USE_MICROTASK_EFFECT_BY_DEFAULT;
|
|
1851
1547
|
var EffectRefImpl = class {
|
|
1852
1548
|
[SIGNAL];
|
|
1853
1549
|
constructor(node) {
|
|
@@ -1857,20 +1553,12 @@ var EffectRefImpl = class {
|
|
|
1857
1553
|
this[SIGNAL].destroy();
|
|
1858
1554
|
}
|
|
1859
1555
|
};
|
|
1860
|
-
function
|
|
1861
|
-
if (
|
|
1862
|
-
|
|
1863
|
-
throw new Error(
|
|
1864
|
-
`Cannot use 'forceRoot' option with microtask effects on`
|
|
1865
|
-
);
|
|
1866
|
-
}
|
|
1867
|
-
return microtaskEffect(effectFn, options);
|
|
1556
|
+
function effect(effectFn, options) {
|
|
1557
|
+
if (false) {
|
|
1558
|
+
assertInInjectionContext(effect);
|
|
1868
1559
|
}
|
|
1869
|
-
!options?.injector && assertInInjectionContext(effect2);
|
|
1870
1560
|
if (false) {
|
|
1871
|
-
console.warn(
|
|
1872
|
-
`The 'allowSignalWrites' flag is deprecated and no longer impacts effect() (writes are always allowed)`
|
|
1873
|
-
);
|
|
1561
|
+
console.warn(`The 'allowSignalWrites' flag is deprecated and no longer impacts effect() (writes are always allowed)`);
|
|
1874
1562
|
}
|
|
1875
1563
|
const injector = options?.injector ?? inject(Injector);
|
|
1876
1564
|
const destroyRef = options?.manualCleanup !== true ? injector.get(DestroyRef) : null;
|
|
@@ -1897,9 +1585,7 @@ var BASE_EFFECT_NODE = /* @__PURE__ */ (() => ({
|
|
|
1897
1585
|
run() {
|
|
1898
1586
|
this.dirty = false;
|
|
1899
1587
|
if (false) {
|
|
1900
|
-
throw new Error(
|
|
1901
|
-
`Schedulers cannot synchronously execute watches while scheduling.`
|
|
1902
|
-
);
|
|
1588
|
+
throw new Error(`Schedulers cannot synchronously execute watches while scheduling.`);
|
|
1903
1589
|
}
|
|
1904
1590
|
if (this.hasRun && !consumerPollProducersForChange(this)) {
|
|
1905
1591
|
return;
|
|
@@ -1918,12 +1604,14 @@ var BASE_EFFECT_NODE = /* @__PURE__ */ (() => ({
|
|
|
1918
1604
|
if (!this.cleanupFns?.length) {
|
|
1919
1605
|
return;
|
|
1920
1606
|
}
|
|
1607
|
+
const prevConsumer = setActiveConsumer(null);
|
|
1921
1608
|
try {
|
|
1922
1609
|
while (this.cleanupFns.length) {
|
|
1923
1610
|
this.cleanupFns.pop()();
|
|
1924
1611
|
}
|
|
1925
1612
|
} finally {
|
|
1926
1613
|
this.cleanupFns = [];
|
|
1614
|
+
setActiveConsumer(prevConsumer);
|
|
1927
1615
|
}
|
|
1928
1616
|
}
|
|
1929
1617
|
}))();
|
|
@@ -1946,7 +1634,7 @@ function createRootEffect(fn, scheduler, notifier) {
|
|
|
1946
1634
|
node.scheduler = scheduler;
|
|
1947
1635
|
node.notifier = notifier;
|
|
1948
1636
|
node.zone = false ? (void 0).current : null;
|
|
1949
|
-
node.scheduler.
|
|
1637
|
+
node.scheduler.add(node);
|
|
1950
1638
|
node.notifier.notify(12 /* RootEffect */);
|
|
1951
1639
|
return node;
|
|
1952
1640
|
}
|
|
@@ -2000,27 +1688,148 @@ var ChangeDetectionSchedulerImpl = class {
|
|
|
2000
1688
|
}
|
|
2001
1689
|
};
|
|
2002
1690
|
|
|
2003
|
-
// src/import/
|
|
2004
|
-
var
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
1691
|
+
// src/import/pending_tasks.ts
|
|
1692
|
+
var import_rxjs = require("rxjs");
|
|
1693
|
+
|
|
1694
|
+
// src/import/error_handler.ts
|
|
1695
|
+
var ErrorHandler = class {
|
|
1696
|
+
/**
|
|
1697
|
+
* @internal
|
|
1698
|
+
*/
|
|
1699
|
+
_console = console;
|
|
1700
|
+
handleError(error) {
|
|
1701
|
+
this._console.error("ERROR", error);
|
|
1702
|
+
}
|
|
1703
|
+
};
|
|
1704
|
+
var INTERNAL_APPLICATION_ERROR_HANDLER = new InjectionToken("", {
|
|
1705
|
+
providedIn: "root",
|
|
1706
|
+
factory: () => {
|
|
1707
|
+
const injector = inject(EnvironmentInjector);
|
|
1708
|
+
let userErrorHandler;
|
|
1709
|
+
return (e) => {
|
|
1710
|
+
userErrorHandler ??= injector.get(ErrorHandler);
|
|
1711
|
+
userErrorHandler.handleError(e);
|
|
1712
|
+
};
|
|
1713
|
+
}
|
|
1714
|
+
});
|
|
1715
|
+
|
|
1716
|
+
// src/import/pending_tasks.ts
|
|
1717
|
+
var PendingTasksInternal = class _PendingTasksInternal {
|
|
1718
|
+
taskId = 0;
|
|
1719
|
+
pendingTasks = /* @__PURE__ */ new Set();
|
|
1720
|
+
destroyed = false;
|
|
1721
|
+
pendingTask = new import_rxjs.BehaviorSubject(false);
|
|
1722
|
+
get hasPendingTasks() {
|
|
1723
|
+
return this.destroyed ? false : this.pendingTask.value;
|
|
1724
|
+
}
|
|
1725
|
+
/**
|
|
1726
|
+
* In case the service is about to be destroyed, return a self-completing observable.
|
|
1727
|
+
* Otherwise, return the observable that emits the current state of pending tasks.
|
|
1728
|
+
*/
|
|
1729
|
+
get hasPendingTasksObservable() {
|
|
1730
|
+
if (this.destroyed) {
|
|
1731
|
+
return new import_rxjs.Observable((subscriber) => {
|
|
1732
|
+
subscriber.next(false);
|
|
1733
|
+
subscriber.complete();
|
|
1734
|
+
});
|
|
1735
|
+
}
|
|
1736
|
+
return this.pendingTask;
|
|
1737
|
+
}
|
|
1738
|
+
add() {
|
|
1739
|
+
if (!this.hasPendingTasks && !this.destroyed) {
|
|
1740
|
+
this.pendingTask.next(true);
|
|
1741
|
+
}
|
|
1742
|
+
const taskId = this.taskId++;
|
|
1743
|
+
this.pendingTasks.add(taskId);
|
|
1744
|
+
return taskId;
|
|
1745
|
+
}
|
|
1746
|
+
has(taskId) {
|
|
1747
|
+
return this.pendingTasks.has(taskId);
|
|
1748
|
+
}
|
|
1749
|
+
remove(taskId) {
|
|
1750
|
+
this.pendingTasks.delete(taskId);
|
|
1751
|
+
if (this.pendingTasks.size === 0 && this.hasPendingTasks) {
|
|
1752
|
+
this.pendingTask.next(false);
|
|
1753
|
+
}
|
|
1754
|
+
}
|
|
1755
|
+
ngOnDestroy() {
|
|
1756
|
+
this.pendingTasks.clear();
|
|
1757
|
+
if (this.hasPendingTasks) {
|
|
1758
|
+
this.pendingTask.next(false);
|
|
1759
|
+
}
|
|
1760
|
+
this.destroyed = true;
|
|
1761
|
+
this.pendingTask.unsubscribe();
|
|
1762
|
+
}
|
|
1763
|
+
/** @nocollapse */
|
|
1764
|
+
static ɵprov = (
|
|
1765
|
+
/** @pureOrBreakMyCode */
|
|
1766
|
+
/* @__PURE__ */ ɵɵdefineInjectable({
|
|
1767
|
+
token: _PendingTasksInternal,
|
|
1768
|
+
providedIn: "root",
|
|
1769
|
+
factory: () => new _PendingTasksInternal()
|
|
1770
|
+
})
|
|
1771
|
+
);
|
|
1772
|
+
};
|
|
1773
|
+
var PendingTasks = class _PendingTasks {
|
|
1774
|
+
internalPendingTasks = inject(PendingTasksInternal);
|
|
1775
|
+
scheduler = inject(ChangeDetectionScheduler);
|
|
1776
|
+
errorHandler = inject(INTERNAL_APPLICATION_ERROR_HANDLER);
|
|
1777
|
+
/**
|
|
1778
|
+
* Adds a new task that should block application's stability.
|
|
1779
|
+
* @returns A cleanup function that removes a task when called.
|
|
1780
|
+
*/
|
|
1781
|
+
add() {
|
|
1782
|
+
const taskId = this.internalPendingTasks.add();
|
|
1783
|
+
return () => {
|
|
1784
|
+
if (!this.internalPendingTasks.has(taskId)) {
|
|
1785
|
+
return;
|
|
1786
|
+
}
|
|
1787
|
+
this.scheduler.notify(11 /* PendingTaskRemoved */);
|
|
1788
|
+
this.internalPendingTasks.remove(taskId);
|
|
1789
|
+
};
|
|
1790
|
+
}
|
|
1791
|
+
/**
|
|
1792
|
+
* Runs an asynchronous function and blocks the application's stability until the function completes.
|
|
1793
|
+
*
|
|
1794
|
+
* ```ts
|
|
1795
|
+
* pendingTasks.run(async () => {
|
|
1796
|
+
* const userData = await fetch('/api/user');
|
|
1797
|
+
* this.userData.set(userData);
|
|
1798
|
+
* });
|
|
1799
|
+
* ```
|
|
1800
|
+
*
|
|
1801
|
+
* @param fn The asynchronous function to execute
|
|
1802
|
+
* @developerPreview 19.0
|
|
1803
|
+
*/
|
|
1804
|
+
run(fn) {
|
|
1805
|
+
const removeTask = this.add();
|
|
1806
|
+
fn().catch(this.errorHandler).finally(removeTask);
|
|
1807
|
+
}
|
|
1808
|
+
/** @nocollapse */
|
|
1809
|
+
static ɵprov = (
|
|
1810
|
+
/** @pureOrBreakMyCode */
|
|
1811
|
+
/* @__PURE__ */ ɵɵdefineInjectable({
|
|
1812
|
+
token: _PendingTasks,
|
|
1813
|
+
providedIn: "root",
|
|
1814
|
+
factory: () => new _PendingTasks()
|
|
1815
|
+
})
|
|
1816
|
+
);
|
|
1817
|
+
};
|
|
2013
1818
|
|
|
2014
1819
|
// src/import/resource/resource.ts
|
|
1820
|
+
var RESOURCE_VALUE_THROWS_ERRORS_DEFAULT = true;
|
|
2015
1821
|
function resource(options) {
|
|
2016
|
-
|
|
2017
|
-
|
|
1822
|
+
if (false) {
|
|
1823
|
+
}
|
|
1824
|
+
const oldNameForParams = options.request;
|
|
1825
|
+
const params = options.params ?? oldNameForParams ?? (() => null);
|
|
2018
1826
|
return new ResourceImpl(
|
|
2019
|
-
|
|
1827
|
+
params,
|
|
2020
1828
|
getLoader(options),
|
|
2021
1829
|
options.defaultValue,
|
|
2022
1830
|
options.equal ? wrapEqualityFn(options.equal) : void 0,
|
|
2023
|
-
options.injector ?? inject(Injector)
|
|
1831
|
+
options.injector ?? inject(Injector),
|
|
1832
|
+
RESOURCE_VALUE_THROWS_ERRORS_DEFAULT
|
|
2024
1833
|
);
|
|
2025
1834
|
}
|
|
2026
1835
|
var BaseWritableResource = class {
|
|
@@ -2031,13 +1840,15 @@ var BaseWritableResource = class {
|
|
|
2031
1840
|
this.value.update = this.update.bind(this);
|
|
2032
1841
|
this.value.asReadonly = signalAsReadonlyFn;
|
|
2033
1842
|
}
|
|
1843
|
+
isError = computed(() => this.status() === "error");
|
|
2034
1844
|
update(updateFn) {
|
|
2035
|
-
this.set(updateFn(
|
|
1845
|
+
this.set(updateFn(untracked2(this.value)));
|
|
2036
1846
|
}
|
|
2037
|
-
isLoading = computed(
|
|
2038
|
-
() => this.status() === 2 /* Loading */ || this.status() === 3 /* Reloading */
|
|
2039
|
-
);
|
|
1847
|
+
isLoading = computed(() => this.status() === "loading" || this.status() === "reloading");
|
|
2040
1848
|
hasValue() {
|
|
1849
|
+
if (this.isError()) {
|
|
1850
|
+
return false;
|
|
1851
|
+
}
|
|
2041
1852
|
return this.value() !== void 0;
|
|
2042
1853
|
}
|
|
2043
1854
|
asReadonly() {
|
|
@@ -2045,20 +1856,32 @@ var BaseWritableResource = class {
|
|
|
2045
1856
|
}
|
|
2046
1857
|
};
|
|
2047
1858
|
var ResourceImpl = class extends BaseWritableResource {
|
|
2048
|
-
constructor(request, loaderFn, defaultValue, equal, injector) {
|
|
1859
|
+
constructor(request, loaderFn, defaultValue, equal, injector, throwErrorsFromValue = RESOURCE_VALUE_THROWS_ERRORS_DEFAULT) {
|
|
2049
1860
|
super(
|
|
2050
1861
|
// Feed a computed signal for the value to `BaseWritableResource`, which will upgrade it to a
|
|
2051
1862
|
// `WritableSignal` that delegates to `ResourceImpl.set`.
|
|
2052
1863
|
computed(
|
|
2053
1864
|
() => {
|
|
2054
1865
|
const streamValue = this.state().stream?.();
|
|
2055
|
-
|
|
1866
|
+
if (!streamValue) {
|
|
1867
|
+
return defaultValue;
|
|
1868
|
+
}
|
|
1869
|
+
if (this.state().status === "loading" && this.error()) {
|
|
1870
|
+
return defaultValue;
|
|
1871
|
+
}
|
|
1872
|
+
if (!isResolved(streamValue)) {
|
|
1873
|
+
if (throwErrorsFromValue) {
|
|
1874
|
+
throw new ResourceValueError(this.error());
|
|
1875
|
+
} else {
|
|
1876
|
+
return defaultValue;
|
|
1877
|
+
}
|
|
1878
|
+
}
|
|
1879
|
+
return streamValue.value;
|
|
2056
1880
|
},
|
|
2057
1881
|
{ equal }
|
|
2058
1882
|
)
|
|
2059
1883
|
);
|
|
2060
1884
|
this.loaderFn = loaderFn;
|
|
2061
|
-
this.defaultValue = defaultValue;
|
|
2062
1885
|
this.equal = equal;
|
|
2063
1886
|
this.extRequest = linkedSignal({
|
|
2064
1887
|
source: request,
|
|
@@ -2069,12 +1892,12 @@ var ResourceImpl = class extends BaseWritableResource {
|
|
|
2069
1892
|
source: this.extRequest,
|
|
2070
1893
|
// Compute the state of the resource given a change in status.
|
|
2071
1894
|
computation: (extRequest, previous) => {
|
|
2072
|
-
const status = extRequest.request === void 0 ?
|
|
1895
|
+
const status = extRequest.request === void 0 ? "idle" : "loading";
|
|
2073
1896
|
if (!previous) {
|
|
2074
1897
|
return {
|
|
2075
1898
|
extRequest,
|
|
2076
1899
|
status,
|
|
2077
|
-
previousStatus:
|
|
1900
|
+
previousStatus: "idle",
|
|
2078
1901
|
stream: void 0
|
|
2079
1902
|
};
|
|
2080
1903
|
} else {
|
|
@@ -2088,12 +1911,12 @@ var ResourceImpl = class extends BaseWritableResource {
|
|
|
2088
1911
|
}
|
|
2089
1912
|
}
|
|
2090
1913
|
});
|
|
2091
|
-
this.effectRef =
|
|
1914
|
+
this.effectRef = effect(this.loadEffect.bind(this), {
|
|
2092
1915
|
injector,
|
|
2093
1916
|
manualCleanup: true
|
|
2094
1917
|
});
|
|
2095
1918
|
this.pendingTasks = injector.get(PendingTasks);
|
|
2096
|
-
injector.get(DestroyRef).onDestroy(() => this.destroy());
|
|
1919
|
+
this.unregisterOnDestroy = injector.get(DestroyRef).onDestroy(() => this.destroy());
|
|
2097
1920
|
}
|
|
2098
1921
|
pendingTasks;
|
|
2099
1922
|
/**
|
|
@@ -2109,6 +1932,7 @@ var ResourceImpl = class extends BaseWritableResource {
|
|
|
2109
1932
|
pendingController;
|
|
2110
1933
|
resolvePendingTask = void 0;
|
|
2111
1934
|
destroyed = false;
|
|
1935
|
+
unregisterOnDestroy;
|
|
2112
1936
|
status = computed(() => projectStatusOfState(this.state()));
|
|
2113
1937
|
error = computed(() => {
|
|
2114
1938
|
const stream = this.state().stream?.();
|
|
@@ -2121,55 +1945,55 @@ var ResourceImpl = class extends BaseWritableResource {
|
|
|
2121
1945
|
if (this.destroyed) {
|
|
2122
1946
|
return;
|
|
2123
1947
|
}
|
|
2124
|
-
const current =
|
|
2125
|
-
const state =
|
|
2126
|
-
if (state.status ===
|
|
1948
|
+
const current = untracked2(this.value);
|
|
1949
|
+
const state = untracked2(this.state);
|
|
1950
|
+
if (state.status === "local" && (this.equal ? this.equal(current, value) : current === value)) {
|
|
2127
1951
|
return;
|
|
2128
1952
|
}
|
|
2129
1953
|
this.state.set({
|
|
2130
1954
|
extRequest: state.extRequest,
|
|
2131
|
-
status:
|
|
2132
|
-
previousStatus:
|
|
1955
|
+
status: "local",
|
|
1956
|
+
previousStatus: "local",
|
|
2133
1957
|
stream: signal({ value })
|
|
2134
1958
|
});
|
|
2135
1959
|
this.abortInProgressLoad();
|
|
2136
1960
|
}
|
|
2137
1961
|
reload() {
|
|
2138
|
-
const { status } =
|
|
2139
|
-
if (status ===
|
|
1962
|
+
const { status } = untracked2(this.state);
|
|
1963
|
+
if (status === "idle" || status === "loading") {
|
|
2140
1964
|
return false;
|
|
2141
1965
|
}
|
|
2142
|
-
this.extRequest.update(({ request, reload }) => ({
|
|
2143
|
-
request,
|
|
2144
|
-
reload: reload + 1
|
|
2145
|
-
}));
|
|
1966
|
+
this.extRequest.update(({ request, reload }) => ({ request, reload: reload + 1 }));
|
|
2146
1967
|
return true;
|
|
2147
1968
|
}
|
|
2148
1969
|
destroy() {
|
|
2149
1970
|
this.destroyed = true;
|
|
1971
|
+
this.unregisterOnDestroy();
|
|
2150
1972
|
this.effectRef.destroy();
|
|
2151
1973
|
this.abortInProgressLoad();
|
|
2152
1974
|
this.state.set({
|
|
2153
1975
|
extRequest: { request: void 0, reload: 0 },
|
|
2154
|
-
status:
|
|
2155
|
-
previousStatus:
|
|
1976
|
+
status: "idle",
|
|
1977
|
+
previousStatus: "idle",
|
|
2156
1978
|
stream: void 0
|
|
2157
1979
|
});
|
|
2158
1980
|
}
|
|
2159
1981
|
async loadEffect() {
|
|
2160
1982
|
const extRequest = this.extRequest();
|
|
2161
|
-
const { status: currentStatus, previousStatus } =
|
|
1983
|
+
const { status: currentStatus, previousStatus } = untracked2(this.state);
|
|
2162
1984
|
if (extRequest.request === void 0) {
|
|
2163
1985
|
return;
|
|
2164
|
-
} else if (currentStatus !==
|
|
1986
|
+
} else if (currentStatus !== "loading") {
|
|
2165
1987
|
return;
|
|
2166
1988
|
}
|
|
2167
1989
|
this.abortInProgressLoad();
|
|
2168
1990
|
let resolvePendingTask = this.resolvePendingTask = this.pendingTasks.add();
|
|
2169
1991
|
const { signal: abortSignal } = this.pendingController = new AbortController();
|
|
2170
1992
|
try {
|
|
2171
|
-
const stream = await
|
|
1993
|
+
const stream = await untracked2(
|
|
2172
1994
|
() => this.loaderFn({
|
|
1995
|
+
params: extRequest.request,
|
|
1996
|
+
// TODO(alxhub): cleanup after g3 removal of `request` alias.
|
|
2173
1997
|
request: extRequest.request,
|
|
2174
1998
|
abortSignal,
|
|
2175
1999
|
previous: {
|
|
@@ -2177,24 +2001,24 @@ var ResourceImpl = class extends BaseWritableResource {
|
|
|
2177
2001
|
}
|
|
2178
2002
|
})
|
|
2179
2003
|
);
|
|
2180
|
-
if (abortSignal.aborted ||
|
|
2004
|
+
if (abortSignal.aborted || untracked2(this.extRequest) !== extRequest) {
|
|
2181
2005
|
return;
|
|
2182
2006
|
}
|
|
2183
2007
|
this.state.set({
|
|
2184
2008
|
extRequest,
|
|
2185
|
-
status:
|
|
2186
|
-
previousStatus:
|
|
2009
|
+
status: "resolved",
|
|
2010
|
+
previousStatus: "resolved",
|
|
2187
2011
|
stream
|
|
2188
2012
|
});
|
|
2189
2013
|
} catch (err) {
|
|
2190
|
-
if (abortSignal.aborted ||
|
|
2014
|
+
if (abortSignal.aborted || untracked2(this.extRequest) !== extRequest) {
|
|
2191
2015
|
return;
|
|
2192
2016
|
}
|
|
2193
2017
|
this.state.set({
|
|
2194
2018
|
extRequest,
|
|
2195
|
-
status:
|
|
2196
|
-
previousStatus:
|
|
2197
|
-
stream: signal({ error: err })
|
|
2019
|
+
status: "resolved",
|
|
2020
|
+
previousStatus: "error",
|
|
2021
|
+
stream: signal({ error: encapsulateResourceError(err) })
|
|
2198
2022
|
});
|
|
2199
2023
|
} finally {
|
|
2200
2024
|
resolvePendingTask?.();
|
|
@@ -2202,7 +2026,7 @@ var ResourceImpl = class extends BaseWritableResource {
|
|
|
2202
2026
|
}
|
|
2203
2027
|
}
|
|
2204
2028
|
abortInProgressLoad() {
|
|
2205
|
-
|
|
2029
|
+
untracked2(() => this.pendingController?.abort());
|
|
2206
2030
|
this.pendingController = void 0;
|
|
2207
2031
|
this.resolvePendingTask?.();
|
|
2208
2032
|
this.resolvePendingTask = void 0;
|
|
@@ -2219,7 +2043,7 @@ function getLoader(options) {
|
|
|
2219
2043
|
try {
|
|
2220
2044
|
return signal({ value: await options.loader(params) });
|
|
2221
2045
|
} catch (err) {
|
|
2222
|
-
return signal({ error: err });
|
|
2046
|
+
return signal({ error: encapsulateResourceError(err) });
|
|
2223
2047
|
}
|
|
2224
2048
|
};
|
|
2225
2049
|
}
|
|
@@ -2228,10 +2052,10 @@ function isStreamingResourceOptions(options) {
|
|
|
2228
2052
|
}
|
|
2229
2053
|
function projectStatusOfState(state) {
|
|
2230
2054
|
switch (state.status) {
|
|
2231
|
-
case
|
|
2232
|
-
return state.extRequest.reload === 0 ?
|
|
2233
|
-
case
|
|
2234
|
-
return isResolved(
|
|
2055
|
+
case "loading":
|
|
2056
|
+
return state.extRequest.reload === 0 ? "loading" : "reloading";
|
|
2057
|
+
case "resolved":
|
|
2058
|
+
return isResolved(state.stream()) ? "resolved" : "error";
|
|
2235
2059
|
default:
|
|
2236
2060
|
return state.status;
|
|
2237
2061
|
}
|
|
@@ -2239,8 +2063,28 @@ function projectStatusOfState(state) {
|
|
|
2239
2063
|
function isResolved(state) {
|
|
2240
2064
|
return state.error === void 0;
|
|
2241
2065
|
}
|
|
2066
|
+
function encapsulateResourceError(error) {
|
|
2067
|
+
if (error instanceof Error) {
|
|
2068
|
+
return error;
|
|
2069
|
+
}
|
|
2070
|
+
return new ResourceWrappedError(error);
|
|
2071
|
+
}
|
|
2072
|
+
var ResourceValueError = class extends Error {
|
|
2073
|
+
constructor(error) {
|
|
2074
|
+
super(error.message, { cause: error });
|
|
2075
|
+
}
|
|
2076
|
+
};
|
|
2077
|
+
var ResourceWrappedError = class extends Error {
|
|
2078
|
+
constructor(error) {
|
|
2079
|
+
super(String(error), { cause: error });
|
|
2080
|
+
}
|
|
2081
|
+
};
|
|
2242
2082
|
|
|
2243
2083
|
// src/import/index.ts
|
|
2084
|
+
function Injectable(args) {
|
|
2085
|
+
return (constructor) => {
|
|
2086
|
+
};
|
|
2087
|
+
}
|
|
2244
2088
|
var StaticInjectOptions = class {
|
|
2245
2089
|
static injectOptions;
|
|
2246
2090
|
};
|
|
@@ -2250,12 +2094,7 @@ var RootStaticInjectOptions = class {
|
|
|
2250
2094
|
};
|
|
2251
2095
|
};
|
|
2252
2096
|
function createInjector2(options) {
|
|
2253
|
-
return new R3Injector(
|
|
2254
|
-
options.providers,
|
|
2255
|
-
options.parent ?? getNullInjector(),
|
|
2256
|
-
options.name ?? "",
|
|
2257
|
-
options.scopes ?? /* @__PURE__ */ new Set([])
|
|
2258
|
-
);
|
|
2097
|
+
return new R3Injector(options.providers, options.parent ?? getNullInjector(), options.name ?? "", options.scopes ?? /* @__PURE__ */ new Set([]));
|
|
2259
2098
|
}
|
|
2260
2099
|
function createRootInjector(options) {
|
|
2261
2100
|
return new R3Injector(
|
|
@@ -2268,7 +2107,7 @@ function createRootInjector(options) {
|
|
|
2268
2107
|
],
|
|
2269
2108
|
getNullInjector(),
|
|
2270
2109
|
options.name ?? "",
|
|
2271
|
-
options.scopes ?? /* @__PURE__ */ new Set([])
|
|
2110
|
+
options.scopes ?? /* @__PURE__ */ new Set(["environment"])
|
|
2272
2111
|
);
|
|
2273
2112
|
}
|
|
2274
2113
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -2277,9 +2116,11 @@ function createRootInjector(options) {
|
|
|
2277
2116
|
ChangeDetectionSchedulerImpl,
|
|
2278
2117
|
DecoratorFlags,
|
|
2279
2118
|
EnvironmentInjector,
|
|
2119
|
+
ErrorHandler,
|
|
2280
2120
|
INJECTOR_SCOPE,
|
|
2121
|
+
INTERNAL_APPLICATION_ERROR_HANDLER,
|
|
2281
2122
|
Inject,
|
|
2282
|
-
|
|
2123
|
+
Injectable,
|
|
2283
2124
|
InjectionToken,
|
|
2284
2125
|
Injector,
|
|
2285
2126
|
InternalInjectFlags,
|
|
@@ -2290,8 +2131,10 @@ function createRootInjector(options) {
|
|
|
2290
2131
|
NullInjector,
|
|
2291
2132
|
Optional,
|
|
2292
2133
|
PROVIDED_ZONELESS,
|
|
2134
|
+
PendingTasks,
|
|
2135
|
+
PendingTasksInternal,
|
|
2293
2136
|
R3Injector,
|
|
2294
|
-
|
|
2137
|
+
RetrievingInjector,
|
|
2295
2138
|
RootStaticInjectOptions,
|
|
2296
2139
|
SCHEDULE_IN_ROOT_ZONE,
|
|
2297
2140
|
SOURCE,
|
|
@@ -2329,9 +2172,7 @@ function createRootInjector(options) {
|
|
|
2329
2172
|
signal,
|
|
2330
2173
|
untracked,
|
|
2331
2174
|
ɵEffectScheduler,
|
|
2332
|
-
ɵMicrotaskEffectScheduler,
|
|
2333
2175
|
ɵSIGNAL,
|
|
2334
|
-
ɵmicrotaskEffect,
|
|
2335
2176
|
ɵunwrapWritableSignal,
|
|
2336
2177
|
ɵɵdefineInjectable,
|
|
2337
2178
|
ɵɵdefineInjector,
|