@takazudo/zdtp 0.7.0 → 0.8.1
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 +53 -0
- package/dist/apply/build-apply-overrides.d.ts +2 -0
- package/dist/astro/host-adapter.js +3 -3
- package/dist/astro/index.js +1 -1
- package/dist/{autoload-state-CGnis85c.js → autoload-state-CtB0e8mY.js} +1 -1
- package/dist/config/cluster-config.d.ts +10 -2
- package/dist/dashboard/index.d.ts +2 -1
- package/dist/dashboard/index.js +314 -266
- package/dist/dashboard/model.d.ts +3 -1
- package/dist/dashboard/styles.css +107 -32
- package/dist/dashboard/token-dashboard.d.ts +8 -5
- package/dist/dashboard/types.d.ts +19 -3
- package/dist/import-modal.d.ts +21 -22
- package/dist/index-CXkidCHj.js +12948 -0
- package/dist/{index-BcqHRoxf.js → index-DufuQu_v.js} +2 -2
- package/dist/index.d.ts +5 -3
- package/dist/index.js +39 -32
- package/dist/mode-dependence-Ci9avNt8.js +61 -0
- package/dist/{panel-config-Crn5QJGy.js → panel-config-DKfob-1r.js} +314 -301
- package/dist/state/tweak-state.d.ts +17 -7
- package/dist/tabs/_generic-item-editor.d.ts +3 -0
- package/dist/tabs/modes-row.d.ts +58 -0
- package/dist/tabs/palette/palette-check-view.d.ts +1 -1
- package/dist/testing.js +2 -2
- package/dist/tokens/mode-dependence.d.ts +23 -0
- package/dist/tokens/tier-model.d.ts +9 -0
- package/dist/{tweak-state-Dhjqig0C.js → tweak-state-BiaKbhXN.js} +729 -671
- package/dist/utils/design-token-serde.d.ts +32 -2
- package/dist/zdtp.css +1 -1
- package/package.json +1 -1
- package/dist/index-CUWkR-Gb.js +0 -12322
|
@@ -1,66 +1,71 @@
|
|
|
1
|
-
import { DEFAULT_STORAGE_PREFIX as
|
|
1
|
+
import { DEFAULT_STORAGE_PREFIX as M, resolveToggleEventName as z, READABLE_STATE_KEY_SUFFIXES as E } from "./constants.js";
|
|
2
2
|
class k extends Error {
|
|
3
3
|
constructor(t) {
|
|
4
4
|
super(t), this.name = "TierResolverError", Object.setPrototypeOf(this, k.prototype);
|
|
5
5
|
}
|
|
6
6
|
}
|
|
7
|
-
function
|
|
7
|
+
function x(e, t) {
|
|
8
8
|
return e.tiers.find((n) => n.id === t);
|
|
9
9
|
}
|
|
10
10
|
function $(e, t) {
|
|
11
11
|
return e.items.find((n) => n.id === t);
|
|
12
12
|
}
|
|
13
|
-
function te(e, t, n,
|
|
14
|
-
const
|
|
15
|
-
if (!
|
|
13
|
+
function te(e, t, n, c) {
|
|
14
|
+
const p = x(e, t);
|
|
15
|
+
if (!p)
|
|
16
16
|
throw new k(
|
|
17
|
-
`Tier "${t}" not found in tab "${e.id}". Available tiers: ${e.tiers.map((
|
|
17
|
+
`Tier "${t}" not found in tab "${e.id}". Available tiers: ${e.tiers.map((d) => d.id).join(", ")}.`
|
|
18
18
|
);
|
|
19
|
-
const
|
|
20
|
-
if (!
|
|
19
|
+
const g = $(p, n);
|
|
20
|
+
if (!g)
|
|
21
21
|
throw new k(
|
|
22
22
|
`Item "${n}" not found in tier "${t}" of tab "${e.id}".`
|
|
23
23
|
);
|
|
24
|
-
const r =
|
|
25
|
-
if (
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
const r = c[t]?.[n];
|
|
25
|
+
if (r === void 0 && g.modes !== void 0)
|
|
26
|
+
return {
|
|
27
|
+
kind: "literal",
|
|
28
|
+
value: `light-dark(${g.modes.light}, ${g.modes.dark})`
|
|
29
|
+
};
|
|
30
|
+
if (p.referencesTier !== void 0) {
|
|
31
|
+
const d = p.referencesTier, a = x(e, d);
|
|
32
|
+
if (!a)
|
|
28
33
|
throw new k(
|
|
29
|
-
`Tier "${t}" declares referencesTier "${
|
|
34
|
+
`Tier "${t}" declares referencesTier "${d}" but that tier does not exist in tab "${e.id}".`
|
|
30
35
|
);
|
|
31
|
-
const
|
|
32
|
-
if (!
|
|
33
|
-
const
|
|
34
|
-
if (!
|
|
36
|
+
const l = $(a, r ?? n);
|
|
37
|
+
if (!l) {
|
|
38
|
+
const i = $(a, g.default) ?? $(a, n) ?? a.items[0];
|
|
39
|
+
if (!i)
|
|
35
40
|
throw new k(
|
|
36
|
-
`Referenced tier "${
|
|
41
|
+
`Referenced tier "${d}" has no items; cannot resolve fallback for item "${n}" in tier "${t}" of tab "${e.id}".`
|
|
37
42
|
);
|
|
38
|
-
return { kind: "ref", targetCssVar:
|
|
43
|
+
return { kind: "ref", targetCssVar: i.cssVar };
|
|
39
44
|
}
|
|
40
|
-
return { kind: "ref", targetCssVar:
|
|
45
|
+
return { kind: "ref", targetCssVar: l.cssVar };
|
|
41
46
|
}
|
|
42
|
-
return r !== void 0 ?
|
|
47
|
+
return r !== void 0 ? g.pill && r === g.pill.value ? { kind: "literal", value: g.pill.value } : { kind: "literal", value: r } : g.pill ? { kind: "literal", value: g.pill.customDefault } : { kind: "literal", value: g.default };
|
|
43
48
|
}
|
|
44
49
|
function ne(e) {
|
|
45
50
|
return e.kind === "literal" ? e.value : `var(${e.targetCssVar})`;
|
|
46
51
|
}
|
|
47
52
|
function D(e, t, n = [t]) {
|
|
48
|
-
const
|
|
49
|
-
if (!
|
|
53
|
+
const c = e.tab === void 0 || e.tab === t.id ? t : n.find((s) => s.id === e.tab);
|
|
54
|
+
if (!c)
|
|
50
55
|
throw new k(
|
|
51
56
|
`Cross-tab ref target tab "${e.tab}" not found. Available tabs: ${n.map((s) => s.id).join(", ")}.`
|
|
52
57
|
);
|
|
53
|
-
const
|
|
54
|
-
if (!
|
|
58
|
+
const p = x(c, e.tier);
|
|
59
|
+
if (!p)
|
|
55
60
|
throw new k(
|
|
56
|
-
`Cross-tab ref target tier "${e.tier}" not found in tab "${
|
|
61
|
+
`Cross-tab ref target tier "${e.tier}" not found in tab "${c.id}". Available tiers: ${c.tiers.map((s) => s.id).join(", ")}.`
|
|
57
62
|
);
|
|
58
|
-
const
|
|
59
|
-
if (!
|
|
63
|
+
const g = $(p, e.item);
|
|
64
|
+
if (!g)
|
|
60
65
|
throw new k(
|
|
61
|
-
`Cross-tab ref target item "${e.item}" not found in tier "${e.tier}" of tab "${
|
|
66
|
+
`Cross-tab ref target item "${e.item}" not found in tier "${e.tier}" of tab "${c.id}". Available items: ${p.items.map((s) => s.id).join(", ")}.`
|
|
62
67
|
);
|
|
63
|
-
return
|
|
68
|
+
return g.cssVar;
|
|
64
69
|
}
|
|
65
70
|
function re(e, t) {
|
|
66
71
|
return e.paletteCssVarTemplate.replace("{n}", String(t));
|
|
@@ -222,83 +227,77 @@ const H = /* @__PURE__ */ new Set([
|
|
|
222
227
|
"revert",
|
|
223
228
|
"revert-layer"
|
|
224
229
|
]);
|
|
225
|
-
function
|
|
230
|
+
function J(e) {
|
|
226
231
|
return e.startsWith("#") || e.includes("(") || H.has(e.toLowerCase());
|
|
227
232
|
}
|
|
228
|
-
function
|
|
229
|
-
const
|
|
230
|
-
if (
|
|
231
|
-
const r = e.slice(0,
|
|
232
|
-
|
|
233
|
+
function B(e, t, n, c) {
|
|
234
|
+
const p = [], g = e.indexOf(":");
|
|
235
|
+
if (g !== -1) {
|
|
236
|
+
const r = e.slice(0, g), d = e.slice(g + 1), a = t.find((o) => o.tier === r);
|
|
237
|
+
a && p.push({ tab: a.tab, tier: a.tier, item: d });
|
|
233
238
|
}
|
|
234
239
|
const [s] = t;
|
|
235
|
-
|
|
236
|
-
for (const r of
|
|
240
|
+
p.push({ tab: s.tab, tier: s.tier, item: e });
|
|
241
|
+
for (const r of p)
|
|
237
242
|
try {
|
|
238
|
-
return D(r, n,
|
|
243
|
+
return D(r, n, c), { ref: r };
|
|
239
244
|
} catch {
|
|
240
245
|
}
|
|
241
|
-
return { ref:
|
|
246
|
+
return { ref: p[0] };
|
|
242
247
|
}
|
|
243
|
-
function F(e, t, n,
|
|
248
|
+
function F(e, t, n, c, p, g) {
|
|
244
249
|
const s = t.get(e.default);
|
|
245
|
-
return s !== void 0 ? s : e.default === "bg" || e.default === "fg" ? e.default : n && n.length > 0 && !
|
|
250
|
+
return s !== void 0 ? s : e.default === "bg" || e.default === "fg" ? e.default : n && n.length > 0 && !J(e.default) ? B(e.default, n, c, p) : g ? (console.warn(
|
|
246
251
|
`[design-token-panel] semantic item "${e.id}" default "${e.default}" names no palette item; falling back to palette index 0`
|
|
247
252
|
), 0) : { literal: e.default };
|
|
248
253
|
}
|
|
249
254
|
function _(e, t = [e]) {
|
|
250
255
|
const n = e.colorExtras;
|
|
251
256
|
if (!n) return;
|
|
252
|
-
const
|
|
253
|
-
(
|
|
254
|
-
),
|
|
255
|
-
(
|
|
256
|
-
);
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
for (let o = 0; o < d.length; o++)
|
|
273
|
-
f.set(d[o].id, o);
|
|
274
|
-
const l = {}, i = {};
|
|
275
|
-
if (u) {
|
|
276
|
-
const o = !u.semantic, c = n.semanticDefaults;
|
|
277
|
-
for (const g of u.items)
|
|
278
|
-
i[g.id] = g.cssVar, l[g.id] = c && g.id in c ? c[g.id] : F(
|
|
279
|
-
g,
|
|
280
|
-
f,
|
|
281
|
-
u.referencesRamps,
|
|
257
|
+
const c = e.tiers.find(
|
|
258
|
+
(i) => !i.referencesTier && !i.semantic && i.items.length > 0 && (i.items[0].type.kind === "color" || i.items[0].modes !== void 0)
|
|
259
|
+
), p = e.tiers.find(
|
|
260
|
+
(i) => c && i.referencesTier === c.id || i.semantic === !0
|
|
261
|
+
), g = c?.items ?? [], s = g.length, r = {};
|
|
262
|
+
for (let i = 0; i < g.length; i++) {
|
|
263
|
+
const f = g[i].modes;
|
|
264
|
+
f && (r[i] = { ...f });
|
|
265
|
+
}
|
|
266
|
+
const d = g[0] ? g[0].cssVar.replace(/\d+$/, "{n}") : "--zudo-stub-p{n}", a = /* @__PURE__ */ new Map();
|
|
267
|
+
for (let i = 0; i < g.length; i++)
|
|
268
|
+
a.set(g[i].id, i);
|
|
269
|
+
const o = {}, l = {};
|
|
270
|
+
if (p) {
|
|
271
|
+
const i = !p.semantic, f = n.semanticDefaults;
|
|
272
|
+
for (const u of p.items)
|
|
273
|
+
l[u.id] = u.cssVar, u.modes ? o[u.id] = { literal: { ...u.modes } } : o[u.id] = f && u.id in f ? f[u.id] : F(
|
|
274
|
+
u,
|
|
275
|
+
a,
|
|
276
|
+
p.referencesRamps,
|
|
282
277
|
e,
|
|
283
278
|
t,
|
|
284
|
-
|
|
279
|
+
i
|
|
285
280
|
);
|
|
286
281
|
}
|
|
282
|
+
for (const i of e.tiers)
|
|
283
|
+
for (const f of i.items)
|
|
284
|
+
!f.modes || a.has(f.id) || f.id in o || (o[f.id] = { literal: { ...f.modes } }, l[f.id] = f.cssVar);
|
|
287
285
|
return {
|
|
288
286
|
id: n.id,
|
|
289
287
|
label: n.label,
|
|
290
288
|
paletteSize: s,
|
|
289
|
+
...Object.keys(r).length > 0 ? { paletteModes: r } : {},
|
|
291
290
|
baseRoles: n.baseRoles,
|
|
292
|
-
paletteCssVarTemplate:
|
|
293
|
-
semanticDefaults:
|
|
294
|
-
semanticCssNames:
|
|
291
|
+
paletteCssVarTemplate: d,
|
|
292
|
+
semanticDefaults: o,
|
|
293
|
+
semanticCssNames: l,
|
|
295
294
|
baseDefaults: n.baseDefaults,
|
|
296
295
|
defaultShikiTheme: n.defaultShikiTheme,
|
|
297
296
|
colorSchemes: n.colorSchemes,
|
|
298
297
|
panelSettings: n.panelSettings
|
|
299
298
|
};
|
|
300
299
|
}
|
|
301
|
-
function
|
|
300
|
+
function oe(e) {
|
|
302
301
|
const t = e.find((n) => n.id === "color");
|
|
303
302
|
if (t)
|
|
304
303
|
return _(t, e);
|
|
@@ -307,26 +306,26 @@ function L(e) {
|
|
|
307
306
|
const t = e.find((n) => n.id === "color-secondary");
|
|
308
307
|
return t ? _(t, e) ?? null : null;
|
|
309
308
|
}
|
|
310
|
-
function
|
|
309
|
+
function S(e, t) {
|
|
311
310
|
if (Object.is(e, t)) return !0;
|
|
312
311
|
if (e === null || t === null || typeof e != typeof t || typeof e != "object") return !1;
|
|
313
312
|
if (Array.isArray(e)) {
|
|
314
313
|
if (!Array.isArray(t) || e.length !== t.length) return !1;
|
|
315
|
-
for (let
|
|
316
|
-
if (!
|
|
314
|
+
for (let g = 0; g < e.length; g++)
|
|
315
|
+
if (!S(e[g], t[g])) return !1;
|
|
317
316
|
return !0;
|
|
318
317
|
}
|
|
319
318
|
if (Array.isArray(t)) return !1;
|
|
320
|
-
const n = Object.keys(e),
|
|
321
|
-
if (n.length !==
|
|
322
|
-
const
|
|
323
|
-
for (const
|
|
324
|
-
if (!
|
|
319
|
+
const n = Object.keys(e), c = Object.keys(t);
|
|
320
|
+
if (n.length !== c.length) return !1;
|
|
321
|
+
const p = new Set(c);
|
|
322
|
+
for (const g of n)
|
|
323
|
+
if (!p.has(g) || !S(e[g], t[g]))
|
|
325
324
|
return !1;
|
|
326
325
|
return !0;
|
|
327
326
|
}
|
|
328
327
|
const q = {
|
|
329
|
-
storagePrefix:
|
|
328
|
+
storagePrefix: M,
|
|
330
329
|
consoleNamespace: "zudo",
|
|
331
330
|
modalClassPrefix: "zudo-design-token-panel-modal",
|
|
332
331
|
schemaId: "zudo-design-tokens/v1",
|
|
@@ -372,7 +371,7 @@ function G(e) {
|
|
|
372
371
|
}
|
|
373
372
|
};
|
|
374
373
|
}
|
|
375
|
-
function
|
|
374
|
+
function ie(e) {
|
|
376
375
|
h().lifecycleHooks = {
|
|
377
376
|
configured: e.configured,
|
|
378
377
|
open: e.open,
|
|
@@ -382,21 +381,21 @@ function oe(e) {
|
|
|
382
381
|
};
|
|
383
382
|
}
|
|
384
383
|
function se(e) {
|
|
385
|
-
const t = h(), n = e.storagePrefix,
|
|
386
|
-
if (
|
|
387
|
-
const
|
|
388
|
-
if (
|
|
389
|
-
return t.defaultPrefix = n,
|
|
384
|
+
const t = h(), n = e.storagePrefix, c = t.instances.get(n);
|
|
385
|
+
if (c) {
|
|
386
|
+
const a = (o) => ({ ...o, applySink: void 0 });
|
|
387
|
+
if (S(a(c.suppliedConfig), a(e)))
|
|
388
|
+
return t.defaultPrefix = n, c.handle;
|
|
390
389
|
throw new Error(
|
|
391
390
|
`[design-token-panel] configurePanel() was already called with different values for storagePrefix "${n}". Configuration is one-shot per prefix per page lifecycle. To re-configure this prefix, call handle.destroy() first, then configurePanel() again. (Use a distinct storagePrefix for a second panel instance.)`
|
|
392
391
|
);
|
|
393
392
|
}
|
|
394
|
-
const
|
|
393
|
+
const p = t.pendingColorPresets, g = p ? { ...e, colorPresets: p } : { ...e };
|
|
395
394
|
t.pendingColorPresets = null;
|
|
396
395
|
const s = t.instances.size === 0, r = s ? [...t.pendingPostConfigureHooks] : [];
|
|
397
396
|
s && (t.pendingPostConfigureHooks.length = 0);
|
|
398
|
-
const
|
|
399
|
-
config:
|
|
397
|
+
const d = {
|
|
398
|
+
config: g,
|
|
400
399
|
// Snapshot the as-supplied config before any runtime merges. Used by the
|
|
401
400
|
// idempotency guard so view-transition re-calls with the original inline
|
|
402
401
|
// config keep passing even after setPanelColorPresets mutates `config`.
|
|
@@ -405,17 +404,17 @@ function se(e) {
|
|
|
405
404
|
postConfigureHooks: r,
|
|
406
405
|
handle: G(n)
|
|
407
406
|
};
|
|
408
|
-
t.instances.set(n,
|
|
409
|
-
for (const
|
|
410
|
-
|
|
411
|
-
return t.lifecycleHooks.configured?.(n),
|
|
407
|
+
t.instances.set(n, d), t.defaultPrefix = n;
|
|
408
|
+
for (const a of d.postConfigureHooks)
|
|
409
|
+
a();
|
|
410
|
+
return t.lifecycleHooks.configured?.(n), d.handle;
|
|
412
411
|
}
|
|
413
|
-
function
|
|
412
|
+
function j() {
|
|
414
413
|
const e = h();
|
|
415
414
|
return e.defaultPrefix === null ? null : e.instances.get(e.defaultPrefix) ?? null;
|
|
416
415
|
}
|
|
417
416
|
function ae(e) {
|
|
418
|
-
const t =
|
|
417
|
+
const t = j();
|
|
419
418
|
if (t === null) {
|
|
420
419
|
const n = h();
|
|
421
420
|
if (n.pendingPostConfigureHooks.includes(e)) return;
|
|
@@ -424,8 +423,8 @@ function ae(e) {
|
|
|
424
423
|
}
|
|
425
424
|
t.postConfigureHooks.includes(e) || (t.postConfigureHooks.push(e), e());
|
|
426
425
|
}
|
|
427
|
-
function
|
|
428
|
-
return
|
|
426
|
+
function T() {
|
|
427
|
+
return j()?.config ?? q;
|
|
429
428
|
}
|
|
430
429
|
function le() {
|
|
431
430
|
return [...h().instances.values()].map((e) => e.config);
|
|
@@ -441,29 +440,29 @@ function A() {
|
|
|
441
440
|
const e = h();
|
|
442
441
|
return e.colorSchemeOwners || (e.colorSchemeOwners = /* @__PURE__ */ new Set()), e.colorSchemeOwners;
|
|
443
442
|
}
|
|
444
|
-
function
|
|
443
|
+
function de(e) {
|
|
445
444
|
A().add(e);
|
|
446
445
|
}
|
|
447
|
-
function
|
|
446
|
+
function ge(e) {
|
|
448
447
|
A().delete(e);
|
|
449
448
|
}
|
|
450
449
|
function ue(e) {
|
|
451
450
|
return A().has(e);
|
|
452
451
|
}
|
|
453
|
-
function pe(e =
|
|
452
|
+
function pe(e = T()) {
|
|
454
453
|
return L(e.tabs);
|
|
455
454
|
}
|
|
456
455
|
function me(e) {
|
|
457
|
-
return e.storagePrefix +
|
|
456
|
+
return e.storagePrefix + E.v2;
|
|
458
457
|
}
|
|
459
458
|
function ye(e) {
|
|
460
|
-
return e.storagePrefix +
|
|
459
|
+
return e.storagePrefix + E.v3;
|
|
461
460
|
}
|
|
462
461
|
function he(e) {
|
|
463
|
-
return e.storagePrefix +
|
|
462
|
+
return e.storagePrefix + E.v4;
|
|
464
463
|
}
|
|
465
464
|
function we(e) {
|
|
466
|
-
return e.storagePrefix +
|
|
465
|
+
return e.storagePrefix + E.v1;
|
|
467
466
|
}
|
|
468
467
|
function be(e) {
|
|
469
468
|
return `${e.storagePrefix}-spawn-ordinal`;
|
|
@@ -480,32 +479,32 @@ function Ce(e) {
|
|
|
480
479
|
function Pe(e) {
|
|
481
480
|
return `${e.storagePrefix}-dock`;
|
|
482
481
|
}
|
|
483
|
-
function
|
|
482
|
+
function ve(e) {
|
|
484
483
|
return `${e.storagePrefix}-dock-size`;
|
|
485
484
|
}
|
|
486
|
-
function
|
|
485
|
+
function Ee(e) {
|
|
487
486
|
return `${e.storagePrefix}-density`;
|
|
488
487
|
}
|
|
489
488
|
function Ae(e) {
|
|
490
489
|
return `${e.storagePrefix}-specimen`;
|
|
491
490
|
}
|
|
492
|
-
function
|
|
491
|
+
function xe(e, t) {
|
|
493
492
|
return `${e.storagePrefix}-snapshot-${t}`;
|
|
494
493
|
}
|
|
495
|
-
function
|
|
494
|
+
function Se(e) {
|
|
496
495
|
return `${e.storagePrefix}-last-applied`;
|
|
497
496
|
}
|
|
498
|
-
function
|
|
497
|
+
function je(e) {
|
|
499
498
|
return `${e.storagePrefix}:visible`;
|
|
500
499
|
}
|
|
501
|
-
function
|
|
500
|
+
function Te(e) {
|
|
502
501
|
return `${e.storagePrefix}:autoload`;
|
|
503
502
|
}
|
|
504
503
|
function Oe(e) {
|
|
505
504
|
return `${e.storagePrefix}-root`;
|
|
506
505
|
}
|
|
507
506
|
function Re(e) {
|
|
508
|
-
return
|
|
507
|
+
return z(e);
|
|
509
508
|
}
|
|
510
509
|
const U = "__zdtp:open-state-changed";
|
|
511
510
|
function Ve(e) {
|
|
@@ -549,10 +548,10 @@ function Ke(e) {
|
|
|
549
548
|
);
|
|
550
549
|
return;
|
|
551
550
|
}
|
|
552
|
-
const
|
|
553
|
-
|
|
551
|
+
const c = { ...e };
|
|
552
|
+
c[N] = !0, t.zdtp = c;
|
|
554
553
|
}
|
|
555
|
-
function
|
|
554
|
+
function Me(e) {
|
|
556
555
|
if (e === null || typeof e != "object" || Array.isArray(e))
|
|
557
556
|
throw new Error("[design-token-panel] PanelConfig must be a non-null object");
|
|
558
557
|
const t = e;
|
|
@@ -578,8 +577,8 @@ function ze(e) {
|
|
|
578
577
|
if (t.applyRouting !== void 0) {
|
|
579
578
|
if (t.applyRouting === null || typeof t.applyRouting != "object" || Array.isArray(t.applyRouting))
|
|
580
579
|
throw new Error("[design-token-panel] PanelConfig.applyRouting must be a plain object");
|
|
581
|
-
for (const [n,
|
|
582
|
-
if (typeof
|
|
580
|
+
for (const [n, c] of Object.entries(t.applyRouting))
|
|
581
|
+
if (typeof c != "string")
|
|
583
582
|
throw new Error(
|
|
584
583
|
`[design-token-panel] PanelConfig.applyRouting[${JSON.stringify(n)}] must be a string`
|
|
585
584
|
);
|
|
@@ -588,10 +587,10 @@ function ze(e) {
|
|
|
588
587
|
if (t.domTweaker === null || typeof t.domTweaker != "object" || Array.isArray(t.domTweaker))
|
|
589
588
|
throw new Error("[design-token-panel] PanelConfig.domTweaker must be a plain object");
|
|
590
589
|
const n = t.domTweaker;
|
|
591
|
-
for (const
|
|
592
|
-
if (
|
|
590
|
+
for (const c of Object.keys(n))
|
|
591
|
+
if (c !== "themeCss")
|
|
593
592
|
throw new Error(
|
|
594
|
-
`[design-token-panel] PanelConfig.domTweaker.${
|
|
593
|
+
`[design-token-panel] PanelConfig.domTweaker.${c} is not a supported field`
|
|
595
594
|
);
|
|
596
595
|
if (n.themeCss !== void 0) {
|
|
597
596
|
if (typeof n.themeCss != "string")
|
|
@@ -608,9 +607,9 @@ function ze(e) {
|
|
|
608
607
|
if (t.dock === null || typeof t.dock != "object" || Array.isArray(t.dock))
|
|
609
608
|
throw new Error("[design-token-panel] PanelConfig.dock must be a plain object");
|
|
610
609
|
const n = t.dock;
|
|
611
|
-
for (const
|
|
612
|
-
if (
|
|
613
|
-
throw new Error(`[design-token-panel] PanelConfig.dock.${
|
|
610
|
+
for (const c of Object.keys(n))
|
|
611
|
+
if (c !== "reflow")
|
|
612
|
+
throw new Error(`[design-token-panel] PanelConfig.dock.${c} is not a supported field`);
|
|
614
613
|
if (n.reflow !== void 0 && n.reflow !== "body-margin" && n.reflow !== "none")
|
|
615
614
|
throw new Error(
|
|
616
615
|
'[design-token-panel] PanelConfig.dock.reflow must be "body-margin" or "none" when set'
|
|
@@ -623,10 +622,10 @@ function ze(e) {
|
|
|
623
622
|
if (t.legacyIdRenameMap !== void 0) {
|
|
624
623
|
if (t.legacyIdRenameMap === null || typeof t.legacyIdRenameMap != "object" || Array.isArray(t.legacyIdRenameMap))
|
|
625
624
|
throw new Error("[design-token-panel] PanelConfig.legacyIdRenameMap must be a plain object");
|
|
626
|
-
for (const [n,
|
|
627
|
-
if (
|
|
625
|
+
for (const [n, c] of Object.entries(t.legacyIdRenameMap))
|
|
626
|
+
if (c !== null && typeof c != "string")
|
|
628
627
|
throw new Error(
|
|
629
|
-
`[design-token-panel] PanelConfig.legacyIdRenameMap[${JSON.stringify(n)}] must be a string or null (got ${typeof
|
|
628
|
+
`[design-token-panel] PanelConfig.legacyIdRenameMap[${JSON.stringify(n)}] must be a string or null (got ${typeof c})`
|
|
630
629
|
);
|
|
631
630
|
}
|
|
632
631
|
}
|
|
@@ -637,14 +636,14 @@ function Z(e) {
|
|
|
637
636
|
for (const n of e) {
|
|
638
637
|
if (n === null || typeof n != "object" || Array.isArray(n))
|
|
639
638
|
throw new Error("[design-token-panel] PanelConfig.tabs: each tab must be a non-null object");
|
|
640
|
-
const
|
|
641
|
-
if (typeof
|
|
639
|
+
const c = n;
|
|
640
|
+
if (typeof c.id != "string" || c.id.length === 0)
|
|
642
641
|
throw new Error("[design-token-panel] PanelConfig.tabs: each tab must have a non-empty string id");
|
|
643
|
-
if (t.has(
|
|
642
|
+
if (t.has(c.id))
|
|
644
643
|
throw new Error(
|
|
645
|
-
`[design-token-panel] PanelConfig.tabs: duplicate tab id "${
|
|
644
|
+
`[design-token-panel] PanelConfig.tabs: duplicate tab id "${c.id}"`
|
|
646
645
|
);
|
|
647
|
-
t.add(
|
|
646
|
+
t.add(c.id), Q(c.id, c, e);
|
|
648
647
|
}
|
|
649
648
|
}
|
|
650
649
|
function X(e) {
|
|
@@ -655,14 +654,14 @@ function X(e) {
|
|
|
655
654
|
const n = t.literal;
|
|
656
655
|
if (typeof n == "string") return !0;
|
|
657
656
|
if (n === null || typeof n != "object" || Array.isArray(n)) return !1;
|
|
658
|
-
const
|
|
659
|
-
return typeof
|
|
657
|
+
const c = n;
|
|
658
|
+
return typeof c.light == "string" && typeof c.dark == "string";
|
|
660
659
|
}
|
|
661
660
|
if ("ref" in t) {
|
|
662
661
|
const n = t.ref;
|
|
663
662
|
if (n === null || typeof n != "object" || Array.isArray(n)) return !1;
|
|
664
|
-
const
|
|
665
|
-
return !(typeof
|
|
663
|
+
const c = n;
|
|
664
|
+
return !(typeof c.tier != "string" || typeof c.item != "string" || c.tab !== void 0 && typeof c.tab != "string");
|
|
666
665
|
}
|
|
667
666
|
return !1;
|
|
668
667
|
}
|
|
@@ -671,7 +670,7 @@ function Q(e, t, n) {
|
|
|
671
670
|
throw new Error(
|
|
672
671
|
`[design-token-panel] PanelConfig.tabs["${e}"].tiers must be an array`
|
|
673
672
|
);
|
|
674
|
-
const
|
|
673
|
+
const c = /* @__PURE__ */ new Set(), p = /* @__PURE__ */ new Map();
|
|
675
674
|
for (const s of t.tiers) {
|
|
676
675
|
if (s === null || typeof s != "object" || Array.isArray(s))
|
|
677
676
|
throw new Error(
|
|
@@ -682,15 +681,15 @@ function Q(e, t, n) {
|
|
|
682
681
|
throw new Error(
|
|
683
682
|
`[design-token-panel] PanelConfig.tabs["${e}"].tiers: each tier must have a non-empty string id`
|
|
684
683
|
);
|
|
685
|
-
if (
|
|
684
|
+
if (c.has(r.id))
|
|
686
685
|
throw new Error(
|
|
687
686
|
`[design-token-panel] PanelConfig.tabs["${e}"]: duplicate tier id "${r.id}"`
|
|
688
687
|
);
|
|
689
|
-
if (
|
|
688
|
+
if (c.add(r.id), r.semantic !== void 0 && r.semantic !== !0)
|
|
690
689
|
throw new Error(
|
|
691
690
|
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${r.id}"].semantic must be exactly \`true\` when present (got ${JSON.stringify(r.semantic)})`
|
|
692
691
|
);
|
|
693
|
-
const
|
|
692
|
+
const d = /* @__PURE__ */ new Set([
|
|
694
693
|
"size",
|
|
695
694
|
"line-height",
|
|
696
695
|
"family",
|
|
@@ -699,7 +698,7 @@ function Q(e, t, n) {
|
|
|
699
698
|
"radius",
|
|
700
699
|
"duration"
|
|
701
700
|
]);
|
|
702
|
-
if (r.preview !== void 0 && !
|
|
701
|
+
if (r.preview !== void 0 && !d.has(r.preview))
|
|
703
702
|
throw new Error(
|
|
704
703
|
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${r.id}"].preview has unsupported value ${JSON.stringify(r.preview)}`
|
|
705
704
|
);
|
|
@@ -715,150 +714,164 @@ function Q(e, t, n) {
|
|
|
715
714
|
throw new Error(
|
|
716
715
|
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${r.id}"].items must be an array`
|
|
717
716
|
);
|
|
718
|
-
let
|
|
719
|
-
for (const
|
|
717
|
+
let a;
|
|
718
|
+
for (const o of r.items) {
|
|
719
|
+
if (o === null || typeof o != "object" || Array.isArray(o)) continue;
|
|
720
|
+
const i = o.type;
|
|
720
721
|
if (i === null || typeof i != "object" || Array.isArray(i)) continue;
|
|
721
|
-
const
|
|
722
|
-
if (
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
if (
|
|
726
|
-
l = g;
|
|
727
|
-
else if (l !== g)
|
|
722
|
+
const f = i.kind;
|
|
723
|
+
if (typeof f == "string") {
|
|
724
|
+
if (a === void 0)
|
|
725
|
+
a = f;
|
|
726
|
+
else if (a !== f)
|
|
728
727
|
throw new Error(
|
|
729
|
-
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${r.id}"]: mixed item kinds — found "${
|
|
728
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${r.id}"]: mixed item kinds — found "${a}" and "${f}" in the same tier (all items must share the same kind)`
|
|
730
729
|
);
|
|
731
730
|
}
|
|
732
731
|
}
|
|
733
|
-
|
|
732
|
+
a !== void 0 && p.set(r.id, a);
|
|
734
733
|
}
|
|
735
|
-
const
|
|
734
|
+
const g = /* @__PURE__ */ new Set();
|
|
736
735
|
for (const s of t.tiers) {
|
|
737
|
-
const r = s,
|
|
738
|
-
for (const
|
|
739
|
-
if (
|
|
736
|
+
const r = s, d = r.id;
|
|
737
|
+
for (const a of r.items) {
|
|
738
|
+
if (a === null || typeof a != "object" || Array.isArray(a))
|
|
740
739
|
throw new Error(
|
|
741
|
-
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${
|
|
740
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${d}"].items: each item must be a non-null object`
|
|
742
741
|
);
|
|
743
|
-
const
|
|
744
|
-
if (typeof
|
|
742
|
+
const o = a;
|
|
743
|
+
if (typeof o.id != "string" || o.id.length === 0)
|
|
745
744
|
throw new Error(
|
|
746
|
-
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${
|
|
745
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${d}"].items: each item must have a non-empty string id`
|
|
747
746
|
);
|
|
748
|
-
if (
|
|
747
|
+
if (g.has(o.id))
|
|
749
748
|
throw new Error(
|
|
750
|
-
`[design-token-panel] PanelConfig.tabs["${e}"]: duplicate item id "${
|
|
749
|
+
`[design-token-panel] PanelConfig.tabs["${e}"]: duplicate item id "${o.id}" (item ids must be unique across all tiers within a tab)`
|
|
751
750
|
);
|
|
752
|
-
if (
|
|
751
|
+
if (g.add(o.id), typeof o.cssVar != "string" || !o.cssVar.startsWith("--"))
|
|
753
752
|
throw new Error(
|
|
754
|
-
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${
|
|
753
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${d}"].items["${o.id}"].cssVar must start with "--" (got ${JSON.stringify(o.cssVar)})`
|
|
755
754
|
);
|
|
756
|
-
if (
|
|
755
|
+
if (o.cssVar.length <= 2)
|
|
757
756
|
throw new Error(
|
|
758
|
-
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${
|
|
757
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${d}"].items["${o.id}"].cssVar must be non-empty after "--"`
|
|
759
758
|
);
|
|
760
|
-
const
|
|
761
|
-
if (o
|
|
762
|
-
const
|
|
763
|
-
if (
|
|
759
|
+
const l = o.type;
|
|
760
|
+
if (o.modes !== void 0) {
|
|
761
|
+
const i = `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${d}"].items["${o.id}"].modes`;
|
|
762
|
+
if (o.modes === null || typeof o.modes != "object" || Array.isArray(o.modes))
|
|
763
|
+
throw new Error(`${i} must be a plain object`);
|
|
764
|
+
const f = l !== null && typeof l == "object" && !Array.isArray(l) ? l.kind : void 0;
|
|
765
|
+
if (f !== "color" && f !== "text")
|
|
766
|
+
throw new Error(
|
|
767
|
+
`${i} is only valid when type.kind is "color" or "text" (got ${JSON.stringify(f)})`
|
|
768
|
+
);
|
|
769
|
+
const u = o.modes;
|
|
770
|
+
for (const m of ["light", "dark"])
|
|
771
|
+
if (typeof u[m] != "string" || u[m].trim().length === 0)
|
|
772
|
+
throw new Error(`${i}.${m} must be a non-empty string`);
|
|
773
|
+
}
|
|
774
|
+
if (l !== null && typeof l == "object" && !Array.isArray(l) && l.kind === "length" && l.units !== void 0) {
|
|
775
|
+
const i = l.units;
|
|
776
|
+
if (!Array.isArray(i))
|
|
764
777
|
throw new Error(
|
|
765
|
-
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${
|
|
778
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${d}"].items["${o.id}"].type.units must be an array`
|
|
766
779
|
);
|
|
767
|
-
const
|
|
768
|
-
for (const
|
|
769
|
-
if (typeof
|
|
780
|
+
const f = /* @__PURE__ */ new Set();
|
|
781
|
+
for (const u of i) {
|
|
782
|
+
if (typeof u != "string" || u.length === 0)
|
|
770
783
|
throw new Error(
|
|
771
|
-
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${
|
|
784
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${d}"].items["${o.id}"].type.units entries must be non-empty strings (got ${JSON.stringify(u)})`
|
|
772
785
|
);
|
|
773
|
-
if (
|
|
786
|
+
if (f.has(u))
|
|
774
787
|
throw new Error(
|
|
775
|
-
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${
|
|
788
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${d}"].items["${o.id}"].type.units: duplicate unit ${JSON.stringify(u)}`
|
|
776
789
|
);
|
|
777
|
-
|
|
790
|
+
f.add(u);
|
|
778
791
|
}
|
|
779
792
|
}
|
|
780
793
|
}
|
|
781
794
|
}
|
|
782
795
|
for (const s of t.tiers) {
|
|
783
|
-
const r = s,
|
|
796
|
+
const r = s, d = r.id;
|
|
784
797
|
if (r.referencesTier !== void 0) {
|
|
785
798
|
if (typeof r.referencesTier != "string")
|
|
786
799
|
throw new Error(
|
|
787
|
-
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${
|
|
800
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${d}"].referencesTier must be a string`
|
|
788
801
|
);
|
|
789
|
-
const
|
|
790
|
-
if (!
|
|
802
|
+
const a = r.referencesTier;
|
|
803
|
+
if (!c.has(a))
|
|
791
804
|
throw new Error(
|
|
792
|
-
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${
|
|
805
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${d}"].referencesTier: tier "${a}" does not exist in this tab`
|
|
793
806
|
);
|
|
794
|
-
const
|
|
795
|
-
if (
|
|
807
|
+
const o = p.get(d), l = p.get(a);
|
|
808
|
+
if (o !== void 0 && l !== void 0 && o !== "text" && o !== l)
|
|
796
809
|
throw new Error(
|
|
797
|
-
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${
|
|
810
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${d}"].referencesTier: referencing tier has kind "${o}" but referenced tier "${a}" has kind "${l}" (cross-kind reference is only allowed when the referencing tier has kind "text")`
|
|
798
811
|
);
|
|
799
812
|
}
|
|
800
813
|
}
|
|
801
814
|
for (const s of t.tiers) {
|
|
802
|
-
const r = s,
|
|
803
|
-
if (
|
|
804
|
-
const
|
|
815
|
+
const r = s, d = r.id, a = r.preview;
|
|
816
|
+
if (a === void 0) continue;
|
|
817
|
+
const o = p.get(d), l = typeof r.referencesTier == "string" ? p.get(r.referencesTier) : void 0, i = (f) => {
|
|
805
818
|
throw new Error(
|
|
806
|
-
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${
|
|
819
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${d}"].preview "${a}" requires ${f}`
|
|
807
820
|
);
|
|
808
821
|
};
|
|
809
|
-
if (
|
|
810
|
-
|
|
811
|
-
for (const
|
|
812
|
-
if (
|
|
822
|
+
if (a === "size" && (r.referencesTier === void 0 ? o !== "length" : l !== "length") && i("a length tier or a reference tier resolving to length"), a === "line-height" && o !== "number" && i("a number tier"), a === "family" && o !== "text" && i("a text tier"), a === "weight" && o !== "select" && o !== "number" && i("a select or number tier"), (a === "bar" || a === "radius") && o !== "length" && i("a length tier"), a === "duration") {
|
|
823
|
+
o !== "length" && o !== "number" && i('a length or number tier with unit "ms" or "s"');
|
|
824
|
+
for (const f of r.items) {
|
|
825
|
+
if (f === null || typeof f != "object" || Array.isArray(f))
|
|
813
826
|
continue;
|
|
814
|
-
const
|
|
815
|
-
m !== "ms" && m !== "s" &&
|
|
827
|
+
const u = f.type, m = u !== null && typeof u == "object" && !Array.isArray(u) ? u.unit : void 0;
|
|
828
|
+
m !== "ms" && m !== "s" && i('a length or number tier with unit "ms" or "s"');
|
|
816
829
|
}
|
|
817
830
|
}
|
|
818
831
|
}
|
|
819
832
|
for (const s of t.tiers) {
|
|
820
|
-
const r = s,
|
|
833
|
+
const r = s, d = r.id;
|
|
821
834
|
if (r.referencesRamps === void 0) continue;
|
|
822
835
|
if (r.semantic !== !0)
|
|
823
836
|
throw new Error(
|
|
824
|
-
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${
|
|
837
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${d}"].referencesRamps is only valid on a tier with semantic: true`
|
|
825
838
|
);
|
|
826
839
|
if (!Array.isArray(r.referencesRamps))
|
|
827
840
|
throw new Error(
|
|
828
|
-
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${
|
|
841
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${d}"].referencesRamps must be an array`
|
|
829
842
|
);
|
|
830
843
|
if (e !== "color" && e !== "color-secondary")
|
|
831
844
|
throw new Error(
|
|
832
|
-
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${
|
|
845
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${d}"].referencesRamps is only supported on tabs with id "color" or "color-secondary" (got "${e}")`
|
|
833
846
|
);
|
|
834
|
-
const
|
|
835
|
-
for (let
|
|
836
|
-
const
|
|
837
|
-
if (
|
|
847
|
+
const a = p.get(d), o = r.referencesRamps;
|
|
848
|
+
for (let l = 0; l < o.length; l++) {
|
|
849
|
+
const i = o[l];
|
|
850
|
+
if (i === null || typeof i != "object" || Array.isArray(i))
|
|
838
851
|
throw new Error(
|
|
839
|
-
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${
|
|
852
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${d}"].referencesRamps[${l}] must be a non-null object`
|
|
840
853
|
);
|
|
841
|
-
const
|
|
842
|
-
if (typeof
|
|
854
|
+
const f = i;
|
|
855
|
+
if (typeof f.tier != "string" || f.tier.length === 0)
|
|
843
856
|
throw new Error(
|
|
844
|
-
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${
|
|
857
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${d}"].referencesRamps[${l}].tier must be a non-empty string`
|
|
845
858
|
);
|
|
846
|
-
if (
|
|
859
|
+
if (f.tab !== void 0 && (typeof f.tab != "string" || f.tab.length === 0))
|
|
847
860
|
throw new Error(
|
|
848
|
-
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${
|
|
861
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${d}"].referencesRamps[${l}].tab must be a non-empty string when set`
|
|
849
862
|
);
|
|
850
|
-
const
|
|
863
|
+
const u = f.tab === void 0 ? e : f.tab;
|
|
851
864
|
let m;
|
|
852
|
-
if (
|
|
865
|
+
if (u === e)
|
|
853
866
|
m = t;
|
|
854
867
|
else {
|
|
855
868
|
const b = n.find(
|
|
856
|
-
(y) => y !== null && typeof y == "object" && !Array.isArray(y) && y.id ===
|
|
869
|
+
(y) => y !== null && typeof y == "object" && !Array.isArray(y) && y.id === u
|
|
857
870
|
);
|
|
858
871
|
if (!b) {
|
|
859
872
|
const y = n.filter((w) => w !== null && typeof w == "object" && !Array.isArray(w)).map((w) => w.id).join(", ");
|
|
860
873
|
throw new Error(
|
|
861
|
-
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${
|
|
874
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${d}"].referencesRamps[${l}]: tab "${u}" does not exist. Available tabs: ${y}.`
|
|
862
875
|
);
|
|
863
876
|
}
|
|
864
877
|
m = b;
|
|
@@ -868,28 +881,28 @@ function Q(e, t, n) {
|
|
|
868
881
|
for (const b of C) {
|
|
869
882
|
if (b === null || typeof b != "object" || Array.isArray(b)) continue;
|
|
870
883
|
const y = b;
|
|
871
|
-
typeof y.id == "string" && (O.push(y.id), y.id ===
|
|
884
|
+
typeof y.id == "string" && (O.push(y.id), y.id === f.tier && (P = y));
|
|
872
885
|
}
|
|
873
886
|
if (!P)
|
|
874
887
|
throw new Error(
|
|
875
|
-
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${
|
|
888
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${d}"].referencesRamps[${l}]: tier "${f.tier}" does not exist in tab "${u}". Available tiers: ${O.join(", ")}.`
|
|
876
889
|
);
|
|
877
|
-
if (
|
|
890
|
+
if (a !== void 0) {
|
|
878
891
|
const b = Array.isArray(P.items) ? P.items : [];
|
|
879
892
|
let y;
|
|
880
893
|
for (const w of b) {
|
|
881
894
|
if (w === null || typeof w != "object" || Array.isArray(w)) continue;
|
|
882
|
-
const
|
|
883
|
-
if (
|
|
884
|
-
const R =
|
|
895
|
+
const v = w.type;
|
|
896
|
+
if (v === null || typeof v != "object" || Array.isArray(v)) continue;
|
|
897
|
+
const R = v.kind;
|
|
885
898
|
if (typeof R == "string") {
|
|
886
899
|
y = R;
|
|
887
900
|
break;
|
|
888
901
|
}
|
|
889
902
|
}
|
|
890
|
-
if (y !== void 0 &&
|
|
903
|
+
if (y !== void 0 && a !== y)
|
|
891
904
|
throw new Error(
|
|
892
|
-
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${
|
|
905
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${d}"].referencesRamps[${l}]: referencing semantic tier has kind "${a}" but target tier "${f.tier}" in tab "${u}" has kind "${y}" (cross-tab ramp sources must share the semantic tier's kind)`
|
|
893
906
|
);
|
|
894
907
|
}
|
|
895
908
|
}
|
|
@@ -900,31 +913,31 @@ function Q(e, t, n) {
|
|
|
900
913
|
'[design-token-panel] PanelConfig.tabs["palette"].colorExtras must be absent — multiple kind:"color" tiers are only safe when resolveColorClusterFromTab is not invoked'
|
|
901
914
|
);
|
|
902
915
|
for (const s of t.tiers) {
|
|
903
|
-
const r = s.items,
|
|
916
|
+
const r = s.items, d = `[design-token-panel] PanelConfig.tabs["palette"].tiers["${s.id}"]`;
|
|
904
917
|
if (r.length === 0)
|
|
905
|
-
throw new Error(`${
|
|
906
|
-
for (const [
|
|
907
|
-
if (
|
|
908
|
-
throw new Error(`${
|
|
909
|
-
const
|
|
910
|
-
if (
|
|
911
|
-
const
|
|
912
|
-
for (const [
|
|
913
|
-
const
|
|
914
|
-
if (!Number.isSafeInteger(
|
|
918
|
+
throw new Error(`${d}.items must be non-empty`);
|
|
919
|
+
for (const [l, i] of r.entries())
|
|
920
|
+
if (i.type.kind !== "color")
|
|
921
|
+
throw new Error(`${d}.items[${l}].type.kind must be "color"`);
|
|
922
|
+
const a = r[0].cssVar, o = a.replace(/\d+$/, "{n}");
|
|
923
|
+
if (o.includes("{n}")) {
|
|
924
|
+
const l = Number(a.match(/\d+$/)[0]);
|
|
925
|
+
for (const [i, f] of r.entries()) {
|
|
926
|
+
const u = o.replace("{n}", String(l + i));
|
|
927
|
+
if (!Number.isSafeInteger(l + i) || f.cssVar !== u)
|
|
915
928
|
throw new Error(
|
|
916
|
-
`${
|
|
929
|
+
`${d}.items[${i}].cssVar is ${JSON.stringify(f.cssVar)} but expected ${JSON.stringify(u)} — palette item cssVars must share one prefix and be numbered consecutively in tier order`
|
|
917
930
|
);
|
|
918
931
|
}
|
|
919
932
|
} else {
|
|
920
|
-
const
|
|
921
|
-
for (const [
|
|
922
|
-
const m =
|
|
923
|
-
if (r.length > 1 &&
|
|
933
|
+
const l = a.slice(0, a.lastIndexOf("-") + 1), i = /* @__PURE__ */ new Set();
|
|
934
|
+
for (const [f, u] of r.entries()) {
|
|
935
|
+
const m = u.cssVar;
|
|
936
|
+
if (r.length > 1 && l === "--" || !m.startsWith(l) || m.length === l.length || /\d+$/.test(m) || i.has(m))
|
|
924
937
|
throw new Error(
|
|
925
|
-
`${
|
|
938
|
+
`${d}.items[${f}].cssVar ${JSON.stringify(m)} — named palette item cssVars must share one prefix and have unique non-numbered suffixes`
|
|
926
939
|
);
|
|
927
|
-
|
|
940
|
+
i.add(m);
|
|
928
941
|
}
|
|
929
942
|
}
|
|
930
943
|
}
|
|
@@ -935,15 +948,15 @@ function Q(e, t, n) {
|
|
|
935
948
|
throw new Error(
|
|
936
949
|
`[design-token-panel] PanelConfig.tabs["${e}"].colorExtras must be a plain object`
|
|
937
950
|
);
|
|
938
|
-
for (const
|
|
939
|
-
if (typeof s[
|
|
951
|
+
for (const o of ["id", "defaultShikiTheme"])
|
|
952
|
+
if (typeof s[o] != "string" || s[o].length === 0)
|
|
940
953
|
throw new Error(
|
|
941
|
-
`[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.${
|
|
954
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.${o} must be a non-empty string (got ${typeof s[o]})`
|
|
942
955
|
);
|
|
943
|
-
for (const
|
|
944
|
-
if (s[
|
|
956
|
+
for (const o of ["colorSchemes", "baseRoles", "baseDefaults"])
|
|
957
|
+
if (s[o] === void 0 || s[o] === null || typeof s[o] != "object" || Array.isArray(s[o]))
|
|
945
958
|
throw new Error(
|
|
946
|
-
`[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.${
|
|
959
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.${o} must be a plain object`
|
|
947
960
|
);
|
|
948
961
|
if (s.panelSettings === void 0 || s.panelSettings === null || typeof s.panelSettings != "object" || Array.isArray(s.panelSettings))
|
|
949
962
|
throw new Error(
|
|
@@ -959,15 +972,15 @@ function Q(e, t, n) {
|
|
|
959
972
|
throw new Error(
|
|
960
973
|
`[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.panelSettings.colorMode must be false or a plain object`
|
|
961
974
|
);
|
|
962
|
-
const
|
|
963
|
-
for (const
|
|
964
|
-
if (typeof
|
|
975
|
+
const o = r.colorMode;
|
|
976
|
+
for (const l of ["lightScheme", "darkScheme"])
|
|
977
|
+
if (typeof o[l] != "string" || o[l].length === 0)
|
|
965
978
|
throw new Error(
|
|
966
|
-
`[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.panelSettings.colorMode.${
|
|
979
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.panelSettings.colorMode.${l} must be a non-empty string`
|
|
967
980
|
);
|
|
968
|
-
if (
|
|
981
|
+
if (o.defaultMode !== "light" && o.defaultMode !== "dark")
|
|
969
982
|
throw new Error(
|
|
970
|
-
`[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.panelSettings.colorMode.defaultMode must be "light" or "dark" (got ${JSON.stringify(
|
|
983
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.panelSettings.colorMode.defaultMode must be "light" or "dark" (got ${JSON.stringify(o.defaultMode)})`
|
|
971
984
|
);
|
|
972
985
|
}
|
|
973
986
|
if (s.semanticDefaults !== void 0) {
|
|
@@ -975,37 +988,37 @@ function Q(e, t, n) {
|
|
|
975
988
|
throw new Error(
|
|
976
989
|
`[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.semanticDefaults must be a plain object`
|
|
977
990
|
);
|
|
978
|
-
const
|
|
979
|
-
for (const [
|
|
980
|
-
if (!X(
|
|
991
|
+
const o = s.semanticDefaults;
|
|
992
|
+
for (const [l, i] of Object.entries(o))
|
|
993
|
+
if (!X(i))
|
|
981
994
|
throw new Error(
|
|
982
|
-
`[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.semanticDefaults["${
|
|
995
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.semanticDefaults["${l}"] must be a valid SemanticValue (number | 'bg' | 'fg' | { literal: string } | { literal: { light, dark } } | { ref: { tier, item, tab? } }), got ${JSON.stringify(i)}`
|
|
983
996
|
);
|
|
984
997
|
}
|
|
985
|
-
const
|
|
986
|
-
if (
|
|
987
|
-
const
|
|
988
|
-
if (!Array.isArray(
|
|
989
|
-
const
|
|
990
|
-
if (
|
|
991
|
-
const
|
|
992
|
-
return
|
|
998
|
+
const a = t.tiers.find((o) => {
|
|
999
|
+
if (o.referencesTier !== void 0 || o.semantic === !0) return !1;
|
|
1000
|
+
const l = o.items;
|
|
1001
|
+
if (!Array.isArray(l) || l.length === 0) return !1;
|
|
1002
|
+
const i = l[0];
|
|
1003
|
+
if (i === null || typeof i != "object" || Array.isArray(i)) return !1;
|
|
1004
|
+
const f = i.type;
|
|
1005
|
+
return f === null || typeof f != "object" || Array.isArray(f) ? !1 : f.kind === "color";
|
|
993
1006
|
});
|
|
994
|
-
if (
|
|
995
|
-
const
|
|
996
|
-
if (
|
|
997
|
-
const
|
|
998
|
-
if (
|
|
999
|
-
for (let
|
|
1000
|
-
const m =
|
|
1007
|
+
if (a) {
|
|
1008
|
+
const o = a.id, l = a.items, i = l[0]?.cssVar;
|
|
1009
|
+
if (i !== void 0) {
|
|
1010
|
+
const f = i.replace(/\d+$/, "{n}");
|
|
1011
|
+
if (f.includes("{n}"))
|
|
1012
|
+
for (let u = 0; u < l.length; u++) {
|
|
1013
|
+
const m = l[u], C = f.replace("{n}", String(u));
|
|
1001
1014
|
if (m.cssVar !== C)
|
|
1002
1015
|
throw new Error(
|
|
1003
|
-
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${
|
|
1016
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${o}"].items[${u}].cssVar is ${JSON.stringify(m.cssVar)} but expected ${JSON.stringify(C)} — palette item cssVars must share one prefix and be numbered 0..n-1 in tier order (template derived from first item: ${JSON.stringify(f)})`
|
|
1004
1017
|
);
|
|
1005
1018
|
}
|
|
1006
|
-
else if (
|
|
1019
|
+
else if (l.length > 1)
|
|
1007
1020
|
throw new Error(
|
|
1008
|
-
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${
|
|
1021
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${o}"].items[0].cssVar ${JSON.stringify(i)} has no trailing digit — palette item cssVars must share one prefix and be numbered 0..n-1 in tier order (e.g. "--pal-0" … "--pal-15")`
|
|
1009
1022
|
);
|
|
1010
1023
|
}
|
|
1011
1024
|
}
|
|
@@ -1034,14 +1047,14 @@ function Q(e, t, n) {
|
|
|
1034
1047
|
`[design-token-panel] PanelConfig.tabs["${e}"].notesExtras must only be set on a tab with id "notes"`
|
|
1035
1048
|
);
|
|
1036
1049
|
}
|
|
1037
|
-
function I(e =
|
|
1050
|
+
function I(e = T()) {
|
|
1038
1051
|
return e.applyRouting ?? {};
|
|
1039
1052
|
}
|
|
1040
|
-
function
|
|
1053
|
+
function ze(e = T()) {
|
|
1041
1054
|
return !!e.applyEndpoint && Object.keys(I(e)).length > 0;
|
|
1042
1055
|
}
|
|
1043
1056
|
function De(e) {
|
|
1044
|
-
const t =
|
|
1057
|
+
const t = j();
|
|
1045
1058
|
if (t === null) {
|
|
1046
1059
|
h().pendingColorPresets = e;
|
|
1047
1060
|
return;
|
|
@@ -1051,15 +1064,15 @@ function De(e) {
|
|
|
1051
1064
|
export {
|
|
1052
1065
|
D as A,
|
|
1053
1066
|
_ as B,
|
|
1054
|
-
|
|
1067
|
+
S as C,
|
|
1055
1068
|
Ne as D,
|
|
1056
1069
|
I as E,
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1070
|
+
ze as F,
|
|
1071
|
+
Se as G,
|
|
1072
|
+
xe as H,
|
|
1060
1073
|
Ae as I,
|
|
1061
1074
|
Ve as J,
|
|
1062
|
-
|
|
1075
|
+
ie as K,
|
|
1063
1076
|
ae as L,
|
|
1064
1077
|
Re as M,
|
|
1065
1078
|
le as N,
|
|
@@ -1067,30 +1080,30 @@ export {
|
|
|
1067
1080
|
Oe as P,
|
|
1068
1081
|
be as Q,
|
|
1069
1082
|
ce as _,
|
|
1070
|
-
|
|
1071
|
-
|
|
1083
|
+
je as a,
|
|
1084
|
+
Me as b,
|
|
1072
1085
|
se as c,
|
|
1073
1086
|
ke as d,
|
|
1074
1087
|
$e as e,
|
|
1075
1088
|
we as f,
|
|
1076
|
-
|
|
1089
|
+
T as g,
|
|
1077
1090
|
me as h,
|
|
1078
1091
|
Ke as i,
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1092
|
+
Te as j,
|
|
1093
|
+
te as k,
|
|
1094
|
+
ne as l,
|
|
1082
1095
|
_e as m,
|
|
1083
1096
|
de as n,
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1097
|
+
he as o,
|
|
1098
|
+
ye as p,
|
|
1099
|
+
ge as q,
|
|
1100
|
+
oe as r,
|
|
1088
1101
|
De as s,
|
|
1089
|
-
|
|
1090
|
-
|
|
1102
|
+
pe as t,
|
|
1103
|
+
Ce as u,
|
|
1091
1104
|
Ee as v,
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1105
|
+
ve as w,
|
|
1106
|
+
Pe as x,
|
|
1107
|
+
re as y,
|
|
1095
1108
|
ue as z
|
|
1096
1109
|
};
|