@astryxdesign/cli 0.7.16-canary.ge95b87c → 0.7.16
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/CHANGELOG.md +369 -0
- package/README.md +1 -1
- package/api/build/_adapter.d.mts +9 -0
- package/api/build/_adapter.mjs +24 -0
- package/api/build/kit/shell.weights.json +1 -0
- package/api/build/kit/shellcall.d.mts +26 -0
- package/api/build/kit/shellcall.mjs +87 -0
- package/api/build/kit/start.mjs +67 -4
- package/api/build/kit/weights.d.mts +15 -0
- package/api/build/kit/weights.mjs +27 -0
- package/api/component/__fixtures__/resolutions/modules.txt +1 -1
- package/api/doctor/_adapter.d.mts +3 -2
- package/api/doctor/_adapter.mjs +7 -1
- package/api/doctor/doctor.d.mts +8 -0
- package/api/doctor/doctor.mjs +53 -8
- package/api/doctor/theme-checks.mjs +157 -8
- package/api/icon/_adapter.d.mts +7 -3
- package/api/icon/_adapter.mjs +12 -3
- package/api/icon/icon.type.d.mts +15 -0
- package/api/icon/icon.type.mjs +10 -3
- package/api/icon/iconUse.doc.mjs +19 -5
- package/api/icon/list/list.mjs +7 -1
- package/api/icon/use/use.d.mts +8 -5
- package/api/icon/use/use.mjs +95 -13
- package/api/init/run/run.mjs +1 -0
- package/api/template/template.type.d.mts +6 -2
- package/api/template/template.type.mjs +2 -1
- package/api/theme/_adapter.mjs +16 -2
- package/api/theme/build/build.d.mts +10 -6
- package/api/theme/build/build.mjs +42 -29
- package/api/theme/generateTonalPalette.doc.mjs +2 -2
- package/api/theme/palette/generate/generator.mjs +141 -2
- package/api/theme/theme.type.d.mts +39 -0
- package/api/theme/theme.type.mjs +21 -0
- package/api/theme/themeBuild.doc.mjs +1 -1
- package/api/theme/themePaletteGenerate.doc.mjs +1 -1
- package/api/theme-edit/_adapter.d.mts +1 -0
- package/api/theme-edit/_adapter.mjs +79 -21
- package/api/theme-edit/_check.d.mts +25 -2
- package/api/theme-edit/_check.mjs +251 -61
- package/api/theme-edit/_context.d.mts +2 -1
- package/api/theme-edit/_context.mjs +19 -1
- package/api/theme-edit/_edit.d.mts +16 -0
- package/api/theme-edit/_edit.mjs +360 -59
- package/api/theme-edit/_how-question.d.mts +8 -0
- package/api/theme-edit/_how-question.mjs +169 -22
- package/api/theme-edit/_marks.d.mts +13 -0
- package/api/theme-edit/_marks.mjs +15 -0
- package/api/theme-edit/_palette.d.mts +27 -0
- package/api/theme-edit/_palette.mjs +112 -8
- package/api/theme-edit/_preview-app.d.mts +46 -1
- package/api/theme-edit/_preview-app.mjs +367 -36
- package/api/theme-edit/_preview.d.mts +55 -0
- package/api/theme-edit/_preview.mjs +231 -6
- package/api/theme-edit/_project.d.mts +4 -0
- package/api/theme-edit/_project.mjs +27 -6
- package/api/theme-edit/_settings.d.mts +61 -2
- package/api/theme-edit/_settings.mjs +317 -115
- package/api/theme-edit/_tables.mjs +1 -1
- package/api/theme-edit/theme-edit.type.d.mts +30 -2
- package/api/theme-edit/theme-edit.type.mjs +10 -2
- package/api/theme-edit/themeEditPreviewApp.doc.mjs +1 -1
- package/assets/docs/author-a-theme.doc.mjs +1 -1
- package/assets/docs/theme.doc.dense.mjs +1 -1
- package/assets/docs/theme.doc.mjs +1 -1
- package/assets/docs/theme.doc.zh.mjs +4 -3
- package/assets/docs/tree/define-the-theme.doc.mjs +1 -1
- package/assets/docs/tree/icon-sets.doc.mjs +63 -8
- package/assets/docs.generated.json +2 -2
- package/assets/self-audit.generated.json +1 -1
- package/assets/templates/blocks/components/Outline/useOutlineFromDOMHookUsage.doc.mjs +21 -0
- package/assets/templates/blocks/components/Outline/useOutlineFromDOMHookUsage.tsx +62 -0
- package/assets/templates/components.generated.json +1 -1
- package/assets/templates/pages/ai-chat/page.tsx +20 -2
- package/assets/templates/themes/neutral/neutralPalettes.generated.receipt.json +2 -0
- package/authoring/config/config.doc.mjs +8 -0
- package/authoring/config/parse.d.mts +1 -0
- package/authoring/config/parse.mjs +12 -0
- package/authoring/config/type.ts +8 -0
- package/authoring/doctypes/icon-set/icon-set-data.doc.mjs +3 -3
- package/clients/cli/build-id.generated.json +1 -1
- package/clients/cli/commands/experimental/icon.mjs +61 -6
- package/clients/cli/commands/experimental/theme.mjs +9 -2
- package/clients/cli/commands/experimental-icon-use.doc.mjs +12 -5
- package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-editor.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-preview-app.doc.mjs +1 -1
- package/clients/cli/commands/theme.doc.mjs +7 -2
- package/clients/cli/commands/theme.mjs +41 -18
- package/clients/cli/commands.generated.json +1 -1
- package/clients/cli/index.mjs +25 -5
- package/clients/cli/manifest.generated.json +1 -1
- package/foundation/agent-docs/agent-docs.mjs +1 -1
- package/foundation/config/config-writer.d.mts +23 -0
- package/foundation/config/config-writer.mjs +150 -56
- package/foundation/config/project.mjs +43 -2
- package/foundation/discovery/component-discovery.mjs +6 -5
- package/foundation/discovery/icon-set-checks.mjs +164 -48
- package/foundation/discovery/icon-set-discovery.d.mts +38 -5
- package/foundation/discovery/icon-set-discovery.mjs +50 -6
- package/foundation/discovery/icon-set-theme-maps.d.mts +59 -0
- package/foundation/discovery/icon-set-theme-maps.mjs +95 -0
- package/foundation/discovery/icon-set-writer.d.mts +2 -3
- package/foundation/discovery/icon-set-writer.mjs +57 -16
- package/foundation/discovery/template-icons.d.mts +27 -10
- package/foundation/discovery/template-icons.mjs +142 -26
- package/foundation/discovery/theme-discovery.d.mts +25 -0
- package/foundation/discovery/theme-discovery.mjs +48 -7
- package/foundation/fs/gather-cache.mjs +6 -2
- package/foundation/integrations/autolink.d.mts +4 -2
- package/foundation/integrations/autolink.mjs +4 -2
- package/foundation/integrations/cli-requirement.d.mts +16 -5
- package/foundation/integrations/cli-requirement.mjs +27 -6
- package/foundation/integrations/may-have-integrations.mjs +5 -2
- package/foundation/integrations/missing-dependency.d.mts +9 -0
- package/foundation/integrations/missing-dependency.mjs +100 -0
- package/package.json +6 -6
|
@@ -235,7 +235,7 @@ function matchingParen(text, open) {
|
|
|
235
235
|
* @returns {number | null}
|
|
236
236
|
*/
|
|
237
237
|
function textSizePx(v) {
|
|
238
|
-
const m = /^\+?(\d*\.?\d+(?:e[+-]?\d+)?)(px|rem|em|%)?$/i.exec(
|
|
238
|
+
const m = /^\+?(\d*\.?\d+(?:e[+-]?\d+)?)(px|rem|em|pt|%)?$/i.exec(
|
|
239
239
|
typedPlain(v)
|
|
240
240
|
.replace(/(\d)\.(?=[a-z%]*$)/i, '$1')
|
|
241
241
|
.replace(/\s+/g, '')
|
|
@@ -244,7 +244,14 @@ function textSizePx(v) {
|
|
|
244
244
|
if (!m) return null;
|
|
245
245
|
const unit = (m[2] ?? '').toLowerCase();
|
|
246
246
|
const n =
|
|
247
|
-
Number(m[1]) *
|
|
247
|
+
Number(m[1]) *
|
|
248
|
+
(/r?em/.test(unit)
|
|
249
|
+
? 16
|
|
250
|
+
: unit === '%'
|
|
251
|
+
? 16 / 100
|
|
252
|
+
: unit === 'pt'
|
|
253
|
+
? 4 / 3
|
|
254
|
+
: 1);
|
|
248
255
|
const px = Math.round(n * 100) / 100;
|
|
249
256
|
return Math.max(10, Math.min(32, px));
|
|
250
257
|
}
|
|
@@ -509,7 +516,7 @@ const COLOR_DIAL_WORDS = (() => {
|
|
|
509
516
|
* @param {string} slug
|
|
510
517
|
* @param {import('./_settings.mjs').ThemeData} data
|
|
511
518
|
* @param {string | {thing: string, on?: string, when?: string, state?: string, mode?: string}} [skip]
|
|
512
|
-
* @returns {Array<{setting: import('./_settings.mjs').Setting, why: string, scope?: boolean}>} every saved setting the editor no longer accepts
|
|
519
|
+
* @returns {Array<{setting: import('./_settings.mjs').Setting, why: string, scope?: boolean, fix?: string}>} every saved setting the editor no longer accepts (`fix`: the clean value to set, when one reads)
|
|
513
520
|
*/
|
|
514
521
|
export function storedProblems(ctx, slug, data, skip = '') {
|
|
515
522
|
// The setting the command replaces (its thing in the same scope); a
|
|
@@ -524,7 +531,7 @@ export function storedProblems(ctx, slug, data, skip = '') {
|
|
|
524
531
|
(s.when ?? '') === (skip.when ?? '') &&
|
|
525
532
|
(s.state ?? '') === (skip.state ?? '') &&
|
|
526
533
|
(s.mode ?? '') === (skip.mode ?? '');
|
|
527
|
-
/** @type {Array<{setting: import('./_settings.mjs').Setting, why: string, scope?: boolean}>} */
|
|
534
|
+
/** @type {Array<{setting: import('./_settings.mjs').Setting, why: string, scope?: boolean, fix?: string}>} */
|
|
528
535
|
const found = [];
|
|
529
536
|
const TOKENS = ctx.project.core.tokenDefaults;
|
|
530
537
|
// Where each saved setting applies names a real part, group, state and
|
|
@@ -612,7 +619,14 @@ export function storedProblems(ctx, slug, data, skip = '') {
|
|
|
612
619
|
checkSetting(
|
|
613
620
|
ctx,
|
|
614
621
|
slug,
|
|
615
|
-
{
|
|
622
|
+
{
|
|
623
|
+
...data,
|
|
624
|
+
// A saved setting for one mode stays saved when the theme keeps
|
|
625
|
+
// one mode (it applies again with both): the rule that refuses
|
|
626
|
+
// --mode on a one-mode theme is for a value typed in.
|
|
627
|
+
...(s.mode ? {mode: 'both'} : {}),
|
|
628
|
+
settings: data.settings.filter(x => x !== s),
|
|
629
|
+
},
|
|
616
630
|
s.thing,
|
|
617
631
|
s.value,
|
|
618
632
|
{on: s.on, when: s.when, state: s.state, mode: s.mode, only: s.only},
|
|
@@ -628,9 +642,24 @@ export function storedProblems(ctx, slug, data, skip = '') {
|
|
|
628
642
|
});
|
|
629
643
|
}
|
|
630
644
|
}
|
|
645
|
+
// A hand edit that put an invisible or non-breaking space in any value
|
|
646
|
+
// (the browser reads `rgb(1\u00A02\u00A03)` as invalid, a family with a
|
|
647
|
+
// zero-width space as another font): named, with the value as set writes
|
|
648
|
+
// it.
|
|
649
|
+
for (const s of data.settings) {
|
|
650
|
+
if (replaced(s) || typeof s.value !== 'string') continue;
|
|
651
|
+
const clean = normalValueText(s.value);
|
|
652
|
+
if (clean !== s.value)
|
|
653
|
+
found.push({
|
|
654
|
+
setting: s,
|
|
655
|
+
why: `${s.thing} holds a no-break, thin or zero-width space, which the browser does not read as a space`,
|
|
656
|
+
fix: clean,
|
|
657
|
+
});
|
|
658
|
+
}
|
|
631
659
|
for (const s of data.settings) {
|
|
632
660
|
if (s.source !== 'token' || s.thing === skipThing || !(s.thing in TOKENS))
|
|
633
661
|
continue;
|
|
662
|
+
if (found.some(f => f.setting === s)) continue;
|
|
634
663
|
// A var() a hand edit put in that names no design token reads nothing,
|
|
635
664
|
// as set refuses it.
|
|
636
665
|
const bad = unknownVarRef(String(s.value ?? ''), TOKENS, s.thing);
|
|
@@ -651,12 +680,20 @@ export function storedProblems(ctx, slug, data, skip = '') {
|
|
|
651
680
|
);
|
|
652
681
|
checkCycle(s.thing, s.value, TOKENS, data, ctx.project.cwd, s);
|
|
653
682
|
} catch (e) {
|
|
683
|
+
// The value the check itself suggests, as for typed input.
|
|
684
|
+
const line = /** @type {any} */ (e)?.suggestions?.find(
|
|
685
|
+
(/** @type {any} */ x) =>
|
|
686
|
+
x.name.startsWith(`${P} set ${slug} ${s.thing} `),
|
|
687
|
+
)?.name;
|
|
654
688
|
found.push({
|
|
655
689
|
setting: s,
|
|
656
690
|
why:
|
|
657
691
|
e instanceof Error
|
|
658
692
|
? e.message.replace(/ Nothing was changed\.$/, '')
|
|
659
693
|
: String(e),
|
|
694
|
+
...(line
|
|
695
|
+
? {fix: unquoteArg(line.slice(`${P} set ${slug} ${s.thing} `.length))}
|
|
696
|
+
: {}),
|
|
660
697
|
});
|
|
661
698
|
}
|
|
662
699
|
}
|
|
@@ -1548,6 +1585,11 @@ function checkOne(ctx, slug, data, thing, value, flags, unset) {
|
|
|
1548
1585
|
refuse(E.ERR_THEME_UNKNOWN_TOKEN, bad.message, {
|
|
1549
1586
|
didYouMean: bad.near,
|
|
1550
1587
|
run: [
|
|
1588
|
+
...(bad.fixed
|
|
1589
|
+
? [
|
|
1590
|
+
`${P} set ${slug} ${thing} ${quoteCommandArgument(bad.fixed)}${/** @type {const} */ (['on', 'state', 'when', 'mode']).map(k => (flags[k] ? ` --${k} ${quoteCommandArgument(String(flags[k]))}` : '')).join('')}`,
|
|
1591
|
+
]
|
|
1592
|
+
: []),
|
|
1551
1593
|
bad.close
|
|
1552
1594
|
? `${HOW} --list tokens ${bad.near[0].replace(/^--/, '').split('-')[0]}`
|
|
1553
1595
|
: `${HOW} --list tokens`,
|
|
@@ -2021,34 +2063,43 @@ function checkOne(ctx, slug, data, thing, value, flags, unset) {
|
|
|
2021
2063
|
`${thing} takes ${DIALS[thing].values}, not "${v}".`,
|
|
2022
2064
|
{
|
|
2023
2065
|
didYouMean: near,
|
|
2024
|
-
run:
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2066
|
+
run:
|
|
2067
|
+
// `type` is the scale's shape; a text-size word or a length
|
|
2068
|
+
// is the body size: text-size, never the corners.
|
|
2069
|
+
thing === 'type' &&
|
|
2070
|
+
(['small', 'medium', 'large', 'larger'].includes(lower) ||
|
|
2071
|
+
(/[a-z%]$/.test(lower) && textSizePx(lower) != null))
|
|
2072
|
+
? [
|
|
2073
|
+
`${P} set ${slug} text-size ${['small', 'medium', 'large', 'larger'].includes(lower) ? lower : textSizePx(lower)}`,
|
|
2074
|
+
]
|
|
2075
|
+
: near[0]
|
|
2076
|
+
? [`${P} set ${slug} ${thing} ${near[0]}`]
|
|
2077
|
+
: // A type-scale ratio (1.25) is the nearest type preset.
|
|
2078
|
+
thing === 'type' && ratioPreset(lower)
|
|
2079
|
+
? [`${P} set ${slug} type ${ratioPreset(lower)}`]
|
|
2080
|
+
: // A corner word or a size with a unit is the corners dial:
|
|
2081
|
+
// on the buttons for `buttons`, for the whole theme
|
|
2082
|
+
// otherwise. A bare number is no size: the dial's own
|
|
2083
|
+
// words.
|
|
2084
|
+
CORNERS.some(([n]) => lower.replace(/s$/, '') === n) ||
|
|
2085
|
+
(/[a-z%]$/.test(lower) && lengthPx(lower) != null)
|
|
2086
|
+
? [
|
|
2087
|
+
setLine(
|
|
2088
|
+
slug,
|
|
2089
|
+
'corners',
|
|
2090
|
+
CORNERS.find(
|
|
2091
|
+
([n]) => lower.replace(/s$/, '') === n,
|
|
2092
|
+
)?.[0] ?? lower,
|
|
2093
|
+
thing === 'buttons' ? {on: 'button'} : {},
|
|
2094
|
+
),
|
|
2095
|
+
]
|
|
2096
|
+
: [
|
|
2097
|
+
...(/^[+-]?\d*\.?\d+$/.test(lower) ? ok : [])
|
|
2098
|
+
.filter(w => /^[a-z-]+$/.test(w))
|
|
2099
|
+
.slice(0, 4)
|
|
2100
|
+
.map(w => `${P} set ${slug} ${thing} ${w}`),
|
|
2101
|
+
`${HOW} ${thing}`,
|
|
2102
|
+
],
|
|
2052
2103
|
},
|
|
2053
2104
|
);
|
|
2054
2105
|
}
|
|
@@ -2972,7 +3023,11 @@ function checkOne(ctx, slug, data, thing, value, flags, unset) {
|
|
|
2972
3023
|
`mode takes both, light-only, or dark-only, not "${v}".`,
|
|
2973
3024
|
{
|
|
2974
3025
|
didYouMean: near,
|
|
2975
|
-
run: near[0]
|
|
3026
|
+
run: near[0]
|
|
3027
|
+
? [`${P} set ${slug} mode ${near[0]}`]
|
|
3028
|
+
: ['both', 'light-only', 'dark-only'].map(
|
|
3029
|
+
m => `${P} set ${slug} mode ${m}`,
|
|
3030
|
+
),
|
|
2976
3031
|
},
|
|
2977
3032
|
);
|
|
2978
3033
|
}
|
|
@@ -3110,8 +3165,15 @@ function checkOne(ctx, slug, data, thing, value, flags, unset) {
|
|
|
3110
3165
|
),
|
|
3111
3166
|
also: r0.also,
|
|
3112
3167
|
});
|
|
3113
|
-
} else if (hard.length)
|
|
3114
|
-
|
|
3168
|
+
} else if (hard.length) {
|
|
3169
|
+
// Some members read it and take the change; name them, and say
|
|
3170
|
+
// what the others read instead (from the check's own message).
|
|
3171
|
+
const readers = recorded.filter(([, r]) => !r).map(([t]) => t);
|
|
3172
|
+
const instead = /reads: ([^.]+)\./.exec(
|
|
3173
|
+
String(/** @type {any} */ (hard[0][1])?.message ?? ''),
|
|
3174
|
+
)?.[1];
|
|
3175
|
+
s.note = `${readers.length ? `${readers.join(', ')} read ${thing} and take this change; ` : ''}the editor's render of ${hard.map(([t]) => t).join(', ')} did not read it${instead ? ` (${hard[0][0]} reads ${instead})` : ''}, so those stay as they were; each part is rendered once, with its default props, so a variant that reads it may be missed`;
|
|
3176
|
+
}
|
|
3115
3177
|
if (!s.note && recorded.length) {
|
|
3116
3178
|
const fed = C.feeds(recorded[0][0], thing);
|
|
3117
3179
|
if (fed.length) s.note = `feeds ${C.fmtFeeds(fed, recorded[0][0])}`;
|
|
@@ -3151,6 +3213,24 @@ function checkOne(ctx, slug, data, thing, value, flags, unset) {
|
|
|
3151
3213
|
return s;
|
|
3152
3214
|
}
|
|
3153
3215
|
const prop = kebab(thing);
|
|
3216
|
+
// A token typed without its leading dashes (color-accent,
|
|
3217
|
+
// text-body-size): the token, when no CSS property has that name.
|
|
3218
|
+
if (
|
|
3219
|
+
!unset &&
|
|
3220
|
+
!thing.startsWith('-') &&
|
|
3221
|
+
`--${thing}` in TOKENS &&
|
|
3222
|
+
!cssProperties().has(thing)
|
|
3223
|
+
)
|
|
3224
|
+
refuse(
|
|
3225
|
+
E.ERR_THEME_UNKNOWN_THING,
|
|
3226
|
+
`"${thing}" is not a dial, a token, or a CSS property; the token is --${thing}.`,
|
|
3227
|
+
{
|
|
3228
|
+
didYouMean: [`--${thing}`],
|
|
3229
|
+
run: [
|
|
3230
|
+
`${P} set ${slug} --${thing}${value ? ` ${quoteCommandArgument(value)}` : ''}`,
|
|
3231
|
+
],
|
|
3232
|
+
},
|
|
3233
|
+
);
|
|
3154
3234
|
// A dial typed in other letters (Font, FONT) is the dial, not the CSS
|
|
3155
3235
|
// property of the same name.
|
|
3156
3236
|
if (thing !== thing.toLowerCase() && DIALS[thing.toLowerCase()])
|
|
@@ -3181,9 +3261,37 @@ function checkOne(ctx, slug, data, thing, value, flags, unset) {
|
|
|
3181
3261
|
s.source = 'property';
|
|
3182
3262
|
s.thing = prop;
|
|
3183
3263
|
if (unset) return s;
|
|
3264
|
+
// A length property (padding, a corner radius, a gap) that reads a
|
|
3265
|
+
// design token of another kind (a color, a font, a duration) gets
|
|
3266
|
+
// nothing the browser keeps: refused like the token form.
|
|
3267
|
+
if (matchValue(prop, '1px') && !matchValue(prop, 'red'))
|
|
3268
|
+
for (const m of v.matchAll(/var\(\s*(--[a-z0-9-]+)/gi)) {
|
|
3269
|
+
const kind = ctx.C.isToken(m[1]) ? ctx.C.typeOf(m[1]) : null;
|
|
3270
|
+
if (kind && !['size', 'number', 'other'].includes(kind)) {
|
|
3271
|
+
const like = /radius/.test(prop)
|
|
3272
|
+
? 'var(--radius-container)'
|
|
3273
|
+
: /^(padding|margin|gap|row-gap|column-gap|inset)/.test(prop)
|
|
3274
|
+
? 'var(--spacing-4)'
|
|
3275
|
+
: exampleOf('size', prop);
|
|
3276
|
+
refuse(
|
|
3277
|
+
E.ERR_THEME_BAD_VALUE,
|
|
3278
|
+
`${prop} takes a length; ${m[1]} is a ${kind}, so the browser would drop it.`,
|
|
3279
|
+
{
|
|
3280
|
+
run: [
|
|
3281
|
+
`${P} set ${slug} ${prop} ${quoteCommandArgument(v.replace(new RegExp(`var\\(\\s*${m[1]}\\s*(,[^)]*)?\\)`, 'i'), like))} --on ${quoteCommandArgument(String(s.on))}${s.state ? ` --state ${s.state}` : ''}${s.when ? ` --when ${quoteCommandArgument(s.when)}` : ''}${s.mode ? ` --mode ${s.mode}` : ''}`,
|
|
3282
|
+
`${HOW} --list tokens ${/radius/.test(prop) ? 'radius' : 'spacing'}`,
|
|
3283
|
+
],
|
|
3284
|
+
},
|
|
3285
|
+
);
|
|
3286
|
+
}
|
|
3287
|
+
}
|
|
3184
3288
|
// initial and unset leave a part's padding variables without a value:
|
|
3185
3289
|
// the part takes Core's own default, which the result names.
|
|
3186
|
-
if (
|
|
3290
|
+
if (
|
|
3291
|
+
/^padding/.test(prop) &&
|
|
3292
|
+
/^(initial|unset|inherit|revert|revert-layer)$/i.test(v.trim()) &&
|
|
3293
|
+
s.on
|
|
3294
|
+
) {
|
|
3187
3295
|
const owner = (ctx.derived?.[s.on] ?? []).some(
|
|
3188
3296
|
d => d.property === 'padding' && d.expand,
|
|
3189
3297
|
)
|
|
@@ -3206,7 +3314,7 @@ function checkOne(ctx, slug, data, thing, value, flags, unset) {
|
|
|
3206
3314
|
// (a composer's or a menu's padding in its corners): one length is all
|
|
3207
3315
|
// that works there, whether a length, a variable, or calc(), min(),
|
|
3208
3316
|
// max() or clamp() giving one.
|
|
3209
|
-
if (s.on && ctx.derived) {
|
|
3317
|
+
if (s.on && ctx.derived && !WRAPPED_PARTS[s.on]) {
|
|
3210
3318
|
const inCalc = calcVars(ctx.project);
|
|
3211
3319
|
const hit = partsOf(ctx, s).find(t =>
|
|
3212
3320
|
(ctx.derived?.[t] ?? []).some(
|
|
@@ -3239,6 +3347,15 @@ function checkOne(ctx, slug, data, thing, value, flags, unset) {
|
|
|
3239
3347
|
!/radius/.test(prop);
|
|
3240
3348
|
const side = /^padding-/.test(prop);
|
|
3241
3349
|
const density = prop === 'padding' && /^density:/.test(s.when ?? '');
|
|
3350
|
+
// Core reads the box's padding only from a variable of its own, which
|
|
3351
|
+
// a theme may not write, and a padding property would pad the
|
|
3352
|
+
// transparent wrapper too.
|
|
3353
|
+
if (prop === 'padding' && !density)
|
|
3354
|
+
refuse(
|
|
3355
|
+
E.ERR_THEME_NO_EFFECT,
|
|
3356
|
+
`${s.on}'s theme class is on a transparent wrapper; ${wrapped.box} inside it reads its padding from a variable of Core's own, which a theme cannot set, and a padding on the wrapper would add a gap outside the box. Its padding follows the theme's spacing.`,
|
|
3357
|
+
{run: [`${HOW} ${s.on}`]},
|
|
3358
|
+
);
|
|
3242
3359
|
if (surface || side || density)
|
|
3243
3360
|
refuse(
|
|
3244
3361
|
E.ERR_THEME_BAD_VALUE,
|
|
@@ -3253,31 +3370,10 @@ function checkOne(ctx, slug, data, thing, value, flags, unset) {
|
|
|
3253
3370
|
`${P} set ${slug} --color-background-popover ${quoteCommandArgument('#ffffff')}`,
|
|
3254
3371
|
`${HOW} ${s.on}`,
|
|
3255
3372
|
]
|
|
3256
|
-
: [
|
|
3257
|
-
`${P} set ${slug} padding ${quoteCommandArgument(v)} --on ${s.on}`,
|
|
3258
|
-
],
|
|
3373
|
+
: [`${HOW} ${s.on}`],
|
|
3259
3374
|
},
|
|
3260
3375
|
);
|
|
3261
3376
|
}
|
|
3262
|
-
// Core writes a container part's padding to variables of its own, where
|
|
3263
|
-
// a keyword that takes its value from elsewhere means no value at all.
|
|
3264
|
-
if (
|
|
3265
|
-
/^padding/.test(prop) &&
|
|
3266
|
-
/^(inherit|revert|revert-layer)$/i.test(v.trim()) &&
|
|
3267
|
-
(ctx.derived?.[/** @type {string} */ (s.on)] ?? []).some(
|
|
3268
|
-
d => d.property === 'padding' && d.expand,
|
|
3269
|
-
)
|
|
3270
|
-
)
|
|
3271
|
-
refuse(
|
|
3272
|
-
E.ERR_THEME_BAD_VALUE,
|
|
3273
|
-
`${s.on} writes ${prop} to variables of its own, where "${v.trim()}" has nothing to take its value from, so ${s.on} would fall back to its default padding. Give a length, or undo the padding to go back to the base theme's.`,
|
|
3274
|
-
{
|
|
3275
|
-
run: [
|
|
3276
|
-
`${P} set ${slug} ${prop} 0 --on ${s.on}`,
|
|
3277
|
-
`${P} undo ${slug} ${prop} --on ${s.on}`,
|
|
3278
|
-
],
|
|
3279
|
-
},
|
|
3280
|
-
);
|
|
3281
3377
|
// Text, headings and links take their color from the color prop.
|
|
3282
3378
|
const textParts = COLOR_PROP_PARTS;
|
|
3283
3379
|
if (
|
|
@@ -3676,9 +3772,26 @@ export {familySpaces};
|
|
|
3676
3772
|
* @param {string} v
|
|
3677
3773
|
* @param {Record<string, unknown>} TOKENS
|
|
3678
3774
|
* @param {string} thing
|
|
3679
|
-
* @returns {{message: string, near: string[], close: boolean} | null}
|
|
3775
|
+
* @returns {{message: string, near: string[], close: boolean, fixed?: string} | null}
|
|
3680
3776
|
*/
|
|
3681
3777
|
export function unknownVarRef(v, TOKENS, thing) {
|
|
3778
|
+
// A var() whose name is not a custom property (`var(color-x)`, `var(-x)`,
|
|
3779
|
+
// `var()`, `var(--)`) makes the whole value invalid: the browser drops
|
|
3780
|
+
// it. Named with the repaired form when there is one.
|
|
3781
|
+
for (const m of v.matchAll(/var\(\s*([^,)]*?)\s*(?=[,)]|$)/gi)) {
|
|
3782
|
+
const raw = m[1];
|
|
3783
|
+
if (/^--[a-z0-9_][a-z0-9_-]*$/i.test(raw)) continue;
|
|
3784
|
+
const bare = raw.replace(/^-+/, '');
|
|
3785
|
+
const repaired = /^[a-z0-9][a-z0-9_-]*$/i.test(bare) ? `--${bare}` : null;
|
|
3786
|
+
return {
|
|
3787
|
+
message: `var(${raw}) is not a CSS variable reference: a variable's name starts with --${repaired ? `, as in var(${repaired})` : ''}, and the browser drops the whole value otherwise.`,
|
|
3788
|
+
near: repaired ? [repaired] : [],
|
|
3789
|
+
close: Boolean(repaired && repaired in TOKENS),
|
|
3790
|
+
...(repaired
|
|
3791
|
+
? {fixed: v.replace(m[0], m[0].replace(raw, repaired))}
|
|
3792
|
+
: {}),
|
|
3793
|
+
};
|
|
3794
|
+
}
|
|
3682
3795
|
for (const [, name, comma] of v.matchAll(/var\(\s*(--[a-z0-9-]+)\s*(,)?/gi)) {
|
|
3683
3796
|
if (name in TOKENS || name.startsWith('--_')) continue;
|
|
3684
3797
|
// A fallback always gives a value: never "reads nothing" (a likely
|
|
@@ -3734,3 +3847,80 @@ export function fontFileReason(value) {
|
|
|
3734
3847
|
? `"${hit}" is a font file or a link, not a font family name. A theme names a family (such as Inter); load the file with @font-face in your app's CSS, or install a font package, then set the family it defines.`
|
|
3735
3848
|
: null;
|
|
3736
3849
|
}
|
|
3850
|
+
|
|
3851
|
+
/**
|
|
3852
|
+
* A value with every Unicode space (no-break, thin, ideographic…) as a plain
|
|
3853
|
+
* space and zero-width and format characters dropped, for every value type:
|
|
3854
|
+
* the browser reads only a plain space as one.
|
|
3855
|
+
* @param {string} v
|
|
3856
|
+
*/
|
|
3857
|
+
export function normalValueText(v) {
|
|
3858
|
+
// Curly quotes (a word processor's, a phone's) are the straight ones CSS
|
|
3859
|
+
// reads.
|
|
3860
|
+
const straight = v
|
|
3861
|
+
.replace(/[\u2018\u2019\u201A\u201B]/g, "'")
|
|
3862
|
+
.replace(/[\u201C\u201D\u201E\u201F]/g, '"');
|
|
3863
|
+
// A quoted CSS string (`content: "a\u00A0b"`) keeps what is inside it.
|
|
3864
|
+
return straight
|
|
3865
|
+
.split(/("(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*')/)
|
|
3866
|
+
.map((part, i) =>
|
|
3867
|
+
i % 2
|
|
3868
|
+
? part
|
|
3869
|
+
: part
|
|
3870
|
+
.replace(/[\u200B-\u200D\u2060\uFEFF]/g, '')
|
|
3871
|
+
.replace(/[\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]/g, ' '),
|
|
3872
|
+
)
|
|
3873
|
+
.join('');
|
|
3874
|
+
}
|
|
3875
|
+
|
|
3876
|
+
/**
|
|
3877
|
+
* The thing and value a setting was typed as, put right before any check: a
|
|
3878
|
+
* declaration pasted whole or split (`accent: #e11d48`, `--color-accent=red`,
|
|
3879
|
+
* `font:inter`, `accent:` with the value next), a token typed with an em or
|
|
3880
|
+
* en dash (`—color-accent`) or as `var(--color-accent)`, and the value's
|
|
3881
|
+
* Unicode spaces. A thing it cannot read is left as typed.
|
|
3882
|
+
* @param {string} thing
|
|
3883
|
+
* @param {string | undefined} value
|
|
3884
|
+
* @returns {{thing: string, value: string | undefined}}
|
|
3885
|
+
*/
|
|
3886
|
+
export function normalizeEntry(thing, value) {
|
|
3887
|
+
let t = normalValueText(String(thing ?? '')).trim();
|
|
3888
|
+
let v = value == null ? value : normalValueText(String(value));
|
|
3889
|
+
// A pasted declaration (the whole of it in the thing, or the thing with
|
|
3890
|
+
// its colon and the value next): its `;` and `!important` go with it.
|
|
3891
|
+
let pasted = false;
|
|
3892
|
+
if (v == null || v.trim() === '') {
|
|
3893
|
+
const m = /^(\S+?)\s*[:=]\s*(.+?)\s*;?\s*$/.exec(t);
|
|
3894
|
+
if (m && !/^https?$/i.test(m[1])) {
|
|
3895
|
+
t = m[1];
|
|
3896
|
+
v = m[2];
|
|
3897
|
+
pasted = true;
|
|
3898
|
+
}
|
|
3899
|
+
}
|
|
3900
|
+
// A thing ending in its colon or equals sign, the value given next.
|
|
3901
|
+
if (/\s*[:=]+$/.test(t)) {
|
|
3902
|
+
t = t.replace(/\s*[:=]+$/, '');
|
|
3903
|
+
pasted = true;
|
|
3904
|
+
}
|
|
3905
|
+
// Dash-like characters where a token's two dashes go (an em or en dash,
|
|
3906
|
+
// a non-breaking hyphen, a minus sign, a full-width hyphen, alone or
|
|
3907
|
+
// mixed with hyphens): `--`.
|
|
3908
|
+
t = t.replace(/^[-\u2010-\u2015\u2212\uFE58\uFE63\uFF0D]+/, run =>
|
|
3909
|
+
/[^-]/.test(run) ? '--' : run,
|
|
3910
|
+
);
|
|
3911
|
+
// A token typed as a var() reference.
|
|
3912
|
+
const ref = /^var\(\s*(--[a-z0-9-]+)\s*\)$/i.exec(t);
|
|
3913
|
+
if (ref) t = ref[1];
|
|
3914
|
+
if (pasted && typeof v === 'string')
|
|
3915
|
+
v = v.replace(/\s*!\s*important\s*;?\s*$/i, '').replace(/;+\s*$/, '');
|
|
3916
|
+
return {thing: t, value: v};
|
|
3917
|
+
}
|
|
3918
|
+
|
|
3919
|
+
/**
|
|
3920
|
+
* A word as a suggested command quotes it, without the quotes.
|
|
3921
|
+
* @param {string} word
|
|
3922
|
+
*/
|
|
3923
|
+
function unquoteArg(word) {
|
|
3924
|
+
const m = /^'(.*)'$/s.exec(word.trim());
|
|
3925
|
+
return m ? m[1].replace(/'\\''/g, "'") : word.trim();
|
|
3926
|
+
}
|
|
@@ -113,9 +113,10 @@ export function fontNotes(ctx: import("./_settings.mjs").Ctx, data: import("./_s
|
|
|
113
113
|
* What a change did to part styles (component settings), one line each.
|
|
114
114
|
* @param {any} before
|
|
115
115
|
* @param {any} after
|
|
116
|
+
* @param {any} [base] the base theme, whose own values a write that repeats them does not change
|
|
116
117
|
* @returns {string[]}
|
|
117
118
|
*/
|
|
118
|
-
export function styledChanges(before: any, after: any): string[];
|
|
119
|
+
export function styledChanges(before: any, after: any, base?: any): string[];
|
|
119
120
|
/**
|
|
120
121
|
* Previews after a change: the sample page always, pictures on request.
|
|
121
122
|
* @param {import('./_settings.mjs').Ctx} ctx
|
|
@@ -539,11 +539,21 @@ export function fontNotes(ctx, data) {
|
|
|
539
539
|
* What a change did to part styles (component settings), one line each.
|
|
540
540
|
* @param {any} before
|
|
541
541
|
* @param {any} after
|
|
542
|
+
* @param {any} [base] the base theme, whose own values a write that repeats them does not change
|
|
542
543
|
* @returns {string[]}
|
|
543
544
|
*/
|
|
544
|
-
export function styledChanges(before, after) {
|
|
545
|
+
export function styledChanges(before, after, base) {
|
|
545
546
|
/** @type {string[]} */
|
|
546
547
|
const out = [];
|
|
548
|
+
/** A value as CSS reads it, for comparing. @param {any} v */
|
|
549
|
+
const plain = v =>
|
|
550
|
+
(Array.isArray(v) && v.length === 2
|
|
551
|
+
? `light-dark(${v[0]}, ${v[1]})`
|
|
552
|
+
: String(v ?? '')
|
|
553
|
+
)
|
|
554
|
+
.replace(/\s+/g, ' ')
|
|
555
|
+
.trim()
|
|
556
|
+
.toLowerCase();
|
|
547
557
|
const a = before?.components ?? {};
|
|
548
558
|
const b = after?.components ?? {};
|
|
549
559
|
for (const target of new Set([...Object.keys(a), ...Object.keys(b)])) {
|
|
@@ -560,6 +570,14 @@ export function styledChanges(before, after) {
|
|
|
560
570
|
: p.replace(/[A-Z]/g, c => `-${c.toLowerCase()}`);
|
|
561
571
|
for (const prop of new Set([...Object.keys(x), ...Object.keys(y)])) {
|
|
562
572
|
if (JSON.stringify(x[prop]) === JSON.stringify(y[prop])) continue;
|
|
573
|
+
// Writing what the base theme already shows there changes nothing.
|
|
574
|
+
const shown = base?.components?.[target]?.[key]?.[prop];
|
|
575
|
+
if (
|
|
576
|
+
x[prop] === undefined &&
|
|
577
|
+
shown !== undefined &&
|
|
578
|
+
plain(shown) === plain(y[prop])
|
|
579
|
+
)
|
|
580
|
+
continue;
|
|
563
581
|
const where = `${target}${key === 'base' ? '' : ` ${key}`}`;
|
|
564
582
|
// A state block (`:hover`) lists each property it changes.
|
|
565
583
|
if (
|
|
@@ -30,6 +30,22 @@ export function newFlagList(like: string | null | undefined, settings: Record<st
|
|
|
30
30
|
* @returns {Promise<import('./theme-edit.type.mjs').ThemeEditChangeResponse>}
|
|
31
31
|
*/
|
|
32
32
|
export function themeEditSet(theme: string, thing: string, value: string, options?: ChangeOptions): Promise<import("./theme-edit.type.mjs").ThemeEditChangeResponse>;
|
|
33
|
+
/**
|
|
34
|
+
* For `compile`: the refusal `show` gives for saved settings the editor no
|
|
35
|
+
* longer accepts (naming the undo that removes each), or null.
|
|
36
|
+
* @param {string} root
|
|
37
|
+
* @param {string} slug
|
|
38
|
+
* @returns {Promise<import('../error.mjs').AstryxError | null>}
|
|
39
|
+
*/
|
|
40
|
+
export function editorStoredRefusal(root: string, slug: string): Promise<import("../error.mjs").AstryxError | null>;
|
|
41
|
+
/**
|
|
42
|
+
* For `compile`: the refusal of [light, dark] pairs on tokens that are not
|
|
43
|
+
* colors in what the theme builds now, or null.
|
|
44
|
+
* @param {string} root
|
|
45
|
+
* @param {string} slug
|
|
46
|
+
* @returns {Promise<import('../error.mjs').AstryxError | null>}
|
|
47
|
+
*/
|
|
48
|
+
export function editorPairRefusal(root: string, slug: string): Promise<import("../error.mjs").AstryxError | null>;
|
|
33
49
|
/**
|
|
34
50
|
* Every setting of a theme, key resolved values, problems it caused, the
|
|
35
51
|
* sample page and the theme-building page with every component.
|