@motion-proto/live-tokens 0.18.2 → 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
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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
|
-
|
|
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 (
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
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
|
|
100
|
+
return null;
|
|
92
101
|
}
|
|
93
102
|
function escapeRe(s) {
|
|
94
103
|
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
package/dist-plugin/index.cjs
CHANGED
|
@@ -641,37 +641,46 @@ function removeTokensMatching(css, predicate) {
|
|
|
641
641
|
return kept.join("\n");
|
|
642
642
|
}
|
|
643
643
|
function findInsertionPoint(lines, anchorPrefixes) {
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
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
|
-
|
|
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 (
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
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
|
|
683
|
+
return null;
|
|
675
684
|
}
|
|
676
685
|
|
|
677
686
|
// vite-plugin/tokensCssMigrations/migrations/2026-05-29-typography-scale-additions.ts
|
package/dist-plugin/index.js
CHANGED
|
@@ -103,37 +103,46 @@ function removeTokensMatching(css, predicate) {
|
|
|
103
103
|
return kept.join("\n");
|
|
104
104
|
}
|
|
105
105
|
function findInsertionPoint(lines, anchorPrefixes) {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
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
|
-
|
|
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 (
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
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
|
|
145
|
+
return null;
|
|
137
146
|
}
|
|
138
147
|
function escapeRe(s) {
|
|
139
148
|
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|