@motion-proto/live-tokens 0.13.1 → 0.13.3
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/package.json
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
import type { FontFamily, FontSource, FontStack, Theme } from '../themes/themeTypes';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
|
|
3
|
+
// Stable relative paths. fonts.css and fonts/ ship colocated under
|
|
4
|
+
// src/system/styles/ in this package, so `./fonts/...` resolves correctly
|
|
5
|
+
// whether the css is served from the repo's own dev server, from inside
|
|
6
|
+
// node_modules in a consumer, or from a hashed asset in a production build.
|
|
7
|
+
// (Previously these were Vite `?url` imports — those resolved to absolute
|
|
8
|
+
// paths like `/src/system/styles/fonts/...` that worked inside live-tokens
|
|
9
|
+
// but 404'd for any consumer importing the bundled fonts.css.)
|
|
10
|
+
const FRAUNCES_ROMAN_LATIN = './fonts/Fraunces/Fraunces-roman-latin.woff2';
|
|
11
|
+
const FRAUNCES_ITALIC_LATIN = './fonts/Fraunces/Fraunces-italic-latin.woff2';
|
|
12
|
+
const MANROPE_LATIN = './fonts/Manrope/Manrope-latin.woff2';
|
|
5
13
|
|
|
6
14
|
function makeId(prefix: string): string {
|
|
7
15
|
return `${prefix}_${Math.random().toString(36).slice(2, 10)}`;
|
|
@@ -43,7 +51,7 @@ export function defaultFontSources(): FontSource[] {
|
|
|
43
51
|
{
|
|
44
52
|
id: frauncesId,
|
|
45
53
|
kind: 'font-face',
|
|
46
|
-
cssText: `@font-face {\n font-family: "Fraunces";\n src: url('${
|
|
54
|
+
cssText: `@font-face {\n font-family: "Fraunces";\n src: url('${FRAUNCES_ROMAN_LATIN}') format('woff2');\n font-weight: 100 900;\n font-style: normal;\n font-display: swap;\n}\n@font-face {\n font-family: "Fraunces";\n src: url('${FRAUNCES_ITALIC_LATIN}') format('woff2');\n font-weight: 100 900;\n font-style: italic;\n font-display: swap;\n}`,
|
|
47
55
|
label: 'Local',
|
|
48
56
|
families: [
|
|
49
57
|
fam(frauncesId, 'Fraunces', '"Fraunces"', [100, 200, 300, 400, 500, 600, 700, 800, 900]),
|
|
@@ -52,7 +60,7 @@ export function defaultFontSources(): FontSource[] {
|
|
|
52
60
|
{
|
|
53
61
|
id: manropeId,
|
|
54
62
|
kind: 'font-face',
|
|
55
|
-
cssText: `@font-face {\n font-family: "Manrope";\n src: url('${
|
|
63
|
+
cssText: `@font-face {\n font-family: "Manrope";\n src: url('${MANROPE_LATIN}') format('woff2');\n font-weight: 200 800;\n font-style: normal;\n font-display: swap;\n}`,
|
|
56
64
|
label: 'Local',
|
|
57
65
|
families: [
|
|
58
66
|
fam(manropeId, 'Manrope', '"Manrope"', [200, 300, 400, 500, 600, 700, 800]),
|
|
@@ -116,11 +124,28 @@ export function defaultFontStacks(sources: FontSource[]): FontStack[] {
|
|
|
116
124
|
* only when missing; safe to call on already-migrated themes. Also strips any
|
|
117
125
|
* stale --font-* entries from cssVariables since those are now derived.
|
|
118
126
|
*/
|
|
127
|
+
// Older themes (built before relative font paths) baked absolute Vite-resolved
|
|
128
|
+
// URLs into fontSources[].cssText, e.g. `/src/system/styles/fonts/...` or
|
|
129
|
+
// `/src/live-tokens/system/styles/fonts/...`. Those paths only resolve inside
|
|
130
|
+
// the live-tokens repo or a consumer that vendored the source; in any package
|
|
131
|
+
// consumer they 404. Normalise to the package-relative `./fonts/...` form on
|
|
132
|
+
// theme load.
|
|
133
|
+
const ABSOLUTE_FONT_PATH_PATTERN = /'\/src\/(?:live-tokens\/)?system\/styles\/fonts\//g;
|
|
134
|
+
|
|
119
135
|
export function migrateThemeFonts(theme: Theme): { migrated: boolean } {
|
|
120
136
|
let migrated = false;
|
|
121
137
|
if (!theme.fontSources || theme.fontSources.length === 0) {
|
|
122
138
|
theme.fontSources = defaultFontSources();
|
|
123
139
|
migrated = true;
|
|
140
|
+
} else {
|
|
141
|
+
for (const src of theme.fontSources) {
|
|
142
|
+
if (!src.cssText) continue;
|
|
143
|
+
const rewritten = src.cssText.replace(ABSOLUTE_FONT_PATH_PATTERN, "'./fonts/");
|
|
144
|
+
if (rewritten !== src.cssText) {
|
|
145
|
+
src.cssText = rewritten;
|
|
146
|
+
migrated = true;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
124
149
|
}
|
|
125
150
|
if (!theme.fontStacks || theme.fontStacks.length === 0) {
|
|
126
151
|
theme.fontStacks = defaultFontStacks(theme.fontSources);
|
|
@@ -71,15 +71,25 @@
|
|
|
71
71
|
// cascades (the storage handler regularly took >1s in practice) and a
|
|
72
72
|
// visible flicker as the view bounces.
|
|
73
73
|
let prevRoute: string | undefined;
|
|
74
|
+
const dbgCtx = isInIframe ? 'iframe' : 'parent';
|
|
74
75
|
run(() => {
|
|
75
76
|
const r = $route;
|
|
77
|
+
console.log(`[lt-debug:${dbgCtx}] route-pair fired`, { route: r, prevRoute, editorView: $editorView });
|
|
76
78
|
if (r === prevRoute) return;
|
|
77
79
|
prevRoute = r;
|
|
78
80
|
if (r === '/components') {
|
|
79
|
-
editorView.update((v) =>
|
|
81
|
+
editorView.update((v) => {
|
|
82
|
+
const next = v === 'components' ? 'tokens' : v;
|
|
83
|
+
console.log(`[lt-debug:${dbgCtx}] route-pair → set editorView`, { from: v, to: next });
|
|
84
|
+
return next;
|
|
85
|
+
});
|
|
80
86
|
}
|
|
81
87
|
});
|
|
82
88
|
|
|
89
|
+
editorView.subscribe((v) => {
|
|
90
|
+
console.log(`[lt-debug:${dbgCtx}] editorView subscribe`, { value: v });
|
|
91
|
+
});
|
|
92
|
+
|
|
83
93
|
// Editor route has its own chrome — hide overlay there.
|
|
84
94
|
let onEditorPath = $derived($route === editorPath);
|
|
85
95
|
let sourceFile = $derived(pageSources[$route]);
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
/* Local — Manrope */
|
|
14
14
|
@font-face {
|
|
15
15
|
font-family: "Manrope";
|
|
16
|
-
src: url('
|
|
16
|
+
src: url('./fonts/Manrope/Manrope-latin.woff2') format('woff2');
|
|
17
17
|
font-weight: 200 800;
|
|
18
18
|
font-style: normal;
|
|
19
19
|
font-display: swap;
|