@angular/core 21.0.0-next.9 → 21.0.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fesm2022/_attribute-chunk.mjs +2 -14
- package/fesm2022/_attribute-chunk.mjs.map +1 -1
- package/fesm2022/_debug_node-chunk.mjs +15164 -28368
- package/fesm2022/_debug_node-chunk.mjs.map +1 -1
- package/fesm2022/_effect-chunk.mjs +322 -504
- package/fesm2022/_effect-chunk.mjs.map +1 -1
- package/fesm2022/_effect-chunk2.mjs +2204 -4061
- package/fesm2022/_effect-chunk2.mjs.map +1 -1
- package/fesm2022/_not_found-chunk.mjs +18 -35
- package/fesm2022/_not_found-chunk.mjs.map +1 -1
- package/fesm2022/_resource-chunk.mjs +312 -391
- package/fesm2022/_resource-chunk.mjs.map +1 -1
- package/fesm2022/_untracked-chunk.mjs +75 -96
- package/fesm2022/_untracked-chunk.mjs.map +1 -1
- package/fesm2022/_weak_ref-chunk.mjs +2 -4
- package/fesm2022/_weak_ref-chunk.mjs.map +1 -1
- package/fesm2022/core.mjs +2461 -4305
- package/fesm2022/core.mjs.map +1 -1
- package/fesm2022/primitives-di.mjs +9 -9
- package/fesm2022/primitives-di.mjs.map +1 -1
- package/fesm2022/primitives-event-dispatch.mjs +626 -1460
- package/fesm2022/primitives-event-dispatch.mjs.map +1 -1
- package/fesm2022/primitives-signals.mjs +154 -188
- package/fesm2022/primitives-signals.mjs.map +1 -1
- package/fesm2022/rxjs-interop.mjs +204 -304
- package/fesm2022/rxjs-interop.mjs.map +1 -1
- package/fesm2022/testing.mjs +2303 -3162
- package/fesm2022/testing.mjs.map +1 -1
- package/package.json +8 -2
- package/resources/best-practices.md +56 -0
- package/schematics/bundles/add-bootstrap-context-to-server-main.cjs +7 -25
- package/schematics/bundles/application-config-core.cjs +8 -19
- package/schematics/bundles/{apply_import_manager-CoeTX_Ob.cjs → apply_import_manager-1Zs_gpB6.cjs} +4 -5
- package/schematics/bundles/bootstrap-options-migration.cjs +93 -132
- package/schematics/bundles/cleanup-unused-imports.cjs +9 -13
- package/schematics/bundles/common-to-standalone-migration.cjs +12 -16
- package/schematics/bundles/{compiler_host-emLDwK2U.cjs → compiler_host-DBwYMlTo.cjs} +10 -11
- package/schematics/bundles/control-flow-migration.cjs +29 -31
- package/schematics/bundles/{imports-DwPXlGFl.cjs → imports-DP72APSx.cjs} +1 -23
- package/schematics/bundles/{index-CLxYZ09c.cjs → index-B7I9sIUx.cjs} +36 -37
- package/schematics/bundles/inject-migration.cjs +9 -26
- package/schematics/bundles/leading_space-D9nQ8UQC.cjs +1 -1
- package/schematics/bundles/{migrate_ts_type_references-CpM5FPGa.cjs → migrate_ts_type_references-UGIUl7En.cjs} +458 -24
- package/schematics/bundles/{ng_component_template-BRbBIAUX.cjs → ng_component_template-Dsuq1Lw7.cjs} +4 -5
- package/schematics/bundles/{ng_decorators-BI0uV7KI.cjs → ng_decorators-DSFlWYQY.cjs} +2 -2
- package/schematics/bundles/ngclass-to-class-migration.cjs +16 -19
- package/schematics/bundles/ngstyle-to-style-migration.cjs +15 -18
- package/schematics/bundles/nodes-B16H9JUd.cjs +1 -1
- package/schematics/bundles/output-migration.cjs +16 -19
- package/schematics/bundles/{parse_html-CPWfkfhR.cjs → parse_html-8VLCL37B.cjs} +5 -5
- package/schematics/bundles/{project_paths-C8H7KDJ3.cjs → project_paths-DvD50ouC.cjs} +14 -247
- package/schematics/bundles/project_tsconfig_paths-CDVxT6Ov.cjs +90 -0
- package/schematics/bundles/property_name-BBwFuqMe.cjs +1 -1
- package/schematics/bundles/route-lazy-loading.cjs +9 -25
- package/schematics/bundles/router-current-navigation.cjs +6 -17
- package/schematics/bundles/router-last-successful-navigation.cjs +6 -17
- package/schematics/bundles/router-testing-module-migration.cjs +7 -18
- package/schematics/bundles/self-closing-tags-migration.cjs +14 -17
- package/schematics/bundles/signal-input-migration.cjs +23 -26
- package/schematics/bundles/signal-queries-migration.cjs +22 -25
- package/schematics/bundles/signals.cjs +10 -13
- package/schematics/bundles/standalone-migration.cjs +22 -56
- package/schematics/bundles/symbol-BObKoqes.cjs +1 -1
- package/types/_api-chunk.d.ts +1 -1
- package/types/_chrome_dev_tools_performance-chunk.d.ts +1 -1
- package/types/_discovery-chunk.d.ts +7 -9
- package/types/_effect-chunk.d.ts +1 -1
- package/types/_event_dispatcher-chunk.d.ts +1 -1
- package/types/_formatter-chunk.d.ts +1 -1
- package/types/_weak_ref-chunk.d.ts +1 -1
- package/types/core.d.ts +1 -81
- package/types/primitives-di.d.ts +1 -1
- package/types/primitives-event-dispatch.d.ts +1 -1
- package/types/primitives-signals.d.ts +1 -1
- package/types/rxjs-interop.d.ts +1 -1
- package/types/testing.d.ts +1 -1
- package/schematics/bundles/index-Dvqnp6JS.cjs +0 -22419
- package/schematics/bundles/project_tsconfig_paths-CiBzGSIa.cjs +0 -51591
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v21.0.0-
|
|
2
|
+
* @license Angular v21.0.0-rc.0
|
|
3
3
|
* (c) 2010-2025 Google LLC. https://angular.dev/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
@@ -9,212 +9,178 @@ export { BASE_EFFECT_NODE, SIGNAL_NODE, createComputed, createSignal, defaultEqu
|
|
|
9
9
|
export { createLinkedSignal, linkedSignalSetFn, linkedSignalUpdateFn, untracked } from './_untracked-chunk.mjs';
|
|
10
10
|
export { setAlternateWeakRefImpl } from './_weak_ref-chunk.mjs';
|
|
11
11
|
|
|
12
|
-
/**
|
|
13
|
-
* A custom formatter which renders signals in an easy-to-read format.
|
|
14
|
-
*
|
|
15
|
-
* @see https://firefox-source-docs.mozilla.org/devtools-user/custom_formatters/index.html
|
|
16
|
-
*/
|
|
17
12
|
const formatter = {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
const color = 'var(--sys-color-primary)';
|
|
73
|
-
return [
|
|
74
|
-
'div',
|
|
75
|
-
{ style: `background: #FFFFFF10; padding-left: 4px; padding-top: 2px; padding-bottom: 2px;` },
|
|
76
|
-
['div', { style: `color: ${color}` }, 'Signal value: '],
|
|
77
|
-
['div', { style: `padding-left: .5rem;` }, ['object', { object: sig(), config }]],
|
|
78
|
-
['div', { style: `color: ${color}` }, 'Signal function: '],
|
|
79
|
-
[
|
|
80
|
-
'div',
|
|
81
|
-
{ style: `padding-left: .5rem;` },
|
|
82
|
-
['object', { object: sig, config: { ...config, skipFormatting: true } }],
|
|
83
|
-
],
|
|
84
|
-
];
|
|
85
|
-
},
|
|
13
|
+
header: (sig, config) => {
|
|
14
|
+
if (!isSignal(sig) || config?.ngSkipFormatting) return null;
|
|
15
|
+
let value;
|
|
16
|
+
try {
|
|
17
|
+
value = sig();
|
|
18
|
+
} catch {
|
|
19
|
+
return ['span', 'Signal(⚠️ Error)'];
|
|
20
|
+
}
|
|
21
|
+
const kind = 'computation' in sig[SIGNAL] ? 'Computed' : 'Signal';
|
|
22
|
+
const isPrimitive = value === null || !Array.isArray(value) && typeof value !== 'object';
|
|
23
|
+
return ['span', {}, ['span', {}, `${kind}(`], (() => {
|
|
24
|
+
if (isSignal(value)) {
|
|
25
|
+
return formatter.header(value, config);
|
|
26
|
+
} else if (isPrimitive && value !== undefined && typeof value !== 'function') {
|
|
27
|
+
return ['object', {
|
|
28
|
+
object: value
|
|
29
|
+
}];
|
|
30
|
+
} else {
|
|
31
|
+
return prettifyPreview(value);
|
|
32
|
+
}
|
|
33
|
+
})(), ['span', {}, `)`]];
|
|
34
|
+
},
|
|
35
|
+
hasBody: (sig, config) => {
|
|
36
|
+
if (!isSignal(sig)) return false;
|
|
37
|
+
try {
|
|
38
|
+
sig();
|
|
39
|
+
} catch {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
return !config?.ngSkipFormatting;
|
|
43
|
+
},
|
|
44
|
+
body: (sig, config) => {
|
|
45
|
+
const color = 'var(--sys-color-primary)';
|
|
46
|
+
return ['div', {
|
|
47
|
+
style: `background: #FFFFFF10; padding-left: 4px; padding-top: 2px; padding-bottom: 2px;`
|
|
48
|
+
}, ['div', {
|
|
49
|
+
style: `color: ${color}`
|
|
50
|
+
}, 'Signal value: '], ['div', {
|
|
51
|
+
style: `padding-left: .5rem;`
|
|
52
|
+
}, ['object', {
|
|
53
|
+
object: sig(),
|
|
54
|
+
config
|
|
55
|
+
}]], ['div', {
|
|
56
|
+
style: `color: ${color}`
|
|
57
|
+
}, 'Signal function: '], ['div', {
|
|
58
|
+
style: `padding-left: .5rem;`
|
|
59
|
+
}, ['object', {
|
|
60
|
+
object: sig,
|
|
61
|
+
config: {
|
|
62
|
+
...config,
|
|
63
|
+
skipFormatting: true
|
|
64
|
+
}
|
|
65
|
+
}]]];
|
|
66
|
+
}
|
|
86
67
|
};
|
|
87
68
|
function prettifyPreview(value) {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
return
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
return 'class';
|
|
104
|
-
}
|
|
105
|
-
else {
|
|
106
|
-
return '() => {…}';
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
case 'object': {
|
|
110
|
-
if (value.constructor.name === 'Object') {
|
|
111
|
-
return '{…}';
|
|
112
|
-
}
|
|
113
|
-
else {
|
|
114
|
-
return `${value.constructor.name} {}`;
|
|
115
|
-
}
|
|
69
|
+
if (value === null) return 'null';
|
|
70
|
+
if (Array.isArray(value)) return `Array(${value.length})`;
|
|
71
|
+
if (value instanceof Element) return `<${value.tagName.toLowerCase()}>`;
|
|
72
|
+
if (value instanceof URL) return `URL`;
|
|
73
|
+
switch (typeof value) {
|
|
74
|
+
case 'undefined':
|
|
75
|
+
{
|
|
76
|
+
return 'undefined';
|
|
77
|
+
}
|
|
78
|
+
case 'function':
|
|
79
|
+
{
|
|
80
|
+
if ('prototype' in value) {
|
|
81
|
+
return 'class';
|
|
82
|
+
} else {
|
|
83
|
+
return '() => {…}';
|
|
116
84
|
}
|
|
117
|
-
|
|
118
|
-
|
|
85
|
+
}
|
|
86
|
+
case 'object':
|
|
87
|
+
{
|
|
88
|
+
if (value.constructor.name === 'Object') {
|
|
89
|
+
return '{…}';
|
|
90
|
+
} else {
|
|
91
|
+
return `${value.constructor.name} {}`;
|
|
119
92
|
}
|
|
120
|
-
|
|
93
|
+
}
|
|
94
|
+
default:
|
|
95
|
+
{
|
|
96
|
+
return ['object', {
|
|
97
|
+
object: value,
|
|
98
|
+
config: {
|
|
99
|
+
skipFormatting: true
|
|
100
|
+
}
|
|
101
|
+
}];
|
|
102
|
+
}
|
|
103
|
+
}
|
|
121
104
|
}
|
|
122
105
|
function isSignal(value) {
|
|
123
|
-
|
|
106
|
+
return value[SIGNAL] !== undefined;
|
|
124
107
|
}
|
|
125
|
-
/**
|
|
126
|
-
* Installs the custom formatter into custom formatting on Signals in the devtools.
|
|
127
|
-
*
|
|
128
|
-
* Supported by both Chrome and Firefox.
|
|
129
|
-
*
|
|
130
|
-
* @see https://firefox-source-docs.mozilla.org/devtools-user/custom_formatters/index.html
|
|
131
|
-
*/
|
|
132
108
|
function installDevToolsSignalFormatter() {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
109
|
+
globalThis.devtoolsFormatters ??= [];
|
|
110
|
+
if (!globalThis.devtoolsFormatters.some(f => f === formatter)) {
|
|
111
|
+
globalThis.devtoolsFormatters.push(formatter);
|
|
112
|
+
}
|
|
137
113
|
}
|
|
138
114
|
|
|
139
115
|
function createWatch(fn, schedule, allowSignalWrites) {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
116
|
+
const node = Object.create(WATCH_NODE);
|
|
117
|
+
if (allowSignalWrites) {
|
|
118
|
+
node.consumerAllowSignalWrites = true;
|
|
119
|
+
}
|
|
120
|
+
node.fn = fn;
|
|
121
|
+
node.schedule = schedule;
|
|
122
|
+
const registerOnCleanup = cleanupFn => {
|
|
123
|
+
node.cleanupFn = cleanupFn;
|
|
124
|
+
};
|
|
125
|
+
function isWatchNodeDestroyed(node) {
|
|
126
|
+
return node.fn === null && node.schedule === null;
|
|
127
|
+
}
|
|
128
|
+
function destroyWatchNode(node) {
|
|
129
|
+
if (!isWatchNodeDestroyed(node)) {
|
|
130
|
+
consumerDestroy(node);
|
|
131
|
+
node.cleanupFn();
|
|
132
|
+
node.fn = null;
|
|
133
|
+
node.schedule = null;
|
|
134
|
+
node.cleanupFn = NOOP_CLEANUP_FN;
|
|
143
135
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
};
|
|
149
|
-
function isWatchNodeDestroyed(node) {
|
|
150
|
-
return node.fn === null && node.schedule === null;
|
|
136
|
+
}
|
|
137
|
+
const run = () => {
|
|
138
|
+
if (node.fn === null) {
|
|
139
|
+
return;
|
|
151
140
|
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
consumerDestroy(node); // disconnect watcher from the reactive graph
|
|
155
|
-
node.cleanupFn();
|
|
156
|
-
// nullify references to the integration functions to mark node as destroyed
|
|
157
|
-
node.fn = null;
|
|
158
|
-
node.schedule = null;
|
|
159
|
-
node.cleanupFn = NOOP_CLEANUP_FN;
|
|
160
|
-
}
|
|
141
|
+
if (isInNotificationPhase()) {
|
|
142
|
+
throw new Error(typeof ngDevMode !== 'undefined' && ngDevMode ? 'Schedulers cannot synchronously execute watches while scheduling.' : '');
|
|
161
143
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
consumerAfterComputation(node, prevConsumer);
|
|
185
|
-
}
|
|
186
|
-
};
|
|
187
|
-
node.ref = {
|
|
188
|
-
notify: () => consumerMarkDirty(node),
|
|
189
|
-
run,
|
|
190
|
-
cleanup: () => node.cleanupFn(),
|
|
191
|
-
destroy: () => destroyWatchNode(node),
|
|
192
|
-
[SIGNAL]: node,
|
|
193
|
-
};
|
|
194
|
-
return node.ref;
|
|
144
|
+
node.dirty = false;
|
|
145
|
+
if (node.version > 0 && !consumerPollProducersForChange(node)) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
node.version++;
|
|
149
|
+
const prevConsumer = consumerBeforeComputation(node);
|
|
150
|
+
try {
|
|
151
|
+
node.cleanupFn();
|
|
152
|
+
node.cleanupFn = NOOP_CLEANUP_FN;
|
|
153
|
+
node.fn(registerOnCleanup);
|
|
154
|
+
} finally {
|
|
155
|
+
consumerAfterComputation(node, prevConsumer);
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
node.ref = {
|
|
159
|
+
notify: () => consumerMarkDirty(node),
|
|
160
|
+
run,
|
|
161
|
+
cleanup: () => node.cleanupFn(),
|
|
162
|
+
destroy: () => destroyWatchNode(node),
|
|
163
|
+
[SIGNAL]: node
|
|
164
|
+
};
|
|
165
|
+
return node.ref;
|
|
195
166
|
}
|
|
196
|
-
const NOOP_CLEANUP_FN = () => {
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
},
|
|
210
|
-
cleanupFn: NOOP_CLEANUP_FN,
|
|
211
|
-
};
|
|
167
|
+
const NOOP_CLEANUP_FN = () => {};
|
|
168
|
+
const WATCH_NODE = /* @__PURE__ */(() => {
|
|
169
|
+
return {
|
|
170
|
+
...REACTIVE_NODE,
|
|
171
|
+
consumerIsAlwaysLive: true,
|
|
172
|
+
consumerAllowSignalWrites: false,
|
|
173
|
+
consumerMarkedDirty: node => {
|
|
174
|
+
if (node.schedule !== null) {
|
|
175
|
+
node.schedule(node.ref);
|
|
176
|
+
}
|
|
177
|
+
},
|
|
178
|
+
cleanupFn: NOOP_CLEANUP_FN
|
|
179
|
+
};
|
|
212
180
|
})();
|
|
213
181
|
|
|
214
|
-
// We're using a top-level access to enable signal formatting whenever the signals package is loaded.
|
|
215
182
|
if (typeof ngDevMode !== 'undefined' && ngDevMode) {
|
|
216
|
-
|
|
217
|
-
installDevToolsSignalFormatter();
|
|
183
|
+
installDevToolsSignalFormatter();
|
|
218
184
|
}
|
|
219
185
|
|
|
220
186
|
export { REACTIVE_NODE, SIGNAL, consumerAfterComputation, consumerBeforeComputation, consumerDestroy, consumerMarkDirty, consumerPollProducersForChange, createWatch, installDevToolsSignalFormatter, isInNotificationPhase };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"primitives-signals.mjs","sources":["../../../../../k8-fastbuild-ST-199a4f3c4e20/bin/packages/core/primitives/signals/src/formatter.ts","../../../../../k8-fastbuild-ST-199a4f3c4e20/bin/packages/core/primitives/signals/src/watch.ts","../../../../../k8-fastbuild-ST-199a4f3c4e20/bin/packages/core/primitives/signals/index.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nimport {SIGNAL} from './graph';\n\n// Only a subset of HTML tags are allowed in the custom formatter JsonML format.\n// See https://firefox-source-docs.mozilla.org/devtools-user/custom_formatters/index.html#html-template-format\ntype AllowedTags = 'span' | 'div' | 'ol' | 'ul' | 'li' | 'table' | 'tr' | 'td';\n\ntype JsonMLText = string;\ntype JsonMLAttrs = Record<string, string>;\ntype JsonMLElement =\n | [tagName: AllowedTags, ...children: (JsonMLNode | JsonMLChild)[]]\n | [tagName: AllowedTags, attrs: JsonMLAttrs, ...children: (JsonMLNode | JsonMLChild)[]];\ntype JsonMLNode = JsonMLText | JsonMLElement;\ntype JsonMLChild = ['object', {object: unknown; config?: unknown}];\ntype JsonML = JsonMLNode;\n\ntype FormatterConfig = unknown & {ngSkipFormatting?: boolean};\n\ndeclare global {\n // We need to use `var` here to be able to declare a global variable.\n // `let` and `const` will be locally scoped to the file.\n // tslint:disable-next-line:no-unused-variable\n var devtoolsFormatters: any[];\n}\n\n/**\n * A custom formatter which renders signals in an easy-to-read format.\n *\n * @see https://firefox-source-docs.mozilla.org/devtools-user/custom_formatters/index.html\n */\n\nconst formatter = {\n /**\n * If the function returns `null`, the formatter is not used for this reference\n */\n header: (sig: any, config: FormatterConfig): JsonML | null => {\n if (!isSignal(sig) || config?.ngSkipFormatting) return null;\n\n let value: unknown;\n try {\n value = sig();\n } catch {\n // In case the signl throws, we don't want to break the formatting.\n return ['span', 'Signal(⚠️ Error)'];\n }\n\n const kind = 'computation' in (sig[SIGNAL] as any) ? 'Computed' : 'Signal';\n\n const isPrimitive = value === null || (!Array.isArray(value) && typeof value !== 'object');\n\n return [\n 'span',\n {},\n ['span', {}, `${kind}(`],\n (() => {\n if (isSignal(value)) {\n // Recursively call formatter. Could return an `object` to call the formatter through DevTools,\n // but then recursive signals will render multiple expando arrows which is an awkward UX.\n return formatter.header(value, config)!;\n } else if (isPrimitive && value !== undefined && typeof value !== 'function') {\n // Use built-in rendering for primitives which applies standard syntax highlighting / theming.\n // Can't do this for `undefined` however, as the browser thinks we forgot to provide an object.\n // Also don't want to do this for functions which render nested expando arrows.\n return ['object', {object: value}];\n } else {\n return prettifyPreview(value as Record<string | number | symbol, unknown>);\n }\n })(),\n ['span', {}, `)`],\n ];\n },\n\n hasBody: (sig: any, config: FormatterConfig) => {\n if (!isSignal(sig)) return false;\n\n try {\n sig();\n } catch {\n return false;\n }\n return !config?.ngSkipFormatting;\n },\n\n body: (sig: any, config: any): JsonML => {\n // We can use sys colors to fit the current DevTools theme.\n // Those are unfortunately only available on Chromium-based browsers.\n // On Firefow we fall back to the default color\n const color = 'var(--sys-color-primary)';\n\n return [\n 'div',\n {style: `background: #FFFFFF10; padding-left: 4px; padding-top: 2px; padding-bottom: 2px;`},\n ['div', {style: `color: ${color}`}, 'Signal value: '],\n ['div', {style: `padding-left: .5rem;`}, ['object', {object: sig(), config}]],\n ['div', {style: `color: ${color}`}, 'Signal function: '],\n [\n 'div',\n {style: `padding-left: .5rem;`},\n ['object', {object: sig, config: {...config, skipFormatting: true}}],\n ],\n ];\n },\n};\n\nfunction prettifyPreview(\n value: Record<string | number | symbol, unknown> | Array<unknown> | undefined,\n): string | JsonMLChild {\n if (value === null) return 'null';\n if (Array.isArray(value)) return `Array(${value.length})`;\n if (value instanceof Element) return `<${value.tagName.toLowerCase()}>`;\n if (value instanceof URL) return `URL`;\n\n switch (typeof value) {\n case 'undefined': {\n return 'undefined';\n }\n case 'function': {\n if ('prototype' in value) {\n // This is what Chrome renders, can't use `object` though because it creates a nested expando arrow.\n return 'class';\n } else {\n return '() => {…}';\n }\n }\n case 'object': {\n if (value.constructor.name === 'Object') {\n return '{…}';\n } else {\n return `${value.constructor.name} {}`;\n }\n }\n default: {\n return ['object', {object: value, config: {skipFormatting: true}}];\n }\n }\n}\n\nfunction isSignal(value: any): boolean {\n return value[SIGNAL] !== undefined;\n}\n\n/**\n * Installs the custom formatter into custom formatting on Signals in the devtools.\n *\n * Supported by both Chrome and Firefox.\n *\n * @see https://firefox-source-docs.mozilla.org/devtools-user/custom_formatters/index.html\n */\nexport function installDevToolsSignalFormatter() {\n globalThis.devtoolsFormatters ??= [];\n if (!globalThis.devtoolsFormatters.some((f: any) => f === formatter)) {\n globalThis.devtoolsFormatters.push(formatter);\n }\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {\n consumerAfterComputation,\n consumerBeforeComputation,\n consumerDestroy,\n consumerMarkDirty,\n consumerPollProducersForChange,\n isInNotificationPhase,\n REACTIVE_NODE,\n ReactiveNode,\n SIGNAL,\n} from './graph';\n\n// Required as the signals library is in a separate package, so we need to explicitly ensure the\n// global `ngDevMode` type is defined.\ndeclare const ngDevMode: boolean | undefined;\n\n/**\n * A cleanup function that can be optionally registered from the watch logic. If registered, the\n * cleanup logic runs before the next watch execution.\n */\nexport type WatchCleanupFn = () => void;\n\n/**\n * A callback passed to the watch function that makes it possible to register cleanup logic.\n */\nexport type WatchCleanupRegisterFn = (cleanupFn: WatchCleanupFn) => void;\n\nexport interface Watch {\n notify(): void;\n\n /**\n * Execute the reactive expression in the context of this `Watch` consumer.\n *\n * Should be called by the user scheduling algorithm when the provided\n * `schedule` hook is called by `Watch`.\n */\n run(): void;\n\n cleanup(): void;\n\n /**\n * Destroy the watcher:\n * - disconnect it from the reactive graph;\n * - mark it as destroyed so subsequent run and notify operations are noop.\n */\n destroy(): void;\n\n [SIGNAL]: WatchNode;\n}\nexport interface WatchNode extends ReactiveNode {\n fn: ((onCleanup: WatchCleanupRegisterFn) => void) | null;\n schedule: ((watch: Watch) => void) | null;\n cleanupFn: WatchCleanupFn;\n ref: Watch;\n}\n\nexport function createWatch(\n fn: (onCleanup: WatchCleanupRegisterFn) => void,\n schedule: (watch: Watch) => void,\n allowSignalWrites: boolean,\n): Watch {\n const node: WatchNode = Object.create(WATCH_NODE);\n if (allowSignalWrites) {\n node.consumerAllowSignalWrites = true;\n }\n\n node.fn = fn;\n node.schedule = schedule;\n\n const registerOnCleanup = (cleanupFn: WatchCleanupFn) => {\n node.cleanupFn = cleanupFn;\n };\n\n function isWatchNodeDestroyed(node: WatchNode) {\n return node.fn === null && node.schedule === null;\n }\n\n function destroyWatchNode(node: WatchNode) {\n if (!isWatchNodeDestroyed(node)) {\n consumerDestroy(node); // disconnect watcher from the reactive graph\n node.cleanupFn();\n\n // nullify references to the integration functions to mark node as destroyed\n node.fn = null;\n node.schedule = null;\n node.cleanupFn = NOOP_CLEANUP_FN;\n }\n }\n\n const run = () => {\n if (node.fn === null) {\n // trying to run a destroyed watch is noop\n return;\n }\n\n if (isInNotificationPhase()) {\n throw new Error(\n typeof ngDevMode !== 'undefined' && ngDevMode\n ? 'Schedulers cannot synchronously execute watches while scheduling.'\n : '',\n );\n }\n\n node.dirty = false;\n if (node.version > 0 && !consumerPollProducersForChange(node)) {\n return;\n }\n node.version++;\n\n const prevConsumer = consumerBeforeComputation(node);\n try {\n node.cleanupFn();\n node.cleanupFn = NOOP_CLEANUP_FN;\n node.fn(registerOnCleanup);\n } finally {\n consumerAfterComputation(node, prevConsumer);\n }\n };\n\n node.ref = {\n notify: () => consumerMarkDirty(node),\n run,\n cleanup: () => node.cleanupFn(),\n destroy: () => destroyWatchNode(node),\n [SIGNAL]: node,\n };\n\n return node.ref;\n}\n\nconst NOOP_CLEANUP_FN: WatchCleanupFn = () => {};\n\n// Note: Using an IIFE here to ensure that the spread assignment is not considered\n// a side-effect, ending up preserving `COMPUTED_NODE` and `REACTIVE_NODE`.\n// TODO: remove when https://github.com/evanw/esbuild/issues/3392 is resolved.\nconst WATCH_NODE: Partial<WatchNode> = /* @__PURE__ */ (() => {\n return {\n ...REACTIVE_NODE,\n consumerIsAlwaysLive: true,\n consumerAllowSignalWrites: false,\n consumerMarkedDirty: (node: WatchNode) => {\n if (node.schedule !== null) {\n node.schedule(node.ref);\n }\n },\n cleanupFn: NOOP_CLEANUP_FN,\n };\n})();\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {installDevToolsSignalFormatter} from './src/formatter';\n\nexport {ComputedNode, createComputed} from './src/computed';\nexport {\n ComputationFn,\n LinkedSignalNode,\n LinkedSignalGetter,\n createLinkedSignal,\n linkedSignalSetFn,\n linkedSignalUpdateFn,\n} from './src/linked_signal';\nexport {ValueEqualityFn, defaultEquals} from './src/equality';\nexport {setThrowInvalidWriteToSignalError} from './src/errors';\nexport {\n REACTIVE_NODE,\n Reactive,\n ReactiveHookFn,\n ReactiveNode,\n ReactiveNodeKind,\n SIGNAL,\n consumerAfterComputation,\n consumerBeforeComputation,\n consumerDestroy,\n consumerMarkDirty,\n consumerPollProducersForChange,\n finalizeConsumerAfterComputation,\n getActiveConsumer,\n isInNotificationPhase,\n isReactive,\n producerAccessed,\n producerIncrementEpoch,\n producerMarkClean,\n producerNotifyConsumers,\n producerUpdateValueVersion,\n producerUpdatesAllowed,\n resetConsumerBeforeComputation,\n runPostProducerCreatedFn,\n setActiveConsumer,\n setPostProducerCreatedFn,\n} from './src/graph';\nexport {\n SIGNAL_NODE,\n SignalGetter,\n SignalNode,\n createSignal,\n runPostSignalSetFn,\n setPostSignalSetFn,\n signalGetFn,\n signalSetFn,\n signalUpdateFn,\n} from './src/signal';\nexport {Watch, WatchCleanupFn, WatchCleanupRegisterFn, createWatch} from './src/watch';\nexport {setAlternateWeakRefImpl} from './src/weak_ref';\nexport {untracked} from './src/untracked';\nexport {runEffect, BASE_EFFECT_NODE, BaseEffectNode} from './src/effect';\nexport {installDevToolsSignalFormatter} from './src/formatter';\n\n// Required as the signals library is in a separate package, so we need to explicitly ensure the\n// global `ngDevMode` type is defined.\ndeclare const ngDevMode: boolean | undefined;\n\n// We're using a top-level access to enable signal formatting whenever the signals package is loaded.\nif (typeof ngDevMode !== 'undefined' && ngDevMode) {\n // tslint:disable-next-line: no-toplevel-property-access\n installDevToolsSignalFormatter();\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAgCA;;;;AAIG;AAEH,MAAM,SAAS,GAAG;AAChB;;AAEG;AACH,IAAA,MAAM,EAAE,CAAC,GAAQ,EAAE,MAAuB,KAAmB;QAC3D,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,MAAM,EAAE,gBAAgB;AAAE,YAAA,OAAO,IAAI;AAE3D,QAAA,IAAI,KAAc;AAClB,QAAA,IAAI;YACF,KAAK,GAAG,GAAG,EAAE;;AACb,QAAA,MAAM;;AAEN,YAAA,OAAO,CAAC,MAAM,EAAE,kBAAkB,CAAC;;AAGrC,QAAA,MAAM,IAAI,GAAG,aAAa,IAAK,GAAG,CAAC,MAAM,CAAS,GAAG,UAAU,GAAG,QAAQ;QAE1E,MAAM,WAAW,GAAG,KAAK,KAAK,IAAI,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC;QAE1F,OAAO;YACL,MAAM;YACN,EAAE;AACF,YAAA,CAAC,MAAM,EAAE,EAAE,EAAE,CAAG,EAAA,IAAI,GAAG,CAAC;AACxB,YAAA,CAAC,MAAK;AACJ,gBAAA,IAAI,QAAQ,CAAC,KAAK,CAAC,EAAE;;;oBAGnB,OAAO,SAAS,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAE;;qBAClC,IAAI,WAAW,IAAI,KAAK,KAAK,SAAS,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE;;;;oBAI5E,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MAAM,YAAY,GAAG,yBAAyB,CAAC,IAAI,CAAC;AACpD,QAAA,IAAI;YACF,IAAI,CAAC,SAAS,EAAE;AAChB,YAAA,IAAI,CAAC,SAAS,GAAG,eAAe;AAChC,YAAA,IAAI,CAAC,EAAE,CAAC,iBAAiB,CAAC;;gBAClB;AACR,YAAA,wBAAwB,CAAC,IAAI,EAAE,YAAY,CAAC;;AAEhD,KAAC;IAED,IAAI,CAAC,GAAG,GAAG;AACT,QAAA,MAAM,EAAE,MAAM,iBAAiB,CAAC,IAAI,CAAC;QACrC,GAAG;AACH,QAAA,OAAO,EAAE,MAAM,IAAI,CAAC,SAAS,EAAE;AAC/B,QAAA,OAAO,EAAE,MAAM,gBAAgB,CAAC,IAAI,CAAC;QACrC,CAAC,MAAM,GAAG,IAAI;KACf;IAED,OAAO,IAAI,CAAC,GAAG;AACjB;AAEA,MAAM,eAAe,GAAmB,MAAK,GAAG;AAEhD;AACA;AACA;AACA,MAAM,UAAU,mBAAuC,CAAC,MAAK;IAC3D,OAAO;AACL,QAAA,GAAG,aAAa;AAChB,QAAA,oBAAoB,EAAE,IAAI;AAC1B,QAAA,yBAAyB,EAAE,KAAK;AAChC,QAAA,mBAAmB,EAAE,CAAC,IAAe,KAAI;AACvC,YAAA,IAAI,IAAI,CAAC,QAAQ,KAAK,IAAI,EAAE;AAC1B,gBAAA,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC;;SAE1B;AACD,QAAA,SAAS,EAAE,eAAe;KAC3B;AACH,CAAC,GAAG;;ACtFJ;AACA,IAAI,OAAO,SAAS,KAAK,WAAW,IAAI,SAAS,EAAE;;AAEjD,IAAA,8BAA8B,EAAE;AAClC;;;;"}
|
|
1
|
+
{"version":3,"file":"primitives-signals.mjs","sources":["../../../../../darwin_arm64-fastbuild-ST-199a4f3c4e20/bin/packages/core/primitives/signals/src/formatter.ts","../../../../../darwin_arm64-fastbuild-ST-199a4f3c4e20/bin/packages/core/primitives/signals/src/watch.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nimport {SIGNAL} from './graph';\n\n// Only a subset of HTML tags are allowed in the custom formatter JsonML format.\n// See https://firefox-source-docs.mozilla.org/devtools-user/custom_formatters/index.html#html-template-format\ntype AllowedTags = 'span' | 'div' | 'ol' | 'ul' | 'li' | 'table' | 'tr' | 'td';\n\ntype JsonMLText = string;\ntype JsonMLAttrs = Record<string, string>;\ntype JsonMLElement =\n | [tagName: AllowedTags, ...children: (JsonMLNode | JsonMLChild)[]]\n | [tagName: AllowedTags, attrs: JsonMLAttrs, ...children: (JsonMLNode | JsonMLChild)[]];\ntype JsonMLNode = JsonMLText | JsonMLElement;\ntype JsonMLChild = ['object', {object: unknown; config?: unknown}];\ntype JsonML = JsonMLNode;\n\ntype FormatterConfig = unknown & {ngSkipFormatting?: boolean};\n\ndeclare global {\n // We need to use `var` here to be able to declare a global variable.\n // `let` and `const` will be locally scoped to the file.\n // tslint:disable-next-line:no-unused-variable\n var devtoolsFormatters: any[];\n}\n\n/**\n * A custom formatter which renders signals in an easy-to-read format.\n *\n * @see https://firefox-source-docs.mozilla.org/devtools-user/custom_formatters/index.html\n */\n\nconst formatter = {\n /**\n * If the function returns `null`, the formatter is not used for this reference\n */\n header: (sig: any, config: FormatterConfig): JsonML | null => {\n if (!isSignal(sig) || config?.ngSkipFormatting) return null;\n\n let value: unknown;\n try {\n value = sig();\n } catch {\n // In case the signl throws, we don't want to break the formatting.\n return ['span', 'Signal(⚠️ Error)'];\n }\n\n const kind = 'computation' in (sig[SIGNAL] as any) ? 'Computed' : 'Signal';\n\n const isPrimitive = value === null || (!Array.isArray(value) && typeof value !== 'object');\n\n return [\n 'span',\n {},\n ['span', {}, `${kind}(`],\n (() => {\n if (isSignal(value)) {\n // Recursively call formatter. Could return an `object` to call the formatter through DevTools,\n // but then recursive signals will render multiple expando arrows which is an awkward UX.\n return formatter.header(value, config)!;\n } else if (isPrimitive && value !== undefined && typeof value !== 'function') {\n // Use built-in rendering for primitives which applies standard syntax highlighting / theming.\n // Can't do this for `undefined` however, as the browser thinks we forgot to provide an object.\n // Also don't want to do this for functions which render nested expando arrows.\n return ['object', {object: value}];\n } else {\n return prettifyPreview(value as Record<string | number | symbol, unknown>);\n }\n })(),\n ['span', {}, `)`],\n ];\n },\n\n hasBody: (sig: any, config: FormatterConfig) => {\n if (!isSignal(sig)) return false;\n\n try {\n sig();\n } catch {\n return false;\n }\n return !config?.ngSkipFormatting;\n },\n\n body: (sig: any, config: any): JsonML => {\n // We can use sys colors to fit the current DevTools theme.\n // Those are unfortunately only available on Chromium-based browsers.\n // On Firefow we fall back to the default color\n const color = 'var(--sys-color-primary)';\n\n return [\n 'div',\n {style: `background: #FFFFFF10; padding-left: 4px; padding-top: 2px; padding-bottom: 2px;`},\n ['div', {style: `color: ${color}`}, 'Signal value: '],\n ['div', {style: `padding-left: .5rem;`}, ['object', {object: sig(), config}]],\n ['div', {style: `color: ${color}`}, 'Signal function: '],\n [\n 'div',\n {style: `padding-left: .5rem;`},\n ['object', {object: sig, config: {...config, skipFormatting: true}}],\n ],\n ];\n },\n};\n\nfunction prettifyPreview(\n value: Record<string | number | symbol, unknown> | Array<unknown> | undefined,\n): string | JsonMLChild {\n if (value === null) return 'null';\n if (Array.isArray(value)) return `Array(${value.length})`;\n if (value instanceof Element) return `<${value.tagName.toLowerCase()}>`;\n if (value instanceof URL) return `URL`;\n\n switch (typeof value) {\n case 'undefined': {\n return 'undefined';\n }\n case 'function': {\n if ('prototype' in value) {\n // This is what Chrome renders, can't use `object` though because it creates a nested expando arrow.\n return 'class';\n } else {\n return '() => {…}';\n }\n }\n case 'object': {\n if (value.constructor.name === 'Object') {\n return '{…}';\n } else {\n return `${value.constructor.name} {}`;\n }\n }\n default: {\n return ['object', {object: value, config: {skipFormatting: true}}];\n }\n }\n}\n\nfunction isSignal(value: any): boolean {\n return value[SIGNAL] !== undefined;\n}\n\n/**\n * Installs the custom formatter into custom formatting on Signals in the devtools.\n *\n * Supported by both Chrome and Firefox.\n *\n * @see https://firefox-source-docs.mozilla.org/devtools-user/custom_formatters/index.html\n */\nexport function installDevToolsSignalFormatter() {\n globalThis.devtoolsFormatters ??= [];\n if (!globalThis.devtoolsFormatters.some((f: any) => f === formatter)) {\n globalThis.devtoolsFormatters.push(formatter);\n }\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {\n consumerAfterComputation,\n consumerBeforeComputation,\n consumerDestroy,\n consumerMarkDirty,\n consumerPollProducersForChange,\n isInNotificationPhase,\n REACTIVE_NODE,\n ReactiveNode,\n SIGNAL,\n} from './graph';\n\n// Required as the signals library is in a separate package, so we need to explicitly ensure the\n// global `ngDevMode` type is defined.\ndeclare const ngDevMode: boolean | undefined;\n\n/**\n * A cleanup function that can be optionally registered from the watch logic. If registered, the\n * cleanup logic runs before the next watch execution.\n */\nexport type WatchCleanupFn = () => void;\n\n/**\n * A callback passed to the watch function that makes it possible to register cleanup logic.\n */\nexport type WatchCleanupRegisterFn = (cleanupFn: WatchCleanupFn) => void;\n\nexport interface Watch {\n notify(): void;\n\n /**\n * Execute the reactive expression in the context of this `Watch` consumer.\n *\n * Should be called by the user scheduling algorithm when the provided\n * `schedule` hook is called by `Watch`.\n */\n run(): void;\n\n cleanup(): void;\n\n /**\n * Destroy the watcher:\n * - disconnect it from the reactive graph;\n * - mark it as destroyed so subsequent run and notify operations are noop.\n */\n destroy(): void;\n\n [SIGNAL]: WatchNode;\n}\nexport interface WatchNode extends ReactiveNode {\n fn: ((onCleanup: WatchCleanupRegisterFn) => void) | null;\n schedule: ((watch: Watch) => void) | null;\n cleanupFn: WatchCleanupFn;\n ref: Watch;\n}\n\nexport function createWatch(\n fn: (onCleanup: WatchCleanupRegisterFn) => void,\n schedule: (watch: Watch) => void,\n allowSignalWrites: boolean,\n): Watch {\n const node: WatchNode = Object.create(WATCH_NODE);\n if (allowSignalWrites) {\n node.consumerAllowSignalWrites = true;\n }\n\n node.fn = fn;\n node.schedule = schedule;\n\n const registerOnCleanup = (cleanupFn: WatchCleanupFn) => {\n node.cleanupFn = cleanupFn;\n };\n\n function isWatchNodeDestroyed(node: WatchNode) {\n return node.fn === null && node.schedule === null;\n }\n\n function destroyWatchNode(node: WatchNode) {\n if (!isWatchNodeDestroyed(node)) {\n consumerDestroy(node); // disconnect watcher from the reactive graph\n node.cleanupFn();\n\n // nullify references to the integration functions to mark node as destroyed\n node.fn = null;\n node.schedule = null;\n node.cleanupFn = NOOP_CLEANUP_FN;\n }\n }\n\n const run = () => {\n if (node.fn === null) {\n // trying to run a destroyed watch is noop\n return;\n }\n\n if (isInNotificationPhase()) {\n throw new Error(\n typeof ngDevMode !== 'undefined' && ngDevMode\n ? 'Schedulers cannot synchronously execute watches while scheduling.'\n : '',\n );\n }\n\n node.dirty = false;\n if (node.version > 0 && !consumerPollProducersForChange(node)) {\n return;\n }\n node.version++;\n\n const prevConsumer = consumerBeforeComputation(node);\n try {\n node.cleanupFn();\n node.cleanupFn = NOOP_CLEANUP_FN;\n node.fn(registerOnCleanup);\n } finally {\n consumerAfterComputation(node, prevConsumer);\n }\n };\n\n node.ref = {\n notify: () => consumerMarkDirty(node),\n run,\n cleanup: () => node.cleanupFn(),\n destroy: () => destroyWatchNode(node),\n [SIGNAL]: node,\n };\n\n return node.ref;\n}\n\nconst NOOP_CLEANUP_FN: WatchCleanupFn = () => {};\n\n// Note: Using an IIFE here to ensure that the spread assignment is not considered\n// a side-effect, ending up preserving `COMPUTED_NODE` and `REACTIVE_NODE`.\n// TODO: remove when https://github.com/evanw/esbuild/issues/3392 is resolved.\nconst WATCH_NODE: Partial<WatchNode> = /* @__PURE__ */ (() => {\n return {\n ...REACTIVE_NODE,\n consumerIsAlwaysLive: true,\n consumerAllowSignalWrites: false,\n consumerMarkedDirty: (node: WatchNode) => {\n if (node.schedule !== null) {\n node.schedule(node.ref);\n }\n },\n cleanupFn: NOOP_CLEANUP_FN,\n };\n})();\n"],"names":["formatter","kind","sig","SIGNAL","isPrimitive","value","Array","isArray","isSignal","header","config","undefined","ngSkipFormatting","style","object","skipFormatting","prettifyPreview","length","URL","constructor","name","node","fn","schedule","registerOnCleanup","cleanupFn","isWatchNodeDestroyed"],"mappings":";;;;;;;;;;;MAsCAA,SAAA,GAAA;;;;;;MAoCM,MAAA;AACiB,MAAA,OAAA,CAAA,MAAA,EAAA,kBAAA,CAAA;AAErB;AAEA,IAAA,MAAAC,IAAA,GAAA,aAAA,IAAAC,GAAA,CAAAC,MAAA,CAAA,GAAA,UAAA,GAAA,QAAA;UACEC,WAAK,GAAAC,KAAA,KAAAC,IAAAA,IAAAA,CAAAA,KAAA,CAAAC,OAAA,CAAAF,KAAA,CAAA,IAAA,OAAAA,KAAA,KAAA,QAAA;IAAe,OAAA,CAAA,MAAA,EAEpB,EAAA,EACE,OAAA,EAAA,EAAA,EAAA,CAAA,EAAKJ,IAAA;MAEL,IAAAO,QAAA,CAAAH,KAAY,CAAA,EAAA;AAM6C,QAAA,OAAAL,SAAA,CAAAS,MAAA,CAAAJ,KAAA,EAAAK,MAAA,CAAA;AAC3D,OAAA,MAC+C,IAAAN,WAAA,IAAAC,KAAA,KAAAM,SAAA,WAAAN,KAAA,KAAA,UAAA,EAAA;;;;;8BAOP,CAAAA,KAAA,CAAA;;;;AAKpC,EAAA,OAAA,EAAA,CAAA,GAAA,EAAA,MAAA,KAAA;iBACD,CAAAH,GAAA,UACF,KAAA;AACF,IAAA,IAAA;MACFA,GAAA,EAAA;KAEQ;MAIE,OAAS,KAAA;AAAQ;WAAgB,CAAAQ,MAAM,EAAME;;AAElD,EAAA,IAAA,EAAA,CAAA,GAAA,EAAAF,MAAA,KAAA;;AAIA,IAAA,OAAA,MAGA,EAAA;MAAeG,KAAA,EAAA,CAAA,gFAAA;;;wBACuF,EACpG,CAAA,KAA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