bestax-migrate 2.25.6 → 2.26.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 +7 -1
- package/dist/cli.d.ts +9 -2
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +92 -9
- package/dist/sources/_shared/html/whitespace.d.ts +21 -0
- package/dist/sources/_shared/html/whitespace.d.ts.map +1 -1
- package/dist/sources/_shared/html/whitespace.js +12 -6
- package/dist/sources/bulma-classes/class-map.d.ts +6 -0
- package/dist/sources/bulma-classes/class-map.d.ts.map +1 -1
- package/dist/sources/bulma-classes/class-map.js +10 -0
- package/dist/sources/bulma-classes/display.d.ts +11 -1
- package/dist/sources/bulma-classes/display.d.ts.map +1 -1
- package/dist/sources/bulma-classes/display.js +33 -1
- package/dist/sources/bulma-classes/html-rules.d.ts +27 -0
- package/dist/sources/bulma-classes/html-rules.d.ts.map +1 -0
- package/dist/sources/bulma-classes/html-rules.js +89 -0
- package/dist/sources/bulma-classes/html.d.ts +84 -0
- package/dist/sources/bulma-classes/html.d.ts.map +1 -0
- package/dist/sources/bulma-classes/html.js +948 -0
- package/dist/sources/bulma-classes/index.d.ts.map +1 -1
- package/dist/sources/bulma-classes/index.js +4 -0
- package/dist/sources/bulma-classes/plan.d.ts.map +1 -1
- package/dist/sources/bulma-classes/plan.js +4 -3
- package/dist/sources/bulma-classes/project.d.ts +14 -2
- package/dist/sources/bulma-classes/project.d.ts.map +1 -1
- package/dist/sources/bulma-classes/project.js +25 -3
- package/dist/types.d.ts +22 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -19,6 +19,7 @@ Currently supported sources:
|
|
|
19
19
|
| [`rbx`](https://github.com/dfee/rbx) (v2) | ✅ Full export surface mapped (a few patterns are flagged as TODOs) |
|
|
20
20
|
| [`bloomer`](https://github.com/AlgusDark/bloomer) (0.6) | ✅ All 108 exports mapped (Font Awesome 4 icons and Bulma 0.4's `Nav` are flagged) |
|
|
21
21
|
| `bulma-classes`: Bulma's classes on plain JSX, no library | ✅ Converts an element only when bestax renders the same markup; the rest is flagged |
|
|
22
|
+
| `bulma-classes` on HTML: static pages and templates styled with Bulma | ✅ Writes a React component beside each page; its head and scripts are flagged |
|
|
22
23
|
|
|
23
24
|
Pass the source as the first argument: `bestax-migrate <source> <paths…>`.
|
|
24
25
|
|
|
@@ -40,6 +41,10 @@ pnpm dlx bestax-migrate rbx src/ --dry
|
|
|
40
41
|
pnpm dlx bestax-migrate bloomer src/ --dry
|
|
41
42
|
# …or, for an app that writes Bulma's classes on plain JSX
|
|
42
43
|
pnpm dlx bestax-migrate bulma-classes src/ --dry
|
|
44
|
+
# …or, for static HTML pages styled with Bulma: name a page, or walk a folder with -e html
|
|
45
|
+
# (-e html,htm takes .htm pages too)
|
|
46
|
+
pnpm dlx bestax-migrate bulma-classes src/pages/login/index.html --dry
|
|
47
|
+
pnpm dlx bestax-migrate bulma-classes -e html src/pages/ --dry
|
|
43
48
|
|
|
44
49
|
# Apply the migration
|
|
45
50
|
pnpm dlx bestax-migrate react-bulma-components src/
|
|
@@ -54,6 +59,7 @@ The codemod uses [jscodeshift](https://github.com/facebook/jscodeshift) to:
|
|
|
54
59
|
- convert props (`renderAs` → `as`, `loading` → `isLoading`, numeric spacing/text sizes → string unions, `textAlign="center"` → `textAlign="centered"`, …)
|
|
55
60
|
- flatten responsive breakpoint objects (`mobile={{ size: 4 }}` → `sizeMobile={4}`) and bloomer's `isDisplay`/`isHidden` strings, arrays and objects (`isHidden="touch"` → `visibilityTouch="hidden"`)
|
|
56
61
|
- for `bulma-classes`, turn raw Bulma markup into components and props (`<a className="button is-primary">` → `<Button as="a" color="primary">`, `<p className="has-text-centered mt-4">` → `<Paragraph textAlign="centered" mt="4">`), converting an element only when bestax renders exactly the same markup
|
|
62
|
+
- for `bulma-classes` on an HTML page, write a React module beside it (`index.html` → `index.tsx`, or `.jsx` when the package isn't TypeScript) whose default export is the page's body as a component (`LoginPage`), converted as the same markup written as JSX would be. The page is never changed and an existing module is never overwritten; the head, the `<html>` and `<body>` attributes, scripts and inline handlers are left as `html-*` TODOs
|
|
57
63
|
- restructure patterns bestax models differently (`Table.Container`, Navbar dropdowns, `Form.Help`, icon-font children → `<Icon name=…>`)
|
|
58
64
|
- migrate stylesheets: CSS imports converge on `@allxsmith/bestax-bulma/bestax.css`, and SCSS files move from Bulma 0.9's `@import` + `$var !default` overrides to `@use 'bulma/sass' with (…)` plus `@use '@allxsmith/bestax-bulma/scss/extras'`
|
|
59
65
|
- update `package.json`: remove the source library, add `@allxsmith/bestax-bulma`, raise a declared pre-1.0 `bulma` to `^1` (adding it only when your sources import `bulma/…` directly — otherwise it arrives transitively), and swap the dead `node-sass` for dart `sass` (no install is ever run). Migrating **rbx** is what frees an app from Bulma 0.7.5: rbx pinned it as a _direct_ dependency, so the app could not choose its own Bulma version at all. The four Bulma extensions rbx also pulled in (`bulma-badge`, `bulma-divider`, `bulma-pageloader`, `bulma-tooltip`) are **reported rather than removed** — bestax replaces all four, but a manifest entry is a deliberate declaration and your own Sass may import them. A **bloomer** app declared its own Bulma 0.6, which is what gets bumped. For **bulma-classes** there is no library to remove, and by default (`--css keep`) the app's Bulma version, Sass and stylesheet imports all stay: its own Bulma already styles every class a converted element renders. `--css bestax` or `--css bulma` moves it to Bulma v1 like the other sources
|
|
@@ -83,7 +89,7 @@ Run it from your app root. `--param paths="src lib"` (default `src`) and `--para
|
|
|
83
89
|
| -------------------- | ---------------------------------------------------------------------------------------------- |
|
|
84
90
|
| `--dry`, `-d` | Report what would change without writing files |
|
|
85
91
|
| `--print`, `-p` | Print transformed sources to stdout |
|
|
86
|
-
| `--extensions`, `-e` | File extensions to include (default `js,jsx,ts,tsx,scss,sass`)
|
|
92
|
+
| `--extensions`, `-e` | File extensions to include in a folder (default `js,jsx,ts,tsx,scss,sass`; `html` for pages) |
|
|
87
93
|
| `--css <mode>` | Stylesheet target: `bestax`, `bulma`, or `keep` (default `bestax`; `keep` for `bulma-classes`) |
|
|
88
94
|
| `--no-deps` | Skip updating package.json dependencies |
|
|
89
95
|
|
package/dist/cli.d.ts
CHANGED
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
* [--telemetry|--no-telemetry]
|
|
7
7
|
*
|
|
8
8
|
* Walks the given files/directories, routes each file by type (JS/TSX →
|
|
9
|
-
* jscodeshift transform, .scss/.sass → the source's stylesheet transform
|
|
9
|
+
* jscodeshift transform, .scss/.sass → the source's stylesheet transform,
|
|
10
|
+
* .html/.htm → a new module beside the page, for a source that reads HTML),
|
|
10
11
|
* updates the nearest package.json (unless --no-deps), writes results back
|
|
11
12
|
* (unless --dry), and prints the run report. TODO annotations are expected
|
|
12
13
|
* output — the exit code is 0 whenever the run itself succeeds.
|
|
@@ -16,7 +17,13 @@ import type { Readable, Writable } from 'node:stream';
|
|
|
16
17
|
import { Command } from 'commander';
|
|
17
18
|
import { type MigrateRunStats } from './telemetry.js';
|
|
18
19
|
import type { MigrationSource } from './types.js';
|
|
19
|
-
|
|
20
|
+
/**
|
|
21
|
+
* The files to migrate: those with one of `extensions` in the folders walked,
|
|
22
|
+
* and every file named, whose extension is one of those or of `named`. A
|
|
23
|
+
* named HTML page is the only use there is for naming one, while a walk meets
|
|
24
|
+
* HTML nobody wants converted (Vite's `index.html`, `public/`).
|
|
25
|
+
*/
|
|
26
|
+
export declare function collectFiles(targets: string[], extensions: string[], named?: readonly string[]): string[];
|
|
20
27
|
/** Nearest package.json for each target, walking up to the filesystem root. */
|
|
21
28
|
export declare function findPackageJsons(targets: string[]): string[];
|
|
22
29
|
export interface CliIo {
|
package/dist/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;A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ACnC,KAAK,EAAE,eAAe,EACtB,IAAI,EAAE,OAAO,GAAG,SAAS,EACzB,EAAE,EAAE,KAAK,EACT,aAAa,GAAE,CAAC,EAAE,EAAE,KAAK,KAAK,OAAO,CAAC,OAAO,GAAG,IAAI,CAA0B,GAC7E,OAAO,CAAC,IAAI,CAAC,CAqBf;AAYD,wBAAgB,SAAS,CACvB,EAAE,GAAE,KAAkD,GACrD,OAAO,CA+IT"}
|
package/dist/cli.js
CHANGED
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
* [--telemetry|--no-telemetry]
|
|
7
7
|
*
|
|
8
8
|
* Walks the given files/directories, routes each file by type (JS/TSX →
|
|
9
|
-
* jscodeshift transform, .scss/.sass → the source's stylesheet transform
|
|
9
|
+
* jscodeshift transform, .scss/.sass → the source's stylesheet transform,
|
|
10
|
+
* .html/.htm → a new module beside the page, for a source that reads HTML),
|
|
10
11
|
* updates the nearest package.json (unless --no-deps), writes results back
|
|
11
12
|
* (unless --dry), and prints the run report. TODO annotations are expected
|
|
12
13
|
* output — the exit code is 0 whenever the run itself succeeds.
|
|
@@ -30,14 +31,25 @@ const SKIP_DIRS = new Set([
|
|
|
30
31
|
]);
|
|
31
32
|
const STYLE_EXTENSIONS = new Set(['scss', 'sass']);
|
|
32
33
|
const CSS_MODES = ['bestax', 'bulma', 'keep'];
|
|
34
|
+
/** HTML pages, which only a source with `htmlExtensions` reads. */
|
|
35
|
+
const HTML_EXTENSIONS = ['html', 'htm'];
|
|
33
36
|
/**
|
|
34
37
|
* Component formats the codemod cannot parse (no jscodeshift grammar) but
|
|
35
38
|
* that can still import the source library — flagged, never rewritten.
|
|
36
39
|
*/
|
|
37
40
|
const UNSUPPORTED_EXTENSIONS = ['astro', 'vue', 'svelte', 'mdx'];
|
|
38
|
-
|
|
41
|
+
function extensionOf(file) {
|
|
42
|
+
return path.extname(file).replace(/^\./, '');
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* The files to migrate: those with one of `extensions` in the folders walked,
|
|
46
|
+
* and every file named, whose extension is one of those or of `named`. A
|
|
47
|
+
* named HTML page is the only use there is for naming one, while a walk meets
|
|
48
|
+
* HTML nobody wants converted (Vite's `index.html`, `public/`).
|
|
49
|
+
*/
|
|
50
|
+
export function collectFiles(targets, extensions, named = []) {
|
|
39
51
|
const files = [];
|
|
40
|
-
const visit = (target) => {
|
|
52
|
+
const visit = (target, isNamed) => {
|
|
41
53
|
const stat = fs.statSync(target, { throwIfNoEntry: false });
|
|
42
54
|
if (!stat) {
|
|
43
55
|
throw new Error(`no such file or directory: ${target}`);
|
|
@@ -46,15 +58,18 @@ export function collectFiles(targets, extensions) {
|
|
|
46
58
|
if (SKIP_DIRS.has(path.basename(target)))
|
|
47
59
|
return;
|
|
48
60
|
for (const entry of fs.readdirSync(target).sort()) {
|
|
49
|
-
visit(path.join(target, entry));
|
|
61
|
+
visit(path.join(target, entry), false);
|
|
50
62
|
}
|
|
63
|
+
return;
|
|
51
64
|
}
|
|
52
|
-
|
|
65
|
+
const extension = extensionOf(target);
|
|
66
|
+
if (extensions.includes(extension) ||
|
|
67
|
+
(isNamed && named.includes(extension))) {
|
|
53
68
|
files.push(target);
|
|
54
69
|
}
|
|
55
70
|
};
|
|
56
71
|
for (const target of targets)
|
|
57
|
-
visit(target);
|
|
72
|
+
visit(target, true);
|
|
58
73
|
return files;
|
|
59
74
|
}
|
|
60
75
|
/** Nearest package.json for each target, walking up to the filesystem root. */
|
|
@@ -217,7 +232,12 @@ function migrateFiles(source, files, reporter, io, options, project) {
|
|
|
217
232
|
for (const file of files) {
|
|
218
233
|
const sourceText = fs.readFileSync(file, 'utf8');
|
|
219
234
|
const collector = reporter.startFile();
|
|
220
|
-
const extension =
|
|
235
|
+
const extension = extensionOf(file);
|
|
236
|
+
if (source.transformHtml && source.htmlExtensions?.includes(extension)) {
|
|
237
|
+
const changed = migrateHtmlPage(source.transformHtml, file, sourceText, collector, io, { ...options, project });
|
|
238
|
+
reporter.finishFile(file, changed, collector.entries);
|
|
239
|
+
continue;
|
|
240
|
+
}
|
|
221
241
|
let output;
|
|
222
242
|
try {
|
|
223
243
|
if (STYLE_EXTENSIONS.has(extension)) {
|
|
@@ -264,6 +284,55 @@ function migrateFiles(source, files, reporter, io, options, project) {
|
|
|
264
284
|
}
|
|
265
285
|
return { bulmaReferenced, sourceStillImported };
|
|
266
286
|
}
|
|
287
|
+
/**
|
|
288
|
+
* One HTML page: its module is written beside it (never over a file already
|
|
289
|
+
* there; the source checks), and the page itself is left as it was.
|
|
290
|
+
*/
|
|
291
|
+
function migrateHtmlPage(transformHtml, file, sourceText, collector, io, options) {
|
|
292
|
+
let result;
|
|
293
|
+
try {
|
|
294
|
+
result = transformHtml(file, sourceText, collector, {
|
|
295
|
+
...options.project,
|
|
296
|
+
cssMode: options.cssMode,
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
catch (error) {
|
|
300
|
+
io.error(chalk.red(`✖ ${file}: ${error.message}`));
|
|
301
|
+
return false;
|
|
302
|
+
}
|
|
303
|
+
if (result.output === null)
|
|
304
|
+
return false;
|
|
305
|
+
if (options.print)
|
|
306
|
+
io.log(result.output);
|
|
307
|
+
if (options.dry) {
|
|
308
|
+
io.log(chalk.yellow(`Would write ${result.outputPath} from ${file}.`));
|
|
309
|
+
}
|
|
310
|
+
else {
|
|
311
|
+
fs.writeFileSync(result.outputPath, result.output);
|
|
312
|
+
io.log(chalk.green(`Wrote ${result.outputPath} from ${file}.`));
|
|
313
|
+
}
|
|
314
|
+
return true;
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* HTML pages a folder walk found but `--extensions` left out, reported when
|
|
318
|
+
* they carry what the source would convert, so a run over a folder of pages
|
|
319
|
+
* that `--extensions` leaves out doesn't just say nothing happened.
|
|
320
|
+
*/
|
|
321
|
+
function reportExcludedHtml(source, targets, reporter, extensions) {
|
|
322
|
+
const left = (source.htmlExtensions ?? []).filter(ext => !extensions.includes(ext));
|
|
323
|
+
const find = source.excludedHtml;
|
|
324
|
+
if (left.length === 0 || !find)
|
|
325
|
+
return;
|
|
326
|
+
const folders = targets.filter(target => fs.statSync(target, { throwIfNoEntry: false })?.isDirectory());
|
|
327
|
+
for (const file of collectFiles(folders, left)) {
|
|
328
|
+
const entry = find(file, fs.readFileSync(file, 'utf8'));
|
|
329
|
+
if (!entry)
|
|
330
|
+
continue;
|
|
331
|
+
const collector = reporter.startFile();
|
|
332
|
+
collector.add(entry);
|
|
333
|
+
reporter.finishFile(file, false, collector.entries);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
267
336
|
/**
|
|
268
337
|
* Surface files in unparseable formats (.astro, .vue, …) that import the
|
|
269
338
|
* source library, so a migration never silently skips them.
|
|
@@ -450,7 +519,7 @@ export function createCLI(io = { log: console.log, error: console.error }) {
|
|
|
450
519
|
.argument('<paths...>', 'files or directories to transform')
|
|
451
520
|
.option('-d, --dry', 'dry run — report what would change without writing', false)
|
|
452
521
|
.option('-p, --print', 'print transformed sources to stdout', false)
|
|
453
|
-
.option('-e, --extensions <list>', 'comma-separated file extensions to include', 'js,jsx,ts,tsx,scss,sass')
|
|
522
|
+
.option('-e, --extensions <list>', 'comma-separated file extensions to include in a folder (html for HTML pages)', 'js,jsx,ts,tsx,scss,sass')
|
|
454
523
|
.option('--css <mode>', `stylesheet target: ${CSS_MODES.join(', ')} (default bestax; keep for bulma-classes)`)
|
|
455
524
|
.option('--no-deps', 'skip updating package.json dependencies')
|
|
456
525
|
.option('--telemetry', 'enable anonymous usage telemetry (https://bestax.io/docs/guides/telemetry)')
|
|
@@ -472,9 +541,22 @@ export function createCLI(io = { log: console.log, error: console.error }) {
|
|
|
472
541
|
.split(',')
|
|
473
542
|
.map(ext => ext.trim())
|
|
474
543
|
.filter(Boolean);
|
|
544
|
+
const htmlExtensions = source.htmlExtensions ?? [];
|
|
545
|
+
if (htmlExtensions.length === 0) {
|
|
546
|
+
const asked = [
|
|
547
|
+
...extensions.filter(ext => HTML_EXTENSIONS.includes(ext)),
|
|
548
|
+
...targets.filter(target => HTML_EXTENSIONS.includes(extensionOf(target))),
|
|
549
|
+
];
|
|
550
|
+
if (asked.length > 0) {
|
|
551
|
+
const readers = sourceNames().filter(name => (getSource(name)?.htmlExtensions?.length ?? 0) > 0);
|
|
552
|
+
io.error(`${chalk.red('The ' + source.name + ' source reads no HTML pages')} (${asked.join(', ')}). HTML pages convert with: ${readers.join(', ')}`);
|
|
553
|
+
program.error('', { exitCode: 1 });
|
|
554
|
+
return;
|
|
555
|
+
}
|
|
556
|
+
}
|
|
475
557
|
let files;
|
|
476
558
|
try {
|
|
477
|
-
files = collectFiles(targets, extensions);
|
|
559
|
+
files = collectFiles(targets, extensions, htmlExtensions);
|
|
478
560
|
}
|
|
479
561
|
catch (error) {
|
|
480
562
|
io.error(chalk.red(error.message));
|
|
@@ -490,6 +572,7 @@ export function createCLI(io = { log: console.log, error: console.error }) {
|
|
|
490
572
|
const reporter = new Reporter();
|
|
491
573
|
const project = source.analyzeProject?.(targets) ?? {};
|
|
492
574
|
const depSignals = migrateFiles(source, files, reporter, io, runOptions, project);
|
|
575
|
+
reportExcludedHtml(source, targets, reporter, extensions);
|
|
493
576
|
const unsupportedImports = reportUnsupportedFiles(source, targets, reporter, extensions);
|
|
494
577
|
if (unsupportedImports)
|
|
495
578
|
depSignals.sourceStillImported = true;
|
|
@@ -67,14 +67,35 @@ export declare function inlineStyleDisplay(element: Element): string | undefined
|
|
|
67
67
|
* closed dialog). Undefined for an element in another namespace.
|
|
68
68
|
*/
|
|
69
69
|
export declare function uaDisplay(element: Element): string | undefined;
|
|
70
|
+
/**
|
|
71
|
+
* An element's inline `display`, when it is one CSS reads; undefined when it
|
|
72
|
+
* sets none, or one CSS ignores.
|
|
73
|
+
*/
|
|
74
|
+
export declare function validInlineDisplay(element: Element): string | undefined;
|
|
70
75
|
/**
|
|
71
76
|
* An inline `display`, when it is one CSS reads (otherwise the declaration
|
|
72
77
|
* is ignored), else the UA stylesheet's.
|
|
73
78
|
*/
|
|
74
79
|
export declare const defaultDisplayOf: DisplayOf;
|
|
80
|
+
/** How a box sits among its siblings. */
|
|
81
|
+
export type Outer = 'none' | 'block' | 'inline';
|
|
82
|
+
/**
|
|
83
|
+
* How a box's content flows: on in its parent's lines (`inline`), in lines
|
|
84
|
+
* of its own (`block`), or as boxes of its own, each child its own block
|
|
85
|
+
* (`boxes`).
|
|
86
|
+
*/
|
|
87
|
+
export type Inner = 'inline' | 'block' | 'boxes';
|
|
88
|
+
interface Box {
|
|
89
|
+
outer: Outer;
|
|
90
|
+
inner: Inner;
|
|
91
|
+
exact: boolean;
|
|
92
|
+
}
|
|
93
|
+
/** What a `display` value means for whitespace: how it sits, how it flows. */
|
|
94
|
+
export declare function boxOfDisplay(display: string | undefined): Omit<Box, 'exact'>;
|
|
75
95
|
/**
|
|
76
96
|
* Every element's and fragment's children as pieces, from `root` down.
|
|
77
97
|
* `root` is laid out as a block container, as a page's body is.
|
|
78
98
|
*/
|
|
79
99
|
export declare function layoutWhitespace(root: ParentNode, displayOf?: DisplayOf): Map<ParentNode, Piece[]>;
|
|
100
|
+
export {};
|
|
80
101
|
//# sourceMappingURL=whitespace.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"whitespace.d.ts","sourceRoot":"","sources":["../../../../src/sources/_shared/html/whitespace.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EAKL,KAAK,WAAW,EAChB,KAAK,OAAO,EACZ,KAAK,UAAU,EAEhB,MAAM,YAAY,CAAC;AAGpB,yEAAyE;AACzE,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,EAAE,OAAO,KAAK,MAAM,GAAG,SAAS,CAAC;AAEjE,MAAM,MAAM,KAAK;AACf,6CAA6C;AAC3C;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,OAAO,GAAG,WAAW,CAAA;CAAE;AAC/C,8CAA8C;GAC5C;IAAE,IAAI,EA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203
|
const DISPLAY_KEYWORDS = /^(?:none|contents|block|inline|run-in|flow|flow-root|table|flex|grid|ruby|list-item|inline-(?:block|table|flex|grid|list-item)|table-(?:row-group|header-group|footer-group|row|cell|column-group|column|caption)|ruby-(?:base|text|base-container|text-container))$/;
|
|
204
204
|
/**
|
|
205
|
-
* An inline `display`, when it is one CSS reads
|
|
206
|
-
*
|
|
205
|
+
* An element's inline `display`, when it is one CSS reads; undefined when it
|
|
206
|
+
* sets none, or one CSS ignores.
|
|
207
207
|
*/
|
|
208
|
-
export
|
|
208
|
+
export function validInlineDisplay(element) {
|
|
209
209
|
const inline = inlineStyleDisplay(element);
|
|
210
210
|
const valid = inline !== undefined &&
|
|
211
211
|
inline.split(/\s+/).every(word => DISPLAY_KEYWORDS.test(word));
|
|
212
|
-
return valid ? inline :
|
|
213
|
-
}
|
|
214
|
-
|
|
212
|
+
return valid ? inline : undefined;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* An inline `display`, when it is one CSS reads (otherwise the declaration
|
|
216
|
+
* is ignored), else the UA stylesheet's.
|
|
217
|
+
*/
|
|
218
|
+
export const defaultDisplayOf = element => validInlineDisplay(element) ?? uaDisplay(element);
|
|
219
|
+
/** What a `display` value means for whitespace: how it sits, how it flows. */
|
|
220
|
+
export function boxOfDisplay(display) {
|
|
215
221
|
const words = (display ?? 'inline').trim().split(/\s+/);
|
|
216
222
|
const has = (...names) => names.some(name => words.includes(name));
|
|
217
223
|
if (has('none'))
|
|
@@ -168,6 +168,12 @@ export interface RootEntry {
|
|
|
168
168
|
readonly on: readonly string[];
|
|
169
169
|
readonly fallback: string;
|
|
170
170
|
readonly keeps: readonly string[];
|
|
171
|
+
/**
|
|
172
|
+
* `fallback` is the tag's own implicit role (`Menu.List`'s
|
|
173
|
+
* `role="list"` on its <ul>), so an element that sets none is the
|
|
174
|
+
* same list and converts as well; only another value refuses.
|
|
175
|
+
*/
|
|
176
|
+
readonly implicit?: boolean;
|
|
171
177
|
}>>;
|
|
172
178
|
/**
|
|
173
179
|
* Attributes the element may carry that the target's props type rejects.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"class-map.d.ts","sourceRoot":"","sources":["../../../src/sources/bulma-classes/class-map.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,uCAAuC;IACvC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,qEAAqE;IACrE,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,MAAM,MAAM,MAAM,GAChB;IAAE,QAAQ,CAAC,EAAE,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,GAAG;IAAE,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,CAAC;AAE9E,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAE1D;AAED,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,MAAM,EAAE,SAAS,SAAS,EAAE,CAAC;IACtC,6EAA6E;IAC7E,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAC5B;;;;;;OAMG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;CACxE;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;AAE9D;;;;GAIG;AACH,MAAM,WAAW,OAAO;IACtB,uBAAuB;IACvB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB;;;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AAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAE1D"}
|
|
@@ -842,6 +842,8 @@ export const ROOTS = {
|
|
|
842
842
|
'`color` renders `has-text-<color>` on the input as well',
|
|
843
843
|
])),
|
|
844
844
|
adoptsIdFrom: ['Field'],
|
|
845
|
+
// The <input>'s own attributes, which React's types take as numbers.
|
|
846
|
+
numberAttrs: ['maxLength', 'minLength'],
|
|
845
847
|
ownProps: [
|
|
846
848
|
'color',
|
|
847
849
|
'size',
|
|
@@ -876,6 +878,8 @@ export const ROOTS = {
|
|
|
876
878
|
'`color` renders `has-text-<color>` on the textarea as well',
|
|
877
879
|
])),
|
|
878
880
|
adoptsIdFrom: ['Field'],
|
|
881
|
+
// The <textarea>'s own attributes, which React's types take as numbers.
|
|
882
|
+
numberAttrs: ['rows', 'cols', 'maxLength', 'minLength'],
|
|
879
883
|
ownProps: [
|
|
880
884
|
'color',
|
|
881
885
|
'size',
|
|
@@ -1486,6 +1490,12 @@ export const ROOTS = {
|
|
|
1486
1490
|
tag: 'ul',
|
|
1487
1491
|
textColor: 'color',
|
|
1488
1492
|
bgColor: 'backgroundColor',
|
|
1493
|
+
// Written after its props, for Safari, which drops a list's role once its
|
|
1494
|
+
// markers are hidden. A list with no role is the same list; one with
|
|
1495
|
+
// another role would lose it.
|
|
1496
|
+
writesAttr: {
|
|
1497
|
+
role: { on: ['ul'], fallback: 'list', keeps: ['list'], implicit: true },
|
|
1498
|
+
},
|
|
1489
1499
|
requiresChildren: true,
|
|
1490
1500
|
topLevelOnly: true,
|
|
1491
1501
|
ownProps: [],
|
|
@@ -37,6 +37,15 @@ export declare const COMPONENT_DISPLAY: Readonly<Record<string, BulmaDisplay | V
|
|
|
37
37
|
* only.
|
|
38
38
|
*/
|
|
39
39
|
export declare const HELPER_DISPLAY: Readonly<Record<string, BulmaDisplay | VaryingDisplay>>;
|
|
40
|
+
/**
|
|
41
|
+
* Bulma's rules that take an element out of the flow (`position: absolute`
|
|
42
|
+
* or `fixed`), at some viewport or all of them, by the same kind of selector
|
|
43
|
+
* as the display tables. A box out of the flow ends no line, so a run beside
|
|
44
|
+
* one is beside whatever is past it, whatever its display.
|
|
45
|
+
*/
|
|
46
|
+
export declare const OUT_OF_FLOW: readonly string[];
|
|
47
|
+
/** Whether a Bulma rule takes an element out of the flow at some viewport. */
|
|
48
|
+
export declare function bulmaOutOfFlow(classes: Iterable<string>): boolean;
|
|
40
49
|
export interface DisplayRule {
|
|
41
50
|
readonly tag: string | undefined;
|
|
42
51
|
readonly classes: readonly string[];
|
|
@@ -68,7 +77,8 @@ export declare function rulesOf(table: Readonly<Record<string, BulmaDisplay | Va
|
|
|
68
77
|
* `none` is no box at all (`.modal` until it is active), so a run beside one
|
|
69
78
|
* is beside whatever is past it. And these are displays alone: a box a rule
|
|
70
79
|
* also takes out of the flow (`.modal`'s `position: fixed`) still reads as
|
|
71
|
-
* its display here, though a run beside it is beside its neighbours
|
|
80
|
+
* its display here, though a run beside it is beside its neighbours, which
|
|
81
|
+
* is what `OUT_OF_FLOW` is for.
|
|
72
82
|
*/
|
|
73
83
|
export declare function bulmaDisplay(tag: string, classes: Iterable<string>): ReadonlySet<BulmaDisplay | undefined> | undefined;
|
|
74
84
|
//# sourceMappingURL=display.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"display.d.ts","sourceRoot":"","sources":["../../../src/sources/bulma-classes/display.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,MAAM,MAAM,YAAY,GACpB,OAAO,GACP,MAAM,GACN,MAAM,GACN,QAAQ,GACR,cAAc,GACd,aAAa,GACb,MAAM,CAAC;AAEX;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,IAAI,CAAC,EAAE,YAAY,CAAC;IAC7B,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;CAC9B;AAED;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CACtC,MAAM,CAAC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,CACnC,MAAM,CAAC,MAAM,EAAE,YAAY,GAAG,cAAc,CAAC,CAS9C,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,WAAW,EAAE,SAAS,MAAM,EAkBxC,CAAC;AAMF,8EAA8E;AAC9E,wBAAgB,cAAc,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,OAAO,CAKjE;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAC;IAC/B,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,0EAA0E;IAC1E,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,wEAAwE;AACxE,wBAAgB,OAAO,CACrB,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,YAAY,GAAG,cAAc,CAAC,CAAC,EAC9D,SAAS,EAAE,OAAO,GACjB,WAAW,EAAE,CA2Bf;AAOD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,YAAY,CAC1B,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,GACxB,WAAW,CAAC,YAAY,GAAG,SAAS,CAAC,GAAG,SAAS,CAoBnD"}
|
|
@@ -142,6 +142,37 @@ export const HELPER_DISPLAY = Object.fromEntries(Object.entries(HELPERS).flatMap
|
|
|
142
142
|
{ media: display },
|
|
143
143
|
]),
|
|
144
144
|
]));
|
|
145
|
+
/**
|
|
146
|
+
* Bulma's rules that take an element out of the flow (`position: absolute`
|
|
147
|
+
* or `fixed`), at some viewport or all of them, by the same kind of selector
|
|
148
|
+
* as the display tables. A box out of the flow ends no line, so a run beside
|
|
149
|
+
* one is beside whatever is past it, whatever its display.
|
|
150
|
+
*/
|
|
151
|
+
export const OUT_OF_FLOW = [
|
|
152
|
+
'.dropdown-menu',
|
|
153
|
+
'.file-input',
|
|
154
|
+
'.hero-video',
|
|
155
|
+
'.is-overlay',
|
|
156
|
+
'.is-position-absolute',
|
|
157
|
+
'.is-position-fixed',
|
|
158
|
+
'.is-sr-only',
|
|
159
|
+
'.modal',
|
|
160
|
+
'.modal-background',
|
|
161
|
+
'.modal-close',
|
|
162
|
+
'.navbar-dropdown',
|
|
163
|
+
'.navbar.is-fixed-bottom',
|
|
164
|
+
'.navbar.is-fixed-bottom-desktop',
|
|
165
|
+
'.navbar.is-fixed-bottom-touch',
|
|
166
|
+
'.navbar.is-fixed-top',
|
|
167
|
+
'.navbar.is-fixed-top-desktop',
|
|
168
|
+
'.navbar.is-fixed-top-touch',
|
|
169
|
+
];
|
|
170
|
+
const OUT_OF_FLOW_CLASSES = OUT_OF_FLOW.map(selector => [...selector.matchAll(/\.([\w-]+)/g)].map(match => match[1]));
|
|
171
|
+
/** Whether a Bulma rule takes an element out of the flow at some viewport. */
|
|
172
|
+
export function bulmaOutOfFlow(classes) {
|
|
173
|
+
const own = new Set(classes);
|
|
174
|
+
return OUT_OF_FLOW_CLASSES.some(needed => needed.every(token => own.has(token)));
|
|
175
|
+
}
|
|
145
176
|
/** A display table's selectors, read as the rules the lookup weighs. */
|
|
146
177
|
export function rulesOf(table, important) {
|
|
147
178
|
return Object.entries(table).flatMap(([selector, entry]) => {
|
|
@@ -192,7 +223,8 @@ const RULES = [
|
|
|
192
223
|
* `none` is no box at all (`.modal` until it is active), so a run beside one
|
|
193
224
|
* is beside whatever is past it. And these are displays alone: a box a rule
|
|
194
225
|
* also takes out of the flow (`.modal`'s `position: fixed`) still reads as
|
|
195
|
-
* its display here, though a run beside it is beside its neighbours
|
|
226
|
+
* its display here, though a run beside it is beside its neighbours, which
|
|
227
|
+
* is what `OUT_OF_FLOW` is for.
|
|
196
228
|
*/
|
|
197
229
|
export function bulmaDisplay(tag, classes) {
|
|
198
230
|
const own = new Set(classes);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rule ids for what the HTML input reports: the parts of a page a component
|
|
3
|
+
* can't carry, and what the converter couldn't write as it was.
|
|
4
|
+
*
|
|
5
|
+
* A page is the app's own text, as its class strings are, so an id carries
|
|
6
|
+
* only fixed names, never a URL, a title, a class of the app's or a line of
|
|
7
|
+
* its code: `kind:token`, the token from a closed vocabulary per kind (a tag
|
|
8
|
+
* the HTML spec names, an event attribute from `property-information`'s
|
|
9
|
+
* table, one of parse5's error codes, one of the names here). A token outside
|
|
10
|
+
* it is dropped and the id is the bare kind, as `ruleId` does, so a gap costs
|
|
11
|
+
* detail and never a telemetry event: the worker takes an id of up to 64
|
|
12
|
+
* characters, and an id that would be longer is the bare kind too.
|
|
13
|
+
*
|
|
14
|
+
* Apart from `rules.ts` because none of it is about a Bulma class: the
|
|
15
|
+
* planner's vocabulary is the class map's, and this one is the page's.
|
|
16
|
+
*/
|
|
17
|
+
/** The classes Bulma reads on `<html>` or `<body>` to pad for a navbar. */
|
|
18
|
+
export declare const NAVBAR_FIXED_CLASSES: readonly string[];
|
|
19
|
+
/** Bulma's classes that set a light or dark scheme on what they're on. */
|
|
20
|
+
export declare const THEME_CLASSES: readonly string[];
|
|
21
|
+
/** The patterns an inline script is checked for, each with its own recipe. */
|
|
22
|
+
export declare const SCRIPT_PATTERNS: readonly string[];
|
|
23
|
+
export declare const HTML_KINDS: ReadonlySet<string>;
|
|
24
|
+
/** Whether a token is one an id of this kind may carry. */
|
|
25
|
+
export declare function inHtmlVocabulary(kind: string, token: string): boolean;
|
|
26
|
+
export declare function htmlRuleId(kind: string, token?: string): string;
|
|
27
|
+
//# sourceMappingURL=html-rules.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"html-rules.d.ts","sourceRoot":"","sources":["../../../src/sources/bulma-classes/html-rules.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAKH,2EAA2E;AAC3E,eAAO,MAAM,oBAAoB,EAAE,SAAS,MAAM,EASjD,CAAC;AAEF,0EAA0E;AAC1E,eAAO,MAAM,aAAa,EAAE,SAAS,MAAM,EAAkC,CAAC;AAE9E,8EAA8E;AAC9E,eAAO,MAAM,eAAe,EAAE,SAAS,MAAM,EAO5C,CAAC;AAqCF,eAAO,MAAM,UAAU,EAAE,WAAW,CAAC,MAAM,CAAoC,CAAC;AAKhF,2DAA2D;AAC3D,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAErE;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAO/D"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rule ids for what the HTML input reports: the parts of a page a component
|
|
3
|
+
* can't carry, and what the converter couldn't write as it was.
|
|
4
|
+
*
|
|
5
|
+
* A page is the app's own text, as its class strings are, so an id carries
|
|
6
|
+
* only fixed names, never a URL, a title, a class of the app's or a line of
|
|
7
|
+
* its code: `kind:token`, the token from a closed vocabulary per kind (a tag
|
|
8
|
+
* the HTML spec names, an event attribute from `property-information`'s
|
|
9
|
+
* table, one of parse5's error codes, one of the names here). A token outside
|
|
10
|
+
* it is dropped and the id is the bare kind, as `ruleId` does, so a gap costs
|
|
11
|
+
* detail and never a telemetry event: the worker takes an id of up to 64
|
|
12
|
+
* characters, and an id that would be longer is the bare kind too.
|
|
13
|
+
*
|
|
14
|
+
* Apart from `rules.ts` because none of it is about a Bulma class: the
|
|
15
|
+
* planner's vocabulary is the class map's, and this one is the page's.
|
|
16
|
+
*/
|
|
17
|
+
import { ErrorCodes } from 'parse5';
|
|
18
|
+
import { html } from 'property-information';
|
|
19
|
+
/** The classes Bulma reads on `<html>` or `<body>` to pad for a navbar. */
|
|
20
|
+
export const NAVBAR_FIXED_CLASSES = [
|
|
21
|
+
'has-navbar-fixed-top',
|
|
22
|
+
'has-navbar-fixed-top-desktop',
|
|
23
|
+
'has-navbar-fixed-top-touch',
|
|
24
|
+
'has-navbar-fixed-bottom',
|
|
25
|
+
'has-navbar-fixed-bottom-desktop',
|
|
26
|
+
'has-navbar-fixed-bottom-touch',
|
|
27
|
+
'has-spaced-navbar-fixed-top',
|
|
28
|
+
'has-spaced-navbar-fixed-bottom',
|
|
29
|
+
];
|
|
30
|
+
/** Bulma's classes that set a light or dark scheme on what they're on. */
|
|
31
|
+
export const THEME_CLASSES = ['theme-dark', 'theme-light'];
|
|
32
|
+
/** The patterns an inline script is checked for, each with its own recipe. */
|
|
33
|
+
export const SCRIPT_PATTERNS = [
|
|
34
|
+
'burger',
|
|
35
|
+
'carousel',
|
|
36
|
+
'dismiss',
|
|
37
|
+
'json-ld',
|
|
38
|
+
'modal',
|
|
39
|
+
'theme',
|
|
40
|
+
];
|
|
41
|
+
/** Every HTML event-handler attribute, as written (`onclick`). */
|
|
42
|
+
const EVENT_ATTRIBUTES = Object.values(html.property)
|
|
43
|
+
.map(info => info.attribute)
|
|
44
|
+
.filter(attribute => /^on[a-z]+$/.test(attribute));
|
|
45
|
+
const VOCABULARY = {
|
|
46
|
+
'html-head': new Set(['title', 'meta', 'link', 'style', 'base']),
|
|
47
|
+
// Reported at the kind level until the asset vocabulary lands.
|
|
48
|
+
'html-asset': new Set(),
|
|
49
|
+
'html-script': new Set(SCRIPT_PATTERNS),
|
|
50
|
+
'html-document': new Set([
|
|
51
|
+
...NAVBAR_FIXED_CLASSES,
|
|
52
|
+
...THEME_CLASSES,
|
|
53
|
+
'class',
|
|
54
|
+
'data-theme',
|
|
55
|
+
'dir',
|
|
56
|
+
'id',
|
|
57
|
+
'lang',
|
|
58
|
+
'style',
|
|
59
|
+
]),
|
|
60
|
+
'html-event': new Set(EVENT_ATTRIBUTES),
|
|
61
|
+
'html-element': new Set([
|
|
62
|
+
'conditional-comment',
|
|
63
|
+
'custom',
|
|
64
|
+
'name',
|
|
65
|
+
'obsolete',
|
|
66
|
+
'template',
|
|
67
|
+
'unknown',
|
|
68
|
+
]),
|
|
69
|
+
'html-url': new Set(['javascript', 'missing', 'relative']),
|
|
70
|
+
'html-attr': new Set(['important', 'name', 'style', 'unknown']),
|
|
71
|
+
'html-parse': new Set(Object.values(ErrorCodes)),
|
|
72
|
+
'html-file': new Set(['exists', 'not-included', 'template-syntax']),
|
|
73
|
+
};
|
|
74
|
+
export const HTML_KINDS = new Set(Object.keys(VOCABULARY));
|
|
75
|
+
/** The longest rule id the telemetry worker takes. */
|
|
76
|
+
const MAX_RULE_LENGTH = 64;
|
|
77
|
+
/** Whether a token is one an id of this kind may carry. */
|
|
78
|
+
export function inHtmlVocabulary(kind, token) {
|
|
79
|
+
return VOCABULARY[kind]?.has(token) ?? false;
|
|
80
|
+
}
|
|
81
|
+
export function htmlRuleId(kind, token) {
|
|
82
|
+
if (!HTML_KINDS.has(kind)) {
|
|
83
|
+
throw new Error(`not an HTML rule kind: ${kind}`);
|
|
84
|
+
}
|
|
85
|
+
if (token === undefined || !inHtmlVocabulary(kind, token))
|
|
86
|
+
return kind;
|
|
87
|
+
const id = `${kind}:${token}`;
|
|
88
|
+
return id.length <= MAX_RULE_LENGTH ? id : kind;
|
|
89
|
+
}
|