bestax-migrate 2.26.0 → 2.28.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/README.md +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +12 -6
- package/dist/sources/_shared/deps-common.d.ts +2 -0
- package/dist/sources/_shared/deps-common.d.ts.map +1 -1
- package/dist/sources/_shared/deps-common.js +3 -1
- package/dist/sources/_shared/polymorphic.d.ts.map +1 -1
- package/dist/sources/_shared/polymorphic.js +16 -1
- package/dist/sources/bloomer/mapping.d.ts.map +1 -1
- package/dist/sources/bloomer/mapping.js +9 -4
- package/dist/sources/bloomer/specials.d.ts.map +1 -1
- package/dist/sources/bloomer/specials.js +30 -3
- package/dist/sources/bulma-classes/class-map.d.ts +41 -10
- package/dist/sources/bulma-classes/class-map.d.ts.map +1 -1
- package/dist/sources/bulma-classes/class-map.js +69 -13
- package/dist/sources/bulma-classes/glyph.d.ts +20 -0
- package/dist/sources/bulma-classes/glyph.d.ts.map +1 -1
- package/dist/sources/bulma-classes/glyph.js +64 -0
- package/dist/sources/bulma-classes/html-assets.d.ts +87 -0
- package/dist/sources/bulma-classes/html-assets.d.ts.map +1 -0
- package/dist/sources/bulma-classes/html-assets.js +246 -0
- package/dist/sources/bulma-classes/html-rules.d.ts +5 -0
- package/dist/sources/bulma-classes/html-rules.d.ts.map +1 -1
- package/dist/sources/bulma-classes/html-rules.js +14 -2
- package/dist/sources/bulma-classes/html.d.ts +12 -4
- package/dist/sources/bulma-classes/html.d.ts.map +1 -1
- package/dist/sources/bulma-classes/html.js +224 -49
- package/dist/sources/bulma-classes/plan.d.ts +40 -1
- package/dist/sources/bulma-classes/plan.d.ts.map +1 -1
- package/dist/sources/bulma-classes/plan.js +160 -24
- package/dist/sources/bulma-classes/project.d.ts +10 -2
- package/dist/sources/bulma-classes/project.d.ts.map +1 -1
- package/dist/sources/bulma-classes/project.js +17 -8
- package/dist/sources/bulma-classes/transform.d.ts +2 -1
- package/dist/sources/bulma-classes/transform.d.ts.map +1 -1
- package/dist/sources/bulma-classes/transform.js +231 -33
- package/dist/sources/rbx/mapping.d.ts +10 -0
- package/dist/sources/rbx/mapping.d.ts.map +1 -1
- package/dist/sources/rbx/mapping.js +13 -7
- package/dist/sources/react-bulma-components/mapping.d.ts.map +1 -1
- package/dist/sources/react-bulma-components/mapping.js +19 -5
- package/package.json +4 -3
|
@@ -7,10 +7,14 @@
|
|
|
7
7
|
* renders exactly the markup the element did. Anything that would change the
|
|
8
8
|
* markup is either left in `className` (a class with no prop here) or refuses
|
|
9
9
|
* the whole element with a TODO (an attribute or tag the component would
|
|
10
|
-
* render differently).
|
|
10
|
+
* render differently). One exception, on purpose: Font Awesome's own
|
|
11
|
+
* `<i aria-hidden="true">` alone in a `.icon` that carries nothing assistive
|
|
12
|
+
* tech reads (the table's `hiddenMovesBeside`) converts to `Icon`, which writes that attribute
|
|
13
|
+
* on the `.icon` instead (`movesHidden`), since the glyph is hidden either
|
|
14
|
+
* way.
|
|
11
15
|
*/
|
|
12
16
|
import { FORWARDS_REF, HELPER_PROPS, HELPER_TOKENS, inTagSet, legacyHint, modifierFor, numberAttrsOf, placedFor, PRECEDENCE, rootFor, WRAPPER_OWN_PROPS, wrapperFor, } from './class-map.js';
|
|
13
|
-
import { readGlyph } from './glyph.js';
|
|
17
|
+
import { glyphProps, readDrawnGlyph, readGlyph, readHiddenGlyph, } from './glyph.js';
|
|
14
18
|
import { ruleId } from './rules.js';
|
|
15
19
|
/** The button text `File` renders when it's given none. */
|
|
16
20
|
const DEFAULT_FILE_LABEL = 'Choose a file\u2026';
|
|
@@ -227,7 +231,19 @@ export function plan(facts) {
|
|
|
227
231
|
: naming === 'unsure'
|
|
228
232
|
? { ...unnamed, ...entry.namedDefaults.defaults }
|
|
229
233
|
: unnamed;
|
|
230
|
-
|
|
234
|
+
// Font Awesome's own markup hides the <i> rather than the element around
|
|
235
|
+
// it, and a target that renders the glyph from props writes the same
|
|
236
|
+
// `aria-hidden` on the element in its place: it moves up, and the glyph is
|
|
237
|
+
// hidden either way. The one difference in markup a conversion makes, on
|
|
238
|
+
// purpose; the render tests compare it with the attribute moved up. Only
|
|
239
|
+
// onto an element that carries nothing assistive tech reads, by name and
|
|
240
|
+
// whatever the value: an expression may render as anything.
|
|
241
|
+
const moved = entry.readsGlyph &&
|
|
242
|
+
defaults['aria-hidden'] === 'true' &&
|
|
243
|
+
[...attributes.keys()].every(name => movesBeside(entry, name))
|
|
244
|
+
? readHiddenGlyph(facts.soleChild)
|
|
245
|
+
: undefined;
|
|
246
|
+
const missing = [...Object.entries(defaults), ...written].filter(([name]) => !attributes.has(name) && !(moved && name === 'aria-hidden'));
|
|
231
247
|
const drop = [];
|
|
232
248
|
for (const name of entry.untypedAttrs ?? []) {
|
|
233
249
|
if (!attributes.has(name))
|
|
@@ -316,7 +332,10 @@ export function plan(facts) {
|
|
|
316
332
|
}
|
|
317
333
|
if (missing.length > 0) {
|
|
318
334
|
const list = missing.map(([name, value]) => `\`${name}="${value}"\``);
|
|
319
|
-
|
|
335
|
+
const usual = `bestax \`${target}\` renders ${list.join(' and ')} when the element does not set ${missing.length === 1 ? 'it' : 'them'}; add ${missing.length === 1 ? 'it' : 'them'} here if that is what you want, then re-run`;
|
|
336
|
+
return refuse('defaults', target, entry.readsGlyph && naming === 'unnamed'
|
|
337
|
+
? hiddenAdvice(facts, entry, usual)
|
|
338
|
+
: usual);
|
|
320
339
|
}
|
|
321
340
|
for (const [name, rule] of Object.entries(entry.writesAttr ?? {})) {
|
|
322
341
|
const value = attributes.get(name);
|
|
@@ -326,8 +345,14 @@ export function plan(facts) {
|
|
|
326
345
|
return refuse('attr', name, `bestax \`${target}\` keeps a <${tag}>'s \`${name}\` only as ${orList(rule.keeps)}, and writes \`${name}="${rule.fallback}"\` in place of anything else, so this one converts only ${rule.implicit ? `with no \`${name}\` or as one of those` : 'as one of those, written out'}; keep this element as markup`);
|
|
327
346
|
}
|
|
328
347
|
}
|
|
348
|
+
// Only on a tag the target renders: on any other, the tag check below is
|
|
349
|
+
// the refusal, and a `drops` one would call an attribute inert that may not
|
|
350
|
+
// be (`type` on a <button>) and promise a conversion a re-run still refuses.
|
|
351
|
+
const tagReached = tag === entry.tag ||
|
|
352
|
+
entry.as === 'any' ||
|
|
353
|
+
(entry.as?.includes(tag) ?? false);
|
|
329
354
|
for (const [name, tags] of Object.entries(entry.dropsAttr ?? {})) {
|
|
330
|
-
if (attributes.has(name) && inTagSet(tags, tag)) {
|
|
355
|
+
if (tagReached && attributes.has(name) && inTagSet(tags, tag)) {
|
|
331
356
|
// Bulma greys out `.button[disabled]` on any tag, so there it is not
|
|
332
357
|
// inert: dropping it changes how the element looks.
|
|
333
358
|
const visible = name === 'disabled' && target === 'Button';
|
|
@@ -353,9 +378,6 @@ export function plan(facts) {
|
|
|
353
378
|
if (renders !== tag) {
|
|
354
379
|
const reachable = entry.as === 'any' || (entry.as?.includes(tag) ?? false);
|
|
355
380
|
if (!reachable) {
|
|
356
|
-
if (entry.otherTagsStay?.tags.includes(tag)) {
|
|
357
|
-
return { conversion: null, todos };
|
|
358
|
-
}
|
|
359
381
|
return refuse('tag', target, `bestax \`${target}\` renders ${tagsItReaches(entry)}, not a <${tag}>; keep the markup, or change the tag and re-run`);
|
|
360
382
|
}
|
|
361
383
|
as = tag;
|
|
@@ -441,6 +463,8 @@ export function plan(facts) {
|
|
|
441
463
|
if (entry.classNameReplaces && (rest.length > 0 || conditionalStays)) {
|
|
442
464
|
return refuse('attr', 'className', `bestax \`${target}\` writes a \`className\` it's given in place of \`.${root}\`, so this converts only with no other class; keep it as markup`);
|
|
443
465
|
}
|
|
466
|
+
// A glyph the target renders from props takes the place of the only child.
|
|
467
|
+
const glyph = moved ?? (entry.readsGlyph ? readGlyph(facts.soleChild) : undefined);
|
|
444
468
|
return {
|
|
445
469
|
conversion: {
|
|
446
470
|
target,
|
|
@@ -449,9 +473,11 @@ export function plan(facts) {
|
|
|
449
473
|
drop,
|
|
450
474
|
numbers,
|
|
451
475
|
...(absorbed ? { absorbs: absorbed } : {}),
|
|
452
|
-
...(counts || entry.rendersText !== undefined
|
|
476
|
+
...(counts || entry.rendersText !== undefined || glyph
|
|
453
477
|
? { rendersChildren: true }
|
|
454
478
|
: {}),
|
|
479
|
+
...(glyph ? { glyph } : {}),
|
|
480
|
+
...(moved ? { movesHidden: true } : {}),
|
|
455
481
|
...(parent ? { replacesParent: true } : {}),
|
|
456
482
|
...(conditional.length > 0 ? { conditional } : {}),
|
|
457
483
|
...(icons ? { icons } : {}),
|
|
@@ -555,6 +581,128 @@ function namingOf(entry, attributes) {
|
|
|
555
581
|
}
|
|
556
582
|
return given.includes(null) ? 'unsure' : 'unnamed';
|
|
557
583
|
}
|
|
584
|
+
/**
|
|
585
|
+
* Whether an element may carry `name` and still take Font Awesome's
|
|
586
|
+
* `aria-hidden` up off its <i>, by the table's `hiddenMovesBeside`, where a
|
|
587
|
+
* name ending in `*` stands for every attribute it starts.
|
|
588
|
+
*/
|
|
589
|
+
function movesBeside(entry, name) {
|
|
590
|
+
return (entry.readsGlyph?.hiddenMovesBeside ?? []).some(allowed => allowed.endsWith('*')
|
|
591
|
+
? name.startsWith(allowed.slice(0, -1))
|
|
592
|
+
: name === allowed);
|
|
593
|
+
}
|
|
594
|
+
/**
|
|
595
|
+
* What to do about an unnamed element whose target hides it with an
|
|
596
|
+
* `aria-hidden` it doesn't carry, and that renders a glyph from props
|
|
597
|
+
* (`Icon`), for its `defaults` TODO: from what it holds (Font Awesome's own
|
|
598
|
+
* `<i aria-hidden>`, the `<svg>` its script draws) and where it sits (a
|
|
599
|
+
* link or button its label names, or one nothing names). Each says what a
|
|
600
|
+
* re-run converts it to once the attribute is in place, when that's sure,
|
|
601
|
+
* and inside a `.control` with icons, the `Control` prop that renders it.
|
|
602
|
+
* `usual` is the message for anything else.
|
|
603
|
+
*/
|
|
604
|
+
function hiddenAdvice(facts, entry, usual) {
|
|
605
|
+
const target = entry.target;
|
|
606
|
+
const sole = facts.soleChild;
|
|
607
|
+
// Font Awesome's own markup hides the <i>, not the `.icon` around it.
|
|
608
|
+
const flag = sole?.attributes.get('aria-hidden');
|
|
609
|
+
const hiddenFont = sole?.tag === 'i' && (flag === 'true' || flag === true);
|
|
610
|
+
const drawn = readDrawnGlyph(sole);
|
|
611
|
+
// The element as a re-run would find it, the attribute in place (moved up
|
|
612
|
+
// off the <i> that carries it): the planner says what that converts to.
|
|
613
|
+
const attributes = new Map(facts.attributes).set('aria-hidden', 'true');
|
|
614
|
+
const retry = plan({
|
|
615
|
+
...facts,
|
|
616
|
+
attributes,
|
|
617
|
+
...(hiddenFont && {
|
|
618
|
+
soleChild: {
|
|
619
|
+
...sole,
|
|
620
|
+
attributes: new Map([...sole.attributes].filter(([name]) => name !== 'aria-hidden')),
|
|
621
|
+
},
|
|
622
|
+
}),
|
|
623
|
+
}).conversion;
|
|
624
|
+
// Only where nothing in it converts on its own, which would change what a
|
|
625
|
+
// re-run finds: an <i> the glyph takes the place of, or an <svg>.
|
|
626
|
+
const outcome = retry?.glyph
|
|
627
|
+
? `, and this converts to \`${target}\` with ${jsxProps(glyphProps(retry.glyph))}`
|
|
628
|
+
: retry && sole?.tag === 'svg'
|
|
629
|
+
? `, and this converts to \`${target}\` around the <svg> as it is`
|
|
630
|
+
: '';
|
|
631
|
+
const hint = controlHint(facts, retry, retry?.glyph ?? drawn);
|
|
632
|
+
// A bare <i> naming a glyph moves it up by itself, onto an element that
|
|
633
|
+
// carries nothing else assistive tech reads, so this one carries more.
|
|
634
|
+
const exposed = readHiddenGlyph(sole)
|
|
635
|
+
? [...facts.attributes.keys()].find(name => !movesBeside(entry, name))
|
|
636
|
+
: undefined;
|
|
637
|
+
if (exposed) {
|
|
638
|
+
return `bestax \`${target}\` takes Font Awesome's \`aria-hidden\` up off a bare <i> like this one only onto a \`.icon\` that carries nothing assistive tech reads, and this one carries \`${exposed}\`, which the move would hide, or, beside a \`role\` or \`tabIndex\`, leave with no \`aria-hidden\` at all; if the icon means something, give the \`.icon\` an \`aria-label\` and \`role="img"\`, and if it is decoration, drop \`${exposed}\`, then re-run`;
|
|
639
|
+
}
|
|
640
|
+
if (hiddenFont) {
|
|
641
|
+
// A bare <i> naming a glyph moves it up by itself, so this one isn't.
|
|
642
|
+
return `bestax \`${target}\` writes \`aria-hidden="true"\` on the \`.icon\`, and takes it from the <i> inside only when that <i> is empty, carries nothing else and names a glyph it renders from props, which this one doesn't; the \`.icon\` holds nothing else, so the attribute hides the same glyph there: move it up onto the \`.icon\`, then re-run${outcome}${hint}`;
|
|
643
|
+
}
|
|
644
|
+
if (drawn) {
|
|
645
|
+
return `this \`.icon\` holds the <svg> Font Awesome's script draws in place of an <i>, and bestax \`${target}\` writes \`aria-hidden="true"\` on the \`.icon\`, which this one doesn't carry; add it, then re-run${outcome}; or write \`${target}\` with ${jsxProps(glyphProps(drawn))} in its place, which renders the <i> the script draws from, and shows only where Font Awesome's stylesheet or script is loaded${hint}`;
|
|
646
|
+
}
|
|
647
|
+
const around = facts.clickableAround;
|
|
648
|
+
const label = around?.label;
|
|
649
|
+
const tag = around && `${/^[aeiou]/.test(around.tag) ? 'an' : 'a'} <${around.tag}>`;
|
|
650
|
+
if (label && label !== 'none') {
|
|
651
|
+
const by = label === 'text' ? 'its own text' : `its \`${label}\``;
|
|
652
|
+
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}`;
|
|
653
|
+
}
|
|
654
|
+
if (label === 'none' && readGlyph(sole)) {
|
|
655
|
+
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}> an \`aria-label\` that says what it does, then add \`aria-hidden="true"\` here, which bestax \`${target}\` writes on an icon with no name of its own, and re-run${outcome}${hint}`;
|
|
656
|
+
}
|
|
657
|
+
return `${usual}${outcome}${hint}`;
|
|
658
|
+
}
|
|
659
|
+
/**
|
|
660
|
+
* Inside a `.control` with icons on this element's side, the `Control` prop
|
|
661
|
+
* that renders the element once it's hidden as `converted` is: given the
|
|
662
|
+
* glyph, the props its classes write and nothing else, since `Control`
|
|
663
|
+
* writes the side's own class over any `className` it's given. Empty when
|
|
664
|
+
* the element carries anything more: another class, an attribute of its own
|
|
665
|
+
* or a class a condition adds.
|
|
666
|
+
*/
|
|
667
|
+
function controlHint(facts, converted, glyph) {
|
|
668
|
+
const side = converted?.className === 'is-left'
|
|
669
|
+
? 'Left'
|
|
670
|
+
: converted?.className === 'is-right'
|
|
671
|
+
? 'Right'
|
|
672
|
+
: undefined;
|
|
673
|
+
const has = `has-icons-${side?.toLowerCase()}`;
|
|
674
|
+
if (!glyph ||
|
|
675
|
+
!side ||
|
|
676
|
+
facts.conditional?.length ||
|
|
677
|
+
!facts.parentTokens?.includes('control') ||
|
|
678
|
+
!facts.parentTokens.includes(has) ||
|
|
679
|
+
facts.attributes.size > 0) {
|
|
680
|
+
return '';
|
|
681
|
+
}
|
|
682
|
+
const object = [...glyphProps(glyph), ...converted.props]
|
|
683
|
+
.map(([name, value]) => `${name}: ${value === true
|
|
684
|
+
? 'true'
|
|
685
|
+
: converted.numbers.includes(name)
|
|
686
|
+
? String(Number(value))
|
|
687
|
+
: valueText(value)}`)
|
|
688
|
+
.join(', ');
|
|
689
|
+
return `; or, since the \`.control\` around it has \`${has}\`, drop this \`.icon\` and give that \`Control\` \`icon${side}={{ ${object} }}\`, which it renders after its children as a \`.icon.is-${side.toLowerCase()}\` around the glyph's <i>, hidden the way \`Icon\` hides it`;
|
|
690
|
+
}
|
|
691
|
+
/** A glyph's props as JSX attributes, for a message. */
|
|
692
|
+
function jsxProps(props) {
|
|
693
|
+
const text = props
|
|
694
|
+
.map(([name, value]) => typeof value === 'string'
|
|
695
|
+
? `${name}="${value}"`
|
|
696
|
+
: `${name}={${valueText(value)}}`)
|
|
697
|
+
.join(' ');
|
|
698
|
+
return `\`${text}\``;
|
|
699
|
+
}
|
|
700
|
+
/** A prop's value as code, for a message: a list as an array of strings. */
|
|
701
|
+
function valueText(value) {
|
|
702
|
+
return typeof value === 'string'
|
|
703
|
+
? JSON.stringify(value)
|
|
704
|
+
: `[${value.map(item => JSON.stringify(item)).join(', ')}]`;
|
|
705
|
+
}
|
|
558
706
|
/**
|
|
559
707
|
* The icons a target that `buildsIcons` builds from an element's children:
|
|
560
708
|
* each `.icon` that converts to `Icon` on its own and holds a glyph `Icon`
|
|
@@ -583,25 +731,13 @@ function buildIcons(children, target) {
|
|
|
583
731
|
const loose = [...child.attributes.keys()].some(name => name === 'key' ||
|
|
584
732
|
name === 'ref' ||
|
|
585
733
|
(name.includes('-') && !name.startsWith('aria-')));
|
|
586
|
-
|
|
734
|
+
// The `.icon` read its glyph itself when it converted on its own.
|
|
735
|
+
const glyph = icon.glyph;
|
|
587
736
|
if (!glyph || loose)
|
|
588
737
|
return { why: shape };
|
|
589
|
-
const props = [
|
|
590
|
-
['library', glyph.library],
|
|
591
|
-
['name', glyph.name],
|
|
592
|
-
];
|
|
593
|
-
if (glyph.variant)
|
|
594
|
-
props.push(['variant', glyph.variant]);
|
|
595
|
-
const { features } = glyph;
|
|
596
|
-
if (features) {
|
|
597
|
-
props.push([
|
|
598
|
-
'features',
|
|
599
|
-
features.length === 1 ? features[0] : features,
|
|
600
|
-
]);
|
|
601
|
-
}
|
|
602
738
|
icons.push({
|
|
603
739
|
index,
|
|
604
|
-
props: [...
|
|
740
|
+
props: [...glyphProps(glyph), ...icon.props],
|
|
605
741
|
className: icon.className,
|
|
606
742
|
drop: icon.drop,
|
|
607
743
|
numbers: icon.numbers,
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
* What the bulma-classes transform needs to know about the project and cannot
|
|
3
3
|
* see from one file: which files a Next.js App Router may render as server
|
|
4
4
|
* components, which packages render JSX through a runtime other than React,
|
|
5
|
-
* and
|
|
5
|
+
* and, for the module an HTML page becomes, which are written in TypeScript
|
|
6
|
+
* and which are Next.js apps, where that module imports no stylesheet.
|
|
6
7
|
*
|
|
7
8
|
* Read once per run, from every package.json the run touches: the nearest one
|
|
8
9
|
* above each target, and every one below it, so a monorepo run from its root
|
|
@@ -26,11 +27,16 @@ export interface ServerComponentRoot {
|
|
|
26
27
|
dir: string;
|
|
27
28
|
except: string[];
|
|
28
29
|
}
|
|
29
|
-
/** A package, and
|
|
30
|
+
/** A package, and what a module it gains should be written for. */
|
|
30
31
|
export interface PackageLanguage {
|
|
31
32
|
dir: string;
|
|
32
33
|
/** It has a `tsconfig.json`, or depends on `typescript`. */
|
|
33
34
|
typescript: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* It depends on `next`, whose Pages Router takes a global stylesheet only
|
|
37
|
+
* in `pages/_app`, so a page's module imports none there.
|
|
38
|
+
*/
|
|
39
|
+
nextjs?: boolean;
|
|
34
40
|
}
|
|
35
41
|
export interface ProjectFacts {
|
|
36
42
|
serverComponentRoots: ServerComponentRoot[];
|
|
@@ -49,4 +55,6 @@ export declare function analyzeProject(targets: string[]): ProjectFacts;
|
|
|
49
55
|
* innermost package around it says, and no when no package does.
|
|
50
56
|
*/
|
|
51
57
|
export declare function writesTypeScript(file: string, languages: unknown): boolean;
|
|
58
|
+
/** Whether the innermost package around `file` is a Next.js app. */
|
|
59
|
+
export declare function inNextApp(file: string, languages: unknown): boolean;
|
|
52
60
|
//# sourceMappingURL=project.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../../src/sources/bulma-classes/project.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../../src/sources/bulma-classes/project.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAKH,qDAAqD;AACrD,eAAO,MAAM,cAAc,EAAE,WAAW,CAAC,MAAM,CAK7C,CAAC;AAqBH,MAAM,WAAW,UAAU;IACzB,uCAAuC;IACvC,GAAG,EAAE,MAAM,CAAC;IACZ,6DAA6D;IAC7D,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;;GAKG;AACH,MAAM,WAAW,mBAAmB;IAClC,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAED,mEAAmE;AACnE,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,4DAA4D;IAC5D,UAAU,EAAE,OAAO,CAAC;IACpB;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,YAAY;IAC3B,oBAAoB,EAAE,mBAAmB,EAAE,CAAC;IAC5C,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,gBAAgB,EAAE,eAAe,EAAE,CAAC;CACrC;AA2GD;;;;GAIG;AACH,wBAAgB,SAAS,CACvB,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,GACjD,MAAM,GAAG,IAAI,CAKf;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,YAAY,CAuD9D;AAcD;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,GAAG,OAAO,CAE1E;AAED,oEAAoE;AACpE,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,GAAG,OAAO,CAEnE"}
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
* What the bulma-classes transform needs to know about the project and cannot
|
|
3
3
|
* see from one file: which files a Next.js App Router may render as server
|
|
4
4
|
* components, which packages render JSX through a runtime other than React,
|
|
5
|
-
* and
|
|
5
|
+
* and, for the module an HTML page becomes, which are written in TypeScript
|
|
6
|
+
* and which are Next.js apps, where that module imports no stylesheet.
|
|
6
7
|
*
|
|
7
8
|
* Read once per run, from every package.json the run touches: the nearest one
|
|
8
9
|
* above each target, and every one below it, so a monorepo run from its root
|
|
@@ -206,20 +207,28 @@ export function analyzeProject(targets) {
|
|
|
206
207
|
dir,
|
|
207
208
|
typescript: Boolean(deps.typescript) ||
|
|
208
209
|
fs.existsSync(path.join(dir, 'tsconfig.json')),
|
|
210
|
+
nextjs: Boolean(deps.next),
|
|
209
211
|
});
|
|
210
212
|
}
|
|
211
213
|
return facts;
|
|
212
214
|
}
|
|
215
|
+
/** The innermost package around `file` of those the run read, if any. */
|
|
216
|
+
function packageAround(file, languages) {
|
|
217
|
+
if (!Array.isArray(languages))
|
|
218
|
+
return undefined;
|
|
219
|
+
const resolved = path.resolve(file);
|
|
220
|
+
return languages
|
|
221
|
+
.filter(entry => resolved.startsWith(`${entry.dir}${path.sep}`))
|
|
222
|
+
.sort((a, b) => b.dir.length - a.dir.length)[0];
|
|
223
|
+
}
|
|
213
224
|
/**
|
|
214
225
|
* Whether a new module beside `file` should be TypeScript: what the
|
|
215
226
|
* innermost package around it says, and no when no package does.
|
|
216
227
|
*/
|
|
217
228
|
export function writesTypeScript(file, languages) {
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
.sort((a, b) => b.dir.length - a.dir.length)[0];
|
|
224
|
-
return found?.typescript ?? false;
|
|
229
|
+
return packageAround(file, languages)?.typescript ?? false;
|
|
230
|
+
}
|
|
231
|
+
/** Whether the innermost package around `file` is a Next.js app. */
|
|
232
|
+
export function inNextApp(file, languages) {
|
|
233
|
+
return packageAround(file, languages)?.nextjs ?? false;
|
|
225
234
|
}
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
* Unlike the library sources there is no import to anchor on: a file is in
|
|
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
|
-
* converts it only when the component renders exactly the same markup
|
|
7
|
+
* converts it only when the component renders exactly the same markup, but
|
|
8
|
+
* for the one exception it states (Font Awesome's hidden `<i>`).
|
|
8
9
|
*
|
|
9
10
|
* Passes, in order:
|
|
10
11
|
* 1. the shared stylesheet-import pass (a no-op under the default `keep`)
|
|
@@ -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;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAW,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE1D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAkiCvD,MAAM,CAAC,OAAO,UAAU,SAAS,CAC/B,QAAQ,EAAE,QAAQ,EAClB,GAAG,EAAE,GAAG,EACR,OAAO,GAAE,gBAAqB,GAC7B,MAAM,GAAG,SAAS,CAs9BpB"}
|