@motion-proto/live-tokens 0.9.0 → 0.10.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.
Files changed (49) hide show
  1. package/README.md +50 -29
  2. package/dist-plugin/index.cjs +177 -125
  3. package/dist-plugin/index.d.cts +3 -2
  4. package/dist-plugin/index.d.ts +3 -2
  5. package/dist-plugin/index.js +177 -125
  6. package/package.json +4 -1
  7. package/src/editor/component-editor/BadgeEditor.svelte +44 -42
  8. package/src/editor/component-editor/ButtonEditor.svelte +224 -0
  9. package/src/editor/component-editor/CollapsibleSectionEditor.svelte +1 -7
  10. package/src/editor/component-editor/CornerBadgeEditor.svelte +44 -34
  11. package/src/editor/component-editor/ImageLightboxEditor.svelte +58 -0
  12. package/src/editor/component-editor/InputEditor.svelte +272 -0
  13. package/src/editor/component-editor/NotificationEditor.svelte +44 -65
  14. package/src/editor/component-editor/ProgressBarEditor.svelte +71 -87
  15. package/src/editor/component-editor/SegmentedControlEditor.svelte +98 -37
  16. package/src/editor/component-editor/SideNavigationEditor.svelte +342 -0
  17. package/src/editor/component-editor/registry.ts +35 -2
  18. package/src/editor/component-editor/scaffolding/ComponentFileManager.svelte +3 -2
  19. package/src/editor/component-editor/scaffolding/StateBlock.svelte +9 -10
  20. package/src/editor/component-editor/scaffolding/TokenLayout.svelte +60 -36
  21. package/src/editor/component-editor/scaffolding/VariantGroup.svelte +38 -1
  22. package/src/editor/component-editor/scaffolding/buildTypeGroupTokens.ts +1 -1
  23. package/src/editor/component-editor/scaffolding/siblings.ts +2 -2
  24. package/src/editor/component-editor/scaffolding/types.ts +2 -1
  25. package/src/editor/core/components/componentConfigService.ts +7 -6
  26. package/src/editor/core/manifests/manifestService.ts +5 -4
  27. package/src/editor/core/storage/apiBase.ts +15 -0
  28. package/src/editor/core/storage/files/versionedFileResourceClient.ts +1 -1
  29. package/src/editor/core/themes/migrations/2026-05-24-collapsiblesection-drop-active-state.ts +28 -0
  30. package/src/editor/core/themes/migrations/2026-05-24-progressbar-collapse-variants.ts +41 -0
  31. package/src/editor/core/themes/migrations/2026-05-24-promote-state-shared-tokens.ts +59 -0
  32. package/src/editor/core/themes/migrations/2026-05-24-segmentedcontrol-divider-inset.ts +29 -0
  33. package/src/editor/core/themes/migrations/2026-05-25-cornerbadge-flatten-variants.ts +46 -0
  34. package/src/editor/core/themes/migrations/index.ts +10 -0
  35. package/src/editor/core/themes/themeInit.ts +3 -2
  36. package/src/editor/core/themes/themeService.ts +3 -2
  37. package/src/editor/ui/UIEasingSelector.svelte +240 -0
  38. package/src/editor/ui/variantScales.ts +34 -0
  39. package/src/system/components/Button.svelte +34 -85
  40. package/src/system/components/CollapsibleSection.svelte +1 -48
  41. package/src/system/components/CornerBadge.svelte +72 -138
  42. package/src/system/components/ImageLightbox.svelte +578 -0
  43. package/src/system/components/Input.svelte +387 -0
  44. package/src/system/components/ProgressBar.svelte +62 -258
  45. package/src/system/components/SegmentedControl.svelte +81 -15
  46. package/src/system/components/SideNavigation.svelte +777 -0
  47. package/src/system/styles/tokens.css +43 -0
  48. package/src/system/styles/tokens.generated.css +4 -183
  49. package/src/editor/component-editor/StandardButtonsEditor.svelte +0 -190
package/README.md CHANGED
@@ -12,7 +12,7 @@ A foundational design system for quickly styling and building Svelte + Vite micr
12
12
  - **Per-component editor** (`/components` route, dev-only) — the home of real-time component-alias editing. Pick token aliases per component without writing CSS.
13
13
  - **Live editor overlay** — pins to the top-right of every dev page. Opens the editor in a side panel or floating window so you edit *on the page you're styling*, not in a separate tab. Includes a "Page Source" button that opens the current page's `.svelte` file in VS Code.
14
14
  - **Preset bundles** — capture a whole site configuration (active theme + every component's active config) as a single portable artifact. Drop a preset into a new project to restore the full styling in one step.
15
- - **Vite plugin** — hosts the `/api/themes/*`, `/api/component-configs/*`, and `/api/presets/*` routes that persist your edits to disk as you make them.
15
+ - **Vite plugin** — hosts the `/api/live-tokens/{themes,component-configs,manifests}/*` routes that persist your edits to disk as you make them. The single namespace keeps live-tokens' routes from colliding with anything your app serves under `/api`.
16
16
 
17
17
  ## Quick install
18
18
 
@@ -32,21 +32,42 @@ export default defineConfig({
32
32
  plugins: [
33
33
  svelte(),
34
34
  themeFileApi({
35
- themesDir: 'themes',
36
35
  tokensCssPath: 'src/system/styles/tokens.css',
37
36
  }),
38
37
  ],
39
- optimizeDeps: {
40
- exclude: ['@motion-proto/live-tokens'],
41
- },
42
38
  });
43
39
  ```
44
40
 
45
41
  The `themeFileApi` plugin:
46
- - Seeds `themes/` with a default theme on first dev-server start.
47
- - Discovers components at `src/system/components/*.svelte` and seeds `component-configs/{comp}/default.json` from each component's `:global(:root)` block.
48
- - Hosts the `/api/*` routes the editor uses to save and load themes + per-component configs.
49
- - Auto-injects `__PROJECT_ROOT__` for the overlay's "Page Source" link.
42
+ - Seeds `src/live-tokens/data/themes/` with a default theme on first dev-server start.
43
+ - Discovers components at `src/system/components/*.svelte` and seeds `src/live-tokens/data/component-configs/{comp}/default.json` from each component's `:global(:root)` block.
44
+ - Hosts the `/api/live-tokens/*` routes the editor uses to save and load themes + per-component configs.
45
+ - Auto-injects `__PROJECT_ROOT__` for the overlay's "Page Source" link and `__LIVE_TOKENS_API_BASE__` so the client uses whatever `apiBase` you configured.
46
+
47
+ ### Where data lands — and how to move it
48
+
49
+ By default, the plugin reads and writes under one folder: `src/live-tokens/data/`. Inside that folder live three subdirectories — `themes/`, `manifests/`, `component-configs/` — each owned by the plugin.
50
+
51
+ To move them, create a `live-tokens.config.json` at your project root:
52
+
53
+ ```json
54
+ {
55
+ "dataDir": "src/live-tokens/data"
56
+ }
57
+ ```
58
+
59
+ All four keys are optional. `dataDir` is the headline knob — it relocates all three subfolders at once. The per-folder overrides exist for unusual layouts (e.g. a monorepo where themes are shared across packages but component-configs aren't):
60
+
61
+ ```json
62
+ {
63
+ "dataDir": "src/live-tokens/data",
64
+ "themesDir": "../shared/themes",
65
+ "componentConfigsDir": "src/live-tokens/data/component-configs",
66
+ "manifestsDir": "src/live-tokens/data/manifests"
67
+ }
68
+ ```
69
+
70
+ Resolution order, per folder: explicit `themeFileApi(opts)` argument > matching key in `live-tokens.config.json` > `<dataDir>/<sub>`. The dev server reads the file once at startup — restart vite to pick up changes.
50
71
 
51
72
  ### Bootstrap in `main.ts`
52
73
 
@@ -228,38 +249,38 @@ Once linked, asking Claude to "add a Stat component to my live-tokens project" t
228
249
 
229
250
  ## How the editor ships changes to prod
230
251
 
231
- 1. Edit in `/editor` or `/components`. Saves write to `themes/{name}.json` and `component-configs/{comp}/{name}.json`.
232
- 2. Promote a theme to "production." Its variables are written into `src/system/styles/tokens.css` and backed up under `src/system/styles/_backups/`.
233
- 3. `npm run build` bundles `tokens.css` as plain CSS. No editor code, no JSON lookups, no dev surfaces ship to prod.
252
+ 1. Edit in `/editor` or `/components`. Saves write to `<dataDir>/themes/{name}.json` and `<dataDir>/component-configs/{comp}/{name}.json`.
253
+ 2. Promote a theme to "production." Its variables are written into `tokens.generated.css` next to your authored `tokens.css`.
254
+ 3. `npm run build` bundles both as plain CSS. No editor code, no JSON lookups, no dev surfaces ship to prod.
234
255
 
235
256
  ## File ownership — what the plugin writes
236
257
 
237
258
  Knowing which files the plugin touches matters when upgrading the package or working in a repo you don't want overwritten.
238
259
 
239
- **On `npm install` or `npm update`: nothing outside `node_modules/`.** No install hooks. Upgrading versions never touches your `themes/`, `component-configs/`, `presets/`, or any file in `src/`.
260
+ **On `npm install` or `npm update`: nothing outside `node_modules/`.** No install hooks. Upgrading versions never touches your `src/live-tokens/data/`, or any file in `src/` outside it.
240
261
 
241
- **At dev-server startup, the plugin only fills gaps it never overwrites authored files:**
262
+ **The plugin only writes inside two locations on disk:**
242
263
 
243
- - `themes/default.json` — written **only if missing**.
244
- - `themes/_active.json` and `themes/_production.json` — written **only if missing**.
245
- - `component-configs/{comp}/_active.json` and `_production.json` — same: only if missing.
246
- - `component-configs/{comp}/default.json` — regenerated from the component's `:global(:root)` block **only when the `.svelte` source is newer than the existing default**. This file is a build artifact of the source; don't hand-edit it.
264
+ - `src/live-tokens/data/` (configurable via `live-tokens.config.json` — see "Where data lands").
265
+ - The CSS sidecars next to your `tokensCssPath` (`tokens.generated.css`, `fonts.css`).
247
266
 
248
- **At dev-time editor actions, these files get rewritten by your explicit save/promote:**
267
+ It never writes to your project root, your `src/` outside the data folder, or anywhere else.
268
+
269
+ **At dev-server startup, the plugin only fills gaps — it never overwrites authored files:**
249
270
 
250
- - `themes/{name}.json` — every save in the editor.
251
- - `src/system/styles/tokens.css` fully regenerated when you save or promote the production theme. **Treat this as a build artifact.** Hand-edits get clobbered next time the production theme is saved; promote a theme instead.
252
- - `src/system/styles/fonts.css` — same rule: regenerated from the theme's font sources.
253
- - `component-configs/{comp}/{name}.json` — every save of a per-component config.
271
+ - `<dataDir>/themes/default.json` — written **only if missing**.
272
+ - `<dataDir>/themes/_active.json` and `_production.json` written **only if missing**.
273
+ - `<dataDir>/component-configs/{comp}/_active.json` and `_production.json` — same: only if missing.
274
+ - `<dataDir>/component-configs/{comp}/default.json` — regenerated from the component's `:global(:root)` block **only when the `.svelte` source is newer than the existing default**. This file is a build artifact of the source; don't hand-edit it.
254
275
 
255
- ## Maintainer notes publishing
276
+ **At dev-time editor actions, these files get rewritten by your explicit save/promote:**
256
277
 
257
- The package publishes to npm as `@motion-proto/live-tokens`.
278
+ - `<dataDir>/themes/{name}.json` every save in the editor.
279
+ - `<tokensCssPath sibling>/tokens.generated.css` — fully regenerated when you save or promote the production theme.
280
+ - `<tokensCssPath sibling>/fonts.css` — same rule: regenerated from the theme's font sources.
281
+ - `<dataDir>/component-configs/{comp}/{name}.json` — every save of a per-component config.
258
282
 
259
- 1. Bump the version in `package.json`.
260
- 2. Verify tarball contents: `npm pack --dry-run`.
261
- 3. `npm publish`. `prepublishOnly` rebuilds `dist-plugin/`.
262
- 4. Tag and push: `git tag vX.Y.Z && git push origin main vX.Y.Z`.
283
+ The developer-authored `tokens.css` itself is **never written** by the plugin — it holds defaults you're free to hand-edit. The editor's overrides land in the sidecar `tokens.generated.css`, which the package imports immediately after `tokens.css`.
263
284
 
264
285
  ## License
265
286