@motion-proto/live-tokens 0.21.0 → 0.21.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -231,6 +231,33 @@ This generates a Svelte + Vite app that **depends on** the package — `vite.con
231
231
 
232
232
  (The older `npx degit motionproto/live-tokens` route cloned this whole repo as your app — the package's source, tests, and all. `create` gives you a thin consumer app instead.)
233
233
 
234
+ ## Recommended project layout
235
+
236
+ `create` scaffolds the preferred integration surface. Whether you scaffolded or wired up by hand, conforming to this layout keeps upgrades non-destructive and consistent across projects.
237
+
238
+ ```
239
+ src/
240
+ main.ts # token CSS chain → bootLiveTokens(App, '#app')
241
+ App.svelte # routes (e.g. <LiveTokensRouter {pages} />)
242
+ pages/ # your pages
243
+ styles/site.css # your themed page typography (yours to edit)
244
+ system/styles/tokens.css # vendored Layer-1 tokens — committed
245
+ live-tokens/data/ # editor state — committed
246
+ tokens.generated.css # editor output
247
+ themes/ manifests/ component-configs/
248
+ **/_backups/ # gitignored (local-only snapshots)
249
+ vite.config.ts # svelte({ preprocess: vitePreprocess() }) + themeFileApi
250
+ svelte.config.js # vitePreprocess()
251
+ ```
252
+
253
+ Conventions that make this work:
254
+
255
+ - **Vendor `tokens.css` into `src/` and commit it.** Point `themeFileApi({ tokensCssPath })` at that file, not at one inside `node_modules`. The dev server writes your edits there; a copy under `node_modules` is wiped on every `npm install`.
256
+ - **All editable state lives under `src/` and is committed** — `tokens.css`, `tokens.generated.css`, and everything in `live-tokens/data/`. This is the invariant that makes upgrades safe: `npm install` only ever touches `node_modules` + `package.json` + the lockfile, never your `src/`.
257
+ - **`_backups/` is gitignored.** The dev server snapshots a file before overwriting it; those snapshots are local working state, not source.
258
+ - **Preprocess with `vitePreprocess()`** (bundled in `@sveltejs/vite-plugin-svelte`), keeping `sass` installed for the components' `scss`. No `svelte-preprocess`, no `legacy-peer-deps` `.npmrc` — the dependency tree resolves cleanly on its own (since 0.19.1).
259
+ - **Import only from the public surface** — `@motion-proto/live-tokens`, `/components/*`, `/vite-plugin`, `/app/*`.
260
+
234
261
  ## Consumer-authored components
235
262
 
236
263
  The shipped components are first-party by default, but you can author your own and get the same real-time editing experience. Co-locate runtime and editor files in `src/components/` (or `src/system/components/`, both are scanned by default) and pass them to `bootLiveTokens`:
package/bin/create.mjs CHANGED
@@ -11,6 +11,7 @@ import {
11
11
  writeFileSync,
12
12
  } from 'node:fs';
13
13
  import { dirname, join, resolve } from 'node:path';
14
+ import { fileURLToPath } from 'node:url';
14
15
 
15
16
  // npm strips dotfiles from published tarballs, so the template ships them
16
17
  // renamed; `create` restores the leading dot on scaffold.
@@ -87,3 +88,12 @@ export function formatCreateResult({ appName, targetDir }, targetArg) {
87
88
  `Then open http://localhost:5173 and edit src/pages/Home.svelte.`,
88
89
  ].join('\n');
89
90
  }
91
+
92
+ // Entry point for the `@motion-proto/create-live-tokens` initializer: it
93
+ // derives pkgRoot from this module's own location (i.e. wherever this package
94
+ // is installed), so the template + seed CSS always come from this exact
95
+ // version. The initializer stays a thin shim with no template of its own.
96
+ export function createApp({ targetDir, force = false } = {}) {
97
+ const pkgRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..');
98
+ return runCreate({ targetDir, pkgRoot, force });
99
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@motion-proto/live-tokens",
3
- "version": "0.21.0",
3
+ "version": "0.21.2",
4
4
  "type": "module",
5
5
  "description": "Design token editor with live CSS variable editing. Svelte 5 + Vite 8.",
6
6
  "keywords": [
@@ -42,6 +42,7 @@
42
42
  "types": "./src/editor/index.ts",
43
43
  "default": "./src/editor/index.ts"
44
44
  },
45
+ "./create": "./bin/create.mjs",
45
46
  "./component-editor": {
46
47
  "svelte": "./src/editor/component-editor/index.ts",
47
48
  "types": "./src/editor/component-editor/index.ts",
@@ -11,6 +11,8 @@ Open http://localhost:5173.
11
11
 
12
12
  ## What you have
13
13
 
14
+ This project follows the package's [recommended layout](https://github.com/motionproto/live-tokens#recommended-project-layout): all editable state lives under `src/` and is committed, so `npm install` and upgrades never touch your styles.
15
+
14
16
  - `src/pages/Home.svelte` — the starter page. Replace it with your own content.
15
17
  - `src/App.svelte` — your routes. `<LiveTokensRouter>` adds the dev-only
16
18
  `/editor` (theme tokens) and `/components` (per-component aliases) routes.