bestax-migrate 2.25.5 → 2.25.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/dist/sources/_shared/html/attributes.d.ts +96 -0
  2. package/dist/sources/_shared/html/attributes.d.ts.map +1 -0
  3. package/dist/sources/_shared/html/attributes.js +313 -0
  4. package/dist/sources/_shared/html/emit.d.ts +49 -0
  5. package/dist/sources/_shared/html/emit.d.ts.map +1 -0
  6. package/dist/sources/_shared/html/emit.js +355 -0
  7. package/dist/sources/_shared/html/parse.d.ts +54 -0
  8. package/dist/sources/_shared/html/parse.d.ts.map +1 -0
  9. package/dist/sources/_shared/html/parse.js +85 -0
  10. package/dist/sources/_shared/html/style.d.ts +61 -0
  11. package/dist/sources/_shared/html/style.d.ts.map +1 -0
  12. package/dist/sources/_shared/html/style.js +185 -0
  13. package/dist/sources/_shared/html/text.d.ts +43 -0
  14. package/dist/sources/_shared/html/text.d.ts.map +1 -0
  15. package/dist/sources/_shared/html/text.js +120 -0
  16. package/dist/sources/_shared/html/whitespace.d.ts +80 -0
  17. package/dist/sources/_shared/html/whitespace.d.ts.map +1 -0
  18. package/dist/sources/_shared/html/whitespace.js +409 -0
  19. package/dist/sources/bulma-classes/class-map.d.ts +6 -0
  20. package/dist/sources/bulma-classes/class-map.d.ts.map +1 -1
  21. package/dist/sources/bulma-classes/class-map.js +6 -0
  22. package/dist/sources/bulma-classes/display.d.ts +74 -0
  23. package/dist/sources/bulma-classes/display.d.ts.map +1 -0
  24. package/dist/sources/bulma-classes/display.js +215 -0
  25. package/dist/sources/bulma-classes/plan.d.ts.map +1 -1
  26. package/dist/sources/bulma-classes/plan.js +4 -3
  27. package/dist/sources/rbx/mapping.js +1 -1
  28. package/dist/sources/react-bulma-components/mapping.js +1 -1
  29. package/package.json +4 -2
@@ -0,0 +1,185 @@
1
+ /**
2
+ * A `style="…"` attribute as the object literal React takes.
3
+ *
4
+ * The declarations are split by hand, since a style attribute is a flat list
5
+ * and the only syntax that matters is what can hide a `;` or a `:`: quoted
6
+ * strings, parentheses (`url(a;b)`), and comments. Property names are camel
7
+ * cased the way React hyphenates them back: `-ms-` becomes `ms`, any other
8
+ * vendor prefix a capital (`WebkitTransition`), and a custom property keeps
9
+ * its name, quoted. Which declaration of a property applies is CSS's choice:
10
+ * an `!important` one over the rest, else the last.
11
+ *
12
+ * As in CSS, a declaration that can't be read (an IE hack like `*zoom: 1`,
13
+ * an empty value, a string or parenthesis left open) is skipped and the rest
14
+ * apply; it is handed back for the caller to report. So is an `!important`
15
+ * one, which is written without its priority, since React sets every value
16
+ * without one.
17
+ */
18
+ import { jsString } from './text.js';
19
+ /** A property name CSS accepts: an identifier, or a custom property. */
20
+ const PROPERTY = /^(?:--[\w-]+|-?[a-z_][\w-]*)$/i;
21
+ /** Runs of whitespace as one space, except inside a quoted string. */
22
+ function collapse(value) {
23
+ let out = '';
24
+ let quote = null;
25
+ for (let i = 0; i < value.length; i++) {
26
+ const char = value[i];
27
+ if (quote) {
28
+ out += char;
29
+ if (char === '\\' && i + 1 < value.length)
30
+ out += value[++i];
31
+ else if (char === quote)
32
+ quote = null;
33
+ }
34
+ else if (/\s/.test(char)) {
35
+ if (!out.endsWith(' '))
36
+ out += ' ';
37
+ }
38
+ else {
39
+ if (char === '"' || char === "'")
40
+ quote = char;
41
+ out += char;
42
+ }
43
+ }
44
+ return out;
45
+ }
46
+ /**
47
+ * Split on `;` outside strings, parentheses and comments. A comment
48
+ * separates tokens and is otherwise nothing, so it becomes a space, and one
49
+ * left open runs to the end. A string or parenthesis left open does too,
50
+ * taking every later declaration into the one it is in, as it does in CSS.
51
+ */
52
+ function declarations(text) {
53
+ const out = [];
54
+ let current = '';
55
+ let balanced = true;
56
+ let quote = null;
57
+ let depth = 0;
58
+ const end = () => {
59
+ const trimmed = current.trim();
60
+ if (trimmed)
61
+ out.push({ text: trimmed, balanced });
62
+ current = '';
63
+ balanced = true;
64
+ };
65
+ for (let i = 0; i < text.length; i++) {
66
+ const char = text[i];
67
+ if (quote) {
68
+ current += char;
69
+ if (char === '\\' && i + 1 < text.length) {
70
+ current += text[++i];
71
+ }
72
+ else if (char === quote) {
73
+ quote = null;
74
+ }
75
+ continue;
76
+ }
77
+ if (char === '/' && text[i + 1] === '*') {
78
+ const close = text.indexOf('*/', i + 2);
79
+ if (close === -1)
80
+ break;
81
+ i = close + 1;
82
+ current += ' ';
83
+ continue;
84
+ }
85
+ if (char === '"' || char === "'") {
86
+ quote = char;
87
+ }
88
+ else if (char === '(') {
89
+ depth++;
90
+ }
91
+ else if (char === ')') {
92
+ if (depth === 0)
93
+ balanced = false;
94
+ else
95
+ depth--;
96
+ }
97
+ else if (char === ';' && depth === 0) {
98
+ end();
99
+ continue;
100
+ }
101
+ current += char;
102
+ }
103
+ if (quote || depth > 0)
104
+ balanced = false;
105
+ end();
106
+ return out;
107
+ }
108
+ /** The key React reads for a CSS property name. */
109
+ export function styleKey(property) {
110
+ if (property.startsWith('--'))
111
+ return property;
112
+ const name = property.toLowerCase();
113
+ const camel = (rest) => rest.replace(/-([a-z\d])/g, (_match, char) => char.toUpperCase());
114
+ if (name.startsWith('-ms-'))
115
+ return camel(`ms-${name.slice(4)}`);
116
+ if (name.startsWith('-')) {
117
+ const rest = camel(name.slice(1));
118
+ return rest.charAt(0).toUpperCase() + rest.slice(1);
119
+ }
120
+ return camel(name);
121
+ }
122
+ function keySource(key) {
123
+ return /^[A-Za-z_$][\w$]*$/.test(key) ? key : jsString(key);
124
+ }
125
+ /** A style attribute's declarations, read one at a time. */
126
+ export function readStyle(text) {
127
+ const style = { declarations: [], skipped: [] };
128
+ for (const part of declarations(text)) {
129
+ const colon = part.text.indexOf(':');
130
+ const written = colon === -1 ? '' : part.text.slice(0, colon).trim();
131
+ let value = collapse(part.text.slice(colon + 1).trim());
132
+ const important = /\s*!\s*important$/i.exec(value);
133
+ if (important)
134
+ value = value.slice(0, important.index);
135
+ if (!part.balanced || !PROPERTY.test(written) || value === '') {
136
+ style.skipped.push(part.text);
137
+ continue;
138
+ }
139
+ style.declarations.push({
140
+ property: written.startsWith('--') ? written : written.toLowerCase(),
141
+ value,
142
+ important: Boolean(important),
143
+ text: part.text,
144
+ });
145
+ }
146
+ return style;
147
+ }
148
+ /**
149
+ * The declaration that applies for each property, as the cascade picks it
150
+ * inside one attribute: an `!important` one over any other, else the last.
151
+ * In the order of the declarations that apply.
152
+ */
153
+ export function applied(declarations) {
154
+ const out = new Map();
155
+ for (const declaration of declarations) {
156
+ const before = out.get(declaration.property);
157
+ if (before?.important && !declaration.important)
158
+ continue;
159
+ out.delete(declaration.property);
160
+ out.set(declaration.property, declaration);
161
+ }
162
+ return out;
163
+ }
164
+ /** A style attribute's text as a React style object. */
165
+ export function styleObject(text) {
166
+ const { declarations: read, skipped } = readStyle(text);
167
+ const issues = skipped.map(detail => ({
168
+ kind: 'style',
169
+ detail,
170
+ }));
171
+ for (const { property, important, text: written } of read) {
172
+ if (important) {
173
+ issues.push({
174
+ kind: 'style-important',
175
+ token: property,
176
+ detail: written,
177
+ });
178
+ }
179
+ }
180
+ const entries = [...applied(read).values()].map(({ property, value }) => `${keySource(styleKey(property))}: ${jsString(value)}`);
181
+ return {
182
+ code: entries.length === 0 ? null : `{ ${entries.join(', ')} }`,
183
+ issues,
184
+ };
185
+ }
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Text, strings and comments, written so JSX reads them back as the HTML had
3
+ * them.
4
+ *
5
+ * JSX text is not HTML text: `{` and `}` open and close an expression, `<`
6
+ * and `>` are tags (TypeScript and Babel both refuse a bare `>`), and an
7
+ * `&name;` is decoded as an entity. Everything else is literal. Whitespace is
8
+ * not handled here: `whitespace.ts` decides which of it renders, and the
9
+ * emitter writes what is left.
10
+ */
11
+ /**
12
+ * Text as a JSX child. The caller passes text with no whitespace at either
13
+ * edge that matters, since JSX trims whitespace next to a line break.
14
+ */
15
+ export declare function jsxText(text: string): string;
16
+ /** A double-quoted JavaScript string, with invisible characters escaped. */
17
+ export declare function jsString(value: string): string;
18
+ /**
19
+ * A template literal holding `value` exactly: what preformatted text with a
20
+ * line break in it is written as, so its lines stay lines.
21
+ */
22
+ export declare function templateLiteral(value: string): string;
23
+ /**
24
+ * A string attribute value: quoted as written when JSX reads it back the
25
+ * same way, and as an expression otherwise. A JSX attribute string has no
26
+ * escapes, so a `"` would end it, and it decodes entities, as text does.
27
+ * A backslash and a line break are literal there, but a reprint can change
28
+ * them, so they go in an expression too.
29
+ */
30
+ export declare function attributeValue(value: string): string;
31
+ /**
32
+ * An Internet Explorer conditional comment, either half of the revealed form
33
+ * (`<!--[if !IE]><!-->` … `<!--<![endif]-->`) included. No browser React
34
+ * supports reads them.
35
+ */
36
+ export declare function isConditionalComment(data: string): boolean;
37
+ /**
38
+ * An HTML comment as JSX comment lines, without indentation. One line stays
39
+ * one line; more are dedented and set between the comment's own delimiters.
40
+ * A `*\/` inside would end the comment, so it is escaped.
41
+ */
42
+ export declare function jsxComment(data: string): string[];
43
+ //# sourceMappingURL=text.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../../../src/sources/_shared/html/text.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AA2CH;;;GAGG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAO5C;AAED,4EAA4E;AAC5E,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE9C;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAQrD;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAMpD;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE1D;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAiBjD"}
@@ -0,0 +1,120 @@
1
+ /**
2
+ * Text, strings and comments, written so JSX reads them back as the HTML had
3
+ * them.
4
+ *
5
+ * JSX text is not HTML text: `{` and `}` open and close an expression, `<`
6
+ * and `>` are tags (TypeScript and Babel both refuse a bare `>`), and an
7
+ * `&name;` is decoded as an entity. Everything else is literal. Whitespace is
8
+ * not handled here: `whitespace.ts` decides which of it renders, and the
9
+ * emitter writes what is left.
10
+ */
11
+ /** An `&` that JSX would read as the start of an entity. */
12
+ const ENTITY_LIKE = /&(?=#\d+;|#x[\da-f]+;|[a-z][a-z\d]*;)/i;
13
+ /**
14
+ * Characters that render as nothing, or as a space a reader can't tell from
15
+ * an ordinary one: no-break and typographic spaces, joiners, direction
16
+ * marks, fillers, the soft hyphen and the byte-order mark. They are written
17
+ * as an entity or an escape, so the code shows them.
18
+ */
19
+ const INVISIBLE_RANGES = [
20
+ [0xa0, 0xa0],
21
+ [0xad, 0xad],
22
+ [0x34f, 0x34f],
23
+ [0x61c, 0x61c],
24
+ [0x115f, 0x1160],
25
+ [0x17b4, 0x17b5],
26
+ [0x180e, 0x180e],
27
+ [0x2000, 0x200f],
28
+ [0x2028, 0x202f],
29
+ [0x205f, 0x2064],
30
+ [0x2066, 0x206f],
31
+ [0x3000, 0x3000],
32
+ [0x3164, 0x3164],
33
+ [0xfeff, 0xfeff],
34
+ [0xffa0, 0xffa0],
35
+ ];
36
+ const INVISIBLE_CLASS = `[${INVISIBLE_RANGES.map(([from, to]) => `\\u{${from.toString(16)}}-\\u{${to.toString(16)}}`).join('')}]`;
37
+ const INVISIBLE = new RegExp(INVISIBLE_CLASS, 'gu');
38
+ /** The two of those with a name every reader knows. */
39
+ const NAMED = {
40
+ [String.fromCodePoint(0xa0)]: '&nbsp;',
41
+ [String.fromCodePoint(0xad)]: '&shy;',
42
+ };
43
+ function hex(char) {
44
+ return char.codePointAt(0).toString(16).toUpperCase().padStart(4, '0');
45
+ }
46
+ /**
47
+ * Text as a JSX child. The caller passes text with no whitespace at either
48
+ * edge that matters, since JSX trims whitespace next to a line break.
49
+ */
50
+ export function jsxText(text) {
51
+ return text
52
+ .replace(new RegExp(ENTITY_LIKE, 'gi'), '&amp;')
53
+ .replace(/</g, '&lt;')
54
+ .replace(/>/g, '&gt;')
55
+ .replace(INVISIBLE, char => NAMED[char] ?? `&#x${hex(char)};`)
56
+ .replace(/[{}]/g, brace => `{"${brace}"}`);
57
+ }
58
+ /** A double-quoted JavaScript string, with invisible characters escaped. */
59
+ export function jsString(value) {
60
+ return JSON.stringify(value).replace(INVISIBLE, char => `\\u${hex(char)}`);
61
+ }
62
+ /**
63
+ * A template literal holding `value` exactly: what preformatted text with a
64
+ * line break in it is written as, so its lines stay lines.
65
+ */
66
+ export function templateLiteral(value) {
67
+ const body = value
68
+ .replace(/\\/g, '\\\\')
69
+ .replace(/`/g, '\\`')
70
+ .replace(/\$\{/g, '\\${')
71
+ .replace(/\r/g, '\\r')
72
+ .replace(INVISIBLE, char => `\\u${hex(char)}`);
73
+ return `\`${body}\``;
74
+ }
75
+ /**
76
+ * A string attribute value: quoted as written when JSX reads it back the
77
+ * same way, and as an expression otherwise. A JSX attribute string has no
78
+ * escapes, so a `"` would end it, and it decodes entities, as text does.
79
+ * A backslash and a line break are literal there, but a reprint can change
80
+ * them, so they go in an expression too.
81
+ */
82
+ export function attributeValue(value) {
83
+ const plain = !/["\\\r\n]/.test(value) &&
84
+ !ENTITY_LIKE.test(value) &&
85
+ value.replace(INVISIBLE, '') === value;
86
+ return plain ? `"${value}"` : `{${jsString(value)}}`;
87
+ }
88
+ /**
89
+ * An Internet Explorer conditional comment, either half of the revealed form
90
+ * (`<!--[if !IE]><!-->` … `<!--<![endif]-->`) included. No browser React
91
+ * supports reads them.
92
+ */
93
+ export function isConditionalComment(data) {
94
+ return /^\s*\[if\s[^\]]*\]>/i.test(data) || /^\s*<!\[endif\]\s*$/i.test(data);
95
+ }
96
+ /**
97
+ * An HTML comment as JSX comment lines, without indentation. One line stays
98
+ * one line; more are dedented and set between the comment's own delimiters.
99
+ * A `*\/` inside would end the comment, so it is escaped.
100
+ */
101
+ export function jsxComment(data) {
102
+ const text = data.replace(/\*\//g, '*\\/');
103
+ const lines = text.split(/\r\n|\r|\n/).map(line => line.trimEnd());
104
+ while (lines.length > 0 && lines[0].trim() === '')
105
+ lines.shift();
106
+ while (lines.length > 0 && lines[lines.length - 1].trim() === '')
107
+ lines.pop();
108
+ if (lines.length === 0)
109
+ return ['{/* */}'];
110
+ if (lines.length === 1)
111
+ return [`{/* ${lines[0].trim()} */}`];
112
+ const margin = Math.min(...lines
113
+ .filter(line => line.trim() !== '')
114
+ .map(line => line.match(/^[ \t]*/)[0].length));
115
+ return [
116
+ '{/*',
117
+ ...lines.map(line => (line.trim() === '' ? '' : ` ${line.slice(margin)}`)),
118
+ '*/}',
119
+ ];
120
+ }
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Which whitespace in an HTML tree renders, decided the way CSS lays it out.
3
+ *
4
+ * JSX has whitespace rules of its own, and they are not CSS's: it keeps a
5
+ * space between two tags on one line and drops every run with a line break
6
+ * in it. So the emitter needs to know, for each run of whitespace in the
7
+ * HTML, whether it renders at all. Inside `<pre>`, `<textarea>` and
8
+ * `<listing>`, under an inline `white-space` that preserves it, and in a
9
+ * script or a stylesheet, every character is kept exactly. Elsewhere a run
10
+ * is one space, and it renders nothing:
11
+ *
12
+ * - at the start or end of a line: the start or end of a block container,
13
+ * or beside a block-level box or a `<br>`, seen through inline elements;
14
+ * - right after another space, which it collapses into;
15
+ * - inside a flex or grid container, a `<select>`, `<head>` or `<html>`,
16
+ * where every child is a box of its own, so a text's edges are line
17
+ * edges too;
18
+ * - between the shapes of an SVG or MathML drawing, outside its text.
19
+ *
20
+ * A table, its rows, groups, cells and captions are block-level boxes and
21
+ * block containers, so a run between two of them renders nothing (the first
22
+ * rule). Inline content in a table, which only CSS can put there, sits in an
23
+ * anonymous cell, and a run inside it renders as it does in any block.
24
+ *
25
+ * Comments and `display: none` boxes render nothing, so a run is judged by
26
+ * what is beside them. An element's display comes from `displayOf`; the
27
+ * default reads an inline `style` and then the HTML UA stylesheet, which is
28
+ * where it stops: a page's own CSS can change any display, and the honest
29
+ * limit is that this reads no CSS file.
30
+ */
31
+ import { type CommentNode, type Element, type ParentNode } from './parse.js';
32
+ /** An element's CSS `display`, or undefined when the hook can't tell. */
33
+ export type DisplayOf = (element: Element) => string | undefined;
34
+ export type Piece =
35
+ /** An element or a comment, in its place. */
36
+ {
37
+ kind: 'node';
38
+ node: Element | CommentNode;
39
+ }
40
+ /** A run of text with no whitespace in it. */
41
+ | {
42
+ kind: 'word';
43
+ text: string;
44
+ line: number | null;
45
+ }
46
+ /**
47
+ * A run of whitespace: one space when `kept`, nothing otherwise.
48
+ * `newlines` counts the line breaks it had, for the emitter's layout.
49
+ */
50
+ | {
51
+ kind: 'space';
52
+ kept: boolean;
53
+ newlines: number;
54
+ line: number | null;
55
+ }
56
+ /** Preformatted text, every character of which renders. */
57
+ | {
58
+ kind: 'exact';
59
+ text: string;
60
+ line: number | null;
61
+ };
62
+ /** The display an element's own `style` attribute gives it. */
63
+ export declare function inlineStyleDisplay(element: Element): string | undefined;
64
+ /**
65
+ * The display the HTML spec's UA stylesheet gives an element: by its tag,
66
+ * and `none` for what it hides by attribute (`[hidden]`, a hidden input, a
67
+ * closed dialog). Undefined for an element in another namespace.
68
+ */
69
+ export declare function uaDisplay(element: Element): string | undefined;
70
+ /**
71
+ * An inline `display`, when it is one CSS reads (otherwise the declaration
72
+ * is ignored), else the UA stylesheet's.
73
+ */
74
+ export declare const defaultDisplayOf: DisplayOf;
75
+ /**
76
+ * Every element's and fragment's children as pieces, from `root` down.
77
+ * `root` is laid out as a block container, as a page's body is.
78
+ */
79
+ export declare function layoutWhitespace(root: ParentNode, displayOf?: DisplayOf): Map<ParentNode, Piece[]>;
80
+ //# sourceMappingURL=whitespace.d.ts.map
@@ -0,0 +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,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE;AACrD;;;GAGG;GACD;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE;AACzE,2DAA2D;GACzD;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAAC;AAyJzD,+DAA+D;AAC/D,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAEvE;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAkB9D;AAMD;;;GAGG;AACH,eAAO,MAAM,gBAAgB,EAAE,SAM9B,CAAC;AAsIF;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,UAAU,EAChB,SAAS,GAAE,SAA4B,GACtC,GAAG,CAAC,UAAU,EAAE,KAAK,EAAE,CAAC,CA0G1B"}