bestax-migrate 2.32.1 → 2.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/sources/bulma-classes/class-map.d.ts +41 -11
- package/dist/sources/bulma-classes/class-map.d.ts.map +1 -1
- package/dist/sources/bulma-classes/class-map.js +101 -4
- package/dist/sources/bulma-classes/glyph.d.ts +22 -7
- package/dist/sources/bulma-classes/glyph.d.ts.map +1 -1
- package/dist/sources/bulma-classes/glyph.js +50 -20
- package/dist/sources/bulma-classes/html-assets.d.ts.map +1 -1
- package/dist/sources/bulma-classes/html-assets.js +5 -3
- package/dist/sources/bulma-classes/html.d.ts +3 -2
- package/dist/sources/bulma-classes/html.d.ts.map +1 -1
- package/dist/sources/bulma-classes/html.js +37 -19
- package/dist/sources/bulma-classes/plan.d.ts +25 -2
- package/dist/sources/bulma-classes/plan.d.ts.map +1 -1
- package/dist/sources/bulma-classes/plan.js +108 -11
- package/dist/sources/bulma-classes/transform.d.ts +20 -2
- package/dist/sources/bulma-classes/transform.d.ts.map +1 -1
- package/dist/sources/bulma-classes/transform.js +113 -11
- package/package.json +2 -2
|
@@ -9,9 +9,14 @@
|
|
|
9
9
|
* library and compared with the raw markup it replaces. The exceptions are
|
|
10
10
|
* on purpose. Font Awesome's own `<i aria-hidden="true">` alone in a `.icon`
|
|
11
11
|
* that carries nothing assistive tech reads converts to `Icon`, which writes
|
|
12
|
-
* the attribute on the `.icon` instead, since the glyph is hidden either way
|
|
13
|
-
*
|
|
14
|
-
*
|
|
12
|
+
* the attribute on the `.icon` instead, since the glyph is hidden either way;
|
|
13
|
+
* a `.icon` around a bare glyph in a link or button its own label names
|
|
14
|
+
* converts too, and `Icon` writes the attribute it doesn't carry, since that
|
|
15
|
+
* label is what assistive tech reads for the control; and Font Awesome 6's
|
|
16
|
+
* long name for a style (`fa-brands`) is written as the skill's `variant`,
|
|
17
|
+
* which `Icon` renders as the short one (`fab`), the same style (see
|
|
18
|
+
* `readsGlyph`). And a Bulma 0.9 helper v1 removed, which styles nothing
|
|
19
|
+
* under v1, converts as the v1 helper that does its job (see
|
|
15
20
|
* `REPLACED_IN_V1`).
|
|
16
21
|
*
|
|
17
22
|
* Data only: `scripts/gen-mcp-index.mjs` imports it directly for the MCP
|
|
@@ -166,13 +171,14 @@ export interface Absorbs {
|
|
|
166
171
|
export interface ReadsGlyph {
|
|
167
172
|
/**
|
|
168
173
|
* The attributes the element may carry and still take Font Awesome's
|
|
169
|
-
* `aria-hidden` up off its `<i
|
|
170
|
-
*
|
|
171
|
-
*
|
|
172
|
-
*
|
|
173
|
-
*
|
|
174
|
-
*
|
|
175
|
-
*
|
|
174
|
+
* `aria-hidden` up off its `<i>`, or take the one the target writes on an
|
|
175
|
+
* icon in a link or button its own label names: ones the target renders
|
|
176
|
+
* as given that assistive tech doesn't read, a name ending in `*` standing
|
|
177
|
+
* for every attribute it starts. Read by name, whatever the value, since
|
|
178
|
+
* an expression may render as anything. Anything else (a name, a
|
|
179
|
+
* description, a `title`, a `role`, a `tabIndex`, a handler) keeps the
|
|
180
|
+
* element as it is: the attribute would hide what it exposes, and `Icon`
|
|
181
|
+
* writes no `aria-hidden` beside a `role` or `tabIndex` at all.
|
|
176
182
|
*/
|
|
177
183
|
readonly hiddenMovesBeside: readonly string[];
|
|
178
184
|
}
|
|
@@ -339,7 +345,9 @@ export interface RootEntry {
|
|
|
339
345
|
* the `aria-hidden` the target writes, as Font Awesome's own markup does,
|
|
340
346
|
* reads too when the element carries nothing assistive tech reads: the
|
|
341
347
|
* attribute moves up onto it, a difference in markup a conversion makes
|
|
342
|
-
* on purpose.
|
|
348
|
+
* on purpose. So does a bare `<i>` in an element that carries no
|
|
349
|
+
* `aria-hidden` and nothing else assistive tech reads, in a link or button
|
|
350
|
+
* its own label names: the target writes the attribute there.
|
|
343
351
|
*/
|
|
344
352
|
readonly readsGlyph?: ReadsGlyph;
|
|
345
353
|
/**
|
|
@@ -480,6 +488,28 @@ export declare const FORWARDS_REF: readonly string[];
|
|
|
480
488
|
export declare const WRAPPERS: Readonly<Record<string, string>>;
|
|
481
489
|
/** The wrappers' own props, as `ROOTS` lists them for the components. */
|
|
482
490
|
export declare const WRAPPER_OWN_PROPS: Readonly<Record<string, readonly string[]>>;
|
|
491
|
+
/**
|
|
492
|
+
* Plain tags a bestax component renders as they are, with no class of its
|
|
493
|
+
* own, that this source leaves as markup all the same: it converts a table's
|
|
494
|
+
* `.table` and not the rows and cells inside it. Never read by the codemod.
|
|
495
|
+
* The MCP lookup names the component for one of these, which would otherwise
|
|
496
|
+
* say bestax has no component for the tag (#1236), and the index carries the
|
|
497
|
+
* props each takes beside the helper props, read off its record.
|
|
498
|
+
*/
|
|
499
|
+
export declare const BY_HAND: Readonly<Record<string, string>>;
|
|
500
|
+
/**
|
|
501
|
+
* Classes no Bulma 1 rule matches that a page takes from another stylesheet
|
|
502
|
+
* it loads, grouped by that stylesheet, each with what to do about them. The
|
|
503
|
+
* codemod leaves a class it doesn't convert where it is, so it never reads
|
|
504
|
+
* these; the MCP lookup does, for a class Bulma 1's stylesheet lacks, which
|
|
505
|
+
* it would otherwise call a class nothing styles (#1236). A `glyph` group's
|
|
506
|
+
* classes name an icon font's glyph, which bestax `Icon` writes from props.
|
|
507
|
+
*/
|
|
508
|
+
export declare const ELSEWHERE: ReadonlyArray<{
|
|
509
|
+
readonly why: string;
|
|
510
|
+
readonly match: RegExp;
|
|
511
|
+
readonly glyph?: boolean;
|
|
512
|
+
}>;
|
|
483
513
|
/**
|
|
484
514
|
* Every class Bulma 0.9.4's compiled stylesheet has and v1's does not, read
|
|
485
515
|
* off the two with the class walk `e2e/bulma-classes-vocabulary.test.ts`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"class-map.d.ts","sourceRoot":"","sources":["../../../src/sources/bulma-classes/class-map.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"class-map.d.ts","sourceRoot":"","sources":["../../../src/sources/bulma-classes/class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;;GAGG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAGlE;AAED,qCAAqC;AACrC,wBAAgB,WAAW,CACzB,KAAK,EAAE,SAAS,EAChB,KAAK,EAAE,MAAM,GACZ,QAAQ,GAAG,SAAS,CAEtB;AAED,0EAA0E;AAC1E,wBAAgB,YAAY,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAKrE;AAED,wEAAwE;AACxE,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAI7D;AAED,kDAAkD;AAClD,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAE5D;AAED,4DAA4D;AAC5D,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAE5D;AAED,0CAA0C;AAC1C,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAE1D"}
|
|
@@ -9,9 +9,14 @@
|
|
|
9
9
|
* library and compared with the raw markup it replaces. The exceptions are
|
|
10
10
|
* on purpose. Font Awesome's own `<i aria-hidden="true">` alone in a `.icon`
|
|
11
11
|
* that carries nothing assistive tech reads converts to `Icon`, which writes
|
|
12
|
-
* the attribute on the `.icon` instead, since the glyph is hidden either way
|
|
13
|
-
*
|
|
14
|
-
*
|
|
12
|
+
* the attribute on the `.icon` instead, since the glyph is hidden either way;
|
|
13
|
+
* a `.icon` around a bare glyph in a link or button its own label names
|
|
14
|
+
* converts too, and `Icon` writes the attribute it doesn't carry, since that
|
|
15
|
+
* label is what assistive tech reads for the control; and Font Awesome 6's
|
|
16
|
+
* long name for a style (`fa-brands`) is written as the skill's `variant`,
|
|
17
|
+
* which `Icon` renders as the short one (`fab`), the same style (see
|
|
18
|
+
* `readsGlyph`). And a Bulma 0.9 helper v1 removed, which styles nothing
|
|
19
|
+
* under v1, converts as the v1 helper that does its job (see
|
|
15
20
|
* `REPLACED_IN_V1`).
|
|
16
21
|
*
|
|
17
22
|
* Data only: `scripts/gen-mcp-index.mjs` imports it directly for the MCP
|
|
@@ -1405,7 +1410,11 @@ export const ROOTS = {
|
|
|
1405
1410
|
ownProps: ['variant', 'lines'],
|
|
1406
1411
|
},
|
|
1407
1412
|
// ---- Families bestax has but that do not map element by element yet ------
|
|
1408
|
-
|
|
1413
|
+
// `Checkbox` renders a `<label class="styled-checkbox checkbox">` around
|
|
1414
|
+
// its `<input>`, hidden, and a box of its own drawn beside it. It puts its
|
|
1415
|
+
// `className` on the `<label>` and the rest of what it's given on the
|
|
1416
|
+
// `<input>`, and its `indeterminate` sets the input's mixed state.
|
|
1417
|
+
checkbox: todo('Checkbox', "bestax `Checkbox` renders its own styled markup, not Bulma's. Write it by hand in place of the element that carries `.checkbox`, Bulma's `<label>` or a bare `<input>`, with the `<input>`'s attributes on it: `id`, `name`, `aria-label` and the rest reach its `<input>`, and a `<label>`'s text is its children. Drive it with `checked` and `onChange`, and add `indeterminate` for a select-all box. Its `className` goes on its `<label>`, which declares the `--bulma-checkbox-*` variables, so set the page's colors with those in a rule for your class beside `.styled-checkbox`. Where the page put `.checkbox` on a bare `<input>`, drop its own rules for that box, since bestax draws its own and `.checkbox` is on its `<label>` now"),
|
|
1409
1418
|
checkboxes: todo('Checkboxes', 'bestax `Checkboxes` renders its own `.field` and `.control` wrappers'),
|
|
1410
1419
|
radio: todo('Radio', "bestax `Radio` renders its own styled markup, not Bulma's"),
|
|
1411
1420
|
radios: todo('Radios', 'bestax `Radios` renders its own `.field` and `.control` wrappers'),
|
|
@@ -1483,6 +1492,16 @@ export const ROOTS = {
|
|
|
1483
1492
|
tag: 'span',
|
|
1484
1493
|
readsGlyph: { hiddenMovesBeside: ['id', 'style', 'key', 'data-*'] },
|
|
1485
1494
|
modifiers: tokens('is-', ['small', 'medium', 'large'], 'size'),
|
|
1495
|
+
// Bulma places an icon with these inside a `.control` that has icons on
|
|
1496
|
+
// that side, and `Control` renders that icon itself from a prop, which
|
|
1497
|
+
// writes the class with the rest of the icon. On `Icon` the class stays.
|
|
1498
|
+
omits: Object.fromEntries(['left', 'right'].map(side => {
|
|
1499
|
+
const prop = side === 'left' ? 'iconLeft' : 'iconRight';
|
|
1500
|
+
return [
|
|
1501
|
+
`is-${side}`,
|
|
1502
|
+
`Bulma places it inside a \`.control\` with \`has-icons-${side}\`, and bestax \`Control\` renders that icon itself from \`${prop}\` (\`${prop}={{ library: "fa", name: "envelope", size: "small" }}\`), after its children, so a hidden \`.icon\` there can go as that prop; on \`Icon\` the class stays in \`className\`, which renders the same`,
|
|
1503
|
+
];
|
|
1504
|
+
})),
|
|
1486
1505
|
defaults: { 'aria-hidden': 'true' },
|
|
1487
1506
|
namedDefaults: {
|
|
1488
1507
|
by: ['aria-label', 'aria-labelledby'],
|
|
@@ -2110,6 +2129,84 @@ export const WRAPPER_OWN_PROPS = {
|
|
|
2110
2129
|
UnorderedList: ['textColor', 'bgColor'],
|
|
2111
2130
|
Figure: ['textColor', 'bgColor'],
|
|
2112
2131
|
};
|
|
2132
|
+
/**
|
|
2133
|
+
* Plain tags a bestax component renders as they are, with no class of its
|
|
2134
|
+
* own, that this source leaves as markup all the same: it converts a table's
|
|
2135
|
+
* `.table` and not the rows and cells inside it. Never read by the codemod.
|
|
2136
|
+
* The MCP lookup names the component for one of these, which would otherwise
|
|
2137
|
+
* say bestax has no component for the tag (#1236), and the index carries the
|
|
2138
|
+
* props each takes beside the helper props, read off its record.
|
|
2139
|
+
*/
|
|
2140
|
+
export const BY_HAND = {
|
|
2141
|
+
thead: 'Table.Thead',
|
|
2142
|
+
tbody: 'Table.Tbody',
|
|
2143
|
+
tfoot: 'Table.Tfoot',
|
|
2144
|
+
tr: 'Table.Tr',
|
|
2145
|
+
th: 'Table.Th',
|
|
2146
|
+
td: 'Table.Td',
|
|
2147
|
+
};
|
|
2148
|
+
/**
|
|
2149
|
+
* The bulma-social brand colors, the classes it adds to Bulma's `.button`,
|
|
2150
|
+
* across its majors: read off the stylesheet each publishes (`css/all.css`
|
|
2151
|
+
* in 2 and 3, `bin/bulma-social.css` in 1). Nothing here installs it, so a
|
|
2152
|
+
* brand a later release adds is missing until it is added here.
|
|
2153
|
+
*/
|
|
2154
|
+
const BULMA_SOCIAL = [
|
|
2155
|
+
'apple',
|
|
2156
|
+
'bitbucket',
|
|
2157
|
+
'discord',
|
|
2158
|
+
'dropbox',
|
|
2159
|
+
'facebook',
|
|
2160
|
+
'flickr',
|
|
2161
|
+
'foursquare',
|
|
2162
|
+
'github',
|
|
2163
|
+
'gitlab',
|
|
2164
|
+
'instagram',
|
|
2165
|
+
'linkedin',
|
|
2166
|
+
'microsoft',
|
|
2167
|
+
'odnoklassniki',
|
|
2168
|
+
'openid',
|
|
2169
|
+
'pinterest',
|
|
2170
|
+
'reddit',
|
|
2171
|
+
'slack',
|
|
2172
|
+
'soundcloud',
|
|
2173
|
+
'tumblr',
|
|
2174
|
+
'twitch',
|
|
2175
|
+
'twitter',
|
|
2176
|
+
'vimeo',
|
|
2177
|
+
'vk',
|
|
2178
|
+
'x',
|
|
2179
|
+
'yahoo',
|
|
2180
|
+
'youtube',
|
|
2181
|
+
];
|
|
2182
|
+
/**
|
|
2183
|
+
* Classes no Bulma 1 rule matches that a page takes from another stylesheet
|
|
2184
|
+
* it loads, grouped by that stylesheet, each with what to do about them. The
|
|
2185
|
+
* codemod leaves a class it doesn't convert where it is, so it never reads
|
|
2186
|
+
* these; the MCP lookup does, for a class Bulma 1's stylesheet lacks, which
|
|
2187
|
+
* it would otherwise call a class nothing styles (#1236). A `glyph` group's
|
|
2188
|
+
* classes name an icon font's glyph, which bestax `Icon` writes from props.
|
|
2189
|
+
*/
|
|
2190
|
+
export const ELSEWHERE = [
|
|
2191
|
+
{
|
|
2192
|
+
why: "a Font Awesome class: Font Awesome's own stylesheet styles it, not Bulma's, so keep loading Font Awesome (the bestax-migrate skill's `html-asset:font-awesome` says how). bestax `Icon` writes these classes from its props, on the <i> it renders inside a `.icon`",
|
|
2193
|
+
match: /^(?:fa|fa[srbldt]|fa-[a-z0-9]+(?:-[a-z0-9]+)*|svg-inline--fa)$/,
|
|
2194
|
+
glyph: true,
|
|
2195
|
+
},
|
|
2196
|
+
{
|
|
2197
|
+
why: 'a Material Design Icons class: its own stylesheet styles it, not Bulma\'s, so keep loading it. bestax `Icon` writes these classes from its props, with `library="mdi"`, on the <i> it renders inside a `.icon`',
|
|
2198
|
+
match: /^mdi(?:-[a-z0-9]+)*$/,
|
|
2199
|
+
glyph: true,
|
|
2200
|
+
},
|
|
2201
|
+
{
|
|
2202
|
+
why: "a bulma-social class, a Bulma extension's brand color for Bulma's `.button`, which bestax's `Button` renders: keep loading bulma-social and keep the class on `Button` in `className`, since bestax has no component for it (the bestax-migrate skill's `html-asset:bulma-extension` has the recipe)",
|
|
2203
|
+
match: new RegExp(`^is-(?:${BULMA_SOCIAL.join('|')}|animated)$`),
|
|
2204
|
+
},
|
|
2205
|
+
{
|
|
2206
|
+
why: "a bulma-carousel class, a Bulma extension bestax's `Carousel` does the job of (the bestax-migrate skill's `html-asset:bulma-extension` says how). Once the page stops loading bulma-carousel nothing styles it: `is-covered`'s `object-fit: cover` on a slide's image goes in the app's own CSS",
|
|
2207
|
+
match: /^(?:has-carousel|hero-carousel|is-background|is-covered|slider-(?:container|item|navigation-next|navigation-previous|page|pagination)|video-container)$/,
|
|
2208
|
+
},
|
|
2209
|
+
];
|
|
2113
2210
|
/**
|
|
2114
2211
|
* Every class Bulma 0.9.4's compiled stylesheet has and v1's does not, read
|
|
2115
2212
|
* off the two with the class walk `e2e/bulma-classes-vocabulary.test.ts`
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Read an icon's glyph, the `<i>` inside a `.icon`, as the props bestax
|
|
3
|
-
* `Icon` builds it from
|
|
4
|
-
* given those props, renders that `<i>`
|
|
5
|
-
*
|
|
6
|
-
* `
|
|
3
|
+
* `Icon` builds it from, spelled the way the bestax-icons skill writes them.
|
|
4
|
+
* Pure: a glyph reads only when `Icon`, given those props, renders that `<i>`
|
|
5
|
+
* with exactly its classes and nothing else, but for one exception on
|
|
6
|
+
* purpose. Font Awesome 6's long name for a style (`fa-brands`) is written as
|
|
7
|
+
* the skill's `variant` (`brands`), which `Icon` renders as the short name
|
|
8
|
+
* (`fab`), the same style in 6 and 7 (`longStyle` says so). `library` is left
|
|
9
|
+
* out for Font Awesome, `Icon`'s default, as the skill writes it: like every
|
|
10
|
+
* conversion, this assumes no `ConfigProvider` sets another default (its
|
|
11
|
+
* `iconLibrary` here, as its `classPrefix` would for any component).
|
|
7
12
|
*/
|
|
8
13
|
import type { ChildFacts } from './plan.js';
|
|
9
14
|
export interface Glyph {
|
|
@@ -13,6 +18,13 @@ export interface Glyph {
|
|
|
13
18
|
variant?: string;
|
|
14
19
|
/** The glyph's other classes, which `Icon` renders after its own. */
|
|
15
20
|
features?: string[];
|
|
21
|
+
/**
|
|
22
|
+
* The long name of Font Awesome's style the `<i>` was written with
|
|
23
|
+
* (`fa-brands`), when `variant` is the skill's name for it, which `Icon`
|
|
24
|
+
* renders as the short one (`fab`): a way a conversion's markup differs
|
|
25
|
+
* on purpose. The render tests compare it with the short name restated.
|
|
26
|
+
*/
|
|
27
|
+
longStyle?: string;
|
|
16
28
|
}
|
|
17
29
|
/**
|
|
18
30
|
* The props `Icon` renders this glyph from, or undefined when it can't: the
|
|
@@ -28,8 +40,9 @@ export declare function readGlyph(glyph: ChildFacts | undefined): Glyph | undefi
|
|
|
28
40
|
*/
|
|
29
41
|
export declare function readHiddenGlyph(glyph: ChildFacts | undefined): Glyph | undefined;
|
|
30
42
|
/**
|
|
31
|
-
* A glyph as the props `Icon` is given, in the order they're written:
|
|
32
|
-
*
|
|
43
|
+
* A glyph as the props `Icon` is given, in the order they're written: no
|
|
44
|
+
* `library` for Font Awesome, `Icon`'s default, and one feature as a string,
|
|
45
|
+
* more than one as a list.
|
|
33
46
|
*/
|
|
34
47
|
export declare function glyphProps(glyph: Glyph): Array<[name: string, value: string | readonly string[]]>;
|
|
35
48
|
/**
|
|
@@ -37,7 +50,9 @@ export declare function glyphProps(glyph: Glyph): Array<[name: string, value: st
|
|
|
37
50
|
* as the props `Icon` renders the `<i>` it was drawn from: the name from its
|
|
38
51
|
* `data-icon` (else its one class naming a glyph), the style from its
|
|
39
52
|
* `data-prefix`, and its other classes but the width one the script adds.
|
|
40
|
-
*
|
|
53
|
+
* The script is Font Awesome 5's or later, which reads the `fa` prefix as
|
|
54
|
+
* solid, so that one is `Icon`'s default here. For advice only: `Icon`
|
|
55
|
+
* renders that `<i>`, never the `<svg>`.
|
|
41
56
|
*/
|
|
42
57
|
export declare function readDrawnGlyph(svg: ChildFacts | undefined): Glyph | undefined;
|
|
43
58
|
//# sourceMappingURL=glyph.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"glyph.d.ts","sourceRoot":"","sources":["../../../src/sources/bulma-classes/glyph.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"glyph.d.ts","sourceRoot":"","sources":["../../../src/sources/bulma-classes/glyph.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE5C,MAAM,WAAW,KAAK;IACpB,OAAO,EAAE,IAAI,GAAG,KAAK,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,kEAAkE;IAClE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,qEAAqE;IACrE,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAuGD;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,UAAU,GAAG,SAAS,GAAG,KAAK,GAAG,SAAS,CAsC1E;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,UAAU,GAAG,SAAS,GAC5B,KAAK,GAAG,SAAS,CAMnB;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CACxB,KAAK,EAAE,KAAK,GACX,KAAK,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAAC,CAAC,CAiB1D;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,UAAU,GAAG,SAAS,GAAG,KAAK,GAAG,SAAS,CA0B7E"}
|
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Read an icon's glyph, the `<i>` inside a `.icon`, as the props bestax
|
|
3
|
-
* `Icon` builds it from
|
|
4
|
-
* given those props, renders that `<i>`
|
|
5
|
-
*
|
|
6
|
-
* `
|
|
3
|
+
* `Icon` builds it from, spelled the way the bestax-icons skill writes them.
|
|
4
|
+
* Pure: a glyph reads only when `Icon`, given those props, renders that `<i>`
|
|
5
|
+
* with exactly its classes and nothing else, but for one exception on
|
|
6
|
+
* purpose. Font Awesome 6's long name for a style (`fa-brands`) is written as
|
|
7
|
+
* the skill's `variant` (`brands`), which `Icon` renders as the short name
|
|
8
|
+
* (`fab`), the same style in 6 and 7 (`longStyle` says so). `library` is left
|
|
9
|
+
* out for Font Awesome, `Icon`'s default, as the skill writes it: like every
|
|
10
|
+
* conversion, this assumes no `ConfigProvider` sets another default (its
|
|
11
|
+
* `iconLibrary` here, as its `classPrefix` would for any component).
|
|
7
12
|
*/
|
|
8
13
|
/**
|
|
9
|
-
* Font Awesome's style classes
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
14
|
+
* Font Awesome's style classes, as the `variant` the bestax-icons skill
|
|
15
|
+
* writes for each. `Icon` renders its `variant` through a table of the
|
|
16
|
+
* skill's names (`regular` as `far`), and as written otherwise, so `fa`, Font
|
|
17
|
+
* Awesome 4's, reads as itself: 4 styles nothing else, and 5 and later read
|
|
18
|
+
* it as solid. `fas` is `Icon`'s default.
|
|
13
19
|
*/
|
|
14
20
|
const FA_STYLES = {
|
|
15
21
|
fas: undefined,
|
|
@@ -19,13 +25,29 @@ const FA_STYLES = {
|
|
|
19
25
|
fad: 'duotone',
|
|
20
26
|
fat: 'thin',
|
|
21
27
|
fa: 'fa',
|
|
22
|
-
'fa-solid':
|
|
23
|
-
'fa-regular': '
|
|
24
|
-
'fa-brands': '
|
|
25
|
-
'fa-light': '
|
|
26
|
-
'fa-thin': '
|
|
27
|
-
'fa-duotone': '
|
|
28
|
+
'fa-solid': undefined,
|
|
29
|
+
'fa-regular': 'regular',
|
|
30
|
+
'fa-brands': 'brands',
|
|
31
|
+
'fa-light': 'light',
|
|
32
|
+
'fa-thin': 'thin',
|
|
33
|
+
'fa-duotone': 'duotone',
|
|
28
34
|
};
|
|
35
|
+
/**
|
|
36
|
+
* Font Awesome 6's long names for its styles, which `Icon` writes as the
|
|
37
|
+
* short ones (`fab`) once read as the skill's `variant`. Font Awesome 6
|
|
38
|
+
* styles an `<i>` the same either way, and 7 does too, but that its short
|
|
39
|
+
* names also set the classic family: so beside `fa-sharp`, which sets
|
|
40
|
+
* another, the long name is kept as written. 5 and older have no long
|
|
41
|
+
* names.
|
|
42
|
+
*/
|
|
43
|
+
const LONG_STYLES = new Set([
|
|
44
|
+
'fa-solid',
|
|
45
|
+
'fa-regular',
|
|
46
|
+
'fa-brands',
|
|
47
|
+
'fa-light',
|
|
48
|
+
'fa-thin',
|
|
49
|
+
'fa-duotone',
|
|
50
|
+
]);
|
|
29
51
|
/** Font Awesome's classes that modify a glyph rather than name one. */
|
|
30
52
|
const FA_MODIFIERS = new Set([
|
|
31
53
|
'fa-2xs',
|
|
@@ -105,12 +127,15 @@ export function readGlyph(glyph) {
|
|
|
105
127
|
const named = nameIn(tokens, 'fa-', FA_MODIFIERS, style);
|
|
106
128
|
if (!named)
|
|
107
129
|
return undefined;
|
|
108
|
-
|
|
130
|
+
// Beside another family, the long name stays as written (`LONG_STYLES`).
|
|
131
|
+
const long = LONG_STYLES.has(style) && !tokens.includes('fa-sharp');
|
|
132
|
+
const variant = long || !LONG_STYLES.has(style) ? FA_STYLES[style] : style;
|
|
109
133
|
return {
|
|
110
134
|
library: 'fa',
|
|
111
135
|
name: named.name,
|
|
112
136
|
...(variant && { variant }),
|
|
113
137
|
...(named.features.length > 0 && { features: named.features }),
|
|
138
|
+
...(long && { longStyle: style }),
|
|
114
139
|
};
|
|
115
140
|
}
|
|
116
141
|
if (mdi && styles.length === 0) {
|
|
@@ -139,13 +164,16 @@ export function readHiddenGlyph(glyph) {
|
|
|
139
164
|
return readGlyph({ ...glyph, attributes: new Map() });
|
|
140
165
|
}
|
|
141
166
|
/**
|
|
142
|
-
* A glyph as the props `Icon` is given, in the order they're written:
|
|
143
|
-
*
|
|
167
|
+
* A glyph as the props `Icon` is given, in the order they're written: no
|
|
168
|
+
* `library` for Font Awesome, `Icon`'s default, and one feature as a string,
|
|
169
|
+
* more than one as a list.
|
|
144
170
|
*/
|
|
145
171
|
export function glyphProps(glyph) {
|
|
146
172
|
const { features } = glyph;
|
|
147
173
|
return [
|
|
148
|
-
|
|
174
|
+
...(glyph.library === 'fa'
|
|
175
|
+
? []
|
|
176
|
+
: [['library', glyph.library]]),
|
|
149
177
|
['name', glyph.name],
|
|
150
178
|
...(glyph.variant ? [['variant', glyph.variant]] : []),
|
|
151
179
|
...(features
|
|
@@ -160,7 +188,9 @@ export function glyphProps(glyph) {
|
|
|
160
188
|
* as the props `Icon` renders the `<i>` it was drawn from: the name from its
|
|
161
189
|
* `data-icon` (else its one class naming a glyph), the style from its
|
|
162
190
|
* `data-prefix`, and its other classes but the width one the script adds.
|
|
163
|
-
*
|
|
191
|
+
* The script is Font Awesome 5's or later, which reads the `fa` prefix as
|
|
192
|
+
* solid, so that one is `Icon`'s default here. For advice only: `Icon`
|
|
193
|
+
* renders that `<i>`, never the `<svg>`.
|
|
164
194
|
*/
|
|
165
195
|
export function readDrawnGlyph(svg) {
|
|
166
196
|
if (svg?.tag !== 'svg' || !svg.tokens?.includes(DRAWN))
|
|
@@ -179,7 +209,7 @@ export function readDrawnGlyph(svg) {
|
|
|
179
209
|
: nameIn(tokens, 'fa-', FA_MODIFIERS, style);
|
|
180
210
|
if (!named)
|
|
181
211
|
return undefined;
|
|
182
|
-
const variant = FA_STYLES[style];
|
|
212
|
+
const variant = style === 'fa' ? undefined : FA_STYLES[style];
|
|
183
213
|
return {
|
|
184
214
|
library: 'fa',
|
|
185
215
|
name: named.name,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html-assets.d.ts","sourceRoot":"","sources":["../../../src/sources/bulma-classes/html-assets.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAG9C,MAAM,MAAM,KAAK,GAAG,YAAY,GAAG,QAAQ,CAAC;AAE5C,MAAM,MAAM,KAAK;AACf,iEAAiE;AAC/D;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,GAC/D;IAAE,IAAI,EAAE,cAAc,CAAC;IAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,GAAG,EAAE,OAAO,CAAA;CAAE;AAC9D,sEAAsE;GACpE;IAAE,IAAI,EAAE,iBAAiB,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACzC;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,GAClB;IACE,IAAI,EAAE,SAAS,CAAC;IAChB,KAAK,EAAE,gBAAgB,GAAG,kBAAkB,GAAG,IAAI,CAAC;CACrD,GACD;IAAE,IAAI,EAAE,YAAY,CAAA;CAAE,GACtB;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,CAAC;AA+DvB,wBAAgB,aAAa,CAAC,GAAG,EAAE,MA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R;AAID;;;GAGG;AACH,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAkBjE,CAAC;AAEF,iFAAiF;AACjF,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAErD;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EAAE,EAChB,KAAK,EAAE,WAAW,CAAC,KAAK,CAAC,EACzB,GAAG,EAAE,OAAO,EACZ,OAAO,UAAQ,GACd,MAAM,CAkBR;AAID,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED,wBAAgB,cAAc,CAC5B,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,CAAC,EAC1C,MAAM,EAAE,MAAM,GACb,MAAM,CASR;AAED,6DAA6D;AAC7D,MAAM,MAAM,KAAK,GAAG,QAAQ,GAAG,SAAS,GAAG,WAAW,CAAC;AAEvD;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,4EAA4E;IAC5E,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,oCAAoC;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,iFAAiF;IACjF,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB;AAED,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,MAAM,EACd,IAAI,CAAC,EAAE,cAAc,GACpB,MAAM,CAeR;AAED,wBAAgB,aAAa,CAC3B,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,MAAM,GACb,MAAM,CAQR"}
|
|
@@ -164,6 +164,8 @@ export function bulmaBuildMessage(build, quoted) {
|
|
|
164
164
|
}
|
|
165
165
|
// ---- Font Awesome ------------------------------------------------------------
|
|
166
166
|
const ICON_LOADS_NO_FONT = "bestax's `Icon` loads no font of its own";
|
|
167
|
+
/** Where the older names that draw another glyph in 6 and 7 are listed. */
|
|
168
|
+
const OLDER_NAMES = "the bestax-icons skill's `references/icon-libraries.md` names the older names that draw another glyph in 6 and 7";
|
|
167
169
|
const INSTALL_FONT_AWESOME = `install \`@fortawesome/fontawesome-free\` (bestax-bulma's optional peer range is \`${FONT_AWESOME_PEER_RANGE}\`) and import its \`css/all.min.css\` from the app's entry`;
|
|
168
170
|
export function fontAwesomeMessage(asset, quoted) {
|
|
169
171
|
const { major, kit } = asset;
|
|
@@ -171,14 +173,14 @@ export function fontAwesomeMessage(asset, quoted) {
|
|
|
171
173
|
return `the page loads a Font Awesome kit from \`${quoted}\`, whose version the URL doesn't say: ${ICON_LOADS_NO_FONT}, so keep loading the kit once for the app, from its index.html, or ${INSTALL_FONT_AWESOME}`;
|
|
172
174
|
}
|
|
173
175
|
if (major === null) {
|
|
174
|
-
return `the page loads Font Awesome from \`${quoted}\`, whose version the URL doesn't say: ${ICON_LOADS_NO_FONT} and writes the classes Font Awesome 5 and later read (\`fas fa-<name>\`), so keep loading it once for the app, or ${INSTALL_FONT_AWESOME}, with \`css/v4-shims.min.css\` beside it if the page's names are Font Awesome 4's (\`fa fa-<name>\`)`;
|
|
176
|
+
return `the page loads Font Awesome from \`${quoted}\`, whose version the URL doesn't say: ${ICON_LOADS_NO_FONT} and writes the classes Font Awesome 5 and later read (\`fas fa-<name>\`), so keep loading it once for the app, or ${INSTALL_FONT_AWESOME}, with \`css/v4-shims.min.css\` beside it if the page's names are Font Awesome 4's (\`fa fa-<name>\`); ${OLDER_NAMES}`;
|
|
175
177
|
}
|
|
176
178
|
const loads = `the page loads Font Awesome ${major} from \`${quoted}\``;
|
|
177
179
|
if (major <= 4) {
|
|
178
|
-
return `${loads}, whose classes are \`fa fa-<name>\`: the codemod keeps that \`fa\` on each icon it converts (\`variant="fa"\`), which ${major} styles, but bestax's \`Icon\` given no \`variant\` writes \`fas fa-<name>\`, which ${major} doesn't, so for icons written from here on, ${INSTALL_FONT_AWESOME}, then either import \`css/v4-shims.min.css\` beside it, so the page's ${major} names keep working, or move them to the current names
|
|
180
|
+
return `${loads}, whose classes are \`fa fa-<name>\`: the codemod keeps that \`fa\` on each icon it converts (\`variant="fa"\`), which ${major} styles, but bestax's \`Icon\` given no \`variant\` writes \`fas fa-<name>\`, which ${major} doesn't, so for icons written from here on, ${INSTALL_FONT_AWESOME}, then either import \`css/v4-shims.min.css\` beside it, so the page's ${major} names keep working, or move them to the current names: \`fa-envelope-o\` is \`envelope\` with \`variant="regular"\`, and a brand's glyph (\`fa fa-github\`) needs \`variant="brands"\`, since 5 and later draw brands in a style of their own, and show a missing-glyph box for one under \`fa\` without the shims`;
|
|
179
181
|
}
|
|
180
182
|
if (major === 5) {
|
|
181
|
-
return `${loads}: ${ICON_LOADS_NO_FONT} and writes the \`fas fa-<name>\` classes 5 reads, so the \`<link>\` keeps working from the app's index.html; installed from npm, \`@fortawesome/fontawesome-free\` takes 6 or 7 (bestax-bulma's optional peer range is \`${FONT_AWESOME_PEER_RANGE}\`, and an older one fails \`npm install\` with ERESOLVE), which still read the 5
|
|
183
|
+
return `${loads}: ${ICON_LOADS_NO_FONT} and writes the \`fas fa-<name>\` classes 5 reads, so the \`<link>\` keeps working from the app's index.html; installed from npm, \`@fortawesome/fontawesome-free\` takes 6 or 7 (bestax-bulma's optional peer range is \`${FONT_AWESOME_PEER_RANGE}\`, and an older one fails \`npm install\` with ERESOLVE), which still read 5's names, many of them since renamed (\`search\` is \`magnifying-glass\`), but turned the handsets round: to keep the glyph the page shows, write 5's \`phone\` and \`phone-square\` as \`phone-flip\` and \`square-phone-flip\`, and 5's \`phone-alt\` and \`phone-square-alt\` as \`phone\` and \`square-phone\``;
|
|
182
184
|
}
|
|
183
185
|
if (major <= 7) {
|
|
184
186
|
return `${loads}: ${ICON_LOADS_NO_FONT}, so keep loading it once for the app, from a \`<link>\` in its index.html, or ${INSTALL_FONT_AWESOME}`;
|
|
@@ -23,8 +23,9 @@
|
|
|
23
23
|
* file, so the CLI's manifest step reads the module the same way too.
|
|
24
24
|
*
|
|
25
25
|
* Nothing is ever overwritten: a module already beside the page stops it
|
|
26
|
-
* (`html-file:exists`), so a second run changes nothing, and the
|
|
27
|
-
* stays as it was. A
|
|
26
|
+
* (`html-file:exists`), so a second run on the page changes nothing, and the
|
|
27
|
+
* page itself stays as it was. A re-run a TODO asks for is one on the module,
|
|
28
|
+
* which is what each says. A page with no Bulma component class writes nothing (a
|
|
28
29
|
* Vite `index.html` is a page like any other), and a server template
|
|
29
30
|
* (`{{`, `{%`, `<?php`, `<%`) is refused rather than read as HTML.
|
|
30
31
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html.d.ts","sourceRoot":"","sources":["../../../src/sources/bulma-classes/html.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"html.d.ts","sourceRoot":"","sources":["../../../src/sources/bulma-classes/html.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAIH,OAAO,KAAK,EAEV,UAAU,EACV,aAAa,EACb,SAAS,EACT,gBAAgB,EACjB,MAAM,gBAAgB,CAAC;AAiBxB,OAAO,EAIL,KAAK,SAAS,EAEf,MAAM,+BAA+B,CAAC;AAkEvC;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,MAAM,CAYjE;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,aAAa,EAAE,SAoB3B,CAAC;AAsBF;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,CAgBnE;AAYD,6DAA6D;AAC7D,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAmBlD;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,gBAAqB,GAC7B,MAAM,CAQR;AAsBD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAU3E;AAkMD,+EAA+E;AAC/E,eAAO,MAAM,YAAY,wCAAsC,CAAC;AA48BhE;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CA4BjD;AAID,+EAA+E;AAC/E,MAAM,WAAW,aAAc,SAAQ,UAAU;IAC/C,2EAA2E;IAC3E,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B;AAWD,wBAAgB,WAAW,CACzB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,aAAa,GAAG,SAAS,EACpC,OAAO,GAAE,gBAAqB,GAC7B,aAAa,CAoIf;AA4CD,yCAAyC;AACzC,wBAAgB,aAAa,CAC3B,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,aAAa,GAAG,SAAS,EACpC,OAAO,GAAE,gBAAqB,GAC7B,UAAU,CAGZ"}
|
|
@@ -23,8 +23,9 @@
|
|
|
23
23
|
* file, so the CLI's manifest step reads the module the same way too.
|
|
24
24
|
*
|
|
25
25
|
* Nothing is ever overwritten: a module already beside the page stops it
|
|
26
|
-
* (`html-file:exists`), so a second run changes nothing, and the
|
|
27
|
-
* stays as it was. A
|
|
26
|
+
* (`html-file:exists`), so a second run on the page changes nothing, and the
|
|
27
|
+
* page itself stays as it was. A re-run a TODO asks for is one on the module,
|
|
28
|
+
* which is what each says. A page with no Bulma component class writes nothing (a
|
|
28
29
|
* Vite `index.html` is a page like any other), and a server template
|
|
29
30
|
* (`{{`, `{%`, `<?php`, `<%`) is refused rather than read as HTML.
|
|
30
31
|
*/
|
|
@@ -261,7 +262,7 @@ const SCRIPT_PATTERNS = [
|
|
|
261
262
|
[
|
|
262
263
|
'modal',
|
|
263
264
|
/modal/,
|
|
264
|
-
"opens or closes a modal: bestax's `Modal` shows while `active` is true and calls `onClose` from its
|
|
265
|
+
"opens or closes a modal: bestax's `Modal` shows while `active` is true and calls `onClose` on Escape and from a `Modal.Close` with no `onClick` of its own, while `Modal.Background` closes it only with `onClick={onClose}`, so keep the open state in `useState`",
|
|
265
266
|
],
|
|
266
267
|
[
|
|
267
268
|
'dismiss',
|
|
@@ -1279,7 +1280,7 @@ export function convertPage(file, source, collector, options = {}) {
|
|
|
1279
1280
|
file,
|
|
1280
1281
|
line: null,
|
|
1281
1282
|
rule: htmlRuleId('html-file', 'exists'),
|
|
1282
|
-
message: `\`${path.basename(outputPath)}\` is already beside the page, and the codemod never overwrites a file:
|
|
1283
|
+
message: `\`${path.basename(outputPath)}\` is already beside the page, and the codemod never overwrites a file: to carry on from the TODOs it holds, run the codemod on \`${path.basename(outputPath)}\` itself, and to convert the page again, move or delete it`,
|
|
1283
1284
|
}, outputPath);
|
|
1284
1285
|
}
|
|
1285
1286
|
const template = TEMPLATE_SYNTAX.exec(source);
|
|
@@ -1347,6 +1348,9 @@ export function convertPage(file, source, collector, options = {}) {
|
|
|
1347
1348
|
}
|
|
1348
1349
|
// The transform reads the module's path, so the gates for a server
|
|
1349
1350
|
// component or another JSX runtime apply to it; its report names the page.
|
|
1351
|
+
// A re-run its TODOs ask for is one on the module, since the page converts
|
|
1352
|
+
// only once (`html-file:exists`), so they say so.
|
|
1353
|
+
const moduleName = path.basename(outputPath);
|
|
1350
1354
|
const planned = new Map();
|
|
1351
1355
|
const onPage = {
|
|
1352
1356
|
add: entry => {
|
|
@@ -1356,11 +1360,15 @@ export function convertPage(file, source, collector, options = {}) {
|
|
|
1356
1360
|
// A file-level gate's TODO is about the whole page, so it gets no
|
|
1357
1361
|
// page line of the element it sits on.
|
|
1358
1362
|
const forFile = FILE_RULES.includes(entry.rule);
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1363
|
+
const text = todoText(entry.message);
|
|
1364
|
+
const lines = planned.get(text) ?? [];
|
|
1365
|
+
planned.set(text, line !== null && !forFile ? [...lines, line] : lines);
|
|
1366
|
+
collector?.add({
|
|
1367
|
+
...entry,
|
|
1368
|
+
message: rerunOn(entry.message, moduleName),
|
|
1369
|
+
file,
|
|
1370
|
+
line,
|
|
1371
|
+
});
|
|
1364
1372
|
},
|
|
1365
1373
|
};
|
|
1366
1374
|
const { output } = runTransform(transform, outputPath, intermediate, onPage, {
|
|
@@ -1369,34 +1377,44 @@ export function convertPage(file, source, collector, options = {}) {
|
|
|
1369
1377
|
});
|
|
1370
1378
|
return {
|
|
1371
1379
|
outputPath,
|
|
1372
|
-
output: finishModule(withPageLines(output ?? intermediate, planned, page)),
|
|
1380
|
+
output: finishModule(withPageLines(output ?? intermediate, planned, page, moduleName)),
|
|
1373
1381
|
intermediate,
|
|
1374
1382
|
};
|
|
1375
1383
|
}
|
|
1384
|
+
/**
|
|
1385
|
+
* A TODO from a page's run with each re-run it asks for named as one on its
|
|
1386
|
+
* module: run again on the page, the codemod writes nothing.
|
|
1387
|
+
*/
|
|
1388
|
+
function rerunOn(message, moduleName) {
|
|
1389
|
+
return message.replace(/\bre-run\b/g, `re-run on \`${moduleName}\``);
|
|
1390
|
+
}
|
|
1376
1391
|
/** A TODO's message as its comment writes it, on one line. */
|
|
1377
1392
|
function todoText(message) {
|
|
1378
1393
|
return message.replace(/[\r\n\u2028\u2029]+/g, ' ').trim();
|
|
1379
1394
|
}
|
|
1380
1395
|
/**
|
|
1381
|
-
* The
|
|
1382
|
-
*
|
|
1383
|
-
*
|
|
1384
|
-
*
|
|
1385
|
-
* the
|
|
1396
|
+
* The transform's TODO lines, each with its re-runs named as ones on the
|
|
1397
|
+
* module and the page's lines it is about, if any. The transform writes one
|
|
1398
|
+
* line for each message, however many elements share it (five `.icon`s
|
|
1399
|
+
* missing the same attribute), above the `return`, so the lines go on after,
|
|
1400
|
+
* the way the page's own notes carry theirs. Nothing from the `return` on is
|
|
1401
|
+
* read, since the page's text is there.
|
|
1386
1402
|
*/
|
|
1387
|
-
function withPageLines(code, planned, page) {
|
|
1403
|
+
function withPageLines(code, planned, page, moduleName) {
|
|
1388
1404
|
if (planned.size === 0)
|
|
1389
1405
|
return code;
|
|
1390
1406
|
const lines = code.split('\n');
|
|
1391
1407
|
for (let i = 0; i < lines.length; i++) {
|
|
1392
1408
|
if (/^\s*return\b/.test(lines[i]))
|
|
1393
1409
|
break;
|
|
1394
|
-
const todo =
|
|
1395
|
-
const on = todo ? planned.get(todo[
|
|
1410
|
+
const todo = /^(\s*\/\/ TODO\(bestax-migrate\): )(.*)$/.exec(lines[i]);
|
|
1411
|
+
const on = todo ? planned.get(todo[2]) : undefined;
|
|
1396
1412
|
if (!on)
|
|
1397
1413
|
continue;
|
|
1398
1414
|
const at = [...new Set(on)].sort((a, b) => a - b).join(', ');
|
|
1399
|
-
lines[i] =
|
|
1415
|
+
lines[i] =
|
|
1416
|
+
`${todo[1]}${rerunOn(todo[2], moduleName)}` +
|
|
1417
|
+
(at === '' ? '' : ` (${page}:${at})`);
|
|
1400
1418
|
}
|
|
1401
1419
|
return lines.join('\n');
|
|
1402
1420
|
}
|
|
@@ -11,8 +11,14 @@
|
|
|
11
11
|
* `<i aria-hidden="true">` alone in a `.icon` that carries nothing assistive
|
|
12
12
|
* tech reads (the table's `hiddenMovesBeside`) converts to `Icon`, which writes that attribute
|
|
13
13
|
* on the `.icon` instead (`movesHidden`), since the glyph is hidden either
|
|
14
|
-
* way.
|
|
15
|
-
*
|
|
14
|
+
* way. A `.icon` like it around a bare glyph, in a link or button its own
|
|
15
|
+
* `aria-label` or `aria-labelledby` names, converts too, and `Icon` writes
|
|
16
|
+
* the attribute it doesn't carry (`addsHidden`), since that label is what
|
|
17
|
+
* assistive tech reads for the control. Font Awesome 6's long name for a
|
|
18
|
+
* style is written as the bestax-icons skill's `variant`, which `Icon`
|
|
19
|
+
* renders as the short name, the same style (`glyph.ts`, `longStyle`). And a
|
|
20
|
+
* Bulma 0.9 helper v1 removed (`REPLACED_IN_V1`), which styles nothing under
|
|
21
|
+
* v1, converts as the v1 helper that does its job.
|
|
16
22
|
*/
|
|
17
23
|
import { type Glyph } from './glyph.js';
|
|
18
24
|
export interface ElementFacts {
|
|
@@ -140,6 +146,14 @@ export interface ElementFacts {
|
|
|
140
146
|
clickableAround?: {
|
|
141
147
|
tag: string;
|
|
142
148
|
label?: 'aria-label' | 'aria-labelledby' | 'text' | 'none';
|
|
149
|
+
/**
|
|
150
|
+
* For an <a>: true when it has an `href` written out as a string, so it
|
|
151
|
+
* is a link, and false when it has neither an `href` nor a `role`, so it
|
|
152
|
+
* has no role at all and ARIA lets nothing name it. Left out when that
|
|
153
|
+
* can't be told from here (an `href` written as an expression, or a
|
|
154
|
+
* `role` of its own).
|
|
155
|
+
*/
|
|
156
|
+
link?: boolean;
|
|
143
157
|
};
|
|
144
158
|
}
|
|
145
159
|
export interface ChildFacts {
|
|
@@ -231,6 +245,15 @@ export interface Conversion {
|
|
|
231
245
|
* attribute moved up, and nothing else.
|
|
232
246
|
*/
|
|
233
247
|
movesHidden?: true;
|
|
248
|
+
/**
|
|
249
|
+
* The element carried no `aria-hidden`, and sits in a link or a <button>
|
|
250
|
+
* its own `aria-label` or `aria-labelledby` names, which assistive tech
|
|
251
|
+
* reads in place of what the control holds: the target writes the
|
|
252
|
+
* attribute on it, a way a conversion's markup differs on purpose, since
|
|
253
|
+
* nothing assistive tech reads changes. The render tests compare it with
|
|
254
|
+
* the attribute restated, and nothing else.
|
|
255
|
+
*/
|
|
256
|
+
addsHidden?: true;
|
|
234
257
|
/**
|
|
235
258
|
* The target renders the bare element around this one too: the component
|
|
236
259
|
* takes that element's place, with its `key`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plan.d.ts","sourceRoot":"","sources":["../../../src/sources/bulma-classes/plan.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"plan.d.ts","sourceRoot":"","sources":["../../../src/sources/bulma-classes/plan.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAwBH,OAAO,EAKL,KAAK,KAAK,EACX,MAAM,YAAY,CAAC;AAIpB,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,2DAA2D;IAC3D,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1B;;;;;OAKG;IACH,WAAW,CAAC,EAAE,SAAS,CAAC,SAAS,MAAM,EAAE,CAAC,EAAE,CAAC;IAC7C;;;;OAIG;IACH,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3B;;;OAGG;IACH,UAAU,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC;IACtD,SAAS,EAAE,OAAO,CAAC;IACnB,MAAM,EAAE,OAAO,CAAC;IAChB,4EAA4E;IAC5E,WAAW,EAAE,OAAO,CAAC;IACrB;;;;OAIG;IACH,YAAY,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;OAGG;IACH,SAAS,CAAC,EAAE,UAAU,CAAC;IACvB;;;;OAIG;IACH,aAAa,CAAC,EAAE,SAAS,UAAU,EAAE,CAAC;IACtC;;;;;OAKG;IACH,cAAc,CAAC,EAAE,SAAS,UAAU,EAAE,CAAC;IACvC,qEAAqE;IACrE,YAAY,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC,qEAAqE;IACrE,YAAY,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC;;;OAGG;IACH,gBAAgB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC;;;OAGG;IACH,aAAa,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC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+11,14 @@
|
|
|
11
11
|
* `<i aria-hidden="true">` alone in a `.icon` that carries nothing assistive
|
|
12
12
|
* tech reads (the table's `hiddenMovesBeside`) converts to `Icon`, which writes that attribute
|
|
13
13
|
* on the `.icon` instead (`movesHidden`), since the glyph is hidden either
|
|
14
|
-
* way.
|
|
15
|
-
*
|
|
14
|
+
* way. A `.icon` like it around a bare glyph, in a link or button its own
|
|
15
|
+
* `aria-label` or `aria-labelledby` names, converts too, and `Icon` writes
|
|
16
|
+
* the attribute it doesn't carry (`addsHidden`), since that label is what
|
|
17
|
+
* assistive tech reads for the control. Font Awesome 6's long name for a
|
|
18
|
+
* style is written as the bestax-icons skill's `variant`, which `Icon`
|
|
19
|
+
* renders as the short name, the same style (`glyph.ts`, `longStyle`). And a
|
|
20
|
+
* Bulma 0.9 helper v1 removed (`REPLACED_IN_V1`), which styles nothing under
|
|
21
|
+
* v1, converts as the v1 helper that does its job.
|
|
16
22
|
*/
|
|
17
23
|
import { FORWARDS_REF, HELPER_PROPS, HELPER_TOKENS, inTagSet, legacyHint, modifierFor, modifiesRoot, numberAttrsOf, placedFor, PRECEDENCE, reachesTag, replacedBy, rootFor, rootItNeeds, tagFit, WRAPPER_OWN_PROPS, wrapperFor, } from './class-map.js';
|
|
18
24
|
import { glyphProps, readDrawnGlyph, readGlyph, readHiddenGlyph, } from './glyph.js';
|
|
@@ -176,8 +182,23 @@ function offTagSizes(entry, root, target, tag, tokens, converted, writes) {
|
|
|
176
182
|
function carriedBy(facts) {
|
|
177
183
|
return [...new Set([...facts.tokens, ...(facts.conditional ?? []).flat()])];
|
|
178
184
|
}
|
|
185
|
+
/**
|
|
186
|
+
* What a TODO that promises a re-run says instead once its element converts:
|
|
187
|
+
* the next run plans no component, so the re-run would do nothing, and the
|
|
188
|
+
* fix is by hand.
|
|
189
|
+
*/
|
|
190
|
+
const BY_HAND = new WeakMap();
|
|
179
191
|
export function plan(facts) {
|
|
180
|
-
const
|
|
192
|
+
const planned = planElement(facts);
|
|
193
|
+
const result = planned.conversion
|
|
194
|
+
? {
|
|
195
|
+
...planned,
|
|
196
|
+
todos: planned.todos.map(todo => {
|
|
197
|
+
const byHand = BY_HAND.get(todo);
|
|
198
|
+
return byHand === undefined ? todo : { ...todo, message: byHand };
|
|
199
|
+
}),
|
|
200
|
+
}
|
|
201
|
+
: planned;
|
|
181
202
|
// A Bulma 0.9 helper v1 removed converts as the v1 helper that replaced
|
|
182
203
|
// it, and only one that stays a class gets the TODO naming that helper:
|
|
183
204
|
// where it converted, nothing is left to do.
|
|
@@ -221,13 +242,17 @@ function planElement(facts) {
|
|
|
221
242
|
})) {
|
|
222
243
|
const needed = rootFor(root);
|
|
223
244
|
const article = /^[aeiou]/.test(root) ? 'an' : 'a';
|
|
224
|
-
const
|
|
245
|
+
const rerun = reachesTag(needed, tag);
|
|
246
|
+
const fix = rerun
|
|
225
247
|
? `add \`${root}\`, which bestax \`${needed.target}\` renders, then re-run`
|
|
226
248
|
: `add \`${root}\` for Bulma to style it, though bestax \`${needed.target}\` renders ${tagsItReaches(needed)}, not ${aTag(tag)}, so the element stays markup`;
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
249
|
+
const says = (remedy) => `\`${token}\` is ${article} \`.${root}\` modifier, and Bulma styles it only on the element that carries \`.${root}\`, so on this one it styles nothing unless the project's own CSS gives it a rule; if this element is the ${root}, ${remedy}, and otherwise drop the class`;
|
|
250
|
+
const todo = { rule: ruleId('modifier', root), message: says(fix) };
|
|
251
|
+
// On an element that converts anyway, a re-run finds a component.
|
|
252
|
+
if (rerun) {
|
|
253
|
+
BY_HAND.set(todo, says(`convert it to bestax \`${needed.target}\` by hand`));
|
|
254
|
+
}
|
|
255
|
+
todos.push(todo);
|
|
231
256
|
}
|
|
232
257
|
}
|
|
233
258
|
// A family this source leaves as markup keeps its element as markup, even
|
|
@@ -425,8 +450,39 @@ function planElement(facts) {
|
|
|
425
450
|
[...attributes.keys()].every(name => movesBeside(entry, name))
|
|
426
451
|
? readHiddenGlyph(facts.soleChild)
|
|
427
452
|
: undefined;
|
|
428
|
-
|
|
453
|
+
// An icon in a link or <button> its own label names is decoration there:
|
|
454
|
+
// that label is what assistive tech reads for the control, in place of
|
|
455
|
+
// what it holds, so the `aria-hidden` the target writes changes nothing it
|
|
456
|
+
// reads. Another difference in markup a conversion makes on purpose, held
|
|
457
|
+
// to the same shape: a bare glyph the target renders from props, in an
|
|
458
|
+
// element that carries nothing else assistive tech reads. The render tests
|
|
459
|
+
// compare it with the attribute restated.
|
|
460
|
+
const decorates = !moved &&
|
|
461
|
+
entry.readsGlyph &&
|
|
462
|
+
naming === 'unnamed' &&
|
|
463
|
+
defaults['aria-hidden'] === 'true' &&
|
|
464
|
+
!attributes.has('aria-hidden') &&
|
|
465
|
+
[...attributes.keys()].every(name => movesBeside(entry, name)) &&
|
|
466
|
+
namesItsContent(facts.clickableAround)
|
|
467
|
+
? readGlyph(facts.soleChild)
|
|
468
|
+
: undefined;
|
|
469
|
+
const missing = [...Object.entries(defaults), ...written].filter(([name]) => !attributes.has(name) && !((moved || decorates) && name === 'aria-hidden'));
|
|
429
470
|
const drop = [];
|
|
471
|
+
// A target that renders a glyph from props is written the way the
|
|
472
|
+
// bestax-icons skill writes it, with no attribute it renders by itself
|
|
473
|
+
// with the same value (`aria-hidden="true"` with no name, `role="img"`
|
|
474
|
+
// beside one): the markup is the same without it.
|
|
475
|
+
// A `role` or `tabIndex` written as an expression may stop those
|
|
476
|
+
// defaults at run time, so the element keeps what it wrote.
|
|
477
|
+
const mayStop = entry.defaultsUnless?.some(name => attributes.has(name) && attributes.get(name) === null);
|
|
478
|
+
if (entry.readsGlyph && naming !== 'unsure' && !mayStop) {
|
|
479
|
+
for (const [name, value] of Object.entries(defaults)) {
|
|
480
|
+
const given = attributes.get(name);
|
|
481
|
+
if (given === value || (given === true && value === 'true')) {
|
|
482
|
+
drop.push(name);
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
}
|
|
430
486
|
for (const name of entry.untypedAttrs ?? []) {
|
|
431
487
|
if (!attributes.has(name))
|
|
432
488
|
continue;
|
|
@@ -630,7 +686,9 @@ function planElement(facts) {
|
|
|
630
686
|
todos.push(...secondColors(entry, root, target, tokens, converted, writes));
|
|
631
687
|
todos.push(...offTagSizes(entry, root, target, tag, tokens, converted, writes));
|
|
632
688
|
// A glyph the target renders from props takes the place of the only child.
|
|
633
|
-
const glyph = moved ??
|
|
689
|
+
const glyph = moved ??
|
|
690
|
+
decorates ??
|
|
691
|
+
(entry.readsGlyph ? readGlyph(facts.soleChild) : undefined);
|
|
634
692
|
return {
|
|
635
693
|
conversion: {
|
|
636
694
|
target,
|
|
@@ -644,6 +702,7 @@ function planElement(facts) {
|
|
|
644
702
|
: {}),
|
|
645
703
|
...(glyph ? { glyph } : {}),
|
|
646
704
|
...(moved ? { movesHidden: true } : {}),
|
|
705
|
+
...(decorates ? { addsHidden: true } : {}),
|
|
647
706
|
...(parent ? { replacesParent: true } : {}),
|
|
648
707
|
...(conditional.length > 0 ? { conditional } : {}),
|
|
649
708
|
...(icons ? { icons } : {}),
|
|
@@ -757,6 +816,16 @@ function movesBeside(entry, name) {
|
|
|
757
816
|
? name.startsWith(allowed.slice(0, -1))
|
|
758
817
|
: name === allowed);
|
|
759
818
|
}
|
|
819
|
+
/**
|
|
820
|
+
* Whether the link or <button> around an element names itself with its own
|
|
821
|
+
* `aria-label` or `aria-labelledby`, which assistive tech reads for it in
|
|
822
|
+
* place of what it holds. An <a> counts only as a link: one with no `href`
|
|
823
|
+
* has no role, and ARIA lets nothing name it.
|
|
824
|
+
*/
|
|
825
|
+
function namesItsContent(around) {
|
|
826
|
+
return ((around?.label === 'aria-label' || around?.label === 'aria-labelledby') &&
|
|
827
|
+
(around.tag === 'button' || around.link === true));
|
|
828
|
+
}
|
|
760
829
|
/**
|
|
761
830
|
* What to do about an unnamed element whose target hides it with an
|
|
762
831
|
* `aria-hidden` it doesn't carry, and that renders a glyph from props
|
|
@@ -813,12 +882,40 @@ function hiddenAdvice(facts, entry, usual) {
|
|
|
813
882
|
const around = facts.clickableAround;
|
|
814
883
|
const label = around?.label;
|
|
815
884
|
const tag = around && aTag(around.tag);
|
|
885
|
+
// An <a> with no `href` and no `role` is no link, and has no role at all,
|
|
886
|
+
// so ARIA lets nothing name it: it needs an `href`, or to be a <button>,
|
|
887
|
+
// before a label does anything.
|
|
888
|
+
const unlinked = around?.tag === 'a' && around.link === false;
|
|
889
|
+
const hide = `add \`aria-hidden="true"\` here, which bestax \`${target}\` writes on an icon with no name of its own`;
|
|
890
|
+
// What a re-run converts this to once the control around it names itself
|
|
891
|
+
// and is a link, where an icon converts as it is (`namesItsContent`). Only
|
|
892
|
+
// from a control that isn't both yet, so the planner asks once.
|
|
893
|
+
const labelled = label === 'aria-label' || label === 'aria-labelledby';
|
|
894
|
+
const fixed = around && (unlinked || label === 'none')
|
|
895
|
+
? plan({
|
|
896
|
+
...facts,
|
|
897
|
+
clickableAround: {
|
|
898
|
+
...around,
|
|
899
|
+
...(!labelled && { label: 'aria-label' }),
|
|
900
|
+
...(unlinked && { link: true }),
|
|
901
|
+
},
|
|
902
|
+
}).conversion
|
|
903
|
+
: undefined;
|
|
904
|
+
const once = fixed?.glyph
|
|
905
|
+
? `re-run, and this converts to \`${target}\` with ${jsxProps(glyphProps(fixed.glyph))}, which hides the icon with \`aria-hidden="true"\`${hint}`
|
|
906
|
+
: undefined;
|
|
907
|
+
if (unlinked && labelled) {
|
|
908
|
+
return `this \`.icon\` sits in an <a> with no \`href\`, which is no link and has no role, so ARIA lets nothing name it and its \`${label}\` names nothing; give the <a> an \`href\`, or make it a <button>, then ${once ?? `${hide}, and re-run${outcome}${hint}`}`;
|
|
909
|
+
}
|
|
816
910
|
if (label && label !== 'none') {
|
|
817
911
|
const by = label === 'text' ? 'its own text' : `its \`${label}\``;
|
|
818
912
|
return `this \`.icon\` sits in ${tag} that ${by} names, so the icon is decoration there, and bestax \`${target}\` writes \`aria-hidden="true"\` on an icon with no name of its own, which this one doesn't carry; add it, then re-run${outcome}${hint}`;
|
|
819
913
|
}
|
|
820
914
|
if (label === 'none' && readGlyph(sole)) {
|
|
821
|
-
|
|
915
|
+
const name = unlinked
|
|
916
|
+
? 'an `href`, or make it a <button>, and give it an `aria-label` that says what it does'
|
|
917
|
+
: 'an `aria-label` that says what it does';
|
|
918
|
+
return `nothing names the <${around.tag}> around this \`.icon\`: it has no \`aria-label\` and no text outside its icons, and a font icon's glyph is no name a screen reader can read; give the <${around.tag}> ${name}, then ${once ?? `${hide}, and re-run${outcome}${hint}`}`;
|
|
822
919
|
}
|
|
823
920
|
return `${usual}${outcome}${hint}`;
|
|
824
921
|
}
|
|
@@ -5,8 +5,9 @@
|
|
|
5
5
|
* scope when a lowercase JSX element carries a `className` with a Bulma class
|
|
6
6
|
* `class-map.ts` knows. Each such element goes through `plan()`, which
|
|
7
7
|
* converts it only when the component renders exactly the same markup, but
|
|
8
|
-
* for the exceptions it states (Font Awesome's hidden `<i>`,
|
|
9
|
-
*
|
|
8
|
+
* for the exceptions it states (Font Awesome's hidden `<i>`, an icon in a
|
|
9
|
+
* link or button its own label names, Font Awesome 6's long name for a
|
|
10
|
+
* style, and a Bulma 0.9 helper v1 removed).
|
|
10
11
|
*
|
|
11
12
|
* Passes, in order:
|
|
12
13
|
* 1. the shared stylesheet-import pass (a no-op under the default `keep`)
|
|
@@ -17,6 +18,9 @@
|
|
|
17
18
|
* Next.js server component (bestax's components are client components)
|
|
18
19
|
* 4. TODOs in reading order; conversions innermost first
|
|
19
20
|
* 5. write the bestax import, after the file's last import
|
|
21
|
+
* 6. settle the TODOs an earlier run wrote: one this run writes again keeps
|
|
22
|
+
* its earlier copy, and one that asked for a re-run it no longer writes
|
|
23
|
+
* goes (`settleTodos`)
|
|
20
24
|
*/
|
|
21
25
|
import type { API, FileInfo } from 'jscodeshift';
|
|
22
26
|
import type { TransformOptions } from '../../types.js';
|
|
@@ -25,6 +29,20 @@ import type { TransformOptions } from '../../types.js';
|
|
|
25
29
|
* the file, though it sits on the first element that would convert, so no
|
|
26
30
|
* line of the file is where it came from.
|
|
27
31
|
*/
|
|
32
|
+
/**
|
|
33
|
+
* A `TODO(bestax-migrate)` line comment's message as a run compares it: the
|
|
34
|
+
* page's lines an HTML page's module adds after it left out, and a re-run it
|
|
35
|
+
* asks for on a named file read as any re-run. So a re-run on that module
|
|
36
|
+
* finds the TODOs it writes again in the ones the page's run wrote.
|
|
37
|
+
*/
|
|
38
|
+
export declare function todoKey(text: string): string;
|
|
39
|
+
/**
|
|
40
|
+
* The packages the library sources migrate from. A file that still imports
|
|
41
|
+
* one may hold that source's TODOs, which ask for a re-run of it, not of
|
|
42
|
+
* this one, so this one leaves every TODO there as it is. A new library
|
|
43
|
+
* source joins this list.
|
|
44
|
+
*/
|
|
45
|
+
export declare const LIBRARY_SOURCES: RegExp;
|
|
28
46
|
export declare const FILE_RULES: readonly ["jsx-runtime", "imports", "styled-jsx", "rsc"];
|
|
29
47
|
export default function transform(fileInfo: FileInfo, api: API, options?: TransformOptions): string | undefined;
|
|
30
48
|
//# sourceMappingURL=transform.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../../src/sources/bulma-classes/transform.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../../src/sources/bulma-classes/transform.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAW,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE1D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAmkCvD;;;;GAIG;AACH;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAM5C;AASD;;;;;GAKG;AACH,eAAO,MAAM,eAAe,QACuB,CAAC;AAEpD,eAAO,MAAM,UAAU,0DAKb,CAAC;AAGX,MAAM,CAAC,OAAO,UAAU,SAAS,CAC/B,QAAQ,EAAE,QAAQ,EAClB,GAAG,EAAE,GAAG,EACR,OAAO,GAAE,gBAAqB,GAC7B,MAAM,GAAG,SAAS,CAwhCpB"}
|
|
@@ -5,8 +5,9 @@
|
|
|
5
5
|
* scope when a lowercase JSX element carries a `className` with a Bulma class
|
|
6
6
|
* `class-map.ts` knows. Each such element goes through `plan()`, which
|
|
7
7
|
* converts it only when the component renders exactly the same markup, but
|
|
8
|
-
* for the exceptions it states (Font Awesome's hidden `<i>`,
|
|
9
|
-
*
|
|
8
|
+
* for the exceptions it states (Font Awesome's hidden `<i>`, an icon in a
|
|
9
|
+
* link or button its own label names, Font Awesome 6's long name for a
|
|
10
|
+
* style, and a Bulma 0.9 helper v1 removed).
|
|
10
11
|
*
|
|
11
12
|
* Passes, in order:
|
|
12
13
|
* 1. the shared stylesheet-import pass (a no-op under the default `keep`)
|
|
@@ -17,6 +18,9 @@
|
|
|
17
18
|
* Next.js server component (bestax's components are client components)
|
|
18
19
|
* 4. TODOs in reading order; conversions innermost first
|
|
19
20
|
* 5. write the bestax import, after the file's last import
|
|
21
|
+
* 6. settle the TODOs an earlier run wrote: one this run writes again keeps
|
|
22
|
+
* its earlier copy, and one that asked for a re-run it no longer writes
|
|
23
|
+
* goes (`settleTodos`)
|
|
20
24
|
*/
|
|
21
25
|
import path from 'node:path';
|
|
22
26
|
import { addTodo, findAttr, forgetJsxParens, jsxNameParts, literalValueOf, makeAttr, removeAttr, renameElement, reprintDirectives, } from '../_shared/jsx-utils.js';
|
|
@@ -837,6 +841,22 @@ function labelOf(clickable, self, kindOf) {
|
|
|
837
841
|
return 'text';
|
|
838
842
|
return unsure ? undefined : 'none';
|
|
839
843
|
}
|
|
844
|
+
/**
|
|
845
|
+
* Whether an <a> is a link, as `ElementFacts.clickableAround` says: true with
|
|
846
|
+
* an `href` written out as a string, false with neither an `href` nor a
|
|
847
|
+
* `role`, and undefined when that can't be told: an `href` written as an
|
|
848
|
+
* expression, which may render as none, a `role` of its own, or a spread,
|
|
849
|
+
* which may carry either.
|
|
850
|
+
*/
|
|
851
|
+
function linkOf(clickable) {
|
|
852
|
+
if ((clickable.openingElement.attributes ?? []).some((attr) => attr.type === 'JSXSpreadAttribute')) {
|
|
853
|
+
return undefined;
|
|
854
|
+
}
|
|
855
|
+
const href = findAttr(clickable, 'href');
|
|
856
|
+
if (href)
|
|
857
|
+
return typeof attributeValue(href) === 'string' ? true : undefined;
|
|
858
|
+
return findAttr(clickable, 'role') ? undefined : false;
|
|
859
|
+
}
|
|
840
860
|
/**
|
|
841
861
|
* An element's content as one prop value: its one element, or its text, or
|
|
842
862
|
* a fragment of them all, each text written as the string it renders.
|
|
@@ -892,6 +912,30 @@ function onlyChildOf(elementPath, bestaxLocals) {
|
|
|
892
912
|
* the file, though it sits on the first element that would convert, so no
|
|
893
913
|
* line of the file is where it came from.
|
|
894
914
|
*/
|
|
915
|
+
/**
|
|
916
|
+
* A `TODO(bestax-migrate)` line comment's message as a run compares it: the
|
|
917
|
+
* page's lines an HTML page's module adds after it left out, and a re-run it
|
|
918
|
+
* asks for on a named file read as any re-run. So a re-run on that module
|
|
919
|
+
* finds the TODOs it writes again in the ones the page's run wrote.
|
|
920
|
+
*/
|
|
921
|
+
export function todoKey(text) {
|
|
922
|
+
return text
|
|
923
|
+
.replace(/^\s*TODO\(bestax-migrate\):\s*/, '')
|
|
924
|
+
.replace(/\s+\([^()]+\.html?:[\d, -]+\)$/, '')
|
|
925
|
+
.replace(/\bre-run on `[^`]+`/g, 're-run')
|
|
926
|
+
.trim();
|
|
927
|
+
}
|
|
928
|
+
function isTodoComment(comment) {
|
|
929
|
+
return ((comment.type === 'CommentLine' || comment.type === 'Line') &&
|
|
930
|
+
/^\s*TODO\(bestax-migrate\):/.test(comment.value));
|
|
931
|
+
}
|
|
932
|
+
/**
|
|
933
|
+
* The packages the library sources migrate from. A file that still imports
|
|
934
|
+
* one may hold that source's TODOs, which ask for a re-run of it, not of
|
|
935
|
+
* this one, so this one leaves every TODO there as it is. A new library
|
|
936
|
+
* source joins this list.
|
|
937
|
+
*/
|
|
938
|
+
export const LIBRARY_SOURCES = /^(?:react-bulma-components|rbx|bloomer)(?:\/|$)/;
|
|
895
939
|
export const FILE_RULES = [
|
|
896
940
|
'jsx-runtime',
|
|
897
941
|
'imports',
|
|
@@ -916,7 +960,60 @@ export default function transform(fileInfo, api, options = {}) {
|
|
|
916
960
|
overrides: new WeakMap(),
|
|
917
961
|
dirty: false,
|
|
918
962
|
};
|
|
963
|
+
// The TODOs the file holds from an earlier run, and the messages this run
|
|
964
|
+
// writes, so a re-run can tell the ones it no longer writes.
|
|
965
|
+
const earlier = new Set();
|
|
966
|
+
const written = new Set();
|
|
967
|
+
root.find(j.Node).forEach((nodePath) => {
|
|
968
|
+
for (const comment of nodePath.node.comments ?? []) {
|
|
969
|
+
if (isTodoComment(comment))
|
|
970
|
+
earlier.add(comment);
|
|
971
|
+
}
|
|
972
|
+
});
|
|
973
|
+
const todo = (path, rule, message) => {
|
|
974
|
+
written.add(todoKey(message));
|
|
975
|
+
addTodo(ctx, path, rule, message);
|
|
976
|
+
};
|
|
977
|
+
/**
|
|
978
|
+
* A re-run's TODOs against the earlier run's: one it writes again keeps
|
|
979
|
+
* the earlier copy, which carries the page's lines when the file is a
|
|
980
|
+
* page's module. One it no longer writes that asked for a re-run, above
|
|
981
|
+
* JSX, is done (the element converts now, or changed), so it goes, unless
|
|
982
|
+
* the file still imports a library source, whose TODOs this one can't tell
|
|
983
|
+
* from its own.
|
|
984
|
+
*/
|
|
985
|
+
const settleTodos = () => {
|
|
986
|
+
if (earlier.size === 0)
|
|
987
|
+
return;
|
|
988
|
+
const library = root
|
|
989
|
+
.find(j.ImportDeclaration)
|
|
990
|
+
.some((importPath) => LIBRARY_SOURCES.test(String(importPath.node.source.value)));
|
|
991
|
+
root.find(j.Node).forEach((nodePath) => {
|
|
992
|
+
const node = nodePath.node;
|
|
993
|
+
const comments = node.comments;
|
|
994
|
+
if (!comments?.some(isTodoComment))
|
|
995
|
+
return;
|
|
996
|
+
const holdsJsx = () => j(node).find(j.JSXElement).size() > 0 ||
|
|
997
|
+
j(node).find(j.JSXFragment).size() > 0;
|
|
998
|
+
const kept = comments.filter(comment => {
|
|
999
|
+
if (!isTodoComment(comment))
|
|
1000
|
+
return true;
|
|
1001
|
+
const key = todoKey(comment.value);
|
|
1002
|
+
if (!earlier.has(comment)) {
|
|
1003
|
+
return !comments.some(other => earlier.has(other) && todoKey(other.value) === key);
|
|
1004
|
+
}
|
|
1005
|
+
if (written.has(key) || library)
|
|
1006
|
+
return true;
|
|
1007
|
+
return !(/\bre-run\b/.test(key) && holdsJsx());
|
|
1008
|
+
});
|
|
1009
|
+
if (kept.length !== comments.length) {
|
|
1010
|
+
node.comments = kept;
|
|
1011
|
+
ctx.dirty = true;
|
|
1012
|
+
}
|
|
1013
|
+
});
|
|
1014
|
+
};
|
|
919
1015
|
const print = () => {
|
|
1016
|
+
settleTodos();
|
|
920
1017
|
if (!ctx.dirty)
|
|
921
1018
|
return undefined;
|
|
922
1019
|
forgetJsxParens(j, root);
|
|
@@ -1182,11 +1279,11 @@ export default function transform(fileInfo, api, options = {}) {
|
|
|
1182
1279
|
'');
|
|
1183
1280
|
};
|
|
1184
1281
|
/**
|
|
1185
|
-
* Where an element whose target renders a glyph sits
|
|
1186
|
-
*
|
|
1187
|
-
*
|
|
1188
|
-
*
|
|
1189
|
-
*
|
|
1282
|
+
* Where an element whose target renders a glyph sits: the classes the
|
|
1283
|
+
* element directly around it renders, and the nearest <a> or <button>
|
|
1284
|
+
* around it, reached through markup and bestax components only, since any
|
|
1285
|
+
* other component between could render anything, with what names that and,
|
|
1286
|
+
* for an <a>, whether it is a link.
|
|
1190
1287
|
*/
|
|
1191
1288
|
const glyphPlace = (elementPath) => {
|
|
1192
1289
|
const parent = elementPath.parent;
|
|
@@ -1214,10 +1311,15 @@ export default function transform(fileInfo, api, options = {}) {
|
|
|
1214
1311
|
return entries.some(buildsContent) ? 'opaque' : 'open';
|
|
1215
1312
|
};
|
|
1216
1313
|
const label = clickable && labelOf(clickable.node, elementPath.node, kindOf);
|
|
1314
|
+
const link = tag === 'a' && clickable ? linkOf(clickable.node) : undefined;
|
|
1217
1315
|
return {
|
|
1218
1316
|
...(parentTokens && { parentTokens }),
|
|
1219
1317
|
...(clickable && {
|
|
1220
|
-
clickableAround: {
|
|
1318
|
+
clickableAround: {
|
|
1319
|
+
tag: tag,
|
|
1320
|
+
...(label && { label }),
|
|
1321
|
+
...(link !== undefined && { link }),
|
|
1322
|
+
},
|
|
1221
1323
|
}),
|
|
1222
1324
|
};
|
|
1223
1325
|
};
|
|
@@ -1441,7 +1543,7 @@ export default function transform(fileInfo, api, options = {}) {
|
|
|
1441
1543
|
const converting = elements.some(element => element.converts);
|
|
1442
1544
|
const block = (rule, message) => {
|
|
1443
1545
|
if (converting)
|
|
1444
|
-
|
|
1546
|
+
todo(elements[0].path, rule, message);
|
|
1445
1547
|
for (const element of elements) {
|
|
1446
1548
|
element.plan = { ...element.plan, conversion: null, fold: undefined };
|
|
1447
1549
|
}
|
|
@@ -1484,8 +1586,8 @@ export default function transform(fileInfo, api, options = {}) {
|
|
|
1484
1586
|
ctx.reserve = makeReserve(ctx, bound);
|
|
1485
1587
|
const bestaxImportState = seedBestaxImport(ctx, root);
|
|
1486
1588
|
for (const { path: elementPath, plan: result } of elements) {
|
|
1487
|
-
for (const
|
|
1488
|
-
|
|
1589
|
+
for (const { rule, message } of result.todos) {
|
|
1590
|
+
todo(elementPath, rule, message);
|
|
1489
1591
|
}
|
|
1490
1592
|
}
|
|
1491
1593
|
for (const { path: elementPath, plan: result } of [...elements].reverse()) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bestax-migrate",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.33.0",
|
|
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": "^7.3.0",
|
|
42
42
|
"property-information": "^7.2.0",
|
|
43
|
-
"@allxsmith/bestax-bulma": "^5.45.
|
|
43
|
+
"@allxsmith/bestax-bulma": "^5.45.1"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@jest/globals": "^30.0.0",
|