@takazudo/zdtp 0.4.6 → 0.4.7
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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.4.7
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
|
|
7
|
+
- fix(server): coalesce same-file token groups in createApplyHandler ([#527](https://github.com/Takazudo/zudo-design-token-panel/pull/527)) (1d84c94)
|
|
8
|
+
|
|
9
|
+
### Other Changes
|
|
10
|
+
|
|
11
|
+
- chore(deps): resolve 19 pnpm audit security advisories ([#525](https://github.com/Takazudo/zudo-design-token-panel/pull/525)) (80c9a0e)
|
|
12
|
+
|
|
3
13
|
## 0.4.6
|
|
4
14
|
|
|
5
15
|
### Features
|
package/dist/bin/server.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { realpathSync as E } from "node:fs";
|
|
3
3
|
import { createServer as H } from "node:http";
|
|
4
4
|
import { resolve as p } from "node:path";
|
|
5
|
-
import { l as $, c as x } from "../load-routing-
|
|
5
|
+
import { l as $, c as x } from "../load-routing-D4H2VOl5.js";
|
|
6
6
|
function g(o, t) {
|
|
7
7
|
return typeof o != "string" || o.length === 0 || t.length === 0 ? !1 : t.includes(o);
|
|
8
8
|
}
|
|
@@ -1,87 +1,87 @@
|
|
|
1
|
-
import { promises as
|
|
2
|
-
import { relative as
|
|
3
|
-
import { randomBytes as
|
|
4
|
-
import { r as
|
|
5
|
-
const
|
|
1
|
+
import { promises as b, readFileSync as q } from "node:fs";
|
|
2
|
+
import { relative as P, isAbsolute as L, sep as _, resolve as D, dirname as T, join as j } from "node:path";
|
|
3
|
+
import { randomBytes as x } from "node:crypto";
|
|
4
|
+
import { r as Z } from "./route-tokens-to-files-1DvmWBdj.js";
|
|
5
|
+
const F = /* @__PURE__ */ new Map();
|
|
6
6
|
async function B(t, r) {
|
|
7
|
-
const e = (
|
|
7
|
+
const e = (F.get(t) ?? Promise.resolve()).then(r, r), o = e.then(
|
|
8
8
|
() => {
|
|
9
9
|
},
|
|
10
10
|
() => {
|
|
11
11
|
}
|
|
12
12
|
);
|
|
13
|
-
|
|
13
|
+
F.set(t, o);
|
|
14
14
|
try {
|
|
15
15
|
return await e;
|
|
16
16
|
} finally {
|
|
17
|
-
|
|
17
|
+
F.get(t) === o && F.delete(t);
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
-
function
|
|
20
|
+
function H(t) {
|
|
21
21
|
return t.replace(/[\r\n\\;{}]/g, "");
|
|
22
22
|
}
|
|
23
|
-
const
|
|
24
|
-
function
|
|
25
|
-
return typeof t == "string" &&
|
|
23
|
+
const U = /^--[a-zA-Z0-9_-]+$/;
|
|
24
|
+
function G(t) {
|
|
25
|
+
return typeof t == "string" && U.test(t);
|
|
26
26
|
}
|
|
27
|
-
function
|
|
27
|
+
function K(t, r) {
|
|
28
28
|
if (!r.endsWith(".css")) return !1;
|
|
29
|
-
const n =
|
|
30
|
-
return !(n === "" || n === "." ||
|
|
29
|
+
const n = P(t, r);
|
|
30
|
+
return !(n === "" || n === "." || L(n) || n === ".." || n.startsWith(`..${_}`) || n.startsWith("../"));
|
|
31
31
|
}
|
|
32
|
-
function
|
|
32
|
+
function Q(t) {
|
|
33
33
|
const r = {};
|
|
34
34
|
for (const [n, e] of Object.entries(t)) {
|
|
35
|
-
if (!
|
|
35
|
+
if (!G(n))
|
|
36
36
|
return { error: `Invalid cssVar name: ${JSON.stringify(n)}` };
|
|
37
37
|
if (typeof e != "string")
|
|
38
38
|
return { error: `Value for ${n} must be a string` };
|
|
39
|
-
r[n] =
|
|
39
|
+
r[n] = H(e);
|
|
40
40
|
}
|
|
41
41
|
return { sanitized: r };
|
|
42
42
|
}
|
|
43
|
-
class
|
|
43
|
+
class S extends Error {
|
|
44
44
|
constructor(r = 'No top-level ":root { ... }" or "@theme { ... }" block found in source.') {
|
|
45
|
-
super(r), this.name = "NoTokenBlockError", Object.setPrototypeOf(this,
|
|
45
|
+
super(r), this.name = "NoTokenBlockError", Object.setPrototypeOf(this, S.prototype);
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
function E(t, r, n) {
|
|
49
|
-
const e = t.length, o = r.length,
|
|
50
|
-
let
|
|
51
|
-
for (;
|
|
52
|
-
const
|
|
53
|
-
if (
|
|
54
|
-
const c = t.indexOf("*/",
|
|
49
|
+
const e = t.length, o = r.length, i = r[0];
|
|
50
|
+
let s = 0, u = 0;
|
|
51
|
+
for (; s < e; ) {
|
|
52
|
+
const f = t[s];
|
|
53
|
+
if (f === "/" && t[s + 1] === "*") {
|
|
54
|
+
const c = t.indexOf("*/", s + 2);
|
|
55
55
|
if (c === -1) return null;
|
|
56
|
-
|
|
56
|
+
s = c + 2;
|
|
57
57
|
continue;
|
|
58
58
|
}
|
|
59
|
-
if (
|
|
60
|
-
const c =
|
|
61
|
-
for (
|
|
62
|
-
t[
|
|
63
|
-
|
|
59
|
+
if (f === '"' || f === "'") {
|
|
60
|
+
const c = f;
|
|
61
|
+
for (s++; s < e && t[s] !== c; )
|
|
62
|
+
t[s] === "\\" && s + 1 < e && s++, s++;
|
|
63
|
+
s++;
|
|
64
64
|
continue;
|
|
65
65
|
}
|
|
66
|
-
if (
|
|
67
|
-
|
|
66
|
+
if (f === "{") {
|
|
67
|
+
u++, s++;
|
|
68
68
|
continue;
|
|
69
69
|
}
|
|
70
|
-
if (
|
|
71
|
-
|
|
70
|
+
if (f === "}") {
|
|
71
|
+
u > 0 && u--, s++;
|
|
72
72
|
continue;
|
|
73
73
|
}
|
|
74
|
-
if (
|
|
75
|
-
const c =
|
|
76
|
-
if (
|
|
77
|
-
const k = n ?
|
|
74
|
+
if (u === 0 && f === i && t.startsWith(r, s)) {
|
|
75
|
+
const c = s + o, p = t[c] ?? "";
|
|
76
|
+
if (!$(p)) {
|
|
77
|
+
const k = n ? Y(t, c) : X(t, c);
|
|
78
78
|
if (k !== -1) {
|
|
79
|
-
const
|
|
80
|
-
return l !== -1 ? { contentStart:
|
|
79
|
+
const m = k + 1, l = tt(t, m);
|
|
80
|
+
return l !== -1 ? { contentStart: m, contentEnd: l } : null;
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
|
-
|
|
84
|
+
s++;
|
|
85
85
|
}
|
|
86
86
|
return null;
|
|
87
87
|
}
|
|
@@ -91,10 +91,10 @@ function C(t) {
|
|
|
91
91
|
function N(t) {
|
|
92
92
|
return E(t, "@theme", !0);
|
|
93
93
|
}
|
|
94
|
-
function
|
|
94
|
+
function $(t) {
|
|
95
95
|
return /[A-Za-z0-9_-]/.test(t);
|
|
96
96
|
}
|
|
97
|
-
function
|
|
97
|
+
function X(t, r) {
|
|
98
98
|
const n = t.length;
|
|
99
99
|
let e = r;
|
|
100
100
|
for (; e < n; ) {
|
|
@@ -105,16 +105,16 @@ function Q(t, r) {
|
|
|
105
105
|
continue;
|
|
106
106
|
}
|
|
107
107
|
if (o === "/" && t[e + 1] === "*") {
|
|
108
|
-
const
|
|
109
|
-
if (
|
|
110
|
-
e =
|
|
108
|
+
const i = t.indexOf("*/", e + 2);
|
|
109
|
+
if (i === -1) return -1;
|
|
110
|
+
e = i + 2;
|
|
111
111
|
continue;
|
|
112
112
|
}
|
|
113
113
|
return o === "{" ? e : -1;
|
|
114
114
|
}
|
|
115
115
|
return -1;
|
|
116
116
|
}
|
|
117
|
-
function
|
|
117
|
+
function Y(t, r) {
|
|
118
118
|
const n = t.length;
|
|
119
119
|
let e = r;
|
|
120
120
|
for (; e < n; ) {
|
|
@@ -125,43 +125,43 @@ function X(t, r) {
|
|
|
125
125
|
continue;
|
|
126
126
|
}
|
|
127
127
|
if (o === "/" && t[e + 1] === "*") {
|
|
128
|
-
const
|
|
129
|
-
if (
|
|
130
|
-
e =
|
|
128
|
+
const i = t.indexOf("*/", e + 2);
|
|
129
|
+
if (i === -1) return -1;
|
|
130
|
+
e = i + 2;
|
|
131
131
|
continue;
|
|
132
132
|
}
|
|
133
133
|
if (o === "{") return e;
|
|
134
|
-
if (
|
|
135
|
-
for (e++; e < n &&
|
|
134
|
+
if ($(o)) {
|
|
135
|
+
for (e++; e < n && $(t[e]); ) e++;
|
|
136
136
|
continue;
|
|
137
137
|
}
|
|
138
138
|
return -1;
|
|
139
139
|
}
|
|
140
140
|
return -1;
|
|
141
141
|
}
|
|
142
|
-
function
|
|
142
|
+
function tt(t, r) {
|
|
143
143
|
const n = t.length;
|
|
144
144
|
let e = r, o = 1;
|
|
145
145
|
for (; e < n; ) {
|
|
146
|
-
const
|
|
147
|
-
if (
|
|
148
|
-
const
|
|
149
|
-
if (
|
|
150
|
-
e =
|
|
146
|
+
const i = t[e];
|
|
147
|
+
if (i === "/" && t[e + 1] === "*") {
|
|
148
|
+
const s = t.indexOf("*/", e + 2);
|
|
149
|
+
if (s === -1) return -1;
|
|
150
|
+
e = s + 2;
|
|
151
151
|
continue;
|
|
152
152
|
}
|
|
153
|
-
if (
|
|
154
|
-
const
|
|
155
|
-
for (e++; e < n && t[e] !==
|
|
153
|
+
if (i === '"' || i === "'") {
|
|
154
|
+
const s = i;
|
|
155
|
+
for (e++; e < n && t[e] !== s; )
|
|
156
156
|
t[e] === "\\" && e + 1 < n && e++, e++;
|
|
157
157
|
e++;
|
|
158
158
|
continue;
|
|
159
159
|
}
|
|
160
|
-
if (
|
|
160
|
+
if (i === "{") {
|
|
161
161
|
o++, e++;
|
|
162
162
|
continue;
|
|
163
163
|
}
|
|
164
|
-
if (
|
|
164
|
+
if (i === "}") {
|
|
165
165
|
if (o--, o === 0) return e;
|
|
166
166
|
e++;
|
|
167
167
|
continue;
|
|
@@ -170,26 +170,26 @@ function Y(t, r) {
|
|
|
170
170
|
}
|
|
171
171
|
return -1;
|
|
172
172
|
}
|
|
173
|
-
function
|
|
173
|
+
function et(t) {
|
|
174
174
|
return t.replace(/[\\^$.*+?()[\]{}|]/g, "\\$&");
|
|
175
175
|
}
|
|
176
|
-
function
|
|
176
|
+
function M(t) {
|
|
177
177
|
return t.replace(/\/\*[\s\S]*?\*\//g, (r) => " ".repeat(r.length));
|
|
178
178
|
}
|
|
179
|
-
function
|
|
180
|
-
const r = t.startsWith("--") ? t.slice(2) : t, n =
|
|
179
|
+
function V(t) {
|
|
180
|
+
const r = t.startsWith("--") ? t.slice(2) : t, n = et(r);
|
|
181
181
|
return new RegExp("(?<![\\w-])(--" + n + ":)(\\s*)([\\s\\S]+?);");
|
|
182
182
|
}
|
|
183
183
|
function R(t, r) {
|
|
184
|
-
return
|
|
184
|
+
return V(r).test(M(t));
|
|
185
185
|
}
|
|
186
|
-
function
|
|
187
|
-
const e =
|
|
188
|
-
if (!
|
|
189
|
-
const [
|
|
190
|
-
return
|
|
186
|
+
function A(t, r, n) {
|
|
187
|
+
const e = V(r), o = M(t), i = e.exec(o);
|
|
188
|
+
if (!i) return { content: t, status: "unknown" };
|
|
189
|
+
const [s, u, f] = i, c = i.index, p = c + s.length, k = c + u.length + f.length, m = p - 1, d = t.slice(k, m).trim(), y = n.trim();
|
|
190
|
+
return d === y ? { content: t, status: "unchanged" } : { content: t.slice(0, c) + u + f + n + ";" + t.slice(p), status: "changed" };
|
|
191
191
|
}
|
|
192
|
-
function
|
|
192
|
+
function nt(t, r) {
|
|
193
193
|
const n = Object.keys(r), e = C(t), o = N(t);
|
|
194
194
|
if (!e && !o)
|
|
195
195
|
return {
|
|
@@ -199,43 +199,43 @@ function et(t, r) {
|
|
|
199
199
|
unknown: [...n],
|
|
200
200
|
unknownOutsideBlock: n.filter((l) => R(t, l))
|
|
201
201
|
};
|
|
202
|
-
let
|
|
203
|
-
const
|
|
202
|
+
let i = e ? t.slice(e.contentStart, e.contentEnd) : null, s = o ? t.slice(o.contentStart, o.contentEnd) : null;
|
|
203
|
+
const u = [], f = [], c = [];
|
|
204
204
|
for (const l of n) {
|
|
205
|
-
if (
|
|
206
|
-
const
|
|
207
|
-
if (
|
|
208
|
-
|
|
205
|
+
if (i !== null) {
|
|
206
|
+
const d = A(i, l, r[l]);
|
|
207
|
+
if (d.status !== "unknown") {
|
|
208
|
+
i = d.content, d.status === "changed" ? u.push(l) : f.push(l);
|
|
209
209
|
continue;
|
|
210
210
|
}
|
|
211
211
|
}
|
|
212
|
-
if (
|
|
213
|
-
const
|
|
214
|
-
if (
|
|
215
|
-
|
|
212
|
+
if (s !== null) {
|
|
213
|
+
const d = A(s, l, r[l]);
|
|
214
|
+
if (d.status !== "unknown") {
|
|
215
|
+
s = d.content, d.status === "changed" ? u.push(l) : f.push(l);
|
|
216
216
|
continue;
|
|
217
217
|
}
|
|
218
218
|
}
|
|
219
219
|
c.push(l);
|
|
220
220
|
}
|
|
221
221
|
const p = [];
|
|
222
|
-
e &&
|
|
222
|
+
e && i !== null && p.push({ start: e.contentStart, end: e.contentEnd, content: i }), o && s !== null && p.push({
|
|
223
223
|
start: o.contentStart,
|
|
224
224
|
end: o.contentEnd,
|
|
225
|
-
content:
|
|
226
|
-
}), p.sort((l,
|
|
225
|
+
content: s
|
|
226
|
+
}), p.sort((l, d) => d.start - l.start);
|
|
227
227
|
let k = t;
|
|
228
228
|
for (const l of p)
|
|
229
229
|
k = k.slice(0, l.start) + l.content + k.slice(l.end);
|
|
230
|
-
const
|
|
231
|
-
return { updated: k, changed:
|
|
230
|
+
const m = c.filter((l) => R(t, l));
|
|
231
|
+
return { updated: k, changed: u, unchanged: f, unknown: c, unknownOutsideBlock: m };
|
|
232
232
|
}
|
|
233
|
-
function
|
|
234
|
-
if (!
|
|
235
|
-
throw new
|
|
236
|
-
return
|
|
233
|
+
function rt(t, r) {
|
|
234
|
+
if (!ot(t))
|
|
235
|
+
throw new S();
|
|
236
|
+
return nt(t, r);
|
|
237
237
|
}
|
|
238
|
-
function
|
|
238
|
+
function ot(t) {
|
|
239
239
|
return C(t) !== null || N(t) !== null;
|
|
240
240
|
}
|
|
241
241
|
function h(t, r = 200) {
|
|
@@ -244,8 +244,8 @@ function h(t, r = 200) {
|
|
|
244
244
|
headers: { "Content-Type": "application/json" }
|
|
245
245
|
});
|
|
246
246
|
}
|
|
247
|
-
async function
|
|
248
|
-
const e = await
|
|
247
|
+
async function st(t, r, n) {
|
|
248
|
+
const e = await b.readFile(t, "utf-8"), o = rt(e, n);
|
|
249
249
|
return {
|
|
250
250
|
absPath: t,
|
|
251
251
|
relPath: r,
|
|
@@ -260,92 +260,97 @@ async function ot(t, r, n) {
|
|
|
260
260
|
async function it(t) {
|
|
261
261
|
if (t.changed.length !== 0)
|
|
262
262
|
return B(t.absPath, async () => {
|
|
263
|
-
const r =
|
|
263
|
+
const r = T(t.absPath), n = j(r, `.tmp-${x(8).toString("hex")}.css`);
|
|
264
264
|
try {
|
|
265
|
-
await
|
|
265
|
+
await b.writeFile(n, t.updated, "utf-8"), await b.rename(n, t.absPath);
|
|
266
266
|
} catch (e) {
|
|
267
267
|
try {
|
|
268
|
-
await
|
|
268
|
+
await b.unlink(n);
|
|
269
269
|
} catch {
|
|
270
270
|
}
|
|
271
271
|
throw e;
|
|
272
272
|
}
|
|
273
273
|
});
|
|
274
274
|
}
|
|
275
|
-
async function
|
|
275
|
+
async function at(t) {
|
|
276
276
|
return B(t.absPath, async () => {
|
|
277
|
-
const r =
|
|
277
|
+
const r = T(t.absPath), n = j(r, `.tmp-${x(8).toString("hex")}.css`);
|
|
278
278
|
try {
|
|
279
|
-
return await
|
|
279
|
+
return await b.writeFile(n, t.original, "utf-8"), await b.rename(n, t.absPath), { ok: !0 };
|
|
280
280
|
} catch (e) {
|
|
281
281
|
console.error("[design-token-panel/server] Restore failed for", t.relPath, e);
|
|
282
282
|
try {
|
|
283
|
-
await
|
|
283
|
+
await b.unlink(n);
|
|
284
284
|
} catch {
|
|
285
285
|
}
|
|
286
286
|
return { ok: !1, error: e };
|
|
287
287
|
}
|
|
288
288
|
});
|
|
289
289
|
}
|
|
290
|
-
function
|
|
290
|
+
function ht(t) {
|
|
291
291
|
const { rootDir: r, writeRoot: n, routing: e } = t;
|
|
292
|
-
return async function(
|
|
293
|
-
let
|
|
292
|
+
return async function(i) {
|
|
293
|
+
let s;
|
|
294
294
|
try {
|
|
295
|
-
|
|
295
|
+
s = await i.json();
|
|
296
296
|
} catch {
|
|
297
297
|
return h({ ok: !1, error: "Invalid JSON in request body" }, 400);
|
|
298
298
|
}
|
|
299
|
-
if (typeof
|
|
299
|
+
if (typeof s != "object" || s === null || Array.isArray(s))
|
|
300
300
|
return h({ ok: !1, error: "Request body must be a JSON object" }, 400);
|
|
301
|
-
const { tokens:
|
|
302
|
-
if (typeof
|
|
301
|
+
const { tokens: u } = s;
|
|
302
|
+
if (typeof u != "object" || u === null || Array.isArray(u))
|
|
303
303
|
return h({ ok: !1, error: "tokens must be a JSON object" }, 400);
|
|
304
|
-
if (Object.entries(
|
|
304
|
+
if (Object.entries(u).length === 0)
|
|
305
305
|
return h({ ok: !1, error: "tokens must contain at least one entry" }, 400);
|
|
306
|
-
const { sanitized: c, error: p } =
|
|
306
|
+
const { sanitized: c, error: p } = Q(u);
|
|
307
307
|
if (p || !c)
|
|
308
308
|
return h({ ok: !1, error: p ?? "Invalid tokens" }, 400);
|
|
309
|
-
const { groups: k, rejected:
|
|
310
|
-
if (
|
|
311
|
-
return h({ ok: !1, error: "Unsupported cssVar prefix", rejected:
|
|
309
|
+
const { groups: k, rejected: m } = Z(c, e);
|
|
310
|
+
if (m.length > 0)
|
|
311
|
+
return h({ ok: !1, error: "Unsupported cssVar prefix", rejected: m }, 400);
|
|
312
312
|
if (k.length === 0)
|
|
313
313
|
return h({ ok: !1, error: "No routable tokens supplied" }, 400);
|
|
314
|
-
const l =
|
|
314
|
+
const l = /* @__PURE__ */ new Map();
|
|
315
315
|
for (const a of k) {
|
|
316
|
-
const
|
|
317
|
-
if (!
|
|
316
|
+
const g = D(r, a.relativePath);
|
|
317
|
+
if (!K(n, g))
|
|
318
318
|
return h({ ok: !1, error: `Path not allowed: ${a.relativePath}` }, 400);
|
|
319
|
-
|
|
319
|
+
const w = l.get(g);
|
|
320
|
+
w ? Object.assign(w.groupTokens, a.tokens) : l.set(g, {
|
|
321
|
+
absPath: g,
|
|
322
|
+
relPath: a.relativePath,
|
|
323
|
+
groupTokens: { ...a.tokens }
|
|
324
|
+
});
|
|
320
325
|
}
|
|
321
|
-
const
|
|
322
|
-
for (const { absPath: a, relPath:
|
|
326
|
+
const d = Array.from(l.values()), y = [];
|
|
327
|
+
for (const { absPath: a, relPath: g, groupTokens: w } of d)
|
|
323
328
|
try {
|
|
324
|
-
|
|
325
|
-
} catch (
|
|
326
|
-
return
|
|
329
|
+
y.push(await st(a, g, w));
|
|
330
|
+
} catch (v) {
|
|
331
|
+
return v instanceof S ? (console.error("[design-token-panel/server] No :root or @theme block in", g), h(
|
|
327
332
|
{
|
|
328
333
|
ok: !1,
|
|
329
|
-
error: `No top-level :root { ... } or @theme { ... } block in ${
|
|
334
|
+
error: `No top-level :root { ... } or @theme { ... } block in ${g}`
|
|
330
335
|
},
|
|
331
336
|
409
|
|
332
|
-
)) : (console.error(`[design-token-panel/server] Error computing ${
|
|
337
|
+
)) : (console.error(`[design-token-panel/server] Error computing ${g}:`, v), h({ ok: !1, error: "Failed to read or parse source file" }, 500));
|
|
333
338
|
}
|
|
334
|
-
const
|
|
335
|
-
for (const a of
|
|
339
|
+
const O = [];
|
|
340
|
+
for (const a of y)
|
|
336
341
|
try {
|
|
337
|
-
await it(a),
|
|
338
|
-
} catch (
|
|
339
|
-
console.error(`[design-token-panel/server] Write failed for ${a.relPath}:`,
|
|
340
|
-
const
|
|
341
|
-
for (let
|
|
342
|
-
(await
|
|
343
|
-
return
|
|
342
|
+
await it(a), O.push(a);
|
|
343
|
+
} catch (g) {
|
|
344
|
+
console.error(`[design-token-panel/server] Write failed for ${a.relPath}:`, g);
|
|
345
|
+
const w = [];
|
|
346
|
+
for (let v = O.length - 1; v >= 0; v--)
|
|
347
|
+
(await at(O[v])).ok || w.push(O[v].relPath);
|
|
348
|
+
return w.length > 0 ? h(
|
|
344
349
|
{
|
|
345
350
|
ok: !1,
|
|
346
|
-
error: `Failed to write file ${a.relPath}; rollback also failed for ${
|
|
351
|
+
error: `Failed to write file ${a.relPath}; rollback also failed for ${w.length} file(s) — disk state is inconsistent. Inspect the listed files manually.`,
|
|
347
352
|
failedFile: a.relPath,
|
|
348
|
-
restoreFailures:
|
|
353
|
+
restoreFailures: w
|
|
349
354
|
},
|
|
350
355
|
500
|
|
351
356
|
) : h(
|
|
@@ -357,8 +362,8 @@ function dt(t) {
|
|
|
357
362
|
500
|
|
358
363
|
);
|
|
359
364
|
}
|
|
360
|
-
const
|
|
361
|
-
file: a.relPath.startsWith("/") ?
|
|
365
|
+
const J = y.flatMap((a) => a.unknown), W = y.flatMap((a) => a.unchanged), z = y.flatMap((a) => a.unknownOutsideBlock), I = y.map((a) => ({
|
|
366
|
+
file: a.relPath.startsWith("/") ? P(r, a.relPath) : a.relPath,
|
|
362
367
|
changed: a.changed,
|
|
363
368
|
unchanged: a.unchanged,
|
|
364
369
|
unknown: a.unknown,
|
|
@@ -366,30 +371,30 @@ function dt(t) {
|
|
|
366
371
|
}));
|
|
367
372
|
return h({
|
|
368
373
|
ok: !0,
|
|
369
|
-
updated:
|
|
370
|
-
unknownCssVars:
|
|
371
|
-
unchangedCssVars:
|
|
372
|
-
unknownOutsideBlockCssVars:
|
|
374
|
+
updated: I,
|
|
375
|
+
unknownCssVars: J,
|
|
376
|
+
unchangedCssVars: W,
|
|
377
|
+
unknownOutsideBlockCssVars: z
|
|
373
378
|
});
|
|
374
379
|
};
|
|
375
380
|
}
|
|
376
|
-
function
|
|
381
|
+
function pt(t) {
|
|
377
382
|
let r;
|
|
378
383
|
try {
|
|
379
|
-
r =
|
|
380
|
-
} catch (
|
|
384
|
+
r = q(t, "utf-8");
|
|
385
|
+
} catch (i) {
|
|
381
386
|
throw new Error(
|
|
382
387
|
`[design-token-panel] loadRoutingFromFile: cannot read file at ${t}
|
|
383
|
-
Cause: ${
|
|
388
|
+
Cause: ${i.message}`
|
|
384
389
|
);
|
|
385
390
|
}
|
|
386
391
|
let n;
|
|
387
392
|
try {
|
|
388
393
|
n = JSON.parse(r);
|
|
389
|
-
} catch (
|
|
394
|
+
} catch (i) {
|
|
390
395
|
throw new Error(
|
|
391
396
|
`[design-token-panel] loadRoutingFromFile: invalid JSON in ${t}
|
|
392
|
-
Cause: ${
|
|
397
|
+
Cause: ${i.message}`
|
|
393
398
|
);
|
|
394
399
|
}
|
|
395
400
|
if (n === null || typeof n != "object" || Array.isArray(n))
|
|
@@ -401,21 +406,21 @@ function ht(t) {
|
|
|
401
406
|
throw new Error(
|
|
402
407
|
`[design-token-panel] loadRoutingFromFile: routing map must not be empty (in ${t})`
|
|
403
408
|
);
|
|
404
|
-
for (const
|
|
405
|
-
const
|
|
406
|
-
if (typeof
|
|
409
|
+
for (const i of o) {
|
|
410
|
+
const s = e[i];
|
|
411
|
+
if (typeof s != "string" || s.trim() === "")
|
|
407
412
|
throw new Error(
|
|
408
|
-
`[design-token-panel] loadRoutingFromFile: every value must be a non-empty string, but key "${
|
|
413
|
+
`[design-token-panel] loadRoutingFromFile: every value must be a non-empty string, but key "${i}" has value ${JSON.stringify(s)} (in ${t})`
|
|
409
414
|
);
|
|
410
415
|
}
|
|
411
416
|
return e;
|
|
412
417
|
}
|
|
413
418
|
export {
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
+
U as C,
|
|
420
|
+
G as a,
|
|
421
|
+
ht as c,
|
|
422
|
+
K as i,
|
|
423
|
+
pt as l,
|
|
419
424
|
B as s,
|
|
420
|
-
|
|
425
|
+
Q as v
|
|
421
426
|
};
|
package/dist/server/index.js
CHANGED