bestax-migrate 2.32.0 → 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/_shared/html/parse.d.ts +10 -0
- package/dist/sources/_shared/html/parse.d.ts.map +1 -1
- package/dist/sources/_shared/html/parse.js +13 -1
- 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 +8 -1
- package/dist/sources/bulma-classes/html-assets.d.ts.map +1 -1
- package/dist/sources/bulma-classes/html-assets.js +35 -8
- package/dist/sources/bulma-classes/html-extensions.d.ts +69 -0
- package/dist/sources/bulma-classes/html-extensions.d.ts.map +1 -0
- package/dist/sources/bulma-classes/html-extensions.js +146 -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 +6 -0
- 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 +143 -33
- 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
|
@@ -30,7 +30,20 @@ const FONT_AWESOME_MAJOR = [
|
|
|
30
30
|
];
|
|
31
31
|
const FONT_AWESOME_KIT = /(?:^|\/\/)kit\.fontawesome\.com\//i;
|
|
32
32
|
/** A package whose name starts `bulma-`, as a path segment or a file. */
|
|
33
|
-
const EXTENSION = /(?:^|[/\\])((?:@creativebulma\/)?bulma-[a-z\d]+(?:-[a-z\d]+)*)(?=@|[/\\]|(?:\.min)?\.(?:css|js)$)/
|
|
33
|
+
const EXTENSION = /(?:^|[/\\])((?:@creativebulma\/)?bulma-[a-z\d]+(?:-[a-z\d]+)*)(?=@|[/\\]|(?:\.min)?\.(?:css|js)$)/gi;
|
|
34
|
+
/**
|
|
35
|
+
* The extension a URL's path loads: the first package it names, but for a
|
|
36
|
+
* file of one extension inside the bulma-extensions bundle's package
|
|
37
|
+
* (`bulma-extensions@6.2.7/bulma-carousel/dist/…`), which is that one's own
|
|
38
|
+
* file, not the bundle's combined stylesheet or script.
|
|
39
|
+
*/
|
|
40
|
+
function extensionOf(urlPath) {
|
|
41
|
+
const [first, ...rest] = [...urlPath.matchAll(EXTENSION)].map(match => match[1]);
|
|
42
|
+
if (first === undefined || extensionPackage(first) !== 'bulma-extensions') {
|
|
43
|
+
return first;
|
|
44
|
+
}
|
|
45
|
+
return (rest.find(name => extensionPackage(name) !== 'bulma-extensions') ?? first);
|
|
46
|
+
}
|
|
34
47
|
/** jQuery itself, not a plugin: `jquery-3.7.1.min.js`, `jquery@3`. */
|
|
35
48
|
const JQUERY = /(?:^|[/\\])jquery(?:-\d+(?:\.\d+)*)?(?:\.slim)?(?:\.min)?\.js$|(?:^|\/)jquery@[\d.]+$/i;
|
|
36
49
|
/** Hosts that serve a web font's stylesheet. */
|
|
@@ -61,7 +74,7 @@ export function classifyAsset(url, loads) {
|
|
|
61
74
|
kit: FONT_AWESOME_KIT.test(url.trim()),
|
|
62
75
|
};
|
|
63
76
|
}
|
|
64
|
-
const extension =
|
|
77
|
+
const extension = extensionOf(urlPath);
|
|
65
78
|
if (extension)
|
|
66
79
|
return { kind: 'bulma-extension', name: extension };
|
|
67
80
|
if (loads === 'script') {
|
|
@@ -151,6 +164,8 @@ export function bulmaBuildMessage(build, quoted) {
|
|
|
151
164
|
}
|
|
152
165
|
// ---- Font Awesome ------------------------------------------------------------
|
|
153
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";
|
|
154
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`;
|
|
155
170
|
export function fontAwesomeMessage(asset, quoted) {
|
|
156
171
|
const { major, kit } = asset;
|
|
@@ -158,14 +173,14 @@ export function fontAwesomeMessage(asset, quoted) {
|
|
|
158
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}`;
|
|
159
174
|
}
|
|
160
175
|
if (major === null) {
|
|
161
|
-
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}`;
|
|
162
177
|
}
|
|
163
178
|
const loads = `the page loads Font Awesome ${major} from \`${quoted}\``;
|
|
164
179
|
if (major <= 4) {
|
|
165
|
-
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`;
|
|
166
181
|
}
|
|
167
182
|
if (major === 5) {
|
|
168
|
-
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\``;
|
|
169
184
|
}
|
|
170
185
|
if (major <= 7) {
|
|
171
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}`;
|
|
@@ -194,9 +209,18 @@ export const EXTENSION_COMPONENTS = {
|
|
|
194
209
|
'bulma-toast': '`Toast` (`toast.show()` from code, with a `ToastContainer` rendered once)',
|
|
195
210
|
'bulma-tooltip': '`Tooltip`',
|
|
196
211
|
};
|
|
197
|
-
|
|
212
|
+
/** An extension's package without its scope, in lower case (`bulma-tooltip`). */
|
|
213
|
+
export function extensionPackage(name) {
|
|
214
|
+
return name.replace(/^@[^/]+\//, '').toLowerCase();
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* What a page's link to an extension leaves to do. `covered`: the page has
|
|
218
|
+
* images with bulma-carousel's `is-covered`, which its stylesheet crops only
|
|
219
|
+
* inside its own slides, so keeping the extension doesn't keep them cropped.
|
|
220
|
+
*/
|
|
221
|
+
export function extensionMessage(name, quoted, loads, css, covered = false) {
|
|
198
222
|
const from = `from ${quoted.map(url => `\`${url}\``).join(' and ')}`;
|
|
199
|
-
const bare = name
|
|
223
|
+
const bare = extensionPackage(name);
|
|
200
224
|
if (bare === 'bulma-social') {
|
|
201
225
|
return `the page loads bulma-social, a Bulma extension for brand-colored buttons, ${from}, and bestax has no component for it: keep loading it once for the app (\`bulma-social\` from npm, imported from its entry, or the \`<link>\` in its index.html), since its classes (\`is-twitter\`, \`is-github\` and the rest) style Bulma's \`.button\`, which bestax's \`Button\` renders, so they go on \`Button\` through \`className\``;
|
|
202
226
|
}
|
|
@@ -205,7 +229,10 @@ export function extensionMessage(name, quoted, loads, css) {
|
|
|
205
229
|
}
|
|
206
230
|
const component = EXTENSION_COMPONENTS[bare];
|
|
207
231
|
if (component) {
|
|
208
|
-
|
|
232
|
+
const crops = covered && bare === 'bulma-carousel'
|
|
233
|
+
? "; the page's `is-covered` images are cropped by its stylesheet only inside its own slides, which `Carousel` doesn't render, so keeping it doesn't keep them cropped: give them the rule the `html-extension:is-covered` TODO has"
|
|
234
|
+
: '';
|
|
235
|
+
return `the page loads ${name}, a Bulma extension, ${from}, and bestax has a component for what it does: ${component}, whose styles ship in bestax's \`extras.css\` and \`bestax.css\`; render that in place of the extension's markup${loads.has('script') ? ' and script' : ''}, and stop loading the extension once nothing the app keeps uses its classes${crops}`;
|
|
209
236
|
}
|
|
210
237
|
return `the page loads ${name}, a Bulma extension, ${from}, and a component doesn't: keep loading it once for the app (from npm, imported from its entry, or a \`<link>\` in its index.html) while the page's markup uses its classes, which go on bestax's components through \`className\`${css === 'keep' ? '' : ', and check it works with Bulma 1, which an extension can predate'}`;
|
|
211
238
|
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A Bulma extension's own markup on a page, which no component converts:
|
|
3
|
+
* the elements bulma-carousel's script makes carousels of, and its
|
|
4
|
+
* `is-covered` class. `html.ts` notes each under `html-extension:<name>`
|
|
5
|
+
* (`EXTENSION_MARKUP` in `html-rules.ts`), beside the `html-asset` note for
|
|
6
|
+
* the extension and the `html-script:carousel` note for its script.
|
|
7
|
+
*
|
|
8
|
+
* Pure. A script is read, never run, so an element is found only through a
|
|
9
|
+
* selector the script writes out as a string, and only in the forms a page
|
|
10
|
+
* names its carousel by: a tag, ids and classes, and a list of those. The
|
|
11
|
+
* page's DOM is searched the way `querySelectorAll` does it, which is what
|
|
12
|
+
* `bulmaCarousel.attach` calls: every element a selector matches becomes a
|
|
13
|
+
* carousel, an id the page repeats included.
|
|
14
|
+
*/
|
|
15
|
+
import { type Element, type ParentNode } from '../_shared/html/parse.js';
|
|
16
|
+
/** The selectors a script attaches bulma-carousel to, once each, in order. */
|
|
17
|
+
export declare function carouselSelectors(code: string): string[];
|
|
18
|
+
interface Compound {
|
|
19
|
+
/** Null for any tag. */
|
|
20
|
+
tag: string | null;
|
|
21
|
+
ids: string[];
|
|
22
|
+
classes: string[];
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* A selector list the codemod can match, or null for any other selector
|
|
26
|
+
* (a combinator, an attribute, a pseudo-class), whose matches it can't know.
|
|
27
|
+
*/
|
|
28
|
+
export declare function readSelector(selector: string): Compound[] | null;
|
|
29
|
+
/**
|
|
30
|
+
* Every element in the content a selector matches, in the page's order, as
|
|
31
|
+
* `querySelectorAll` finds them once the page's scripts run, or null for a
|
|
32
|
+
* selector `readSelector` can't read. A `<template>`'s content isn't in the
|
|
33
|
+
* document (parse5 keeps it apart from its children), and with scripts on a
|
|
34
|
+
* `<noscript>` holds text, so neither is searched.
|
|
35
|
+
*/
|
|
36
|
+
export declare function selectAll(root: ParentNode, selector: string, quirks: boolean): Element[] | null;
|
|
37
|
+
/** The class bulma-carousel's markup gives a carousel, and bestax `Carousel`'s. */
|
|
38
|
+
export declare const CAROUSEL_CLASS = "carousel";
|
|
39
|
+
/** bulma-carousel's class for an image cropped to its frame. */
|
|
40
|
+
export declare const COVERED_CLASS = "is-covered";
|
|
41
|
+
/** What bulma-carousel's stylesheet styles `is-covered` on: an `.image`. */
|
|
42
|
+
export declare const COVERED_SELECTOR = ".image.is-covered";
|
|
43
|
+
export interface DrivenFacts {
|
|
44
|
+
/** The selector, as the script writes it. */
|
|
45
|
+
selector: string;
|
|
46
|
+
/** The script, as the TODO names it (`the page's script \`js/app.js\``). */
|
|
47
|
+
script: string;
|
|
48
|
+
/** How many elements the selector matches. */
|
|
49
|
+
count: number;
|
|
50
|
+
/** The id they all have, when several do. */
|
|
51
|
+
sharedId?: string;
|
|
52
|
+
/** Whether one of them has the `carousel` class. */
|
|
53
|
+
carouselClass: boolean;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* The elements a page's script attaches bulma-carousel to: each one a
|
|
57
|
+
* carousel, whose children become its slides, and none of it run by the
|
|
58
|
+
* module.
|
|
59
|
+
*/
|
|
60
|
+
export declare function drivenMessage(facts: DrivenFacts): string;
|
|
61
|
+
/**
|
|
62
|
+
* An element with the `carousel` class on a page that uses bulma-carousel,
|
|
63
|
+
* where no selector the codemod read reaches it.
|
|
64
|
+
*/
|
|
65
|
+
export declare function carouselClassMessage(): string;
|
|
66
|
+
/** An `.image` with bulma-carousel's `is-covered`. */
|
|
67
|
+
export declare function coveredMessage(): string;
|
|
68
|
+
export {};
|
|
69
|
+
//# sourceMappingURL=html-extensions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"html-extensions.d.ts","sourceRoot":"","sources":["../../../src/sources/bulma-classes/html-extensions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAIL,KAAK,OAAO,EACZ,KAAK,UAAU,EAChB,MAAM,0BAA0B,CAAC;AAclC,8EAA8E;AAC9E,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAKxD;AAUD,UAAU,QAAQ;IAChB,wBAAwB;IACxB,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,GAAG,EAAE,MAAM,EAAE,CAAC;IACd,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,QAAQ,EAAE,GAAG,IAAI,CAehE;AA4BD;;;;;;GAMG;AACH,wBAAgB,SAAS,CACvB,IAAI,EAAE,UAAU,EAChB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,OAAO,GACd,OAAO,EAAE,GAAG,IAAI,CAelB;AAID,mFAAmF;AACnF,eAAO,MAAM,cAAc,aAAa,CAAC;AAEzC,gEAAgE;AAChE,eAAO,MAAM,aAAa,eAAe,CAAC;AAE1C,4EAA4E;AAC5E,eAAO,MAAM,gBAAgB,sBAA4B,CAAC;AAW1D,MAAM,WAAW,WAAW;IAC1B,6CAA6C;IAC7C,QAAQ,EAAE,MAAM,CAAC;IACjB,4EAA4E;IAC5E,MAAM,EAAE,MAAM,CAAC;IACf,8CAA8C;IAC9C,KAAK,EAAE,MAAM,CAAC;IACd,6CAA6C;IAC7C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,oDAAoD;IACpD,aAAa,EAAE,OAAO,CAAC;CACxB;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,CAkBxD;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,CAE7C;AAED,sDAAsD;AACtD,wBAAgB,cAAc,IAAI,MAAM,CAEvC"}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A Bulma extension's own markup on a page, which no component converts:
|
|
3
|
+
* the elements bulma-carousel's script makes carousels of, and its
|
|
4
|
+
* `is-covered` class. `html.ts` notes each under `html-extension:<name>`
|
|
5
|
+
* (`EXTENSION_MARKUP` in `html-rules.ts`), beside the `html-asset` note for
|
|
6
|
+
* the extension and the `html-script:carousel` note for its script.
|
|
7
|
+
*
|
|
8
|
+
* Pure. A script is read, never run, so an element is found only through a
|
|
9
|
+
* selector the script writes out as a string, and only in the forms a page
|
|
10
|
+
* names its carousel by: a tag, ids and classes, and a list of those. The
|
|
11
|
+
* page's DOM is searched the way `querySelectorAll` does it, which is what
|
|
12
|
+
* `bulmaCarousel.attach` calls: every element a selector matches becomes a
|
|
13
|
+
* carousel, an id the page repeats included.
|
|
14
|
+
*/
|
|
15
|
+
import { attributeOf, classesOf, isElement, } from '../_shared/html/parse.js';
|
|
16
|
+
const HTML_NS = 'http://www.w3.org/1999/xhtml';
|
|
17
|
+
// ---- What the page's scripts attach bulma-carousel to ------------------------
|
|
18
|
+
/**
|
|
19
|
+
* `bulmaCarousel.attach(` with its selector written as a string, the whole
|
|
20
|
+
* argument, without an escape or a substitution, which would make it
|
|
21
|
+
* something else to read.
|
|
22
|
+
*/
|
|
23
|
+
const ATTACH = /\bbulmaCarousel\s*\.\s*attach\s*\(\s*(?:'([^'\\\n]*)'|"([^"\\\n]*)"|`([^`\\$]*)`)\s*[,)]/g;
|
|
24
|
+
/** The selectors a script attaches bulma-carousel to, once each, in order. */
|
|
25
|
+
export function carouselSelectors(code) {
|
|
26
|
+
const selectors = [...code.matchAll(ATTACH)].map(match => (match[1] ?? match[2] ?? match[3]).trim());
|
|
27
|
+
return [...new Set(selectors.filter(Boolean))];
|
|
28
|
+
}
|
|
29
|
+
// ---- Matching a selector -----------------------------------------------------
|
|
30
|
+
/** A CSS identifier, as a tag, an id or a class writes it. */
|
|
31
|
+
const IDENT = String.raw `(?:--|-?[_a-zA-Z\u0080-\uffff])[-\w\u0080-\uffff]*`;
|
|
32
|
+
/** A tag (or `*`), then ids and classes, with nothing between them. */
|
|
33
|
+
const COMPOUND = new RegExp(String.raw `^(\*|${IDENT})?((?:[#.]${IDENT})*)$`);
|
|
34
|
+
/**
|
|
35
|
+
* A selector list the codemod can match, or null for any other selector
|
|
36
|
+
* (a combinator, an attribute, a pseudo-class), whose matches it can't know.
|
|
37
|
+
*/
|
|
38
|
+
export function readSelector(selector) {
|
|
39
|
+
const compounds = [];
|
|
40
|
+
for (const part of selector.split(',').map(each => each.trim())) {
|
|
41
|
+
const match = part === '' ? null : COMPOUND.exec(part);
|
|
42
|
+
if (!match)
|
|
43
|
+
return null;
|
|
44
|
+
const simple = match[2].match(/[#.][^#.]+/g) ?? [];
|
|
45
|
+
compounds.push({
|
|
46
|
+
tag: match[1] === undefined || match[1] === '*' ? null : match[1],
|
|
47
|
+
ids: simple.filter(each => each[0] === '#').map(each => each.slice(1)),
|
|
48
|
+
classes: simple
|
|
49
|
+
.filter(each => each[0] === '.')
|
|
50
|
+
.map(each => each.slice(1)),
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
return compounds;
|
|
54
|
+
}
|
|
55
|
+
/** ASCII letters in lower case, and nothing else changed. */
|
|
56
|
+
function asciiLower(text) {
|
|
57
|
+
return text.replace(/[A-Z]/g, letter => letter.toLowerCase());
|
|
58
|
+
}
|
|
59
|
+
function matches(element, compound, quirks) {
|
|
60
|
+
if (compound.tag !== null) {
|
|
61
|
+
// An HTML element's tag matches in any case; a foreign one's as written.
|
|
62
|
+
const html = element.namespaceURI === HTML_NS;
|
|
63
|
+
const tag = html ? asciiLower(compound.tag) : compound.tag;
|
|
64
|
+
if (element.tagName !== tag)
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
// Quirks mode matches ids and classes in any ASCII case.
|
|
68
|
+
const fold = quirks ? asciiLower : (text) => text;
|
|
69
|
+
const id = attributeOf(element, 'id');
|
|
70
|
+
if (compound.ids.some(each => id === undefined || fold(id) !== fold(each))) {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
const classes = classesOf(element).map(fold);
|
|
74
|
+
return compound.classes.every(each => classes.includes(fold(each)));
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Every element in the content a selector matches, in the page's order, as
|
|
78
|
+
* `querySelectorAll` finds them once the page's scripts run, or null for a
|
|
79
|
+
* selector `readSelector` can't read. A `<template>`'s content isn't in the
|
|
80
|
+
* document (parse5 keeps it apart from its children), and with scripts on a
|
|
81
|
+
* `<noscript>` holds text, so neither is searched.
|
|
82
|
+
*/
|
|
83
|
+
export function selectAll(root, selector, quirks) {
|
|
84
|
+
const compounds = readSelector(selector);
|
|
85
|
+
if (!compounds)
|
|
86
|
+
return null;
|
|
87
|
+
const found = [];
|
|
88
|
+
const visit = (parent) => {
|
|
89
|
+
for (const child of parent.childNodes) {
|
|
90
|
+
if (!isElement(child))
|
|
91
|
+
continue;
|
|
92
|
+
if (compounds.some(compound => matches(child, compound, quirks))) {
|
|
93
|
+
found.push(child);
|
|
94
|
+
}
|
|
95
|
+
if (child.tagName !== 'noscript')
|
|
96
|
+
visit(child);
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
visit(root);
|
|
100
|
+
return found;
|
|
101
|
+
}
|
|
102
|
+
// ---- What the notes say ------------------------------------------------------
|
|
103
|
+
/** The class bulma-carousel's markup gives a carousel, and bestax `Carousel`'s. */
|
|
104
|
+
export const CAROUSEL_CLASS = 'carousel';
|
|
105
|
+
/** bulma-carousel's class for an image cropped to its frame. */
|
|
106
|
+
export const COVERED_CLASS = 'is-covered';
|
|
107
|
+
/** What bulma-carousel's stylesheet styles `is-covered` on: an `.image`. */
|
|
108
|
+
export const COVERED_SELECTOR = `.image.${COVERED_CLASS}`;
|
|
109
|
+
/** What bestax's stylesheet does with the `carousel` class on markup. */
|
|
110
|
+
const CAROUSEL_STYLED = "which `bestax.css` and `extras.css` style as its root (`position: relative`, `overflow: hidden`, `width: 100%`) until a `Carousel` takes the element's place";
|
|
111
|
+
/** What replaces a carousel, in the place of `where`. */
|
|
112
|
+
function renderCarousel(where) {
|
|
113
|
+
return `render bestax's \`Carousel\` in ${where}, with a \`CarouselItem\` for each slide, and carry the script's options over as the \`html-script:carousel\` recipe says`;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* The elements a page's script attaches bulma-carousel to: each one a
|
|
117
|
+
* carousel, whose children become its slides, and none of it run by the
|
|
118
|
+
* module.
|
|
119
|
+
*/
|
|
120
|
+
export function drivenMessage(facts) {
|
|
121
|
+
const { selector, script, count, sharedId, carouselClass } = facts;
|
|
122
|
+
const which = count === 1
|
|
123
|
+
? `${script} attaches bulma-carousel to this element (\`${selector}\`)`
|
|
124
|
+
: `${script} attaches bulma-carousel to \`${selector}\`, which selects these ${count} elements${sharedId === undefined
|
|
125
|
+
? ''
|
|
126
|
+
: `, since the page gives each one \`id="${sharedId}"\``}, so each is a carousel`;
|
|
127
|
+
return [
|
|
128
|
+
`${which}: the script makes a slide of each of its children and builds the carousel around them, which the module doesn't do, so ${renderCarousel(count === 1 ? 'its place' : 'the place of each')}`,
|
|
129
|
+
...(carouselClass
|
|
130
|
+
? [
|
|
131
|
+
`\`${CAROUSEL_CLASS}\` is bestax \`Carousel\`'s own class, ${CAROUSEL_STYLED}`,
|
|
132
|
+
]
|
|
133
|
+
: []),
|
|
134
|
+
].join('; ');
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* An element with the `carousel` class on a page that uses bulma-carousel,
|
|
138
|
+
* where no selector the codemod read reaches it.
|
|
139
|
+
*/
|
|
140
|
+
export function carouselClassMessage() {
|
|
141
|
+
return `\`${CAROUSEL_CLASS}\` is the class bulma-carousel's markup gives a carousel, and bestax \`Carousel\`'s own, ${CAROUSEL_STYLED}: if the page's carousel script drives this element, ${renderCarousel('its place')}, and otherwise drop the class or rename it`;
|
|
142
|
+
}
|
|
143
|
+
/** An `.image` with bulma-carousel's `is-covered`. */
|
|
144
|
+
export function coveredMessage() {
|
|
145
|
+
return `\`${COVERED_CLASS}\` is bulma-carousel's class: inside one of the slides its script builds, its stylesheet makes the \`<img>\` in an \`.image\` fill the frame and crops the photo to fit (\`object-fit: cover\`); nothing in bestax reads the class (\`Image\` has no prop for it, and \`Carousel\`'s slides aren't bulma-carousel's), so in the app a ratio image stretches its photo instead: keep the class and give it the rule in the app's stylesheet (\`.image.is-covered img { width: 100%; height: 100%; object-fit: cover; }\`)`;
|
|
146
|
+
}
|
|
@@ -25,6 +25,11 @@ export declare const SCRIPT_PATTERNS: readonly string[];
|
|
|
25
25
|
* Font Awesome, a Bulma extension, jQuery, a web font, or any other.
|
|
26
26
|
*/
|
|
27
27
|
export declare const ASSET_KINDS: readonly string[];
|
|
28
|
+
/**
|
|
29
|
+
* A Bulma extension's own markup on the page (`html-extensions.ts`): an
|
|
30
|
+
* element bulma-carousel's script makes a carousel of, and its `is-covered`.
|
|
31
|
+
*/
|
|
32
|
+
export declare const EXTENSION_MARKUP: readonly string[];
|
|
28
33
|
export declare const HTML_KINDS: ReadonlySet<string>;
|
|
29
34
|
/** Whether a token is one an id of this kind may carry. */
|
|
30
35
|
export declare function inHtmlVocabulary(kind: string, token: string): boolean;
|
|
@@ -1 +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;AAEF;;;GAGG;AACH,eAAO,MAAM,WAAW,EAAE,SAAS,MAAM,EAQxC,CAAC;
|
|
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;AAEF;;;GAGG;AACH,eAAO,MAAM,WAAW,EAAE,SAAS,MAAM,EAQxC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,gBAAgB,EAAE,SAAS,MAAM,EAA+B,CAAC;AA4C9E,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"}
|
|
@@ -51,6 +51,11 @@ export const ASSET_KINDS = [
|
|
|
51
51
|
'stylesheet',
|
|
52
52
|
'webfont',
|
|
53
53
|
];
|
|
54
|
+
/**
|
|
55
|
+
* A Bulma extension's own markup on the page (`html-extensions.ts`): an
|
|
56
|
+
* element bulma-carousel's script makes a carousel of, and its `is-covered`.
|
|
57
|
+
*/
|
|
58
|
+
export const EXTENSION_MARKUP = ['carousel', 'is-covered'];
|
|
54
59
|
/** Every HTML event-handler attribute, as written (`onclick`). */
|
|
55
60
|
const EVENT_ATTRIBUTES = Object.values(html.property)
|
|
56
61
|
.map(info => info.attribute)
|
|
@@ -59,6 +64,7 @@ const VOCABULARY = {
|
|
|
59
64
|
'html-head': new Set(['title', 'meta', 'csp', 'link', 'style', 'base']),
|
|
60
65
|
'html-asset': new Set(ASSET_KINDS),
|
|
61
66
|
'html-script': new Set(SCRIPT_PATTERNS),
|
|
67
|
+
'html-extension': new Set(EXTENSION_MARKUP),
|
|
62
68
|
'html-document': new Set([
|
|
63
69
|
...NAVBAR_FIXED_CLASSES,
|
|
64
70
|
...THEME_CLASSES,
|
|
@@ -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"}
|