bestax-migrate 2.40.1 → 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.
Files changed (53) hide show
  1. package/README.md +1 -1
  2. package/dist/sources/_shared/bestax-floor.d.ts +49 -0
  3. package/dist/sources/_shared/bestax-floor.d.ts.map +1 -1
  4. package/dist/sources/_shared/bestax-floor.js +84 -0
  5. package/dist/sources/_shared/bestax-import.d.ts +16 -1
  6. package/dist/sources/_shared/bestax-import.d.ts.map +1 -1
  7. package/dist/sources/_shared/bestax-import.js +67 -2
  8. package/dist/sources/_shared/bestax-release.d.ts +27 -0
  9. package/dist/sources/_shared/bestax-release.d.ts.map +1 -0
  10. package/dist/sources/_shared/bestax-release.js +79 -0
  11. package/dist/sources/_shared/deps-common.d.ts +11 -9
  12. package/dist/sources/_shared/deps-common.d.ts.map +1 -1
  13. package/dist/sources/_shared/deps-common.js +25 -11
  14. package/dist/sources/_shared/imports.d.ts +50 -1
  15. package/dist/sources/_shared/imports.d.ts.map +1 -1
  16. package/dist/sources/_shared/imports.js +121 -0
  17. package/dist/sources/_shared/jsx-utils.d.ts +8 -0
  18. package/dist/sources/_shared/jsx-utils.d.ts.map +1 -1
  19. package/dist/sources/_shared/jsx-utils.js +13 -0
  20. package/dist/sources/_shared/props.d.ts +13 -0
  21. package/dist/sources/_shared/props.d.ts.map +1 -1
  22. package/dist/sources/_shared/props.js +36 -0
  23. package/dist/sources/bloomer/deps.d.ts +2 -3
  24. package/dist/sources/bloomer/deps.d.ts.map +1 -1
  25. package/dist/sources/bloomer/deps.js +9 -9
  26. package/dist/sources/bloomer/mapping.d.ts +3 -22
  27. package/dist/sources/bloomer/mapping.d.ts.map +1 -1
  28. package/dist/sources/bloomer/mapping.js +5 -45
  29. package/dist/sources/bloomer/transform.d.ts +3 -2
  30. package/dist/sources/bloomer/transform.d.ts.map +1 -1
  31. package/dist/sources/bloomer/transform.js +50 -39
  32. package/dist/sources/bulma-classes/deps.d.ts +2 -2
  33. package/dist/sources/bulma-classes/deps.js +2 -2
  34. package/dist/sources/rbx/deps.d.ts +2 -3
  35. package/dist/sources/rbx/deps.d.ts.map +1 -1
  36. package/dist/sources/rbx/deps.js +9 -9
  37. package/dist/sources/rbx/index.d.ts.map +1 -1
  38. package/dist/sources/rbx/index.js +6 -0
  39. package/dist/sources/rbx/mapping.d.ts +8 -0
  40. package/dist/sources/rbx/mapping.d.ts.map +1 -1
  41. package/dist/sources/rbx/mapping.js +53 -0
  42. package/dist/sources/rbx/transform.d.ts +3 -2
  43. package/dist/sources/rbx/transform.d.ts.map +1 -1
  44. package/dist/sources/rbx/transform.js +162 -72
  45. package/dist/sources/react-bulma-components/deps.d.ts +2 -2
  46. package/dist/sources/react-bulma-components/deps.d.ts.map +1 -1
  47. package/dist/sources/react-bulma-components/deps.js +10 -9
  48. package/dist/sources/react-bulma-components/transform.d.ts +3 -2
  49. package/dist/sources/react-bulma-components/transform.d.ts.map +1 -1
  50. package/dist/sources/react-bulma-components/transform.js +46 -63
  51. package/dist/types.d.ts +4 -3
  52. package/dist/types.d.ts.map +1 -1
  53. package/package.json +6 -6
@@ -5,6 +5,7 @@
5
5
  *
6
6
  * Source-agnostic: nothing here knows which library is being migrated.
7
7
  */
8
+ import { addTodo } from './jsx-utils.js';
8
9
  /* eslint-disable @typescript-eslint/no-explicit-any */
9
10
  export const nameOf = (node) => typeof node === 'string' ? node : String(node?.name ?? '');
10
11
  /**
@@ -212,3 +213,123 @@ export function makeAliasRegistry() {
212
213
  const anyAlias = (name) => ownersFor(name).length > 0;
213
214
  return { register, aliasAt, anyAlias };
214
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
+ }
245
+ /**
246
+ * The flat bestax name a re-export of `mapping`'s component is written as
247
+ * (`export { Columns as Group }`), or undefined when it has none to write.
248
+ */
249
+ export function flatReExportTarget(mapping) {
250
+ return mapping &&
251
+ mapping.status !== 'todo' &&
252
+ mapping.target &&
253
+ !mapping.target.includes('.')
254
+ ? mapping.target
255
+ : undefined;
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
+ }
282
+ /** A `DestructuringPlan` for the transform whose context is `ctx`. */
283
+ export function makeDestructuringPlan(ctx) {
284
+ const kept = new WeakSet();
285
+ const keptPaths = [];
286
+ const prunable = [];
287
+ const keep = (path, root, message) => {
288
+ const declarator = path.node;
289
+ for (const prop of declarator.id.properties) {
290
+ if (prop.value?.type !== 'Identifier')
291
+ continue;
292
+ kept.add(prop.value);
293
+ if (prop.shorthand)
294
+ kept.add(prop.key);
295
+ }
296
+ kept.add(declarator.init);
297
+ ctx.retained.add(root);
298
+ keptPaths.push(path);
299
+ addTodo(ctx, path, 'imports', message);
300
+ };
301
+ const settle = () => {
302
+ for (let i = 0; i < keptPaths.length; i++) {
303
+ const base = keptPaths[i].node.init.name;
304
+ // Every binding of the name in that scope, since its table has no
305
+ // blocks. One kept too many costs a TODO; pruning the one it reads
306
+ // would leave it reading nothing.
307
+ const bindings = new Set((keptPaths[i].scope?.lookup(base)?.getBindings()[base] ?? []).map((binding) => binding.node));
308
+ for (let k = prunable.length - 1; k >= 0; k--) {
309
+ const { path, root } = prunable[k];
310
+ if (!path.node.id.properties.some((p) => bindings.has(p.value))) {
311
+ continue;
312
+ }
313
+ prunable.splice(k, 1);
314
+ keep(path, root, `kept for a destructuring of \`${base}\` that stays; migrate that one first`);
315
+ }
316
+ }
317
+ for (const { path } of prunable) {
318
+ const declaration = path.parent;
319
+ if (declaration?.node?.type === 'VariableDeclaration' &&
320
+ declaration.node.declarations.length === 1) {
321
+ declaration.prune();
322
+ }
323
+ else {
324
+ path.prune();
325
+ }
326
+ ctx.dirty = true;
327
+ }
328
+ };
329
+ return {
330
+ kept,
331
+ keep,
332
+ prune: (path, root) => prunable.push({ path, root }),
333
+ settle,
334
+ };
335
+ }
@@ -55,6 +55,14 @@ export interface ResolvedElement {
55
55
  export declare function jsxNameParts(name: any): string[] | null;
56
56
  /** Build a JSXIdentifier / JSXMemberExpression chain from a dotted name. */
57
57
  export declare function buildJsxName(j: JSCodeshift, dotted: string): any;
58
+ /**
59
+ * Replace the member chain at `chain` with `replacement`, putting the old
60
+ * chain's names in `handled`. A walk over the file's identifiers still
61
+ * reaches them, and the last one then reads as a child of `replacement`:
62
+ * `B.PageEllipsis` beside a named `PageEllipsis` import became
63
+ * `Pagination.Pagination.Ellipsis`.
64
+ */
65
+ export declare function replaceChain(chain: ASTPath<any>, replacement: any, handled: WeakSet<object>): void;
58
66
  /** Rename both the opening and (when present) closing element. */
59
67
  export declare function renameElement(j: JSCodeshift, element: any, dotted: string): void;
60
68
  /** Non-spread attributes of an element. */
@@ -1 +1 @@
1
- {"version":3,"file":"jsx-utils.d.ts","sourceRoot":"","sources":["../../../src/sources/_shared/jsx-utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAMpD,MAAM,WAAW,gBAAgB;IAC/B,CAAC,EAAE,WAAW,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,aAAa,GAAG,SAAS,CAAC;IACrC,2EAA2E;IAC3E,QAAQ,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACtB,8EAA8E;IAC9E,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5B;;;;OAIG;IACH,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;IAClC;;;;OAIG;IACH,SAAS,EAAE,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC;;;OAGG;IACH,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,MAAM,EAAE,GAAG,IAAI,CAAC;IACzC;;;;;OAKG;IACH,cAAc,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,eAAe,GAAG,IAAI,CAAC;IACvD,KAAK,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,CAW/D;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,GAAG,GAAG,IAAI,CAajE;AAED;;;;;GAKG;AACH,wBAAgB,OAAO,CACrB,GAAG,EAAE,gBAAgB,EACrB,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,EAClB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,GACd,IAAI,CAgDN;AAED,uEAAuE;AACvE,wBAAgB,YAAY,CAC1B,CAAC,EAAE,WAAW,EACd,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,KAAK,EAAE,GAAG,EAAE,EACZ,QAAQ,EAAE,GAAG,EAAE,EACf,WAAW,UAAQ,GAClB,GAAG,CAsBL"}
@@ -30,6 +30,19 @@ export function buildJsxName(j, dotted) {
30
30
  }
31
31
  return node;
32
32
  }
33
+ /**
34
+ * Replace the member chain at `chain` with `replacement`, putting the old
35
+ * chain's names in `handled`. A walk over the file's identifiers still
36
+ * reaches them, and the last one then reads as a child of `replacement`:
37
+ * `B.PageEllipsis` beside a named `PageEllipsis` import became
38
+ * `Pagination.Pagination.Ellipsis`.
39
+ */
40
+ export function replaceChain(chain, replacement, handled) {
41
+ for (let node = chain.node; node?.type === 'MemberExpression' && !node.computed; node = node.object) {
42
+ handled.add(node.property);
43
+ }
44
+ chain.replace(replacement);
45
+ }
33
46
  /** Rename both the opening and (when present) closing element. */
34
47
  export function renameElement(j, element, dotted) {
35
48
  element.openingElement.name = buildJsxName(j, dotted);
@@ -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,GA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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.
@@ -1,8 +1,7 @@
1
1
  /**
2
2
  * package.json migration: swap bloomer for @allxsmith/bestax-bulma, move the
3
- * app's own Bulma to v1, and replace the dead node-sass with dart-sass. Pure
4
- * data-in/data-out — the CLI owns file IO, and no package manager is ever
5
- * invoked (the report tells the user to install).
3
+ * app's own Bulma to v1, and replace the dead node-sass with dart-sass. No
4
+ * package manager is ever invoked (the report tells the user to install).
6
5
  *
7
6
  * bloomer is the react-bulma-components case, not the rbx one: it never
8
7
  * depended on Bulma itself (its README says "npm install bulma"), so there is
@@ -1 +1 @@
1
- {"version":3,"file":"deps.d.ts","sourceRoot":"","sources":["../../../src/sources/bloomer/deps.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAUzD,eAAO,MAAM,kBAAkB,EAAE,kBAwChC,CAAC"}
1
+ {"version":3,"file":"deps.d.ts","sourceRoot":"","sources":["../../../src/sources/bloomer/deps.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAUzD,eAAO,MAAM,kBAAkB,EAAE,kBAyChC,CAAC"}
@@ -1,8 +1,7 @@
1
1
  /**
2
2
  * package.json migration: swap bloomer for @allxsmith/bestax-bulma, move the
3
- * app's own Bulma to v1, and replace the dead node-sass with dart-sass. Pure
4
- * data-in/data-out — the CLI owns file IO, and no package manager is ever
5
- * invoked (the report tells the user to install).
3
+ * app's own Bulma to v1, and replace the dead node-sass with dart-sass. No
4
+ * package manager is ever invoked (the report tells the user to install).
6
5
  *
7
6
  * bloomer is the react-bulma-components case, not the rbx one: it never
8
7
  * depended on Bulma itself (its README says "npm install bulma"), so there is
@@ -25,13 +24,14 @@ export const updateDependencies = (filePath, pkg, collector, options) => {
25
24
  manifest.note(`removed bloomer from ${name}`);
26
25
  }
27
26
  }
28
- // The transform deliberately RETAINS imports for components with no bestax
29
- // equivalent (Tile, the Bulma 0.4 Nav family) so a partially migrated app
30
- // still runs. Removing the package from the manifest strands exactly those
31
- // imports once the user runs the install the report asks for, so say so
32
- // rather than letting them find out at build time.
27
+ // Files can still import the library after the run: a trimmed import the
28
+ // transform kept, so a partially migrated app still runs, one it couldn't
29
+ // rewrite, a file it couldn't parse or doesn't read (`.vue`, `.astro`).
30
+ // Removing the package from the manifest strands those imports once the
31
+ // user runs the install the report asks for, so say so rather than letting
32
+ // them find out at build time.
33
33
  if (removedSource && options.sourceStillImported) {
34
- manifest.report('deps', 'bloomer was removed from package.json, but some files still import it for components with no bestax equivalent — resolve those `TODO(bestax-migrate)` imports before installing, or re-add bloomer until you have');
34
+ manifest.report('deps', 'bloomer was removed from package.json, but some files still import it, and installing would leave those imports unresolved: migrate every remaining import of bloomer (the ones the codemod kept are marked `TODO(bestax-migrate)`) before installing, or re-add bloomer until you have');
35
35
  }
36
36
  addBestax(manifest);
37
37
  moveBulmaToV1(manifest, options.bulmaReferenced);
@@ -48,29 +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
- * bestax targets that extend only React's HTML attributes — no
52
- * `BulmaClassesProps` — so bloomer's universal helpers have no prop to land
53
- * on. The transform turns each into a TODO naming the Bulma class instead of
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
- /**
63
- * Targets that keep their own class beside a `className` only from a
64
- * bestax-bulma release, by target. An older release writes the `className`
65
- * in place of the class that makes the element work, so the transform takes
66
- * one as a `NO_CLASSNAME_TARGETS` entry unless the run shows the project gets
67
- * that release (`_shared/bestax-floor.ts`), and as a `HELPERLESS_TARGETS` one
68
- * when it does. bulma-classes' class map holds the same release as
69
- * `classNameSince`.
70
- */
71
- export declare const CLASSNAME_SINCE: Readonly<Record<string, string>>;
72
- export declare const HELPERLESS_TARGETS: Set<string>;
73
- /** The Bulma class a helper prop stood for, for the hint on those targets. */
74
55
  export declare function helperClassHint(name: string, value: string | number | boolean | undefined): string | null;
75
56
  /** Bloomer's fraction and width spellings → bestax's `BulmaColumnSize` names. */
76
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,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IG;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,51 +122,10 @@ export const RESPONSIVE_PROPS = {
122
122
  isHidden: null,
123
123
  };
124
124
  /**
125
- * bestax targets that extend only React's HTML attributes — no
126
- * `BulmaClassesProps` — so bloomer's universal helpers have no prop to land
127
- * on. The transform turns each into a TODO naming the Bulma class instead of
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
- /**
137
- * Targets that keep their own class beside a `className` only from a
138
- * bestax-bulma release, by target. An older release writes the `className`
139
- * in place of the class that makes the element work, so the transform takes
140
- * one as a `NO_CLASSNAME_TARGETS` entry unless the run shows the project gets
141
- * that release (`_shared/bestax-floor.ts`), and as a `HELPERLESS_TARGETS` one
142
- * when it does. bulma-classes' class map holds the same release as
143
- * `classNameSince`.
144
- */
145
- export const CLASSNAME_SINCE = {
146
- 'Pagination.Ellipsis': '5.78.4',
147
- };
148
- export const HELPERLESS_TARGETS = new Set([
149
- 'Pagination.Previous',
150
- 'Pagination.Next',
151
- 'Navbar.Dropdown',
152
- 'Navbar.DropdownMenu',
153
- 'Navbar.Divider',
154
- 'Panel.Heading',
155
- 'Panel.Tabs',
156
- 'Panel.Block',
157
- 'Tabs.Item',
158
- 'Message.Header',
159
- 'Message.Body',
160
- 'Modal.Background',
161
- 'Modal.Content',
162
- 'Modal.Card',
163
- 'Modal.Card.Head',
164
- 'Modal.Card.Title',
165
- 'Modal.Card.Body',
166
- 'Modal.Card.Foot',
167
- 'Modal.Close',
168
- ]);
169
- /** The Bulma class a helper prop stood for, for the hint on those targets. */
170
129
  export function helperClassHint(name, value) {
171
130
  const v = typeof value === 'string' ? value : undefined;
172
131
  switch (name) {
@@ -707,7 +666,8 @@ export const MAPPING = {
707
666
  PageEllipsis: {
708
667
  status: 'mapped',
709
668
  target: 'Pagination.Ellipsis',
710
- // Classes, where the project gets the release in CLASSNAME_SINCE.
669
+ // Classes, where the project gets the release `CLASSNAME_SINCE` in
670
+ // `_shared/bestax-floor.ts` names.
711
671
  props: {
712
672
  isActive: { toClass: 'is-active' },
713
673
  isFocused: { toClass: 'is-focused' },
@@ -8,8 +8,9 @@
8
8
  * (isDisplay / isHidden / Column sizes) → component prop map →
9
9
  * universal helper props
10
10
  * 3. rewrite imports: drop bloomer, add one merged bestax-bulma import; keep
11
- * a trimmed bloomer import (with a TODO) only for components that have
12
- * no bestax equivalent (Tile, the Nav family, …)
11
+ * a trimmed bloomer import (with a TODO) only for what another TODO left
12
+ * using it, such as a component with no bestax equivalent (Tile, the Nav
13
+ * family, …)
13
14
  *
14
15
  * Anything unsafe gets a `// TODO(bestax-migrate)` comment on the enclosing
15
16
  * statement plus an entry in the run report.
@@ -1 +1 @@
1
- {"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../../src/sources/bloomer/transform.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAqDvD,MAAM,CAAC,OAAO,UAAU,SAAS,CAC/B,QAAQ,EAAE,QAAQ,EAClB,GAAG,EAAE,GAAG,EACR,OAAO,GAAE,gBAAqB,GAC7B,MAAM,GAAG,SAAS,CA4xBpB"}
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"}
@@ -8,8 +8,9 @@
8
8
  * (isDisplay / isHidden / Column sizes) → component prop map →
9
9
  * universal helper props
10
10
  * 3. rewrite imports: drop bloomer, add one merged bestax-bulma import; keep
11
- * a trimmed bloomer import (with a TODO) only for components that have
12
- * no bestax equivalent (Tile, the Nav family, …)
11
+ * a trimmed bloomer import (with a TODO) only for what another TODO left
12
+ * using it, such as a component with no bestax equivalent (Tile, the Nav
13
+ * family, …)
13
14
  *
14
15
  * Anything unsafe gets a `// TODO(bestax-migrate)` comment on the enclosing
15
16
  * statement plus an entry in the run report.
@@ -21,17 +22,16 @@
21
22
  * and most of them rename onto a dotted bestax compound; the rename and
22
23
  * value-reference passes below build those from the mapping's `target`.
23
24
  */
24
- import { CLASSNAME_SINCE, HELPERLESS_TARGETS, MAPPING, NO_CLASSNAME_TARGETS, UNIVERSAL_PROPS, helperClassHint, resolveMapping, } from './mapping.js';
25
- import { addTodo, attributesOf, forgetJsxParens, jsxNameParts, literalValueOf, removeAttr, renameElement, reprintDirectives, } from '../_shared/jsx-utils.js';
26
- import { applyPropAction, applyUniversalProps, mergeClass, } from '../_shared/props.js';
25
+ import { MAPPING, UNIVERSAL_PROPS, helperClassHint, resolveMapping, } from './mapping.js';
26
+ import { addTodo, attributesOf, forgetJsxParens, jsxNameParts, literalValueOf, removeAttr, renameElement, replaceChain, reprintDirectives, } from '../_shared/jsx-utils.js';
27
+ import { HELPERLESS_TARGETS, NO_CLASSNAME_TARGETS, applyPropAction, applyUniversalProps, mergeClass, } from '../_shared/props.js';
27
28
  import { enforcePolymorphicProps } from '../_shared/polymorphic.js';
28
29
  import { keepBaseDisplay } from '../_shared/display.js';
29
30
  import { askForModalName } from '../_shared/modal-name.js';
30
- import { bestaxValueLocals, buildBestaxImport, carryPrunedComments, placeBestaxImport, seedBestaxImport, } from '../_shared/bestax-import.js';
31
- import { bestaxFloorFor } from '../_shared/bestax-floor.js';
31
+ import { bestaxValueLocals, buildBestaxImport, carryPrunedComments, noteRetainedImport, placeBestaxImport, seedBestaxImport, } from '../_shared/bestax-import.js';
32
+ import { CLASSNAME_SINCE, bestaxFloorFor, classNameWaitsFor, heldForRelease, releaseHoldMessage, makeReferenceHold, releaseRaise, } from '../_shared/bestax-floor.js';
32
33
  import { rewriteStylesheetImports } from '../_shared/css-imports.js';
33
- import { compareVersions } from '../_shared/semver-range.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 */
@@ -274,23 +274,24 @@ export default function transform(fileInfo, api, options = {}) {
274
274
  // of its class, so a class cannot be written on either: every helper is
275
275
  // named instead, and anything else left on the divider would not compile.
276
276
  const since = CLASSNAME_SINCE[target];
277
- const sinceUnmet = since !== undefined &&
278
- !(bestaxFloor && compareVersions(bestaxFloor, since) >= 0);
279
- // What a TODO says about a release the project isn't sure to get.
280
- const raise = `bestax \`${target}\` keeps its own class beside a \`className\` from @allxsmith/bestax-bulma ${since} on, and this project isn't sure to get ${since}`;
277
+ const sinceUnmet = classNameWaitsFor(target, bestaxFloor) !== undefined;
278
+ const raise = releaseRaise(target, since);
279
+ // A `className` of its own, or a spread that may carry one, would
280
+ // replace that class. Keep bloomer's element.
281
+ const held = heldForRelease(element, target, bestaxFloor);
282
+ if (held) {
283
+ ctx.retained.add(sourcePath[0]);
284
+ addTodo(ctx, path, `component:${dotted}`, releaseHoldMessage(target, held, 'bloomer'));
285
+ return;
286
+ }
281
287
  if (NO_CLASSNAME_TARGETS.has(target) || sinceUnmet) {
282
- // A spread may carry a `className` that would replace the structural
283
- // class, or props `Dropdown.Divider` silently ignores, and the codemod
284
- // cannot read inside it. Keep bloomer's element.
285
- const spread = (element.openingElement.attributes ?? []).some((a) => a.type === 'JSXSpreadAttribute');
286
- // A `className` of its own would replace that class too.
287
- const ownClass = sinceUnmet &&
288
- attributesOf(element).some((a) => a.name.name === 'className');
289
- if (spread || ownClass) {
288
+ // A spread may carry props `Dropdown.Divider` silently ignores, and
289
+ // the codemod cannot read inside it. Keep bloomer's element.
290
+ const spread = NO_CLASSNAME_TARGETS.has(target) &&
291
+ (element.openingElement.attributes ?? []).some((a) => a.type === 'JSXSpreadAttribute');
292
+ if (spread) {
290
293
  ctx.retained.add(sourcePath[0]);
291
- addTodo(ctx, path, `component:${dotted}`, sinceUnmet
292
- ? `${raise}, and this element carries ${spread ? 'a spread whose contents the codemod cannot read, where a `className` would replace that class' : 'a `className`, which would replace that class'}, so it stays bloomer's: declare \`@allxsmith/bestax-bulma\` at \`^${since}\` or later and re-run`
293
- : `bestax \`${target}\` takes no props at all, and this element carries a spread whose contents the codemod cannot read, so it stays bloomer's`);
294
+ addTodo(ctx, path, `component:${dotted}`, `bestax \`${target}\` takes no props at all, and this element carries a spread whose contents the codemod cannot read, so it stays bloomer's`);
294
295
  return;
295
296
  }
296
297
  for (const attr of [...attributesOf(element)]) {
@@ -404,6 +405,13 @@ export default function transform(fileInfo, api, options = {}) {
404
405
  // generic "referenced as a value" branch, emitting a spurious TODO and
405
406
  // marking the root retained when it was not.
406
407
  const handledValueRefs = new WeakSet();
408
+ // A reference to a target that waits for a release stays bloomer's.
409
+ const heldReference = makeReferenceHold(ctx, bestaxFloor, 'bloomer', imported => {
410
+ if (imported === '*')
411
+ namespaceStillReferenced = true;
412
+ else
413
+ ctx.retained.add(imported);
414
+ });
407
415
  root.find(j.Identifier).forEach(path => {
408
416
  // find(Identifier) also matches JSXIdentifier (a subtype) — JSX names
409
417
  // were already handled by the element walker above.
@@ -435,6 +443,10 @@ export default function transform(fileInfo, api, options = {}) {
435
443
  // runtime, so it is not a value use of the namespace at all.
436
444
  if (parentType === 'TSQualifiedName')
437
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;
438
450
  // A namespace binding in a real value position. `bloomer.Button` is still a
439
451
  // mappable component reference, so fall through to the member-expression
440
452
  // branch below with an empty prefix (the namespace itself is not part of
@@ -453,8 +465,6 @@ export default function transform(fileInfo, api, options = {}) {
453
465
  // target keeps the public name (\`export { SubTitle as Subtitle }\`), a
454
466
  // dotted one cannot be re-exported under a member name and is flagged.
455
467
  if (parentType === 'ExportSpecifier') {
456
- if (parentNode.local !== path.node)
457
- return;
458
468
  const exportedName = nameOf(parentNode.exported ?? parentNode.local);
459
469
  const mapping = MAPPING[imported];
460
470
  if (mapping &&
@@ -511,8 +521,10 @@ export default function transform(fileInfo, api, options = {}) {
511
521
  outer.node.property?.type === 'Identifier') {
512
522
  memberPath.push(nameOf(outer.node.property));
513
523
  const next = outer.parent;
524
+ // Not into `[…]`, which the rebuilt chain would drop.
514
525
  if (next?.node?.type === 'MemberExpression' &&
515
- next.node.object === outer.node) {
526
+ next.node.object === outer.node &&
527
+ !next.node.computed) {
516
528
  outer = next;
517
529
  }
518
530
  else {
@@ -528,6 +540,8 @@ export default function transform(fileInfo, api, options = {}) {
528
540
  memberMapping.status !== 'todo' &&
529
541
  memberMapping.target &&
530
542
  !memberMapping.special) {
543
+ if (heldReference(outer, memberMapping.target, imported))
544
+ return;
531
545
  // `B.CardHeaderTitle` → `Card.Header.Title`: the namespace prefix has
532
546
  // to go and the target may be dotted, so rebuild the whole chain from
533
547
  // the target rather than renaming anything in place.
@@ -536,7 +550,7 @@ export default function transform(fileInfo, api, options = {}) {
536
550
  for (const part of targetRest) {
537
551
  rebuilt = j.memberExpression(rebuilt, j.identifier(part));
538
552
  }
539
- outer.replace(rebuilt);
553
+ replaceChain(outer, rebuilt, handledValueRefs);
540
554
  ctx.dirty = true;
541
555
  return;
542
556
  }
@@ -562,6 +576,11 @@ export default function transform(fileInfo, api, options = {}) {
562
576
  if (shorthandMapping &&
563
577
  shorthandMapping.status !== 'todo' &&
564
578
  shorthandMapping.target) {
579
+ if (heldReference(path, shorthandMapping.target, imported)) {
580
+ handledValueRefs.add(parentNode.key);
581
+ handledValueRefs.add(parentNode.value);
582
+ return;
583
+ }
565
584
  const [root, ...rest] = shorthandMapping.target.split('.');
566
585
  const local = ctx.reserve(root);
567
586
  let value = j.identifier(local);
@@ -599,6 +618,8 @@ export default function transform(fileInfo, api, options = {}) {
599
618
  // bestax component (`const Old = Icon` → bestax's Icon). Only a
600
619
  // target-less special (NavbarItem, Help, …) has nothing to rename to.
601
620
  if (mapping && mapping.status !== 'todo' && mapping.target) {
621
+ if (heldReference(path, mapping.target, imported))
622
+ return;
602
623
  const [root, ...rest] = mapping.target.split('.');
603
624
  const local = ctx.reserve(root);
604
625
  if (rest.length > 0) {
@@ -625,7 +646,6 @@ export default function transform(fileInfo, api, options = {}) {
625
646
  });
626
647
  // ---- 3. Rewrite imports -----------------------------------------------
627
648
  if (imports.size > 0) {
628
- const retainedNames = [...ctx.retained].sort((a, b) => a.localeCompare(b));
629
649
  const bestaxImport = buildBestaxImport(ctx, bestaxImportState);
630
650
  let inserted = false;
631
651
  // A retained bloomer specifier must never collide with a bestax import local
@@ -661,16 +681,7 @@ export default function transform(fileInfo, api, options = {}) {
661
681
  }
662
682
  if (keepSpecifiers.length > 0) {
663
683
  node.specifiers = keepSpecifiers;
664
- // Only when named/namespace bindings are being retained. An import
665
- // kept solely for a broken default binding has no names to list, and
666
- // already carries its own "bloomer has no default export" TODO.
667
- if (retainedNames.length > 0) {
668
- node.comments = node.comments ?? [];
669
- const text = ` TODO(bestax-migrate): ${retainedNames.join(', ')} ${retainedNames.length === 1 ? 'has' : 'have'} no bestax-bulma equivalent yet — migrate and remove this import`;
670
- if (!node.comments.some((c) => c.value === text)) {
671
- node.comments.push(j.commentLine(text, true, false));
672
- }
673
- }
684
+ noteRetainedImport(ctx, path, ctx.retained);
674
685
  }
675
686
  else {
676
687
  carryPrunedComments(node, path, bestaxImportState.existing?.node ?? bestaxImport);
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * package.json migration for an app that styled plain markup with Bulma:
3
- * bestax-bulma comes in, and nothing goes out. Pure data-in/data-out: no
4
- * package manager is ever invoked.
3
+ * bestax-bulma comes in, and nothing goes out. No package manager is ever
4
+ * invoked.
5
5
  *
6
6
  * Under the default `--css keep` the app's styling stack is left as it is:
7
7
  * converted elements render the same classes, which the app's own Bulma