@takazudo/zdtp 0.4.13 → 0.4.15
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 +143 -0
- package/PORTABLE-CONTRACT.md +366 -94
- package/README.md +218 -96
- package/dist/apply/build-apply-overrides.d.ts +2 -2
- package/dist/apply/compute-hunks.d.ts +23 -0
- package/dist/apply/last-applied.d.ts +5 -0
- package/dist/apply/reconcile-applied.d.ts +19 -0
- package/dist/apply-modal.d.ts +2 -48
- package/dist/astro/host-adapter.js +3 -3
- package/dist/astro/index.js +2 -2
- package/dist/{autoload-state-CfL2VUe1.js → autoload-state-7BQYXI7Y.js} +1 -1
- package/dist/bin/server.js +52 -50
- package/dist/bulk/bulk-actions.d.ts +45 -0
- package/dist/bulk/index.d.ts +2 -0
- package/dist/chain/index.d.ts +2 -0
- package/dist/chain/token-chain-context.d.ts +19 -0
- package/dist/chain/token-chain-popover.d.ts +22 -0
- package/dist/changed/contribution.d.ts +32 -0
- package/dist/changed/footer-content.d.ts +16 -0
- package/dist/changed/index.d.ts +4 -0
- package/dist/changed/tab-badge.d.ts +8 -0
- package/dist/changed/tab-filter.d.ts +8 -0
- package/dist/config/panel-config.d.ts +22 -25
- package/dist/controls/actions-menu-popover.d.ts +2 -0
- package/dist/controls/role-button.d.ts +5 -2
- package/dist/controls/tooltip.d.ts +8 -4
- package/dist/element-inspect/element-inspect-context.d.ts +22 -0
- package/dist/element-inspect/element-inspect-orchestrator.d.ts +17 -0
- package/dist/element-inspect/element-inspect-overlay.d.ts +16 -0
- package/dist/element-inspect/element-inspect-toggle-button.d.ts +3 -0
- package/dist/element-inspect/element-inspect-view.d.ts +6 -0
- package/dist/element-inspect/find-tokens-for-element.d.ts +23 -0
- package/dist/element-inspect/index.d.ts +8 -0
- package/dist/highlight/find-elements.d.ts +14 -3
- package/dist/highlight/highlight-orchestrator.d.ts +7 -3
- package/dist/highlight/highlight-state.d.ts +3 -2
- package/dist/highlight/highlight-toggle-button.d.ts +3 -0
- package/dist/highlight/walk-css-rules.d.ts +2 -0
- package/dist/history/buttons.d.ts +28 -0
- package/dist/history/index.d.ts +3 -0
- package/dist/history/rail.d.ts +13 -0
- package/dist/history/snapshots.d.ts +57 -0
- package/dist/host/host-mutations.d.ts +23 -0
- package/dist/index-BOOmFtJh.js +12165 -0
- package/dist/{index-BAY1JOUl.js → index-C2DIYD0d.js} +2 -2
- package/dist/index.js +14 -14
- package/dist/load-routing-BtCE1hGI.js +547 -0
- package/dist/{manifest-DCReQE0k.js → manifest-DvuKi7I4.js} +11 -7
- package/dist/{panel-config-COHesW2B.js → panel-config-CRf-ONSV.js} +404 -308
- package/dist/picker/alt-click-picker.d.ts +10 -2
- package/dist/picker/arming-coordinator.d.ts +2 -0
- package/dist/picker/index.d.ts +2 -2
- package/dist/search/command-palette.d.ts +21 -0
- package/dist/search/contribution.d.ts +7 -0
- package/dist/search/fuzzy.d.ts +10 -0
- package/dist/search/index.d.ts +4 -0
- package/dist/search/match-bar.d.ts +14 -0
- package/dist/search/search-header.d.ts +7 -0
- package/dist/search/token-search.d.ts +36 -0
- package/dist/server/create-apply-handler.d.ts +33 -0
- package/dist/server/index.d.ts +2 -1
- package/dist/server/index.js +1 -1
- package/dist/shell/dock-mode-switch.d.ts +6 -0
- package/dist/shell/footer.d.ts +1 -0
- package/dist/shell/ghost-idle.d.ts +24 -0
- package/dist/shell/header.d.ts +5 -0
- package/dist/shell/layer-activity.d.ts +6 -0
- package/dist/shell/mini-pill.d.ts +21 -0
- package/dist/shell/regions.d.ts +26 -0
- package/dist/shell/shortcut-dispatcher.d.ts +17 -0
- package/dist/shell/tab-bar.d.ts +17 -0
- package/dist/shell/tab-overflow-popover.d.ts +13 -0
- package/dist/specimen/on-page-specimen.d.ts +19 -0
- package/dist/specimen/preview-glyphs.d.ts +2 -0
- package/dist/specimen/specimen-state.d.ts +12 -0
- package/dist/specimen/specimen-tab-body.d.ts +18 -0
- package/dist/specimen/specimen-toolbar.d.ts +10 -0
- package/dist/specimen/specimen-values.d.ts +9 -0
- package/dist/state/history.d.ts +64 -0
- package/dist/state/persist.d.ts +10 -14
- package/dist/state/transaction.d.ts +24 -0
- package/dist/state/tweak-state.d.ts +16 -0
- package/dist/styles/z-index-tokens.d.ts +2 -0
- package/dist/tabs/color-tab.d.ts +10 -1
- package/dist/tabs/flat/flat-tab.d.ts +27 -0
- package/dist/tabs/flat/index.d.ts +8 -0
- package/dist/tabs/flat/scroll-to-token-row.d.ts +3 -0
- package/dist/tabs/flat/tier-section.d.ts +17 -0
- package/dist/tabs/flat/token-controller.d.ts +23 -0
- package/dist/tabs/flat/token-row.d.ts +12 -0
- package/dist/tabs/flat/types.d.ts +25 -0
- package/dist/tabs/font-tab.d.ts +13 -12
- package/dist/tabs/generic-tab.d.ts +8 -38
- package/dist/tabs/palette/palette-check-view.d.ts +5 -1
- package/dist/tabs/palette/palette-edit-view.d.ts +9 -1
- package/dist/tabs/palette/palette-tab.d.ts +12 -1
- package/dist/tabs/size-tab.d.ts +7 -10
- package/dist/tabs/spacing-tab.d.ts +7 -13
- package/dist/testing.js +3 -3
- package/dist/tokens/tier-model.d.ts +6 -0
- package/dist/{tweak-state-BKNxtHzb.js → tweak-state-BGp_7Tfh.js} +473 -423
- package/dist/utils/numeric-transform.d.ts +32 -0
- package/dist/utils/token-diff.d.ts +25 -0
- package/dist/utils/token-graph.d.ts +23 -0
- package/dist/utils/token-index.d.ts +30 -0
- package/dist/zdtp.css +1 -1
- package/package.json +3 -1
- package/dist/controls/pill-slider-row.d.ts +0 -36
- package/dist/controls/select-row.d.ts +0 -25
- package/dist/controls/slider-row.d.ts +0 -29
- package/dist/controls/text-row.d.ts +0 -27
- package/dist/index-U7Ol7tgA.js +0 -7591
- package/dist/load-routing-D4H2VOl5.js +0 -426
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
class
|
|
1
|
+
class k extends Error {
|
|
2
2
|
constructor(t) {
|
|
3
|
-
super(t), this.name = "TierResolverError", Object.setPrototypeOf(this,
|
|
3
|
+
super(t), this.name = "TierResolverError", Object.setPrototypeOf(this, k.prototype);
|
|
4
4
|
}
|
|
5
5
|
}
|
|
6
6
|
function A(e, t) {
|
|
@@ -9,62 +9,62 @@ function A(e, t) {
|
|
|
9
9
|
function $(e, t) {
|
|
10
10
|
return e.items.find((n) => n.id === t);
|
|
11
11
|
}
|
|
12
|
-
function
|
|
13
|
-
const
|
|
14
|
-
if (!
|
|
15
|
-
throw new
|
|
16
|
-
`Tier "${t}" not found in tab "${e.id}". Available tiers: ${e.tiers.map((
|
|
12
|
+
function I(e, t, n, i) {
|
|
13
|
+
const u = A(e, t);
|
|
14
|
+
if (!u)
|
|
15
|
+
throw new k(
|
|
16
|
+
`Tier "${t}" not found in tab "${e.id}". Available tiers: ${e.tiers.map((f) => f.id).join(", ")}.`
|
|
17
17
|
);
|
|
18
|
-
const
|
|
19
|
-
if (!
|
|
20
|
-
throw new
|
|
18
|
+
const d = $(u, n);
|
|
19
|
+
if (!d)
|
|
20
|
+
throw new k(
|
|
21
21
|
`Item "${n}" not found in tier "${t}" of tab "${e.id}".`
|
|
22
22
|
);
|
|
23
|
-
const
|
|
24
|
-
if (
|
|
25
|
-
const
|
|
26
|
-
if (!
|
|
27
|
-
throw new
|
|
28
|
-
`Tier "${t}" declares referencesTier "${
|
|
23
|
+
const r = i[t]?.[n];
|
|
24
|
+
if (u.referencesTier !== void 0) {
|
|
25
|
+
const f = u.referencesTier, l = A(e, f);
|
|
26
|
+
if (!l)
|
|
27
|
+
throw new k(
|
|
28
|
+
`Tier "${t}" declares referencesTier "${f}" but that tier does not exist in tab "${e.id}".`
|
|
29
29
|
);
|
|
30
|
-
const
|
|
31
|
-
if (!
|
|
32
|
-
const
|
|
33
|
-
if (!
|
|
34
|
-
throw new
|
|
35
|
-
`Referenced tier "${
|
|
30
|
+
const a = $(l, r ?? n);
|
|
31
|
+
if (!a) {
|
|
32
|
+
const g = $(l, d.default) ?? $(l, n) ?? l.items[0];
|
|
33
|
+
if (!g)
|
|
34
|
+
throw new k(
|
|
35
|
+
`Referenced tier "${f}" has no items; cannot resolve fallback for item "${n}" in tier "${t}" of tab "${e.id}".`
|
|
36
36
|
);
|
|
37
|
-
return { kind: "ref", targetCssVar:
|
|
37
|
+
return { kind: "ref", targetCssVar: g.cssVar };
|
|
38
38
|
}
|
|
39
|
-
return { kind: "ref", targetCssVar:
|
|
39
|
+
return { kind: "ref", targetCssVar: a.cssVar };
|
|
40
40
|
}
|
|
41
|
-
return
|
|
41
|
+
return r !== void 0 ? d.pill && r === d.pill.value ? { kind: "literal", value: d.pill.value } : { kind: "literal", value: r } : d.pill ? { kind: "literal", value: d.pill.customDefault } : { kind: "literal", value: d.default };
|
|
42
42
|
}
|
|
43
|
-
function
|
|
43
|
+
function ee(e) {
|
|
44
44
|
return e.kind === "literal" ? e.value : `var(${e.targetCssVar})`;
|
|
45
45
|
}
|
|
46
|
-
function
|
|
46
|
+
function N(e, t, n = [t]) {
|
|
47
47
|
const i = e.tab === void 0 || e.tab === t.id ? t : n.find((s) => s.id === e.tab);
|
|
48
48
|
if (!i)
|
|
49
|
-
throw new
|
|
49
|
+
throw new k(
|
|
50
50
|
`Cross-tab ref target tab "${e.tab}" not found. Available tabs: ${n.map((s) => s.id).join(", ")}.`
|
|
51
51
|
);
|
|
52
|
-
const
|
|
53
|
-
if (!
|
|
54
|
-
throw new
|
|
52
|
+
const u = A(i, e.tier);
|
|
53
|
+
if (!u)
|
|
54
|
+
throw new k(
|
|
55
55
|
`Cross-tab ref target tier "${e.tier}" not found in tab "${i.id}". Available tiers: ${i.tiers.map((s) => s.id).join(", ")}.`
|
|
56
56
|
);
|
|
57
|
-
const
|
|
58
|
-
if (!
|
|
59
|
-
throw new
|
|
60
|
-
`Cross-tab ref target item "${e.item}" not found in tier "${e.tier}" of tab "${i.id}". Available items: ${
|
|
57
|
+
const d = $(u, e.item);
|
|
58
|
+
if (!d)
|
|
59
|
+
throw new k(
|
|
60
|
+
`Cross-tab ref target item "${e.item}" not found in tier "${e.tier}" of tab "${i.id}". Available items: ${u.items.map((s) => s.id).join(", ")}.`
|
|
61
61
|
);
|
|
62
|
-
return
|
|
62
|
+
return d.cssVar;
|
|
63
63
|
}
|
|
64
|
-
function
|
|
64
|
+
function te(e, t) {
|
|
65
65
|
return e.paletteCssVarTemplate.replace("{n}", String(t));
|
|
66
66
|
}
|
|
67
|
-
const
|
|
67
|
+
const M = /* @__PURE__ */ new Set([
|
|
68
68
|
"aliceblue",
|
|
69
69
|
"antiquewhite",
|
|
70
70
|
"aqua",
|
|
@@ -221,27 +221,27 @@ const N = /* @__PURE__ */ new Set([
|
|
|
221
221
|
"revert",
|
|
222
222
|
"revert-layer"
|
|
223
223
|
]);
|
|
224
|
-
function
|
|
225
|
-
return e.startsWith("#") || e.includes("(") ||
|
|
224
|
+
function D(e) {
|
|
225
|
+
return e.startsWith("#") || e.includes("(") || M.has(e.toLowerCase());
|
|
226
226
|
}
|
|
227
227
|
function H(e, t, n, i) {
|
|
228
|
-
const
|
|
229
|
-
if (
|
|
230
|
-
const
|
|
231
|
-
|
|
228
|
+
const u = [], d = e.indexOf(":");
|
|
229
|
+
if (d !== -1) {
|
|
230
|
+
const r = e.slice(0, d), f = e.slice(d + 1), l = t.find((o) => o.tier === r);
|
|
231
|
+
l && u.push({ tab: l.tab, tier: l.tier, item: f });
|
|
232
232
|
}
|
|
233
233
|
const [s] = t;
|
|
234
|
-
|
|
235
|
-
for (const
|
|
234
|
+
u.push({ tab: s.tab, tier: s.tier, item: e });
|
|
235
|
+
for (const r of u)
|
|
236
236
|
try {
|
|
237
|
-
return
|
|
237
|
+
return N(r, n, i), { ref: r };
|
|
238
238
|
} catch {
|
|
239
239
|
}
|
|
240
|
-
return { ref:
|
|
240
|
+
return { ref: u[0] };
|
|
241
241
|
}
|
|
242
|
-
function
|
|
242
|
+
function L(e, t, n, i, u, d) {
|
|
243
243
|
const s = t.get(e.default);
|
|
244
|
-
return s !== void 0 ? s : e.default === "bg" || e.default === "fg" ? e.default : n && n.length > 0 && !
|
|
244
|
+
return s !== void 0 ? s : e.default === "bg" || e.default === "fg" ? e.default : n && n.length > 0 && !D(e.default) ? H(e.default, n, i, u) : d ? (console.warn(
|
|
245
245
|
`[design-token-panel] semantic item "${e.id}" default "${e.default}" names no palette item; falling back to palette index 0`
|
|
246
246
|
), 0) : { literal: e.default };
|
|
247
247
|
}
|
|
@@ -249,11 +249,11 @@ function V(e, t = [e]) {
|
|
|
249
249
|
const n = e.colorExtras;
|
|
250
250
|
if (!n) return;
|
|
251
251
|
const i = e.tiers.find(
|
|
252
|
-
(
|
|
253
|
-
),
|
|
254
|
-
(
|
|
252
|
+
(a) => !a.referencesTier && !a.semantic && a.items.length > 0 && a.items[0].type.kind === "color"
|
|
253
|
+
), u = e.tiers.find(
|
|
254
|
+
(a) => i && a.referencesTier === i.id || a.semantic === !0
|
|
255
255
|
);
|
|
256
|
-
if (!i && !
|
|
256
|
+
if (!i && !u)
|
|
257
257
|
return {
|
|
258
258
|
id: n.id,
|
|
259
259
|
label: n.label,
|
|
@@ -267,20 +267,20 @@ function V(e, t = [e]) {
|
|
|
267
267
|
colorSchemes: n.colorSchemes,
|
|
268
268
|
panelSettings: n.panelSettings
|
|
269
269
|
};
|
|
270
|
-
const
|
|
271
|
-
for (let
|
|
272
|
-
|
|
273
|
-
const
|
|
274
|
-
if (
|
|
275
|
-
const
|
|
276
|
-
for (const
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
270
|
+
const d = i?.items ?? [], s = d.length, r = d[0] ? d[0].cssVar.replace(/\d+$/, "{n}") : "--zudo-stub-p{n}", f = /* @__PURE__ */ new Map();
|
|
271
|
+
for (let a = 0; a < d.length; a++)
|
|
272
|
+
f.set(d[a].id, a);
|
|
273
|
+
const l = {}, o = {};
|
|
274
|
+
if (u) {
|
|
275
|
+
const a = !u.semantic, g = n.semanticDefaults;
|
|
276
|
+
for (const c of u.items)
|
|
277
|
+
o[c.id] = c.cssVar, l[c.id] = g && c.id in g ? g[c.id] : L(
|
|
278
|
+
c,
|
|
279
|
+
f,
|
|
280
|
+
u.referencesRamps,
|
|
281
281
|
e,
|
|
282
282
|
t,
|
|
283
|
-
|
|
283
|
+
a
|
|
284
284
|
);
|
|
285
285
|
}
|
|
286
286
|
return {
|
|
@@ -288,39 +288,39 @@ function V(e, t = [e]) {
|
|
|
288
288
|
label: n.label,
|
|
289
289
|
paletteSize: s,
|
|
290
290
|
baseRoles: n.baseRoles,
|
|
291
|
-
paletteCssVarTemplate:
|
|
292
|
-
semanticDefaults:
|
|
293
|
-
semanticCssNames:
|
|
291
|
+
paletteCssVarTemplate: r,
|
|
292
|
+
semanticDefaults: l,
|
|
293
|
+
semanticCssNames: o,
|
|
294
294
|
baseDefaults: n.baseDefaults,
|
|
295
295
|
defaultShikiTheme: n.defaultShikiTheme,
|
|
296
296
|
colorSchemes: n.colorSchemes,
|
|
297
297
|
panelSettings: n.panelSettings
|
|
298
298
|
};
|
|
299
299
|
}
|
|
300
|
-
function
|
|
300
|
+
function ne(e) {
|
|
301
301
|
const t = e.find((n) => n.id === "color");
|
|
302
302
|
if (t)
|
|
303
303
|
return V(t, e);
|
|
304
304
|
}
|
|
305
|
-
function
|
|
305
|
+
function B(e) {
|
|
306
306
|
const t = e.find((n) => n.id === "color-secondary");
|
|
307
307
|
return t ? V(t, e) ?? null : null;
|
|
308
308
|
}
|
|
309
|
-
function
|
|
309
|
+
function x(e, t) {
|
|
310
310
|
if (Object.is(e, t)) return !0;
|
|
311
311
|
if (e === null || t === null || typeof e != typeof t || typeof e != "object") return !1;
|
|
312
312
|
if (Array.isArray(e)) {
|
|
313
313
|
if (!Array.isArray(t) || e.length !== t.length) return !1;
|
|
314
|
-
for (let
|
|
315
|
-
if (!
|
|
314
|
+
for (let d = 0; d < e.length; d++)
|
|
315
|
+
if (!x(e[d], t[d])) return !1;
|
|
316
316
|
return !0;
|
|
317
317
|
}
|
|
318
318
|
if (Array.isArray(t)) return !1;
|
|
319
319
|
const n = Object.keys(e), i = Object.keys(t);
|
|
320
320
|
if (n.length !== i.length) return !1;
|
|
321
|
-
const
|
|
322
|
-
for (const
|
|
323
|
-
if (!
|
|
321
|
+
const u = new Set(i);
|
|
322
|
+
for (const d of n)
|
|
323
|
+
if (!u.has(d) || !x(e[d], t[d]))
|
|
324
324
|
return !1;
|
|
325
325
|
return !0;
|
|
326
326
|
}
|
|
@@ -336,10 +336,10 @@ const _ = {
|
|
|
336
336
|
// No bundled apply endpoint / routing — hosts wire their own.
|
|
337
337
|
applyEndpoint: void 0,
|
|
338
338
|
applyRouting: void 0
|
|
339
|
-
},
|
|
339
|
+
}, R = /* @__PURE__ */ Symbol.for("@takazudo/zdtp:singleton");
|
|
340
340
|
function m() {
|
|
341
341
|
const e = globalThis;
|
|
342
|
-
let t = e[
|
|
342
|
+
let t = e[R];
|
|
343
343
|
return t || (t = {
|
|
344
344
|
instances: /* @__PURE__ */ new Map(),
|
|
345
345
|
defaultPrefix: null,
|
|
@@ -347,7 +347,7 @@ function m() {
|
|
|
347
347
|
pendingPostConfigureHooks: [],
|
|
348
348
|
lifecycleHooks: {},
|
|
349
349
|
colorSchemeOwners: /* @__PURE__ */ new Set()
|
|
350
|
-
}, e[
|
|
350
|
+
}, e[R] = t), t;
|
|
351
351
|
}
|
|
352
352
|
function F(e) {
|
|
353
353
|
return {
|
|
@@ -371,7 +371,7 @@ function F(e) {
|
|
|
371
371
|
}
|
|
372
372
|
};
|
|
373
373
|
}
|
|
374
|
-
function
|
|
374
|
+
function re(e) {
|
|
375
375
|
m().lifecycleHooks = {
|
|
376
376
|
configured: e.configured,
|
|
377
377
|
open: e.open,
|
|
@@ -380,41 +380,41 @@ function I(e) {
|
|
|
380
380
|
destroy: e.destroy
|
|
381
381
|
};
|
|
382
382
|
}
|
|
383
|
-
function
|
|
383
|
+
function oe(e) {
|
|
384
384
|
const t = m(), n = e.storagePrefix, i = t.instances.get(n);
|
|
385
385
|
if (i) {
|
|
386
|
-
const
|
|
387
|
-
if (
|
|
386
|
+
const l = (o) => ({ ...o, applySink: void 0 });
|
|
387
|
+
if (x(l(i.suppliedConfig), l(e)))
|
|
388
388
|
return t.defaultPrefix = n, i.handle;
|
|
389
389
|
throw new Error(
|
|
390
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.)`
|
|
391
391
|
);
|
|
392
392
|
}
|
|
393
|
-
const
|
|
393
|
+
const u = t.pendingColorPresets, d = u ? { ...e, colorPresets: u } : { ...e };
|
|
394
394
|
t.pendingColorPresets = null;
|
|
395
|
-
const s = t.instances.size === 0,
|
|
395
|
+
const s = t.instances.size === 0, r = s ? [...t.pendingPostConfigureHooks] : [];
|
|
396
396
|
s && (t.pendingPostConfigureHooks.length = 0);
|
|
397
|
-
const
|
|
398
|
-
config:
|
|
397
|
+
const f = {
|
|
398
|
+
config: d,
|
|
399
399
|
// Snapshot the as-supplied config before any runtime merges. Used by the
|
|
400
400
|
// idempotency guard so view-transition re-calls with the original inline
|
|
401
401
|
// config keep passing even after setPanelColorPresets mutates `config`.
|
|
402
402
|
suppliedConfig: { ...e },
|
|
403
403
|
pendingColorPresets: null,
|
|
404
|
-
postConfigureHooks:
|
|
404
|
+
postConfigureHooks: r,
|
|
405
405
|
handle: F(n)
|
|
406
406
|
};
|
|
407
|
-
t.instances.set(n,
|
|
408
|
-
for (const
|
|
409
|
-
|
|
410
|
-
return t.lifecycleHooks.configured?.(n),
|
|
407
|
+
t.instances.set(n, f), t.defaultPrefix = n;
|
|
408
|
+
for (const l of f.postConfigureHooks)
|
|
409
|
+
l();
|
|
410
|
+
return t.lifecycleHooks.configured?.(n), f.handle;
|
|
411
411
|
}
|
|
412
|
-
function
|
|
412
|
+
function S() {
|
|
413
413
|
const e = m();
|
|
414
414
|
return e.defaultPrefix === null ? null : e.instances.get(e.defaultPrefix) ?? null;
|
|
415
415
|
}
|
|
416
|
-
function
|
|
417
|
-
const t =
|
|
416
|
+
function ie(e) {
|
|
417
|
+
const t = S();
|
|
418
418
|
if (t === null) {
|
|
419
419
|
const n = m();
|
|
420
420
|
if (n.pendingPostConfigureHooks.includes(e)) return;
|
|
@@ -423,16 +423,16 @@ function te(e) {
|
|
|
423
423
|
}
|
|
424
424
|
t.postConfigureHooks.includes(e) || (t.postConfigureHooks.push(e), e());
|
|
425
425
|
}
|
|
426
|
-
function
|
|
427
|
-
return
|
|
426
|
+
function j() {
|
|
427
|
+
return S()?.config ?? _;
|
|
428
428
|
}
|
|
429
|
-
function
|
|
429
|
+
function se() {
|
|
430
430
|
return [...m().instances.values()].map((e) => e.config);
|
|
431
431
|
}
|
|
432
|
-
function
|
|
432
|
+
function ae(e) {
|
|
433
433
|
return m().instances.get(e)?.config ?? null;
|
|
434
434
|
}
|
|
435
|
-
function
|
|
435
|
+
function le() {
|
|
436
436
|
const e = m();
|
|
437
437
|
e.instances.clear(), e.defaultPrefix = null, e.pendingColorPresets = null, e.pendingPostConfigureHooks.length = 0, v().clear();
|
|
438
438
|
}
|
|
@@ -440,80 +440,116 @@ function v() {
|
|
|
440
440
|
const e = m();
|
|
441
441
|
return e.colorSchemeOwners || (e.colorSchemeOwners = /* @__PURE__ */ new Set()), e.colorSchemeOwners;
|
|
442
442
|
}
|
|
443
|
-
function
|
|
443
|
+
function fe(e) {
|
|
444
444
|
v().add(e);
|
|
445
445
|
}
|
|
446
|
-
function
|
|
446
|
+
function ce(e) {
|
|
447
447
|
v().delete(e);
|
|
448
448
|
}
|
|
449
|
-
function
|
|
449
|
+
function ge(e) {
|
|
450
450
|
return v().has(e);
|
|
451
451
|
}
|
|
452
|
-
function
|
|
453
|
-
return
|
|
452
|
+
function de(e = j()) {
|
|
453
|
+
return B(e.tabs);
|
|
454
454
|
}
|
|
455
|
-
function
|
|
455
|
+
function ue(e) {
|
|
456
456
|
return `${e.storagePrefix}-state-v2`;
|
|
457
457
|
}
|
|
458
|
-
function
|
|
458
|
+
function pe(e) {
|
|
459
459
|
return `${e.storagePrefix}-state-v3`;
|
|
460
460
|
}
|
|
461
|
-
function
|
|
461
|
+
function ye(e) {
|
|
462
462
|
return `${e.storagePrefix}-state-v4`;
|
|
463
463
|
}
|
|
464
|
-
function
|
|
464
|
+
function me(e) {
|
|
465
465
|
return `${e.storagePrefix}-state`;
|
|
466
466
|
}
|
|
467
|
-
function
|
|
467
|
+
function he(e) {
|
|
468
468
|
return `${e.storagePrefix}-open`;
|
|
469
469
|
}
|
|
470
|
-
function
|
|
470
|
+
function we(e) {
|
|
471
471
|
return `${e.storagePrefix}-position`;
|
|
472
472
|
}
|
|
473
|
-
function
|
|
473
|
+
function be(e) {
|
|
474
474
|
return `${e.storagePrefix}-size`;
|
|
475
475
|
}
|
|
476
|
-
function
|
|
476
|
+
function ke(e) {
|
|
477
|
+
return `${e.storagePrefix}-dock`;
|
|
478
|
+
}
|
|
479
|
+
function $e(e) {
|
|
480
|
+
return `${e.storagePrefix}-dock-size`;
|
|
481
|
+
}
|
|
482
|
+
function Ce(e) {
|
|
477
483
|
return `${e.storagePrefix}-density`;
|
|
478
484
|
}
|
|
479
|
-
function
|
|
485
|
+
function Pe(e) {
|
|
486
|
+
return `${e.storagePrefix}-specimen`;
|
|
487
|
+
}
|
|
488
|
+
function Ee(e, t) {
|
|
489
|
+
return `${e.storagePrefix}-snapshot-${t}`;
|
|
490
|
+
}
|
|
491
|
+
function ve(e) {
|
|
492
|
+
return `${e.storagePrefix}-last-applied`;
|
|
493
|
+
}
|
|
494
|
+
function Ae(e) {
|
|
480
495
|
return `${e.storagePrefix}:visible`;
|
|
481
496
|
}
|
|
482
|
-
function
|
|
497
|
+
function xe(e) {
|
|
483
498
|
return `${e.storagePrefix}:autoload`;
|
|
484
499
|
}
|
|
485
|
-
function
|
|
500
|
+
function Se(e) {
|
|
486
501
|
return `${e.storagePrefix}-root`;
|
|
487
502
|
}
|
|
488
503
|
const J = _.storagePrefix, q = "toggle-design-token-panel";
|
|
489
|
-
function
|
|
504
|
+
function je(e) {
|
|
490
505
|
return e.storagePrefix === J ? q : e.toggleEvent ?? `toggle-${e.storagePrefix}`;
|
|
491
506
|
}
|
|
492
507
|
const G = "__zdtp:open-state-changed";
|
|
493
|
-
function
|
|
508
|
+
function Te(e) {
|
|
494
509
|
return `${G}:${e.storagePrefix}`;
|
|
495
510
|
}
|
|
496
|
-
function
|
|
511
|
+
function Oe(e, t) {
|
|
497
512
|
return `${e.modalClassPrefix}${t}`;
|
|
498
513
|
}
|
|
499
|
-
function
|
|
514
|
+
function Re(e) {
|
|
500
515
|
return `${e.exportFilenameBase}.json`;
|
|
501
516
|
}
|
|
502
|
-
const
|
|
503
|
-
function
|
|
517
|
+
const z = /* @__PURE__ */ Symbol.for("@takazudo/zdtp:global-alias-marker");
|
|
518
|
+
function K(e) {
|
|
519
|
+
return typeof e == "object" && e !== null || typeof e == "function";
|
|
520
|
+
}
|
|
521
|
+
function U(e) {
|
|
522
|
+
if (!K(e)) return !1;
|
|
523
|
+
try {
|
|
524
|
+
return e[z] === !0;
|
|
525
|
+
} catch {
|
|
526
|
+
return !1;
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
function W(e) {
|
|
530
|
+
if (!K(e)) return !1;
|
|
531
|
+
try {
|
|
532
|
+
const t = e;
|
|
533
|
+
return typeof t.show == "function" && typeof t.hide == "function" && typeof t.toggle == "function";
|
|
534
|
+
} catch {
|
|
535
|
+
return !1;
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
function Ve(e) {
|
|
504
539
|
if (typeof window > "u") return;
|
|
505
540
|
const t = window, n = t.zdtp;
|
|
506
541
|
if (n !== void 0) {
|
|
507
|
-
if ((
|
|
542
|
+
if (U(n) || W(n))
|
|
543
|
+
return;
|
|
508
544
|
console.warn(
|
|
509
545
|
"[design-token-panel] window.zdtp already exists and was not installed by this package. Skipping the zdtp.show() / zdtp.hide() / zdtp.toggle() global alias to avoid clobbering it. Use window[consoleNamespace].* or the configurePanel(cfg) handle instead."
|
|
510
546
|
);
|
|
511
547
|
return;
|
|
512
548
|
}
|
|
513
549
|
const i = { ...e };
|
|
514
|
-
i[
|
|
550
|
+
i[z] = !0, t.zdtp = i;
|
|
515
551
|
}
|
|
516
|
-
function
|
|
552
|
+
function _e(e) {
|
|
517
553
|
if (e === null || typeof e != "object" || Array.isArray(e))
|
|
518
554
|
throw new Error("[design-token-panel] PanelConfig must be a non-null object");
|
|
519
555
|
const t = e;
|
|
@@ -528,7 +564,7 @@ function ve(e) {
|
|
|
528
564
|
throw new Error(
|
|
529
565
|
`[design-token-panel] PanelConfig.${n} must be a non-empty string (got ${typeof t[n]})`
|
|
530
566
|
);
|
|
531
|
-
if (
|
|
567
|
+
if (Z(t.tabs), t.toggleEvent !== void 0 && (typeof t.toggleEvent != "string" || t.toggleEvent.length === 0))
|
|
532
568
|
throw new Error(
|
|
533
569
|
`[design-token-panel] PanelConfig.toggleEvent must be a non-empty string when set (got ${typeof t.toggleEvent})`
|
|
534
570
|
);
|
|
@@ -565,6 +601,18 @@ function ve(e) {
|
|
|
565
601
|
);
|
|
566
602
|
}
|
|
567
603
|
}
|
|
604
|
+
if (t.dock !== void 0) {
|
|
605
|
+
if (t.dock === null || typeof t.dock != "object" || Array.isArray(t.dock))
|
|
606
|
+
throw new Error("[design-token-panel] PanelConfig.dock must be a plain object");
|
|
607
|
+
const n = t.dock;
|
|
608
|
+
for (const i of Object.keys(n))
|
|
609
|
+
if (i !== "reflow")
|
|
610
|
+
throw new Error(`[design-token-panel] PanelConfig.dock.${i} is not a supported field`);
|
|
611
|
+
if (n.reflow !== void 0 && n.reflow !== "body-margin" && n.reflow !== "none")
|
|
612
|
+
throw new Error(
|
|
613
|
+
'[design-token-panel] PanelConfig.dock.reflow must be "body-margin" or "none" when set'
|
|
614
|
+
);
|
|
615
|
+
}
|
|
568
616
|
if (t.autoRememberOnOpen !== void 0 && typeof t.autoRememberOnOpen != "boolean")
|
|
569
617
|
throw new Error(
|
|
570
618
|
`[design-token-panel] PanelConfig.autoRememberOnOpen must be a boolean when set (got ${typeof t.autoRememberOnOpen})`
|
|
@@ -579,7 +627,7 @@ function ve(e) {
|
|
|
579
627
|
);
|
|
580
628
|
}
|
|
581
629
|
}
|
|
582
|
-
function
|
|
630
|
+
function Z(e) {
|
|
583
631
|
if (!Array.isArray(e))
|
|
584
632
|
throw new Error("[design-token-panel] PanelConfig.tabs must be an array");
|
|
585
633
|
const t = /* @__PURE__ */ new Set();
|
|
@@ -593,10 +641,10 @@ function B(e) {
|
|
|
593
641
|
throw new Error(
|
|
594
642
|
`[design-token-panel] PanelConfig.tabs: duplicate tab id "${i.id}"`
|
|
595
643
|
);
|
|
596
|
-
t.add(i.id),
|
|
644
|
+
t.add(i.id), Q(i.id, i, e);
|
|
597
645
|
}
|
|
598
646
|
}
|
|
599
|
-
function
|
|
647
|
+
function Y(e) {
|
|
600
648
|
if (typeof e == "number" || e === "bg" || e === "fg") return !0;
|
|
601
649
|
if (e === null || typeof e != "object" || Array.isArray(e)) return !1;
|
|
602
650
|
const t = e;
|
|
@@ -615,191 +663,230 @@ function U(e) {
|
|
|
615
663
|
}
|
|
616
664
|
return !1;
|
|
617
665
|
}
|
|
618
|
-
function
|
|
666
|
+
function Q(e, t, n) {
|
|
619
667
|
if (!Array.isArray(t.tiers))
|
|
620
668
|
throw new Error(
|
|
621
669
|
`[design-token-panel] PanelConfig.tabs["${e}"].tiers must be an array`
|
|
622
670
|
);
|
|
623
|
-
const i = /* @__PURE__ */ new Set(),
|
|
671
|
+
const i = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Map();
|
|
624
672
|
for (const s of t.tiers) {
|
|
625
673
|
if (s === null || typeof s != "object" || Array.isArray(s))
|
|
626
674
|
throw new Error(
|
|
627
675
|
`[design-token-panel] PanelConfig.tabs["${e}"].tiers: each tier must be a non-null object`
|
|
628
676
|
);
|
|
629
|
-
const
|
|
630
|
-
if (typeof
|
|
677
|
+
const r = s;
|
|
678
|
+
if (typeof r.id != "string" || r.id.length === 0)
|
|
631
679
|
throw new Error(
|
|
632
680
|
`[design-token-panel] PanelConfig.tabs["${e}"].tiers: each tier must have a non-empty string id`
|
|
633
681
|
);
|
|
634
|
-
if (i.has(
|
|
682
|
+
if (i.has(r.id))
|
|
683
|
+
throw new Error(
|
|
684
|
+
`[design-token-panel] PanelConfig.tabs["${e}"]: duplicate tier id "${r.id}"`
|
|
685
|
+
);
|
|
686
|
+
if (i.add(r.id), r.semantic !== void 0 && r.semantic !== !0)
|
|
687
|
+
throw new Error(
|
|
688
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${r.id}"].semantic must be exactly \`true\` when present (got ${JSON.stringify(r.semantic)})`
|
|
689
|
+
);
|
|
690
|
+
const f = /* @__PURE__ */ new Set([
|
|
691
|
+
"size",
|
|
692
|
+
"line-height",
|
|
693
|
+
"family",
|
|
694
|
+
"weight",
|
|
695
|
+
"bar",
|
|
696
|
+
"radius",
|
|
697
|
+
"duration"
|
|
698
|
+
]);
|
|
699
|
+
if (r.preview !== void 0 && !f.has(r.preview))
|
|
635
700
|
throw new Error(
|
|
636
|
-
`[design-token-panel] PanelConfig.tabs["${e}"]
|
|
701
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${r.id}"].preview has unsupported value ${JSON.stringify(r.preview)}`
|
|
637
702
|
);
|
|
638
|
-
if (
|
|
703
|
+
if (r.previewBase !== void 0 && (typeof r.previewBase != "string" || !r.previewBase.startsWith("--") || r.previewBase.length <= 2))
|
|
639
704
|
throw new Error(
|
|
640
|
-
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${
|
|
705
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${r.id}"].previewBase must be a CSS custom property name`
|
|
641
706
|
);
|
|
642
|
-
if (
|
|
707
|
+
if (r.previewBase !== void 0 && r.preview !== "line-height")
|
|
643
708
|
throw new Error(
|
|
644
|
-
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${
|
|
709
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${r.id}"].previewBase is only valid with preview "line-height"`
|
|
710
|
+
);
|
|
711
|
+
if (!Array.isArray(r.items))
|
|
712
|
+
throw new Error(
|
|
713
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${r.id}"].items must be an array`
|
|
645
714
|
);
|
|
646
715
|
let l;
|
|
647
|
-
for (const
|
|
648
|
-
if (f === null || typeof f != "object" || Array.isArray(f)) continue;
|
|
649
|
-
const o = f.type;
|
|
716
|
+
for (const o of r.items) {
|
|
650
717
|
if (o === null || typeof o != "object" || Array.isArray(o)) continue;
|
|
651
|
-
const
|
|
652
|
-
if (typeof
|
|
718
|
+
const g = o.type;
|
|
719
|
+
if (g === null || typeof g != "object" || Array.isArray(g)) continue;
|
|
720
|
+
const c = g.kind;
|
|
721
|
+
if (typeof c == "string") {
|
|
653
722
|
if (l === void 0)
|
|
654
|
-
l =
|
|
655
|
-
else if (l !==
|
|
723
|
+
l = c;
|
|
724
|
+
else if (l !== c)
|
|
656
725
|
throw new Error(
|
|
657
|
-
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${
|
|
726
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${r.id}"]: mixed item kinds — found "${l}" and "${c}" in the same tier (all items must share the same kind)`
|
|
658
727
|
);
|
|
659
728
|
}
|
|
660
729
|
}
|
|
661
|
-
l !== void 0 &&
|
|
730
|
+
l !== void 0 && u.set(r.id, l);
|
|
662
731
|
}
|
|
663
|
-
const
|
|
732
|
+
const d = /* @__PURE__ */ new Set();
|
|
664
733
|
for (const s of t.tiers) {
|
|
665
|
-
const
|
|
666
|
-
for (const
|
|
667
|
-
if (
|
|
734
|
+
const r = s, f = r.id;
|
|
735
|
+
for (const l of r.items) {
|
|
736
|
+
if (l === null || typeof l != "object" || Array.isArray(l))
|
|
668
737
|
throw new Error(
|
|
669
|
-
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${
|
|
738
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${f}"].items: each item must be a non-null object`
|
|
670
739
|
);
|
|
671
|
-
const
|
|
672
|
-
if (typeof
|
|
740
|
+
const o = l;
|
|
741
|
+
if (typeof o.id != "string" || o.id.length === 0)
|
|
673
742
|
throw new Error(
|
|
674
|
-
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${
|
|
743
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${f}"].items: each item must have a non-empty string id`
|
|
675
744
|
);
|
|
676
|
-
if (
|
|
745
|
+
if (d.has(o.id))
|
|
677
746
|
throw new Error(
|
|
678
|
-
`[design-token-panel] PanelConfig.tabs["${e}"]: duplicate item id "${
|
|
747
|
+
`[design-token-panel] PanelConfig.tabs["${e}"]: duplicate item id "${o.id}" (item ids must be unique across all tiers within a tab)`
|
|
679
748
|
);
|
|
680
|
-
if (
|
|
749
|
+
if (d.add(o.id), typeof o.cssVar != "string" || !o.cssVar.startsWith("--"))
|
|
681
750
|
throw new Error(
|
|
682
|
-
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${
|
|
751
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${f}"].items["${o.id}"].cssVar must start with "--" (got ${JSON.stringify(o.cssVar)})`
|
|
683
752
|
);
|
|
684
|
-
if (
|
|
753
|
+
if (o.cssVar.length <= 2)
|
|
685
754
|
throw new Error(
|
|
686
|
-
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${
|
|
755
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${f}"].items["${o.id}"].cssVar must be non-empty after "--"`
|
|
687
756
|
);
|
|
688
|
-
const
|
|
689
|
-
if (
|
|
690
|
-
const
|
|
691
|
-
if (!Array.isArray(
|
|
757
|
+
const a = o.type;
|
|
758
|
+
if (a !== null && typeof a == "object" && !Array.isArray(a) && a.kind === "length" && a.units !== void 0) {
|
|
759
|
+
const g = a.units;
|
|
760
|
+
if (!Array.isArray(g))
|
|
692
761
|
throw new Error(
|
|
693
|
-
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${
|
|
762
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${f}"].items["${o.id}"].type.units must be an array`
|
|
694
763
|
);
|
|
695
|
-
const
|
|
696
|
-
for (const p of
|
|
764
|
+
const c = /* @__PURE__ */ new Set();
|
|
765
|
+
for (const p of g) {
|
|
697
766
|
if (typeof p != "string" || p.length === 0)
|
|
698
767
|
throw new Error(
|
|
699
|
-
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${
|
|
768
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${f}"].items["${o.id}"].type.units entries must be non-empty strings (got ${JSON.stringify(p)})`
|
|
700
769
|
);
|
|
701
|
-
if (
|
|
770
|
+
if (c.has(p))
|
|
702
771
|
throw new Error(
|
|
703
|
-
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${
|
|
772
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${f}"].items["${o.id}"].type.units: duplicate unit ${JSON.stringify(p)}`
|
|
704
773
|
);
|
|
705
|
-
|
|
774
|
+
c.add(p);
|
|
706
775
|
}
|
|
707
776
|
}
|
|
708
777
|
}
|
|
709
778
|
}
|
|
710
779
|
for (const s of t.tiers) {
|
|
711
|
-
const
|
|
712
|
-
if (
|
|
713
|
-
if (typeof
|
|
780
|
+
const r = s, f = r.id;
|
|
781
|
+
if (r.referencesTier !== void 0) {
|
|
782
|
+
if (typeof r.referencesTier != "string")
|
|
714
783
|
throw new Error(
|
|
715
|
-
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${
|
|
784
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${f}"].referencesTier must be a string`
|
|
716
785
|
);
|
|
717
|
-
const
|
|
718
|
-
if (!i.has(
|
|
786
|
+
const l = r.referencesTier;
|
|
787
|
+
if (!i.has(l))
|
|
719
788
|
throw new Error(
|
|
720
|
-
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${
|
|
789
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${f}"].referencesTier: tier "${l}" does not exist in this tab`
|
|
721
790
|
);
|
|
722
|
-
const
|
|
723
|
-
if (
|
|
791
|
+
const o = u.get(f), a = u.get(l);
|
|
792
|
+
if (o !== void 0 && a !== void 0 && o !== "text" && o !== a)
|
|
724
793
|
throw new Error(
|
|
725
|
-
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${
|
|
794
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${f}"].referencesTier: referencing tier has kind "${o}" but referenced tier "${l}" has kind "${a}" (cross-kind reference is only allowed when the referencing tier has kind "text")`
|
|
726
795
|
);
|
|
727
796
|
}
|
|
728
797
|
}
|
|
729
798
|
for (const s of t.tiers) {
|
|
730
|
-
const
|
|
731
|
-
if (
|
|
732
|
-
|
|
799
|
+
const r = s, f = r.id, l = r.preview;
|
|
800
|
+
if (l === void 0) continue;
|
|
801
|
+
const o = u.get(f), a = typeof r.referencesTier == "string" ? u.get(r.referencesTier) : void 0, g = (c) => {
|
|
802
|
+
throw new Error(
|
|
803
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${f}"].preview "${l}" requires ${c}`
|
|
804
|
+
);
|
|
805
|
+
};
|
|
806
|
+
if (l === "size" && (r.referencesTier === void 0 ? o !== "length" : a !== "length") && g("a length tier or a reference tier resolving to length"), l === "line-height" && o !== "number" && g("a number tier"), l === "family" && o !== "text" && g("a text tier"), l === "weight" && o !== "select" && o !== "number" && g("a select or number tier"), (l === "bar" || l === "radius") && o !== "length" && g("a length tier"), l === "duration") {
|
|
807
|
+
o !== "length" && o !== "number" && g('a length or number tier with unit "ms" or "s"');
|
|
808
|
+
for (const c of r.items) {
|
|
809
|
+
if (c === null || typeof c != "object" || Array.isArray(c))
|
|
810
|
+
continue;
|
|
811
|
+
const p = c.type, h = p !== null && typeof p == "object" && !Array.isArray(p) ? p.unit : void 0;
|
|
812
|
+
h !== "ms" && h !== "s" && g('a length or number tier with unit "ms" or "s"');
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
for (const s of t.tiers) {
|
|
817
|
+
const r = s, f = r.id;
|
|
818
|
+
if (r.referencesRamps === void 0) continue;
|
|
819
|
+
if (r.semantic !== !0)
|
|
733
820
|
throw new Error(
|
|
734
|
-
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${
|
|
821
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${f}"].referencesRamps is only valid on a tier with semantic: true`
|
|
735
822
|
);
|
|
736
|
-
if (!Array.isArray(
|
|
823
|
+
if (!Array.isArray(r.referencesRamps))
|
|
737
824
|
throw new Error(
|
|
738
|
-
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${
|
|
825
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${f}"].referencesRamps must be an array`
|
|
739
826
|
);
|
|
740
827
|
if (e !== "color" && e !== "color-secondary")
|
|
741
828
|
throw new Error(
|
|
742
|
-
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${
|
|
829
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${f}"].referencesRamps is only supported on tabs with id "color" or "color-secondary" (got "${e}")`
|
|
743
830
|
);
|
|
744
|
-
const
|
|
745
|
-
for (let
|
|
746
|
-
const
|
|
747
|
-
if (
|
|
831
|
+
const l = u.get(f), o = r.referencesRamps;
|
|
832
|
+
for (let a = 0; a < o.length; a++) {
|
|
833
|
+
const g = o[a];
|
|
834
|
+
if (g === null || typeof g != "object" || Array.isArray(g))
|
|
748
835
|
throw new Error(
|
|
749
|
-
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${
|
|
836
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${f}"].referencesRamps[${a}] must be a non-null object`
|
|
750
837
|
);
|
|
751
|
-
const
|
|
752
|
-
if (typeof
|
|
838
|
+
const c = g;
|
|
839
|
+
if (typeof c.tier != "string" || c.tier.length === 0)
|
|
753
840
|
throw new Error(
|
|
754
|
-
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${
|
|
841
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${f}"].referencesRamps[${a}].tier must be a non-empty string`
|
|
755
842
|
);
|
|
756
|
-
if (
|
|
843
|
+
if (c.tab !== void 0 && (typeof c.tab != "string" || c.tab.length === 0))
|
|
757
844
|
throw new Error(
|
|
758
|
-
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${
|
|
845
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${f}"].referencesRamps[${a}].tab must be a non-empty string when set`
|
|
759
846
|
);
|
|
760
|
-
const p =
|
|
761
|
-
let
|
|
847
|
+
const p = c.tab === void 0 ? e : c.tab;
|
|
848
|
+
let h;
|
|
762
849
|
if (p === e)
|
|
763
|
-
|
|
850
|
+
h = t;
|
|
764
851
|
else {
|
|
765
|
-
const
|
|
852
|
+
const b = n.find(
|
|
766
853
|
(y) => y !== null && typeof y == "object" && !Array.isArray(y) && y.id === p
|
|
767
854
|
);
|
|
768
|
-
if (!
|
|
769
|
-
const y = n.filter((
|
|
855
|
+
if (!b) {
|
|
856
|
+
const y = n.filter((w) => w !== null && typeof w == "object" && !Array.isArray(w)).map((w) => w.id).join(", ");
|
|
770
857
|
throw new Error(
|
|
771
|
-
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${
|
|
858
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${f}"].referencesRamps[${a}]: tab "${p}" does not exist. Available tabs: ${y}.`
|
|
772
859
|
);
|
|
773
860
|
}
|
|
774
|
-
|
|
861
|
+
h = b;
|
|
775
862
|
}
|
|
776
|
-
const C = Array.isArray(
|
|
863
|
+
const C = Array.isArray(h.tiers) ? h.tiers : [], T = [];
|
|
777
864
|
let P;
|
|
778
|
-
for (const
|
|
779
|
-
if (
|
|
780
|
-
const y =
|
|
781
|
-
typeof y.id == "string" && (T.push(y.id), y.id ===
|
|
865
|
+
for (const b of C) {
|
|
866
|
+
if (b === null || typeof b != "object" || Array.isArray(b)) continue;
|
|
867
|
+
const y = b;
|
|
868
|
+
typeof y.id == "string" && (T.push(y.id), y.id === c.tier && (P = y));
|
|
782
869
|
}
|
|
783
870
|
if (!P)
|
|
784
871
|
throw new Error(
|
|
785
|
-
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${
|
|
872
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${f}"].referencesRamps[${a}]: tier "${c.tier}" does not exist in tab "${p}". Available tiers: ${T.join(", ")}.`
|
|
786
873
|
);
|
|
787
|
-
if (
|
|
788
|
-
const
|
|
874
|
+
if (l !== void 0) {
|
|
875
|
+
const b = Array.isArray(P.items) ? P.items : [];
|
|
789
876
|
let y;
|
|
790
|
-
for (const
|
|
791
|
-
if (
|
|
792
|
-
const E =
|
|
877
|
+
for (const w of b) {
|
|
878
|
+
if (w === null || typeof w != "object" || Array.isArray(w)) continue;
|
|
879
|
+
const E = w.type;
|
|
793
880
|
if (E === null || typeof E != "object" || Array.isArray(E)) continue;
|
|
794
|
-
const
|
|
795
|
-
if (typeof
|
|
796
|
-
y =
|
|
881
|
+
const O = E.kind;
|
|
882
|
+
if (typeof O == "string") {
|
|
883
|
+
y = O;
|
|
797
884
|
break;
|
|
798
885
|
}
|
|
799
886
|
}
|
|
800
|
-
if (y !== void 0 &&
|
|
887
|
+
if (y !== void 0 && l !== y)
|
|
801
888
|
throw new Error(
|
|
802
|
-
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${
|
|
889
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${f}"].referencesRamps[${a}]: referencing semantic tier has kind "${l}" but target tier "${c.tier}" in tab "${p}" has kind "${y}" (cross-tab ramp sources must share the semantic tier's kind)`
|
|
803
890
|
);
|
|
804
891
|
}
|
|
805
892
|
}
|
|
@@ -810,39 +897,39 @@ function W(e, t, n) {
|
|
|
810
897
|
throw new Error(
|
|
811
898
|
`[design-token-panel] PanelConfig.tabs["${e}"].colorExtras must be a plain object`
|
|
812
899
|
);
|
|
813
|
-
for (const
|
|
814
|
-
if (typeof s[
|
|
900
|
+
for (const o of ["id", "defaultShikiTheme"])
|
|
901
|
+
if (typeof s[o] != "string" || s[o].length === 0)
|
|
815
902
|
throw new Error(
|
|
816
|
-
`[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.${
|
|
903
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.${o} must be a non-empty string (got ${typeof s[o]})`
|
|
817
904
|
);
|
|
818
|
-
for (const
|
|
819
|
-
if (s[
|
|
905
|
+
for (const o of ["colorSchemes", "baseRoles", "baseDefaults"])
|
|
906
|
+
if (s[o] === void 0 || s[o] === null || typeof s[o] != "object" || Array.isArray(s[o]))
|
|
820
907
|
throw new Error(
|
|
821
|
-
`[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.${
|
|
908
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.${o} must be a plain object`
|
|
822
909
|
);
|
|
823
910
|
if (s.panelSettings === void 0 || s.panelSettings === null || typeof s.panelSettings != "object" || Array.isArray(s.panelSettings))
|
|
824
911
|
throw new Error(
|
|
825
912
|
`[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.panelSettings must be a plain object`
|
|
826
913
|
);
|
|
827
|
-
const
|
|
828
|
-
if (typeof
|
|
914
|
+
const r = s.panelSettings;
|
|
915
|
+
if (typeof r.colorScheme != "string" || r.colorScheme.length === 0)
|
|
829
916
|
throw new Error(
|
|
830
917
|
`[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.panelSettings.colorScheme must be a non-empty string`
|
|
831
918
|
);
|
|
832
|
-
if (
|
|
833
|
-
if (
|
|
919
|
+
if (r.colorMode !== !1) {
|
|
920
|
+
if (r.colorMode === null || typeof r.colorMode != "object" || Array.isArray(r.colorMode))
|
|
834
921
|
throw new Error(
|
|
835
922
|
`[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.panelSettings.colorMode must be false or a plain object`
|
|
836
923
|
);
|
|
837
|
-
const
|
|
838
|
-
for (const
|
|
839
|
-
if (typeof
|
|
924
|
+
const o = r.colorMode;
|
|
925
|
+
for (const a of ["lightScheme", "darkScheme"])
|
|
926
|
+
if (typeof o[a] != "string" || o[a].length === 0)
|
|
840
927
|
throw new Error(
|
|
841
|
-
`[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.panelSettings.colorMode.${
|
|
928
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.panelSettings.colorMode.${a} must be a non-empty string`
|
|
842
929
|
);
|
|
843
|
-
if (
|
|
930
|
+
if (o.defaultMode !== "light" && o.defaultMode !== "dark")
|
|
844
931
|
throw new Error(
|
|
845
|
-
`[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.panelSettings.colorMode.defaultMode must be "light" or "dark" (got ${JSON.stringify(
|
|
932
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.panelSettings.colorMode.defaultMode must be "light" or "dark" (got ${JSON.stringify(o.defaultMode)})`
|
|
846
933
|
);
|
|
847
934
|
}
|
|
848
935
|
if (s.semanticDefaults !== void 0) {
|
|
@@ -850,37 +937,37 @@ function W(e, t, n) {
|
|
|
850
937
|
throw new Error(
|
|
851
938
|
`[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.semanticDefaults must be a plain object`
|
|
852
939
|
);
|
|
853
|
-
const
|
|
854
|
-
for (const [
|
|
855
|
-
if (!
|
|
940
|
+
const o = s.semanticDefaults;
|
|
941
|
+
for (const [a, g] of Object.entries(o))
|
|
942
|
+
if (!Y(g))
|
|
856
943
|
throw new Error(
|
|
857
|
-
`[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.semanticDefaults["${
|
|
944
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.semanticDefaults["${a}"] must be a valid SemanticValue (number | 'bg' | 'fg' | { literal: string } | { literal: { light, dark } } | { ref: { tier, item, tab? } }), got ${JSON.stringify(g)}`
|
|
858
945
|
);
|
|
859
946
|
}
|
|
860
|
-
const
|
|
861
|
-
if (
|
|
862
|
-
const
|
|
863
|
-
if (!Array.isArray(
|
|
864
|
-
const
|
|
865
|
-
if (
|
|
866
|
-
const
|
|
867
|
-
return
|
|
947
|
+
const l = t.tiers.find((o) => {
|
|
948
|
+
if (o.referencesTier !== void 0 || o.semantic === !0) return !1;
|
|
949
|
+
const a = o.items;
|
|
950
|
+
if (!Array.isArray(a) || a.length === 0) return !1;
|
|
951
|
+
const g = a[0];
|
|
952
|
+
if (g === null || typeof g != "object" || Array.isArray(g)) return !1;
|
|
953
|
+
const c = g.type;
|
|
954
|
+
return c === null || typeof c != "object" || Array.isArray(c) ? !1 : c.kind === "color";
|
|
868
955
|
});
|
|
869
|
-
if (
|
|
870
|
-
const
|
|
871
|
-
if (
|
|
872
|
-
const
|
|
873
|
-
if (
|
|
874
|
-
for (let p = 0; p <
|
|
875
|
-
const
|
|
876
|
-
if (
|
|
956
|
+
if (l) {
|
|
957
|
+
const o = l.id, a = l.items, g = a[0]?.cssVar;
|
|
958
|
+
if (g !== void 0) {
|
|
959
|
+
const c = g.replace(/\d+$/, "{n}");
|
|
960
|
+
if (c.includes("{n}"))
|
|
961
|
+
for (let p = 0; p < a.length; p++) {
|
|
962
|
+
const h = a[p], C = c.replace("{n}", String(p));
|
|
963
|
+
if (h.cssVar !== C)
|
|
877
964
|
throw new Error(
|
|
878
|
-
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${
|
|
965
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${o}"].items[${p}].cssVar is ${JSON.stringify(h.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(c)})`
|
|
879
966
|
);
|
|
880
967
|
}
|
|
881
|
-
else if (
|
|
968
|
+
else if (a.length > 1)
|
|
882
969
|
throw new Error(
|
|
883
|
-
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${
|
|
970
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${o}"].items[0].cssVar ${JSON.stringify(g)} 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")`
|
|
884
971
|
);
|
|
885
972
|
}
|
|
886
973
|
}
|
|
@@ -899,21 +986,24 @@ function W(e, t, n) {
|
|
|
899
986
|
'[design-token-panel] PanelConfig.tabs["notes"].notesExtras must be a plain object with { title, html }'
|
|
900
987
|
);
|
|
901
988
|
const s = t.notesExtras;
|
|
902
|
-
for (const
|
|
903
|
-
if (typeof s[
|
|
989
|
+
for (const r of ["title", "html"])
|
|
990
|
+
if (typeof s[r] != "string" || s[r].length === 0)
|
|
904
991
|
throw new Error(
|
|
905
|
-
`[design-token-panel] PanelConfig.tabs["notes"].notesExtras.${
|
|
992
|
+
`[design-token-panel] PanelConfig.tabs["notes"].notesExtras.${r} must be a non-empty string (got ${typeof s[r]})`
|
|
906
993
|
);
|
|
907
994
|
} else if (t.notesExtras !== void 0)
|
|
908
995
|
throw new Error(
|
|
909
996
|
`[design-token-panel] PanelConfig.tabs["${e}"].notesExtras must only be set on a tab with id "notes"`
|
|
910
997
|
);
|
|
911
998
|
}
|
|
912
|
-
function
|
|
999
|
+
function X(e = j()) {
|
|
913
1000
|
return e.applyRouting ?? {};
|
|
914
1001
|
}
|
|
915
|
-
function
|
|
916
|
-
|
|
1002
|
+
function ze(e = j()) {
|
|
1003
|
+
return !!e.applyEndpoint && Object.keys(X(e)).length > 0;
|
|
1004
|
+
}
|
|
1005
|
+
function Ke(e) {
|
|
1006
|
+
const t = S();
|
|
917
1007
|
if (t === null) {
|
|
918
1008
|
m().pendingColorPresets = e;
|
|
919
1009
|
return;
|
|
@@ -921,42 +1011,48 @@ function Se(e) {
|
|
|
921
1011
|
t.config = { ...t.config, colorPresets: e };
|
|
922
1012
|
}
|
|
923
1013
|
export {
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
1014
|
+
N as A,
|
|
1015
|
+
V as B,
|
|
1016
|
+
x as C,
|
|
1017
|
+
Re as D,
|
|
1018
|
+
X as E,
|
|
1019
|
+
ze as F,
|
|
1020
|
+
ve as G,
|
|
1021
|
+
Ee as H,
|
|
1022
|
+
Pe as I,
|
|
1023
|
+
Te as J,
|
|
1024
|
+
re as K,
|
|
1025
|
+
ie as L,
|
|
1026
|
+
je as M,
|
|
1027
|
+
q as N,
|
|
1028
|
+
se as O,
|
|
1029
|
+
ae as P,
|
|
1030
|
+
Se as Q,
|
|
1031
|
+
le as _,
|
|
1032
|
+
Ae as a,
|
|
1033
|
+
_e as b,
|
|
1034
|
+
oe as c,
|
|
1035
|
+
he as d,
|
|
1036
|
+
we as e,
|
|
1037
|
+
me as f,
|
|
1038
|
+
j as g,
|
|
1039
|
+
ue as h,
|
|
1040
|
+
Ve as i,
|
|
1041
|
+
xe as j,
|
|
1042
|
+
ye as k,
|
|
1043
|
+
pe as l,
|
|
1044
|
+
Oe as m,
|
|
1045
|
+
ce as n,
|
|
1046
|
+
de as o,
|
|
1047
|
+
I as p,
|
|
1048
|
+
ee as q,
|
|
1049
|
+
ne as r,
|
|
1050
|
+
Ke as s,
|
|
1051
|
+
be as t,
|
|
1052
|
+
Ce as u,
|
|
1053
|
+
$e as v,
|
|
1054
|
+
ke as w,
|
|
1055
|
+
te as x,
|
|
1056
|
+
fe as y,
|
|
1057
|
+
ge as z
|
|
962
1058
|
};
|