bestax-migrate 2.3.8 → 2.4.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 +21 -17
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +45 -11
- package/dist/sources/_shared/bestax-import.d.ts +48 -0
- package/dist/sources/_shared/bestax-import.d.ts.map +1 -0
- package/dist/sources/_shared/bestax-import.js +142 -0
- package/dist/sources/_shared/css-imports.d.ts +33 -0
- package/dist/sources/_shared/css-imports.d.ts.map +1 -0
- package/dist/sources/_shared/css-imports.js +103 -0
- package/dist/sources/_shared/deps-common.d.ts +51 -0
- package/dist/sources/_shared/deps-common.d.ts.map +1 -0
- package/dist/sources/_shared/deps-common.js +115 -0
- package/dist/sources/_shared/jsx-utils.d.ts +28 -0
- package/dist/sources/_shared/jsx-utils.d.ts.map +1 -1
- package/dist/sources/_shared/jsx-utils.js +59 -1
- package/dist/sources/_shared/make-styles-transform.d.ts +6 -2
- package/dist/sources/_shared/make-styles-transform.d.ts.map +1 -1
- package/dist/sources/_shared/make-styles-transform.js +12 -4
- package/dist/sources/_shared/props.d.ts.map +1 -1
- package/dist/sources/_shared/props.js +2 -2
- package/dist/sources/_shared/specials-utils.d.ts +1 -1
- package/dist/sources/_shared/specials-utils.d.ts.map +1 -1
- package/dist/sources/_shared/specials-utils.js +19 -1
- package/dist/sources/bloomer/deps.d.ts.map +1 -1
- package/dist/sources/bloomer/deps.js +14 -89
- package/dist/sources/bloomer/transform.d.ts.map +1 -1
- package/dist/sources/bloomer/transform.js +12 -186
- package/dist/sources/bulma-classes/class-map.d.ts +161 -0
- package/dist/sources/bulma-classes/class-map.d.ts.map +1 -0
- package/dist/sources/bulma-classes/class-map.js +1046 -0
- package/dist/sources/bulma-classes/deps.d.ts +14 -0
- package/dist/sources/bulma-classes/deps.d.ts.map +1 -0
- package/dist/sources/bulma-classes/deps.js +56 -0
- package/dist/sources/bulma-classes/index.d.ts +3 -0
- package/dist/sources/bulma-classes/index.d.ts.map +1 -0
- package/dist/sources/bulma-classes/index.js +35 -0
- package/dist/sources/bulma-classes/plan.d.ts +53 -0
- package/dist/sources/bulma-classes/plan.d.ts.map +1 -0
- package/dist/sources/bulma-classes/plan.js +231 -0
- package/dist/sources/bulma-classes/project.d.ts +40 -0
- package/dist/sources/bulma-classes/project.d.ts.map +1 -0
- package/dist/sources/bulma-classes/project.js +203 -0
- package/dist/sources/bulma-classes/rules.d.ts +16 -0
- package/dist/sources/bulma-classes/rules.d.ts.map +1 -0
- package/dist/sources/bulma-classes/rules.js +53 -0
- package/dist/sources/bulma-classes/styles.d.ts +13 -0
- package/dist/sources/bulma-classes/styles.d.ts.map +1 -0
- package/dist/sources/bulma-classes/styles.js +18 -0
- package/dist/sources/bulma-classes/transform.d.ts +21 -0
- package/dist/sources/bulma-classes/transform.d.ts.map +1 -0
- package/dist/sources/bulma-classes/transform.js +486 -0
- package/dist/sources/rbx/deps.d.ts.map +1 -1
- package/dist/sources/rbx/deps.js +29 -117
- package/dist/sources/rbx/mapping.d.ts.map +1 -1
- package/dist/sources/rbx/mapping.js +9 -1
- package/dist/sources/rbx/specials.d.ts.map +1 -1
- package/dist/sources/rbx/specials.js +20 -10
- package/dist/sources/rbx/transform.d.ts.map +1 -1
- package/dist/sources/rbx/transform.js +22 -204
- package/dist/sources/react-bulma-components/deps.d.ts.map +1 -1
- package/dist/sources/react-bulma-components/deps.js +12 -87
- package/dist/sources/react-bulma-components/mapping.js +1 -1
- package/dist/sources/react-bulma-components/specials.d.ts.map +1 -1
- package/dist/sources/react-bulma-components/specials.js +42 -4
- package/dist/sources/react-bulma-components/transform.d.ts.map +1 -1
- package/dist/sources/react-bulma-components/transform.js +16 -187
- package/dist/sources/registry.d.ts.map +1 -1
- package/dist/sources/registry.js +2 -0
- package/dist/types.d.ts +25 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +4 -3
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The package.json steps every source's manifest pass takes once the source
|
|
3
|
+
* library itself is dealt with: bring in bestax-bulma, move the app's Bulma to
|
|
4
|
+
* v1, report peer ranges bestax-bulma cannot install beside, and swap the
|
|
5
|
+
* dead node-sass for dart-sass. Pure data-in/data-out, like the passes that
|
|
6
|
+
* call it: no package manager is ever invoked.
|
|
7
|
+
*/
|
|
8
|
+
import { isPreV1 } from './semver-range.js';
|
|
9
|
+
const BESTAX_RANGE = '^5';
|
|
10
|
+
export const BULMA_RANGE = '^1.0.4';
|
|
11
|
+
// Bulma v1's sass tree uses `color.channel(…)` — needs dart-sass ≥ 1.79.
|
|
12
|
+
const SASS_RANGE = '^1.79.0';
|
|
13
|
+
export const DEP_SECTIONS = ['dependencies', 'devDependencies'];
|
|
14
|
+
export function openManifest(filePath, pkg, collector) {
|
|
15
|
+
const changes = [];
|
|
16
|
+
const next = pkg;
|
|
17
|
+
const report = (rule, message) => collector?.add({ file: filePath, line: null, rule, message });
|
|
18
|
+
return {
|
|
19
|
+
next,
|
|
20
|
+
section: name => (next[name] ?? undefined),
|
|
21
|
+
note: message => {
|
|
22
|
+
changes.push(message);
|
|
23
|
+
report('deps', message);
|
|
24
|
+
},
|
|
25
|
+
report,
|
|
26
|
+
result: () => changes.length > 0 ? next : null,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/** Whether every alternative of a plain range names a major below `major`. */
|
|
30
|
+
function majorBelow(range, major) {
|
|
31
|
+
const majors = range
|
|
32
|
+
.split('||')
|
|
33
|
+
.map(set => set.trim().match(/^[~^=v\s]*(\d+)(?:[.\s]|$)/)?.[1]);
|
|
34
|
+
return (majors.length > 0 &&
|
|
35
|
+
majors.every(found => found !== undefined && Number(found) < major));
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* @allxsmith/bestax-bulma comes in as a runtime dependency. An older major
|
|
39
|
+
* already declared is reported, not raised: the migrated code is written for
|
|
40
|
+
* the current one, and moving the app's existing bestax code across majors is
|
|
41
|
+
* the app's own step.
|
|
42
|
+
*/
|
|
43
|
+
export function addBestax(manifest) {
|
|
44
|
+
const dependencies = (manifest.next.dependencies ??= {});
|
|
45
|
+
const declared = dependencies['@allxsmith/bestax-bulma'] ??
|
|
46
|
+
manifest.section('devDependencies')?.['@allxsmith/bestax-bulma'];
|
|
47
|
+
if (declared === undefined) {
|
|
48
|
+
dependencies['@allxsmith/bestax-bulma'] = BESTAX_RANGE;
|
|
49
|
+
manifest.note(`added @allxsmith/bestax-bulma ${BESTAX_RANGE} to dependencies`);
|
|
50
|
+
}
|
|
51
|
+
else if (majorBelow(declared, 5)) {
|
|
52
|
+
manifest.report('peer-deps', `@allxsmith/bestax-bulma ${declared} is older than the ${BESTAX_RANGE} the migrated code is written for; upgrade it before installing (the bestax-bulma upgrade guides cover each major)`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Bump a pre-1 Bulma range; add one only when sources still reference
|
|
57
|
+
* bulma/… directly (otherwise it arrives transitively via bestax-bulma).
|
|
58
|
+
*/
|
|
59
|
+
export function moveBulmaToV1(manifest, bulmaReferenced) {
|
|
60
|
+
const outcome = { declared: null, bumped: false, added: false };
|
|
61
|
+
for (const name of DEP_SECTIONS) {
|
|
62
|
+
const deps = manifest.section(name);
|
|
63
|
+
if (deps?.bulma) {
|
|
64
|
+
outcome.declared = deps.bulma;
|
|
65
|
+
if (isPreV1(deps.bulma)) {
|
|
66
|
+
deps.bulma = BULMA_RANGE;
|
|
67
|
+
outcome.bumped = true;
|
|
68
|
+
manifest.note(`bumped bulma to ${BULMA_RANGE} in ${name} (was pre-1.0)`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if (outcome.declared === null && bulmaReferenced) {
|
|
73
|
+
const dependencies = (manifest.next.dependencies ??= {});
|
|
74
|
+
dependencies.bulma = BULMA_RANGE;
|
|
75
|
+
outcome.added = true;
|
|
76
|
+
manifest.note(`added bulma ${BULMA_RANGE} to dependencies (sources import bulma/… directly)`);
|
|
77
|
+
}
|
|
78
|
+
return outcome;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Report ranges bestax-bulma's peers cannot install beside. Report only: a
|
|
82
|
+
* React major and a Font Awesome major (whose icon names change) are the
|
|
83
|
+
* app's own migration steps.
|
|
84
|
+
*/
|
|
85
|
+
export function reportPeerRanges(manifest) {
|
|
86
|
+
for (const name of DEP_SECTIONS) {
|
|
87
|
+
const range = manifest.section(name)?.react;
|
|
88
|
+
if (range && /^[~^]?(?:[0-9]|1[0-7])(?:[.x]|$)/.test(range.trim())) {
|
|
89
|
+
manifest.report('peer-deps', `react ${range} predates bestax-bulma's peer range (^18 || ^19) — upgrade react and react-dom to 18 or 19 before installing`);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
// Font Awesome older than 6 conflicts with bestax-bulma's optional peer
|
|
93
|
+
// range and makes `npm install` fail with ERESOLVE.
|
|
94
|
+
for (const name of DEP_SECTIONS) {
|
|
95
|
+
const range = manifest.section(name)?.['@fortawesome/fontawesome-free'];
|
|
96
|
+
if (range && /^[~^]?[0-5](?:[.x]|$)/.test(range.trim())) {
|
|
97
|
+
manifest.report('peer-deps', `@fortawesome/fontawesome-free ${range} predates bestax-bulma's optional peer range (^6.7.2 || ^7.0.0) — upgrade it, or install with \`npm install --legacy-peer-deps\``);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
/** node-sass is dead; dart-sass replaces it in the same section. */
|
|
102
|
+
export function replaceNodeSass(manifest) {
|
|
103
|
+
for (const name of DEP_SECTIONS) {
|
|
104
|
+
const deps = manifest.section(name);
|
|
105
|
+
if (deps && 'node-sass' in deps) {
|
|
106
|
+
delete deps['node-sass'];
|
|
107
|
+
manifest.note(`removed node-sass from ${name}`);
|
|
108
|
+
const sassDeclared = DEP_SECTIONS.some(s => manifest.section(s)?.sass);
|
|
109
|
+
if (!sassDeclared) {
|
|
110
|
+
deps.sass = SASS_RANGE;
|
|
111
|
+
manifest.note(`added sass ${SASS_RANGE} to ${name} (replaces node-sass)`);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
@@ -98,8 +98,36 @@ export type Booleanish = 'truthy' | 'falsy' | 'expression';
|
|
|
98
98
|
* resolvable, so they can't drift out of sync with each other.
|
|
99
99
|
*/
|
|
100
100
|
export declare function resolveBooleanish(attr: any): Booleanish;
|
|
101
|
+
/**
|
|
102
|
+
* A JSX attribute value holding `value`. A JSX attribute string has no
|
|
103
|
+
* escapes, so the printer's `\"` would end the string early and its `\\` would
|
|
104
|
+
* double a backslash: a value holding either goes in an expression
|
|
105
|
+
* (`name={"…"}`), where the escaping means what it says.
|
|
106
|
+
*/
|
|
107
|
+
export declare function jsxStringValue(j: JSCodeshift, value: string): any;
|
|
101
108
|
/** Create `name` (bare boolean) or `name="value"` attribute. */
|
|
102
109
|
export declare function makeAttr(j: JSCodeshift, name: string, value?: string): any;
|
|
110
|
+
/**
|
|
111
|
+
* Call on the root just before `toSource`. recast reuses the original text of
|
|
112
|
+
* whatever an edit left alone, but it cannot patch a JSX element the source
|
|
113
|
+
* wrapped in parentheses (the usual `return ( … )`), so an edit anywhere in
|
|
114
|
+
* one reprints the whole element. Its printer trims the whitespace at the
|
|
115
|
+
* edges of every text child and decodes entities, so `</b> ends` came back as
|
|
116
|
+
* `</b>ends` and `<` as a raw `<`: visible text changed, and some files no
|
|
117
|
+
* longer parsed. Dropping the parenthesized marker from the node and from
|
|
118
|
+
* recast's copy of the original lets it patch; the parentheses themselves are
|
|
119
|
+
* still in the reused text.
|
|
120
|
+
*/
|
|
121
|
+
export declare function forgetJsxParens(j: JSCodeshift, root: any): void;
|
|
122
|
+
/**
|
|
123
|
+
* Call on the root just before `toSource`. When a statement is added at the
|
|
124
|
+
* top level (a new import), recast reprints the program: it reuses each
|
|
125
|
+
* directive's original text, semicolon included, and then adds a semicolon of
|
|
126
|
+
* its own, so `'use client';` came back as `'use client';;`. A new directive
|
|
127
|
+
* node has no original text to reuse, and carrying the raw string keeps its
|
|
128
|
+
* quotes as written.
|
|
129
|
+
*/
|
|
130
|
+
export declare function reprintDirectives(j: JSCodeshift, root: any): void;
|
|
103
131
|
/**
|
|
104
132
|
* Attach a `// TODO(bestax-migrate): ...` leading comment to the closest
|
|
105
133
|
* enclosing statement (comments inside JSX children are not valid JS, so the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsx-utils.d.ts","sourceRoot":"","sources":["../../../src/sources/_shared/jsx-utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAMpD,MAAM,WAAW,gBAAgB;IAC/B,CAAC,EAAE,WAAW,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,aAAa,GAAG,SAAS,CAAC;IACrC,2EAA2E;IAC3E,QAAQ,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACtB,8EAA8E;IAC9E,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5B;;;;OAIG;IACH,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;IAClC;;;;OAIG;IACH,SAAS,EAAE,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC;;;OAGG;IACH,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,MAAM,EAAE,GAAG,IAAI,CAAC;IACzC,KAAK,EAAE,OAAO,CAAC;CAChB;AAED,2EAA2E;AAC3E,wBAAgB,YAAY,CAAC,IAAI,EAAE,GAAG,GAAG,MAAM,EAAE,GAAG,IAAI,CASvD;AAED,4EAA4E;AA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B,EACrB,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,EAClB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,GACd,IAAI,CAgDN;AAED,uEAAuE;AACvE,wBAAgB,YAAY,CAC1B,CAAC,EAAE,WAAW,EACd,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,KAAK,EAAE,GAAG,EAAE,EACZ,QAAQ,EAAE,GAAG,EAAE,EACf,WAAW,UAAQ,GAClB,GAAG,CAsBL"}
|
|
@@ -148,9 +148,67 @@ export function resolveBooleanish(attr) {
|
|
|
148
148
|
return 'expression';
|
|
149
149
|
return literal.value ? 'truthy' : 'falsy';
|
|
150
150
|
}
|
|
151
|
+
/**
|
|
152
|
+
* A JSX attribute value holding `value`. A JSX attribute string has no
|
|
153
|
+
* escapes, so the printer's `\"` would end the string early and its `\\` would
|
|
154
|
+
* double a backslash: a value holding either goes in an expression
|
|
155
|
+
* (`name={"…"}`), where the escaping means what it says.
|
|
156
|
+
*/
|
|
157
|
+
export function jsxStringValue(j, value) {
|
|
158
|
+
const literal = j.stringLiteral(value);
|
|
159
|
+
return /["\\]/.test(value) ? j.jsxExpressionContainer(literal) : literal;
|
|
160
|
+
}
|
|
151
161
|
/** Create `name` (bare boolean) or `name="value"` attribute. */
|
|
152
162
|
export function makeAttr(j, name, value) {
|
|
153
|
-
|
|
163
|
+
if (value === undefined)
|
|
164
|
+
return j.jsxAttribute(j.jsxIdentifier(name), null);
|
|
165
|
+
return j.jsxAttribute(j.jsxIdentifier(name), jsxStringValue(j, value));
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Call on the root just before `toSource`. recast reuses the original text of
|
|
169
|
+
* whatever an edit left alone, but it cannot patch a JSX element the source
|
|
170
|
+
* wrapped in parentheses (the usual `return ( … )`), so an edit anywhere in
|
|
171
|
+
* one reprints the whole element. Its printer trims the whitespace at the
|
|
172
|
+
* edges of every text child and decodes entities, so `</b> ends` came back as
|
|
173
|
+
* `</b>ends` and `<` as a raw `<`: visible text changed, and some files no
|
|
174
|
+
* longer parsed. Dropping the parenthesized marker from the node and from
|
|
175
|
+
* recast's copy of the original lets it patch; the parentheses themselves are
|
|
176
|
+
* still in the reused text.
|
|
177
|
+
*/
|
|
178
|
+
export function forgetJsxParens(j, root) {
|
|
179
|
+
const clear = (node) => {
|
|
180
|
+
for (const copy of [node, node.original]) {
|
|
181
|
+
if (copy?.extra?.parenthesized) {
|
|
182
|
+
delete copy.extra.parenthesized;
|
|
183
|
+
delete copy.extra.parenStart;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
root.find(j.JSXElement).forEach((path) => clear(path.node));
|
|
188
|
+
root.find(j.JSXFragment).forEach((path) => clear(path.node));
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Call on the root just before `toSource`. When a statement is added at the
|
|
192
|
+
* top level (a new import), recast reprints the program: it reuses each
|
|
193
|
+
* directive's original text, semicolon included, and then adds a semicolon of
|
|
194
|
+
* its own, so `'use client';` came back as `'use client';;`. A new directive
|
|
195
|
+
* node has no original text to reuse, and carrying the raw string keeps its
|
|
196
|
+
* quotes as written.
|
|
197
|
+
*/
|
|
198
|
+
export function reprintDirectives(j, root) {
|
|
199
|
+
const program = root.find(j.Program).paths()[0]?.node;
|
|
200
|
+
if (!program?.directives?.length)
|
|
201
|
+
return;
|
|
202
|
+
program.directives = program.directives.map((directive) => {
|
|
203
|
+
const literal = j.directiveLiteral(directive.value.value);
|
|
204
|
+
const raw = directive.value.extra?.raw;
|
|
205
|
+
if (typeof raw === 'string') {
|
|
206
|
+
literal.extra = { raw, rawValue: directive.value.value };
|
|
207
|
+
}
|
|
208
|
+
const fresh = j.directive(literal);
|
|
209
|
+
fresh.comments = directive.comments;
|
|
210
|
+
return fresh;
|
|
211
|
+
});
|
|
154
212
|
}
|
|
155
213
|
/**
|
|
156
214
|
* Attach a `// TODO(bestax-migrate): ...` leading comment to the closest
|
|
@@ -14,8 +14,11 @@
|
|
|
14
14
|
*/
|
|
15
15
|
import type { StylesTransform } from '../../types.js';
|
|
16
16
|
export interface StylesConfig {
|
|
17
|
-
/**
|
|
18
|
-
|
|
17
|
+
/**
|
|
18
|
+
* npm package name of the source library, e.g. `rbx`. Omitted for a source
|
|
19
|
+
* with no package, whose stylesheets only ever import Bulma itself.
|
|
20
|
+
*/
|
|
21
|
+
packageName?: string;
|
|
19
22
|
/** URL of that source's migration guide, linked from every TODO. */
|
|
20
23
|
guideUrl: string;
|
|
21
24
|
/**
|
|
@@ -32,6 +35,7 @@ export interface StylesConfig {
|
|
|
32
35
|
* `packageName` drives two regexes — one matching any `@import` of that
|
|
33
36
|
* package, one narrowing to its *root* stylesheet (which becomes a Bulma v1
|
|
34
37
|
* root rather than being dropped). Everything else is Bulma-side and shared.
|
|
38
|
+
* Without a package neither can match, and only the Bulma rewriting runs.
|
|
35
39
|
*/
|
|
36
40
|
export declare function makeStylesTransform(config: StylesConfig): StylesTransform;
|
|
37
41
|
//# sourceMappingURL=make-styles-transform.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"make-styles-transform.d.ts","sourceRoot":"","sources":["../../../src/sources/_shared/make-styles-transform.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,KAAK,EAAE,eAAe,EAAiB,MAAM,gBAAgB,CAAC;AAErE,MAAM,WAAW,YAAY;IAC3B
|
|
1
|
+
{"version":3,"file":"make-styles-transform.d.ts","sourceRoot":"","sources":["../../../src/sources/_shared/make-styles-transform.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,KAAK,EAAE,eAAe,EAAiB,MAAM,gBAAgB,CAAC;AAErE,MAAM,WAAW,YAAY;IAC3B;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oEAAoE;IACpE,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;;OAKG;IACH,sBAAsB,EAAE,MAAM,EAAE,CAAC;CAClC;AAyMD;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,YAAY,GAAG,eAAe,CAsVzE"}
|
|
@@ -197,10 +197,14 @@ function report(collector, file, line, rule, message) {
|
|
|
197
197
|
* `packageName` drives two regexes — one matching any `@import` of that
|
|
198
198
|
* package, one narrowing to its *root* stylesheet (which becomes a Bulma v1
|
|
199
199
|
* root rather than being dropped). Everything else is Bulma-side and shared.
|
|
200
|
+
* Without a package neither can match, and only the Bulma rewriting runs.
|
|
200
201
|
*/
|
|
201
202
|
export function makeStylesTransform(config) {
|
|
202
203
|
const { packageName, guideUrl: GUIDE } = config;
|
|
203
|
-
|
|
204
|
+
// `packageName` is interpolated into messages only after one of these
|
|
205
|
+
// matched, so the no-package case never reaches them.
|
|
206
|
+
const NEVER = /(?!)/;
|
|
207
|
+
const pkg = packageName?.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
204
208
|
// Already regex fragments — see StylesConfig.
|
|
205
209
|
const roots = config.rootStylesheetSuffixes.join('|');
|
|
206
210
|
/**
|
|
@@ -210,11 +214,15 @@ export function makeStylesTransform(config) {
|
|
|
210
214
|
* and SOURCE_ROOT_STYLESHEET below already accepts that bare form — so
|
|
211
215
|
* requiring the slash here made the bare case unreachable.
|
|
212
216
|
*/
|
|
213
|
-
const SOURCE_STYLE_IMPORT =
|
|
217
|
+
const SOURCE_STYLE_IMPORT = pkg === undefined
|
|
218
|
+
? NEVER
|
|
219
|
+
: new RegExp(`^(\\s*)@import\\s+(['"])((?:\\.\\.?/)+node_modules/|~)?${pkg}(?:/[^'"]*)?\\2\\s*;?\\s*(?://[^\\n]*)?\\s*$`);
|
|
214
220
|
/** Cheap "is this file even about us?" pre-filter (see the guard below). */
|
|
215
|
-
const SOURCE_MENTION = new RegExp(pkg);
|
|
221
|
+
const SOURCE_MENTION = pkg === undefined ? NEVER : new RegExp(pkg);
|
|
216
222
|
/** …narrowed to the ones that stand in for a whole Bulma root. */
|
|
217
|
-
const SOURCE_ROOT_STYLESHEET =
|
|
223
|
+
const SOURCE_ROOT_STYLESHEET = pkg === undefined
|
|
224
|
+
? NEVER
|
|
225
|
+
: new RegExp(`^\\s*@import\\s+(['"])(?:(?:\\.\\.?/)+node_modules/|~)?${pkg}${roots ? `(?:${roots})?` : ''}\\1\\s*;?\\s*(?://[^\\n]*)?\\s*$`);
|
|
218
226
|
const transformStyles = (filePath, source, collector, options) => {
|
|
219
227
|
const cssMode = options.cssMode ?? 'bestax';
|
|
220
228
|
// Cheap pre-filter. It must accept a file that names only the SOURCE
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"props.d.ts","sourceRoot":"","sources":["../../../src/sources/_shared/props.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,
|
|
1
|
+
{"version":3,"file":"props.d.ts","sourceRoot":"","sources":["../../../src/sources/_shared/props.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAUL,KAAK,gBAAgB,EACtB,MAAM,gBAAgB,CAAC;AAIxB;;;;GAIG;AACH,wBAAgB,YAAY,CAC1B,GAAG,EAAE,gBAAgB,EACrB,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,EAClB,OAAO,EAAE,GAAG,EACZ,YAAY,EAAE,MAAM,EACpB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,GAAG,SAAS,GACxB,IAAI,CAEN;AAED;;;GAGG;AACH,wBAAgB,WAAW,CACzB,GAAG,EAAE,gBAAgB,EACrB,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,EAClB,OAAO,EAAE,GAAG,EACZ,YAAY,EAAE,MAAM,EACpB,IAAI,EAAE,GAAG,GACR,IAAI,CAmBN;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CACxB,GAAG,EAAE,gBAAgB,EACrB,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,EAClB,OAAO,EAAE,GAAG,EACZ,GAAG,EAAE,MAAM,EACX,YAAY,EAAE,MAAM,GACnB,IAAI,CAoBN;AAED,mDAAmD;AACnD,wBAAgB,eAAe,CAC7B,GAAG,EAAE,gBAAgB,EACrB,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,EAClB,OAAO,EAAE,GAAG,EACZ,IAAI,EAAE,GAAG,EACT,MAAM,EAAE,UAAU,GACjB,IAAI,CAqLN;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,gBAAgB,EACrB,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,EAClB,OAAO,EAAE,GAAG,EACZ,OAAO,EAAE,GAAG,CAAC,MAAM,CAAC,EACpB,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,GACzC,IAAI,CAQN"}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* imported, so each source keeps its own `UNIVERSAL_PROPS` in its `mapping.ts`
|
|
7
7
|
* while sharing this interpreter.
|
|
8
8
|
*/
|
|
9
|
-
import { addAttr, addTodo, attributesOf, findAttr, literalValueOf, makeAttr, removeAttr, resolveBooleanish, } from './jsx-utils.js';
|
|
9
|
+
import { addAttr, addTodo, attributesOf, findAttr, jsxStringValue, literalValueOf, makeAttr, removeAttr, resolveBooleanish, } from './jsx-utils.js';
|
|
10
10
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
11
11
|
/**
|
|
12
12
|
* Add a converted attribute unless the target name is already present — two
|
|
@@ -51,7 +51,7 @@ export function mergeClass(ctx, path, element, cls, originalName) {
|
|
|
51
51
|
const classes = literal.value.split(/\s+/).filter(Boolean);
|
|
52
52
|
if (!classes.includes(cls))
|
|
53
53
|
classes.push(cls);
|
|
54
|
-
existing.value = j
|
|
54
|
+
existing.value = jsxStringValue(j, classes.join(' '));
|
|
55
55
|
return;
|
|
56
56
|
}
|
|
57
57
|
addTodo(ctx, path, `prop:${originalName}`, `\`${originalName}\` becomes the \`${cls}\` class, but \`className\` is dynamic here; add \`${cls}\` to it by hand`);
|
|
@@ -29,7 +29,7 @@ export declare function alignTarget(ctx: TransformContext, path: ASTPath<any>, e
|
|
|
29
29
|
* bound for a plain HTML element (they only exist on bestax components),
|
|
30
30
|
* leaving a TODO when any were dropped.
|
|
31
31
|
*/
|
|
32
|
-
export declare function makeStripModifierProps(universalProps: Record<string, PropAction>, responsiveBreakpoints: Record<string, string | null
|
|
32
|
+
export declare function makeStripModifierProps(universalProps: Record<string, PropAction>, responsiveBreakpoints: Record<string, string | null>, refProp?: string): (ctx: TransformContext, path: ASTPath<any>, attrs: any[], where: string) => any[];
|
|
33
33
|
/**
|
|
34
34
|
* Consume the element's `className` so a plain-element rewrite can merge it
|
|
35
35
|
* with its hard-coded Bulma class instead of dropping it. A dynamic value
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"specials-utils.d.ts","sourceRoot":"","sources":["../../../src/sources/_shared/specials-utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAQjD,OAAO,EAUL,KAAK,gBAAgB,EACtB,MAAM,gBAAgB,CAAC;AAIxB,MAAM,WAAW,aAAa;IAC5B,2DAA2D;IAC3D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,oEAAoE;IACpE,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,yEAAyE;IACzE,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB;AAED,MAAM,MAAM,cAAc,GAAG,C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G;AACH,wBAAgB,aAAa,CAC3B,GAAG,EAAE,gBAAgB,EACrB,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,EAClB,OAAO,EAAE,GAAG,EACZ,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,GACZ,MAAM,CAeR;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,gBAAgB,EACrB,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,EAClB,OAAO,EAAE,GAAG,EACZ,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,OAAO,EAAE,MAAM,EAAE,EACjB,IAAI,SAAO,GACV,IAAI,CAaN;AAED;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CACtC,GAAG,EAAE,gBAAgB,EACrB,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,EAClB,OAAO,EAAE,GAAG,EACZ,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,GACZ,IAAI,CA2CN;AAED,8EAA8E;AAC9E,MAAM,MAAM,SAAS,GAAG,CACtB,GAAG,EAAE,gBAAgB,EACrB,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,EAClB,KAAK,EAAE,GAAG,EAAE,EACZ,KAAK,EAAE,MAAM,KACV,GAAG,EAAE,CAAC;AAEX;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,SAAS;4BAG7C,gBAAgB,QACf,OAAO,CAAC,GAAG,CAAC,WACT,GAAG,OACP,MAAM,aACA,MAAM,GAAG,SAAS,SACtB,MAAM,KACZ,aAAa;6BA2CT,gBAAgB,QACf,OAAO,CAAC,GAAG,CAAC,WACT,GAAG,SACL,MAAM,YACH,MAAM,GAAG,MAAM,EAAE,KAC1B,aAAa,GAAG,IAAI;EA8CxB"}
|
|
@@ -39,12 +39,30 @@ export function alignTarget(ctx, path, element, prop, targets, fallback) {
|
|
|
39
39
|
* bound for a plain HTML element (they only exist on bestax components),
|
|
40
40
|
* leaving a TODO when any were dropped.
|
|
41
41
|
*/
|
|
42
|
-
export function makeStripModifierProps(universalProps, responsiveBreakpoints) {
|
|
42
|
+
export function makeStripModifierProps(universalProps, responsiveBreakpoints, refProp) {
|
|
43
43
|
return function stripModifierProps(ctx, path, attrs, where) {
|
|
44
44
|
const kept = [];
|
|
45
45
|
const dropped = [];
|
|
46
46
|
for (const attr of attrs) {
|
|
47
47
|
const name = attr?.name?.name;
|
|
48
|
+
// Both sources keep their ref escape hatch (`innerRef`, `domRef`) in
|
|
49
|
+
// the universal table so an unmapped one is flagged rather than passed
|
|
50
|
+
// through in silence. Neither is a Bulma modifier, and the intrinsic
|
|
51
|
+
// tag this rewrite produces takes a real `ref` — so it is renamed onto
|
|
52
|
+
// the tag here. Dropping it would delete a working ref and tell the
|
|
53
|
+
// user to "restyle with classes", which is advice for a modifier.
|
|
54
|
+
// The same collision `applyPropAction` guards: with a `ref` already on
|
|
55
|
+
// the element the rename would emit two, which does not compile.
|
|
56
|
+
if (refProp && name === refProp) {
|
|
57
|
+
if (attrs.some(other => other?.name?.name === 'ref')) {
|
|
58
|
+
addTodo(ctx, path, `prop:${refProp}`, `${where}: \`${refProp}\` maps to \`ref\`, but \`ref\` is already set on this element, so \`${refProp}\` was dropped — reconcile by hand`);
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
attr.name = ctx.j.jsxIdentifier('ref');
|
|
62
|
+
ctx.dirty = true;
|
|
63
|
+
kept.push(attr);
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
48
66
|
if (name && (universalProps[name] || name in responsiveBreakpoints)) {
|
|
49
67
|
dropped.push(name);
|
|
50
68
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deps.d.ts","sourceRoot":"","sources":["../../../src/sources/bloomer/deps.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAUzD,eAAO,MAAM,kBAAkB,EAAE,
|
|
1
|
+
{"version":3,"file":"deps.d.ts","sourceRoot":"","sources":["../../../src/sources/bloomer/deps.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAUzD,eAAO,MAAM,kBAAkB,EAAE,kBAwChC,CAAC"}
|
|
@@ -12,28 +12,17 @@
|
|
|
12
12
|
* not the app's; if they appear here the app declared them for its own
|
|
13
13
|
* reasons, so they are left alone.
|
|
14
14
|
*/
|
|
15
|
-
import {
|
|
16
|
-
const BESTAX_RANGE = '^5';
|
|
17
|
-
const BULMA_RANGE = '^1.0.4';
|
|
18
|
-
// Bulma v1's sass tree uses `color.channel(…)` — needs dart-sass ≥ 1.79.
|
|
19
|
-
const SASS_RANGE = '^1.79.0';
|
|
20
|
-
const DEP_SECTIONS = ['dependencies', 'devDependencies'];
|
|
15
|
+
import { DEP_SECTIONS, addBestax, moveBulmaToV1, openManifest, replaceNodeSass, reportPeerRanges, } from '../_shared/deps-common.js';
|
|
21
16
|
export const updateDependencies = (filePath, pkg, collector, options) => {
|
|
22
|
-
const
|
|
23
|
-
const next = pkg;
|
|
24
|
-
const section = (name) => (next[name] ?? undefined);
|
|
25
|
-
const note = (message) => {
|
|
26
|
-
changes.push(message);
|
|
27
|
-
collector?.add({ file: filePath, line: null, rule: 'deps', message });
|
|
28
|
-
};
|
|
17
|
+
const manifest = openManifest(filePath, pkg, collector);
|
|
29
18
|
// bloomer goes away entirely.
|
|
30
19
|
let removedSource = false;
|
|
31
20
|
for (const name of DEP_SECTIONS) {
|
|
32
|
-
const deps = section(name);
|
|
21
|
+
const deps = manifest.section(name);
|
|
33
22
|
if (deps && 'bloomer' in deps) {
|
|
34
23
|
delete deps.bloomer;
|
|
35
24
|
removedSource = true;
|
|
36
|
-
note(`removed bloomer from ${name}`);
|
|
25
|
+
manifest.note(`removed bloomer from ${name}`);
|
|
37
26
|
}
|
|
38
27
|
}
|
|
39
28
|
// The transform deliberately RETAINS imports for components with no bestax
|
|
@@ -42,78 +31,14 @@ export const updateDependencies = (filePath, pkg, collector, options) => {
|
|
|
42
31
|
// imports once the user runs the install the report asks for, so say so
|
|
43
32
|
// rather than letting them find out at build time.
|
|
44
33
|
if (removedSource && options.sourceStillImported) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
!section('devDependencies')?.['@allxsmith/bestax-bulma']) {
|
|
56
|
-
dependencies['@allxsmith/bestax-bulma'] = BESTAX_RANGE;
|
|
57
|
-
note(`added @allxsmith/bestax-bulma ${BESTAX_RANGE} to dependencies`);
|
|
58
|
-
}
|
|
59
|
-
// Bulma: bump a pre-1 range; add only when sources still reference bulma/…
|
|
60
|
-
// directly (otherwise it arrives transitively via bestax-bulma).
|
|
61
|
-
let bulmaDeclared = false;
|
|
62
|
-
for (const name of DEP_SECTIONS) {
|
|
63
|
-
const deps = section(name);
|
|
64
|
-
if (deps?.bulma) {
|
|
65
|
-
bulmaDeclared = true;
|
|
66
|
-
if (isPreV1(deps.bulma)) {
|
|
67
|
-
deps.bulma = BULMA_RANGE;
|
|
68
|
-
note(`bumped bulma to ${BULMA_RANGE} in ${name} (was pre-1.0)`);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
if (!bulmaDeclared && options.bulmaReferenced) {
|
|
73
|
-
dependencies.bulma = BULMA_RANGE;
|
|
74
|
-
note(`added bulma ${BULMA_RANGE} to dependencies (sources import bulma/… directly)`);
|
|
75
|
-
}
|
|
76
|
-
// bestax-bulma requires React 18/19; bloomer peer-depended on React ^16.2.
|
|
77
|
-
// Report only — a React major upgrade is the app's own migration step.
|
|
78
|
-
for (const name of DEP_SECTIONS) {
|
|
79
|
-
const range = section(name)?.react;
|
|
80
|
-
if (range && /^[~^]?(?:[0-9]|1[0-7])(?:[.x]|$)/.test(range.trim())) {
|
|
81
|
-
collector?.add({
|
|
82
|
-
file: filePath,
|
|
83
|
-
line: null,
|
|
84
|
-
rule: 'peer-deps',
|
|
85
|
-
message: `react ${range} predates bestax-bulma's peer range (^18 || ^19) — upgrade react and react-dom to 18 or 19 before installing`,
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
// Font Awesome older than 6 conflicts with bestax-bulma's optional peer
|
|
90
|
-
// range and makes `npm install` fail with ERESOLVE. Report only — icon
|
|
91
|
-
// names change across FA majors, so upgrading is the app's decision. (A
|
|
92
|
-
// bloomer-era app more often loads Font Awesome 4 from a CDN <link>, which
|
|
93
|
-
// no manifest pass can see; the Icon conversion flags those in the code.)
|
|
94
|
-
for (const name of DEP_SECTIONS) {
|
|
95
|
-
const range = section(name)?.['@fortawesome/fontawesome-free'];
|
|
96
|
-
if (range && /^[~^]?[0-5](?:[.x]|$)/.test(range.trim())) {
|
|
97
|
-
collector?.add({
|
|
98
|
-
file: filePath,
|
|
99
|
-
line: null,
|
|
100
|
-
rule: 'peer-deps',
|
|
101
|
-
message: `@fortawesome/fontawesome-free ${range} predates bestax-bulma's optional peer range (^6.7.2 || ^7.0.0) — upgrade it, or install with \`npm install --legacy-peer-deps\``,
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
// node-sass is dead; dart-sass replaces it in the same section.
|
|
106
|
-
for (const name of DEP_SECTIONS) {
|
|
107
|
-
const deps = section(name);
|
|
108
|
-
if (deps && 'node-sass' in deps) {
|
|
109
|
-
delete deps['node-sass'];
|
|
110
|
-
note(`removed node-sass from ${name}`);
|
|
111
|
-
const sassDeclared = DEP_SECTIONS.some(s => section(s)?.sass);
|
|
112
|
-
if (!sassDeclared) {
|
|
113
|
-
deps.sass = SASS_RANGE;
|
|
114
|
-
note(`added sass ${SASS_RANGE} to ${name} (replaces node-sass)`);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
return changes.length > 0 ? next : null;
|
|
34
|
+
manifest.report('deps', 'bloomer was removed from package.json, but some files still import it for components with no bestax equivalent — resolve those `TODO(bestax-migrate)` imports before installing, or re-add bloomer until you have');
|
|
35
|
+
}
|
|
36
|
+
addBestax(manifest);
|
|
37
|
+
moveBulmaToV1(manifest, options.bulmaReferenced);
|
|
38
|
+
// bloomer peer-depended on React ^16.2. A bloomer-era app more often loads
|
|
39
|
+
// Font Awesome 4 from a CDN <link>, which no manifest pass can see; the Icon
|
|
40
|
+
// conversion flags those in the code.
|
|
41
|
+
reportPeerRanges(manifest);
|
|
42
|
+
replaceNodeSass(manifest);
|
|
43
|
+
return manifest.result();
|
|
119
44
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../../src/sources/bloomer/transform.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../../src/sources/bloomer/transform.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAgDvD,MAAM,CAAC,OAAO,UAAU,SAAS,CAC/B,QAAQ,EAAE,QAAQ,EAClB,GAAG,EAAE,GAAG,EACR,OAAO,GAAE,gBAAqB,GAC7B,MAAM,GAAG,SAAS,CA8uBpB"}
|