@angular/core 21.2.0-next.1 → 21.2.0-next.2

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.
Files changed (77) hide show
  1. package/fesm2022/_attribute-chunk.mjs +1 -1
  2. package/fesm2022/_attribute-chunk.mjs.map +1 -1
  3. package/fesm2022/_debug_node-chunk.mjs +184 -537
  4. package/fesm2022/_debug_node-chunk.mjs.map +1 -1
  5. package/fesm2022/_effect-chunk.mjs +2 -11
  6. package/fesm2022/_effect-chunk.mjs.map +1 -1
  7. package/fesm2022/_effect-chunk2.mjs +2969 -0
  8. package/fesm2022/_effect-chunk2.mjs.map +1 -0
  9. package/fesm2022/_not_found-chunk.mjs +1 -1
  10. package/fesm2022/_not_found-chunk.mjs.map +1 -1
  11. package/fesm2022/_resource-chunk.mjs +8 -4
  12. package/fesm2022/_resource-chunk.mjs.map +1 -1
  13. package/fesm2022/_untracked-chunk.mjs +72 -2946
  14. package/fesm2022/_untracked-chunk.mjs.map +1 -1
  15. package/fesm2022/_weak_ref-chunk.mjs +1 -1
  16. package/fesm2022/_weak_ref-chunk.mjs.map +1 -1
  17. package/fesm2022/core.mjs +6 -10
  18. package/fesm2022/core.mjs.map +1 -1
  19. package/fesm2022/primitives-di.mjs +1 -1
  20. package/fesm2022/primitives-di.mjs.map +1 -1
  21. package/fesm2022/primitives-event-dispatch.mjs +2 -2
  22. package/fesm2022/primitives-event-dispatch.mjs.map +1 -1
  23. package/fesm2022/primitives-signals.mjs +3 -3
  24. package/fesm2022/primitives-signals.mjs.map +1 -1
  25. package/fesm2022/rxjs-interop.mjs +4 -4
  26. package/fesm2022/rxjs-interop.mjs.map +1 -1
  27. package/fesm2022/testing.mjs +2 -2
  28. package/fesm2022/testing.mjs.map +1 -1
  29. package/package.json +2 -2
  30. package/schematics/bundles/add-bootstrap-context-to-server-main.cjs +1 -1
  31. package/schematics/bundles/application-config-core.cjs +1 -1
  32. package/schematics/bundles/apply_import_manager-CxA_YYgB.cjs +1 -1
  33. package/schematics/bundles/bootstrap-options-migration.cjs +1 -1
  34. package/schematics/bundles/cleanup-unused-imports.cjs +1 -1
  35. package/schematics/bundles/common-to-standalone-migration.cjs +1 -1
  36. package/schematics/bundles/compiler_host-CY14HvaP.cjs +1 -1
  37. package/schematics/bundles/control-flow-migration.cjs +1 -1
  38. package/schematics/bundles/imports-CVmcbVA9.cjs +1 -1
  39. package/schematics/bundles/index-BtLcQH8g.cjs +1 -1
  40. package/schematics/bundles/inject-migration.cjs +1 -1
  41. package/schematics/bundles/leading_space-BTPRV0wu.cjs +1 -1
  42. package/schematics/bundles/migrate_ts_type_references-MWoZx-Cb.cjs +1 -1
  43. package/schematics/bundles/ng_component_template-BOuKAnQd.cjs +1 -1
  44. package/schematics/bundles/ng_decorators-DYy6II6x.cjs +1 -1
  45. package/schematics/bundles/ngclass-to-class-migration.cjs +1 -1
  46. package/schematics/bundles/ngstyle-to-style-migration.cjs +1 -1
  47. package/schematics/bundles/nodes-ZSQ7WZRB.cjs +1 -1
  48. package/schematics/bundles/output-migration.cjs +1 -1
  49. package/schematics/bundles/parse_html-C8eKA9px.cjs +1 -1
  50. package/schematics/bundles/project_paths-D2V-Uh2L.cjs +1 -1
  51. package/schematics/bundles/project_tsconfig_paths-DkkMibv-.cjs +1 -1
  52. package/schematics/bundles/property_name-BCpALNpZ.cjs +1 -1
  53. package/schematics/bundles/route-lazy-loading.cjs +1 -1
  54. package/schematics/bundles/router-current-navigation.cjs +1 -1
  55. package/schematics/bundles/router-last-successful-navigation.cjs +1 -1
  56. package/schematics/bundles/router-testing-module-migration.cjs +1 -1
  57. package/schematics/bundles/self-closing-tags-migration.cjs +1 -1
  58. package/schematics/bundles/signal-input-migration.cjs +1 -1
  59. package/schematics/bundles/signal-queries-migration.cjs +1 -1
  60. package/schematics/bundles/signals.cjs +1 -1
  61. package/schematics/bundles/standalone-migration.cjs +1 -1
  62. package/schematics/bundles/symbol-DZeHSR-V.cjs +1 -1
  63. package/types/_api-chunk.d.ts +1 -1
  64. package/types/_chrome_dev_tools_performance-chunk.d.ts +1 -1
  65. package/types/_discovery-chunk.d.ts +86 -25
  66. package/types/_effect-chunk.d.ts +1 -1
  67. package/types/_event_dispatcher-chunk.d.ts +2 -2
  68. package/types/_formatter-chunk.d.ts +1 -1
  69. package/types/_weak_ref-chunk.d.ts +1 -1
  70. package/types/core.d.ts +11 -187
  71. package/types/primitives-di.d.ts +1 -1
  72. package/types/primitives-event-dispatch.d.ts +3 -3
  73. package/types/primitives-signals.d.ts +1 -1
  74. package/types/rxjs-interop.d.ts +1 -1
  75. package/types/testing.d.ts +1 -1
  76. package/fesm2022/_linked_signal-chunk.mjs +0 -87
  77. package/fesm2022/_linked_signal-chunk.mjs.map +0 -1
@@ -1,2973 +1,99 @@
1
1
  /**
2
- * @license Angular v21.2.0-next.1
2
+ * @license Angular v21.2.0-next.2
3
3
  * (c) 2010-2026 Google LLC. https://angular.dev/
4
4
  * License: MIT
5
5
  */
6
6
 
7
- import { getActiveConsumer, setActiveConsumer as setActiveConsumer$1, createSignal, SIGNAL, consumerDestroy, BASE_EFFECT_NODE, isInNotificationPhase, runEffect, untracked as untracked$1 } from './_effect-chunk.mjs';
8
- import { BehaviorSubject, Observable, Subject, Subscription } from 'rxjs';
9
- import { isNotFound, getCurrentInjector, setCurrentInjector } from './_not_found-chunk.mjs';
10
- import { setActiveConsumer } from '@angular/core/primitives/signals';
11
- import { isNotFound as isNotFound$1 } from '@angular/core/primitives/di';
7
+ import { SIGNAL, runPostProducerCreatedFn, producerUpdateValueVersion, signalSetFn, producerMarkClean, ERRORED, signalUpdateFn, REACTIVE_NODE, UNSET, defaultEquals, COMPUTING, consumerBeforeComputation, consumerAfterComputation, producerAccessed, setActiveConsumer } from './_effect-chunk.mjs';
12
8
 
13
- class Version {
14
- full;
15
- major;
16
- minor;
17
- patch;
18
- constructor(full) {
19
- this.full = full;
20
- const parts = full.split('.');
21
- this.major = parts[0];
22
- this.minor = parts[1];
23
- this.patch = parts.slice(2).join('.');
9
+ function createLinkedSignal(sourceFn, computationFn, equalityFn) {
10
+ const node = Object.create(LINKED_SIGNAL_NODE);
11
+ node.source = sourceFn;
12
+ node.computation = computationFn;
13
+ if (equalityFn != undefined) {
14
+ node.equal = equalityFn;
24
15
  }
25
- }
26
- const VERSION = /* @__PURE__ */new Version('21.2.0-next.1');
27
-
28
- const DOC_PAGE_BASE_URL = (() => {
29
- const full = VERSION.full;
30
- const isPreRelease = full.includes('-next') || full.includes('-rc') || full === '0.0.0' + '-PLACEHOLDER';
31
- const prefix = isPreRelease ? 'next' : `v${VERSION.major}`;
32
- return `https://${prefix}.angular.dev`;
33
- })();
34
- const ERROR_DETAILS_PAGE_BASE_URL = (() => {
35
- return `${DOC_PAGE_BASE_URL}/errors`;
36
- })();
37
- const XSS_SECURITY_URL = 'https://angular.dev/best-practices/security#preventing-cross-site-scripting-xss';
38
-
39
- class RuntimeError extends Error {
40
- code;
41
- constructor(code, message) {
42
- super(formatRuntimeError(code, message));
43
- this.code = code;
44
- }
45
- }
46
- function formatRuntimeErrorCode(code) {
47
- return `NG0${Math.abs(code)}`;
48
- }
49
- function formatRuntimeError(code, message) {
50
- const fullCode = formatRuntimeErrorCode(code);
51
- let errorMessage = `${fullCode}${message ? ': ' + message : ''}`;
52
- if (ngDevMode && code < 0) {
53
- const addPeriodSeparator = !errorMessage.match(/[.,;!?\n]$/);
54
- const separator = addPeriodSeparator ? '.' : '';
55
- errorMessage = `${errorMessage}${separator} Find more at ${ERROR_DETAILS_PAGE_BASE_URL}/${fullCode}`;
56
- }
57
- return errorMessage;
58
- }
59
-
60
- const _global = globalThis;
61
-
62
- function ngDevModeResetPerfCounters() {
63
- const locationString = typeof location !== 'undefined' ? location.toString() : '';
64
- const newCounters = {
65
- hydratedNodes: 0,
66
- hydratedComponents: 0,
67
- dehydratedViewsRemoved: 0,
68
- dehydratedViewsCleanupRuns: 0,
69
- componentsSkippedHydration: 0,
70
- deferBlocksWithIncrementalHydration: 0
71
- };
72
- const allowNgDevModeTrue = locationString.indexOf('ngDevMode=false') === -1;
73
- if (!allowNgDevModeTrue) {
74
- _global['ngDevMode'] = false;
75
- } else {
76
- if (typeof _global['ngDevMode'] !== 'object') {
77
- _global['ngDevMode'] = {};
78
- }
79
- Object.assign(_global['ngDevMode'], newCounters);
80
- }
81
- return newCounters;
82
- }
83
- function initNgDevMode() {
84
- if (typeof ngDevMode === 'undefined' || ngDevMode) {
85
- if (typeof ngDevMode !== 'object' || Object.keys(ngDevMode).length === 0) {
86
- ngDevModeResetPerfCounters();
87
- }
88
- return typeof ngDevMode !== 'undefined' && !!ngDevMode;
89
- }
90
- return false;
91
- }
92
-
93
- function getClosureSafeProperty(objWithPropertyToExtract) {
94
- for (let key in objWithPropertyToExtract) {
95
- if (objWithPropertyToExtract[key] === getClosureSafeProperty) {
96
- return key;
97
- }
98
- }
99
- throw Error(typeof ngDevMode !== 'undefined' && ngDevMode ? 'Could not find renamed property on target object.' : '');
100
- }
101
- function fillProperties(target, source) {
102
- for (const key in source) {
103
- if (source.hasOwnProperty(key) && !target.hasOwnProperty(key)) {
104
- target[key] = source[key];
105
- }
106
- }
107
- }
108
-
109
- function stringify(token) {
110
- if (typeof token === 'string') {
111
- return token;
112
- }
113
- if (Array.isArray(token)) {
114
- return `[${token.map(stringify).join(', ')}]`;
115
- }
116
- if (token == null) {
117
- return '' + token;
118
- }
119
- const name = token.overriddenName || token.name;
120
- if (name) {
121
- return `${name}`;
122
- }
123
- const result = token.toString();
124
- if (result == null) {
125
- return '' + result;
126
- }
127
- const newLineIndex = result.indexOf('\n');
128
- return newLineIndex >= 0 ? result.slice(0, newLineIndex) : result;
129
- }
130
- function concatStringsWithSpace(before, after) {
131
- if (!before) return after || '';
132
- if (!after) return before;
133
- return `${before} ${after}`;
134
- }
135
- function truncateMiddle(str, maxLength = 100) {
136
- if (!str || maxLength < 1 || str.length <= maxLength) return str;
137
- if (maxLength == 1) return str.substring(0, 1) + '...';
138
- const halfLimit = Math.round(maxLength / 2);
139
- return str.substring(0, halfLimit) + '...' + str.substring(str.length - halfLimit);
140
- }
141
-
142
- const __forward_ref__ = getClosureSafeProperty({
143
- __forward_ref__: getClosureSafeProperty
144
- });
145
- function forwardRef(forwardRefFn) {
146
- forwardRefFn.__forward_ref__ = forwardRef;
147
- forwardRefFn.toString = function () {
148
- return stringify(this());
149
- };
150
- return forwardRefFn;
151
- }
152
- function resolveForwardRef(type) {
153
- return isForwardRef(type) ? type() : type;
154
- }
155
- function isForwardRef(fn) {
156
- return typeof fn === 'function' && fn.hasOwnProperty(__forward_ref__) && fn.__forward_ref__ === forwardRef;
157
- }
158
-
159
- function assertNumber(actual, msg) {
160
- if (!(typeof actual === 'number')) {
161
- throwError(msg, typeof actual, 'number', '===');
162
- }
163
- }
164
- function assertNumberInRange(actual, minInclusive, maxInclusive) {
165
- assertNumber(actual, 'Expected a number');
166
- assertLessThanOrEqual(actual, maxInclusive, 'Expected number to be less than or equal to');
167
- assertGreaterThanOrEqual(actual, minInclusive, 'Expected number to be greater than or equal to');
168
- }
169
- function assertString(actual, msg) {
170
- if (!(typeof actual === 'string')) {
171
- throwError(msg, actual === null ? 'null' : typeof actual, 'string', '===');
172
- }
173
- }
174
- function assertFunction(actual, msg) {
175
- if (!(typeof actual === 'function')) {
176
- throwError(msg, actual === null ? 'null' : typeof actual, 'function', '===');
177
- }
178
- }
179
- function assertEqual(actual, expected, msg) {
180
- if (!(actual == expected)) {
181
- throwError(msg, actual, expected, '==');
182
- }
183
- }
184
- function assertNotEqual(actual, expected, msg) {
185
- if (!(actual != expected)) {
186
- throwError(msg, actual, expected, '!=');
187
- }
188
- }
189
- function assertSame(actual, expected, msg) {
190
- if (!(actual === expected)) {
191
- throwError(msg, actual, expected, '===');
192
- }
193
- }
194
- function assertNotSame(actual, expected, msg) {
195
- if (!(actual !== expected)) {
196
- throwError(msg, actual, expected, '!==');
197
- }
198
- }
199
- function assertLessThan(actual, expected, msg) {
200
- if (!(actual < expected)) {
201
- throwError(msg, actual, expected, '<');
202
- }
203
- }
204
- function assertLessThanOrEqual(actual, expected, msg) {
205
- if (!(actual <= expected)) {
206
- throwError(msg, actual, expected, '<=');
207
- }
208
- }
209
- function assertGreaterThan(actual, expected, msg) {
210
- if (!(actual > expected)) {
211
- throwError(msg, actual, expected, '>');
212
- }
213
- }
214
- function assertGreaterThanOrEqual(actual, expected, msg) {
215
- if (!(actual >= expected)) {
216
- throwError(msg, actual, expected, '>=');
217
- }
218
- }
219
- function assertNotDefined(actual, msg) {
220
- if (actual != null) {
221
- throwError(msg, actual, null, '==');
222
- }
223
- }
224
- function assertDefined(actual, msg) {
225
- if (actual == null) {
226
- throwError(msg, actual, null, '!=');
227
- }
228
- }
229
- function throwError(msg, actual, expected, comparison) {
230
- throw new Error(`ASSERTION ERROR: ${msg}` + (comparison == null ? '' : ` [Expected=> ${expected} ${comparison} ${actual} <=Actual]`));
231
- }
232
- function assertDomNode(node) {
233
- if (!(node instanceof Node)) {
234
- throwError(`The provided value must be an instance of a DOM Node but got ${stringify(node)}`);
235
- }
236
- }
237
- function assertElement(node) {
238
- if (!(node instanceof Element)) {
239
- throwError(`The provided value must be an element but got ${stringify(node)}`);
240
- }
241
- }
242
- function assertIndexInRange(arr, index) {
243
- assertDefined(arr, 'Array must be defined.');
244
- const maxLen = arr.length;
245
- if (index < 0 || index >= maxLen) {
246
- throwError(`Index expected to be less than ${maxLen} but got ${index}`);
247
- }
248
- }
249
- function assertOneOf(value, ...validValues) {
250
- if (validValues.indexOf(value) !== -1) return true;
251
- throwError(`Expected value to be one of ${JSON.stringify(validValues)} but was ${JSON.stringify(value)}.`);
252
- }
253
- function assertNotReactive(fn) {
254
- if (getActiveConsumer() !== null) {
255
- throwError(`${fn}() should never be called in a reactive context.`);
256
- }
257
- }
258
-
259
- function ɵɵdefineInjectable(opts) {
260
- return {
261
- token: opts.token,
262
- providedIn: opts.providedIn || null,
263
- factory: opts.factory,
264
- value: undefined
265
- };
266
- }
267
- function ɵɵdefineInjector(options) {
268
- return {
269
- providers: options.providers || [],
270
- imports: options.imports || []
271
- };
272
- }
273
- function getInjectableDef(type) {
274
- return getOwnDefinition(type, NG_PROV_DEF);
275
- }
276
- function isInjectable(type) {
277
- return getInjectableDef(type) !== null;
278
- }
279
- function getOwnDefinition(type, field) {
280
- return type.hasOwnProperty(field) && type[field] || null;
281
- }
282
- function getInheritedInjectableDef(type) {
283
- const def = type?.[NG_PROV_DEF] ?? null;
284
- if (def) {
285
- ngDevMode && console.warn(`DEPRECATED: DI is instantiating a token "${type.name}" that inherits its @Injectable decorator but does not provide one itself.\n` + `This will become an error in a future version of Angular. Please add @Injectable() to the "${type.name}" class.`);
286
- return def;
287
- } else {
288
- return null;
289
- }
290
- }
291
- function getInjectorDef(type) {
292
- return type && type.hasOwnProperty(NG_INJ_DEF) ? type[NG_INJ_DEF] : null;
293
- }
294
- const NG_PROV_DEF = getClosureSafeProperty({
295
- ɵprov: getClosureSafeProperty
296
- });
297
- const NG_INJ_DEF = getClosureSafeProperty({
298
- ɵinj: getClosureSafeProperty
299
- });
300
-
301
- class InjectionToken {
302
- _desc;
303
- ngMetadataName = 'InjectionToken';
304
- ɵprov;
305
- constructor(_desc, options) {
306
- this._desc = _desc;
307
- this.ɵprov = undefined;
308
- if (typeof options == 'number') {
309
- (typeof ngDevMode === 'undefined' || ngDevMode) && assertLessThan(options, 0, 'Only negative numbers are supported here');
310
- this.__NG_ELEMENT_ID__ = options;
311
- } else if (options !== undefined) {
312
- this.ɵprov = ɵɵdefineInjectable({
313
- token: this,
314
- providedIn: options.providedIn || 'root',
315
- factory: options.factory
316
- });
317
- }
318
- }
319
- get multi() {
320
- return this;
321
- }
322
- toString() {
323
- return `InjectionToken ${this._desc}`;
324
- }
325
- }
326
-
327
- let _injectorProfilerContext;
328
- function getInjectorProfilerContext() {
329
- !ngDevMode && throwError('getInjectorProfilerContext should never be called in production mode');
330
- return _injectorProfilerContext;
331
- }
332
- function setInjectorProfilerContext(context) {
333
- !ngDevMode && throwError('setInjectorProfilerContext should never be called in production mode');
334
- const previous = _injectorProfilerContext;
335
- _injectorProfilerContext = context;
336
- return previous;
337
- }
338
- const injectorProfilerCallbacks = [];
339
- const NOOP_PROFILER_REMOVAL = () => {};
340
- function removeProfiler(profiler) {
341
- const profilerIdx = injectorProfilerCallbacks.indexOf(profiler);
342
- if (profilerIdx !== -1) {
343
- injectorProfilerCallbacks.splice(profilerIdx, 1);
344
- }
345
- }
346
- function setInjectorProfiler(injectorProfiler) {
347
- !ngDevMode && throwError('setInjectorProfiler should never be called in production mode');
348
- if (injectorProfiler !== null) {
349
- if (!injectorProfilerCallbacks.includes(injectorProfiler)) {
350
- injectorProfilerCallbacks.push(injectorProfiler);
351
- }
352
- return () => removeProfiler(injectorProfiler);
353
- } else {
354
- injectorProfilerCallbacks.length = 0;
355
- return NOOP_PROFILER_REMOVAL;
356
- }
357
- }
358
- function injectorProfiler(event) {
359
- !ngDevMode && throwError('Injector profiler should never be called in production mode');
360
- for (let i = 0; i < injectorProfilerCallbacks.length; i++) {
361
- const injectorProfilerCallback = injectorProfilerCallbacks[i];
362
- injectorProfilerCallback(event);
363
- }
364
- }
365
- function emitProviderConfiguredEvent(eventProvider, isViewProvider = false) {
366
- !ngDevMode && throwError('Injector profiler should never be called in production mode');
367
- let token;
368
- if (typeof eventProvider === 'function') {
369
- token = eventProvider;
370
- } else if (eventProvider instanceof InjectionToken) {
371
- token = eventProvider;
372
- } else {
373
- token = resolveForwardRef(eventProvider.provide);
374
- }
375
- let provider = eventProvider;
376
- if (eventProvider instanceof InjectionToken) {
377
- provider = eventProvider.ɵprov || eventProvider;
378
- }
379
- injectorProfiler({
380
- type: 2,
381
- context: getInjectorProfilerContext(),
382
- providerRecord: {
383
- token,
384
- provider,
385
- isViewProvider
386
- }
387
- });
388
- }
389
- function emitInjectorToCreateInstanceEvent(token) {
390
- !ngDevMode && throwError('Injector profiler should never be called in production mode');
391
- injectorProfiler({
392
- type: 5,
393
- context: getInjectorProfilerContext(),
394
- token: token
395
- });
396
- }
397
- function emitInstanceCreatedByInjectorEvent(instance) {
398
- !ngDevMode && throwError('Injector profiler should never be called in production mode');
399
- injectorProfiler({
400
- type: 1,
401
- context: getInjectorProfilerContext(),
402
- instance: {
403
- value: instance
404
- }
405
- });
406
- }
407
- function emitInjectEvent(token, value, flags) {
408
- !ngDevMode && throwError('Injector profiler should never be called in production mode');
409
- injectorProfiler({
410
- type: 0,
411
- context: getInjectorProfilerContext(),
412
- service: {
413
- token,
414
- value,
415
- flags
416
- }
417
- });
418
- }
419
- function emitEffectCreatedEvent(effect) {
420
- !ngDevMode && throwError('Injector profiler should never be called in production mode');
421
- injectorProfiler({
422
- type: 3,
423
- context: getInjectorProfilerContext(),
424
- effect
425
- });
426
- }
427
- function emitAfterRenderEffectPhaseCreatedEvent(effectPhase) {
428
- !ngDevMode && throwError('Injector profiler should never be called in production mode');
429
- injectorProfiler({
430
- type: 4,
431
- context: getInjectorProfilerContext(),
432
- effectPhase
433
- });
434
- }
435
- function runInInjectorProfilerContext(injector, token, callback) {
436
- !ngDevMode && throwError('runInInjectorProfilerContext should never be called in production mode');
437
- const prevInjectContext = setInjectorProfilerContext({
438
- injector,
439
- token
440
- });
441
- try {
442
- callback();
443
- } finally {
444
- setInjectorProfilerContext(prevInjectContext);
445
- }
446
- }
447
-
448
- function isEnvironmentProviders(value) {
449
- return value && !!value.ɵproviders;
450
- }
451
-
452
- const NG_COMP_DEF = getClosureSafeProperty({
453
- ɵcmp: getClosureSafeProperty
454
- });
455
- const NG_DIR_DEF = getClosureSafeProperty({
456
- ɵdir: getClosureSafeProperty
457
- });
458
- const NG_PIPE_DEF = getClosureSafeProperty({
459
- ɵpipe: getClosureSafeProperty
460
- });
461
- const NG_MOD_DEF = getClosureSafeProperty({
462
- ɵmod: getClosureSafeProperty
463
- });
464
- const NG_FACTORY_DEF = getClosureSafeProperty({
465
- ɵfac: getClosureSafeProperty
466
- });
467
- const NG_ELEMENT_ID = getClosureSafeProperty({
468
- __NG_ELEMENT_ID__: getClosureSafeProperty
469
- });
470
- const NG_ENV_ID = getClosureSafeProperty({
471
- __NG_ENV_ID__: getClosureSafeProperty
472
- });
473
-
474
- function getNgModuleDef(type) {
475
- assertTypeDefined(type, '@NgModule');
476
- return type[NG_MOD_DEF] || null;
477
- }
478
- function getNgModuleDefOrThrow(type) {
479
- const ngModuleDef = getNgModuleDef(type);
480
- if (!ngModuleDef) {
481
- throw new RuntimeError(915, (typeof ngDevMode === 'undefined' || ngDevMode) && `Type ${stringify(type)} does not have 'ɵmod' property.`);
482
- }
483
- return ngModuleDef;
484
- }
485
- function getComponentDef(type) {
486
- assertTypeDefined(type, '@Component');
487
- return type[NG_COMP_DEF] || null;
488
- }
489
- function getDirectiveDefOrThrow(type) {
490
- const def = getDirectiveDef(type);
491
- if (!def) {
492
- throw new RuntimeError(916, (typeof ngDevMode === 'undefined' || ngDevMode) && `Type ${stringify(type)} does not have 'ɵdir' property.`);
493
- }
494
- return def;
495
- }
496
- function getDirectiveDef(type) {
497
- assertTypeDefined(type, '@Directive');
498
- return type[NG_DIR_DEF] || null;
499
- }
500
- function getPipeDef(type) {
501
- assertTypeDefined(type, '@Pipe');
502
- return type[NG_PIPE_DEF] || null;
503
- }
504
- function assertTypeDefined(type, symbolType) {
505
- if (type == null) {
506
- throw new RuntimeError(-919, (typeof ngDevMode === 'undefined' || ngDevMode) && `Cannot read ${symbolType} metadata. This can indicate a runtime ` + `circular dependency in your app that needs to be resolved.`);
507
- }
508
- }
509
- function isStandalone(type) {
510
- const def = getComponentDef(type) || getDirectiveDef(type) || getPipeDef(type);
511
- return def !== null && def.standalone;
512
- }
513
-
514
- function renderStringify(value) {
515
- if (typeof value === 'string') return value;
516
- if (value == null) return '';
517
- return String(value);
518
- }
519
- function stringifyForError(value) {
520
- if (typeof value === 'function') return value.name || value.toString();
521
- if (typeof value === 'object' && value != null && typeof value.type === 'function') {
522
- return value.type.name || value.type.toString();
523
- }
524
- return renderStringify(value);
525
- }
526
- function debugStringifyTypeForError(type) {
527
- const componentDef = getComponentDef(type);
528
- if (componentDef !== null && componentDef.debugInfo) {
529
- return stringifyTypeFromDebugInfo(componentDef.debugInfo);
530
- }
531
- return stringifyForError(type);
532
- }
533
- function stringifyTypeFromDebugInfo(debugInfo) {
534
- if (!debugInfo.filePath || !debugInfo.lineNumber) {
535
- return debugInfo.className;
536
- } else {
537
- return `${debugInfo.className} (at ${debugInfo.filePath}:${debugInfo.lineNumber})`;
538
- }
539
- }
540
-
541
- const NG_RUNTIME_ERROR_CODE = getClosureSafeProperty({
542
- 'ngErrorCode': getClosureSafeProperty
543
- });
544
- const NG_RUNTIME_ERROR_MESSAGE = getClosureSafeProperty({
545
- 'ngErrorMessage': getClosureSafeProperty
546
- });
547
- const NG_TOKEN_PATH = getClosureSafeProperty({
548
- 'ngTokenPath': getClosureSafeProperty
549
- });
550
- function cyclicDependencyError(token, path) {
551
- const message = ngDevMode ? `Circular dependency detected for \`${token}\`.` : '';
552
- return createRuntimeError(message, -200, path);
553
- }
554
- function cyclicDependencyErrorWithDetails(token, path) {
555
- return augmentRuntimeError(cyclicDependencyError(token, path), null);
556
- }
557
- function throwMixedMultiProviderError() {
558
- throw new Error(`Cannot mix multi providers and regular providers`);
559
- }
560
- function throwInvalidProviderError(ngModuleType, providers, provider) {
561
- if (ngModuleType && providers) {
562
- const providerDetail = providers.map(v => v == provider ? '?' + provider + '?' : '...');
563
- throw new Error(`Invalid provider for the NgModule '${stringify(ngModuleType)}' - only instances of Provider and Type are allowed, got: [${providerDetail.join(', ')}]`);
564
- } else if (isEnvironmentProviders(provider)) {
565
- if (provider.ɵfromNgModule) {
566
- throw new RuntimeError(207, `Invalid providers from 'importProvidersFrom' present in a non-environment injector. 'importProvidersFrom' can't be used for component providers.`);
567
- } else {
568
- throw new RuntimeError(207, `Invalid providers present in a non-environment injector. 'EnvironmentProviders' can't be used for component providers.`);
569
- }
570
- } else {
571
- throw new Error('Invalid provider');
572
- }
573
- }
574
- function throwProviderNotFoundError(token, injectorName) {
575
- const errorMessage = ngDevMode && `No provider for ${stringifyForError(token)} found${injectorName ? ` in ${injectorName}` : ''}`;
576
- throw new RuntimeError(-201, errorMessage);
577
- }
578
- function prependTokenToDependencyPath(error, token) {
579
- error[NG_TOKEN_PATH] ??= [];
580
- const currentPath = error[NG_TOKEN_PATH];
581
- let pathStr;
582
- if (typeof token === 'object' && 'multi' in token && token?.multi === true) {
583
- assertDefined(token.provide, 'Token with multi: true should have a provide property');
584
- pathStr = stringifyForError(token.provide);
585
- } else {
586
- pathStr = stringifyForError(token);
587
- }
588
- if (currentPath[0] !== pathStr) {
589
- error[NG_TOKEN_PATH].unshift(pathStr);
590
- }
591
- }
592
- function augmentRuntimeError(error, source) {
593
- const tokenPath = error[NG_TOKEN_PATH];
594
- const errorCode = error[NG_RUNTIME_ERROR_CODE];
595
- const message = error[NG_RUNTIME_ERROR_MESSAGE] || error.message;
596
- error.message = formatErrorMessage(message, errorCode, tokenPath, source);
597
- return error;
598
- }
599
- function createRuntimeError(message, code, path) {
600
- const error = new RuntimeError(code, message);
601
- error[NG_RUNTIME_ERROR_CODE] = code;
602
- error[NG_RUNTIME_ERROR_MESSAGE] = message;
603
- if (path) {
604
- error[NG_TOKEN_PATH] = path;
605
- }
606
- return error;
607
- }
608
- function getRuntimeErrorCode(error) {
609
- return error[NG_RUNTIME_ERROR_CODE];
610
- }
611
- function formatErrorMessage(text, code, path = [], source = null) {
612
- let pathDetails = '';
613
- if (path && path.length > 1) {
614
- pathDetails = ` Path: ${path.join(' -> ')}.`;
615
- }
616
- const sourceDetails = source ? ` Source: ${source}.` : '';
617
- return formatRuntimeError(code, `${text}${sourceDetails}${pathDetails}`);
618
- }
619
-
620
- let _injectImplementation;
621
- function getInjectImplementation() {
622
- return _injectImplementation;
623
- }
624
- function setInjectImplementation(impl) {
625
- const previous = _injectImplementation;
626
- _injectImplementation = impl;
627
- return previous;
628
- }
629
- function injectRootLimpMode(token, notFoundValue, flags) {
630
- const injectableDef = getInjectableDef(token);
631
- if (injectableDef && injectableDef.providedIn == 'root') {
632
- return injectableDef.value === undefined ? injectableDef.value = injectableDef.factory() : injectableDef.value;
633
- }
634
- if (flags & 8) return null;
635
- if (notFoundValue !== undefined) return notFoundValue;
636
- throwProviderNotFoundError(token, typeof ngDevMode !== 'undefined' && ngDevMode ? 'Injector' : '');
637
- }
638
- function assertInjectImplementationNotEqual(fn) {
639
- ngDevMode && assertNotEqual(_injectImplementation, fn, 'Calling ɵɵinject would cause infinite recursion');
640
- }
641
-
642
- const _THROW_IF_NOT_FOUND = {};
643
- const THROW_IF_NOT_FOUND = _THROW_IF_NOT_FOUND;
644
- const DI_DECORATOR_FLAG = '__NG_DI_FLAG__';
645
- class RetrievingInjector {
646
- injector;
647
- constructor(injector) {
648
- this.injector = injector;
649
- }
650
- retrieve(token, options) {
651
- const flags = convertToBitFlags(options) || 0;
652
- try {
653
- return this.injector.get(token, flags & 8 ? null : THROW_IF_NOT_FOUND, flags);
654
- } catch (e) {
655
- if (isNotFound(e)) {
656
- return e;
657
- }
658
- throw e;
659
- }
660
- }
661
- }
662
- function injectInjectorOnly(token, flags = 0) {
663
- const currentInjector = getCurrentInjector();
664
- if (currentInjector === undefined) {
665
- throw new RuntimeError(-203, ngDevMode && `The \`${stringify(token)}\` token injection failed. \`inject()\` function must be called from an injection context such as a constructor, a factory function, a field initializer, or a function used with \`runInInjectionContext\`.`);
666
- } else if (currentInjector === null) {
667
- return injectRootLimpMode(token, undefined, flags);
668
- } else {
669
- const options = convertToInjectOptions(flags);
670
- const value = currentInjector.retrieve(token, options);
671
- ngDevMode && emitInjectEvent(token, value, flags);
672
- if (isNotFound(value)) {
673
- if (options.optional) {
674
- return null;
675
- }
676
- throw value;
677
- }
678
- return value;
679
- }
680
- }
681
- function ɵɵinject(token, flags = 0) {
682
- return (getInjectImplementation() || injectInjectorOnly)(resolveForwardRef(token), flags);
683
- }
684
- function ɵɵinvalidFactoryDep(index) {
685
- throw new RuntimeError(202, ngDevMode && `This constructor is not compatible with Angular Dependency Injection because its dependency at index ${index} of the parameter list is invalid.
686
- This can happen if the dependency type is a primitive like a string or if an ancestor of this class is missing an Angular decorator.
687
-
688
- Please check that 1) the type for the parameter at index ${index} is correct and 2) the correct Angular decorators are defined for this class and its ancestors.`);
689
- }
690
- function inject(token, options) {
691
- return ɵɵinject(token, convertToBitFlags(options));
692
- }
693
- function convertToBitFlags(flags) {
694
- if (typeof flags === 'undefined' || typeof flags === 'number') {
695
- return flags;
696
- }
697
- return 0 | (flags.optional && 8) | (flags.host && 1) | (flags.self && 2) | (flags.skipSelf && 4);
698
- }
699
- function convertToInjectOptions(flags) {
700
- return {
701
- optional: !!(flags & 8),
702
- host: !!(flags & 1),
703
- self: !!(flags & 2),
704
- skipSelf: !!(flags & 4)
705
- };
706
- }
707
- function injectArgs(types) {
708
- const args = [];
709
- for (let i = 0; i < types.length; i++) {
710
- const arg = resolveForwardRef(types[i]);
711
- if (Array.isArray(arg)) {
712
- if (arg.length === 0) {
713
- throw new RuntimeError(900, ngDevMode && 'Arguments array must have arguments.');
714
- }
715
- let type = undefined;
716
- let flags = 0;
717
- for (let j = 0; j < arg.length; j++) {
718
- const meta = arg[j];
719
- const flag = getInjectFlag(meta);
720
- if (typeof flag === 'number') {
721
- if (flag === -1) {
722
- type = meta.token;
723
- } else {
724
- flags |= flag;
725
- }
726
- } else {
727
- type = meta;
728
- }
729
- }
730
- args.push(ɵɵinject(type, flags));
731
- } else {
732
- args.push(ɵɵinject(arg));
733
- }
734
- }
735
- return args;
736
- }
737
- function attachInjectFlag(decorator, flag) {
738
- decorator[DI_DECORATOR_FLAG] = flag;
739
- decorator.prototype[DI_DECORATOR_FLAG] = flag;
740
- return decorator;
741
- }
742
- function getInjectFlag(token) {
743
- return token[DI_DECORATOR_FLAG];
744
- }
745
-
746
- function getFactoryDef(type, throwNotFound) {
747
- const hasFactoryDef = type.hasOwnProperty(NG_FACTORY_DEF);
748
- if (!hasFactoryDef && throwNotFound === true && ngDevMode) {
749
- throw new Error(`Type ${stringify(type)} does not have 'ɵfac' property.`);
750
- }
751
- return hasFactoryDef ? type[NG_FACTORY_DEF] : null;
752
- }
753
-
754
- function arrayEquals(a, b, identityAccessor) {
755
- if (a.length !== b.length) return false;
756
- for (let i = 0; i < a.length; i++) {
757
- let valueA = a[i];
758
- let valueB = b[i];
759
- if (identityAccessor) {
760
- valueA = identityAccessor(valueA);
761
- valueB = identityAccessor(valueB);
762
- }
763
- if (valueB !== valueA) {
764
- return false;
765
- }
766
- }
767
- return true;
768
- }
769
- function flatten(list) {
770
- return list.flat(Number.POSITIVE_INFINITY);
771
- }
772
- function deepForEach(input, fn) {
773
- input.forEach(value => Array.isArray(value) ? deepForEach(value, fn) : fn(value));
774
- }
775
- function addToArray(arr, index, value) {
776
- if (index >= arr.length) {
777
- arr.push(value);
778
- } else {
779
- arr.splice(index, 0, value);
780
- }
781
- }
782
- function removeFromArray(arr, index) {
783
- if (index >= arr.length - 1) {
784
- return arr.pop();
785
- } else {
786
- return arr.splice(index, 1)[0];
787
- }
788
- }
789
- function newArray(size, value) {
790
- const list = [];
791
- for (let i = 0; i < size; i++) {
792
- list.push(value);
793
- }
794
- return list;
795
- }
796
- function arraySplice(array, index, count) {
797
- const length = array.length - count;
798
- while (index < length) {
799
- array[index] = array[index + count];
800
- index++;
801
- }
802
- while (count--) {
803
- array.pop();
804
- }
805
- }
806
- function arrayInsert2(array, index, value1, value2) {
807
- ngDevMode && assertLessThanOrEqual(index, array.length, "Can't insert past array end.");
808
- let end = array.length;
809
- if (end == index) {
810
- array.push(value1, value2);
811
- } else if (end === 1) {
812
- array.push(value2, array[0]);
813
- array[0] = value1;
814
- } else {
815
- end--;
816
- array.push(array[end - 1], array[end]);
817
- while (end > index) {
818
- const previousEnd = end - 2;
819
- array[end] = array[previousEnd];
820
- end--;
821
- }
822
- array[index] = value1;
823
- array[index + 1] = value2;
824
- }
825
- }
826
- function keyValueArraySet(keyValueArray, key, value) {
827
- let index = keyValueArrayIndexOf(keyValueArray, key);
828
- if (index >= 0) {
829
- keyValueArray[index | 1] = value;
830
- } else {
831
- index = ~index;
832
- arrayInsert2(keyValueArray, index, key, value);
833
- }
834
- return index;
835
- }
836
- function keyValueArrayGet(keyValueArray, key) {
837
- const index = keyValueArrayIndexOf(keyValueArray, key);
838
- if (index >= 0) {
839
- return keyValueArray[index | 1];
840
- }
841
- return undefined;
842
- }
843
- function keyValueArrayIndexOf(keyValueArray, key) {
844
- return _arrayIndexOfSorted(keyValueArray, key, 1);
845
- }
846
- function _arrayIndexOfSorted(array, value, shift) {
847
- ngDevMode && assertEqual(Array.isArray(array), true, 'Expecting an array');
848
- let start = 0;
849
- let end = array.length >> shift;
850
- while (end !== start) {
851
- const middle = start + (end - start >> 1);
852
- const current = array[middle << shift];
853
- if (value === current) {
854
- return middle << shift;
855
- } else if (current > value) {
856
- end = middle;
857
- } else {
858
- start = middle + 1;
859
- }
860
- }
861
- return ~(end << shift);
862
- }
863
-
864
- const EMPTY_OBJ = {};
865
- const EMPTY_ARRAY = [];
866
- if ((typeof ngDevMode === 'undefined' || ngDevMode) && initNgDevMode()) {
867
- Object.freeze(EMPTY_OBJ);
868
- Object.freeze(EMPTY_ARRAY);
869
- }
870
-
871
- const ENVIRONMENT_INITIALIZER = new InjectionToken(typeof ngDevMode !== 'undefined' && ngDevMode ? 'ENVIRONMENT_INITIALIZER' : '');
872
-
873
- const INJECTOR$1 = new InjectionToken(typeof ngDevMode !== 'undefined' && ngDevMode ? 'INJECTOR' : '', -1);
874
-
875
- const INJECTOR_DEF_TYPES = new InjectionToken(typeof ngDevMode !== 'undefined' && ngDevMode ? 'INJECTOR_DEF_TYPES' : '');
876
-
877
- class NullInjector {
878
- get(token, notFoundValue = THROW_IF_NOT_FOUND) {
879
- if (notFoundValue === THROW_IF_NOT_FOUND) {
880
- const message = ngDevMode ? `No provider found for \`${stringify(token)}\`.` : '';
881
- const error = createRuntimeError(message, -201);
882
- error.name = 'ɵNotFound';
883
- throw error;
884
- }
885
- return notFoundValue;
886
- }
887
- }
888
-
889
- function makeEnvironmentProviders(providers) {
890
- return {
891
- ɵproviders: providers
892
- };
893
- }
894
- function provideEnvironmentInitializer(initializerFn) {
895
- return makeEnvironmentProviders([{
896
- provide: ENVIRONMENT_INITIALIZER,
897
- multi: true,
898
- useValue: initializerFn
899
- }]);
900
- }
901
- function importProvidersFrom(...sources) {
902
- return {
903
- ɵproviders: internalImportProvidersFrom(true, sources),
904
- ɵfromNgModule: true
905
- };
906
- }
907
- function internalImportProvidersFrom(checkForStandaloneCmp, ...sources) {
908
- const providersOut = [];
909
- const dedup = new Set();
910
- let injectorTypesWithProviders;
911
- const collectProviders = provider => {
912
- providersOut.push(provider);
913
- };
914
- deepForEach(sources, source => {
915
- if ((typeof ngDevMode === 'undefined' || ngDevMode) && checkForStandaloneCmp) {
916
- const cmpDef = getComponentDef(source);
917
- if (cmpDef?.standalone) {
918
- throw new RuntimeError(800, `Importing providers supports NgModule or ModuleWithProviders but got a standalone component "${stringifyForError(source)}"`);
919
- }
920
- }
921
- const internalSource = source;
922
- if (walkProviderTree(internalSource, collectProviders, [], dedup)) {
923
- injectorTypesWithProviders ||= [];
924
- injectorTypesWithProviders.push(internalSource);
925
- }
926
- });
927
- if (injectorTypesWithProviders !== undefined) {
928
- processInjectorTypesWithProviders(injectorTypesWithProviders, collectProviders);
929
- }
930
- return providersOut;
931
- }
932
- function processInjectorTypesWithProviders(typesWithProviders, visitor) {
933
- for (let i = 0; i < typesWithProviders.length; i++) {
934
- const {
935
- ngModule,
936
- providers
937
- } = typesWithProviders[i];
938
- deepForEachProvider(providers, provider => {
939
- ngDevMode && validateProvider(provider, providers || EMPTY_ARRAY, ngModule);
940
- visitor(provider, ngModule);
941
- });
942
- }
943
- }
944
- function walkProviderTree(container, visitor, parents, dedup) {
945
- container = resolveForwardRef(container);
946
- if (!container) return false;
947
- let defType = null;
948
- let injDef = getInjectorDef(container);
949
- const cmpDef = !injDef && getComponentDef(container);
950
- if (!injDef && !cmpDef) {
951
- const ngModule = container.ngModule;
952
- injDef = getInjectorDef(ngModule);
953
- if (injDef) {
954
- defType = ngModule;
955
- } else {
956
- return false;
957
- }
958
- } else if (cmpDef && !cmpDef.standalone) {
959
- return false;
960
- } else {
961
- defType = container;
962
- }
963
- if (ngDevMode && parents.indexOf(defType) !== -1) {
964
- const defName = stringify(defType);
965
- const path = parents.map(stringify).concat(defName);
966
- throw cyclicDependencyErrorWithDetails(defName, path);
967
- }
968
- const isDuplicate = dedup.has(defType);
969
- if (cmpDef) {
970
- if (isDuplicate) {
971
- return false;
972
- }
973
- dedup.add(defType);
974
- if (cmpDef.dependencies) {
975
- const deps = typeof cmpDef.dependencies === 'function' ? cmpDef.dependencies() : cmpDef.dependencies;
976
- for (const dep of deps) {
977
- walkProviderTree(dep, visitor, parents, dedup);
978
- }
979
- }
980
- } else if (injDef) {
981
- if (injDef.imports != null && !isDuplicate) {
982
- ngDevMode && parents.push(defType);
983
- dedup.add(defType);
984
- let importTypesWithProviders;
985
- try {
986
- deepForEach(injDef.imports, imported => {
987
- if (walkProviderTree(imported, visitor, parents, dedup)) {
988
- importTypesWithProviders ||= [];
989
- importTypesWithProviders.push(imported);
990
- }
991
- });
992
- } finally {
993
- ngDevMode && parents.pop();
994
- }
995
- if (importTypesWithProviders !== undefined) {
996
- processInjectorTypesWithProviders(importTypesWithProviders, visitor);
997
- }
998
- }
999
- if (!isDuplicate) {
1000
- const factory = getFactoryDef(defType) || (() => new defType());
1001
- visitor({
1002
- provide: defType,
1003
- useFactory: factory,
1004
- deps: EMPTY_ARRAY
1005
- }, defType);
1006
- visitor({
1007
- provide: INJECTOR_DEF_TYPES,
1008
- useValue: defType,
1009
- multi: true
1010
- }, defType);
1011
- visitor({
1012
- provide: ENVIRONMENT_INITIALIZER,
1013
- useValue: () => ɵɵinject(defType),
1014
- multi: true
1015
- }, defType);
1016
- }
1017
- const defProviders = injDef.providers;
1018
- if (defProviders != null && !isDuplicate) {
1019
- const injectorType = container;
1020
- deepForEachProvider(defProviders, provider => {
1021
- ngDevMode && validateProvider(provider, defProviders, injectorType);
1022
- visitor(provider, injectorType);
1023
- });
1024
- }
1025
- } else {
1026
- return false;
1027
- }
1028
- return defType !== container && container.providers !== undefined;
1029
- }
1030
- function validateProvider(provider, providers, containerType) {
1031
- if (isTypeProvider(provider) || isValueProvider(provider) || isFactoryProvider(provider) || isExistingProvider(provider)) {
1032
- return;
1033
- }
1034
- const classRef = resolveForwardRef(provider && (provider.useClass || provider.provide));
1035
- if (!classRef) {
1036
- throwInvalidProviderError(containerType, providers, provider);
1037
- }
1038
- }
1039
- function deepForEachProvider(providers, fn) {
1040
- for (let provider of providers) {
1041
- if (isEnvironmentProviders(provider)) {
1042
- provider = provider.ɵproviders;
1043
- }
1044
- if (Array.isArray(provider)) {
1045
- deepForEachProvider(provider, fn);
1046
- } else {
1047
- fn(provider);
1048
- }
1049
- }
1050
- }
1051
- const USE_VALUE = getClosureSafeProperty({
1052
- provide: String,
1053
- useValue: getClosureSafeProperty
1054
- });
1055
- function isValueProvider(value) {
1056
- return value !== null && typeof value == 'object' && USE_VALUE in value;
1057
- }
1058
- function isExistingProvider(value) {
1059
- return !!(value && value.useExisting);
1060
- }
1061
- function isFactoryProvider(value) {
1062
- return !!(value && value.useFactory);
1063
- }
1064
- function isTypeProvider(value) {
1065
- return typeof value === 'function';
1066
- }
1067
- function isClassProvider(value) {
1068
- return !!value.useClass;
1069
- }
1070
-
1071
- const INJECTOR_SCOPE = new InjectionToken(typeof ngDevMode !== 'undefined' && ngDevMode ? 'Set Injector scope.' : '');
1072
-
1073
- const NOT_YET = {};
1074
- const CIRCULAR = {};
1075
- let NULL_INJECTOR = undefined;
1076
- function getNullInjector() {
1077
- if (NULL_INJECTOR === undefined) {
1078
- NULL_INJECTOR = new NullInjector();
1079
- }
1080
- return NULL_INJECTOR;
1081
- }
1082
- class EnvironmentInjector {}
1083
- class R3Injector extends EnvironmentInjector {
1084
- parent;
1085
- source;
1086
- scopes;
1087
- records = new Map();
1088
- _ngOnDestroyHooks = new Set();
1089
- _onDestroyHooks = [];
1090
- get destroyed() {
1091
- return this._destroyed;
1092
- }
1093
- _destroyed = false;
1094
- injectorDefTypes;
1095
- constructor(providers, parent, source, scopes) {
1096
- super();
1097
- this.parent = parent;
1098
- this.source = source;
1099
- this.scopes = scopes;
1100
- forEachSingleProvider(providers, provider => this.processProvider(provider));
1101
- this.records.set(INJECTOR$1, makeRecord(undefined, this));
1102
- if (scopes.has('environment')) {
1103
- this.records.set(EnvironmentInjector, makeRecord(undefined, this));
1104
- }
1105
- const record = this.records.get(INJECTOR_SCOPE);
1106
- if (record != null && typeof record.value === 'string') {
1107
- this.scopes.add(record.value);
1108
- }
1109
- this.injectorDefTypes = new Set(this.get(INJECTOR_DEF_TYPES, EMPTY_ARRAY, {
1110
- self: true
1111
- }));
1112
- }
1113
- retrieve(token, options) {
1114
- const flags = convertToBitFlags(options) || 0;
1115
- try {
1116
- return this.get(token, THROW_IF_NOT_FOUND, flags);
1117
- } catch (e) {
1118
- if (isNotFound$1(e)) {
1119
- return e;
1120
- }
1121
- throw e;
1122
- }
1123
- }
1124
- destroy() {
1125
- assertNotDestroyed(this);
1126
- this._destroyed = true;
1127
- const prevConsumer = setActiveConsumer(null);
1128
- try {
1129
- for (const service of this._ngOnDestroyHooks) {
1130
- service.ngOnDestroy();
1131
- }
1132
- const onDestroyHooks = this._onDestroyHooks;
1133
- this._onDestroyHooks = [];
1134
- for (const hook of onDestroyHooks) {
1135
- hook();
1136
- }
1137
- } finally {
1138
- this.records.clear();
1139
- this._ngOnDestroyHooks.clear();
1140
- this.injectorDefTypes.clear();
1141
- setActiveConsumer(prevConsumer);
1142
- }
1143
- }
1144
- onDestroy(callback) {
1145
- assertNotDestroyed(this);
1146
- this._onDestroyHooks.push(callback);
1147
- return () => this.removeOnDestroy(callback);
1148
- }
1149
- runInContext(fn) {
1150
- assertNotDestroyed(this);
1151
- const previousInjector = setCurrentInjector(this);
1152
- const previousInjectImplementation = setInjectImplementation(undefined);
1153
- let prevInjectContext;
1154
- if (ngDevMode) {
1155
- prevInjectContext = setInjectorProfilerContext({
1156
- injector: this,
1157
- token: null
1158
- });
1159
- }
1160
- try {
1161
- return fn();
1162
- } finally {
1163
- setCurrentInjector(previousInjector);
1164
- setInjectImplementation(previousInjectImplementation);
1165
- ngDevMode && setInjectorProfilerContext(prevInjectContext);
1166
- }
1167
- }
1168
- get(token, notFoundValue = THROW_IF_NOT_FOUND, options) {
1169
- assertNotDestroyed(this);
1170
- if (token.hasOwnProperty(NG_ENV_ID)) {
1171
- return token[NG_ENV_ID](this);
1172
- }
1173
- const flags = convertToBitFlags(options);
1174
- let prevInjectContext;
1175
- if (ngDevMode) {
1176
- prevInjectContext = setInjectorProfilerContext({
1177
- injector: this,
1178
- token: token
1179
- });
1180
- }
1181
- const previousInjector = setCurrentInjector(this);
1182
- const previousInjectImplementation = setInjectImplementation(undefined);
1183
- try {
1184
- if (!(flags & 4)) {
1185
- let record = this.records.get(token);
1186
- if (record === undefined) {
1187
- const def = couldBeInjectableType(token) && getInjectableDef(token);
1188
- if (def && this.injectableDefInScope(def)) {
1189
- if (ngDevMode) {
1190
- runInInjectorProfilerContext(this, token, () => {
1191
- emitProviderConfiguredEvent(token);
1192
- });
1193
- }
1194
- record = makeRecord(injectableDefOrInjectorDefFactory(token), NOT_YET);
1195
- } else {
1196
- record = null;
1197
- }
1198
- this.records.set(token, record);
1199
- }
1200
- if (record != null) {
1201
- return this.hydrate(token, record, flags);
1202
- }
1203
- }
1204
- const nextInjector = !(flags & 2) ? this.parent : getNullInjector();
1205
- notFoundValue = flags & 8 && notFoundValue === THROW_IF_NOT_FOUND ? null : notFoundValue;
1206
- return nextInjector.get(token, notFoundValue);
1207
- } catch (error) {
1208
- const errorCode = getRuntimeErrorCode(error);
1209
- if (errorCode === -200 || errorCode === -201) {
1210
- if (ngDevMode) {
1211
- prependTokenToDependencyPath(error, token);
1212
- if (previousInjector) {
1213
- throw error;
1214
- } else {
1215
- throw augmentRuntimeError(error, this.source);
1216
- }
1217
- } else {
1218
- throw new RuntimeError(errorCode, null);
1219
- }
1220
- } else {
1221
- throw error;
1222
- }
1223
- } finally {
1224
- setInjectImplementation(previousInjectImplementation);
1225
- setCurrentInjector(previousInjector);
1226
- ngDevMode && setInjectorProfilerContext(prevInjectContext);
1227
- }
1228
- }
1229
- resolveInjectorInitializers() {
1230
- const prevConsumer = setActiveConsumer(null);
1231
- const previousInjector = setCurrentInjector(this);
1232
- const previousInjectImplementation = setInjectImplementation(undefined);
1233
- let prevInjectContext;
1234
- if (ngDevMode) {
1235
- prevInjectContext = setInjectorProfilerContext({
1236
- injector: this,
1237
- token: null
1238
- });
1239
- }
1240
- try {
1241
- const initializers = this.get(ENVIRONMENT_INITIALIZER, EMPTY_ARRAY, {
1242
- self: true
1243
- });
1244
- if (ngDevMode && !Array.isArray(initializers)) {
1245
- throw new RuntimeError(-209, 'Unexpected type of the `ENVIRONMENT_INITIALIZER` token value ' + `(expected an array, but got ${typeof initializers}). ` + 'Please check that the `ENVIRONMENT_INITIALIZER` token is configured as a ' + '`multi: true` provider.');
1246
- }
1247
- for (const initializer of initializers) {
1248
- initializer();
1249
- }
1250
- } finally {
1251
- setCurrentInjector(previousInjector);
1252
- setInjectImplementation(previousInjectImplementation);
1253
- ngDevMode && setInjectorProfilerContext(prevInjectContext);
1254
- setActiveConsumer(prevConsumer);
1255
- }
1256
- }
1257
- toString() {
1258
- const tokens = [];
1259
- const records = this.records;
1260
- for (const token of records.keys()) {
1261
- tokens.push(stringify(token));
1262
- }
1263
- return `R3Injector[${tokens.join(', ')}]`;
1264
- }
1265
- processProvider(provider) {
1266
- provider = resolveForwardRef(provider);
1267
- let token = isTypeProvider(provider) ? provider : resolveForwardRef(provider && provider.provide);
1268
- const record = providerToRecord(provider);
1269
- if (ngDevMode) {
1270
- runInInjectorProfilerContext(this, token, () => {
1271
- if (isValueProvider(provider)) {
1272
- emitInjectorToCreateInstanceEvent(token);
1273
- emitInstanceCreatedByInjectorEvent(provider.useValue);
1274
- }
1275
- emitProviderConfiguredEvent(provider);
1276
- });
1277
- }
1278
- if (!isTypeProvider(provider) && provider.multi === true) {
1279
- let multiRecord = this.records.get(token);
1280
- if (multiRecord) {
1281
- if (ngDevMode && multiRecord.multi === undefined) {
1282
- throwMixedMultiProviderError();
1283
- }
1284
- } else {
1285
- multiRecord = makeRecord(undefined, NOT_YET, true);
1286
- multiRecord.factory = () => injectArgs(multiRecord.multi);
1287
- this.records.set(token, multiRecord);
1288
- }
1289
- token = provider;
1290
- multiRecord.multi.push(provider);
1291
- } else {
1292
- if (ngDevMode) {
1293
- const existing = this.records.get(token);
1294
- if (existing && existing.multi !== undefined) {
1295
- throwMixedMultiProviderError();
1296
- }
1297
- }
1298
- }
1299
- this.records.set(token, record);
1300
- }
1301
- hydrate(token, record, flags) {
1302
- const prevConsumer = setActiveConsumer(null);
1303
- try {
1304
- if (record.value === CIRCULAR) {
1305
- throw cyclicDependencyError(stringify(token));
1306
- } else if (record.value === NOT_YET) {
1307
- record.value = CIRCULAR;
1308
- if (ngDevMode) {
1309
- runInInjectorProfilerContext(this, token, () => {
1310
- emitInjectorToCreateInstanceEvent(token);
1311
- record.value = record.factory(undefined, flags);
1312
- emitInstanceCreatedByInjectorEvent(record.value);
1313
- });
1314
- } else {
1315
- record.value = record.factory(undefined, flags);
1316
- }
1317
- }
1318
- if (typeof record.value === 'object' && record.value && hasOnDestroy(record.value)) {
1319
- this._ngOnDestroyHooks.add(record.value);
1320
- }
1321
- return record.value;
1322
- } finally {
1323
- setActiveConsumer(prevConsumer);
1324
- }
1325
- }
1326
- injectableDefInScope(def) {
1327
- if (!def.providedIn) {
1328
- return false;
1329
- }
1330
- const providedIn = resolveForwardRef(def.providedIn);
1331
- if (typeof providedIn === 'string') {
1332
- return providedIn === 'any' || this.scopes.has(providedIn);
1333
- } else {
1334
- return this.injectorDefTypes.has(providedIn);
1335
- }
1336
- }
1337
- removeOnDestroy(callback) {
1338
- const destroyCBIdx = this._onDestroyHooks.indexOf(callback);
1339
- if (destroyCBIdx !== -1) {
1340
- this._onDestroyHooks.splice(destroyCBIdx, 1);
1341
- }
1342
- }
1343
- }
1344
- function injectableDefOrInjectorDefFactory(token) {
1345
- const injectableDef = getInjectableDef(token);
1346
- const factory = injectableDef !== null ? injectableDef.factory : getFactoryDef(token);
1347
- if (factory !== null) {
1348
- return factory;
1349
- }
1350
- if (token instanceof InjectionToken) {
1351
- throw new RuntimeError(204, ngDevMode && `Token ${stringify(token)} is missing a ɵprov definition.`);
1352
- }
1353
- if (token instanceof Function) {
1354
- return getUndecoratedInjectableFactory(token);
1355
- }
1356
- throw new RuntimeError(204, ngDevMode && 'unreachable');
1357
- }
1358
- function getUndecoratedInjectableFactory(token) {
1359
- const paramLength = token.length;
1360
- if (paramLength > 0) {
1361
- throw new RuntimeError(204, ngDevMode && `Can't resolve all parameters for ${stringify(token)}: (${newArray(paramLength, '?').join(', ')}).`);
1362
- }
1363
- const inheritedInjectableDef = getInheritedInjectableDef(token);
1364
- if (inheritedInjectableDef !== null) {
1365
- return () => inheritedInjectableDef.factory(token);
1366
- } else {
1367
- return () => new token();
1368
- }
1369
- }
1370
- function providerToRecord(provider) {
1371
- if (isValueProvider(provider)) {
1372
- return makeRecord(undefined, provider.useValue);
1373
- } else {
1374
- const factory = providerToFactory(provider);
1375
- return makeRecord(factory, NOT_YET);
1376
- }
1377
- }
1378
- function providerToFactory(provider, ngModuleType, providers) {
1379
- let factory = undefined;
1380
- if (ngDevMode && isEnvironmentProviders(provider)) {
1381
- throwInvalidProviderError(undefined, providers, provider);
1382
- }
1383
- if (isTypeProvider(provider)) {
1384
- const unwrappedProvider = resolveForwardRef(provider);
1385
- return getFactoryDef(unwrappedProvider) || injectableDefOrInjectorDefFactory(unwrappedProvider);
1386
- } else {
1387
- if (isValueProvider(provider)) {
1388
- factory = () => resolveForwardRef(provider.useValue);
1389
- } else if (isFactoryProvider(provider)) {
1390
- factory = () => provider.useFactory(...injectArgs(provider.deps || []));
1391
- } else if (isExistingProvider(provider)) {
1392
- factory = (_, flags) => ɵɵinject(resolveForwardRef(provider.useExisting), flags !== undefined && flags & 8 ? 8 : undefined);
1393
- } else {
1394
- const classRef = resolveForwardRef(provider && (provider.useClass || provider.provide));
1395
- if (ngDevMode && !classRef) {
1396
- throwInvalidProviderError(ngModuleType, providers, provider);
1397
- }
1398
- if (hasDeps(provider)) {
1399
- factory = () => new classRef(...injectArgs(provider.deps));
1400
- } else {
1401
- return getFactoryDef(classRef) || injectableDefOrInjectorDefFactory(classRef);
1402
- }
1403
- }
1404
- }
1405
- return factory;
1406
- }
1407
- function assertNotDestroyed(injector) {
1408
- if (injector.destroyed) {
1409
- throw new RuntimeError(205, ngDevMode && 'Injector has already been destroyed.');
1410
- }
1411
- }
1412
- function makeRecord(factory, value, multi = false) {
1413
- return {
1414
- factory: factory,
1415
- value: value,
1416
- multi: multi ? [] : undefined
1417
- };
1418
- }
1419
- function hasDeps(value) {
1420
- return !!value.deps;
1421
- }
1422
- function hasOnDestroy(value) {
1423
- return value !== null && typeof value === 'object' && typeof value.ngOnDestroy === 'function';
1424
- }
1425
- function couldBeInjectableType(value) {
1426
- return typeof value === 'function' || typeof value === 'object' && value.ngMetadataName === 'InjectionToken';
1427
- }
1428
- function forEachSingleProvider(providers, fn) {
1429
- for (const provider of providers) {
1430
- if (Array.isArray(provider)) {
1431
- forEachSingleProvider(provider, fn);
1432
- } else if (provider && isEnvironmentProviders(provider)) {
1433
- forEachSingleProvider(provider.ɵproviders, fn);
1434
- } else {
1435
- fn(provider);
1436
- }
1437
- }
1438
- }
1439
-
1440
- function runInInjectionContext(injector, fn) {
1441
- let internalInjector;
1442
- if (injector instanceof R3Injector) {
1443
- assertNotDestroyed(injector);
1444
- internalInjector = injector;
1445
- } else {
1446
- internalInjector = new RetrievingInjector(injector);
1447
- }
1448
- let prevInjectorProfilerContext;
1449
- if (ngDevMode) {
1450
- prevInjectorProfilerContext = setInjectorProfilerContext({
1451
- injector,
1452
- token: null
1453
- });
1454
- }
1455
- const prevInjector = setCurrentInjector(internalInjector);
1456
- const previousInjectImplementation = setInjectImplementation(undefined);
1457
- try {
1458
- return fn();
1459
- } finally {
1460
- setCurrentInjector(prevInjector);
1461
- ngDevMode && setInjectorProfilerContext(prevInjectorProfilerContext);
1462
- setInjectImplementation(previousInjectImplementation);
1463
- }
1464
- }
1465
- function isInInjectionContext() {
1466
- return getInjectImplementation() !== undefined || getCurrentInjector() != null;
1467
- }
1468
- function assertInInjectionContext(debugFn) {
1469
- if (!isInInjectionContext()) {
1470
- throw new RuntimeError(-203, ngDevMode && debugFn.name + '() can only be used within an injection context such as a constructor, a factory function, a field initializer, or a function used with `runInInjectionContext`');
1471
- }
1472
- }
1473
-
1474
- const HOST = 0;
1475
- const TVIEW = 1;
1476
- const FLAGS = 2;
1477
- const PARENT = 3;
1478
- const NEXT = 4;
1479
- const T_HOST = 5;
1480
- const HYDRATION = 6;
1481
- const CLEANUP = 7;
1482
- const CONTEXT = 8;
1483
- const INJECTOR = 9;
1484
- const ENVIRONMENT = 10;
1485
- const RENDERER = 11;
1486
- const CHILD_HEAD = 12;
1487
- const CHILD_TAIL = 13;
1488
- const DECLARATION_VIEW = 14;
1489
- const DECLARATION_COMPONENT_VIEW = 15;
1490
- const DECLARATION_LCONTAINER = 16;
1491
- const PREORDER_HOOK_FLAGS = 17;
1492
- const QUERIES = 18;
1493
- const ID = 19;
1494
- const EMBEDDED_VIEW_INJECTOR = 20;
1495
- const ON_DESTROY_HOOKS = 21;
1496
- const EFFECTS_TO_SCHEDULE = 22;
1497
- const EFFECTS = 23;
1498
- const REACTIVE_TEMPLATE_CONSUMER = 24;
1499
- const AFTER_RENDER_SEQUENCES_TO_ADD = 25;
1500
- const ANIMATIONS = 26;
1501
- const HEADER_OFFSET = 27;
1502
-
1503
- const TYPE = 1;
1504
- const DEHYDRATED_VIEWS = 6;
1505
- const NATIVE = 7;
1506
- const VIEW_REFS = 8;
1507
- const MOVED_VIEWS = 9;
1508
- const CONTAINER_HEADER_OFFSET = 10;
1509
-
1510
- function isLView(value) {
1511
- return Array.isArray(value) && typeof value[TYPE] === 'object';
1512
- }
1513
- function isLContainer(value) {
1514
- return Array.isArray(value) && value[TYPE] === true;
1515
- }
1516
- function isContentQueryHost(tNode) {
1517
- return (tNode.flags & 4) !== 0;
1518
- }
1519
- function isComponentHost(tNode) {
1520
- return tNode.componentOffset > -1;
1521
- }
1522
- function isDirectiveHost(tNode) {
1523
- return (tNode.flags & 1) === 1;
1524
- }
1525
- function isComponentDef(def) {
1526
- return !!def.template;
1527
- }
1528
- function isRootView(target) {
1529
- return (target[FLAGS] & 512) !== 0;
1530
- }
1531
- function isProjectionTNode(tNode) {
1532
- return (tNode.type & 16) === 16;
1533
- }
1534
- function hasI18n(lView) {
1535
- return (lView[FLAGS] & 32) === 32;
1536
- }
1537
- function isDestroyed(lView) {
1538
- return (lView[FLAGS] & 256) === 256;
1539
- }
1540
-
1541
- function assertTNodeForLView(tNode, lView) {
1542
- assertTNodeForTView(tNode, lView[TVIEW]);
1543
- }
1544
- function assertTNodeCreationIndex(lView, index) {
1545
- const adjustedIndex = index + HEADER_OFFSET;
1546
- assertIndexInRange(lView, adjustedIndex);
1547
- assertLessThan(adjustedIndex, lView[TVIEW].bindingStartIndex, 'TNodes should be created before any bindings');
1548
- }
1549
- function assertTNodeForTView(tNode, tView) {
1550
- assertTNode(tNode);
1551
- const tData = tView.data;
1552
- for (let i = HEADER_OFFSET; i < tData.length; i++) {
1553
- if (tData[i] === tNode) {
1554
- return;
1555
- }
1556
- }
1557
- throwError('This TNode does not belong to this TView.');
1558
- }
1559
- function assertTNode(tNode) {
1560
- assertDefined(tNode, 'TNode must be defined');
1561
- if (!(tNode && typeof tNode === 'object' && tNode.hasOwnProperty('directiveStylingLast'))) {
1562
- throwError('Not of type TNode, got: ' + tNode);
1563
- }
1564
- }
1565
- function assertTIcu(tIcu) {
1566
- assertDefined(tIcu, 'Expected TIcu to be defined');
1567
- if (!(typeof tIcu.currentCaseLViewIndex === 'number')) {
1568
- throwError('Object is not of TIcu type.');
1569
- }
1570
- }
1571
- function assertComponentType(actual, msg = "Type passed in is not ComponentType, it does not have 'ɵcmp' property.") {
1572
- if (!getComponentDef(actual)) {
1573
- throwError(msg);
1574
- }
1575
- }
1576
- function assertNgModuleType(actual, msg = "Type passed in is not NgModuleType, it does not have 'ɵmod' property.") {
1577
- if (!getNgModuleDef(actual)) {
1578
- throwError(msg);
1579
- }
1580
- }
1581
- function assertHasParent(tNode) {
1582
- assertDefined(tNode, 'currentTNode should exist!');
1583
- assertDefined(tNode.parent, 'currentTNode should have a parent');
1584
- }
1585
- function assertLContainer(value) {
1586
- assertDefined(value, 'LContainer must be defined');
1587
- assertEqual(isLContainer(value), true, 'Expecting LContainer');
1588
- }
1589
- function assertLViewOrUndefined(value) {
1590
- value && assertEqual(isLView(value), true, 'Expecting LView or undefined or null');
1591
- }
1592
- function assertLView(value) {
1593
- assertDefined(value, 'LView must be defined');
1594
- assertEqual(isLView(value), true, 'Expecting LView');
1595
- }
1596
- function assertFirstCreatePass(tView, errMessage) {
1597
- assertEqual(tView.firstCreatePass, true, errMessage || 'Should only be called in first create pass.');
1598
- }
1599
- function assertFirstUpdatePass(tView, errMessage) {
1600
- assertEqual(tView.firstUpdatePass, true, 'Should only be called in first update pass.');
1601
- }
1602
- function assertDirectiveDef(obj) {
1603
- if (obj.type === undefined || obj.selectors == undefined || obj.inputs === undefined) {
1604
- throwError(`Expected a DirectiveDef/ComponentDef and this object does not seem to have the expected shape.`);
1605
- }
1606
- }
1607
- function assertIndexInDeclRange(tView, index) {
1608
- assertBetween(HEADER_OFFSET, tView.bindingStartIndex, index);
1609
- }
1610
- function assertIndexInExpandoRange(lView, index) {
1611
- const tView = lView[1];
1612
- assertBetween(tView.expandoStartIndex, lView.length, index);
1613
- }
1614
- function assertBetween(lower, upper, index) {
1615
- if (!(lower <= index && index < upper)) {
1616
- throwError(`Index out of range (expecting ${lower} <= ${index} < ${upper})`);
1617
- }
1618
- }
1619
- function assertProjectionSlots(lView, errMessage) {
1620
- assertDefined(lView[DECLARATION_COMPONENT_VIEW], 'Component views should exist.');
1621
- assertDefined(lView[DECLARATION_COMPONENT_VIEW][T_HOST].projection, 'Components with projection nodes (<ng-content>) must have projection slots defined.');
1622
- }
1623
- function assertParentView(lView, errMessage) {
1624
- assertDefined(lView, "Component views should always have a parent view (component's host view)");
1625
- }
1626
- function assertNodeInjector(lView, injectorIndex) {
1627
- assertIndexInExpandoRange(lView, injectorIndex);
1628
- assertIndexInExpandoRange(lView, injectorIndex + 8);
1629
- assertNumber(lView[injectorIndex + 0], 'injectorIndex should point to a bloom filter');
1630
- assertNumber(lView[injectorIndex + 1], 'injectorIndex should point to a bloom filter');
1631
- assertNumber(lView[injectorIndex + 2], 'injectorIndex should point to a bloom filter');
1632
- assertNumber(lView[injectorIndex + 3], 'injectorIndex should point to a bloom filter');
1633
- assertNumber(lView[injectorIndex + 4], 'injectorIndex should point to a bloom filter');
1634
- assertNumber(lView[injectorIndex + 5], 'injectorIndex should point to a bloom filter');
1635
- assertNumber(lView[injectorIndex + 6], 'injectorIndex should point to a bloom filter');
1636
- assertNumber(lView[injectorIndex + 7], 'injectorIndex should point to a bloom filter');
1637
- assertNumber(lView[injectorIndex + 8], 'injectorIndex should point to parent injector');
1638
- }
1639
-
1640
- const SVG_NAMESPACE = 'svg';
1641
- const MATH_ML_NAMESPACE = 'math';
1642
-
1643
- function unwrapRNode(value) {
1644
- while (Array.isArray(value)) {
1645
- value = value[HOST];
1646
- }
1647
- return value;
1648
- }
1649
- function unwrapLView(value) {
1650
- while (Array.isArray(value)) {
1651
- if (typeof value[TYPE] === 'object') return value;
1652
- value = value[HOST];
1653
- }
1654
- return null;
1655
- }
1656
- function getNativeByIndex(index, lView) {
1657
- ngDevMode && assertIndexInRange(lView, index);
1658
- ngDevMode && assertGreaterThanOrEqual(index, HEADER_OFFSET, 'Expected to be past HEADER_OFFSET');
1659
- return unwrapRNode(lView[index]);
1660
- }
1661
- function getNativeByTNode(tNode, lView) {
1662
- ngDevMode && assertTNodeForLView(tNode, lView);
1663
- ngDevMode && assertIndexInRange(lView, tNode.index);
1664
- const node = unwrapRNode(lView[tNode.index]);
1665
- return node;
1666
- }
1667
- function getNativeByTNodeOrNull(tNode, lView) {
1668
- const index = tNode === null ? -1 : tNode.index;
1669
- if (index !== -1) {
1670
- ngDevMode && assertTNodeForLView(tNode, lView);
1671
- const node = unwrapRNode(lView[index]);
1672
- return node;
1673
- }
1674
- return null;
1675
- }
1676
- function getTNode(tView, index) {
1677
- ngDevMode && assertGreaterThan(index, -1, 'wrong index for TNode');
1678
- ngDevMode && assertLessThan(index, tView.data.length, 'wrong index for TNode');
1679
- const tNode = tView.data[index];
1680
- ngDevMode && tNode !== null && assertTNode(tNode);
1681
- return tNode;
1682
- }
1683
- function load(view, index) {
1684
- ngDevMode && assertIndexInRange(view, index);
1685
- return view[index];
1686
- }
1687
- function store(tView, lView, index, value) {
1688
- if (index >= tView.data.length) {
1689
- tView.data[index] = null;
1690
- tView.blueprint[index] = null;
1691
- }
1692
- lView[index] = value;
1693
- }
1694
- function getComponentLViewByIndex(nodeIndex, hostView) {
1695
- ngDevMode && assertIndexInRange(hostView, nodeIndex);
1696
- const slotValue = hostView[nodeIndex];
1697
- const lView = isLView(slotValue) ? slotValue : slotValue[HOST];
1698
- return lView;
1699
- }
1700
- function isCreationMode(view) {
1701
- return (view[FLAGS] & 4) === 4;
1702
- }
1703
- function viewAttachedToChangeDetector(view) {
1704
- return (view[FLAGS] & 128) === 128;
1705
- }
1706
- function viewAttachedToContainer(view) {
1707
- return isLContainer(view[PARENT]);
1708
- }
1709
- function getConstant(consts, index) {
1710
- if (index === null || index === undefined) return null;
1711
- ngDevMode && assertIndexInRange(consts, index);
1712
- return consts[index];
1713
- }
1714
- function resetPreOrderHookFlags(lView) {
1715
- lView[PREORDER_HOOK_FLAGS] = 0;
1716
- }
1717
- function markViewForRefresh(lView) {
1718
- if (lView[FLAGS] & 1024) {
1719
- return;
1720
- }
1721
- lView[FLAGS] |= 1024;
1722
- if (viewAttachedToChangeDetector(lView)) {
1723
- markAncestorsForTraversal(lView);
1724
- }
1725
- }
1726
- function walkUpViews(nestingLevel, currentView) {
1727
- while (nestingLevel > 0) {
1728
- ngDevMode && assertDefined(currentView[DECLARATION_VIEW], 'Declaration view should be defined if nesting level is greater than 0.');
1729
- currentView = currentView[DECLARATION_VIEW];
1730
- nestingLevel--;
1731
- }
1732
- return currentView;
1733
- }
1734
- function requiresRefreshOrTraversal(lView) {
1735
- return !!(lView[FLAGS] & (1024 | 8192) || lView[REACTIVE_TEMPLATE_CONSUMER]?.dirty);
1736
- }
1737
- function updateAncestorTraversalFlagsOnAttach(lView) {
1738
- lView[ENVIRONMENT].changeDetectionScheduler?.notify(8);
1739
- if (lView[FLAGS] & 64) {
1740
- lView[FLAGS] |= 1024;
1741
- }
1742
- if (requiresRefreshOrTraversal(lView)) {
1743
- markAncestorsForTraversal(lView);
1744
- }
1745
- }
1746
- function markAncestorsForTraversal(lView) {
1747
- lView[ENVIRONMENT].changeDetectionScheduler?.notify(0);
1748
- let parent = getLViewParent(lView);
1749
- while (parent !== null) {
1750
- if (parent[FLAGS] & 8192) {
1751
- break;
1752
- }
1753
- parent[FLAGS] |= 8192;
1754
- if (!viewAttachedToChangeDetector(parent)) {
1755
- break;
1756
- }
1757
- parent = getLViewParent(parent);
1758
- }
1759
- }
1760
- function storeLViewOnDestroy(lView, onDestroyCallback) {
1761
- if (isDestroyed(lView)) {
1762
- throw new RuntimeError(911, ngDevMode && 'View has already been destroyed.');
1763
- }
1764
- if (lView[ON_DESTROY_HOOKS] === null) {
1765
- lView[ON_DESTROY_HOOKS] = [];
1766
- }
1767
- lView[ON_DESTROY_HOOKS].push(onDestroyCallback);
1768
- }
1769
- function removeLViewOnDestroy(lView, onDestroyCallback) {
1770
- if (lView[ON_DESTROY_HOOKS] === null) return;
1771
- const destroyCBIdx = lView[ON_DESTROY_HOOKS].indexOf(onDestroyCallback);
1772
- if (destroyCBIdx !== -1) {
1773
- lView[ON_DESTROY_HOOKS].splice(destroyCBIdx, 1);
1774
- }
1775
- }
1776
- function getLViewParent(lView) {
1777
- ngDevMode && assertLView(lView);
1778
- const parent = lView[PARENT];
1779
- return isLContainer(parent) ? parent[PARENT] : parent;
1780
- }
1781
- function getOrCreateLViewCleanup(view) {
1782
- return view[CLEANUP] ??= [];
1783
- }
1784
- function getOrCreateTViewCleanup(tView) {
1785
- return tView.cleanup ??= [];
1786
- }
1787
- function storeCleanupWithContext(tView, lView, context, cleanupFn) {
1788
- const lCleanup = getOrCreateLViewCleanup(lView);
1789
- ngDevMode && assertDefined(context, 'Cleanup context is mandatory when registering framework-level destroy hooks');
1790
- lCleanup.push(context);
1791
- if (tView.firstCreatePass) {
1792
- getOrCreateTViewCleanup(tView).push(cleanupFn, lCleanup.length - 1);
1793
- } else {
1794
- if (ngDevMode) {
1795
- Object.freeze(getOrCreateTViewCleanup(tView));
1796
- }
1797
- }
1798
- }
1799
-
1800
- const instructionState = {
1801
- lFrame: createLFrame(null),
1802
- bindingsEnabled: true,
1803
- skipHydrationRootTNode: null
1804
- };
1805
- var CheckNoChangesMode;
1806
- (function (CheckNoChangesMode) {
1807
- CheckNoChangesMode[CheckNoChangesMode["Off"] = 0] = "Off";
1808
- CheckNoChangesMode[CheckNoChangesMode["Exhaustive"] = 1] = "Exhaustive";
1809
- CheckNoChangesMode[CheckNoChangesMode["OnlyDirtyViews"] = 2] = "OnlyDirtyViews";
1810
- })(CheckNoChangesMode || (CheckNoChangesMode = {}));
1811
- let _checkNoChangesMode = 0;
1812
- let _isRefreshingViews = false;
1813
- function getElementDepthCount() {
1814
- return instructionState.lFrame.elementDepthCount;
1815
- }
1816
- function increaseElementDepthCount() {
1817
- instructionState.lFrame.elementDepthCount++;
1818
- }
1819
- function decreaseElementDepthCount() {
1820
- instructionState.lFrame.elementDepthCount--;
1821
- }
1822
- function getBindingsEnabled() {
1823
- return instructionState.bindingsEnabled;
1824
- }
1825
- function isInSkipHydrationBlock() {
1826
- return instructionState.skipHydrationRootTNode !== null;
1827
- }
1828
- function isSkipHydrationRootTNode(tNode) {
1829
- return instructionState.skipHydrationRootTNode === tNode;
1830
- }
1831
- function ɵɵenableBindings() {
1832
- instructionState.bindingsEnabled = true;
1833
- }
1834
- function enterSkipHydrationBlock(tNode) {
1835
- instructionState.skipHydrationRootTNode = tNode;
1836
- }
1837
- function ɵɵdisableBindings() {
1838
- instructionState.bindingsEnabled = false;
1839
- }
1840
- function leaveSkipHydrationBlock() {
1841
- instructionState.skipHydrationRootTNode = null;
1842
- }
1843
- function getLView() {
1844
- return instructionState.lFrame.lView;
1845
- }
1846
- function getTView() {
1847
- return instructionState.lFrame.tView;
1848
- }
1849
- function ɵɵrestoreView(viewToRestore) {
1850
- instructionState.lFrame.contextLView = viewToRestore;
1851
- return viewToRestore[CONTEXT];
1852
- }
1853
- function ɵɵresetView(value) {
1854
- instructionState.lFrame.contextLView = null;
1855
- return value;
1856
- }
1857
- function getCurrentTNode() {
1858
- let currentTNode = getCurrentTNodePlaceholderOk();
1859
- while (currentTNode !== null && currentTNode.type === 64) {
1860
- currentTNode = currentTNode.parent;
1861
- }
1862
- return currentTNode;
1863
- }
1864
- function getCurrentTNodePlaceholderOk() {
1865
- return instructionState.lFrame.currentTNode;
1866
- }
1867
- function getCurrentParentTNode() {
1868
- const lFrame = instructionState.lFrame;
1869
- const currentTNode = lFrame.currentTNode;
1870
- return lFrame.isParent ? currentTNode : currentTNode.parent;
1871
- }
1872
- function setCurrentTNode(tNode, isParent) {
1873
- ngDevMode && tNode && assertTNodeForTView(tNode, instructionState.lFrame.tView);
1874
- const lFrame = instructionState.lFrame;
1875
- lFrame.currentTNode = tNode;
1876
- lFrame.isParent = isParent;
1877
- }
1878
- function isCurrentTNodeParent() {
1879
- return instructionState.lFrame.isParent;
1880
- }
1881
- function setCurrentTNodeAsNotParent() {
1882
- instructionState.lFrame.isParent = false;
1883
- }
1884
- function getContextLView() {
1885
- const contextLView = instructionState.lFrame.contextLView;
1886
- ngDevMode && assertDefined(contextLView, 'contextLView must be defined.');
1887
- return contextLView;
1888
- }
1889
- function isInCheckNoChangesMode() {
1890
- !ngDevMode && throwError('Must never be called in production mode');
1891
- return _checkNoChangesMode !== CheckNoChangesMode.Off;
1892
- }
1893
- function isExhaustiveCheckNoChanges() {
1894
- !ngDevMode && throwError('Must never be called in production mode');
1895
- return _checkNoChangesMode === CheckNoChangesMode.Exhaustive;
1896
- }
1897
- function setIsInCheckNoChangesMode(mode) {
1898
- !ngDevMode && throwError('Must never be called in production mode');
1899
- _checkNoChangesMode = mode;
1900
- }
1901
- function isRefreshingViews() {
1902
- return _isRefreshingViews;
1903
- }
1904
- function setIsRefreshingViews(mode) {
1905
- const prev = _isRefreshingViews;
1906
- _isRefreshingViews = mode;
1907
- return prev;
1908
- }
1909
- function getBindingRoot() {
1910
- const lFrame = instructionState.lFrame;
1911
- let index = lFrame.bindingRootIndex;
1912
- if (index === -1) {
1913
- index = lFrame.bindingRootIndex = lFrame.tView.bindingStartIndex;
1914
- }
1915
- return index;
1916
- }
1917
- function getBindingIndex() {
1918
- return instructionState.lFrame.bindingIndex;
1919
- }
1920
- function setBindingIndex(value) {
1921
- return instructionState.lFrame.bindingIndex = value;
1922
- }
1923
- function nextBindingIndex() {
1924
- return instructionState.lFrame.bindingIndex++;
1925
- }
1926
- function incrementBindingIndex(count) {
1927
- const lFrame = instructionState.lFrame;
1928
- const index = lFrame.bindingIndex;
1929
- lFrame.bindingIndex = lFrame.bindingIndex + count;
1930
- return index;
1931
- }
1932
- function isInI18nBlock() {
1933
- return instructionState.lFrame.inI18n;
1934
- }
1935
- function setInI18nBlock(isInI18nBlock) {
1936
- instructionState.lFrame.inI18n = isInI18nBlock;
1937
- }
1938
- function setBindingRootForHostBindings(bindingRootIndex, currentDirectiveIndex) {
1939
- const lFrame = instructionState.lFrame;
1940
- lFrame.bindingIndex = lFrame.bindingRootIndex = bindingRootIndex;
1941
- setCurrentDirectiveIndex(currentDirectiveIndex);
1942
- }
1943
- function getCurrentDirectiveIndex() {
1944
- return instructionState.lFrame.currentDirectiveIndex;
1945
- }
1946
- function setCurrentDirectiveIndex(currentDirectiveIndex) {
1947
- instructionState.lFrame.currentDirectiveIndex = currentDirectiveIndex;
1948
- }
1949
- function getCurrentDirectiveDef(tData) {
1950
- const currentDirectiveIndex = instructionState.lFrame.currentDirectiveIndex;
1951
- return currentDirectiveIndex === -1 ? null : tData[currentDirectiveIndex];
1952
- }
1953
- function getCurrentQueryIndex() {
1954
- return instructionState.lFrame.currentQueryIndex;
1955
- }
1956
- function setCurrentQueryIndex(value) {
1957
- instructionState.lFrame.currentQueryIndex = value;
1958
- }
1959
- function getDeclarationTNode(lView) {
1960
- const tView = lView[TVIEW];
1961
- if (tView.type === 2) {
1962
- ngDevMode && assertDefined(tView.declTNode, 'Embedded TNodes should have declaration parents.');
1963
- return tView.declTNode;
1964
- }
1965
- if (tView.type === 1) {
1966
- return lView[T_HOST];
1967
- }
1968
- return null;
1969
- }
1970
- function enterDI(lView, tNode, flags) {
1971
- ngDevMode && assertLViewOrUndefined(lView);
1972
- if (flags & 4) {
1973
- ngDevMode && assertTNodeForTView(tNode, lView[TVIEW]);
1974
- let parentTNode = tNode;
1975
- let parentLView = lView;
1976
- while (true) {
1977
- ngDevMode && assertDefined(parentTNode, 'Parent TNode should be defined');
1978
- parentTNode = parentTNode.parent;
1979
- if (parentTNode === null && !(flags & 1)) {
1980
- parentTNode = getDeclarationTNode(parentLView);
1981
- if (parentTNode === null) break;
1982
- ngDevMode && assertDefined(parentLView, 'Parent LView should be defined');
1983
- parentLView = parentLView[DECLARATION_VIEW];
1984
- if (parentTNode.type & (2 | 8)) {
1985
- break;
1986
- }
1987
- } else {
1988
- break;
1989
- }
1990
- }
1991
- if (parentTNode === null) {
1992
- return false;
1993
- } else {
1994
- tNode = parentTNode;
1995
- lView = parentLView;
1996
- }
1997
- }
1998
- ngDevMode && assertTNodeForLView(tNode, lView);
1999
- const lFrame = instructionState.lFrame = allocLFrame();
2000
- lFrame.currentTNode = tNode;
2001
- lFrame.lView = lView;
2002
- return true;
2003
- }
2004
- function enterView(newView) {
2005
- ngDevMode && assertNotEqual(newView[0], newView[1], '????');
2006
- ngDevMode && assertLViewOrUndefined(newView);
2007
- const newLFrame = allocLFrame();
2008
- if (ngDevMode) {
2009
- assertEqual(newLFrame.isParent, true, 'Expected clean LFrame');
2010
- assertEqual(newLFrame.lView, null, 'Expected clean LFrame');
2011
- assertEqual(newLFrame.tView, null, 'Expected clean LFrame');
2012
- assertEqual(newLFrame.selectedIndex, -1, 'Expected clean LFrame');
2013
- assertEqual(newLFrame.elementDepthCount, 0, 'Expected clean LFrame');
2014
- assertEqual(newLFrame.currentDirectiveIndex, -1, 'Expected clean LFrame');
2015
- assertEqual(newLFrame.currentNamespace, null, 'Expected clean LFrame');
2016
- assertEqual(newLFrame.bindingRootIndex, -1, 'Expected clean LFrame');
2017
- assertEqual(newLFrame.currentQueryIndex, 0, 'Expected clean LFrame');
2018
- }
2019
- const tView = newView[TVIEW];
2020
- instructionState.lFrame = newLFrame;
2021
- ngDevMode && tView.firstChild && assertTNodeForTView(tView.firstChild, tView);
2022
- newLFrame.currentTNode = tView.firstChild;
2023
- newLFrame.lView = newView;
2024
- newLFrame.tView = tView;
2025
- newLFrame.contextLView = newView;
2026
- newLFrame.bindingIndex = tView.bindingStartIndex;
2027
- newLFrame.inI18n = false;
2028
- }
2029
- function allocLFrame() {
2030
- const currentLFrame = instructionState.lFrame;
2031
- const childLFrame = currentLFrame === null ? null : currentLFrame.child;
2032
- const newLFrame = childLFrame === null ? createLFrame(currentLFrame) : childLFrame;
2033
- return newLFrame;
2034
- }
2035
- function createLFrame(parent) {
2036
- const lFrame = {
2037
- currentTNode: null,
2038
- isParent: true,
2039
- lView: null,
2040
- tView: null,
2041
- selectedIndex: -1,
2042
- contextLView: null,
2043
- elementDepthCount: 0,
2044
- currentNamespace: null,
2045
- currentDirectiveIndex: -1,
2046
- bindingRootIndex: -1,
2047
- bindingIndex: -1,
2048
- currentQueryIndex: 0,
2049
- parent: parent,
2050
- child: null,
2051
- inI18n: false
2052
- };
2053
- parent !== null && (parent.child = lFrame);
2054
- return lFrame;
2055
- }
2056
- function leaveViewLight() {
2057
- const oldLFrame = instructionState.lFrame;
2058
- instructionState.lFrame = oldLFrame.parent;
2059
- oldLFrame.currentTNode = null;
2060
- oldLFrame.lView = null;
2061
- return oldLFrame;
2062
- }
2063
- const leaveDI = leaveViewLight;
2064
- function leaveView() {
2065
- const oldLFrame = leaveViewLight();
2066
- oldLFrame.isParent = true;
2067
- oldLFrame.tView = null;
2068
- oldLFrame.selectedIndex = -1;
2069
- oldLFrame.contextLView = null;
2070
- oldLFrame.elementDepthCount = 0;
2071
- oldLFrame.currentDirectiveIndex = -1;
2072
- oldLFrame.currentNamespace = null;
2073
- oldLFrame.bindingRootIndex = -1;
2074
- oldLFrame.bindingIndex = -1;
2075
- oldLFrame.currentQueryIndex = 0;
2076
- }
2077
- function nextContextImpl(level) {
2078
- const contextLView = instructionState.lFrame.contextLView = walkUpViews(level, instructionState.lFrame.contextLView);
2079
- return contextLView[CONTEXT];
2080
- }
2081
- function getSelectedIndex() {
2082
- return instructionState.lFrame.selectedIndex;
2083
- }
2084
- function setSelectedIndex(index) {
2085
- ngDevMode && index !== -1 && assertGreaterThanOrEqual(index, HEADER_OFFSET, 'Index must be past HEADER_OFFSET (or -1).');
2086
- ngDevMode && assertLessThan(index, instructionState.lFrame.lView.length, "Can't set index passed end of LView");
2087
- instructionState.lFrame.selectedIndex = index;
2088
- }
2089
- function getSelectedTNode() {
2090
- const lFrame = instructionState.lFrame;
2091
- return getTNode(lFrame.tView, lFrame.selectedIndex);
2092
- }
2093
- function ɵɵnamespaceSVG() {
2094
- instructionState.lFrame.currentNamespace = SVG_NAMESPACE;
2095
- }
2096
- function ɵɵnamespaceMathML() {
2097
- instructionState.lFrame.currentNamespace = MATH_ML_NAMESPACE;
2098
- }
2099
- function ɵɵnamespaceHTML() {
2100
- namespaceHTMLInternal();
2101
- }
2102
- function namespaceHTMLInternal() {
2103
- instructionState.lFrame.currentNamespace = null;
2104
- }
2105
- function getNamespace() {
2106
- return instructionState.lFrame.currentNamespace;
2107
- }
2108
- let _wasLastNodeCreated = true;
2109
- function wasLastNodeCreated() {
2110
- return _wasLastNodeCreated;
2111
- }
2112
- function lastNodeWasCreated(flag) {
2113
- _wasLastNodeCreated = flag;
2114
- }
2115
-
2116
- function createInjector(defType, parent = null, additionalProviders = null, name) {
2117
- const injector = createInjectorWithoutInjectorInstances(defType, parent, additionalProviders, name);
2118
- injector.resolveInjectorInitializers();
2119
- return injector;
2120
- }
2121
- function createInjectorWithoutInjectorInstances(defType, parent = null, additionalProviders = null, name, scopes = new Set()) {
2122
- const providers = [additionalProviders || EMPTY_ARRAY, importProvidersFrom(defType)];
2123
- name = name || (typeof defType === 'object' ? undefined : stringify(defType));
2124
- return new R3Injector(providers, parent || getNullInjector(), name || null, scopes);
2125
- }
2126
-
2127
- class Injector {
2128
- static THROW_IF_NOT_FOUND = THROW_IF_NOT_FOUND;
2129
- static NULL = new NullInjector();
2130
- static create(options, parent) {
2131
- if (Array.isArray(options)) {
2132
- return createInjector({
2133
- name: ''
2134
- }, parent, options, '');
2135
- } else {
2136
- const name = options.name ?? '';
2137
- return createInjector({
2138
- name
2139
- }, options.parent, options.providers, name);
2140
- }
2141
- }
2142
- static ɵprov =
2143
- /* @__PURE__ */
2144
- ɵɵdefineInjectable({
2145
- token: Injector,
2146
- providedIn: 'any',
2147
- factory: () => ɵɵinject(INJECTOR$1)
2148
- });
2149
- static __NG_ELEMENT_ID__ = -1;
2150
- }
2151
-
2152
- const DOCUMENT = new InjectionToken(typeof ngDevMode !== 'undefined' && ngDevMode ? 'DocumentToken' : '');
2153
-
2154
- class DestroyRef {
2155
- static __NG_ELEMENT_ID__ = injectDestroyRef;
2156
- static __NG_ENV_ID__ = injector => injector;
2157
- }
2158
- class NodeInjectorDestroyRef extends DestroyRef {
2159
- _lView;
2160
- constructor(_lView) {
2161
- super();
2162
- this._lView = _lView;
2163
- }
2164
- get destroyed() {
2165
- return isDestroyed(this._lView);
2166
- }
2167
- onDestroy(callback) {
2168
- const lView = this._lView;
2169
- storeLViewOnDestroy(lView, callback);
2170
- return () => removeLViewOnDestroy(lView, callback);
2171
- }
2172
- }
2173
- function injectDestroyRef() {
2174
- return new NodeInjectorDestroyRef(getLView());
2175
- }
2176
-
2177
- const SCHEDULE_IN_ROOT_ZONE_DEFAULT = false;
2178
-
2179
- const DEBUG_TASK_TRACKER = new InjectionToken(typeof ngDevMode !== 'undefined' && ngDevMode ? 'DEBUG_TASK_TRACKER' : '');
2180
-
2181
- class PendingTasksInternal {
2182
- taskId = 0;
2183
- pendingTasks = new Set();
2184
- destroyed = false;
2185
- pendingTask = new BehaviorSubject(false);
2186
- debugTaskTracker = inject(DEBUG_TASK_TRACKER, {
2187
- optional: true
2188
- });
2189
- get hasPendingTasks() {
2190
- return this.destroyed ? false : this.pendingTask.value;
2191
- }
2192
- get hasPendingTasksObservable() {
2193
- if (this.destroyed) {
2194
- return new Observable(subscriber => {
2195
- subscriber.next(false);
2196
- subscriber.complete();
2197
- });
2198
- }
2199
- return this.pendingTask;
2200
- }
2201
- add() {
2202
- if (!this.hasPendingTasks && !this.destroyed) {
2203
- this.pendingTask.next(true);
2204
- }
2205
- const taskId = this.taskId++;
2206
- this.pendingTasks.add(taskId);
2207
- this.debugTaskTracker?.add(taskId);
2208
- return taskId;
2209
- }
2210
- has(taskId) {
2211
- return this.pendingTasks.has(taskId);
2212
- }
2213
- remove(taskId) {
2214
- this.pendingTasks.delete(taskId);
2215
- this.debugTaskTracker?.remove(taskId);
2216
- if (this.pendingTasks.size === 0 && this.hasPendingTasks) {
2217
- this.pendingTask.next(false);
2218
- }
2219
- }
2220
- ngOnDestroy() {
2221
- this.pendingTasks.clear();
2222
- if (this.hasPendingTasks) {
2223
- this.pendingTask.next(false);
2224
- }
2225
- this.destroyed = true;
2226
- this.pendingTask.unsubscribe();
2227
- }
2228
- static ɵprov =
2229
- /* @__PURE__ */
2230
- ɵɵdefineInjectable({
2231
- token: PendingTasksInternal,
2232
- providedIn: 'root',
2233
- factory: () => new PendingTasksInternal()
2234
- });
2235
- }
2236
-
2237
- class EventEmitter_ extends Subject {
2238
- __isAsync;
2239
- destroyRef = undefined;
2240
- pendingTasks = undefined;
2241
- constructor(isAsync = false) {
2242
- super();
2243
- this.__isAsync = isAsync;
2244
- if (isInInjectionContext()) {
2245
- this.destroyRef = inject(DestroyRef, {
2246
- optional: true
2247
- }) ?? undefined;
2248
- this.pendingTasks = inject(PendingTasksInternal, {
2249
- optional: true
2250
- }) ?? undefined;
2251
- }
2252
- }
2253
- emit(value) {
2254
- const prevConsumer = setActiveConsumer$1(null);
2255
- try {
2256
- super.next(value);
2257
- } finally {
2258
- setActiveConsumer$1(prevConsumer);
2259
- }
2260
- }
2261
- subscribe(observerOrNext, error, complete) {
2262
- let nextFn = observerOrNext;
2263
- let errorFn = error || (() => null);
2264
- let completeFn = complete;
2265
- if (observerOrNext && typeof observerOrNext === 'object') {
2266
- const observer = observerOrNext;
2267
- nextFn = observer.next?.bind(observer);
2268
- errorFn = observer.error?.bind(observer);
2269
- completeFn = observer.complete?.bind(observer);
2270
- }
2271
- if (this.__isAsync) {
2272
- errorFn = this.wrapInTimeout(errorFn);
2273
- if (nextFn) {
2274
- nextFn = this.wrapInTimeout(nextFn);
2275
- }
2276
- if (completeFn) {
2277
- completeFn = this.wrapInTimeout(completeFn);
2278
- }
2279
- }
2280
- const sink = super.subscribe({
2281
- next: nextFn,
2282
- error: errorFn,
2283
- complete: completeFn
2284
- });
2285
- if (observerOrNext instanceof Subscription) {
2286
- observerOrNext.add(sink);
16
+ const linkedSignalGetter = () => {
17
+ producerUpdateValueVersion(node);
18
+ producerAccessed(node);
19
+ if (node.value === ERRORED) {
20
+ throw node.error;
2287
21
  }
2288
- return sink;
2289
- }
2290
- wrapInTimeout(fn) {
2291
- return value => {
2292
- const taskId = this.pendingTasks?.add();
2293
- setTimeout(() => {
2294
- try {
2295
- fn(value);
2296
- } finally {
2297
- if (taskId !== undefined) {
2298
- this.pendingTasks?.remove(taskId);
2299
- }
2300
- }
2301
- });
2302
- };
2303
- }
2304
- }
2305
- const EventEmitter = EventEmitter_;
2306
-
2307
- function noop(...args) {}
2308
-
2309
- function scheduleCallbackWithRafRace(callback) {
2310
- let timeoutId;
2311
- let animationFrameId;
2312
- function cleanup() {
2313
- callback = noop;
2314
- try {
2315
- if (animationFrameId !== undefined && typeof cancelAnimationFrame === 'function') {
2316
- cancelAnimationFrame(animationFrameId);
2317
- }
2318
- if (timeoutId !== undefined) {
2319
- clearTimeout(timeoutId);
2320
- }
2321
- } catch {}
2322
- }
2323
- timeoutId = setTimeout(() => {
2324
- callback();
2325
- cleanup();
2326
- });
2327
- if (typeof requestAnimationFrame === 'function') {
2328
- animationFrameId = requestAnimationFrame(() => {
2329
- callback();
2330
- cleanup();
2331
- });
2332
- }
2333
- return () => cleanup();
2334
- }
2335
- function scheduleCallbackWithMicrotask(callback) {
2336
- queueMicrotask(() => callback());
2337
- return () => {
2338
- callback = noop;
22
+ return node.value;
2339
23
  };
2340
- }
2341
-
2342
- class AsyncStackTaggingZoneSpec {
2343
- createTask;
2344
- constructor(namePrefix, consoleAsyncStackTaggingImpl = console) {
2345
- this.name = 'asyncStackTagging for ' + namePrefix;
2346
- this.createTask = consoleAsyncStackTaggingImpl?.createTask ?? (() => null);
2347
- }
2348
- name;
2349
- onScheduleTask(delegate, _current, target, task) {
2350
- task.consoleTask = this.createTask(`Zone - ${task.source || task.type}`);
2351
- return delegate.scheduleTask(target, task);
2352
- }
2353
- onInvokeTask(delegate, _currentZone, targetZone, task, applyThis, applyArgs) {
2354
- let ret;
2355
- if (task.consoleTask) {
2356
- ret = task.consoleTask.run(() => delegate.invokeTask(targetZone, task, applyThis, applyArgs));
2357
- } else {
2358
- ret = delegate.invokeTask(targetZone, task, applyThis, applyArgs);
2359
- }
2360
- return ret;
2361
- }
2362
- }
2363
-
2364
- const isAngularZoneProperty = 'isAngularZone';
2365
- const angularZoneInstanceIdProperty = isAngularZoneProperty + '_ID';
2366
- let ngZoneInstanceId = 0;
2367
- class NgZone {
2368
- hasPendingMacrotasks = false;
2369
- hasPendingMicrotasks = false;
2370
- isStable = true;
2371
- onUnstable = new EventEmitter(false);
2372
- onMicrotaskEmpty = new EventEmitter(false);
2373
- onStable = new EventEmitter(false);
2374
- onError = new EventEmitter(false);
2375
- constructor(options) {
2376
- const {
2377
- enableLongStackTrace = false,
2378
- shouldCoalesceEventChangeDetection = false,
2379
- shouldCoalesceRunChangeDetection = false,
2380
- scheduleInRootZone = SCHEDULE_IN_ROOT_ZONE_DEFAULT
2381
- } = options;
2382
- if (typeof Zone == 'undefined') {
2383
- throw new RuntimeError(908, ngDevMode && `In this configuration Angular requires Zone.js`);
2384
- }
2385
- Zone.assertZonePatched();
2386
- const self = this;
2387
- self._nesting = 0;
2388
- self._outer = self._inner = Zone.current;
2389
- if (ngDevMode) {
2390
- self._inner = self._inner.fork(new AsyncStackTaggingZoneSpec('Angular'));
2391
- }
2392
- if (Zone['TaskTrackingZoneSpec']) {
2393
- self._inner = self._inner.fork(new Zone['TaskTrackingZoneSpec']());
2394
- }
2395
- if (enableLongStackTrace && Zone['longStackTraceZoneSpec']) {
2396
- self._inner = self._inner.fork(Zone['longStackTraceZoneSpec']);
2397
- }
2398
- self.shouldCoalesceEventChangeDetection = !shouldCoalesceRunChangeDetection && shouldCoalesceEventChangeDetection;
2399
- self.shouldCoalesceRunChangeDetection = shouldCoalesceRunChangeDetection;
2400
- self.callbackScheduled = false;
2401
- self.scheduleInRootZone = scheduleInRootZone;
2402
- forkInnerZoneWithAngularBehavior(self);
2403
- }
2404
- static isInAngularZone() {
2405
- return typeof Zone !== 'undefined' && Zone.current.get(isAngularZoneProperty) === true;
2406
- }
2407
- static assertInAngularZone() {
2408
- if (!NgZone.isInAngularZone()) {
2409
- throw new RuntimeError(909, ngDevMode && 'Expected to be in Angular Zone, but it is not!');
2410
- }
2411
- }
2412
- static assertNotInAngularZone() {
2413
- if (NgZone.isInAngularZone()) {
2414
- throw new RuntimeError(909, ngDevMode && 'Expected to not be in Angular Zone, but it is!');
2415
- }
2416
- }
2417
- run(fn, applyThis, applyArgs) {
2418
- return this._inner.run(fn, applyThis, applyArgs);
2419
- }
2420
- runTask(fn, applyThis, applyArgs, name) {
2421
- const zone = this._inner;
2422
- const task = zone.scheduleEventTask('NgZoneEvent: ' + name, fn, EMPTY_PAYLOAD, noop, noop);
2423
- try {
2424
- return zone.runTask(task, applyThis, applyArgs);
2425
- } finally {
2426
- zone.cancelTask(task);
2427
- }
2428
- }
2429
- runGuarded(fn, applyThis, applyArgs) {
2430
- return this._inner.runGuarded(fn, applyThis, applyArgs);
2431
- }
2432
- runOutsideAngular(fn) {
2433
- return this._outer.run(fn);
24
+ const getter = linkedSignalGetter;
25
+ getter[SIGNAL] = node;
26
+ if (typeof ngDevMode !== 'undefined' && ngDevMode) {
27
+ const debugName = node.debugName ? ' (' + node.debugName + ')' : '';
28
+ getter.toString = () => `[LinkedSignal${debugName}: ${String(node.value)}]`;
2434
29
  }
30
+ runPostProducerCreatedFn(node);
31
+ return getter;
2435
32
  }
2436
- const EMPTY_PAYLOAD = {};
2437
- function checkStable(zone) {
2438
- if (zone._nesting == 0 && !zone.hasPendingMicrotasks && !zone.isStable) {
2439
- try {
2440
- zone._nesting++;
2441
- zone.onMicrotaskEmpty.emit(null);
2442
- } finally {
2443
- zone._nesting--;
2444
- if (!zone.hasPendingMicrotasks) {
2445
- try {
2446
- zone.runOutsideAngular(() => zone.onStable.emit(null));
2447
- } finally {
2448
- zone.isStable = true;
2449
- }
2450
- }
2451
- }
2452
- }
33
+ function linkedSignalSetFn(node, newValue) {
34
+ producerUpdateValueVersion(node);
35
+ signalSetFn(node, newValue);
36
+ producerMarkClean(node);
2453
37
  }
2454
- function delayChangeDetectionForEvents(zone) {
2455
- if (zone.isCheckStableRunning || zone.callbackScheduled) {
2456
- return;
2457
- }
2458
- zone.callbackScheduled = true;
2459
- function scheduleCheckStable() {
2460
- scheduleCallbackWithRafRace(() => {
2461
- zone.callbackScheduled = false;
2462
- updateMicroTaskStatus(zone);
2463
- zone.isCheckStableRunning = true;
2464
- checkStable(zone);
2465
- zone.isCheckStableRunning = false;
2466
- });
38
+ function linkedSignalUpdateFn(node, updater) {
39
+ producerUpdateValueVersion(node);
40
+ if (node.value === ERRORED) {
41
+ throw node.error;
2467
42
  }
2468
- if (zone.scheduleInRootZone) {
2469
- Zone.root.run(() => {
2470
- scheduleCheckStable();
2471
- });
2472
- } else {
2473
- zone._outer.run(() => {
2474
- scheduleCheckStable();
2475
- });
2476
- }
2477
- updateMicroTaskStatus(zone);
43
+ signalUpdateFn(node, updater);
44
+ producerMarkClean(node);
2478
45
  }
2479
- function forkInnerZoneWithAngularBehavior(zone) {
2480
- const delayChangeDetectionForEventsDelegate = () => {
2481
- delayChangeDetectionForEvents(zone);
2482
- };
2483
- const instanceId = ngZoneInstanceId++;
2484
- zone._inner = zone._inner.fork({
2485
- name: 'angular',
2486
- properties: {
2487
- [isAngularZoneProperty]: true,
2488
- [angularZoneInstanceIdProperty]: instanceId,
2489
- [angularZoneInstanceIdProperty + instanceId]: true
2490
- },
2491
- onInvokeTask: (delegate, current, target, task, applyThis, applyArgs) => {
2492
- if (shouldBeIgnoredByZone(applyArgs)) {
2493
- return delegate.invokeTask(target, task, applyThis, applyArgs);
2494
- }
2495
- try {
2496
- onEnter(zone);
2497
- return delegate.invokeTask(target, task, applyThis, applyArgs);
2498
- } finally {
2499
- if (zone.shouldCoalesceEventChangeDetection && task.type === 'eventTask' || zone.shouldCoalesceRunChangeDetection) {
2500
- delayChangeDetectionForEventsDelegate();
2501
- }
2502
- onLeave(zone);
2503
- }
46
+ const LINKED_SIGNAL_NODE = /* @__PURE__ */(() => {
47
+ return {
48
+ ...REACTIVE_NODE,
49
+ value: UNSET,
50
+ dirty: true,
51
+ error: null,
52
+ equal: defaultEquals,
53
+ kind: 'linkedSignal',
54
+ producerMustRecompute(node) {
55
+ return node.value === UNSET || node.value === COMPUTING;
2504
56
  },
2505
- onInvoke: (delegate, current, target, callback, applyThis, applyArgs, source) => {
57
+ producerRecomputeValue(node) {
58
+ if (node.value === COMPUTING) {
59
+ throw new Error(typeof ngDevMode !== 'undefined' && ngDevMode ? 'Detected cycle in computations.' : '');
60
+ }
61
+ const oldValue = node.value;
62
+ node.value = COMPUTING;
63
+ const prevConsumer = consumerBeforeComputation(node);
64
+ let newValue;
2506
65
  try {
2507
- onEnter(zone);
2508
- return delegate.invoke(target, callback, applyThis, applyArgs, source);
66
+ const newSourceValue = node.source();
67
+ const prev = oldValue === UNSET || oldValue === ERRORED ? undefined : {
68
+ source: node.sourceValue,
69
+ value: oldValue
70
+ };
71
+ newValue = node.computation(newSourceValue, prev);
72
+ node.sourceValue = newSourceValue;
73
+ } catch (err) {
74
+ newValue = ERRORED;
75
+ node.error = err;
2509
76
  } finally {
2510
- if (zone.shouldCoalesceRunChangeDetection && !zone.callbackScheduled && !isSchedulerTick(applyArgs)) {
2511
- delayChangeDetectionForEventsDelegate();
2512
- }
2513
- onLeave(zone);
2514
- }
2515
- },
2516
- onHasTask: (delegate, current, target, hasTaskState) => {
2517
- delegate.hasTask(target, hasTaskState);
2518
- if (current === target) {
2519
- if (hasTaskState.change == 'microTask') {
2520
- zone._hasPendingMicrotasks = hasTaskState.microTask;
2521
- updateMicroTaskStatus(zone);
2522
- checkStable(zone);
2523
- } else if (hasTaskState.change == 'macroTask') {
2524
- zone.hasPendingMacrotasks = hasTaskState.macroTask;
2525
- }
77
+ consumerAfterComputation(node, prevConsumer);
2526
78
  }
2527
- },
2528
- onHandleError: (delegate, current, target, error) => {
2529
- delegate.handleError(target, error);
2530
- zone.runOutsideAngular(() => zone.onError.emit(error));
2531
- return false;
2532
- }
2533
- });
2534
- }
2535
- function updateMicroTaskStatus(zone) {
2536
- if (zone._hasPendingMicrotasks || (zone.shouldCoalesceEventChangeDetection || zone.shouldCoalesceRunChangeDetection) && zone.callbackScheduled === true) {
2537
- zone.hasPendingMicrotasks = true;
2538
- } else {
2539
- zone.hasPendingMicrotasks = false;
2540
- }
2541
- }
2542
- function onEnter(zone) {
2543
- zone._nesting++;
2544
- if (zone.isStable) {
2545
- zone.isStable = false;
2546
- zone.onUnstable.emit(null);
2547
- }
2548
- }
2549
- function onLeave(zone) {
2550
- zone._nesting--;
2551
- checkStable(zone);
2552
- }
2553
- class NoopNgZone {
2554
- hasPendingMicrotasks = false;
2555
- hasPendingMacrotasks = false;
2556
- isStable = true;
2557
- onUnstable = new EventEmitter();
2558
- onMicrotaskEmpty = new EventEmitter();
2559
- onStable = new EventEmitter();
2560
- onError = new EventEmitter();
2561
- run(fn, applyThis, applyArgs) {
2562
- return fn.apply(applyThis, applyArgs);
2563
- }
2564
- runGuarded(fn, applyThis, applyArgs) {
2565
- return fn.apply(applyThis, applyArgs);
2566
- }
2567
- runOutsideAngular(fn) {
2568
- return fn();
2569
- }
2570
- runTask(fn, applyThis, applyArgs, name) {
2571
- return fn.apply(applyThis, applyArgs);
2572
- }
2573
- }
2574
- function shouldBeIgnoredByZone(applyArgs) {
2575
- return hasApplyArgsData(applyArgs, '__ignore_ng_zone__');
2576
- }
2577
- function isSchedulerTick(applyArgs) {
2578
- return hasApplyArgsData(applyArgs, '__scheduler_tick__');
2579
- }
2580
- function hasApplyArgsData(applyArgs, key) {
2581
- if (!Array.isArray(applyArgs)) {
2582
- return false;
2583
- }
2584
- if (applyArgs.length !== 1) {
2585
- return false;
2586
- }
2587
- return applyArgs[0]?.data?.[key] === true;
2588
- }
2589
-
2590
- class ErrorHandler {
2591
- _console = console;
2592
- handleError(error) {
2593
- this._console.error('ERROR', error);
2594
- }
2595
- }
2596
- const INTERNAL_APPLICATION_ERROR_HANDLER = new InjectionToken(typeof ngDevMode === 'undefined' || ngDevMode ? 'internal error handler' : '', {
2597
- factory: () => {
2598
- const zone = inject(NgZone);
2599
- const injector = inject(EnvironmentInjector);
2600
- let userErrorHandler;
2601
- return e => {
2602
- zone.runOutsideAngular(() => {
2603
- if (injector.destroyed && !userErrorHandler) {
2604
- setTimeout(() => {
2605
- throw e;
2606
- });
2607
- } else {
2608
- userErrorHandler ??= injector.get(ErrorHandler);
2609
- userErrorHandler.handleError(e);
2610
- }
2611
- });
2612
- };
2613
- }
2614
- });
2615
- const errorHandlerEnvironmentInitializer = {
2616
- provide: ENVIRONMENT_INITIALIZER,
2617
- useValue: () => {
2618
- const handler = inject(ErrorHandler, {
2619
- optional: true
2620
- });
2621
- if ((typeof ngDevMode === 'undefined' || ngDevMode) && handler === null) {
2622
- throw new RuntimeError(402, `A required Injectable was not found in the dependency injection tree. ` + 'If you are bootstrapping an NgModule, make sure that the `BrowserModule` is imported.');
2623
- }
2624
- },
2625
- multi: true
2626
- };
2627
- const globalErrorListeners = new InjectionToken(typeof ngDevMode !== 'undefined' && ngDevMode ? 'GlobalErrorListeners' : '', {
2628
- factory: () => {
2629
- if (typeof ngServerMode !== 'undefined' && ngServerMode) {
2630
- return;
2631
- }
2632
- const window = inject(DOCUMENT).defaultView;
2633
- if (!window) {
2634
- return;
2635
- }
2636
- const errorHandler = inject(INTERNAL_APPLICATION_ERROR_HANDLER);
2637
- const rejectionListener = e => {
2638
- errorHandler(e.reason);
2639
- e.preventDefault();
2640
- };
2641
- const errorListener = e => {
2642
- if (e.error) {
2643
- errorHandler(e.error);
2644
- } else {
2645
- errorHandler(new Error(ngDevMode ? `An ErrorEvent with no error occurred. See Error.cause for details: ${e.message}` : e.message, {
2646
- cause: e
2647
- }));
2648
- }
2649
- e.preventDefault();
2650
- };
2651
- const setupEventListeners = () => {
2652
- window.addEventListener('unhandledrejection', rejectionListener);
2653
- window.addEventListener('error', errorListener);
2654
- };
2655
- if (typeof Zone !== 'undefined') {
2656
- Zone.root.run(setupEventListeners);
2657
- } else {
2658
- setupEventListeners();
2659
- }
2660
- inject(DestroyRef).onDestroy(() => {
2661
- window.removeEventListener('error', errorListener);
2662
- window.removeEventListener('unhandledrejection', rejectionListener);
2663
- });
2664
- }
2665
- });
2666
- function provideBrowserGlobalErrorListeners() {
2667
- return makeEnvironmentProviders([provideEnvironmentInitializer(() => void inject(globalErrorListeners))]);
2668
- }
2669
-
2670
- function ɵunwrapWritableSignal(value) {
2671
- return null;
2672
- }
2673
- function signal(initialValue, options) {
2674
- const [get, set, update] = createSignal(initialValue, options?.equal);
2675
- const signalFn = get;
2676
- const node = signalFn[SIGNAL];
2677
- signalFn.set = set;
2678
- signalFn.update = update;
2679
- signalFn.asReadonly = signalAsReadonlyFn.bind(signalFn);
2680
- if (ngDevMode) {
2681
- signalFn.toString = () => `[Signal: ${signalFn()}]`;
2682
- node.debugName = options?.debugName;
2683
- }
2684
- return signalFn;
2685
- }
2686
- function signalAsReadonlyFn() {
2687
- const node = this[SIGNAL];
2688
- if (node.readonlyFn === undefined) {
2689
- const readonlyFn = () => this();
2690
- readonlyFn[SIGNAL] = node;
2691
- node.readonlyFn = readonlyFn;
2692
- }
2693
- return node.readonlyFn;
2694
- }
2695
-
2696
- function assertNotInReactiveContext(debugFn, extraContext) {
2697
- if (getActiveConsumer() !== null) {
2698
- throw new RuntimeError(-602, ngDevMode && `${debugFn.name}() cannot be called from within a reactive context.${extraContext ? ` ${extraContext}` : ''}`);
2699
- }
2700
- }
2701
-
2702
- class ViewContext {
2703
- view;
2704
- node;
2705
- constructor(view, node) {
2706
- this.view = view;
2707
- this.node = node;
2708
- }
2709
- static __NG_ELEMENT_ID__ = injectViewContext;
2710
- }
2711
- function injectViewContext() {
2712
- return new ViewContext(getLView(), getCurrentTNode());
2713
- }
2714
-
2715
- class ChangeDetectionScheduler {}
2716
- const ZONELESS_ENABLED = new InjectionToken(typeof ngDevMode === 'undefined' || ngDevMode ? 'Zoneless enabled' : '', {
2717
- factory: () => true
2718
- });
2719
- const PROVIDED_ZONELESS = new InjectionToken(typeof ngDevMode === 'undefined' || ngDevMode ? 'Zoneless provided' : '', {
2720
- factory: () => false
2721
- });
2722
- const SCHEDULE_IN_ROOT_ZONE = new InjectionToken(typeof ngDevMode === 'undefined' || ngDevMode ? 'run changes outside zone in root' : '');
2723
-
2724
- class PendingTasks {
2725
- internalPendingTasks = inject(PendingTasksInternal);
2726
- scheduler = inject(ChangeDetectionScheduler);
2727
- errorHandler = inject(INTERNAL_APPLICATION_ERROR_HANDLER);
2728
- add() {
2729
- const taskId = this.internalPendingTasks.add();
2730
- return () => {
2731
- if (!this.internalPendingTasks.has(taskId)) {
79
+ if (oldValue !== UNSET && newValue !== ERRORED && node.equal(oldValue, newValue)) {
80
+ node.value = oldValue;
2732
81
  return;
2733
82
  }
2734
- this.scheduler.notify(11);
2735
- this.internalPendingTasks.remove(taskId);
2736
- };
2737
- }
2738
- run(fn) {
2739
- const removeTask = this.add();
2740
- fn().catch(this.errorHandler).finally(removeTask);
2741
- }
2742
- static ɵprov =
2743
- /* @__PURE__ */
2744
- ɵɵdefineInjectable({
2745
- token: PendingTasks,
2746
- providedIn: 'root',
2747
- factory: () => new PendingTasks()
2748
- });
2749
- }
2750
-
2751
- class EffectScheduler {
2752
- static ɵprov =
2753
- /* @__PURE__ */
2754
- ɵɵdefineInjectable({
2755
- token: EffectScheduler,
2756
- providedIn: 'root',
2757
- factory: () => new ZoneAwareEffectScheduler()
2758
- });
2759
- }
2760
- class ZoneAwareEffectScheduler {
2761
- dirtyEffectCount = 0;
2762
- queues = new Map();
2763
- add(handle) {
2764
- this.enqueue(handle);
2765
- this.schedule(handle);
2766
- }
2767
- schedule(handle) {
2768
- if (!handle.dirty) {
2769
- return;
2770
- }
2771
- this.dirtyEffectCount++;
2772
- }
2773
- remove(handle) {
2774
- const zone = handle.zone;
2775
- const queue = this.queues.get(zone);
2776
- if (!queue.has(handle)) {
2777
- return;
2778
- }
2779
- queue.delete(handle);
2780
- if (handle.dirty) {
2781
- this.dirtyEffectCount--;
2782
- }
2783
- }
2784
- enqueue(handle) {
2785
- const zone = handle.zone;
2786
- if (!this.queues.has(zone)) {
2787
- this.queues.set(zone, new Set());
2788
- }
2789
- const queue = this.queues.get(zone);
2790
- if (queue.has(handle)) {
2791
- return;
2792
- }
2793
- queue.add(handle);
2794
- }
2795
- flush() {
2796
- while (this.dirtyEffectCount > 0) {
2797
- let ranOneEffect = false;
2798
- for (const [zone, queue] of this.queues) {
2799
- if (zone === null) {
2800
- ranOneEffect ||= this.flushQueue(queue);
2801
- } else {
2802
- ranOneEffect ||= zone.run(() => this.flushQueue(queue));
2803
- }
2804
- }
2805
- if (!ranOneEffect) {
2806
- this.dirtyEffectCount = 0;
2807
- }
2808
- }
2809
- }
2810
- flushQueue(queue) {
2811
- let ranOneEffect = false;
2812
- for (const handle of queue) {
2813
- if (!handle.dirty) {
2814
- continue;
2815
- }
2816
- this.dirtyEffectCount--;
2817
- ranOneEffect = true;
2818
- handle.run();
2819
- }
2820
- return ranOneEffect;
2821
- }
2822
- }
2823
-
2824
- class EffectRefImpl {
2825
- [SIGNAL];
2826
- constructor(node) {
2827
- this[SIGNAL] = node;
2828
- }
2829
- destroy() {
2830
- this[SIGNAL].destroy();
2831
- }
2832
- }
2833
- function effect(effectFn, options) {
2834
- ngDevMode && assertNotInReactiveContext(effect, 'Call `effect` outside of a reactive context. For example, schedule the ' + 'effect inside the component constructor.');
2835
- if (ngDevMode && !options?.injector) {
2836
- assertInInjectionContext(effect);
2837
- }
2838
- if (ngDevMode && options?.allowSignalWrites !== undefined) {
2839
- console.warn(`The 'allowSignalWrites' flag is deprecated and no longer impacts effect() (writes are always allowed)`);
2840
- }
2841
- const injector = options?.injector ?? inject(Injector);
2842
- let destroyRef = options?.manualCleanup !== true ? injector.get(DestroyRef) : null;
2843
- let node;
2844
- const viewContext = injector.get(ViewContext, null, {
2845
- optional: true
2846
- });
2847
- const notifier = injector.get(ChangeDetectionScheduler);
2848
- if (viewContext !== null) {
2849
- node = createViewEffect(viewContext.view, notifier, effectFn);
2850
- if (destroyRef instanceof NodeInjectorDestroyRef && destroyRef._lView === viewContext.view) {
2851
- destroyRef = null;
2852
- }
2853
- } else {
2854
- node = createRootEffect(effectFn, injector.get(EffectScheduler), notifier);
2855
- }
2856
- node.injector = injector;
2857
- if (destroyRef !== null) {
2858
- node.onDestroyFns = [destroyRef.onDestroy(() => node.destroy())];
2859
- }
2860
- const effectRef = new EffectRefImpl(node);
2861
- if (ngDevMode) {
2862
- node.debugName = options?.debugName ?? '';
2863
- const prevInjectorProfilerContext = setInjectorProfilerContext({
2864
- injector,
2865
- token: null
2866
- });
2867
- try {
2868
- emitEffectCreatedEvent(effectRef);
2869
- } finally {
2870
- setInjectorProfilerContext(prevInjectorProfilerContext);
2871
- }
2872
- }
2873
- return effectRef;
2874
- }
2875
- const EFFECT_NODE = /* @__PURE__ */(() => ({
2876
- ...BASE_EFFECT_NODE,
2877
- cleanupFns: undefined,
2878
- zone: null,
2879
- onDestroyFns: null,
2880
- run() {
2881
- if (ngDevMode && isInNotificationPhase()) {
2882
- throw new Error(`Schedulers cannot synchronously execute watches while scheduling.`);
2883
- }
2884
- const prevRefreshingViews = setIsRefreshingViews(false);
2885
- try {
2886
- runEffect(this);
2887
- } finally {
2888
- setIsRefreshingViews(prevRefreshingViews);
2889
- }
2890
- },
2891
- cleanup() {
2892
- if (!this.cleanupFns?.length) {
2893
- return;
2894
- }
2895
- const prevConsumer = setActiveConsumer$1(null);
2896
- try {
2897
- while (this.cleanupFns.length) {
2898
- this.cleanupFns.pop()();
2899
- }
2900
- } finally {
2901
- this.cleanupFns = [];
2902
- setActiveConsumer$1(prevConsumer);
2903
- }
2904
- }
2905
- }))();
2906
- const ROOT_EFFECT_NODE = /* @__PURE__ */(() => ({
2907
- ...EFFECT_NODE,
2908
- consumerMarkedDirty() {
2909
- this.scheduler.schedule(this);
2910
- this.notifier.notify(12);
2911
- },
2912
- destroy() {
2913
- consumerDestroy(this);
2914
- if (this.onDestroyFns !== null) {
2915
- for (const fn of this.onDestroyFns) {
2916
- fn();
2917
- }
2918
- }
2919
- this.cleanup();
2920
- this.scheduler.remove(this);
2921
- }
2922
- }))();
2923
- const VIEW_EFFECT_NODE = /* @__PURE__ */(() => ({
2924
- ...EFFECT_NODE,
2925
- consumerMarkedDirty() {
2926
- this.view[FLAGS] |= 8192;
2927
- markAncestorsForTraversal(this.view);
2928
- this.notifier.notify(13);
2929
- },
2930
- destroy() {
2931
- consumerDestroy(this);
2932
- if (this.onDestroyFns !== null) {
2933
- for (const fn of this.onDestroyFns) {
2934
- fn();
2935
- }
83
+ node.value = newValue;
84
+ node.version++;
2936
85
  }
2937
- this.cleanup();
2938
- this.view[EFFECTS]?.delete(this);
2939
- }
2940
- }))();
2941
- function createViewEffect(view, notifier, fn) {
2942
- const node = Object.create(VIEW_EFFECT_NODE);
2943
- node.view = view;
2944
- node.zone = typeof Zone !== 'undefined' ? Zone.current : null;
2945
- node.notifier = notifier;
2946
- node.fn = createEffectFn(node, fn);
2947
- view[EFFECTS] ??= new Set();
2948
- view[EFFECTS].add(node);
2949
- node.consumerMarkedDirty(node);
2950
- return node;
2951
- }
2952
- function createRootEffect(fn, scheduler, notifier) {
2953
- const node = Object.create(ROOT_EFFECT_NODE);
2954
- node.fn = createEffectFn(node, fn);
2955
- node.scheduler = scheduler;
2956
- node.notifier = notifier;
2957
- node.zone = typeof Zone !== 'undefined' ? Zone.current : null;
2958
- node.scheduler.add(node);
2959
- node.notifier.notify(12);
2960
- return node;
2961
- }
2962
- function createEffectFn(node, fn) {
2963
- return () => {
2964
- fn(cleanupFn => (node.cleanupFns ??= []).push(cleanupFn));
2965
86
  };
2966
- }
87
+ })();
2967
88
 
2968
89
  function untracked(nonReactiveReadsFn) {
2969
- return untracked$1(nonReactiveReadsFn);
90
+ const prevConsumer = setActiveConsumer(null);
91
+ try {
92
+ return nonReactiveReadsFn();
93
+ } finally {
94
+ setActiveConsumer(prevConsumer);
95
+ }
2970
96
  }
2971
97
 
2972
- export { AFTER_RENDER_SEQUENCES_TO_ADD, ANIMATIONS, CHILD_HEAD, CHILD_TAIL, CLEANUP, CONTAINER_HEADER_OFFSET, CONTEXT, ChangeDetectionScheduler, CheckNoChangesMode, DEBUG_TASK_TRACKER, DECLARATION_COMPONENT_VIEW, DECLARATION_LCONTAINER, DECLARATION_VIEW, DEHYDRATED_VIEWS, DOCUMENT, DOC_PAGE_BASE_URL, DestroyRef, EFFECTS, EFFECTS_TO_SCHEDULE, EMBEDDED_VIEW_INJECTOR, EMPTY_ARRAY, EMPTY_OBJ, ENVIRONMENT, ENVIRONMENT_INITIALIZER, ERROR_DETAILS_PAGE_BASE_URL, EffectRefImpl, EffectScheduler, EnvironmentInjector, ErrorHandler, EventEmitter, FLAGS, HEADER_OFFSET, HOST, HYDRATION, ID, INJECTOR$1 as INJECTOR, INJECTOR as INJECTOR$1, INJECTOR_DEF_TYPES, INJECTOR_SCOPE, INTERNAL_APPLICATION_ERROR_HANDLER, InjectionToken, Injector, MATH_ML_NAMESPACE, MOVED_VIEWS, NATIVE, NEXT, NG_COMP_DEF, NG_DIR_DEF, NG_ELEMENT_ID, NG_FACTORY_DEF, NG_INJ_DEF, NG_MOD_DEF, NG_PIPE_DEF, NG_PROV_DEF, NgZone, NoopNgZone, NullInjector, ON_DESTROY_HOOKS, PARENT, PREORDER_HOOK_FLAGS, PROVIDED_ZONELESS, PendingTasks, PendingTasksInternal, QUERIES, R3Injector, REACTIVE_TEMPLATE_CONSUMER, RENDERER, RuntimeError, SCHEDULE_IN_ROOT_ZONE, SCHEDULE_IN_ROOT_ZONE_DEFAULT, SVG_NAMESPACE, TVIEW, T_HOST, VERSION, VIEW_REFS, Version, ViewContext, XSS_SECURITY_URL, ZONELESS_ENABLED, _global, addToArray, angularZoneInstanceIdProperty, arrayEquals, arrayInsert2, arraySplice, assertComponentType, assertDefined, assertDirectiveDef, assertDomNode, assertElement, assertEqual, assertFirstCreatePass, assertFirstUpdatePass, assertFunction, assertGreaterThan, assertGreaterThanOrEqual, assertHasParent, assertInInjectionContext, assertIndexInDeclRange, assertIndexInExpandoRange, assertIndexInRange, assertInjectImplementationNotEqual, assertLContainer, assertLView, assertLessThan, assertNgModuleType, assertNodeInjector, assertNotDefined, assertNotEqual, assertNotInReactiveContext, assertNotReactive, assertNotSame, assertNumber, assertNumberInRange, assertOneOf, assertParentView, assertProjectionSlots, assertSame, assertString, assertTIcu, assertTNode, assertTNodeCreationIndex, assertTNodeForLView, assertTNodeForTView, attachInjectFlag, concatStringsWithSpace, convertToBitFlags, createInjector, createInjectorWithoutInjectorInstances, cyclicDependencyError, cyclicDependencyErrorWithDetails, debugStringifyTypeForError, decreaseElementDepthCount, deepForEach, effect, emitAfterRenderEffectPhaseCreatedEvent, emitInjectEvent, emitInjectorToCreateInstanceEvent, emitInstanceCreatedByInjectorEvent, emitProviderConfiguredEvent, enterDI, enterSkipHydrationBlock, enterView, errorHandlerEnvironmentInitializer, fillProperties, flatten, formatRuntimeError, forwardRef, getBindingIndex, getBindingRoot, getBindingsEnabled, getClosureSafeProperty, getComponentDef, getComponentLViewByIndex, getConstant, getContextLView, getCurrentDirectiveDef, getCurrentDirectiveIndex, getCurrentParentTNode, getCurrentQueryIndex, getCurrentTNode, getCurrentTNodePlaceholderOk, getDirectiveDef, getDirectiveDefOrThrow, getElementDepthCount, getFactoryDef, getInjectableDef, getInjectorDef, getLView, getLViewParent, getNamespace, getNativeByIndex, getNativeByTNode, getNativeByTNodeOrNull, getNgModuleDef, getNgModuleDefOrThrow, getNullInjector, getOrCreateLViewCleanup, getOrCreateTViewCleanup, getPipeDef, getSelectedIndex, getSelectedTNode, getTNode, getTView, hasI18n, importProvidersFrom, increaseElementDepthCount, incrementBindingIndex, initNgDevMode, inject, injectRootLimpMode, internalImportProvidersFrom, isClassProvider, isComponentDef, isComponentHost, isContentQueryHost, isCreationMode, isCurrentTNodeParent, isDestroyed, isDirectiveHost, isEnvironmentProviders, isExhaustiveCheckNoChanges, isForwardRef, isInCheckNoChangesMode, isInI18nBlock, isInInjectionContext, isInSkipHydrationBlock, isInjectable, isLContainer, isLView, isProjectionTNode, isRefreshingViews, isRootView, isSkipHydrationRootTNode, isStandalone, isTypeProvider, keyValueArrayGet, keyValueArrayIndexOf, keyValueArraySet, lastNodeWasCreated, leaveDI, leaveSkipHydrationBlock, leaveView, load, makeEnvironmentProviders, markAncestorsForTraversal, markViewForRefresh, newArray, nextBindingIndex, nextContextImpl, provideBrowserGlobalErrorListeners, provideEnvironmentInitializer, providerToFactory, removeFromArray, removeLViewOnDestroy, renderStringify, requiresRefreshOrTraversal, resetPreOrderHookFlags, resolveForwardRef, runInInjectionContext, runInInjectorProfilerContext, scheduleCallbackWithMicrotask, scheduleCallbackWithRafRace, setBindingIndex, setBindingRootForHostBindings, setCurrentDirectiveIndex, setCurrentQueryIndex, setCurrentTNode, setCurrentTNodeAsNotParent, setInI18nBlock, setInjectImplementation, setInjectorProfiler, setInjectorProfilerContext, setIsInCheckNoChangesMode, setIsRefreshingViews, setSelectedIndex, signal, signalAsReadonlyFn, store, storeCleanupWithContext, storeLViewOnDestroy, stringify, stringifyForError, throwError, throwProviderNotFoundError, truncateMiddle, untracked, unwrapLView, unwrapRNode, updateAncestorTraversalFlagsOnAttach, viewAttachedToChangeDetector, viewAttachedToContainer, walkProviderTree, walkUpViews, wasLastNodeCreated, ɵunwrapWritableSignal, ɵɵdefineInjectable, ɵɵdefineInjector, ɵɵdisableBindings, ɵɵenableBindings, ɵɵinject, ɵɵinvalidFactoryDep, ɵɵnamespaceHTML, ɵɵnamespaceMathML, ɵɵnamespaceSVG, ɵɵresetView, ɵɵrestoreView };
98
+ export { createLinkedSignal, linkedSignalSetFn, linkedSignalUpdateFn, untracked };
2973
99
  //# sourceMappingURL=_untracked-chunk.mjs.map