bestax-migrate 2.41.0 → 2.41.1
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/dist/sources/_shared/imports.d.ts +20 -0
- package/dist/sources/_shared/imports.d.ts.map +1 -1
- package/dist/sources/_shared/imports.js +54 -0
- package/dist/sources/_shared/props.d.ts +13 -0
- package/dist/sources/_shared/props.d.ts.map +1 -1
- package/dist/sources/_shared/props.js +36 -0
- package/dist/sources/bloomer/mapping.d.ts +3 -12
- package/dist/sources/bloomer/mapping.d.ts.map +1 -1
- package/dist/sources/bloomer/mapping.js +3 -32
- package/dist/sources/bloomer/transform.d.ts.map +1 -1
- package/dist/sources/bloomer/transform.js +7 -5
- package/dist/sources/rbx/mapping.d.ts +8 -0
- package/dist/sources/rbx/mapping.d.ts.map +1 -1
- package/dist/sources/rbx/mapping.js +53 -0
- package/dist/sources/rbx/transform.d.ts.map +1 -1
- package/dist/sources/rbx/transform.js +76 -32
- package/dist/sources/react-bulma-components/transform.d.ts.map +1 -1
- package/dist/sources/react-bulma-components/transform.js +12 -29
- package/package.json +2 -2
|
@@ -72,11 +72,31 @@ export interface AliasRegistry {
|
|
|
72
72
|
anyAlias(name: string): boolean;
|
|
73
73
|
}
|
|
74
74
|
export declare function makeAliasRegistry(): AliasRegistry;
|
|
75
|
+
/**
|
|
76
|
+
* Whether the identifier at `path` is a name in an export specifier that
|
|
77
|
+
* binds nothing here: the public name of `export { Card as Header }`, or any
|
|
78
|
+
* name in `export … from './other'`, which names that module's exports.
|
|
79
|
+
*/
|
|
80
|
+
export declare function namesNoLocal(path: ASTPath<any>): boolean;
|
|
81
|
+
/**
|
|
82
|
+
* The locals `export { … }` names. Pruning the declaration that binds one of
|
|
83
|
+
* them (`const { Header } = Card; export { Header };`) leaves the specifier
|
|
84
|
+
* naming nothing.
|
|
85
|
+
*/
|
|
86
|
+
export declare function reExportedLocals(j: JSCodeshift, root: Collection<any>): Set<string>;
|
|
75
87
|
/**
|
|
76
88
|
* The flat bestax name a re-export of `mapping`'s component is written as
|
|
77
89
|
* (`export { Columns as Group }`), or undefined when it has none to write.
|
|
78
90
|
*/
|
|
79
91
|
export declare function flatReExportTarget(mapping: ComponentMapping | undefined): string | undefined;
|
|
92
|
+
/**
|
|
93
|
+
* Why the destructuring at `path`, of the library path `base`, stays for an
|
|
94
|
+
* export, or undefined when it exports nothing as it is. A name the
|
|
95
|
+
* value-reference pass re-exports as bestax's own flat name needs no
|
|
96
|
+
* declaration, but a declaration that is the export
|
|
97
|
+
* (`export const { Header } = Card`) takes the export with it.
|
|
98
|
+
*/
|
|
99
|
+
export declare function keptForExport(path: ASTPath<any>, base: string[], reExported: Set<string>, resolveMapping: (parts: string[]) => ComponentMapping | undefined): string | undefined;
|
|
80
100
|
/** What the destructuring pass decided about its declarations. */
|
|
81
101
|
export interface DestructuringPlan {
|
|
82
102
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"imports.d.ts","sourceRoot":"","sources":["../../../src/sources/_shared/imports.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACpE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAW,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAIhE,eAAO,MAAM,MAAM,GAAI,MAAM,GAAG,KAAG,MACyB,CAAC;AAE7D;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAC/B,CAAC,EAAE,WAAW,EACd,IAAI,EAAE,UAAU,CAAC,GAAG,CAAC,EACrB,gBAAgB,EAAE,MAAM,GACvB,GAAG,CAAC,MAAM,CAAC,CAmEb;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CACzB,GAAG,EAAE,gBAAgB,EACrB,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,GACjB,CAAC,YAAY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@@ -213,6 +213,35 @@ export function makeAliasRegistry() {
|
|
|
213
213
|
const anyAlias = (name) => ownersFor(name).length > 0;
|
|
214
214
|
return { register, aliasAt, anyAlias };
|
|
215
215
|
}
|
|
216
|
+
/**
|
|
217
|
+
* Whether the identifier at `path` is a name in an export specifier that
|
|
218
|
+
* binds nothing here: the public name of `export { Card as Header }`, or any
|
|
219
|
+
* name in `export … from './other'`, which names that module's exports.
|
|
220
|
+
*/
|
|
221
|
+
export function namesNoLocal(path) {
|
|
222
|
+
const specifier = path.parent;
|
|
223
|
+
const type = specifier?.node?.type;
|
|
224
|
+
if (!type?.startsWith('Export') || !type.endsWith('Specifier'))
|
|
225
|
+
return false;
|
|
226
|
+
return (Boolean(specifier.parent?.node?.source) ||
|
|
227
|
+
specifier.node.local !== path.node);
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* The locals `export { … }` names. Pruning the declaration that binds one of
|
|
231
|
+
* them (`const { Header } = Card; export { Header };`) leaves the specifier
|
|
232
|
+
* naming nothing.
|
|
233
|
+
*/
|
|
234
|
+
export function reExportedLocals(j, root) {
|
|
235
|
+
const names = new Set();
|
|
236
|
+
root.find(j.ExportSpecifier).forEach(p => {
|
|
237
|
+
if (p.parent?.node?.source)
|
|
238
|
+
return;
|
|
239
|
+
const local = p.node.local ?? p.node.exported;
|
|
240
|
+
if (local?.type === 'Identifier')
|
|
241
|
+
names.add(local.name);
|
|
242
|
+
});
|
|
243
|
+
return names;
|
|
244
|
+
}
|
|
216
245
|
/**
|
|
217
246
|
* The flat bestax name a re-export of `mapping`'s component is written as
|
|
218
247
|
* (`export { Columns as Group }`), or undefined when it has none to write.
|
|
@@ -225,6 +254,31 @@ export function flatReExportTarget(mapping) {
|
|
|
225
254
|
? mapping.target
|
|
226
255
|
: undefined;
|
|
227
256
|
}
|
|
257
|
+
/**
|
|
258
|
+
* Why the destructuring at `path`, of the library path `base`, stays for an
|
|
259
|
+
* export, or undefined when it exports nothing as it is. A name the
|
|
260
|
+
* value-reference pass re-exports as bestax's own flat name needs no
|
|
261
|
+
* declaration, but a declaration that is the export
|
|
262
|
+
* (`export const { Header } = Card`) takes the export with it.
|
|
263
|
+
*/
|
|
264
|
+
export function keptForExport(path, base, reExported, resolveMapping) {
|
|
265
|
+
const declaration = path.parent;
|
|
266
|
+
const exported = declaration?.parent?.node?.type === 'ExportNamedDeclaration' &&
|
|
267
|
+
declaration.parent.node.declaration === declaration.node;
|
|
268
|
+
const names = path.node.id.properties
|
|
269
|
+
.filter((prop) => (prop.type === 'ObjectProperty' || prop.type === 'Property') &&
|
|
270
|
+
prop.value?.type === 'Identifier' &&
|
|
271
|
+
(exported ||
|
|
272
|
+
(reExported.has(prop.value.name) &&
|
|
273
|
+
!flatReExportTarget(resolveMapping([...base, nameOf(prop.key)])))))
|
|
274
|
+
.map((prop) => `\`${prop.value.name}\``)
|
|
275
|
+
.join(', ');
|
|
276
|
+
if (!names)
|
|
277
|
+
return undefined;
|
|
278
|
+
return exported
|
|
279
|
+
? `kept for the export of ${names}; migrate the modules that import this one, then this declaration, by hand`
|
|
280
|
+
: `kept for the re-export of ${names}; migrate that first`;
|
|
281
|
+
}
|
|
228
282
|
/** A `DestructuringPlan` for the transform whose context is `ctx`. */
|
|
229
283
|
export function makeDestructuringPlan(ctx) {
|
|
230
284
|
const kept = new WeakSet();
|
|
@@ -28,6 +28,19 @@ export declare function addAttrOnce(ctx: TransformContext, path: ASTPath<any>, e
|
|
|
28
28
|
export declare function mergeClass(ctx: TransformContext, path: ASTPath<any>, element: any, cls: string, originalName: string): void;
|
|
29
29
|
/** Apply one PropAction to `attr` on `element`. */
|
|
30
30
|
export declare function applyPropAction(ctx: TransformContext, path: ASTPath<any>, element: any, attr: any, action: PropAction): void;
|
|
31
|
+
/**
|
|
32
|
+
* bestax targets that extend only React's HTML attributes, with no
|
|
33
|
+
* `BulmaClassesProps`, so a source's universal helpers have no prop to land
|
|
34
|
+
* on there. A source writes each as the Bulma class it stood for instead,
|
|
35
|
+
* from its own `helperClassHint`.
|
|
36
|
+
*/
|
|
37
|
+
export declare const HELPERLESS_TARGETS: ReadonlySet<string>;
|
|
38
|
+
/**
|
|
39
|
+
* Targets whose `className` cannot be used either: `Dropdown.Divider` is a
|
|
40
|
+
* bare `React.FC` that declares no props at all and renders its own `<hr>`
|
|
41
|
+
* regardless. A helper on one of these is named, never converted.
|
|
42
|
+
*/
|
|
43
|
+
export declare const NO_CLASSNAME_TARGETS: ReadonlySet<string>;
|
|
31
44
|
/**
|
|
32
45
|
* Apply the source library's universal modifier-prop conversions to every
|
|
33
46
|
* attribute that was not already handled by the component's own prop map.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"props.d.ts","sourceRoot":"","sources":["../../../src/sources/_shared/props.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAWL,KAAK,gBAAgB,EACtB,MAAM,gBAAgB,CAAC;AAIxB;;;;GAIG;AACH,wBAAgB,YAAY,CAC1B,GAAG,EAAE,gBAAgB,EACrB,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,EAClB,OAAO,EAAE,GAAG,EACZ,YAAY,EAAE,MAAM,EACpB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,GAAG,SAAS,GACxB,IAAI,CAEN;AAED;;;GAGG;AACH,wBAAgB,WAAW,CACzB,GAAG,EAAE,gBAAgB,EACrB,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,EAClB,OAAO,EAAE,GAAG,EACZ,YAAY,EAAE,MAAM,EACpB,IAAI,EAAE,GAAG,GACR,IAAI,CAmBN;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CACxB,GAAG,EAAE,gBAAgB,EACrB,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,EAClB,OAAO,EAAE,GAAG,EACZ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CACxB,GAAG,EAAE,gBAAgB,EACrB,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,EAClB,OAAO,EAAE,GAAG,EACZ,GAAG,EAAE,MAAM,EACX,YAAY,EAAE,MAAM,GACnB,IAAI,CAoBN;AAED,mDAAmD;AACnD,wBAAgB,eAAe,CAC7B,GAAG,EAAE,gBAAgB,EACrB,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,EAClB,OAAO,EAAE,GAAG,EACZ,IAAI,EAAE,GAAG,EACT,MAAM,EAAE,UAAU,GACjB,IAAI,CAyNN;AAED;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,EAAE,WAAW,CAAC,MAAM,CAqBjD,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,EAAE,WAAW,CAAC,MAAM,CAEnD,CAAC;AAEH;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,gBAAgB,EACrB,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,EAClB,OAAO,EAAE,GAAG,EACZ,OAAO,EAAE,GAAG,CAAC,MAAM,CAAC,EACpB,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,GACzC,IAAI,CAQN"}
|
|
@@ -210,6 +210,42 @@ export function applyPropAction(ctx, path, element, attr, action) {
|
|
|
210
210
|
}
|
|
211
211
|
}
|
|
212
212
|
}
|
|
213
|
+
/**
|
|
214
|
+
* bestax targets that extend only React's HTML attributes, with no
|
|
215
|
+
* `BulmaClassesProps`, so a source's universal helpers have no prop to land
|
|
216
|
+
* on there. A source writes each as the Bulma class it stood for instead,
|
|
217
|
+
* from its own `helperClassHint`.
|
|
218
|
+
*/
|
|
219
|
+
export const HELPERLESS_TARGETS = new Set([
|
|
220
|
+
'Pagination.Previous',
|
|
221
|
+
'Pagination.Next',
|
|
222
|
+
'Pagination.Ellipsis',
|
|
223
|
+
'Navbar.Dropdown',
|
|
224
|
+
'Navbar.DropdownMenu',
|
|
225
|
+
'Navbar.Divider',
|
|
226
|
+
'Panel.Heading',
|
|
227
|
+
'Panel.Tabs',
|
|
228
|
+
'Panel.Block',
|
|
229
|
+
'Tabs.Item',
|
|
230
|
+
'Message.Header',
|
|
231
|
+
'Message.Body',
|
|
232
|
+
'Modal.Background',
|
|
233
|
+
'Modal.Content',
|
|
234
|
+
'Modal.Card',
|
|
235
|
+
'Modal.Card.Head',
|
|
236
|
+
'Modal.Card.Title',
|
|
237
|
+
'Modal.Card.Body',
|
|
238
|
+
'Modal.Card.Foot',
|
|
239
|
+
'Modal.Close',
|
|
240
|
+
]);
|
|
241
|
+
/**
|
|
242
|
+
* Targets whose `className` cannot be used either: `Dropdown.Divider` is a
|
|
243
|
+
* bare `React.FC` that declares no props at all and renders its own `<hr>`
|
|
244
|
+
* regardless. A helper on one of these is named, never converted.
|
|
245
|
+
*/
|
|
246
|
+
export const NO_CLASSNAME_TARGETS = new Set([
|
|
247
|
+
'Dropdown.Divider',
|
|
248
|
+
]);
|
|
213
249
|
/**
|
|
214
250
|
* Apply the source library's universal modifier-prop conversions to every
|
|
215
251
|
* attribute that was not already handled by the component's own prop map.
|
|
@@ -48,19 +48,10 @@ export declare const UNIVERSAL_PROPS: Record<string, PropAction>;
|
|
|
48
48
|
*/
|
|
49
49
|
export declare const RESPONSIVE_PROPS: Record<string, string | null>;
|
|
50
50
|
/**
|
|
51
|
-
*
|
|
52
|
-
* `
|
|
53
|
-
*
|
|
54
|
-
* emitting an excess-property type error.
|
|
51
|
+
* The Bulma class a helper prop stood for, written on a target that takes no
|
|
52
|
+
* helper props (`HELPERLESS_TARGETS` in `_shared/props.ts`) or named in its
|
|
53
|
+
* TODO.
|
|
55
54
|
*/
|
|
56
|
-
/**
|
|
57
|
-
* Targets whose `className` cannot be used: `Dropdown.Divider` is a bare
|
|
58
|
-
* `React.FC` that declares no props at all and renders its own `<hr>`
|
|
59
|
-
* regardless. A helper on one of these is named, never converted.
|
|
60
|
-
*/
|
|
61
|
-
export declare const NO_CLASSNAME_TARGETS: Set<string>;
|
|
62
|
-
export declare const HELPERLESS_TARGETS: Set<string>;
|
|
63
|
-
/** The Bulma class a helper prop stood for, for the hint on those targets. */
|
|
64
55
|
export declare function helperClassHint(name: string, value: string | number | boolean | undefined): string | null;
|
|
65
56
|
/** Bloomer's fraction and width spellings → bestax's `BulmaColumnSize` names. */
|
|
66
57
|
export declare const COLUMN_SIZE_MAP: Record<string, string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapping.d.ts","sourceRoot":"","sources":["../../../src/sources/bloomer/mapping.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAkBnE;;;;GAIG;AACH,eAAO,MAAM,WAAW,EAAE,UAEzB,CAAC;AA8CF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAsBtD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAG1D,CAAC;AAEF
|
|
1
|
+
{"version":3,"file":"mapping.d.ts","sourceRoot":"","sources":["../../../src/sources/bloomer/mapping.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAkBnE;;;;GAIG;AACH,eAAO,MAAM,WAAW,EAAE,UAEzB,CAAC;AA8CF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAsBtD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAG1D,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,GAC3C,MAAM,GAAG,IAAI,CA0Bf;AAED,iFAAiF;AACjF,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAOlD,CAAC;AAEF,eAAO,MAAM,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CA0nBpD,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAiIpD,CAAC;AAEF,sDAAsD;AACtD,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,gBAAgB,GAAG,SAAS,CAM3E"}
|
|
@@ -122,39 +122,10 @@ export const RESPONSIVE_PROPS = {
|
|
|
122
122
|
isHidden: null,
|
|
123
123
|
};
|
|
124
124
|
/**
|
|
125
|
-
*
|
|
126
|
-
* `
|
|
127
|
-
*
|
|
128
|
-
* emitting an excess-property type error.
|
|
125
|
+
* The Bulma class a helper prop stood for, written on a target that takes no
|
|
126
|
+
* helper props (`HELPERLESS_TARGETS` in `_shared/props.ts`) or named in its
|
|
127
|
+
* TODO.
|
|
129
128
|
*/
|
|
130
|
-
/**
|
|
131
|
-
* Targets whose `className` cannot be used: `Dropdown.Divider` is a bare
|
|
132
|
-
* `React.FC` that declares no props at all and renders its own `<hr>`
|
|
133
|
-
* regardless. A helper on one of these is named, never converted.
|
|
134
|
-
*/
|
|
135
|
-
export const NO_CLASSNAME_TARGETS = new Set(['Dropdown.Divider']);
|
|
136
|
-
export const HELPERLESS_TARGETS = new Set([
|
|
137
|
-
'Pagination.Previous',
|
|
138
|
-
'Pagination.Next',
|
|
139
|
-
'Navbar.Dropdown',
|
|
140
|
-
'Navbar.DropdownMenu',
|
|
141
|
-
'Navbar.Divider',
|
|
142
|
-
'Panel.Heading',
|
|
143
|
-
'Panel.Tabs',
|
|
144
|
-
'Panel.Block',
|
|
145
|
-
'Tabs.Item',
|
|
146
|
-
'Message.Header',
|
|
147
|
-
'Message.Body',
|
|
148
|
-
'Modal.Background',
|
|
149
|
-
'Modal.Content',
|
|
150
|
-
'Modal.Card',
|
|
151
|
-
'Modal.Card.Head',
|
|
152
|
-
'Modal.Card.Title',
|
|
153
|
-
'Modal.Card.Body',
|
|
154
|
-
'Modal.Card.Foot',
|
|
155
|
-
'Modal.Close',
|
|
156
|
-
]);
|
|
157
|
-
/** The Bulma class a helper prop stood for, for the hint on those targets. */
|
|
158
129
|
export function helperClassHint(name, value) {
|
|
159
130
|
const v = typeof value === 'string' ? value : undefined;
|
|
160
131
|
switch (name) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../../src/sources/bloomer/transform.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../../src/sources/bloomer/transform.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AA8DvD,MAAM,CAAC,OAAO,UAAU,SAAS,CAC/B,QAAQ,EAAE,QAAQ,EAClB,GAAG,EAAE,GAAG,EACR,OAAO,GAAE,gBAAqB,GAC7B,MAAM,GAAG,SAAS,CA0yBpB"}
|
|
@@ -22,16 +22,16 @@
|
|
|
22
22
|
* and most of them rename onto a dotted bestax compound; the rename and
|
|
23
23
|
* value-reference passes below build those from the mapping's `target`.
|
|
24
24
|
*/
|
|
25
|
-
import {
|
|
25
|
+
import { MAPPING, UNIVERSAL_PROPS, helperClassHint, resolveMapping, } from './mapping.js';
|
|
26
26
|
import { addTodo, attributesOf, forgetJsxParens, jsxNameParts, literalValueOf, removeAttr, renameElement, replaceChain, reprintDirectives, } from '../_shared/jsx-utils.js';
|
|
27
|
-
import { applyPropAction, applyUniversalProps, mergeClass, } from '../_shared/props.js';
|
|
27
|
+
import { HELPERLESS_TARGETS, NO_CLASSNAME_TARGETS, applyPropAction, applyUniversalProps, mergeClass, } from '../_shared/props.js';
|
|
28
28
|
import { enforcePolymorphicProps } from '../_shared/polymorphic.js';
|
|
29
29
|
import { keepBaseDisplay } from '../_shared/display.js';
|
|
30
30
|
import { askForModalName } from '../_shared/modal-name.js';
|
|
31
31
|
import { bestaxValueLocals, buildBestaxImport, carryPrunedComments, noteRetainedImport, placeBestaxImport, seedBestaxImport, } from '../_shared/bestax-import.js';
|
|
32
32
|
import { CLASSNAME_SINCE, bestaxFloorFor, classNameWaitsFor, heldForRelease, releaseHoldMessage, makeReferenceHold, releaseRaise, } from '../_shared/bestax-floor.js';
|
|
33
33
|
import { rewriteStylesheetImports } from '../_shared/css-imports.js';
|
|
34
|
-
import { collectBoundNames, makeReserve, nameOf, prefersTabs, resolvesToBinding, } from '../_shared/imports.js';
|
|
34
|
+
import { collectBoundNames, makeReserve, nameOf, namesNoLocal, prefersTabs, resolvesToBinding, } from '../_shared/imports.js';
|
|
35
35
|
import { flattenResponsiveProps, RESPONSIVE_KINDS } from './responsive.js';
|
|
36
36
|
import { runSpecial } from './specials.js';
|
|
37
37
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
@@ -443,6 +443,10 @@ export default function transform(fileInfo, api, options = {}) {
|
|
|
443
443
|
// runtime, so it is not a value use of the namespace at all.
|
|
444
444
|
if (parentType === 'TSQualifiedName')
|
|
445
445
|
return;
|
|
446
|
+
// A public name (`export { Card as Header }`) or a name in
|
|
447
|
+
// `export { Header } from './other'` binds nothing here.
|
|
448
|
+
if (namesNoLocal(path))
|
|
449
|
+
return;
|
|
446
450
|
// A namespace binding in a real value position. `bloomer.Button` is still a
|
|
447
451
|
// mappable component reference, so fall through to the member-expression
|
|
448
452
|
// branch below with an empty prefix (the namespace itself is not part of
|
|
@@ -461,8 +465,6 @@ export default function transform(fileInfo, api, options = {}) {
|
|
|
461
465
|
// target keeps the public name (\`export { SubTitle as Subtitle }\`), a
|
|
462
466
|
// dotted one cannot be re-exported under a member name and is flagged.
|
|
463
467
|
if (parentType === 'ExportSpecifier') {
|
|
464
|
-
if (parentNode.local !== path.node)
|
|
465
|
-
return;
|
|
466
468
|
const exportedName = nameOf(parentNode.exported ?? parentNode.local);
|
|
467
469
|
const mapping = MAPPING[imported];
|
|
468
470
|
if (mapping &&
|
|
@@ -34,6 +34,14 @@ export declare const AS_OK: PropAction;
|
|
|
34
34
|
* would silently produce a type error rather than a TODO.
|
|
35
35
|
*/
|
|
36
36
|
export declare const UNIVERSAL_PROPS: Record<string, PropAction>;
|
|
37
|
+
/**
|
|
38
|
+
* The Bulma class one of the universal helpers above stood for, written on
|
|
39
|
+
* a target that takes no helper props (`HELPERLESS_TARGETS` in
|
|
40
|
+
* `_shared/props.ts`) or named in its TODO. `value` is the helper's literal
|
|
41
|
+
* value, undefined when it is dynamic; `textColor` and `backgroundColor` are
|
|
42
|
+
* left to their own passes, which flag them on these targets.
|
|
43
|
+
*/
|
|
44
|
+
export declare function helperClassHint(name: string, value: string | number | boolean | undefined): string | null;
|
|
37
45
|
/** rbx badge helper props → bestax `<Badge>` props. */
|
|
38
46
|
export declare const BADGE_PROPS: Record<string, string | null>;
|
|
39
47
|
/** rbx tooltip helper props → bestax `<Tooltip>` props. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapping.d.ts","sourceRoot":"","sources":["../../../src/sources/rbx/mapping.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,gBAAgB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,GAAG,SAAS,GAC3C,MAAM,GAAG,IAAI,CA8Cf;AAED,uDAAuD;AACvD,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAOrD,CAAC;AAEF,2DAA2D;AAC3D,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAQvD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAShE,CAAC;AAEF,eAAO,MAAM,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CA2tBpD,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CA2FhD,CAAC;AAEF,sDAAsD;AACtD,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,gBAAgB,GAAG,SAAS,CAM3E"}
|
|
@@ -87,6 +87,59 @@ export const UNIVERSAL_PROPS = {
|
|
|
87
87
|
todo: `\`innerRef\` has no counterpart; rename it to \`ref\` if this target forwards one, otherwise move it onto a wrapping element you control (${DOCS}/api)`,
|
|
88
88
|
},
|
|
89
89
|
};
|
|
90
|
+
/**
|
|
91
|
+
* The Bulma class one of the universal helpers above stood for, written on
|
|
92
|
+
* a target that takes no helper props (`HELPERLESS_TARGETS` in
|
|
93
|
+
* `_shared/props.ts`) or named in its TODO. `value` is the helper's literal
|
|
94
|
+
* value, undefined when it is dynamic; `textColor` and `backgroundColor` are
|
|
95
|
+
* left to their own passes, which flag them on these targets.
|
|
96
|
+
*/
|
|
97
|
+
export function helperClassHint(name, value) {
|
|
98
|
+
const v = typeof value === 'string' || typeof value === 'number'
|
|
99
|
+
? String(value)
|
|
100
|
+
: undefined;
|
|
101
|
+
switch (name) {
|
|
102
|
+
case 'textAlign':
|
|
103
|
+
return `has-text-${v ?? '<alignment>'}`;
|
|
104
|
+
case 'textTransform':
|
|
105
|
+
return `is-${v ?? '<transform>'}`;
|
|
106
|
+
case 'textWeight':
|
|
107
|
+
return `has-text-weight-${v ?? '<weight>'}`;
|
|
108
|
+
case 'textSize':
|
|
109
|
+
return `is-size-${v ?? '<size>'}`;
|
|
110
|
+
case 'pull':
|
|
111
|
+
return `is-pulled-${v ?? '<side>'}`;
|
|
112
|
+
case 'italic':
|
|
113
|
+
return 'is-italic';
|
|
114
|
+
case 'clearfix':
|
|
115
|
+
return 'is-clearfix';
|
|
116
|
+
case 'clipped':
|
|
117
|
+
return 'is-clipped';
|
|
118
|
+
case 'overlay':
|
|
119
|
+
return 'is-overlay';
|
|
120
|
+
case 'hidden':
|
|
121
|
+
return 'is-hidden';
|
|
122
|
+
case 'invisible':
|
|
123
|
+
return 'is-invisible';
|
|
124
|
+
case 'srOnly':
|
|
125
|
+
return 'is-sr-only';
|
|
126
|
+
// Bulma v1 removed `is-marginless` and `is-paddingless`; these do their job.
|
|
127
|
+
case 'marginless':
|
|
128
|
+
return 'm-0';
|
|
129
|
+
case 'paddingless':
|
|
130
|
+
return 'p-0';
|
|
131
|
+
case 'radiusless':
|
|
132
|
+
return 'is-radiusless';
|
|
133
|
+
case 'shadowless':
|
|
134
|
+
return 'is-shadowless';
|
|
135
|
+
case 'unselectable':
|
|
136
|
+
return 'is-unselectable';
|
|
137
|
+
case 'relative':
|
|
138
|
+
return 'is-relative';
|
|
139
|
+
default:
|
|
140
|
+
return null;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
90
143
|
/** rbx badge helper props → bestax `<Badge>` props. */
|
|
91
144
|
export const BADGE_PROPS = {
|
|
92
145
|
badge: 'content',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../../src/sources/rbx/transform.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../../src/sources/rbx/transform.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AA6EvD,MAAM,CAAC,OAAO,UAAU,SAAS,CAC/B,QAAQ,EAAE,QAAQ,EAClB,GAAG,EAAE,GAAG,EACR,OAAO,GAAE,gBAAqB,GAC7B,MAAM,GAAG,SAAS,CA+lCpB"}
|
|
@@ -20,17 +20,17 @@
|
|
|
20
20
|
* `Tooltip` components. So `<Button tooltip="hi" />` is a wrapping rewrite,
|
|
21
21
|
* not a rename.
|
|
22
22
|
*/
|
|
23
|
-
import { BADGE_PROPS, MAPPING, TOOLTIP_PROPS, UNIVERSAL_PROPS, resolveMapping, } from './mapping.js';
|
|
23
|
+
import { BADGE_PROPS, MAPPING, TOOLTIP_PROPS, UNIVERSAL_PROPS, helperClassHint, resolveMapping, } from './mapping.js';
|
|
24
24
|
import { addTodo, attributesOf, findAttr, forgetJsxParens, jsxNameParts, literalValueOf, removeAttr, renameElement, replaceChain, reprintDirectives, } from '../_shared/jsx-utils.js';
|
|
25
25
|
import { applyBackgroundColor } from '../_shared/background-props.js';
|
|
26
|
-
import { applyPropAction, applyUniversalProps } from '../_shared/props.js';
|
|
26
|
+
import { HELPERLESS_TARGETS, NO_CLASSNAME_TARGETS, applyPropAction, applyUniversalProps, mergeClass, } from '../_shared/props.js';
|
|
27
27
|
import { applyTextColor } from '../_shared/text-color-props.js';
|
|
28
28
|
import { enforcePolymorphicProps } from '../_shared/polymorphic.js';
|
|
29
29
|
import { askForModalName } from '../_shared/modal-name.js';
|
|
30
30
|
import { BESTAX, bestaxValueLocals, buildBestaxImport, carryPrunedComments, noteRetainedImport, placeBestaxImport, seedBestaxImport, } from '../_shared/bestax-import.js';
|
|
31
31
|
import { rewriteStylesheetImports } from '../_shared/css-imports.js';
|
|
32
|
-
import { bestaxFloorFor, classNameWaitsFor, heldForRelease, releaseHoldMessage, makeReferenceHold, } from '../_shared/bestax-floor.js';
|
|
33
|
-
import { collectBoundNames, flatReExportTarget, makeAliasRegistry, makeDestructuringPlan, makeReserve, nameOf, prefersTabs, resolvesToBinding, } from '../_shared/imports.js';
|
|
32
|
+
import { bestaxFloorFor, classNameWaitsFor, heldForRelease, releaseHoldMessage, releaseRaise, makeReferenceHold, } from '../_shared/bestax-floor.js';
|
|
33
|
+
import { collectBoundNames, flatReExportTarget, keptForExport, makeAliasRegistry, makeDestructuringPlan, makeReserve, nameOf, namesNoLocal, prefersTabs, reExportedLocals, resolvesToBinding, } from '../_shared/imports.js';
|
|
34
34
|
import { flattenResponsiveProps, RESPONSIVE_KINDS } from './responsive.js';
|
|
35
35
|
import { runSpecial } from './specials.js';
|
|
36
36
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
@@ -148,17 +148,7 @@ export default function transform(fileInfo, api, options = {}) {
|
|
|
148
148
|
// against the binding it actually resolves to rather than matched by name.
|
|
149
149
|
const programScope = root.find(j.Program).paths()[0]?.scope;
|
|
150
150
|
const { register: registerAlias, aliasAt, anyAlias } = makeAliasRegistry();
|
|
151
|
-
|
|
152
|
-
* Locals a re-export names. Pruning the declaration that binds one of them
|
|
153
|
-
* (`const { Header } = Card; export { Header };`) leaves the specifier
|
|
154
|
-
* pointing at nothing, so those declarations are kept.
|
|
155
|
-
*/
|
|
156
|
-
const reExported = new Set();
|
|
157
|
-
root.find(j.ExportSpecifier).forEach(p => {
|
|
158
|
-
const local = p.node.local ?? p.node.exported;
|
|
159
|
-
if (local?.type === 'Identifier')
|
|
160
|
-
reExported.add(local.name);
|
|
161
|
-
});
|
|
151
|
+
const reExported = reExportedLocals(j, root);
|
|
162
152
|
// ---- 1b. Resolve `const { Item } = Card` destructuring -----------------
|
|
163
153
|
const destructurings = makeDestructuringPlan(ctx);
|
|
164
154
|
root.find(j.VariableDeclarator).forEach(path => {
|
|
@@ -202,22 +192,13 @@ export default function transform(fileInfo, api, options = {}) {
|
|
|
202
192
|
allResolved = false;
|
|
203
193
|
}
|
|
204
194
|
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
!flatReExportTarget(resolveMapping([...basePath, nameOf(prop.key)])))
|
|
212
|
-
.map((prop) => `\`${prop.value.name}\``);
|
|
213
|
-
if (allResolved && reExports.length === 0) {
|
|
195
|
+
const kept = allResolved
|
|
196
|
+
? keptForExport(path, basePath, reExported, resolveMapping)
|
|
197
|
+
: `could not resolve every name destructured from \`${base}\`; migrate the leftovers by hand`;
|
|
198
|
+
if (kept)
|
|
199
|
+
destructurings.keep(path, basePath[0], kept);
|
|
200
|
+
else
|
|
214
201
|
destructurings.prune(path, basePath[0]);
|
|
215
|
-
}
|
|
216
|
-
else {
|
|
217
|
-
destructurings.keep(path, basePath[0], allResolved
|
|
218
|
-
? `kept for the re-export of ${reExports.join(', ')}; migrate that first`
|
|
219
|
-
: `could not resolve every name destructured from \`${base}\`; migrate the leftovers by hand`);
|
|
220
|
-
}
|
|
221
202
|
});
|
|
222
203
|
/**
|
|
223
204
|
* Whether an element `heldForRelease` names stays rbx's. One reached
|
|
@@ -500,6 +481,67 @@ export default function transform(fileInfo, api, options = {}) {
|
|
|
500
481
|
return;
|
|
501
482
|
}
|
|
502
483
|
}
|
|
484
|
+
// Targets that extend only React's HTML attributes take none of rbx's
|
|
485
|
+
// universal helpers, so each becomes the Bulma class it stood for, as
|
|
486
|
+
// bloomer's do. Where no `className` can carry it, each is named in a
|
|
487
|
+
// TODO instead: on a target that takes no props at all, and below the
|
|
488
|
+
// release a CLASSNAME_SINCE target keeps its own class beside a
|
|
489
|
+
// `className` from, where the `className` would replace that class.
|
|
490
|
+
const noProps = NO_CLASSNAME_TARGETS.has(target);
|
|
491
|
+
if (HELPERLESS_TARGETS.has(target) || noProps) {
|
|
492
|
+
const since = classNameWaitsFor(target, bestaxFloor);
|
|
493
|
+
// Why a class can't be written, and what to do about it.
|
|
494
|
+
const refusal = (what) => noProps
|
|
495
|
+
? `bestax \`${target}\` takes no props at all, so ${what} cannot be set on it: wrap it, or restyle by hand`
|
|
496
|
+
: since
|
|
497
|
+
? `${releaseRaise(target, since)}, so ${what} isn't set on it: declare \`@allxsmith/bestax-bulma\` at \`^${since}\` or later and re-run, or restyle by hand`
|
|
498
|
+
: undefined;
|
|
499
|
+
const takesNone = `bestax \`${target}\` takes no Bulma helper props (it extends only React's HTML attributes)`;
|
|
500
|
+
// A spread after the `className`, or anywhere when there is none, can
|
|
501
|
+
// carry a `className` of its own that replaces the class written here.
|
|
502
|
+
const attributes = element.openingElement.attributes ?? [];
|
|
503
|
+
const classAt = attributes.indexOf(findAttr(element, 'className'));
|
|
504
|
+
const spread = attributes.some((a, i) => a.type === 'JSXSpreadAttribute' && i > classAt);
|
|
505
|
+
for (const attr of [...attributesOf(element)]) {
|
|
506
|
+
const name = attr.name.name;
|
|
507
|
+
if (handled.has(name))
|
|
508
|
+
continue;
|
|
509
|
+
if (name === 'responsive') {
|
|
510
|
+
removeAttr(element, attr);
|
|
511
|
+
handled.add(name);
|
|
512
|
+
addTodo(ctx, path, 'prop:responsive', refusal('the classes `responsive` stood for') ??
|
|
513
|
+
`${takesNone}; add the classes \`responsive\` stood for to \`className\` by hand`);
|
|
514
|
+
continue;
|
|
515
|
+
}
|
|
516
|
+
const literal = literalValueOf(attr);
|
|
517
|
+
const cls = helperClassHint(name, literal.kind === 'expression' ? undefined : literal.value);
|
|
518
|
+
if (!cls)
|
|
519
|
+
continue;
|
|
520
|
+
removeAttr(element, attr);
|
|
521
|
+
handled.add(name);
|
|
522
|
+
// A falsy literal wrote no class in rbx; nothing to carry.
|
|
523
|
+
if (literal.kind !== 'expression' && !literal.value)
|
|
524
|
+
continue;
|
|
525
|
+
const refused = refusal(`the \`${cls}\` class this became`);
|
|
526
|
+
if (refused) {
|
|
527
|
+
addTodo(ctx, path, `prop:${name}`, refused);
|
|
528
|
+
}
|
|
529
|
+
else if (literal.kind === 'expression') {
|
|
530
|
+
addTodo(ctx, path, `prop:${name}`, `${takesNone}; add the \`${cls}\` class to \`className\` by hand, wherever its value set it`);
|
|
531
|
+
}
|
|
532
|
+
else if (cls.includes('<')) {
|
|
533
|
+
// A placeholder (`is-pulled-<side>`): the helper took a value and
|
|
534
|
+
// was given none, so there is no class to write.
|
|
535
|
+
addTodo(ctx, path, `prop:${name}`, `${takesNone}, and \`${name}\` carries no value here; add the \`${cls}\` class it takes to \`className\` by hand, with the value you meant`);
|
|
536
|
+
}
|
|
537
|
+
else if (spread) {
|
|
538
|
+
addTodo(ctx, path, `prop:${name}`, `${takesNone}; add the \`${cls}\` class to the \`className\` its spread may carry, by hand`);
|
|
539
|
+
}
|
|
540
|
+
else {
|
|
541
|
+
mergeClass(ctx, path, element, cls, name);
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
}
|
|
503
545
|
// Rename to the bestax name, aliasing the import root on collision.
|
|
504
546
|
const [targetRoot, ...targetRest] = target.split('.');
|
|
505
547
|
const localTarget = [ctx.reserve(targetRoot), ...targetRest].join('.');
|
|
@@ -610,6 +652,10 @@ export default function transform(fileInfo, api, options = {}) {
|
|
|
610
652
|
// runtime, so it is not a value use of the namespace at all.
|
|
611
653
|
if (parentType === 'TSQualifiedName')
|
|
612
654
|
return;
|
|
655
|
+
// A public name (`export { Card as Header }`) or a name in
|
|
656
|
+
// `export { Header } from './other'` binds nothing here.
|
|
657
|
+
if (namesNoLocal(path))
|
|
658
|
+
return;
|
|
613
659
|
// A namespace binding in a real value position. `rbx.Button` is still a
|
|
614
660
|
// mappable component reference, so fall through to the member-expression
|
|
615
661
|
// branch below with an empty prefix (the namespace itself is not part of
|
|
@@ -628,8 +674,6 @@ export default function transform(fileInfo, api, options = {}) {
|
|
|
628
674
|
// target keeps the public name (\`export { SubTitle as Subtitle }\`), a
|
|
629
675
|
// dotted one cannot be re-exported under a member name and is flagged.
|
|
630
676
|
if (parentType === 'ExportSpecifier') {
|
|
631
|
-
if (parentNode.local !== path.node)
|
|
632
|
-
return;
|
|
633
677
|
const exportedName = nameOf(parentNode.exported ?? parentNode.local);
|
|
634
678
|
const mapping = aliasPath ? resolveMapping(aliasPath) : MAPPING[imported];
|
|
635
679
|
const flat = flatReExportTarget(mapping);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../../src/sources/react-bulma-components/transform.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../../src/sources/react-bulma-components/transform.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAgDvD,MAAM,CAAC,OAAO,UAAU,SAAS,CAC/B,QAAQ,EAAE,QAAQ,EAClB,GAAG,EAAE,GAAG,EACR,OAAO,GAAE,gBAAqB,GAC7B,MAAM,GAAG,SAAS,CA0vBpB"}
|
|
@@ -24,7 +24,7 @@ import { keepBaseDisplay } from '../_shared/display.js';
|
|
|
24
24
|
import { askForModalName } from '../_shared/modal-name.js';
|
|
25
25
|
import { bestaxValueLocals, buildBestaxImport, carryPrunedComments, noteRetainedImport, placeBestaxImport, seedBestaxImport, } from '../_shared/bestax-import.js';
|
|
26
26
|
import { rewriteStylesheetImports } from '../_shared/css-imports.js';
|
|
27
|
-
import { collectBoundNames, flatReExportTarget, makeAliasRegistry, makeDestructuringPlan, makeReserve, nameOf, prefersTabs, resolvesToBinding, } from '../_shared/imports.js';
|
|
27
|
+
import { collectBoundNames, flatReExportTarget, keptForExport, makeAliasRegistry, makeDestructuringPlan, makeReserve, nameOf, namesNoLocal, prefersTabs, reExportedLocals, resolvesToBinding, } from '../_shared/imports.js';
|
|
28
28
|
import { applyColorVariant } from './color-variant.js';
|
|
29
29
|
import { flattenResponsiveProps } from './responsive.js';
|
|
30
30
|
import { RESPONSIVE_KINDS, runSpecial } from './specials.js';
|
|
@@ -109,17 +109,7 @@ export default function transform(fileInfo, api, options = {}) {
|
|
|
109
109
|
// against the binding it actually resolves to rather than matched by name.
|
|
110
110
|
const programScope = root.find(j.Program).paths()[0]?.scope;
|
|
111
111
|
const { register: registerAlias, aliasAt, anyAlias } = makeAliasRegistry();
|
|
112
|
-
|
|
113
|
-
* Locals a re-export names. Pruning the declaration that binds one of them
|
|
114
|
-
* (`const { Header } = Card; export { Header };`) leaves the specifier
|
|
115
|
-
* pointing at nothing, so those declarations are kept.
|
|
116
|
-
*/
|
|
117
|
-
const reExported = new Set();
|
|
118
|
-
root.find(j.ExportSpecifier).forEach(p => {
|
|
119
|
-
const local = p.node.local ?? p.node.exported;
|
|
120
|
-
if (local?.type === 'Identifier')
|
|
121
|
-
reExported.add(local.name);
|
|
122
|
-
});
|
|
112
|
+
const reExported = reExportedLocals(j, root);
|
|
123
113
|
// ---- 1b. Resolve `const { Input, Field: F } = Form` destructuring -----
|
|
124
114
|
const destructurings = makeDestructuringPlan(ctx);
|
|
125
115
|
root.find(j.VariableDeclarator).forEach(path => {
|
|
@@ -163,22 +153,13 @@ export default function transform(fileInfo, api, options = {}) {
|
|
|
163
153
|
allResolved = false;
|
|
164
154
|
}
|
|
165
155
|
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
!flatReExportTarget(resolveMapping([...basePath, nameOf(prop.key)])))
|
|
173
|
-
.map((prop) => `\`${prop.value.name}\``);
|
|
174
|
-
if (allResolved && reExports.length === 0) {
|
|
156
|
+
const kept = allResolved
|
|
157
|
+
? keptForExport(path, basePath, reExported, resolveMapping)
|
|
158
|
+
: `could not resolve every name destructured from \`${base}\`; migrate the leftovers by hand`;
|
|
159
|
+
if (kept)
|
|
160
|
+
destructurings.keep(path, basePath[0], kept);
|
|
161
|
+
else
|
|
175
162
|
destructurings.prune(path, basePath[0]);
|
|
176
|
-
}
|
|
177
|
-
else {
|
|
178
|
-
destructurings.keep(path, basePath[0], allResolved
|
|
179
|
-
? `kept for the re-export of ${reExports.join(', ')}; migrate that first`
|
|
180
|
-
: `could not resolve every name destructured from \`${base}\`; migrate the leftovers by hand`);
|
|
181
|
-
}
|
|
182
163
|
});
|
|
183
164
|
/** Resolve a JSX name into a canonical RBC component path, or null. */
|
|
184
165
|
function resolveJsxPath(name, at) {
|
|
@@ -417,6 +398,10 @@ export default function transform(fileInfo, api, options = {}) {
|
|
|
417
398
|
// runtime, so it is not a value use of the namespace at all.
|
|
418
399
|
if (parentType === 'TSQualifiedName')
|
|
419
400
|
return;
|
|
401
|
+
// A public name (`export { Card as Header }`) or a name in
|
|
402
|
+
// `export { Header } from './other'` binds nothing here.
|
|
403
|
+
if (namesNoLocal(path))
|
|
404
|
+
return;
|
|
420
405
|
// A namespace binding in a real value position. `RBC.Box` is still a
|
|
421
406
|
// mappable component reference, so fall through to the member-expression
|
|
422
407
|
// branch below with an empty prefix (the namespace itself is not part of
|
|
@@ -437,8 +422,6 @@ export default function transform(fileInfo, api, options = {}) {
|
|
|
437
422
|
// target keeps the public name (\`export { SubTitle as Subtitle }\`), a
|
|
438
423
|
// dotted one cannot be re-exported under a member name and is flagged.
|
|
439
424
|
if (parentType === 'ExportSpecifier') {
|
|
440
|
-
if (parentNode.local !== path.node)
|
|
441
|
-
return;
|
|
442
425
|
const exportedName = nameOf(parentNode.exported ?? parentNode.local);
|
|
443
426
|
const mapping = aliasPath ? resolveMapping(aliasPath) : MAPPING[imported];
|
|
444
427
|
const flat = flatReExportTarget(mapping);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bestax-migrate",
|
|
3
|
-
"version": "2.41.
|
|
3
|
+
"version": "2.41.1",
|
|
4
4
|
"description": "Codemods for migrating existing React apps from other Bulma libraries to @allxsmith/bestax-bulma",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"jscodeshift": "^17.3.0",
|
|
41
41
|
"parse5": "^8.1.1",
|
|
42
42
|
"property-information": "^7.2.0",
|
|
43
|
-
"@allxsmith/bestax-bulma": "^5.81.
|
|
43
|
+
"@allxsmith/bestax-bulma": "^5.81.6"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@types/jscodeshift": "^17.3.0",
|