@eui/core 22.0.0-alpha.66 → 22.0.0-alpha.68
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/CHANGELOG.md +72 -0
- package/docs/changelog.html +40 -0
- package/docs/interceptors/{UxRequestErrorModelInterceptor.html → RequestErrorInterceptor.html} +3 -3
- package/docs/interfaces/Annotation.html +402 -0
- package/docs/interfaces/MigrateResult.html +39 -0
- package/docs/interfaces/RemovedAttr.html +0 -13
- package/docs/interfaces/RemovedIdentifier.html +0 -7
- package/docs/interfaces/RemovedTag.html +0 -7
- package/docs/interfaces/Schema-13.html +22 -15
- package/docs/js/menu-wc.js +4 -1
- package/docs/js/search/search_index.js +2 -2
- package/docs/json/documentation.json +1729 -1299
- package/docs/llms.txt +39 -21
- package/docs/miscellaneous/functions.html +3344 -3039
- package/docs/miscellaneous/variables.html +100 -36
- package/docs/overview.html +1 -1
- package/docs/properties.html +1 -1
- package/fesm2022/eui-core.mjs +9 -9
- package/fesm2022/eui-core.mjs.map +1 -1
- package/migrations.json +1 -1
- package/package.json +2 -2
- package/schematics/collection.json +1 -1
- package/schematics/migrate-ecl-removed-components/index.d.ts +20 -15
- package/schematics/migrate-ecl-removed-components/index.js +99 -43
- package/schematics/migrate-ecl-removed-components/index.js.map +1 -1
- package/schematics/migrate-to-signals/index.js +125 -6
- package/schematics/migrate-to-signals/index.js.map +1 -1
- package/types/eui-core.d.ts +3 -3
- package/types/eui-core.d.ts.map +1 -1
package/migrations.json
CHANGED
|
@@ -153,7 +153,7 @@
|
|
|
153
153
|
},
|
|
154
154
|
"migrate-ecl-removed-components": {
|
|
155
155
|
"version": "22.0.0",
|
|
156
|
-
"description": "
|
|
156
|
+
"description": "Flags removed ECL members that need manual migration (EclDatePickerDirective, EclSiteHeaderBannerTopComponent, EclPageHeaderNextComponent, EclRadioHelpComponent): warns and inserts TODO comments next to each usage. Makes no other code changes.",
|
|
157
157
|
"factory": "./migrate-ecl-removed-components/index#migrateEclRemovedComponents",
|
|
158
158
|
"schema": "./migrate-ecl-removed-components/schema.json"
|
|
159
159
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eui/core",
|
|
3
|
-
"version": "22.0.0-alpha.
|
|
3
|
+
"version": "22.0.0-alpha.68",
|
|
4
4
|
"tag": "next",
|
|
5
5
|
"description": "eUI core package - holding UI components for Desktop applications",
|
|
6
6
|
"homepage": "https://eui.ecdevops.eu",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"url": "https://sdlc.webcloud.ec.europa.eu/csdr/eui/eui.git"
|
|
11
11
|
},
|
|
12
12
|
"peerDependencies": {
|
|
13
|
-
"@eui/base": "22.0.0-alpha.
|
|
13
|
+
"@eui/base": "22.0.0-alpha.68",
|
|
14
14
|
"rxjs": "^7.8.0",
|
|
15
15
|
"extend": "^3.0.2",
|
|
16
16
|
"localforage": "^1.10.0",
|
|
@@ -176,7 +176,7 @@
|
|
|
176
176
|
"schema": "./migrate-ecl-quiz/schema.json"
|
|
177
177
|
},
|
|
178
178
|
"migrate-ecl-removed-components": {
|
|
179
|
-
"description": "
|
|
179
|
+
"description": "Flags removed ECL members that need manual migration (EclDatePickerDirective, EclSiteHeaderBannerTopComponent, EclPageHeaderNextComponent, EclRadioHelpComponent): warns and inserts TODO comments next to each usage. Makes no other code changes.",
|
|
180
180
|
"factory": "./migrate-ecl-removed-components/index#migrateEclRemovedComponents",
|
|
181
181
|
"schema": "./migrate-ecl-removed-components/schema.json"
|
|
182
182
|
},
|
|
@@ -1,23 +1,28 @@
|
|
|
1
1
|
import { Rule } from '@angular-devkit/schematics';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
3
|
+
* Flags usages of ECL members removed in v22 that have no automatic drop-in
|
|
4
|
+
* replacement.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
6
|
+
* For each usage it:
|
|
7
|
+
* 1. Logs a precise manual-action warning.
|
|
8
|
+
* 2. Inserts a `TODO: [eUI v22 migration] ...` comment on the line above the
|
|
9
|
+
* usage so it is easy to locate in the editor.
|
|
9
10
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* - `EclPageHeaderNextComponent`: removed, no longer exported.
|
|
17
|
-
* - `EclRadioHelpComponent` (`[eclRadioHelp]`): removed. Use `[eclHelpBlock]`
|
|
18
|
-
* (`EclHelpBlockDirective` from `@eui/ecl/components/ecl-help-block`).
|
|
11
|
+
* It makes **no other edits** — it never comments out, deletes, or rewrites the
|
|
12
|
+
* user's code. These removed members require a developer decision (they are
|
|
13
|
+
* components/directives with different APIs, or have no replacement), so the
|
|
14
|
+
* schematic only points at what needs attention and leaves the change to the
|
|
15
|
+
* developer. Searching a project for `TODO: [eUI v22 migration]` after the run
|
|
16
|
+
* surfaces every spot to migrate.
|
|
19
17
|
*
|
|
20
|
-
*
|
|
18
|
+
* Removed members handled:
|
|
19
|
+
* - `EclDatePickerDirective` (`input[eclDatePicker]`) → `EclDatePickerDuetDirective`
|
|
20
|
+
* on `<duet-date-picker eclDatePicker>`.
|
|
21
|
+
* - `EUI_ECL_DATE_PICKER` — still exported (now provides the Duet directive);
|
|
22
|
+
* only the markup needs updating.
|
|
23
|
+
* - `EclSiteHeaderBannerTopComponent` (`ecl-site-header-banner-top`) → removed, no replacement.
|
|
24
|
+
* - `EclPageHeaderNextComponent` → removed, no longer exported.
|
|
25
|
+
* - `EclRadioHelpComponent` (`[eclRadioHelp]`) → `[eclHelpBlock]` (`EclHelpBlockDirective`).
|
|
21
26
|
*/
|
|
22
27
|
interface Schema {
|
|
23
28
|
path?: string;
|
|
@@ -37,21 +37,22 @@ exports.migrateEclRemovedComponents = migrateEclRemovedComponents;
|
|
|
37
37
|
const compiler_1 = require("@angular/compiler");
|
|
38
38
|
const ts = __importStar(require("typescript"));
|
|
39
39
|
const dry_run_1 = require("../utils/dry-run");
|
|
40
|
+
const TODO_PREFIX = 'TODO: [eUI v22 migration]';
|
|
40
41
|
const REMOVED_TAGS = [
|
|
41
42
|
{
|
|
42
43
|
tag: 'ecl-site-header-banner-top',
|
|
43
|
-
message: '<ecl-site-header-banner-top>
|
|
44
|
+
message: 'EclSiteHeaderBannerTopComponent (<ecl-site-header-banner-top>) was removed in v22 with no replacement. Remove it and use the standard site-header variant without a banner-top.',
|
|
44
45
|
},
|
|
45
46
|
];
|
|
46
47
|
const REMOVED_ATTRS = [
|
|
47
48
|
{
|
|
48
49
|
attr: 'eclDatePicker',
|
|
49
50
|
onTag: 'input',
|
|
50
|
-
message: '
|
|
51
|
+
message: 'EclDatePickerDirective (input[eclDatePicker]) was removed in v22. Use EclDatePickerDuetDirective on a <duet-date-picker eclDatePicker> element; yearRange/format/firstDayOfWeek are configured on the <duet-date-picker> web component.',
|
|
51
52
|
},
|
|
52
53
|
{
|
|
53
54
|
attr: 'eclRadioHelp',
|
|
54
|
-
message: '
|
|
55
|
+
message: 'EclRadioHelpComponent ([eclRadioHelp]) was removed in v22. Use [eclHelpBlock] (EclHelpBlockDirective from @eui/ecl/components/ecl-help-block) instead.',
|
|
55
56
|
},
|
|
56
57
|
];
|
|
57
58
|
const REMOVED_IDENTIFIERS = [
|
|
@@ -61,7 +62,7 @@ const REMOVED_IDENTIFIERS = [
|
|
|
61
62
|
},
|
|
62
63
|
{
|
|
63
64
|
name: 'EUI_ECL_DATE_PICKER',
|
|
64
|
-
message: 'EUI_ECL_DATE_PICKER no longer includes the removed EclDatePickerDirective
|
|
65
|
+
message: 'EUI_ECL_DATE_PICKER no longer includes the removed EclDatePickerDirective (it now provides EclDatePickerDuetDirective). The import still works; update your markup from <input eclDatePicker> to <duet-date-picker eclDatePicker>.',
|
|
65
66
|
},
|
|
66
67
|
{
|
|
67
68
|
name: 'EclSiteHeaderBannerTopComponent',
|
|
@@ -86,6 +87,7 @@ function migrateEclRemovedComponents(options = {}) {
|
|
|
86
87
|
return (tree, context) => {
|
|
87
88
|
const scanPath = options.path ? '/' + options.path.replace(/^\.?\//, '').replace(/\/$/, '') : '';
|
|
88
89
|
let warningCount = 0;
|
|
90
|
+
let fileCount = 0;
|
|
89
91
|
visitDir(tree.getDir(scanPath || '/'), (path) => {
|
|
90
92
|
const buffer = tree.read(path);
|
|
91
93
|
if (!buffer)
|
|
@@ -93,18 +95,31 @@ function migrateEclRemovedComponents(options = {}) {
|
|
|
93
95
|
const source = buffer.toString('utf-8');
|
|
94
96
|
if (!TRIGGER_TOKENS.some((t) => source.includes(t)))
|
|
95
97
|
return;
|
|
96
|
-
|
|
97
|
-
|
|
98
|
+
const annotations = path.endsWith('.html')
|
|
99
|
+
? collectTemplateAnnotations(source, 0, 'html')
|
|
100
|
+
: collectTypeScriptAnnotations(source, path);
|
|
101
|
+
if (annotations.length === 0)
|
|
102
|
+
return;
|
|
103
|
+
for (const a of annotations) {
|
|
104
|
+
context.logger.warn(`${path}:${a.line + 1} - ${a.message}`);
|
|
105
|
+
warningCount++;
|
|
98
106
|
}
|
|
99
|
-
|
|
100
|
-
|
|
107
|
+
const result = applyAnnotations(source, annotations);
|
|
108
|
+
if (result !== source) {
|
|
109
|
+
if (options.dryRun) {
|
|
110
|
+
(0, dry_run_1.logDryRun)(context, `Would annotate removed ECL usage(s) with TODO comments in ${path}`);
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
tree.overwrite(path, result);
|
|
114
|
+
}
|
|
115
|
+
fileCount++;
|
|
101
116
|
}
|
|
102
117
|
});
|
|
103
118
|
if (warningCount === 0) {
|
|
104
119
|
context.logger.info('No usages of removed ECL components found.');
|
|
105
120
|
}
|
|
106
121
|
else {
|
|
107
|
-
context.logger.info(`Found ${warningCount} usage(s) of removed ECL components.
|
|
122
|
+
context.logger.info(`Found ${warningCount} usage(s) of removed ECL components in ${fileCount} file(s). Search for "${TODO_PREFIX}" and migrate them manually.`);
|
|
108
123
|
}
|
|
109
124
|
if (options.dryRun) {
|
|
110
125
|
(0, dry_run_1.logDryRunNote)(context);
|
|
@@ -112,38 +127,34 @@ function migrateEclRemovedComponents(options = {}) {
|
|
|
112
127
|
return tree;
|
|
113
128
|
};
|
|
114
129
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
*/
|
|
120
|
-
function scanTemplate(template, _fileSource, lineOffset, path, context) {
|
|
130
|
+
// ---------------------------------------------------------------------------
|
|
131
|
+
// Templates
|
|
132
|
+
// ---------------------------------------------------------------------------
|
|
133
|
+
function collectTemplateAnnotations(template, lineOffset, commentStyle) {
|
|
121
134
|
let parsed;
|
|
122
135
|
try {
|
|
123
136
|
parsed = (0, compiler_1.parseTemplate)(template, '', { preserveWhitespaces: true });
|
|
124
137
|
}
|
|
125
138
|
catch {
|
|
126
|
-
return
|
|
139
|
+
return [];
|
|
127
140
|
}
|
|
128
|
-
|
|
141
|
+
const annotations = [];
|
|
129
142
|
const visit = (nodes) => {
|
|
130
143
|
for (const node of nodes) {
|
|
131
144
|
if (node instanceof compiler_1.TmplAstElement) {
|
|
132
|
-
|
|
145
|
+
collectElementAnnotation(node, lineOffset, commentStyle, annotations);
|
|
133
146
|
visit(node.children);
|
|
134
147
|
}
|
|
135
148
|
}
|
|
136
149
|
};
|
|
137
150
|
visit(parsed.nodes);
|
|
138
|
-
return
|
|
151
|
+
return annotations;
|
|
139
152
|
}
|
|
140
|
-
function
|
|
141
|
-
|
|
142
|
-
const line = element.startSourceSpan.start.line + 1 + lineOffset;
|
|
153
|
+
function collectElementAnnotation(element, lineOffset, commentStyle, annotations) {
|
|
154
|
+
const line = element.startSourceSpan.start.line + lineOffset;
|
|
143
155
|
const removedTag = REMOVED_TAGS.find((t) => t.tag === element.name);
|
|
144
156
|
if (removedTag) {
|
|
145
|
-
|
|
146
|
-
count++;
|
|
157
|
+
annotations.push({ line, commentStyle, message: removedTag.message });
|
|
147
158
|
}
|
|
148
159
|
for (const removed of REMOVED_ATTRS) {
|
|
149
160
|
const hasAttr = element.attributes.some((a) => a.name === removed.attr) || element.inputs.some((i) => i.name === removed.attr);
|
|
@@ -151,23 +162,28 @@ function checkElement(element, lineOffset, path, context) {
|
|
|
151
162
|
continue;
|
|
152
163
|
if (removed.onTag && element.name !== removed.onTag)
|
|
153
164
|
continue;
|
|
154
|
-
|
|
155
|
-
count++;
|
|
165
|
+
annotations.push({ line, commentStyle, message: removed.message });
|
|
156
166
|
}
|
|
157
|
-
return count;
|
|
158
167
|
}
|
|
159
|
-
|
|
168
|
+
// ---------------------------------------------------------------------------
|
|
169
|
+
// TypeScript
|
|
170
|
+
// ---------------------------------------------------------------------------
|
|
171
|
+
function collectTypeScriptAnnotations(source, path) {
|
|
160
172
|
const sourceFile = ts.createSourceFile(path, source, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);
|
|
161
|
-
|
|
162
|
-
// 1. Inline templates —
|
|
173
|
+
const annotations = [];
|
|
174
|
+
// 1. Inline templates — annotate with a `//` comment on the line of the
|
|
175
|
+
// `template` property (inserting an HTML comment inside the template
|
|
176
|
+
// literal is fragile across single/multi-line forms, so we place a TS
|
|
177
|
+
// comment above the property instead).
|
|
163
178
|
const visitForTemplates = (node) => {
|
|
164
179
|
if (ts.isPropertyAssignment(node) && isTemplateProperty(node) && isComponentMetadataProperty(node)) {
|
|
165
180
|
const init = unwrapExpression(node.initializer);
|
|
166
181
|
if (ts.isStringLiteral(init) || ts.isNoSubstitutionTemplateLiteral(init)) {
|
|
167
|
-
const raw = init.getText(sourceFile).slice(1, -1);
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
182
|
+
const raw = init.getText(sourceFile).slice(1, -1);
|
|
183
|
+
const inlineMessages = collectTemplateAnnotations(raw, 0, 'html').map((a) => a.message);
|
|
184
|
+
if (inlineMessages.length > 0) {
|
|
185
|
+
const { line } = sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile));
|
|
186
|
+
annotations.push({ line, commentStyle: 'ts', message: [...new Set(inlineMessages)].join(' ') });
|
|
171
187
|
}
|
|
172
188
|
}
|
|
173
189
|
}
|
|
@@ -175,26 +191,66 @@ function scanTypeScript(source, path, context) {
|
|
|
175
191
|
};
|
|
176
192
|
visitForTemplates(sourceFile);
|
|
177
193
|
// 2. Identifier usages (imports, type references, array entries, etc.).
|
|
178
|
-
|
|
194
|
+
// One annotation per affected line; merge messages for multiple symbols.
|
|
195
|
+
const perLine = new Map();
|
|
179
196
|
const visitForIdentifiers = (node) => {
|
|
180
197
|
if (ts.isIdentifier(node)) {
|
|
181
198
|
const removed = REMOVED_IDENTIFIERS.find((r) => r.name === node.text);
|
|
182
199
|
if (removed) {
|
|
183
200
|
const { line } = sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile));
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
reportedLines.add(key);
|
|
188
|
-
context.logger.warn(`${path}:${line + 1} - ${removed.message}`);
|
|
189
|
-
count++;
|
|
190
|
-
}
|
|
201
|
+
const set = perLine.get(line) ?? new Set();
|
|
202
|
+
set.add(removed.message);
|
|
203
|
+
perLine.set(line, set);
|
|
191
204
|
}
|
|
192
205
|
}
|
|
193
206
|
ts.forEachChild(node, visitForIdentifiers);
|
|
194
207
|
};
|
|
195
208
|
visitForIdentifiers(sourceFile);
|
|
196
|
-
|
|
209
|
+
for (const [line, messages] of perLine) {
|
|
210
|
+
annotations.push({ line, commentStyle: 'ts', message: [...messages].join(' ') });
|
|
211
|
+
}
|
|
212
|
+
return annotations;
|
|
213
|
+
}
|
|
214
|
+
// ---------------------------------------------------------------------------
|
|
215
|
+
// Annotation application
|
|
216
|
+
// ---------------------------------------------------------------------------
|
|
217
|
+
function applyAnnotations(source, annotations) {
|
|
218
|
+
if (annotations.length === 0)
|
|
219
|
+
return source;
|
|
220
|
+
const eol = source.includes('\r\n') ? '\r\n' : '\n';
|
|
221
|
+
const lines = source.split(/\r?\n/);
|
|
222
|
+
// One annotation per line (merge messages if several target the same line).
|
|
223
|
+
const byLine = new Map();
|
|
224
|
+
for (const a of annotations) {
|
|
225
|
+
const existing = byLine.get(a.line);
|
|
226
|
+
if (!existing) {
|
|
227
|
+
byLine.set(a.line, { ...a });
|
|
228
|
+
}
|
|
229
|
+
else if (!existing.message.includes(a.message)) {
|
|
230
|
+
existing.message = `${existing.message} ${a.message}`;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
// Skip lines whose preceding line already carries this TODO (idempotency).
|
|
234
|
+
// Apply bottom-up so inserted lines don't shift later targets.
|
|
235
|
+
const sorted = [...byLine.values()].sort((a, b) => b.line - a.line);
|
|
236
|
+
for (const a of sorted) {
|
|
237
|
+
if (a.line < 0 || a.line >= lines.length)
|
|
238
|
+
continue;
|
|
239
|
+
const indent = (lines[a.line].match(/^(\s*)/)?.[1]) ?? '';
|
|
240
|
+
const todo = a.commentStyle === 'html'
|
|
241
|
+
? `${indent}<!-- ${TODO_PREFIX} ${a.message} -->`
|
|
242
|
+
: `${indent}// ${TODO_PREFIX} ${a.message}`;
|
|
243
|
+
// Idempotency guard: if the line above already is this exact TODO, skip.
|
|
244
|
+
const prev = a.line > 0 ? lines[a.line - 1] : '';
|
|
245
|
+
if (prev.trim() === todo.trim())
|
|
246
|
+
continue;
|
|
247
|
+
lines.splice(a.line, 0, todo);
|
|
248
|
+
}
|
|
249
|
+
return lines.join(eol);
|
|
197
250
|
}
|
|
251
|
+
// ---------------------------------------------------------------------------
|
|
252
|
+
// Shared
|
|
253
|
+
// ---------------------------------------------------------------------------
|
|
198
254
|
function isTemplateProperty(node) {
|
|
199
255
|
const name = node.name;
|
|
200
256
|
return (ts.isIdentifier(name) && name.text === 'template') || (ts.isStringLiteral(name) && name.text === 'template');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../schematics/migrate-ecl-removed-components/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../schematics/migrate-ecl-removed-components/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoHA,kEA+CC;AAnKD,gDAA+E;AAE/E,+CAAiC;AACjC,8CAA4D;AAiC5D,MAAM,WAAW,GAAG,2BAA2B,CAAC;AAkBhD,MAAM,YAAY,GAA0B;IAC1C;QACE,GAAG,EAAE,4BAA4B;QACjC,OAAO,EACL,iLAAiL;KACpL;CACF,CAAC;AAEF,MAAM,aAAa,GAA2B;IAC5C;QACE,IAAI,EAAE,eAAe;QACrB,KAAK,EAAE,OAAO;QACd,OAAO,EACL,yOAAyO;KAC5O;IACD;QACE,IAAI,EAAE,cAAc;QACpB,OAAO,EACL,wJAAwJ;KAC3J;CACF,CAAC;AAEF,MAAM,mBAAmB,GAAiC;IACxD;QACE,IAAI,EAAE,wBAAwB;QAC9B,OAAO,EACL,iIAAiI;KACpI;IACD;QACE,IAAI,EAAE,qBAAqB;QAC3B,OAAO,EACL,oOAAoO;KACvO;IACD;QACE,IAAI,EAAE,iCAAiC;QACvC,OAAO,EAAE,2FAA2F;KACrG;IACD;QACE,IAAI,EAAE,4BAA4B;QAClC,OAAO,EAAE,6GAA6G;KACvH;IACD;QACE,IAAI,EAAE,uBAAuB;QAC7B,OAAO,EACL,uIAAuI;KAC1I;CACF,CAAC;AAEF,qEAAqE;AACrE,MAAM,cAAc,GAAG;IACrB,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;IACjC,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IACnC,GAAG,mBAAmB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;CAC1C,CAAC;AASF,SAAgB,2BAA2B,CAAC,UAA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c,IAAI,GAAG,KAAK,MAAM;YAAE,SAAS;QACvD,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,CAAC;IACnC,CAAC;AACH,CAAC"}
|
|
@@ -70,6 +70,7 @@ function migrateToSignals(options = {}) {
|
|
|
70
70
|
const scanPath = options.path ? '/' + options.path.replace(/^\.?\//, '').replace(/\/$/, '') : '';
|
|
71
71
|
let fileCount = 0;
|
|
72
72
|
let propCount = 0;
|
|
73
|
+
let todoCount = 0;
|
|
73
74
|
visitDir(tree.getDir(scanPath || '/'), (path) => {
|
|
74
75
|
if (!path.endsWith('.ts'))
|
|
75
76
|
return;
|
|
@@ -87,16 +88,25 @@ function migrateToSignals(options = {}) {
|
|
|
87
88
|
const result = migrateTypeScript(original, path, tree, context);
|
|
88
89
|
if (result.source !== original) {
|
|
89
90
|
if (options.dryRun) {
|
|
90
|
-
|
|
91
|
+
if (result.editCount > 0) {
|
|
92
|
+
(0, dry_run_1.logDryRun)(context, `Would migrate ${result.editCount} signal property access(es) in ${path}`);
|
|
93
|
+
}
|
|
94
|
+
if (result.todoCount > 0) {
|
|
95
|
+
(0, dry_run_1.logDryRun)(context, `Would comment out ${result.todoCount} programmatic signal-input write(s) with a TODO in ${path}`);
|
|
96
|
+
}
|
|
91
97
|
}
|
|
92
98
|
else {
|
|
93
99
|
tree.overwrite(path, result.source);
|
|
94
100
|
}
|
|
95
101
|
fileCount++;
|
|
96
102
|
propCount += result.editCount;
|
|
103
|
+
todoCount += result.todoCount;
|
|
97
104
|
}
|
|
98
105
|
});
|
|
99
106
|
context.logger.info(`Migrated ${propCount} property access(es) to signal getters in ${fileCount} file(s).`);
|
|
107
|
+
if (todoCount > 0) {
|
|
108
|
+
context.logger.info(`Commented out ${todoCount} programmatic signal-input write(s) and left a TODO — these cannot be migrated automatically and need a manual fix.`);
|
|
109
|
+
}
|
|
100
110
|
if (options.dryRun) {
|
|
101
111
|
(0, dry_run_1.logDryRunNote)(context);
|
|
102
112
|
}
|
|
@@ -118,12 +128,13 @@ function hasStringRefQuery(source) {
|
|
|
118
128
|
function migrateTypeScript(source, filePath, tree, context) {
|
|
119
129
|
const sourceFile = ts.createSourceFile(filePath, source, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);
|
|
120
130
|
const edits = [];
|
|
131
|
+
const todoEdits = [];
|
|
121
132
|
// Phase 0: Build template ref map (#refName → EUI class name) from the component's template
|
|
122
133
|
const templateRefMap = buildTemplateRefMap(sourceFile, source, filePath, tree);
|
|
123
134
|
// Phase 1: Collect all variables/properties typed as EUI classes
|
|
124
135
|
const euiRefs = collectEuiReferences(sourceFile, source, templateRefMap);
|
|
125
136
|
if (euiRefs.size === 0) {
|
|
126
|
-
return { source, editCount: 0 };
|
|
137
|
+
return { source, editCount: 0, todoCount: 0 };
|
|
127
138
|
}
|
|
128
139
|
// Phase 2: Find property accesses on those references and rewrite signal props
|
|
129
140
|
const visitNode = (node) => {
|
|
@@ -133,16 +144,30 @@ function migrateTypeScript(source, filePath, tree, context) {
|
|
|
133
144
|
if (rewrite) {
|
|
134
145
|
edits.push(rewrite);
|
|
135
146
|
}
|
|
147
|
+
// Separately: a programmatic WRITE to a now-signal input cannot be
|
|
148
|
+
// migrated automatically. Flag it with a TODO instead of silently
|
|
149
|
+
// leaving a line that will fail to compile against the signal API.
|
|
150
|
+
const todo = tryInsertWriteTodo(node, euiRefs, sourceFile, source);
|
|
151
|
+
if (todo) {
|
|
152
|
+
todoEdits.push(todo);
|
|
153
|
+
}
|
|
136
154
|
}
|
|
137
155
|
ts.forEachChild(node, visitNode);
|
|
138
156
|
};
|
|
139
157
|
ts.forEachChild(sourceFile, visitNode);
|
|
140
|
-
if (edits.length === 0) {
|
|
141
|
-
return { source, editCount: 0 };
|
|
158
|
+
if (edits.length === 0 && todoEdits.length === 0) {
|
|
159
|
+
return { source, editCount: 0, todoCount: 0 };
|
|
142
160
|
}
|
|
161
|
+
const dedupedTodos = deduplicateEdits(todoEdits);
|
|
162
|
+
// A TODO edit comments out the whole write statement. Any read-rewrite `()`
|
|
163
|
+
// edit whose position falls inside that commented-out range must be dropped,
|
|
164
|
+
// otherwise we'd both edit and comment the same text (and produce overlapping
|
|
165
|
+
// edits that corrupt the output).
|
|
166
|
+
const keptEdits = edits.filter((edit) => !isInsideAnyRange(edit, dedupedTodos));
|
|
143
167
|
return {
|
|
144
|
-
source: applyEdits(source,
|
|
145
|
-
editCount:
|
|
168
|
+
source: applyEdits(source, [...keptEdits, ...dedupedTodos]),
|
|
169
|
+
editCount: keptEdits.length,
|
|
170
|
+
todoCount: dedupedTodos.length,
|
|
146
171
|
};
|
|
147
172
|
}
|
|
148
173
|
/**
|
|
@@ -322,6 +347,100 @@ function tryRewritePropertyAccess(node, euiRefs, sourceFile, source) {
|
|
|
322
347
|
function isAssignmentOperator(kind) {
|
|
323
348
|
return kind >= ts.SyntaxKind.FirstAssignment && kind <= ts.SyntaxKind.LastAssignment;
|
|
324
349
|
}
|
|
350
|
+
/** Marker used to detect an already-inserted TODO so the schematic stays idempotent. */
|
|
351
|
+
const WRITE_TODO_MARKER = 'TODO(eui-signals):';
|
|
352
|
+
/**
|
|
353
|
+
* Detects a programmatic WRITE to a now-signal input and returns an edit that
|
|
354
|
+
* comments out the offending statement and prepends an explanatory TODO.
|
|
355
|
+
*
|
|
356
|
+
* A signal input (`input()`) exposes a read-only getter — it cannot be assigned
|
|
357
|
+
* from outside the component (`comp.prop = value` no longer compiles, and
|
|
358
|
+
* `comp.prop()` is a getter, not a setter). There is no safe, mechanical
|
|
359
|
+
* rewrite: the correct fix is to drive the value declaratively through a
|
|
360
|
+
* template binding (`[prop]="..."`) or, when a ComponentRef is genuinely
|
|
361
|
+
* available, `componentRef.setInput('prop', value)`. Both require human
|
|
362
|
+
* judgement, so instead of rewriting we comment the statement out (keeping the
|
|
363
|
+
* build green) and leave a TODO pointing at the manual fix.
|
|
364
|
+
*
|
|
365
|
+
* Only acts when the assignment is the ENTIRE statement
|
|
366
|
+
* (`ExpressionStatement` whose expression is exactly this assignment):
|
|
367
|
+
* ref.prop = value (simple assignment)
|
|
368
|
+
* ref.prop += value, etc. (compound assignment)
|
|
369
|
+
* where `ref` is a tracked EUI/ECL reference and `prop` is in its signal set.
|
|
370
|
+
*
|
|
371
|
+
* When the write is only part of a larger statement (e.g. inside an `if`
|
|
372
|
+
* without a block, or nested in another expression), commenting it out would
|
|
373
|
+
* also remove unrelated logic, so we leave it untouched (it will surface as a
|
|
374
|
+
* compile error the developer must resolve by hand).
|
|
375
|
+
*/
|
|
376
|
+
function tryInsertWriteTodo(node, euiRefs, sourceFile, source) {
|
|
377
|
+
const propName = node.name.text;
|
|
378
|
+
const refName = resolveRefName(node.expression);
|
|
379
|
+
if (!refName)
|
|
380
|
+
return null;
|
|
381
|
+
const signalProps = euiRefs.get(refName);
|
|
382
|
+
if (!signalProps || !signalProps.has(propName))
|
|
383
|
+
return null;
|
|
384
|
+
// Only act on assignment targets: `ref.prop = ...` or `ref.prop <op>= ...`
|
|
385
|
+
if (!ts.isBinaryExpression(node.parent) ||
|
|
386
|
+
node.parent.left !== node ||
|
|
387
|
+
!isAssignmentOperator(node.parent.operatorToken.kind)) {
|
|
388
|
+
return null;
|
|
389
|
+
}
|
|
390
|
+
const assignment = node.parent;
|
|
391
|
+
// Only comment out when the assignment IS the whole statement — otherwise we'd
|
|
392
|
+
// delete unrelated logic from a larger statement.
|
|
393
|
+
const statement = node.parent.parent;
|
|
394
|
+
if (!statement || !ts.isExpressionStatement(statement) || statement.expression !== assignment) {
|
|
395
|
+
return null;
|
|
396
|
+
}
|
|
397
|
+
// The statement must stand on its own (a direct child of a block/source), not
|
|
398
|
+
// be the unbraced body of an `if`/`for`/`while` etc. — commenting those out by
|
|
399
|
+
// line would swallow the surrounding `if (...)` and break the code.
|
|
400
|
+
const parent = statement.parent;
|
|
401
|
+
if (!parent ||
|
|
402
|
+
!(ts.isBlock(parent) || ts.isSourceFile(parent) || ts.isModuleBlock(parent) || ts.isCaseClause(parent) || ts.isDefaultClause(parent))) {
|
|
403
|
+
return null;
|
|
404
|
+
}
|
|
405
|
+
const stmtStart = statement.getStart(sourceFile);
|
|
406
|
+
const stmtEnd = statement.getEnd(); // includes the trailing semicolon
|
|
407
|
+
const lineStart = getLineStartPosition(source, stmtStart);
|
|
408
|
+
const indent = source.slice(lineStart, stmtStart);
|
|
409
|
+
// The statement text, as written (may span multiple lines).
|
|
410
|
+
const statementText = source.slice(stmtStart, stmtEnd);
|
|
411
|
+
// Comment out every line of the statement, preserving each line's own
|
|
412
|
+
// indentation (insert `// ` after the leading whitespace). The first line's
|
|
413
|
+
// indentation was stripped by starting the replacement at lineStart, so we
|
|
414
|
+
// re-add it explicitly.
|
|
415
|
+
const commentedStatement = statementText
|
|
416
|
+
.split('\n')
|
|
417
|
+
.map((line, i) => {
|
|
418
|
+
if (i === 0)
|
|
419
|
+
return `${indent}// ${line}`;
|
|
420
|
+
const lineIndent = line.slice(0, line.length - line.trimStart().length);
|
|
421
|
+
return `${lineIndent}// ${line.trimStart()}`;
|
|
422
|
+
})
|
|
423
|
+
.join('\n');
|
|
424
|
+
const todo = `${indent}// ${WRITE_TODO_MARKER} '${propName}' is now a signal input and cannot be assigned directly.\n` +
|
|
425
|
+
`${indent}// Set it via a template binding ([${propName}]="...") or componentRef.setInput('${propName}', ...).\n` +
|
|
426
|
+
`${indent}// The original statement is commented out below so the build does not fail:\n`;
|
|
427
|
+
// Replace the statement (from the start of its line, to drop the original
|
|
428
|
+
// indentation we re-add) with the TODO + commented-out statement.
|
|
429
|
+
return {
|
|
430
|
+
start: lineStart,
|
|
431
|
+
end: stmtEnd,
|
|
432
|
+
replacement: todo + commentedStatement,
|
|
433
|
+
};
|
|
434
|
+
}
|
|
435
|
+
/** True if `edit`'s position falls within any of the given ranges. */
|
|
436
|
+
function isInsideAnyRange(edit, ranges) {
|
|
437
|
+
return ranges.some((range) => edit.start >= range.start && edit.end <= range.end);
|
|
438
|
+
}
|
|
439
|
+
/** Returns the index of the first character of the line containing `pos`. */
|
|
440
|
+
function getLineStartPosition(source, pos) {
|
|
441
|
+
const newlineIndex = source.lastIndexOf('\n', pos - 1);
|
|
442
|
+
return newlineIndex === -1 ? 0 : newlineIndex + 1;
|
|
443
|
+
}
|
|
325
444
|
/**
|
|
326
445
|
* Resolves a reference name from an expression.
|
|
327
446
|
* Handles: `ref`, `this.ref`, `this._ref`
|