@motion-proto/live-tokens 0.52.1 → 0.54.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/.claude/skills/live-tokens-adjust-shape-space/SKILL.md +28 -3
- package/.claude/skills/live-tokens-generate-theme/SKILL.md +16 -1
- package/CHANGELOG.md +89 -0
- package/bin/adjust.mjs +16 -39
- package/bin/generate-theme.mjs +21 -6
- package/dist-plugin/adjust/index.cjs +785 -21
- package/dist-plugin/adjust/index.d.cts +2 -1
- package/dist-plugin/adjust/index.d.ts +2 -1
- package/dist-plugin/adjust/index.js +47 -21
- package/dist-plugin/{chunk-6OZFXIQI.js → chunk-232GZGQU.js} +207 -12
- package/dist-plugin/chunk-NE6N66EE.js +753 -0
- package/dist-plugin/{chunk-JIGIIE5P.js → chunk-PB2JTK2H.js} +123 -0
- package/dist-plugin/generateColorsAndType/index.cjs +110 -31
- package/dist-plugin/generateColorsAndType/index.d.cts +6 -2
- package/dist-plugin/generateColorsAndType/index.d.ts +6 -2
- package/dist-plugin/generateColorsAndType/index.js +69 -772
- package/dist-plugin/{themeTypes-Dky03HL9.d.cts → index-DpTIRZ2H.d.cts} +49 -21
- package/dist-plugin/{themeTypes-Dky03HL9.d.ts → index-DpTIRZ2H.d.ts} +49 -21
- package/dist-plugin/index.cjs +1159 -85
- package/dist-plugin/index.js +102 -80
- package/dist-plugin/migrateData/index.cjs +956 -14
- package/dist-plugin/migrateData/index.js +10 -3
- package/package.json +6 -4
- package/src/editor/component-editor/scaffolding/ComponentFileManager.svelte +9 -23
- package/src/editor/component-editor/scaffolding/LinkedBlock.svelte +8 -8
- package/src/editor/core/components/adjustAliases.ts +65 -22
- package/src/editor/core/components/aliasKinds.ts +7 -2
- package/src/editor/core/components/componentConfigService.ts +1 -1
- package/src/editor/core/store/editorStore.ts +7 -197
- package/src/editor/core/store/editorTypes.ts +9 -30
- package/src/editor/core/themes/generateColorsAndType.ts +50 -1
- package/src/editor/core/themes/lookSummary.ts +3 -25
- package/src/editor/core/themes/migrateComponentConfig.ts +205 -0
- package/src/editor/core/themes/migrations/2026-05-19-sectiondivider-rich-gradient.ts +1 -1
- package/src/editor/core/themes/migrations/2026-05-20-sectiondivider-slim-variants.ts +1 -1
- package/src/editor/core/themes/migrations/2026-05-22-sectiondivider-intrinsics-to-css.ts +1 -1
- package/src/editor/core/themes/parsers/gradient.ts +211 -0
- package/src/editor/core/themes/parsers/shadow.ts +52 -0
- package/src/editor/core/themes/slices/gradients.ts +5 -58
- package/src/editor/core/themes/slices/shadows.ts +2 -38
- package/src/editor/core/themes/themeService.ts +22 -9
- package/src/editor/core/themes/themeTypes.ts +71 -21
- package/src/editor/docs/content/themes-workflow.md +9 -11
- package/src/editor/docs/content/where-themes-live.md +2 -2
- package/src/editor/docs/content.generated.ts +2 -2
- package/src/editor/index.ts +1 -0
- package/src/editor/styles/ui-editor.css +5 -2
- package/src/editor/ui/PaletteEditor.svelte +30 -15
- package/src/editor/ui/ThemePanel.svelte +24 -15
- package/src/editor/ui/Toggle.svelte +22 -22
- package/src/editor/ui/UIPillButton.svelte +1 -1
- package/src/editor/ui/UIReveal.svelte +47 -0
- package/src/editor/ui/UISquareButton.svelte +1 -1
- package/src/editor/ui/colors/ColorsTab.svelte +4 -5
- package/src/editor/ui/palette/OverridesPanel.svelte +4 -3
- package/src/editor/ui/palette/PaletteJumpButton.svelte +3 -3
- package/src/editor/ui/palette/ScaleCurveEditor.svelte +3 -2
- package/src/live-tokens/data/colors-and-type/autumn.json +5 -5
- package/src/live-tokens/data/colors-and-type/ocean.json +5 -5
- package/src/live-tokens/data/colors-and-type/spring-meadow.json +5 -5
- package/src/live-tokens/data/themes/autumn.json +82 -46
- package/src/live-tokens/data/themes/halloween.json +53 -52
- package/src/live-tokens/data/themes/midnight-study.json +151 -83
- package/src/live-tokens/data/themes/ocean.json +82 -46
- package/src/live-tokens/data/themes/royal-velvet.json +43 -42
- package/src/live-tokens/data/themes/spring-meadow.json +91 -57
- package/src/live-tokens/data/themes/sunset.json +101 -40
- package/src/system/components/FloatingTokenTags.css +6 -4
- package/src/system/internal/backgroundContrast.ts +2 -1
|
@@ -11,7 +11,7 @@ You translate the request into a small ops file; the CLI resolves each matching
|
|
|
11
11
|
|
|
12
12
|
1. Write the ops file to a temp path (not the project tree), e.g. `/tmp/adjust-ops.json`.
|
|
13
13
|
2. Run `npx live-tokens adjust /tmp/adjust-ops.json`. It writes `component-configs/<id>/_working.json` for every component the ops change, which is the buffer the page already runs. `--dry-run` prints the report without writing.
|
|
14
|
-
3. Read the report card: every changed alias old → new, plus skips (raw value, off the ladder, already at the ladder end, pill preserved). Exit 1 means the run was rejected; the message names the offending op or the missing input, so fix it and re-run.
|
|
14
|
+
3. Read the report card: every changed alias old → new, plus skips (raw value, off the ladder, already at the ladder end, pill preserved). Exit 1 means the run was rejected; the message names the offending op or the missing input, so fix it and re-run. Read where the controls landed, not only that the run succeeded: a button, badge, input, or tab padding sitting at `--space-6` is on its floor, and one that also carries `--radius-full` wants a targeted lift.
|
|
15
15
|
4. Tell the user to reload the app and look. Offer the inverse op as the undo, and say the edit is unsaved until they save the open theme.
|
|
16
16
|
|
|
17
17
|
Each run reads the LIVE config (buffer, else the open theme, else the shipped default), so "a bit more" and "back one" compound naturally.
|
|
@@ -40,7 +40,7 @@ Targeted, absolute:
|
|
|
40
40
|
|
|
41
41
|
| Request | Ops |
|
|
42
42
|
|---|---|
|
|
43
|
-
| pill, capsule | radius `set: "--radius-full"
|
|
43
|
+
| pill, capsule | radius `set: "--radius-full"`, plus the padding the pill needs (see below) |
|
|
44
44
|
| sharp, square corners | radius `set: "--radius-none"`, or `--radius-sm` for "mostly sharp" |
|
|
45
45
|
| rounded (a named component) | radius `shift: 2` |
|
|
46
46
|
| softer, rounder (global) | radius `shift: 1` to `2`, no `full` |
|
|
@@ -52,9 +52,33 @@ Targeted, absolute:
|
|
|
52
52
|
|
|
53
53
|
Magnitude words: "slightly" or "a bit" is 1 step, unqualified is 1 to 2, "much", "way", or "really" is 2 to 3. Mood words often mean both axes: "softer" is rounder plus airier, "compact" is tighter padding plus smaller gaps.
|
|
54
54
|
|
|
55
|
+
## Controls squeeze before containers
|
|
56
|
+
|
|
57
|
+
A global op spends the same number of steps everywhere, but a step costs a control far more than a container. `padding shift: -2` takes a card from a 16px inset to 10px and it is still a card. It takes a button from 8 to 4, doubled to 8px at each end, around an 18px line. The button stops reading as a button.
|
|
58
|
+
|
|
59
|
+
So a global compaction is `shift: -1`. When the brief wants more, spend the extra steps on the containers by name (`card`, `dialog`, `panel`, `sidenavigation`, `table`, `codesnippet`) and leave the controls alone. Loosening is not symmetric: airier is safe globally, because nothing breaks by growing.
|
|
60
|
+
|
|
61
|
+
A pill needs the room most. `--radius-full` bends the corner in over the first and last glyph, so a capsule wants more horizontal inset than a square-cornered control, never less. `--space-8` is the floor for a large-text pill, which is where compact Midnight Study sits; the roomier pill presets (Ocean, Sunset, Royal Velvet) run `--space-10` to `--space-12`. Pair the radius op with a padding `set` on the same target, placed after any global compaction so it wins outright:
|
|
62
|
+
|
|
63
|
+
```json
|
|
64
|
+
{ "ops": [
|
|
65
|
+
{ "kind": "padding", "shift": -1 },
|
|
66
|
+
{ "target": "button", "kind": "radius", "set": "--radius-full" },
|
|
67
|
+
{ "target": "button", "kind": "padding", "set": "--space-10" }
|
|
68
|
+
] }
|
|
69
|
+
```
|
|
70
|
+
|
|
55
71
|
## Ladders
|
|
56
72
|
|
|
57
|
-
Radius runs `none, sm, md, lg, xl, 2xl, 3xl, 4xl`, with `full` as the gated ninth rung. Space (padding and gap) is the editor picker's subset: `0, 2, 4, 6, 8, 10, 12, 16, 20, 24, 32, 48`, so every written value stays re-editable by hand. Border width is the full `--border-width-*` scale. `set` values must be on the ladder (`--space-64` is rejected)
|
|
73
|
+
Radius runs `none, sm, md, lg, xl, 2xl, 3xl, 4xl`, with `full` as the gated ninth rung. Space (padding and gap) is the editor picker's subset: `0, 2, 4, 6, 8, 10, 12, 16, 20, 24, 32, 48`, so every written value stays re-editable by hand. Border width is the full `--border-width-*` scale. `set` values must be on the ladder (`--space-64` is rejected).
|
|
74
|
+
|
|
75
|
+
Content insets stop at `--space-4`. Below it the text sits against its own edge, so `--space-0` and `--space-2` are destinations a person picks on purpose, not ones a relative "tighter" hands you. Both stay available through the editor picker and through `set`. An alias already below the floor still moves up, and a shift that would push one under `--space-4` reports as clamped and writes nothing.
|
|
76
|
+
|
|
77
|
+
Padding that wraps a line of type stops a rung higher, at `--space-6`. The engine spots it in the config itself: a variant that also declares a `-text-font-size` is holding text, and the components that hold text double their padding horizontally, so `--space-4` there is 4px over an 18px line and 8px at each end. No shipped default puts text below `--space-6`.
|
|
78
|
+
|
|
79
|
+
The floor guards `-padding` only. Outer space is exempt, because a 2px gap between an icon and its label, or a 2px margin under a bar, is ordinary design rather than a mistake. Note that `-margin` rides the `padding` kind, so a padding op moves margins too; it just does not floor them.
|
|
80
|
+
|
|
81
|
+
An alias sitting off the subset spends its first step reaching the rung the shift points at, so `--space-2` with `shift: 1` lands on `--space-4` rather than jumping past it.
|
|
58
82
|
|
|
59
83
|
## Scope
|
|
60
84
|
|
|
@@ -64,5 +88,6 @@ Every value written is an existing token; nothing new is minted. `tokens.css`, s
|
|
|
64
88
|
|
|
65
89
|
- The CLI exits 0 and the report card lists the changes you expected, with no surprising skips.
|
|
66
90
|
- The app (dev server running) shows the new shape on each changed component after a reload.
|
|
91
|
+
- Buttons still read as buttons: the label has room at both ends, and a pill has more of it than a square-cornered control had.
|
|
67
92
|
- `component-configs/<id>/_working.json` exists for every component the report listed. That buffer is the whole change: it stays until the open theme is saved or another theme is loaded.
|
|
68
93
|
- To revert, run the inverse ops, or load a theme in the Theme panel to discard every unsaved edit.
|
|
@@ -130,6 +130,21 @@ A sky needs a committed canvas: when the Canvas seed anchors at the ramp edge
|
|
|
130
130
|
side and the engine skips the sky, saying so in the report. An atmospheric
|
|
131
131
|
brief that wants one should already be at canvas commitment level 2–3.
|
|
132
132
|
|
|
133
|
+
## Shadow weight follows the canvas
|
|
134
|
+
|
|
135
|
+
The engine sets the opacity of the `--shadow-*` scale from the Canvas seed's
|
|
136
|
+
lightness and carries each shadow's geometry and color through untouched. A
|
|
137
|
+
near-black shadow at 0.9 opacity is what a dark ground needs to show any
|
|
138
|
+
shadow at all, and it punches a hole in paper, so opacity holds at 0.9 up to
|
|
139
|
+
canvas L 0.5 and eases to 0.2 by L 0.9. There is nothing to choose: the report
|
|
140
|
+
prints the derived value, and every regeneration re-derives it, so a brief
|
|
141
|
+
iterated from a light canvas to a dark one gets its weight back.
|
|
142
|
+
|
|
143
|
+
When the user says the shadows read heavy, muddy, or dirty, the canvas is the
|
|
144
|
+
lever. Raise the Canvas seed's lightness and the shadows lighten with it. A
|
|
145
|
+
one-off override lives in the editor's Shadows tab and survives regeneration
|
|
146
|
+
in everything except opacity.
|
|
147
|
+
|
|
133
148
|
## Named themes (canonical OKLCH anchors)
|
|
134
149
|
|
|
135
150
|
Holiday briefs are statement briefs — default to commitment level 2–3 above, not cream. The named colors go on the *ground*, not just the buttons.
|
|
@@ -143,7 +158,7 @@ Holiday briefs are statement briefs — default to commitment level 2–3 above,
|
|
|
143
158
|
|
|
144
159
|
## Scope
|
|
145
160
|
|
|
146
|
-
Fonts are never touched (they carry forward from the live look, as do
|
|
161
|
+
Fonts are never touched (they carry forward from the live look, as do component aliases and shadow geometry; shadow opacity is derived, see above). Swatch gradients (`--gradient-1..4`) carry forward when user-tuned; if they are absent or still stock, the engine rebuilds them from the new theme's families — you never author them. Radius is out of scope for generation. Shipping the theme stays a human action: Adopt, in the editor.
|
|
147
162
|
|
|
148
163
|
## Verify
|
|
149
164
|
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,94 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.54.0 — Shadow weight and text insets follow their context
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
|
|
7
|
+
- **Padding that holds text stops at `--space-6`.** One floor for every inset
|
|
8
|
+
treated a card and a button alike, but the components that hold text double
|
|
9
|
+
their padding horizontally, so `--space-4` on a button is 4px over an 18px
|
|
10
|
+
line and 8px at each end. `adjust` now reads which floor applies off the
|
|
11
|
+
config itself: a variant that also declares a `-text-font-size` is holding
|
|
12
|
+
type. Containers keep the `--space-4` floor, `-margin` and `-gap` stay
|
|
13
|
+
exempt, and both rungs stay reachable by `set` and by the editor picker.
|
|
14
|
+
Midnight Study shipped with every text inset on the old floor, its pill
|
|
15
|
+
buttons worst of all; its controls move up, and the six full-size button
|
|
16
|
+
variants to `--space-8` so the capsule has room for its label.
|
|
17
|
+
|
|
18
|
+
### Changed
|
|
19
|
+
|
|
20
|
+
- **Shadow weight follows the canvas.** The `--shadow-*` scale was one fixed
|
|
21
|
+
near-black at 0.9 opacity in every theme, which is what a dark ground needs
|
|
22
|
+
and what puts a smudge under every card on a light one. `generate-theme` now
|
|
23
|
+
derives the opacity from the Canvas seed's lightness: 0.9 holds up to L 0.5
|
|
24
|
+
and eases to 0.2 by L 0.9. Geometry and color carry forward untouched, so a
|
|
25
|
+
hand-tuned elevation ramp survives regeneration. The three light presets
|
|
26
|
+
(Ocean, Spring Meadow, Autumn) ship with the derived values; the dark presets
|
|
27
|
+
and the default theme are unchanged.
|
|
28
|
+
|
|
29
|
+
## 0.53.0 — Themes are complete documents
|
|
30
|
+
|
|
31
|
+
### Fixed
|
|
32
|
+
|
|
33
|
+
- **The editor no longer imports build tooling.** `themeService.ts` and
|
|
34
|
+
`themeTypes.ts` read `THEME_SCHEMA_VERSION` from
|
|
35
|
+
`vite-plugin/themes/normalizeTheme`, a path that resolves in this repository
|
|
36
|
+
and in no installed copy, because the tarball ships no tooling. Any consumer
|
|
37
|
+
building the editor failed on an unresolved import. The constant now lives in
|
|
38
|
+
`themeTypes.ts` and the plugin re-exports it. `check:no-tooling-imports`
|
|
39
|
+
gates the direction.
|
|
40
|
+
|
|
41
|
+
### Changed
|
|
42
|
+
|
|
43
|
+
- **Content insets stop at `--space-4`.** Below it the text sits against its
|
|
44
|
+
own edge, so a relative "tighter" no longer deposits a `-padding` alias on
|
|
45
|
+
`--space-0` or `--space-2`. Both stay available in the editor picker and
|
|
46
|
+
through an explicit `set` op, which is where that call belongs. A shift that
|
|
47
|
+
would push an alias under the floor reports as clamped and writes nothing.
|
|
48
|
+
Outer space is exempt: a 2px gap between an icon and its label, or a 2px
|
|
49
|
+
margin under a bar, is ordinary design.
|
|
50
|
+
|
|
51
|
+
- **An off-ladder value spends its first step reaching the ladder.** Shifting
|
|
52
|
+
such a value used to snap it to the nearest rung and then apply the full
|
|
53
|
+
shift on top, so a one-step request moved two visible steps, and an
|
|
54
|
+
above-ladder value could be quietly pulled *down* by a request to go up.
|
|
55
|
+
The snap now follows the shift's direction and counts as its opening step.
|
|
56
|
+
This retires the report card's `!` marker, which existed only to flag that
|
|
57
|
+
backwards case.
|
|
58
|
+
|
|
59
|
+
- **Themes are complete documents.** A theme now stores every component and
|
|
60
|
+
every alias, by value, at `schemaVersion` 4. Boot migrates and fills a
|
|
61
|
+
local theme once; an incomplete imported theme still loads with whatever
|
|
62
|
+
components it carries, filled from the current defaults, and the fill is
|
|
63
|
+
reported in the Theme panel. The preset generator that re-derived the
|
|
64
|
+
seven shipped presets on every run is gone. `seed-preset-theme.mjs <slug>`
|
|
65
|
+
seeds a new preset once and `check:preset-themes` guards the shipped seven
|
|
66
|
+
against drift.
|
|
67
|
+
|
|
68
|
+
### Fixed
|
|
69
|
+
|
|
70
|
+
- **`generate-theme` no longer inherits gaps from an incomplete open theme.**
|
|
71
|
+
The live resolution path gained the missing default layer, so a theme
|
|
72
|
+
missing a component no longer leaves the generator working from a hole.
|
|
73
|
+
- **A pre-rename alias key in an old theme is migrated before the bake**,
|
|
74
|
+
instead of being emitted verbatim into `tokens.generated.css`.
|
|
75
|
+
- **A component's gradient default survives a fresh checkout.** The dev
|
|
76
|
+
server derives `component-configs/<comp>/default.json` from the component's
|
|
77
|
+
`:global(:root)` block, and it could not read a baked gradient back. On a
|
|
78
|
+
tree with no prior file it dropped the alias. It now parses the gradient
|
|
79
|
+
into its structured form, so the derivation covers every value the bake
|
|
80
|
+
emits.
|
|
81
|
+
- **A radial gradient bakes the shape the editor shows.** The production bake
|
|
82
|
+
carried its own copy of the gradient renderer, which ignored the centre and
|
|
83
|
+
both aspect factors and wrote `circle … at center` for every radial. Both
|
|
84
|
+
sides now share one renderer.
|
|
85
|
+
- **The shipped `panel` aliases sit in derivation order.** `Panel.svelte`
|
|
86
|
+
declares `--panel-stage-surface` before the stage spacing, but every
|
|
87
|
+
committed copy carried it last. On a fresh checkout, where the component
|
|
88
|
+
source is newer than the data tree, boot re-derived `default.json` into
|
|
89
|
+
source order while the seven presets kept the old one, and the preset gate
|
|
90
|
+
read two different key orders. The committed data now matches the source.
|
|
91
|
+
|
|
3
92
|
## 0.52.1 — Notification header actions are previewable
|
|
4
93
|
|
|
5
94
|
### Fixed
|
package/bin/adjust.mjs
CHANGED
|
@@ -18,7 +18,6 @@ const packageThemesDir = join(pkgRoot, 'src/live-tokens/data/themes');
|
|
|
18
18
|
const SOURCE_LABELS = {
|
|
19
19
|
working: 'your unsaved edits',
|
|
20
20
|
theme: 'the open theme',
|
|
21
|
-
default: 'the shipped default',
|
|
22
21
|
};
|
|
23
22
|
|
|
24
23
|
const SKIP_LABELS = [
|
|
@@ -46,35 +45,6 @@ function readJsonIfExists(path) {
|
|
|
46
45
|
return existsSync(path) ? readJson(path) : null;
|
|
47
46
|
}
|
|
48
47
|
|
|
49
|
-
function numericRung(token) {
|
|
50
|
-
const match = /-(\d+)$/.exec(token);
|
|
51
|
-
return match ? Number(match[1]) : null;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/** Net direction the ops asked for on this alias. An explicit `set` owns the
|
|
55
|
-
* value outright, so it reports no direction. */
|
|
56
|
-
function requestedDirection(ops, matchesKind, component, variable) {
|
|
57
|
-
let total = 0;
|
|
58
|
-
for (const op of ops) {
|
|
59
|
-
if (op.target !== undefined && op.target !== component) continue;
|
|
60
|
-
if (!matchesKind(variable, op.kind)) continue;
|
|
61
|
-
if (op.shift === undefined) return 0;
|
|
62
|
-
total += op.shift;
|
|
63
|
-
}
|
|
64
|
-
return Math.sign(total);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/** A shift can land below where it started: an off-subset value (`--space-64`)
|
|
68
|
-
* snaps to its nearest writable rung first. Those changes are marked, never
|
|
69
|
-
* listed as an ordinary shift. */
|
|
70
|
-
function opposesShift(ops, matchesKind, component, change) {
|
|
71
|
-
const from = numericRung(change.from);
|
|
72
|
-
const to = numericRung(change.to);
|
|
73
|
-
if (from === null || to === null) return false;
|
|
74
|
-
const direction = requestedDirection(ops, matchesKind, component, change.variable);
|
|
75
|
-
return direction !== 0 && Math.sign(to - from) !== direction;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
48
|
/** Successive ops can touch the same alias (soften, then pill the buttons);
|
|
79
49
|
* the report shows one entry per alias, first `from` to last `to`. */
|
|
80
50
|
function collapseChanges(changes) {
|
|
@@ -98,9 +68,11 @@ function readActiveTheme(themesDir) {
|
|
|
98
68
|
return theme ? { slug, theme } : null;
|
|
99
69
|
}
|
|
100
70
|
|
|
101
|
-
/** Each component's live config and
|
|
102
|
-
*
|
|
103
|
-
*
|
|
71
|
+
/** Each component's live config, and whether a buffer or the open document
|
|
72
|
+
* answered. The document's own copy falls back to the shipped default for a
|
|
73
|
+
* component it somehow lacks, which reports as the document either way.
|
|
74
|
+
* Mirrors the dev server's `resolveLiveComponentConfig`, so the CLI adjusts
|
|
75
|
+
* what the page runs. */
|
|
104
76
|
function readLiveConfigs(dir, active) {
|
|
105
77
|
const configs = {};
|
|
106
78
|
const sources = {};
|
|
@@ -109,13 +81,19 @@ function readLiveConfigs(dir, active) {
|
|
|
109
81
|
const comp = entry.name;
|
|
110
82
|
const componentDir = join(dir, comp);
|
|
111
83
|
const working = readJsonIfExists(join(componentDir, '_working.json'));
|
|
112
|
-
|
|
113
|
-
|
|
84
|
+
// Every theme carries every component by value, but this CLI reads the
|
|
85
|
+
// file straight off disk, ahead of any server-side fill — a theme
|
|
86
|
+
// written before this component existed can still omit it, so a missing
|
|
87
|
+
// entry falls back to the shipped default the same way the theme's own
|
|
88
|
+
// fill would.
|
|
89
|
+
const embedded =
|
|
90
|
+
active?.theme?.componentConfigs?.[comp] ?? readJsonIfExists(join(componentDir, 'default.json'));
|
|
91
|
+
const config = working ?? embedded;
|
|
114
92
|
if (!config) {
|
|
115
93
|
throw new Error(`component "${comp}": default.json is missing`);
|
|
116
94
|
}
|
|
117
95
|
configs[comp] = { ...config, component: comp };
|
|
118
|
-
sources[comp] = working ? 'working' :
|
|
96
|
+
sources[comp] = working ? 'working' : 'theme';
|
|
119
97
|
}
|
|
120
98
|
return { configs, sources };
|
|
121
99
|
}
|
|
@@ -173,7 +151,7 @@ export async function runAdjust({
|
|
|
173
151
|
components.push({
|
|
174
152
|
component,
|
|
175
153
|
source: sources[component],
|
|
176
|
-
changes
|
|
154
|
+
changes,
|
|
177
155
|
skips,
|
|
178
156
|
});
|
|
179
157
|
}
|
|
@@ -228,8 +206,7 @@ export function formatAdjustResult(result) {
|
|
|
228
206
|
|
|
229
207
|
const width = Math.max(0, ...entry.changes.map((c) => c.variable.length));
|
|
230
208
|
for (const c of entry.changes) {
|
|
231
|
-
|
|
232
|
-
lines.push(` ${c.snapped ? '!' : ' '} ${c.variable.padEnd(width)} ${c.from} → ${c.to}${note}`);
|
|
209
|
+
lines.push(` ${c.variable.padEnd(width)} ${c.from} → ${c.to}`);
|
|
233
210
|
}
|
|
234
211
|
|
|
235
212
|
for (const [reason, label] of SKIP_LABELS) {
|
package/bin/generate-theme.mjs
CHANGED
|
@@ -21,7 +21,9 @@ import { fileURLToPath } from 'node:url';
|
|
|
21
21
|
const pkgRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..');
|
|
22
22
|
const ENGINE = resolve(pkgRoot, 'dist-plugin/generateColorsAndType/index.js');
|
|
23
23
|
const packageDataDir = join(pkgRoot, 'src/live-tokens/data');
|
|
24
|
-
|
|
24
|
+
// Source of truth: vite-plugin/themes/normalizeTheme.ts. This copy cannot
|
|
25
|
+
// import TS, so `check:preset-themes` (Wave 5) is what catches a drift.
|
|
26
|
+
const THEME_SCHEMA_VERSION = 4;
|
|
25
27
|
|
|
26
28
|
async function loadEngine() {
|
|
27
29
|
if (!existsSync(ENGINE)) {
|
|
@@ -69,11 +71,18 @@ function stripMarkers(value) {
|
|
|
69
71
|
return rest;
|
|
70
72
|
}
|
|
71
73
|
|
|
74
|
+
/** A component's derived default, local tree first, then the installed
|
|
75
|
+
* package's shipped copy — same fallback order every other read here uses. */
|
|
76
|
+
function defaultComponentConfig(componentConfigsDir, comp) {
|
|
77
|
+
return readData(join(componentConfigsDir, comp), `component-configs/${comp}`, 'default');
|
|
78
|
+
}
|
|
79
|
+
|
|
72
80
|
/**
|
|
73
81
|
* The look the new theme carries forward. Without --carry-from that is the LIVE
|
|
74
82
|
* state — buffer first, then the open theme, then the shipped default — because
|
|
75
83
|
* what the user sees is what they expect to keep. With it, the named theme,
|
|
76
|
-
*
|
|
84
|
+
* then the shipped default for anything that theme omits, so an incomplete
|
|
85
|
+
* source never produces an incomplete result.
|
|
77
86
|
*/
|
|
78
87
|
function resolveCarrySource({ carryFrom, colorsAndTypeDir, componentConfigsDir, themesDir }) {
|
|
79
88
|
const comps = componentNames(componentConfigsDir);
|
|
@@ -83,7 +92,7 @@ function resolveCarrySource({ carryFrom, colorsAndTypeDir, componentConfigsDir,
|
|
|
83
92
|
if (!theme) throw new Error(`--carry-from theme "${carryFrom}" not found`);
|
|
84
93
|
const componentConfigs = {};
|
|
85
94
|
for (const comp of comps) {
|
|
86
|
-
const cfg = theme.componentConfigs?.[comp];
|
|
95
|
+
const cfg = theme.componentConfigs?.[comp] ?? defaultComponentConfig(componentConfigsDir, comp);
|
|
87
96
|
if (cfg) componentConfigs[comp] = stripMarkers(cfg);
|
|
88
97
|
}
|
|
89
98
|
return { colorsAndType: stripMarkers(theme.colorsAndType), componentConfigs };
|
|
@@ -98,12 +107,15 @@ function resolveCarrySource({ carryFrom, colorsAndTypeDir, componentConfigsDir,
|
|
|
98
107
|
);
|
|
99
108
|
|
|
100
109
|
// A working buffer is an unsaved delta from the active theme; absent theme
|
|
101
|
-
// component entries fall through to the component defaults.
|
|
110
|
+
// component entries fall through to the component defaults. Mirrors
|
|
111
|
+
// `bin/adjust.mjs`'s `readLiveConfigs` and the dev server's
|
|
112
|
+
// `resolveLiveComponentConfig` — all three layers, in the same order.
|
|
102
113
|
const componentConfigs = {};
|
|
103
114
|
for (const comp of comps) {
|
|
104
115
|
const live =
|
|
105
116
|
readJsonIfExists(join(componentConfigsDir, comp, '_working.json')) ??
|
|
106
|
-
activeTheme?.componentConfigs?.[comp]
|
|
117
|
+
activeTheme?.componentConfigs?.[comp] ??
|
|
118
|
+
defaultComponentConfig(componentConfigsDir, comp);
|
|
107
119
|
if (live) componentConfigs[comp] = stripMarkers(live);
|
|
108
120
|
}
|
|
109
121
|
return { colorsAndType, componentConfigs };
|
|
@@ -121,7 +133,8 @@ export async function runGenerateTheme({
|
|
|
121
133
|
themesDir,
|
|
122
134
|
engine,
|
|
123
135
|
} = {}) {
|
|
124
|
-
const { buildColorsAndTypeFromSeeds, resolveDataDirs } =
|
|
136
|
+
const { buildColorsAndTypeFromSeeds, resolveDataDirs, CURRENT_COMPONENT_SCHEMA_VERSION } =
|
|
137
|
+
engine ?? (await loadEngine());
|
|
125
138
|
|
|
126
139
|
const briefFull = resolve(root, briefPath);
|
|
127
140
|
if (!existsSync(briefFull)) {
|
|
@@ -162,6 +175,7 @@ export async function runGenerateTheme({
|
|
|
162
175
|
schemaVersion: THEME_SCHEMA_VERSION,
|
|
163
176
|
colorsAndType,
|
|
164
177
|
componentConfigs: carry.componentConfigs,
|
|
178
|
+
componentSchemaVersion: CURRENT_COMPONENT_SCHEMA_VERSION,
|
|
165
179
|
};
|
|
166
180
|
|
|
167
181
|
if (!dryRun) {
|
|
@@ -227,6 +241,7 @@ export function formatGenerateThemeResult(result) {
|
|
|
227
241
|
? '\nGradients: kept your tuned swatch gradients.'
|
|
228
242
|
: '\nGradients: swatch tokens rebuilt from the theme families.',
|
|
229
243
|
);
|
|
244
|
+
lines.push(`Shadows: ${result.report.shadows}; carried geometry kept.`);
|
|
230
245
|
if (result.report.canvasGradient) {
|
|
231
246
|
lines.push(`Canvas sky: ${result.report.canvasGradient}.`);
|
|
232
247
|
}
|