@motion-proto/live-tokens 0.17.1 → 0.18.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.
@@ -58,37 +58,46 @@ function removeTokensMatching(css, predicate) {
58
58
  return kept.join("\n");
59
59
  }
60
60
  function findInsertionPoint(lines, anchorPrefixes) {
61
- for (const prefix of anchorPrefixes) {
62
- let last = -1;
63
- let indent = " ";
64
- for (let i = 0; i < lines.length; i++) {
65
- const m = lines[i].match(/^(\s*)(--[a-z0-9-]+)\s*:/);
66
- if (m && m[2].startsWith(prefix)) {
67
- last = i;
68
- indent = m[1] || " ";
61
+ const root = findTopLevelRoot(lines);
62
+ if (!root) return { indent: " ", insertAfter: lines.length - 1 };
63
+ const lastByPrefix = /* @__PURE__ */ new Map();
64
+ let lastDecl = null;
65
+ let depth = 1;
66
+ for (let i = root.start + 1; i < root.end; i++) {
67
+ const line = lines[i];
68
+ if (depth === 1) {
69
+ const m = line.match(/^(\s*)(--[a-z0-9-]+)\s*:/);
70
+ if (m) {
71
+ const hit = { index: i, indent: m[1] || " " };
72
+ lastDecl = hit;
73
+ for (const prefix of anchorPrefixes) {
74
+ if (m[2].startsWith(prefix)) lastByPrefix.set(prefix, hit);
75
+ }
69
76
  }
70
77
  }
71
- if (last !== -1) return { indent, insertAfter: last };
78
+ depth += (line.match(/\{/g)?.length ?? 0) - (line.match(/\}/g)?.length ?? 0);
79
+ }
80
+ for (const prefix of anchorPrefixes) {
81
+ const hit = lastByPrefix.get(prefix);
82
+ if (hit) return { indent: hit.indent, insertAfter: hit.index };
72
83
  }
84
+ return { indent: lastDecl?.indent ?? " ", insertAfter: root.end - 1 };
85
+ }
86
+ function findTopLevelRoot(lines) {
73
87
  let depth = 0;
74
- let inRoot = false;
75
- let lastDeclIndent = " ";
76
88
  for (let i = 0; i < lines.length; i++) {
77
89
  const line = lines[i];
78
- if (!inRoot && /(^|\s):root[^{]*\{/.test(line)) {
79
- inRoot = true;
80
- depth = 1;
81
- continue;
90
+ if (depth === 0 && /(^|[\s,]):root[^{]*\{/.test(line)) {
91
+ let d = 0;
92
+ for (let j = i; j < lines.length; j++) {
93
+ d += (lines[j].match(/\{/g)?.length ?? 0) - (lines[j].match(/\}/g)?.length ?? 0);
94
+ if (d === 0) return { start: i, end: j };
95
+ }
96
+ return { start: i, end: lines.length - 1 };
82
97
  }
83
- if (!inRoot) continue;
84
- const declIndent = line.match(/^(\s*)--[a-z0-9-]+\s*:/);
85
- if (declIndent) lastDeclIndent = declIndent[1] || " ";
86
98
  depth += (line.match(/\{/g)?.length ?? 0) - (line.match(/\}/g)?.length ?? 0);
87
- if (depth === 0) {
88
- return { indent: lastDeclIndent, insertAfter: i - 1 };
89
- }
90
99
  }
91
- return { indent: " ", insertAfter: lines.length - 1 };
100
+ return null;
92
101
  }
93
102
  function escapeRe(s) {
94
103
  return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
@@ -641,37 +641,46 @@ function removeTokensMatching(css, predicate) {
641
641
  return kept.join("\n");
642
642
  }
643
643
  function findInsertionPoint(lines, anchorPrefixes) {
644
- for (const prefix of anchorPrefixes) {
645
- let last = -1;
646
- let indent = " ";
647
- for (let i = 0; i < lines.length; i++) {
648
- const m = lines[i].match(/^(\s*)(--[a-z0-9-]+)\s*:/);
649
- if (m && m[2].startsWith(prefix)) {
650
- last = i;
651
- indent = m[1] || " ";
644
+ const root = findTopLevelRoot(lines);
645
+ if (!root) return { indent: " ", insertAfter: lines.length - 1 };
646
+ const lastByPrefix = /* @__PURE__ */ new Map();
647
+ let lastDecl = null;
648
+ let depth = 1;
649
+ for (let i = root.start + 1; i < root.end; i++) {
650
+ const line = lines[i];
651
+ if (depth === 1) {
652
+ const m = line.match(/^(\s*)(--[a-z0-9-]+)\s*:/);
653
+ if (m) {
654
+ const hit = { index: i, indent: m[1] || " " };
655
+ lastDecl = hit;
656
+ for (const prefix of anchorPrefixes) {
657
+ if (m[2].startsWith(prefix)) lastByPrefix.set(prefix, hit);
658
+ }
652
659
  }
653
660
  }
654
- if (last !== -1) return { indent, insertAfter: last };
661
+ depth += (line.match(/\{/g)?.length ?? 0) - (line.match(/\}/g)?.length ?? 0);
662
+ }
663
+ for (const prefix of anchorPrefixes) {
664
+ const hit = lastByPrefix.get(prefix);
665
+ if (hit) return { indent: hit.indent, insertAfter: hit.index };
655
666
  }
667
+ return { indent: lastDecl?.indent ?? " ", insertAfter: root.end - 1 };
668
+ }
669
+ function findTopLevelRoot(lines) {
656
670
  let depth = 0;
657
- let inRoot = false;
658
- let lastDeclIndent = " ";
659
671
  for (let i = 0; i < lines.length; i++) {
660
672
  const line = lines[i];
661
- if (!inRoot && /(^|\s):root[^{]*\{/.test(line)) {
662
- inRoot = true;
663
- depth = 1;
664
- continue;
665
- }
666
- if (!inRoot) continue;
667
- const declIndent = line.match(/^(\s*)--[a-z0-9-]+\s*:/);
668
- if (declIndent) lastDeclIndent = declIndent[1] || " ";
669
- depth += (line.match(/\{/g)?.length ?? 0) - (line.match(/\}/g)?.length ?? 0);
670
- if (depth === 0) {
671
- return { indent: lastDeclIndent, insertAfter: i - 1 };
673
+ if (depth === 0 && /(^|[\s,]):root[^{]*\{/.test(line)) {
674
+ let d = 0;
675
+ for (let j = i; j < lines.length; j++) {
676
+ d += (lines[j].match(/\{/g)?.length ?? 0) - (lines[j].match(/\}/g)?.length ?? 0);
677
+ if (d === 0) return { start: i, end: j };
678
+ }
679
+ return { start: i, end: lines.length - 1 };
672
680
  }
681
+ depth += (line.match(/\{/g)?.length ?? 0) - (line.match(/\}/g)?.length ?? 0);
673
682
  }
674
- return { indent: " ", insertAfter: lines.length - 1 };
683
+ return null;
675
684
  }
676
685
 
677
686
  // vite-plugin/tokensCssMigrations/migrations/2026-05-29-typography-scale-additions.ts
@@ -4,7 +4,7 @@ import {
4
4
  resolveDataDirs,
5
5
  runTokensCssMigrations,
6
6
  validateTokensCss
7
- } from "./chunk-UBS57IYV.js";
7
+ } from "./chunk-CUC32QJ2.js";
8
8
 
9
9
  // vite-plugin/themeFileApi.ts
10
10
  import fs2 from "fs";
@@ -103,37 +103,46 @@ function removeTokensMatching(css, predicate) {
103
103
  return kept.join("\n");
104
104
  }
105
105
  function findInsertionPoint(lines, anchorPrefixes) {
106
- for (const prefix of anchorPrefixes) {
107
- let last = -1;
108
- let indent = " ";
109
- for (let i = 0; i < lines.length; i++) {
110
- const m = lines[i].match(/^(\s*)(--[a-z0-9-]+)\s*:/);
111
- if (m && m[2].startsWith(prefix)) {
112
- last = i;
113
- indent = m[1] || " ";
106
+ const root = findTopLevelRoot(lines);
107
+ if (!root) return { indent: " ", insertAfter: lines.length - 1 };
108
+ const lastByPrefix = /* @__PURE__ */ new Map();
109
+ let lastDecl = null;
110
+ let depth = 1;
111
+ for (let i = root.start + 1; i < root.end; i++) {
112
+ const line = lines[i];
113
+ if (depth === 1) {
114
+ const m = line.match(/^(\s*)(--[a-z0-9-]+)\s*:/);
115
+ if (m) {
116
+ const hit = { index: i, indent: m[1] || " " };
117
+ lastDecl = hit;
118
+ for (const prefix of anchorPrefixes) {
119
+ if (m[2].startsWith(prefix)) lastByPrefix.set(prefix, hit);
120
+ }
114
121
  }
115
122
  }
116
- if (last !== -1) return { indent, insertAfter: last };
123
+ depth += (line.match(/\{/g)?.length ?? 0) - (line.match(/\}/g)?.length ?? 0);
124
+ }
125
+ for (const prefix of anchorPrefixes) {
126
+ const hit = lastByPrefix.get(prefix);
127
+ if (hit) return { indent: hit.indent, insertAfter: hit.index };
117
128
  }
129
+ return { indent: lastDecl?.indent ?? " ", insertAfter: root.end - 1 };
130
+ }
131
+ function findTopLevelRoot(lines) {
118
132
  let depth = 0;
119
- let inRoot = false;
120
- let lastDeclIndent = " ";
121
133
  for (let i = 0; i < lines.length; i++) {
122
134
  const line = lines[i];
123
- if (!inRoot && /(^|\s):root[^{]*\{/.test(line)) {
124
- inRoot = true;
125
- depth = 1;
126
- continue;
135
+ if (depth === 0 && /(^|[\s,]):root[^{]*\{/.test(line)) {
136
+ let d = 0;
137
+ for (let j = i; j < lines.length; j++) {
138
+ d += (lines[j].match(/\{/g)?.length ?? 0) - (lines[j].match(/\}/g)?.length ?? 0);
139
+ if (d === 0) return { start: i, end: j };
140
+ }
141
+ return { start: i, end: lines.length - 1 };
127
142
  }
128
- if (!inRoot) continue;
129
- const declIndent = line.match(/^(\s*)--[a-z0-9-]+\s*:/);
130
- if (declIndent) lastDeclIndent = declIndent[1] || " ";
131
143
  depth += (line.match(/\{/g)?.length ?? 0) - (line.match(/\}/g)?.length ?? 0);
132
- if (depth === 0) {
133
- return { indent: lastDeclIndent, insertAfter: i - 1 };
134
- }
135
144
  }
136
- return { indent: " ", insertAfter: lines.length - 1 };
145
+ return null;
137
146
  }
138
147
  function escapeRe(s) {
139
148
  return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
@@ -9,7 +9,7 @@ import {
9
9
  renameToken,
10
10
  runTokensCssMigrations,
11
11
  validateTokensCss
12
- } from "../chunk-UBS57IYV.js";
12
+ } from "../chunk-CUC32QJ2.js";
13
13
  export {
14
14
  TOKENS_CSS_MIGRATIONS,
15
15
  collectDefinedTokens,
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@motion-proto/live-tokens",
3
- "version": "0.17.1",
3
+ "version": "0.18.3",
4
4
  "type": "module",
5
- "description": "Design token editor with live CSS variable editing. Svelte 5 + Vite 6/7.",
5
+ "description": "Design token editor with live CSS variable editing. Svelte 5 + Vite 8.",
6
6
  "keywords": [
7
7
  "svelte",
8
8
  "vite",
@@ -95,12 +95,12 @@
95
95
  "sass": "^1.0",
96
96
  "svelte": "^5",
97
97
  "svelte-preprocess": "^6.0",
98
- "vite": "^6 || ^7"
98
+ "vite": "^8"
99
99
  },
100
100
  "devDependencies": {
101
- "@sveltejs/vite-plugin-svelte": "^6.2.4",
101
+ "@sveltejs/vite-plugin-svelte": "^7.1.2",
102
102
  "@tsconfig/svelte": "^5.0.8",
103
- "@types/node": "^24.12.0",
103
+ "@types/node": "^25.9.1",
104
104
  "happy-dom": "^20.9.0",
105
105
  "highlight.js": "^11.11.1",
106
106
  "marked": "^18.0.4",
@@ -110,8 +110,8 @@
110
110
  "svelte-check": "^4.4.8",
111
111
  "svelte-preprocess": "^6.0.3",
112
112
  "tsup": "^8.5.1",
113
- "typescript": "~5.9.3",
114
- "vite": "^7.3.3",
113
+ "typescript": "~6.0.3",
114
+ "vite": "^8.0.14",
115
115
  "vitest": "^4.1.4"
116
116
  },
117
117
  "dependencies": {