@astryxdesign/cli 0.7.14 → 0.7.15-canary.g79b95eb
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/api/doctor/_adapter.d.mts +1 -0
- package/api/doctor/_adapter.mjs +8 -0
- package/api/doctor/_authoring-audit.d.mts +42 -0
- package/api/doctor/_authoring-audit.mjs +106 -0
- package/api/doctor/doctor.d.mts +7 -0
- package/api/doctor/doctor.mjs +24 -39
- package/api/search/_adapter.mjs +124 -3
- package/api/search/_candidate-score.mjs +63 -9
- package/api/search/_entries.d.mts +10 -0
- package/api/search/_entries.mjs +68 -1
- package/api/search/_gather-templates.d.mts +11 -0
- package/api/search/_gather-templates.mjs +22 -2
- package/api/search/_words.mjs +26 -6
- package/api/swizzle/copy/copy.mjs +1 -1
- package/api/theme/_adapter.mjs +20 -9
- package/api/theme/build/build.d.mts +15 -1
- package/api/theme/build/build.mjs +132 -32
- package/api/theme/targets/targets.d.mts +8 -0
- package/api/theme/targets/targets.mjs +14 -1
- package/api/theme/themeBuild.doc.mjs +6 -3
- package/api/theme/themeEject.doc.mjs +3 -3
- package/api/theme/themeTargets.doc.mjs +1 -1
- package/api/theme-edit/_adapter.d.mts +46 -3
- package/api/theme-edit/_adapter.mjs +372 -109
- package/api/theme-edit/_check.d.mts +6 -3
- package/api/theme-edit/_check.mjs +665 -87
- package/api/theme-edit/_color.mjs +4 -2
- package/api/theme-edit/_compiler.d.mts +2 -1
- package/api/theme-edit/_compiler.mjs +27 -13
- package/api/theme-edit/_context.d.mts +2 -1
- package/api/theme-edit/_context.mjs +47 -8
- package/api/theme-edit/_edit.d.mts +9 -3
- package/api/theme-edit/_edit.mjs +484 -66
- package/api/theme-edit/_how-commands.d.mts +33 -7
- package/api/theme-edit/_how-commands.mjs +57 -45
- package/api/theme-edit/_how-question.d.mts +4 -0
- package/api/theme-edit/_how-question.mjs +1004 -223
- package/api/theme-edit/_how.mjs +96 -9
- package/api/theme-edit/_palette.d.mts +38 -13
- package/api/theme-edit/_palette.mjs +620 -223
- package/api/theme-edit/_parts.mjs +63 -7
- package/api/theme-edit/_png.d.mts +4 -4
- package/api/theme-edit/_png.mjs +4 -2
- package/api/theme-edit/_preview-app.d.mts +6 -0
- package/api/theme-edit/_preview-app.mjs +1194 -207
- package/api/theme-edit/_preview.mjs +2 -2
- package/api/theme-edit/_project.d.mts +12 -1
- package/api/theme-edit/_project.mjs +37 -6
- package/api/theme-edit/_settings.d.mts +104 -33
- package/api/theme-edit/_settings.mjs +818 -118
- package/api/theme-edit/_tables.d.mts +7 -0
- package/api/theme-edit/_tables.mjs +61 -0
- package/api/theme-edit/theme-edit.type.d.mts +11 -1
- package/api/theme-edit/theme-edit.type.mjs +4 -3
- package/api/theme-edit/themeEditHow.doc.mjs +6 -0
- package/api/theme-edit/themeEditPreviewAdd.doc.mjs +1 -1
- package/api/theme-edit/themeEditPreviewApp.doc.mjs +1 -1
- package/api/theme-edit/themeEditPreviewList.doc.mjs +1 -1
- package/api/theme-edit/themeEditPreviewRemove.doc.mjs +5 -1
- package/api/theme-edit/themeEditUndo.doc.mjs +1 -1
- package/api/upgrade/_adapter.d.mts +1 -0
- package/assets/codemods/run-codemod.mjs +61 -0
- package/assets/codemods/runner.mjs +5 -4
- package/assets/codemods/transforms/v0.0.14/rename-status-variants.mjs +3 -0
- package/assets/codemods/transforms/v0.1.8/rename-avatar-size-scale.mjs +5 -1
- package/assets/codemods/transforms/v0.6.4/migrate-native-picker-to-presentation.mjs +3 -0
- package/assets/codemods/transforms/v0.7.0/migrate-deprecated-theme-surface.mjs +4 -0
- package/assets/codemods/transforms/v0.7.0/rename-empty-search-results-text.mjs +17 -12
- package/assets/codemods/transforms/v0.7.2/migrate-list-edge-compensation-to-edge.mjs +3 -0
- package/assets/codemods/transforms/v0.7.5/migrate-codeblock-tokenizer-to-language.mjs +3 -0
- package/assets/codemods/transforms/v0.7.8/promote-tokenizer-presentation.mjs +3 -0
- package/assets/docs/tree/calendars.doc.mjs +1 -3
- package/assets/docs.generated.json +2 -1
- package/assets/self-audit.generated.json +1 -0
- package/assets/templates/blocks/components/Theme/useThemeNameHookUsage.doc.mjs +14 -0
- package/assets/templates/blocks/components/Theme/useThemeNameHookUsage.tsx +31 -0
- package/assets/templates/components.generated.json +1 -1
- package/clients/cli/bin/astryx.mjs +19 -15
- package/clients/cli/build-id.generated.json +1 -0
- package/clients/cli/commands/ensure-core-built.mjs +12 -5
- package/clients/cli/commands/experimental/theme.mjs +178 -78
- package/clients/cli/commands/experimental-theme-compile.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-editor-how.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +1 -2
- package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-editor.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-eject.doc.mjs +3 -3
- package/clients/cli/commands/experimental-theme-preview-add.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-preview-app.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-preview-list.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-preview-remove.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-remove.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-template.doc.mjs +4 -3
- package/clients/cli/commands/manifest.mjs +5 -2
- package/clients/cli/commands/theme.mjs +118 -22
- package/clients/cli/index.mjs +9 -3
- package/clients/cli/lib/manifest.mjs +37 -0
- package/clients/cli/lib/resolve-theme.mjs +2 -1
- package/clients/cli/manifest.generated.json +1 -0
- package/foundation/discovery/module-exports.mjs +16 -2
- package/foundation/discovery/stored-self-audit.d.mts +31 -0
- package/foundation/discovery/stored-self-audit.mjs +119 -0
- package/foundation/discovery/template-adapter.d.mts +48 -2
- package/foundation/discovery/template-adapter.mjs +51 -19
- package/foundation/discovery/template-needs.d.mts +6 -0
- package/foundation/discovery/template-needs.mjs +20 -1
- package/foundation/discovery/template-source-tree.d.mts +7 -0
- package/foundation/discovery/template-source-tree.mjs +15 -0
- package/foundation/discovery/theme-discovery.d.mts +2 -1
- package/foundation/discovery/theme-discovery.mjs +2 -8
- package/foundation/discovery/theme-module-extensions.d.mts +18 -0
- package/foundation/discovery/theme-module-extensions.mjs +30 -0
- package/foundation/doc-compiler/import.mjs +12 -11
- package/foundation/doc-compiler/stored-docs.d.mts +18 -12
- package/foundation/doc-compiler/stored-docs.mjs +52 -19
- package/foundation/env/private-dir.d.mts +17 -0
- package/foundation/env/private-dir.mjs +42 -0
- package/foundation/fs/gather-cache.d.mts +108 -0
- package/foundation/fs/gather-cache.mjs +716 -0
- package/foundation/fs/module-loader.mjs +7 -1
- package/foundation/fs/read-record.d.mts +31 -1
- package/foundation/fs/read-record.mjs +93 -6
- package/foundation/integrations/validate-contributions.mjs +24 -11
- package/foundation/release/cache.d.mts +11 -2
- package/foundation/release/cache.mjs +59 -10
- package/foundation/release/folder-lock.d.mts +21 -0
- package/foundation/release/folder-lock.mjs +171 -0
- package/package.json +8 -6
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
* @position api/theme-edit — checks over the part data
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
+
import {createRequire} from 'node:module';
|
|
12
13
|
import {ERROR_CODES} from '../../foundation/response/error-codes.mjs';
|
|
13
14
|
import {levenshteinDistance} from '../../foundation/text/levenshtein.mjs';
|
|
14
15
|
import {CSS_PROPERTIES} from './_css-properties.mjs';
|
|
@@ -26,6 +27,7 @@ import {
|
|
|
26
27
|
LIKE,
|
|
27
28
|
HOW,
|
|
28
29
|
OPEN_FONTS,
|
|
30
|
+
CSS_WIDE_KEYWORDS,
|
|
29
31
|
P,
|
|
30
32
|
SPACING,
|
|
31
33
|
TEXT_SIZE,
|
|
@@ -55,9 +57,33 @@ import {
|
|
|
55
57
|
nearest,
|
|
56
58
|
partDefault,
|
|
57
59
|
partsOf,
|
|
58
|
-
q,
|
|
59
60
|
refuse,
|
|
61
|
+
lengthPx,
|
|
62
|
+
radiusAt,
|
|
60
63
|
} from './_settings.mjs';
|
|
64
|
+
import {quoteCommandArgument} from '../../foundation/env/package-manager.mjs';
|
|
65
|
+
|
|
66
|
+
export {lengthPx};
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* A token's value in px, following var() references through the tokens.
|
|
70
|
+
* @param {{light: Record<string, string>}} base
|
|
71
|
+
* @param {string} token
|
|
72
|
+
* @returns {number | null}
|
|
73
|
+
*/
|
|
74
|
+
function tokenPx(base, token) {
|
|
75
|
+
let v = base.light[token] ?? '';
|
|
76
|
+
for (let i = 0; i < 5; i++) {
|
|
77
|
+
const ref = /^\s*var\((--[\w-]+)\)\s*$/.exec(v);
|
|
78
|
+
if (!ref) break;
|
|
79
|
+
v = base.light[ref[1]] ?? '';
|
|
80
|
+
}
|
|
81
|
+
return lengthPx(v);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** @param {string} v */
|
|
85
|
+
const cornerPxOf = v =>
|
|
86
|
+
CORNERS.find(([n]) => n === v)?.[1] ?? lengthPx(v) ?? Number.NaN;
|
|
61
87
|
|
|
62
88
|
const E = ERROR_CODES;
|
|
63
89
|
|
|
@@ -131,10 +157,50 @@ const COLOR_DIAL_WORDS = (() => {
|
|
|
131
157
|
* @param {string} slug
|
|
132
158
|
* @param {import('./_settings.mjs').ThemeData} data
|
|
133
159
|
* @param {string} [skip]
|
|
134
|
-
* @returns {{setting: import('./_settings.mjs').Setting, why: string}
|
|
160
|
+
* @returns {Array<{setting: import('./_settings.mjs').Setting, why: string, scope?: boolean}>} every saved setting the editor no longer accepts
|
|
135
161
|
*/
|
|
136
|
-
export function
|
|
162
|
+
export function storedProblems(ctx, slug, data, skip = '') {
|
|
163
|
+
/** @type {Array<{setting: import('./_settings.mjs').Setting, why: string, scope?: boolean}>} */
|
|
164
|
+
const found = [];
|
|
137
165
|
const TOKENS = ctx.project.core.tokenDefaults;
|
|
166
|
+
// Where each saved setting applies names a real part, group, state and
|
|
167
|
+
// variant of this Core, as `set` checks them.
|
|
168
|
+
const WHOLE_ONLY = [
|
|
169
|
+
'surfaces',
|
|
170
|
+
'buttons',
|
|
171
|
+
'base',
|
|
172
|
+
'mode',
|
|
173
|
+
'vibrancy',
|
|
174
|
+
'text-size',
|
|
175
|
+
'headings',
|
|
176
|
+
'type',
|
|
177
|
+
...PALETTE_DIALS,
|
|
178
|
+
];
|
|
179
|
+
for (const s of data.settings) {
|
|
180
|
+
if (s.thing === skip) continue;
|
|
181
|
+
/** @param {string} why */
|
|
182
|
+
const scope = why => ({setting: s, why, scope: true});
|
|
183
|
+
const problem = (() => {
|
|
184
|
+
const t = s.on ? ctx.project.target.get(s.on) : null;
|
|
185
|
+
if (s.on && !t && !FAMILIES[s.on])
|
|
186
|
+
return scope(`there is no part or group "${s.on}"`);
|
|
187
|
+
if (s.source === 'dial' && s.on && WHOLE_ONLY.includes(s.thing))
|
|
188
|
+
return scope(`${s.thing} applies to the whole theme, not to ${s.on}`);
|
|
189
|
+
if (s.mode && s.source === 'dial' && !PALETTE_DIALS.includes(s.thing))
|
|
190
|
+
return scope(`${s.thing} is the same in light and dark`);
|
|
191
|
+
if (t && s.state && ![...t.states, ...COMMON_STATES].includes(s.state))
|
|
192
|
+
return scope(`"${s.state}" is not a state of ${s.on}`);
|
|
193
|
+
if (t && s.when) {
|
|
194
|
+
const [prop, value] = String(s.when).split(':');
|
|
195
|
+
const values = ctx.C.variantValues(/** @type {string} */ (s.on));
|
|
196
|
+
if (!(prop in values)) return scope(`${s.on} has no prop "${prop}"`);
|
|
197
|
+
if (values[prop].length && !values[prop].includes(value))
|
|
198
|
+
return scope(`${s.on} has no ${prop} "${value}"`);
|
|
199
|
+
}
|
|
200
|
+
return null;
|
|
201
|
+
})();
|
|
202
|
+
if (problem) found.push(problem);
|
|
203
|
+
}
|
|
138
204
|
for (const s of data.settings) {
|
|
139
205
|
if (s.source !== 'token' || s.thing === skip || !(s.thing in TOKENS))
|
|
140
206
|
continue;
|
|
@@ -149,16 +215,16 @@ export function storedTokenProblem(ctx, slug, data, skip = '') {
|
|
|
149
215
|
);
|
|
150
216
|
checkCycle(s.thing, s.value, TOKENS, data);
|
|
151
217
|
} catch (e) {
|
|
152
|
-
|
|
218
|
+
found.push({
|
|
153
219
|
setting: s,
|
|
154
220
|
why:
|
|
155
221
|
e instanceof Error
|
|
156
222
|
? e.message.replace(/ Nothing was changed\.$/, '')
|
|
157
223
|
: String(e),
|
|
158
|
-
};
|
|
224
|
+
});
|
|
159
225
|
}
|
|
160
226
|
}
|
|
161
|
-
return
|
|
227
|
+
return found;
|
|
162
228
|
}
|
|
163
229
|
|
|
164
230
|
/**
|
|
@@ -205,13 +271,17 @@ function checkTypedValue(type, value, name, TOKENS, typeOf, slug) {
|
|
|
205
271
|
refuse(
|
|
206
272
|
E.ERR_THEME_BAD_VALUE,
|
|
207
273
|
`${name} is ${what}; "${value}" is not one.`,
|
|
208
|
-
{run: [`${P} set ${slug} ${name} ${
|
|
274
|
+
{run: [`${P} set ${slug} ${name} ${quoteCommandArgument(example)}`]},
|
|
209
275
|
);
|
|
210
276
|
if (!isSafeValue(value))
|
|
211
277
|
refuse(
|
|
212
278
|
E.ERR_THEME_BAD_VALUE,
|
|
213
279
|
`"${value}" cannot be a CSS value: it has a ; { } < > or a newline, a comment, !important, or an unclosed bracket or quote.`,
|
|
214
|
-
{
|
|
280
|
+
{
|
|
281
|
+
run: [
|
|
282
|
+
`${P} set ${slug} ${name} ${quoteCommandArgument(exampleOf(type, name))}`,
|
|
283
|
+
],
|
|
284
|
+
},
|
|
215
285
|
);
|
|
216
286
|
// A var() naming a design token must name one of the same kind; the
|
|
217
287
|
// app's own variables are its business.
|
|
@@ -494,6 +564,162 @@ function checkCycle(thing, value, TOKENS, data) {
|
|
|
494
564
|
);
|
|
495
565
|
}
|
|
496
566
|
|
|
567
|
+
const require = createRequire(import.meta.url);
|
|
568
|
+
/** @type {any} */
|
|
569
|
+
let tree = null;
|
|
570
|
+
/** css-tree, loaded on first use. */
|
|
571
|
+
const csstree = () => (tree ??= require('css-tree'));
|
|
572
|
+
|
|
573
|
+
/** What a var() or env() may stand for while the rest of a value is matched. */
|
|
574
|
+
const VAR_STANDS_FOR = ['0', '1px', '1ms', 'red', 'ease', 'serif', '0 0 red'];
|
|
575
|
+
|
|
576
|
+
/**
|
|
577
|
+
* Whether a value matches a property's grammar as css-tree reads it (the
|
|
578
|
+
* browser's grammar, from MDN's data). A var() or env() can hold anything,
|
|
579
|
+
* so the value matches when some ordinary value in its place does.
|
|
580
|
+
* @param {string} prop
|
|
581
|
+
* @param {string} value
|
|
582
|
+
*/
|
|
583
|
+
function matchesProperty(prop, value) {
|
|
584
|
+
const {lexer, parse} = csstree();
|
|
585
|
+
const vars =
|
|
586
|
+
value.match(/(?:var|env)\([^()]*(?:\([^()]*\)[^()]*)*\)/gi) ?? [];
|
|
587
|
+
/** @param {string} v */
|
|
588
|
+
const tryOne = v => {
|
|
589
|
+
try {
|
|
590
|
+
return !lexer.matchProperty(prop, parse(v, {context: 'value'})).error;
|
|
591
|
+
} catch {
|
|
592
|
+
return false;
|
|
593
|
+
}
|
|
594
|
+
};
|
|
595
|
+
if (vars.length > 3) return false;
|
|
596
|
+
/** @param {string} v @param {number} i @returns {boolean} */
|
|
597
|
+
const fill = (v, i) =>
|
|
598
|
+
i === vars.length
|
|
599
|
+
? tryOne(v)
|
|
600
|
+
: VAR_STANDS_FOR.some(stand => fill(v.replace(vars[i], stand), i + 1));
|
|
601
|
+
return fill(value, 0);
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
/**
|
|
605
|
+
* The keywords a property's grammar takes, through the types it names.
|
|
606
|
+
* @param {string} prop
|
|
607
|
+
* @returns {string[]}
|
|
608
|
+
*/
|
|
609
|
+
function keywordsOf(prop) {
|
|
610
|
+
const t = csstree();
|
|
611
|
+
const seen = new Set();
|
|
612
|
+
/** @type {Set<string>} */
|
|
613
|
+
const words = new Set();
|
|
614
|
+
/** @param {any} syntax */
|
|
615
|
+
const walk = syntax => {
|
|
616
|
+
if (!syntax) return;
|
|
617
|
+
t.definitionSyntax.walk(syntax, (/** @type {any} */ n) => {
|
|
618
|
+
if (n.type === 'Keyword') {
|
|
619
|
+
if (!n.name.startsWith('-')) words.add(n.name);
|
|
620
|
+
} else if (n.type === 'Type' && !seen.has(n.name)) {
|
|
621
|
+
seen.add(n.name);
|
|
622
|
+
walk(t.lexer.types[n.name]?.syntax);
|
|
623
|
+
}
|
|
624
|
+
});
|
|
625
|
+
};
|
|
626
|
+
walk(t.lexer.properties[prop]?.syntax);
|
|
627
|
+
return [...words];
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
/**
|
|
631
|
+
* A value the property takes, to put in a suggestion: its initial value
|
|
632
|
+
* from MDN's data (a shorthand's first longhand's).
|
|
633
|
+
* @param {string} prop
|
|
634
|
+
* @returns {string | null}
|
|
635
|
+
*/
|
|
636
|
+
function initialOf(prop) {
|
|
637
|
+
const mdn = /** @type {Record<string, {initial?: string | string[]}>} */ (
|
|
638
|
+
createRequire(require.resolve('css-tree/package.json'))(
|
|
639
|
+
'mdn-data/css/properties.json',
|
|
640
|
+
)
|
|
641
|
+
);
|
|
642
|
+
const initial = mdn[prop]?.initial;
|
|
643
|
+
if (Array.isArray(initial)) return initial[0] ? initialOf(initial[0]) : null;
|
|
644
|
+
return typeof initial === 'string' && matchesProperty(prop, initial)
|
|
645
|
+
? initial
|
|
646
|
+
: null;
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
/**
|
|
650
|
+
* A property's grammar as text, cut at a whole term when it is long.
|
|
651
|
+
* @param {any} syntax
|
|
652
|
+
*/
|
|
653
|
+
function grammarText(syntax) {
|
|
654
|
+
const text = csstree().definitionSyntax.generate(syntax);
|
|
655
|
+
if (text.length <= 120) return text;
|
|
656
|
+
return `${text.slice(0, 120).replace(/\s*\|[^|]*$/, '')} | …`;
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
/**
|
|
660
|
+
* Why a value is not one the property takes, or null. Colors are checked
|
|
661
|
+
* by the editor's own color check; a property css-tree has no grammar for
|
|
662
|
+
* is not checked.
|
|
663
|
+
* @param {string} prop
|
|
664
|
+
* @param {string} value
|
|
665
|
+
* @returns {{takes: string, near: string | null} | null}
|
|
666
|
+
*/
|
|
667
|
+
function propertyProblem(prop, value) {
|
|
668
|
+
const v = value.trim();
|
|
669
|
+
const known = csstree().lexer.properties[prop];
|
|
670
|
+
if (!known || COLOR_PROPS.test(prop) || matchesProperty(prop, v)) return null;
|
|
671
|
+
const near = /^[a-z-]+$/i.test(v)
|
|
672
|
+
? (nearest(v.toLowerCase(), keywordsOf(prop))[0] ?? null)
|
|
673
|
+
: null;
|
|
674
|
+
return {
|
|
675
|
+
takes: `a value its CSS grammar takes (${grammarText(known.syntax)})`,
|
|
676
|
+
near: near ?? initialOf(prop),
|
|
677
|
+
};
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
/** Words people use for a dial's values, by dial. */
|
|
681
|
+
const DIAL_WORDS = /** @type {Record<string, Record<string, string>>} */ ({
|
|
682
|
+
surfaces: {
|
|
683
|
+
elevated: 'raised',
|
|
684
|
+
elevation: 'raised',
|
|
685
|
+
shadow: 'raised',
|
|
686
|
+
shadows: 'raised',
|
|
687
|
+
lifted: 'raised',
|
|
688
|
+
frosted: 'glass',
|
|
689
|
+
blur: 'glass',
|
|
690
|
+
blurred: 'glass',
|
|
691
|
+
translucent: 'glass',
|
|
692
|
+
bordered: 'outlined',
|
|
693
|
+
border: 'outlined',
|
|
694
|
+
borders: 'outlined',
|
|
695
|
+
lined: 'outlined',
|
|
696
|
+
outline: 'outlined',
|
|
697
|
+
plain: 'flat',
|
|
698
|
+
minimal: 'flat',
|
|
699
|
+
},
|
|
700
|
+
buttons: {
|
|
701
|
+
uppercase: 'caps',
|
|
702
|
+
upper: 'caps',
|
|
703
|
+
allcaps: 'caps',
|
|
704
|
+
capitals: 'caps',
|
|
705
|
+
tint: 'soft',
|
|
706
|
+
tinted: 'soft',
|
|
707
|
+
subtle: 'soft',
|
|
708
|
+
outlined: 'outline',
|
|
709
|
+
bordered: 'outline',
|
|
710
|
+
ghost: 'outline',
|
|
711
|
+
filled: 'solid',
|
|
712
|
+
fill: 'solid',
|
|
713
|
+
},
|
|
714
|
+
mode: {
|
|
715
|
+
auto: 'both',
|
|
716
|
+
system: 'both',
|
|
717
|
+
default: 'both',
|
|
718
|
+
light: 'light-only',
|
|
719
|
+
dark: 'dark-only',
|
|
720
|
+
},
|
|
721
|
+
});
|
|
722
|
+
|
|
497
723
|
/**
|
|
498
724
|
* Check one setting and give it back ready to store, or refuse.
|
|
499
725
|
* @param {import('./_settings.mjs').Ctx} ctx
|
|
@@ -529,7 +755,7 @@ export function checkSetting(
|
|
|
529
755
|
`Give the token and its value as two words: ${name} ${rest.join('=')}.`,
|
|
530
756
|
{
|
|
531
757
|
run: [
|
|
532
|
-
`${P} ${unset ? 'undo' : 'set'} ${slug} ${name}${unset ? '' : ` ${
|
|
758
|
+
`${P} ${unset ? 'undo' : 'set'} ${slug} ${name}${unset ? '' : ` ${quoteCommandArgument(rest.join('='))}`}`,
|
|
533
759
|
],
|
|
534
760
|
},
|
|
535
761
|
);
|
|
@@ -545,7 +771,8 @@ export function checkSetting(
|
|
|
545
771
|
refuse(E.ERR_MISSING_ARGUMENT, `--${k} was given no value.`, {
|
|
546
772
|
run: [`${P} ${unset ? 'undo' : 'set'} --help`],
|
|
547
773
|
});
|
|
548
|
-
|
|
774
|
+
// A value pasted over several lines is one value.
|
|
775
|
+
const v = (value ?? '').replace(/\s*[\r\n]+\s*/g, ' ').trim();
|
|
549
776
|
// A var() that misspells a design token would read nothing.
|
|
550
777
|
if (!unset)
|
|
551
778
|
for (const [, name] of v.matchAll(/var\(\s*(--[a-z0-9-]+)/gi)) {
|
|
@@ -574,6 +801,16 @@ export function checkSetting(
|
|
|
574
801
|
);
|
|
575
802
|
/** @type {import('./_settings.mjs').Setting} */
|
|
576
803
|
const s = {thing, value: v, source: 'dial'};
|
|
804
|
+
// A flag given only spaces names nothing; it is never read as absent.
|
|
805
|
+
for (const k of /** @type {const} */ (['on', 'when', 'state', 'mode']))
|
|
806
|
+
if (typeof flags[k] === 'string' && flags[k].trim() === '')
|
|
807
|
+
refuse(E.ERR_MISSING_ARGUMENT, `--${k} is empty.`, {
|
|
808
|
+
run: [
|
|
809
|
+
k === 'mode'
|
|
810
|
+
? `${P} set ${slug} ${thing} ${quoteCommandArgument(v || '#1f2937')}`
|
|
811
|
+
: `${HOW} --list parts`,
|
|
812
|
+
],
|
|
813
|
+
});
|
|
577
814
|
if (flags.on) s.on = flags.on.trim();
|
|
578
815
|
if (flags.when) s.when = flags.when.trim();
|
|
579
816
|
if (flags.state) s.state = flags.state.trim();
|
|
@@ -594,7 +831,7 @@ export function checkSetting(
|
|
|
594
831
|
refuse(
|
|
595
832
|
E.ERR_THEME_NO_MODE,
|
|
596
833
|
`This theme is ${data.mode}; --mode is for themes with both modes.`,
|
|
597
|
-
{run: [`${P} set ${slug} ${thing} ${
|
|
834
|
+
{run: [`${P} set ${slug} ${thing} ${quoteCommandArgument(v)}${onFlag}`]},
|
|
598
835
|
);
|
|
599
836
|
if ((s.when || s.state) && !s.on)
|
|
600
837
|
refuse(E.ERR_MISSING_ARGUMENT, '--when and --state need --on <part>.', {
|
|
@@ -615,8 +852,8 @@ export function checkSetting(
|
|
|
615
852
|
{
|
|
616
853
|
run: [
|
|
617
854
|
unset
|
|
618
|
-
? `${P} undo ${slug} ${thing}${v ? ` ${
|
|
619
|
-
: `${P} set ${slug} ${thing} ${
|
|
855
|
+
? `${P} undo ${slug} ${thing}${v ? ` ${quoteCommandArgument(v)}` : ''} --on ${s.on}`
|
|
856
|
+
: `${P} set ${slug} ${thing} ${quoteCommandArgument(v)} --on ${s.on}`,
|
|
620
857
|
],
|
|
621
858
|
},
|
|
622
859
|
);
|
|
@@ -626,17 +863,31 @@ export function checkSetting(
|
|
|
626
863
|
if (s.on && !isRole && !FAMILIES[s.on]) {
|
|
627
864
|
const t = TARGET.get(s.on);
|
|
628
865
|
if (!t) {
|
|
866
|
+
// Another case of a part or group: that one, as a working command.
|
|
867
|
+
const lower = s.on.toLowerCase();
|
|
868
|
+
if (TARGET.has(lower) || FAMILIES[lower])
|
|
869
|
+
refuse(
|
|
870
|
+
E.ERR_THEME_UNKNOWN_PART,
|
|
871
|
+
`"${s.on}" is not a part you can style; part names are lower case: ${lower}.`,
|
|
872
|
+
{
|
|
873
|
+
didYouMean: [lower],
|
|
874
|
+
run: [
|
|
875
|
+
`${P} ${unset ? 'undo' : 'set'} ${slug} ${thing}${v ? ` ${quoteCommandArgument(v)}` : ''} --on ${lower}${s.when ? ` --when ${s.when}` : ''}${s.state ? ` --state ${s.state}` : ''}${s.mode ? ` --mode ${s.mode}` : ''}`,
|
|
876
|
+
],
|
|
877
|
+
},
|
|
878
|
+
);
|
|
629
879
|
refuse(
|
|
630
880
|
E.ERR_THEME_UNKNOWN_PART,
|
|
631
881
|
`"${s.on}" is not a part you can style.`,
|
|
632
882
|
{
|
|
633
|
-
|
|
883
|
+
// A plural or another case names the part it means.
|
|
884
|
+
didYouMean: nearest(s.on.toLowerCase().replace(/s$/, ''), [
|
|
634
885
|
...TARGET.keys(),
|
|
635
886
|
...Object.keys(FAMILIES),
|
|
636
887
|
]),
|
|
637
888
|
run: [
|
|
638
|
-
`${HOW} --list parts ${s.on.split('-')[0]}`,
|
|
639
|
-
`${HOW} ${
|
|
889
|
+
`${HOW} --list parts ${s.on.toLowerCase().replace(/s$/, '').split('-')[0]}`,
|
|
890
|
+
`${HOW} ${quoteCommandArgument(s.on)}`,
|
|
640
891
|
],
|
|
641
892
|
},
|
|
642
893
|
);
|
|
@@ -712,7 +963,7 @@ export function checkSetting(
|
|
|
712
963
|
`${thing} moves every part it covers; drop --on. For one part, set CSS properties --on <part>.`,
|
|
713
964
|
{
|
|
714
965
|
run: [
|
|
715
|
-
`${P} set ${slug} ${thing} ${
|
|
966
|
+
`${P} set ${slug} ${thing} ${quoteCommandArgument(v || DIALS[thing].values.split('|')[0])}`,
|
|
716
967
|
],
|
|
717
968
|
},
|
|
718
969
|
);
|
|
@@ -720,19 +971,27 @@ export function checkSetting(
|
|
|
720
971
|
refuse(
|
|
721
972
|
E.ERR_THEME_NO_MODE,
|
|
722
973
|
`${thing} is the same in light and dark; drop --mode.`,
|
|
723
|
-
{run: [`${P} set ${slug} ${thing} ${
|
|
974
|
+
{run: [`${P} set ${slug} ${thing} ${quoteCommandArgument(v)}`]},
|
|
724
975
|
);
|
|
725
976
|
if (unset) return s;
|
|
726
977
|
const ok = DIALS[thing].values.split('|');
|
|
727
978
|
const lower = v.toLowerCase();
|
|
728
979
|
if (!ok.includes(v)) {
|
|
729
|
-
|
|
980
|
+
// A word that means one of the values names it; a word close in
|
|
981
|
+
// spelling only, the nearest; anything else, no guess (never the
|
|
982
|
+
// first value, which may be the opposite).
|
|
983
|
+
const meant = DIAL_WORDS[thing]?.[lower];
|
|
984
|
+
const near = ok.includes(lower)
|
|
985
|
+
? [lower]
|
|
986
|
+
: meant
|
|
987
|
+
? [meant]
|
|
988
|
+
: nearest(lower, ok);
|
|
730
989
|
refuse(
|
|
731
990
|
E.ERR_THEME_BAD_VALUE,
|
|
732
991
|
`${thing} takes ${DIALS[thing].values}, not "${v}".`,
|
|
733
992
|
{
|
|
734
993
|
didYouMean: near,
|
|
735
|
-
run: [`${P} set ${slug} ${thing} ${near[0]
|
|
994
|
+
run: near[0] ? [`${P} set ${slug} ${thing} ${near[0]}`] : [],
|
|
736
995
|
},
|
|
737
996
|
);
|
|
738
997
|
}
|
|
@@ -755,7 +1014,7 @@ export function checkSetting(
|
|
|
755
1014
|
'headings is the same in light and dark; drop --mode.',
|
|
756
1015
|
{
|
|
757
1016
|
run: [
|
|
758
|
-
`${P} ${unset ? 'undo' : 'set'} ${slug} headings${v ? ` ${
|
|
1017
|
+
`${P} ${unset ? 'undo' : 'set'} ${slug} headings${v ? ` ${quoteCommandArgument(v)}` : ''}`,
|
|
759
1018
|
],
|
|
760
1019
|
},
|
|
761
1020
|
);
|
|
@@ -788,28 +1047,48 @@ export function checkSetting(
|
|
|
788
1047
|
return s;
|
|
789
1048
|
}
|
|
790
1049
|
if (unset) return s;
|
|
791
|
-
/** @param {Array<[string, number]>} L @param {string} def */
|
|
1050
|
+
/** @param {Array<[string, number]>} L @param {string | number} def */
|
|
792
1051
|
const ladder = (L, def) => {
|
|
793
1052
|
// The value in effect for the target: its own setting, else the
|
|
794
1053
|
// whole-theme one, else the starting point.
|
|
1054
|
+
// Same target: the part, and the same variant and state.
|
|
795
1055
|
const own = (/** @type {string} */ on) =>
|
|
796
|
-
[...data.settings]
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
1056
|
+
[...data.settings].reverse().find(
|
|
1057
|
+
x =>
|
|
1058
|
+
x.thing === thing &&
|
|
1059
|
+
(x.on ?? '') === on &&
|
|
1060
|
+
(x.when ?? '') === (on ? (s.when ?? '') : '') &&
|
|
1061
|
+
(x.state ?? '') === (on ? (s.state ?? '') : '') &&
|
|
1062
|
+
// A member set alone (--only) is not the member as the group
|
|
1063
|
+
// spreads it.
|
|
1064
|
+
Boolean(x.only) === (on === s.on ? Boolean(s.only) : false),
|
|
1065
|
+
)?.value;
|
|
1066
|
+
// A member of a group set on the group steps from the group's value.
|
|
1067
|
+
const fam = s.on ? familyOf(s.on) : null;
|
|
1068
|
+
const cur =
|
|
1069
|
+
own(s.on ?? '') ??
|
|
1070
|
+
(fam && fam !== s.on && !s.only ? own(fam) : undefined) ??
|
|
1071
|
+
// A part's own radius (a number) already counts a whole-theme
|
|
1072
|
+
// setting.
|
|
1073
|
+
(s.on && typeof def !== 'number' ? own('') : undefined) ??
|
|
1074
|
+
def;
|
|
1075
|
+
const at = L.findIndex(([n]) => n === cur);
|
|
1076
|
+
if (at >= 0)
|
|
1077
|
+
return L[
|
|
1078
|
+
Math.max(0, Math.min(L.length - 1, at + (v === 'more' ? 1 : -1)))
|
|
1079
|
+
][0];
|
|
1080
|
+
// A size between rungs steps to the next rung that way, never past it.
|
|
1081
|
+
const px = typeof cur === 'number' ? cur : (lengthPx(cur) ?? Number.NaN);
|
|
1082
|
+
if (Number.isNaN(px)) return L[0][0];
|
|
1083
|
+
const next =
|
|
1084
|
+
v === 'more'
|
|
1085
|
+
? L.find(([, n]) => n > px + 0.01)
|
|
1086
|
+
: [...L].reverse().find(([, n]) => n < px - 0.01);
|
|
1087
|
+
return (next ?? (v === 'more' ? L[L.length - 1] : L[0]))[0];
|
|
809
1088
|
};
|
|
810
1089
|
if (PALETTE_DIALS.includes(thing) && (s.on || s.mode)) {
|
|
811
1090
|
const token = paletteToken(thing);
|
|
812
|
-
const value =
|
|
1091
|
+
const value = quoteCommandArgument(v || '#7c3aed');
|
|
813
1092
|
/** @type {string[]} */
|
|
814
1093
|
let run = [
|
|
815
1094
|
`${P} set ${slug} ${token} ${value}${onFlag}${s.mode ? ` --mode ${s.mode}` : ''}`,
|
|
@@ -845,32 +1124,146 @@ export function checkSetting(
|
|
|
845
1124
|
refuse(
|
|
846
1125
|
E.ERR_THEME_NO_MODE,
|
|
847
1126
|
`${thing} is not a color, so it is the same in light and dark; drop --mode.`,
|
|
848
|
-
{
|
|
1127
|
+
{
|
|
1128
|
+
run: [
|
|
1129
|
+
`${P} set ${slug} ${thing} ${quoteCommandArgument(v)}${onFlag}`,
|
|
1130
|
+
],
|
|
1131
|
+
},
|
|
849
1132
|
);
|
|
850
1133
|
if (thing === 'corners') {
|
|
851
1134
|
if (s.on) refuseInvisibleCorners(ctx, slug, s, data);
|
|
852
1135
|
// With no corners setting yet, a step starts from the base theme's
|
|
853
1136
|
// own radius.
|
|
854
1137
|
if (step) {
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
:
|
|
861
|
-
|
|
862
|
-
|
|
1138
|
+
// A step moves to the next rung the part SHOWS bigger or smaller:
|
|
1139
|
+
// each rung is measured as the build writes it for the radius token
|
|
1140
|
+
// the part reads (a card reads the container radius), and so is
|
|
1141
|
+
// what the part shows now.
|
|
1142
|
+
const base = ctx.base ?? {
|
|
1143
|
+
light: /** @type {Record<string, string>} */ ({}),
|
|
1144
|
+
dark: /** @type {Record<string, string>} */ ({}),
|
|
1145
|
+
};
|
|
1146
|
+
const token =
|
|
1147
|
+
(s.on
|
|
1148
|
+
? /^var\((--radius-[\w-]+)\)$/.exec(
|
|
1149
|
+
partDefault(
|
|
1150
|
+
ctx,
|
|
1151
|
+
partsOf(ctx, s)[0] ?? s.on,
|
|
1152
|
+
'borderRadius',
|
|
1153
|
+
s.when,
|
|
1154
|
+
) ?? '',
|
|
1155
|
+
)?.[1]
|
|
1156
|
+
: null) ?? '--radius-element';
|
|
1157
|
+
// What the part shows: a setting on it or on its group (the later
|
|
1158
|
+
// one wins), else a whole-theme setting, else the base theme.
|
|
1159
|
+
const fam = s.on ? familyOf(s.on) : null;
|
|
1160
|
+
const onPart = s.on
|
|
1161
|
+
? [...data.settings].reverse().find(
|
|
1162
|
+
x =>
|
|
1163
|
+
x.thing === 'corners' &&
|
|
1164
|
+
(x.when ?? '') === (s.when ?? '') &&
|
|
1165
|
+
(x.state ?? '') === (s.state ?? '') &&
|
|
1166
|
+
// A member set alone shows that value too.
|
|
1167
|
+
(x.on === s.on ||
|
|
1168
|
+
(fam && fam !== s.on && x.on === fam && !x.only)),
|
|
1169
|
+
)
|
|
1170
|
+
: undefined;
|
|
1171
|
+
// A step on a member set alone stays on that member alone.
|
|
1172
|
+
if (onPart && onPart.on === s.on && onPart.only && !s.only)
|
|
1173
|
+
s.only = true;
|
|
1174
|
+
const whole = [...data.settings]
|
|
1175
|
+
.reverse()
|
|
1176
|
+
.find(x => x.thing === 'corners' && !x.on);
|
|
1177
|
+
const isRung = (/** @type {string} */ x) =>
|
|
1178
|
+
CORNERS.some(([n]) => n === x);
|
|
1179
|
+
const shown = onPart
|
|
1180
|
+
? isRung(onPart.value) || cornerPxOf(onPart.value) >= 1000
|
|
1181
|
+
? radiusAt(base, onPart.value, token)
|
|
1182
|
+
: cornerPxOf(onPart.value)
|
|
1183
|
+
: whole
|
|
1184
|
+
? radiusAt(base, whole.value, token)
|
|
1185
|
+
: // The base theme's radius; one it does not give in px (a var()
|
|
1186
|
+
// chain) counts as medium's.
|
|
1187
|
+
(tokenPx(base, token) ?? radiusAt(base, 'medium', token));
|
|
1188
|
+
const rungs = CORNERS.map(
|
|
1189
|
+
([n]) => /** @type {const} */ ([n, radiusAt(base, n, token)]),
|
|
1190
|
+
);
|
|
1191
|
+
const next =
|
|
1192
|
+
v === 'more'
|
|
1193
|
+
? rungs.find(([, n]) => n > shown + 0.01)
|
|
1194
|
+
: [...rungs].reverse().find(([, n]) => n < shown - 0.01);
|
|
1195
|
+
s.value =
|
|
1196
|
+
(next ??
|
|
1197
|
+
(Number.isNaN(shown)
|
|
1198
|
+
? rungs.find(([n]) => n === 'medium')
|
|
1199
|
+
: v === 'more'
|
|
1200
|
+
? rungs[rungs.length - 1]
|
|
1201
|
+
: rungs[0]))?.[0] ?? 'medium';
|
|
1202
|
+
} else {
|
|
1203
|
+
// A rung in any case, a size in px written any way: the plain form.
|
|
1204
|
+
const lower = v.toLowerCase();
|
|
1205
|
+
const px = /^(\d+(?:\.\d+)?|\.\d+)px$/.exec(lower);
|
|
1206
|
+
if (CORNERS.some(([n]) => n === lower)) s.value = lower;
|
|
1207
|
+
else if (px) s.value = `${Number(px[1])}px`;
|
|
1208
|
+
else if (lower === '0') s.value = 'square';
|
|
1209
|
+
else {
|
|
1210
|
+
// What it most likely means, as a value corners takes.
|
|
1211
|
+
const len = lengthPx(lower);
|
|
1212
|
+
const pct = /^(\d+(?:\.\d+)?)%$/.exec(lower);
|
|
1213
|
+
const meant =
|
|
1214
|
+
len != null
|
|
1215
|
+
? `${len}px`
|
|
1216
|
+
: pct
|
|
1217
|
+
? Number(pct[1]) >= 50
|
|
1218
|
+
? 'pill'
|
|
1219
|
+
: null
|
|
1220
|
+
: (nearest(
|
|
1221
|
+
lower,
|
|
1222
|
+
CORNERS.map(([n]) => n),
|
|
1223
|
+
)[0] ?? null);
|
|
1224
|
+
refuse(
|
|
1225
|
+
E.ERR_THEME_BAD_VALUE,
|
|
1226
|
+
`corners takes ${DIALS.corners.values}, not "${v}".`,
|
|
1227
|
+
{
|
|
1228
|
+
...(meant ? {didYouMean: [meant]} : {}),
|
|
1229
|
+
run: [
|
|
1230
|
+
`${P} set ${slug} corners ${meant ?? 'medium'}${onFlag}${s.when ? ` --when ${s.when}` : ''}`,
|
|
1231
|
+
],
|
|
1232
|
+
},
|
|
1233
|
+
);
|
|
1234
|
+
}
|
|
1235
|
+
}
|
|
1236
|
+
} else if (thing === 'spacing') {
|
|
1237
|
+
// Spacing scales the space tokens a part reads; a state does not
|
|
1238
|
+
// change them, and a part that reads none shows nothing.
|
|
1239
|
+
if (s.state)
|
|
863
1240
|
refuse(
|
|
864
|
-
E.
|
|
865
|
-
`
|
|
1241
|
+
E.ERR_THEME_NO_EFFECT,
|
|
1242
|
+
`spacing does not change in a state; drop --state.`,
|
|
866
1243
|
{
|
|
867
|
-
|
|
868
|
-
v
|
|
869
|
-
|
|
870
|
-
),
|
|
1244
|
+
run: [
|
|
1245
|
+
`${P} set ${slug} spacing ${quoteCommandArgument(v || 'roomy')}${onFlag}`,
|
|
1246
|
+
],
|
|
871
1247
|
},
|
|
872
1248
|
);
|
|
873
|
-
|
|
1249
|
+
if (s.on && !ctx.unchecked) {
|
|
1250
|
+
// The tokens reach the parts inside it too.
|
|
1251
|
+
const reads = (/** @type {string} */ t) =>
|
|
1252
|
+
Object.values(ctx.C.MAP[t]?.own ?? {}).some(p =>
|
|
1253
|
+
Object.keys(p.tokens ?? {}).some(x =>
|
|
1254
|
+
/^--(spacing-|size-element-)/.test(x),
|
|
1255
|
+
),
|
|
1256
|
+
);
|
|
1257
|
+
const spaced = partsOf(ctx, s).filter(
|
|
1258
|
+
t => reads(t) || (ctx.C.MAP[t]?.contains ?? []).some(reads),
|
|
1259
|
+
);
|
|
1260
|
+
if (!spaced.length)
|
|
1261
|
+
refuse(
|
|
1262
|
+
E.ERR_THEME_NO_EFFECT,
|
|
1263
|
+
`${s.on} reads no spacing or control size, so spacing changes nothing you see there. For space around it, set margin or padding on it.`,
|
|
1264
|
+
{run: [`${P} set ${slug} padding 8px${onFlag}`]},
|
|
1265
|
+
);
|
|
1266
|
+
}
|
|
874
1267
|
if (step) s.value = ladder(SPACING, 'medium');
|
|
875
1268
|
else if (!SPACING.some(([n]) => n === v))
|
|
876
1269
|
refuse(
|
|
@@ -905,7 +1298,7 @@ export function checkSetting(
|
|
|
905
1298
|
} else if (PALETTE_DIALS.includes(thing)) {
|
|
906
1299
|
if (step)
|
|
907
1300
|
refuse(E.ERR_THEME_BAD_VALUE, `${thing} takes a color, not a step.`, {
|
|
908
|
-
run: [`${P} set ${slug} ${thing}
|
|
1301
|
+
run: [`${P} set ${slug} ${thing} ${quoteCommandArgument('#7c3aed')}`],
|
|
909
1302
|
});
|
|
910
1303
|
const problem = colorProblem(v);
|
|
911
1304
|
if (problem) {
|
|
@@ -933,7 +1326,9 @@ export function checkSetting(
|
|
|
933
1326
|
`"${v}" ${problem.message}.${problem.kind === 'unknown' || problem.kind === 'malformed' ? ' Give a hex, a color name, or an rgb(), hsl(), hwb(), lab(), lch(), oklab(), oklch() or color() color.' : ''}`,
|
|
934
1327
|
{
|
|
935
1328
|
didYouMean: better ? [better] : near,
|
|
936
|
-
run: [
|
|
1329
|
+
run: [
|
|
1330
|
+
`${P} set ${slug} ${thing} ${quoteCommandArgument(better ?? '#7c3aed')}`,
|
|
1331
|
+
],
|
|
937
1332
|
},
|
|
938
1333
|
);
|
|
939
1334
|
}
|
|
@@ -942,7 +1337,7 @@ export function checkSetting(
|
|
|
942
1337
|
refuse(
|
|
943
1338
|
E.ERR_THEME_BAD_VALUE,
|
|
944
1339
|
'vibrancy applies to every generated color of the theme; drop --on.',
|
|
945
|
-
{run: [`${P} set ${slug} vibrancy ${
|
|
1340
|
+
{run: [`${P} set ${slug} vibrancy ${quoteCommandArgument(v)}`]},
|
|
946
1341
|
);
|
|
947
1342
|
if (step) {
|
|
948
1343
|
const saved = [...data.settings]
|
|
@@ -990,7 +1385,7 @@ export function checkSetting(
|
|
|
990
1385
|
colors.length
|
|
991
1386
|
? 'vibrancy sets how saturated the generated colors are, and every color this theme sets is a gray, so it would change nothing. Set a color first.'
|
|
992
1387
|
: 'vibrancy sets how saturated the generated colors are, and this theme sets no color yet. Set one first.',
|
|
993
|
-
{run: [`${P} set ${slug} accent
|
|
1388
|
+
{run: [`${P} set ${slug} accent ${quoteCommandArgument('#7c3aed')}`]},
|
|
994
1389
|
);
|
|
995
1390
|
} else if (thing === 'font') {
|
|
996
1391
|
if (s.when || s.state)
|
|
@@ -999,7 +1394,7 @@ export function checkSetting(
|
|
|
999
1394
|
'font sets a role (body, heading, code) for the whole theme; it takes no --when or --state. For one part use font-family.',
|
|
1000
1395
|
{
|
|
1001
1396
|
run: [
|
|
1002
|
-
`${P} set ${slug} font-family ${
|
|
1397
|
+
`${P} set ${slug} font-family ${quoteCommandArgument(v)} --on heading${s.when ? ` --when ${s.when}` : ''}${s.state ? ` --state ${s.state}` : ''}`,
|
|
1003
1398
|
],
|
|
1004
1399
|
},
|
|
1005
1400
|
);
|
|
@@ -1007,7 +1402,11 @@ export function checkSetting(
|
|
|
1007
1402
|
refuse(
|
|
1008
1403
|
E.ERR_THEME_BAD_VALUE,
|
|
1009
1404
|
"font --on takes body, heading, or code. For one part's font use font-family.",
|
|
1010
|
-
{
|
|
1405
|
+
{
|
|
1406
|
+
run: [
|
|
1407
|
+
`${P} set ${slug} font-family ${quoteCommandArgument(v)} --on ${s.on}`,
|
|
1408
|
+
],
|
|
1409
|
+
},
|
|
1011
1410
|
);
|
|
1012
1411
|
if (step)
|
|
1013
1412
|
refuse(
|
|
@@ -1019,6 +1418,12 @@ export function checkSetting(
|
|
|
1019
1418
|
// could end the CSS declaration or the preview's style block. A
|
|
1020
1419
|
// preset typed in another case or spacing is the preset.
|
|
1021
1420
|
s.value = v.trim();
|
|
1421
|
+
// A font package names its preset: @fontsource/inter is inter.
|
|
1422
|
+
const fromPackage = /^@fontsource(?:-variable)?\/([a-z0-9-]+)$/i.exec(
|
|
1423
|
+
s.value,
|
|
1424
|
+
)?.[1];
|
|
1425
|
+
if (fromPackage && OPEN_FONTS[fromPackage.toLowerCase()])
|
|
1426
|
+
s.value = fromPackage.toLowerCase();
|
|
1022
1427
|
const key = s.value.toLowerCase().replace(/[\s_-]+/g, '');
|
|
1023
1428
|
const preset = [...Object.keys(FONTS), ...Object.keys(OPEN_FONTS)].find(
|
|
1024
1429
|
k => k.toLowerCase().replace(/[\s_-]+/g, '') === key,
|
|
@@ -1028,6 +1433,34 @@ export function checkSetting(
|
|
|
1028
1433
|
// (O'Reilly Sans); the dial quotes it when it writes it.
|
|
1029
1434
|
const family = (/** @type {string} */ f) =>
|
|
1030
1435
|
/^"[^"]+"$/.test(f) || /^'[^']+'$/.test(f) || /^[^"',\s][^"]*$/.test(f);
|
|
1436
|
+
// A CSS-wide keyword inside a family list makes the browser drop
|
|
1437
|
+
// the whole declaration.
|
|
1438
|
+
const keyword = s.value
|
|
1439
|
+
.split(',')
|
|
1440
|
+
.map(f =>
|
|
1441
|
+
f
|
|
1442
|
+
.trim()
|
|
1443
|
+
.replace(/^["']|["']$/g, '')
|
|
1444
|
+
.toLowerCase(),
|
|
1445
|
+
)
|
|
1446
|
+
.find(f => CSS_WIDE_KEYWORDS.includes(f));
|
|
1447
|
+
if (keyword)
|
|
1448
|
+
refuse(
|
|
1449
|
+
E.ERR_THEME_BAD_VALUE,
|
|
1450
|
+
`"${keyword}" is a CSS keyword, not a font: inside a font list it makes the browser drop the whole font. Give a preset or a family name; to go back to the base theme's font, undo the font setting.`,
|
|
1451
|
+
{
|
|
1452
|
+
run: [
|
|
1453
|
+
`${P} set ${slug} font system${s.on ? ` --on ${s.on}` : ''}`,
|
|
1454
|
+
`${P} undo ${slug} font${s.on ? ` --on ${s.on}` : ''}`,
|
|
1455
|
+
],
|
|
1456
|
+
},
|
|
1457
|
+
);
|
|
1458
|
+
if (s.value.split(',').some(f => f.trim().length > 100))
|
|
1459
|
+
refuse(
|
|
1460
|
+
E.ERR_THEME_BAD_VALUE,
|
|
1461
|
+
'A font family name is at most 100 characters.',
|
|
1462
|
+
{run: [`${P} set ${slug} font inter`]},
|
|
1463
|
+
);
|
|
1031
1464
|
if (
|
|
1032
1465
|
!s.value ||
|
|
1033
1466
|
/[;{}<>\\\n]/.test(s.value) ||
|
|
@@ -1043,27 +1476,50 @@ export function checkSetting(
|
|
|
1043
1476
|
refuse(
|
|
1044
1477
|
E.ERR_THEME_BAD_VALUE,
|
|
1045
1478
|
'base applies to the whole theme; drop --on.',
|
|
1046
|
-
{run: [`${P} set ${slug} base ${
|
|
1479
|
+
{run: [`${P} set ${slug} base ${quoteCommandArgument(v)}`]},
|
|
1047
1480
|
);
|
|
1048
|
-
if (![...LIKE, 'none'].includes(v))
|
|
1481
|
+
if (![...LIKE, 'none'].includes(v)) {
|
|
1482
|
+
// `NEUTRAL`, `base=neutral`, `None`: the base meant.
|
|
1483
|
+
const meant = v
|
|
1484
|
+
.toLowerCase()
|
|
1485
|
+
.replace(/^base\s*[=:]\s*/, '')
|
|
1486
|
+
.trim();
|
|
1487
|
+
const near = [...LIKE, 'none'].includes(meant)
|
|
1488
|
+
? [meant]
|
|
1489
|
+
: nearest(meant, [...LIKE, 'none']);
|
|
1049
1490
|
refuse(
|
|
1050
1491
|
E.ERR_THEME_BAD_VALUE,
|
|
1051
1492
|
`base takes ${DIALS.base.values}, not "${v}".`,
|
|
1052
|
-
{
|
|
1493
|
+
{
|
|
1494
|
+
didYouMean: near,
|
|
1495
|
+
run: near[0] ? [`${P} set ${slug} base ${near[0]}`] : [],
|
|
1496
|
+
},
|
|
1053
1497
|
);
|
|
1498
|
+
}
|
|
1054
1499
|
} else if (thing === 'mode') {
|
|
1055
1500
|
if (s.on)
|
|
1056
1501
|
refuse(
|
|
1057
1502
|
E.ERR_THEME_BAD_VALUE,
|
|
1058
1503
|
'mode applies to the whole theme; drop --on.',
|
|
1059
|
-
{run: [`${P} set ${slug} mode ${
|
|
1504
|
+
{run: [`${P} set ${slug} mode ${quoteCommandArgument(v)}`]},
|
|
1060
1505
|
);
|
|
1061
|
-
if (!['both', 'light-only', 'dark-only'].includes(v))
|
|
1506
|
+
if (!['both', 'light-only', 'dark-only'].includes(v)) {
|
|
1507
|
+
const lower = v.toLowerCase().replace(/^mode\s*[=:]\s*/, '');
|
|
1508
|
+
const meant =
|
|
1509
|
+
DIAL_WORDS.mode[lower] ??
|
|
1510
|
+
(['both', 'light-only', 'dark-only'].includes(lower) ? lower : null);
|
|
1511
|
+
const near = meant
|
|
1512
|
+
? [meant]
|
|
1513
|
+
: nearest(lower, ['both', 'light-only', 'dark-only']);
|
|
1062
1514
|
refuse(
|
|
1063
1515
|
E.ERR_THEME_BAD_VALUE,
|
|
1064
1516
|
`mode takes both, light-only, or dark-only, not "${v}".`,
|
|
1065
|
-
{
|
|
1517
|
+
{
|
|
1518
|
+
didYouMean: near,
|
|
1519
|
+
run: near[0] ? [`${P} set ${slug} mode ${near[0]}`] : [],
|
|
1520
|
+
},
|
|
1066
1521
|
);
|
|
1522
|
+
}
|
|
1067
1523
|
}
|
|
1068
1524
|
return s;
|
|
1069
1525
|
}
|
|
@@ -1072,7 +1528,7 @@ export function checkSetting(
|
|
|
1072
1528
|
refuse(
|
|
1073
1529
|
E.ERR_THEME_PRIVATE_TOKEN,
|
|
1074
1530
|
`"${thing}" is private to a component; themes cannot set it.`,
|
|
1075
|
-
{run: [`${HOW} ${
|
|
1531
|
+
{run: [`${HOW} ${quoteCommandArgument(thing)}`]},
|
|
1076
1532
|
);
|
|
1077
1533
|
if (!(thing in TOKENS)) {
|
|
1078
1534
|
refuse(E.ERR_THEME_UNKNOWN_TOKEN, `"${thing}" is not a design token.`, {
|
|
@@ -1097,7 +1553,7 @@ export function checkSetting(
|
|
|
1097
1553
|
run: [
|
|
1098
1554
|
unset
|
|
1099
1555
|
? `${P} undo ${slug} ${thing}${onFlag}`
|
|
1100
|
-
: `${P} set ${slug} ${thing} ${
|
|
1556
|
+
: `${P} set ${slug} ${thing} ${quoteCommandArgument(v)}${onFlag}`,
|
|
1101
1557
|
],
|
|
1102
1558
|
},
|
|
1103
1559
|
);
|
|
@@ -1219,7 +1675,7 @@ export function checkSetting(
|
|
|
1219
1675
|
`${prop} is a CSS property, so it needs --on <part|group>. For the whole theme use a dial or a token.`,
|
|
1220
1676
|
{
|
|
1221
1677
|
run: [
|
|
1222
|
-
`${P} set ${slug} ${prop} ${
|
|
1678
|
+
`${P} set ${slug} ${prop} ${quoteCommandArgument(v || exampleOf(groupOfPropType(prop), prop))} --on card`,
|
|
1223
1679
|
`${HOW} "${prop}"`,
|
|
1224
1680
|
],
|
|
1225
1681
|
},
|
|
@@ -1227,8 +1683,37 @@ export function checkSetting(
|
|
|
1227
1683
|
s.source = 'property';
|
|
1228
1684
|
s.thing = prop;
|
|
1229
1685
|
if (unset) return s;
|
|
1686
|
+
// Text, headings and links take their color from the color prop, whose
|
|
1687
|
+
// rule Core writes after part styles: a color set on them never shows.
|
|
1688
|
+
const textParts = ['text', 'heading', 'link'];
|
|
1689
|
+
if (
|
|
1690
|
+
(prop === 'color' || prop === '-webkit-text-fill-color') &&
|
|
1691
|
+
partsOf(ctx, s).some(t => textParts.includes(t))
|
|
1692
|
+
) {
|
|
1693
|
+
if (partsOf(ctx, s).every(t => textParts.includes(t))) {
|
|
1694
|
+
const named = /^color:([\w-]+)$/.exec(s.when ?? '')?.[1];
|
|
1695
|
+
refuse(
|
|
1696
|
+
E.ERR_THEME_NO_EFFECT,
|
|
1697
|
+
`${s.on} takes its color from the color prop, which Core sets after part styles, so a color set on ${s.on} never shows. Set the text color token instead.`,
|
|
1698
|
+
{
|
|
1699
|
+
run: [
|
|
1700
|
+
`${P} set ${slug} --color-text-${named ?? 'primary'} ${quoteCommandArgument(v || '#1f2937')}${s.mode ? ` --mode ${s.mode}` : ''}`,
|
|
1701
|
+
...(named
|
|
1702
|
+
? []
|
|
1703
|
+
: [
|
|
1704
|
+
`${P} set ${slug} --color-text-secondary ${quoteCommandArgument(v || '#1f2937')}${s.mode ? ` --mode ${s.mode}` : ''}`,
|
|
1705
|
+
]),
|
|
1706
|
+
],
|
|
1707
|
+
},
|
|
1708
|
+
);
|
|
1709
|
+
}
|
|
1710
|
+
s.note = `text, heading and link inside ${s.on} keep the color their color prop gives; set --color-text-primary for those`;
|
|
1711
|
+
}
|
|
1230
1712
|
// One mode on a part whose variants each read their own value: the
|
|
1231
1713
|
// other mode cannot keep each variant's value in one rule.
|
|
1714
|
+
// With a state, the other mode would take one variant's value for
|
|
1715
|
+
// every variant, so any part whose variants read their own value needs
|
|
1716
|
+
// the variant named.
|
|
1232
1717
|
if (s.mode && !s.when) {
|
|
1233
1718
|
const g = C.groupOfProp(
|
|
1234
1719
|
prop === 'background' ? 'background-color' : prop,
|
|
@@ -1237,20 +1722,38 @@ export function checkSetting(
|
|
|
1237
1722
|
const reads = g
|
|
1238
1723
|
? C.partReads(t, g).filter(r => r.props.includes(prop))
|
|
1239
1724
|
: [];
|
|
1240
|
-
const
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1725
|
+
const variantsOf = (
|
|
1726
|
+
/** @type {(w: string) => string | undefined} */ pick,
|
|
1727
|
+
) => [
|
|
1728
|
+
...new Set(
|
|
1729
|
+
reads
|
|
1730
|
+
.flatMap(r => r.when)
|
|
1731
|
+
.map(pick)
|
|
1732
|
+
.filter(Boolean),
|
|
1733
|
+
),
|
|
1734
|
+
];
|
|
1735
|
+
// Resting reads keyed by the variant alone, and reads in the state.
|
|
1736
|
+
const rest = variantsOf(w => /^variant=([\w-]+)$/.exec(w)?.[1]);
|
|
1737
|
+
const inState = s.state
|
|
1738
|
+
? variantsOf(w =>
|
|
1739
|
+
w.includes(`:${s.state}`)
|
|
1740
|
+
? /(?:^|,)variant=([\w-]+)/.exec(w)?.[1]
|
|
1741
|
+
: undefined,
|
|
1742
|
+
)
|
|
1743
|
+
: [];
|
|
1744
|
+
// A state that does not change this property shows each variant's
|
|
1745
|
+
// resting value, so that is what the other mode must keep.
|
|
1746
|
+
const variants = inState.length ? inState : rest;
|
|
1747
|
+
const perVariant = inState.length
|
|
1748
|
+
? true
|
|
1749
|
+
: rest.length > 0 && !reads.some(r => r.when.includes(''));
|
|
1750
|
+
if (reads.length && variants.length && perVariant)
|
|
1248
1751
|
refuse(
|
|
1249
1752
|
E.ERR_THEME_NO_MODE,
|
|
1250
|
-
`Each variant of ${t} has its own ${prop}, so one mode cannot be set for all of them at once
|
|
1753
|
+
`Each variant of ${t} has its own ${prop}${s.state ? ` when ${s.state}` : ''}, so one mode cannot be set for all of them at once: the other mode would take one variant's color for every variant. Name the variant.`,
|
|
1251
1754
|
{
|
|
1252
1755
|
run: [
|
|
1253
|
-
`${P} set ${slug} ${prop} ${
|
|
1756
|
+
`${P} set ${slug} ${prop} ${quoteCommandArgument(v)} --on ${s.on} --when variant:${variants[0]}${s.state ? ` --state ${s.state}` : ''} --mode ${s.mode}`,
|
|
1254
1757
|
],
|
|
1255
1758
|
},
|
|
1256
1759
|
);
|
|
@@ -1268,13 +1771,31 @@ export function checkSetting(
|
|
|
1268
1771
|
E.ERR_THEME_BAD_VALUE,
|
|
1269
1772
|
`"more"/"less" work only on dials. Give ${prop} an exact CSS value.`,
|
|
1270
1773
|
);
|
|
1774
|
+
const grammar = propertyProblem(prop, v);
|
|
1775
|
+
if (grammar)
|
|
1776
|
+
refuse(
|
|
1777
|
+
E.ERR_THEME_BAD_VALUE,
|
|
1778
|
+
`${prop} takes ${grammar.takes}; "${v}" is not one.`,
|
|
1779
|
+
{
|
|
1780
|
+
...(grammar.near && /^[a-z-]+$/i.test(v)
|
|
1781
|
+
? {didYouMean: [grammar.near]}
|
|
1782
|
+
: {}),
|
|
1783
|
+
run: grammar.near
|
|
1784
|
+
? [
|
|
1785
|
+
`${P} set ${slug} ${prop} ${quoteCommandArgument(grammar.near)} --on ${s.on}${s.when ? ` --when ${s.when}` : ''}${s.state ? ` --state ${s.state}` : ''}${s.mode ? ` --mode ${s.mode}` : ''}`,
|
|
1786
|
+
]
|
|
1787
|
+
: [`${HOW} ${prop}`],
|
|
1788
|
+
},
|
|
1789
|
+
);
|
|
1271
1790
|
if (COLOR_PROPS.test(prop) && !isColorValue(v)) {
|
|
1272
1791
|
refuse(
|
|
1273
1792
|
E.ERR_THEME_BAD_VALUE,
|
|
1274
1793
|
`${prop} takes a color; "${v}" is not one.${/gradient/.test(v) ? ' Gradients go in background.' : ''}`,
|
|
1275
1794
|
{
|
|
1276
1795
|
run: /gradient/.test(v)
|
|
1277
|
-
? [
|
|
1796
|
+
? [
|
|
1797
|
+
`${P} set ${slug} background ${quoteCommandArgument(v)} --on ${s.on}`,
|
|
1798
|
+
]
|
|
1278
1799
|
: [],
|
|
1279
1800
|
},
|
|
1280
1801
|
);
|
|
@@ -1297,22 +1818,63 @@ export function checkSetting(
|
|
|
1297
1818
|
{
|
|
1298
1819
|
run: alt
|
|
1299
1820
|
? [
|
|
1300
|
-
`${P} set ${slug} ${prop} ${
|
|
1301
|
-
`${P} set ${slug} ${alt}
|
|
1821
|
+
`${P} set ${slug} ${prop} ${quoteCommandArgument(v.replace(/#[0-9a-f]{3,8}|rgba?\([^)]*\)/i, 'currentcolor'))} --on ${s.on}${whenFlag} # the shape, both modes`,
|
|
1822
|
+
`${P} set ${slug} ${alt} ${quoteCommandArgument(/#[0-9a-f]{3,8}\b|rgba?\([^)]*\)|hsla?\([^)]*\)/i.exec(v)?.[0] ?? '#1f2937')} --on ${s.on}${whenFlag} --mode ${s.mode} # then the color per mode`,
|
|
1302
1823
|
]
|
|
1303
1824
|
: [
|
|
1304
|
-
`${P} set ${slug} ${prop} ${
|
|
1825
|
+
`${P} set ${slug} ${prop} ${quoteCommandArgument(v)} --on ${s.on}${whenFlag} # both modes`,
|
|
1305
1826
|
],
|
|
1306
1827
|
},
|
|
1307
1828
|
);
|
|
1308
1829
|
}
|
|
1830
|
+
// In a state, the other mode keeps the state's own value there (or a
|
|
1831
|
+
// value set for both modes); with none to keep, the setting would
|
|
1832
|
+
// change that mode too. Without a state, the other mode keeps the
|
|
1833
|
+
// part's plain color.
|
|
1309
1834
|
if (
|
|
1310
1835
|
s.mode &&
|
|
1311
|
-
|
|
1836
|
+
s.state &&
|
|
1837
|
+
!partsOf(ctx, s).every(t =>
|
|
1838
|
+
partDefault(ctx, t, camel(prop), s.when, s.state),
|
|
1839
|
+
) &&
|
|
1840
|
+
!data.settings.some(
|
|
1841
|
+
x =>
|
|
1842
|
+
x.thing === prop &&
|
|
1843
|
+
x.on === s.on &&
|
|
1844
|
+
x.when === s.when &&
|
|
1845
|
+
x.state === s.state &&
|
|
1846
|
+
x.mode !== s.mode,
|
|
1847
|
+
)
|
|
1312
1848
|
)
|
|
1313
|
-
|
|
1849
|
+
refuse(
|
|
1850
|
+
E.ERR_THEME_NO_MODE,
|
|
1851
|
+
`${s.on} has no ${prop}${s.state ? ` when ${s.state}` : ''}${s.when ? ` for ${s.when}` : ''} of its own for the ${s.mode === 'light' ? 'dark' : 'light'} mode to keep, so a ${s.mode}-only value would change it too. Set it for both modes.`,
|
|
1852
|
+
{
|
|
1853
|
+
run: [
|
|
1854
|
+
`${P} set ${slug} ${prop} ${quoteCommandArgument(v)} --on ${s.on}${s.when ? ` --when ${s.when}` : ''}${s.state ? ` --state ${s.state}` : ''}`,
|
|
1855
|
+
],
|
|
1856
|
+
},
|
|
1857
|
+
);
|
|
1314
1858
|
return s;
|
|
1315
1859
|
}
|
|
1860
|
+
// A property written with _ or spaces, a trailing colon, or in camel
|
|
1861
|
+
// case: the property meant.
|
|
1862
|
+
const meant = kebab(String(thing).trim().replace(/:$/, ''))
|
|
1863
|
+
.replace(/[_\s]+/g, '-')
|
|
1864
|
+
.replace(/-+/g, '-');
|
|
1865
|
+
if (meant !== prop && CSS_PROPERTIES.has(meant))
|
|
1866
|
+
refuse(
|
|
1867
|
+
E.ERR_THEME_UNKNOWN_THING,
|
|
1868
|
+
`"${thing}" is not a dial, a token, or a CSS property; the property is ${meant}.`,
|
|
1869
|
+
{
|
|
1870
|
+
didYouMean: [meant],
|
|
1871
|
+
run: [
|
|
1872
|
+
unset
|
|
1873
|
+
? `${P} undo ${slug} ${meant}${onFlag}`
|
|
1874
|
+
: `${P} set ${slug} ${meant} ${quoteCommandArgument(v || exampleOf(groupOfPropType(meant), meant))}${onFlag || ' --on card'}`,
|
|
1875
|
+
],
|
|
1876
|
+
},
|
|
1877
|
+
);
|
|
1316
1878
|
const hint =
|
|
1317
1879
|
/** @type {((v: string, on: string | undefined) => string[]) | undefined} */ (
|
|
1318
1880
|
THING_HINTS[thing.toLowerCase()]
|
|
@@ -1329,7 +1891,7 @@ export function checkSetting(
|
|
|
1329
1891
|
run: aliases.map(d =>
|
|
1330
1892
|
unset
|
|
1331
1893
|
? `${P} undo ${slug} ${d}${onFlag}`
|
|
1332
|
-
: `${P} set ${slug} ${d} ${
|
|
1894
|
+
: `${P} set ${slug} ${d} ${quoteCommandArgument(valueFor(d, v))}${onFlag}`,
|
|
1333
1895
|
),
|
|
1334
1896
|
},
|
|
1335
1897
|
);
|
|
@@ -1337,9 +1899,24 @@ export function checkSetting(
|
|
|
1337
1899
|
E.ERR_THEME_UNKNOWN_THING,
|
|
1338
1900
|
`"${thing}" is not a dial, a token, or a CSS property.`,
|
|
1339
1901
|
{
|
|
1902
|
+
// A hint names this theme and the part (card when none is given),
|
|
1903
|
+
// and a corners value corners takes.
|
|
1340
1904
|
run: hint
|
|
1341
|
-
? hint(
|
|
1342
|
-
|
|
1905
|
+
? hint(
|
|
1906
|
+
/corners/.test(String(hint('', '')))
|
|
1907
|
+
? CORNERS.some(([n]) => n === v) || /^\d+(\.\d+)?px$/.test(v)
|
|
1908
|
+
? v
|
|
1909
|
+
: ''
|
|
1910
|
+
: v,
|
|
1911
|
+
s.on,
|
|
1912
|
+
).map(x =>
|
|
1913
|
+
x
|
|
1914
|
+
.replace(/<theme>/g, slug)
|
|
1915
|
+
.replace(/<part>/g, 'card')
|
|
1916
|
+
.replace(/"([^"]*)"/g, (_, q) => quoteCommandArgument(q)),
|
|
1917
|
+
)
|
|
1918
|
+
: // A list that answers, not a question the parser may not match.
|
|
1919
|
+
[`${HOW} --list properties`, `${HOW} --list dials`],
|
|
1343
1920
|
didYouMean: hint
|
|
1344
1921
|
? []
|
|
1345
1922
|
: nearest(prop, [...Object.keys(DIALS), ...CSS_PROPERTIES]),
|
|
@@ -1376,7 +1953,8 @@ function refuseInvisibleCorners(ctx, slug, s, data) {
|
|
|
1376
1953
|
{
|
|
1377
1954
|
run: kids.length
|
|
1378
1955
|
? kids.map(
|
|
1379
|
-
k =>
|
|
1956
|
+
k =>
|
|
1957
|
+
`${P} set ${slug} corners ${quoteCommandArgument(s.value || 'round')} --on ${k}`,
|
|
1380
1958
|
)
|
|
1381
1959
|
: [`${HOW} ${s.on}`],
|
|
1382
1960
|
},
|