@takazudo/zdtp 0.7.0 → 0.8.0

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/dist/index.d.ts CHANGED
@@ -76,8 +76,10 @@ export type { TierValueKind, PillSpec, TierItem, TierConfig, TabConfig, ColorClu
76
76
  export { isLengthKind, isNumberKind, isSelectKind, isTextKind, isColorKind, isCursorKind, isContentKind, isMaskImageKind, } from "./tokens/tier-model.js";
77
77
  export type { TweakState } from "./state/tweak-state.js";
78
78
  export { emptyOverrides } from "./state/tweak-state.js";
79
- export { SCHEMA_V1, SCHEMA_V2, SCHEMA_V3, } from "./utils/design-token-serde.js";
79
+ export { SCHEMA_V1, SCHEMA_V2, SCHEMA_V3, analyzeDesignTokenJson, deserialize, DesignTokenSchemaError, } from "./utils/design-token-serde.js";
80
+ export type { ImportAnalysis, DeserializeOptions, DeserializeResult } from "./utils/design-token-serde.js";
80
81
  export { getClusterDefaultMode, resolvePerModeLiteral, resolveSemanticPreviewColor, } from "./state/tweak-state.js";
82
+ export { splitLightDark, resolveModeSides, isModeDependent } from "./tokens/mode-dependence.js";
81
83
  export declare function showDesignTokenPanel(): void;
82
84
  export declare function hideDesignTokenPanel(): void;
83
85
  export declare function toggleDesignPanel(): void;
@@ -127,8 +129,8 @@ export declare function __reapplyFromStorageForTests(): void;
127
129
  * Preact shell still mounts separately when visibility intent requires it via
128
130
  * `reapplyFromStorage()`.
129
131
  *
130
- * No-op when nothing is persisted. Swallows errors — missing storage or
131
- * corrupt state should never block the UI thread (stylesheet defaults paint
132
+ * With no persisted state, applies only explicit manifest mode pairs. Swallows
133
+ * errors — missing storage or corrupt state should never block the UI thread (stylesheet defaults paint
132
134
  * instead, same as before this helper existed).
133
135
  */
134
136
  export declare function reapplyPersistedOverrides(): void;
package/dist/index.js CHANGED
@@ -1,42 +1,49 @@
1
1
  import "preact/jsx-runtime";
2
2
  import "preact";
3
- import { S as i, c as n, d as l, _ as d, e as _, f as p, g as m, h as g, i as P, j as S, k as C, l as A, m as T, n as u, o as c, q as f, r as K, s as M, t as w, v as F, w as v, x, y as E, z as h, B as y } from "./index-CUWkR-Gb.js";
4
- import { Z as b, a2 as k, x as H, w as L, a5 as V } from "./tweak-state-Dhjqig0C.js";
5
- import { b as Y, c as B, s as G } from "./panel-config-Crn5QJGy.js";
6
- import "./autoload-state-CGnis85c.js";
3
+ import { D as t, S as n, c as l, d, _ as p, e as _, f as g, g as m, h as S, i as P, j as C, k as T, l as A, m as c, n as f, o as u, q as D, r as M, s as E, t as K, v as h, w as k, x as v, y as w, z as x, B as F, C as y, E as L } from "./index-blRjSavc.js";
4
+ import { Z as H, a3 as V, x as z, w as O, a6 as Y } from "./tweak-state-BiaKbhXN.js";
5
+ import { b as G, c as I, s as N } from "./panel-config-DKfob-1r.js";
6
+ import "./autoload-state-CtB0e8mY.js";
7
+ import { i as Z, r as j, s as q } from "./mode-dependence-Ci9avNt8.js";
7
8
  import "./constants.js";
8
9
  export {
9
- i as SCHEMA_V1,
10
- n as SCHEMA_V2,
11
- l as SCHEMA_V3,
12
- b as ZDTP_LEGACY_TYPOGRAPHY_RENAME_MAP,
13
- d as __claimSpawnSlotForTests,
10
+ t as DesignTokenSchemaError,
11
+ n as SCHEMA_V1,
12
+ l as SCHEMA_V2,
13
+ d as SCHEMA_V3,
14
+ H as ZDTP_LEGACY_TYPOGRAPHY_RENAME_MAP,
15
+ p as __claimSpawnSlotForTests,
14
16
  _ as __mountedSpawnSlotsForTests,
15
- p as __panelConfigForTest,
17
+ g as __panelConfigForTest,
16
18
  m as __reapplyFromStorageForTests,
17
- g as __resetInstanceBindingsForTests,
19
+ S as __resetInstanceBindingsForTests,
18
20
  P as __resetSpawnSlotsForTests,
19
- Y as assertValidPanelConfig,
20
- B as configurePanel,
21
- S as disableAutoload,
22
- k as emptyOverrides,
23
- C as enableAutoload,
24
- H as getClusterDefaultMode,
25
- A as hideDesignTokenPanel,
26
- T as isColorKind,
27
- u as isContentKind,
28
- c as isCursorKind,
29
- f as isLengthKind,
21
+ C as analyzeDesignTokenJson,
22
+ G as assertValidPanelConfig,
23
+ I as configurePanel,
24
+ T as deserialize,
25
+ A as disableAutoload,
26
+ V as emptyOverrides,
27
+ c as enableAutoload,
28
+ z as getClusterDefaultMode,
29
+ f as hideDesignTokenPanel,
30
+ u as isColorKind,
31
+ D as isContentKind,
32
+ M as isCursorKind,
33
+ E as isLengthKind,
30
34
  K as isMaskImageKind,
31
- M as isNumberKind,
32
- w as isSelectKind,
33
- F as isTextKind,
34
- v as reapplyPersistedOverrides,
35
- L as resolvePerModeLiteral,
36
- V as resolveSemanticPreviewColor,
35
+ Z as isModeDependent,
36
+ h as isNumberKind,
37
+ k as isSelectKind,
38
+ v as isTextKind,
39
+ w as reapplyPersistedOverrides,
40
+ j as resolveModeSides,
41
+ O as resolvePerModeLiteral,
42
+ Y as resolveSemanticPreviewColor,
37
43
  x as setLifecycleAdapter,
38
- G as setPanelColorPresets,
39
- E as shouldAutoload,
40
- h as showDesignTokenPanel,
41
- y as toggleDesignPanel
44
+ N as setPanelColorPresets,
45
+ F as shouldAutoload,
46
+ y as showDesignTokenPanel,
47
+ q as splitLightDark,
48
+ L as toggleDesignPanel
42
49
  };
@@ -0,0 +1,61 @@
1
+ function g(e) {
2
+ if (typeof e != "string") return null;
3
+ const n = e.trim(), l = /^light-dark\s*\(/i.exec(n);
4
+ if (!l) return null;
5
+ const s = l[0].lastIndexOf("(");
6
+ let i = 1, u = -1, o = -1;
7
+ for (let t = s + 1; t < n.length; t++) {
8
+ const r = n[t];
9
+ if (r === '"' || r === "'") {
10
+ const f = r;
11
+ let a = !1;
12
+ for (t++; t < n.length; t++)
13
+ if (n[t] === "\\")
14
+ t++;
15
+ else if (n[t] === f) {
16
+ a = !0;
17
+ break;
18
+ }
19
+ if (!a) return null;
20
+ continue;
21
+ }
22
+ if (r === "/" && n[t + 1] === "*") {
23
+ const f = n.indexOf("*/", t + 2);
24
+ if (f === -1) return null;
25
+ t = f + 1;
26
+ continue;
27
+ }
28
+ if (r === "(") {
29
+ if (/\blight-dark\s*$/i.test(n.slice(s + 1, t))) return null;
30
+ i++;
31
+ } else if (r === ")") {
32
+ if (i--, i < 0) return null;
33
+ if (i === 0) {
34
+ o = t;
35
+ break;
36
+ }
37
+ } else if (r === "," && i === 1) {
38
+ if (u !== -1) return null;
39
+ u = t;
40
+ }
41
+ }
42
+ if (o === -1 || n.slice(o + 1).trim() !== "" || u === -1) return null;
43
+ const c = n.slice(s + 1, u).trim(), d = n.slice(u + 1, o).trim();
44
+ return c.length === 0 || d.length === 0 ? null : { light: c, dark: d };
45
+ }
46
+ function h(e, n) {
47
+ if (e.modes !== void 0) return { ...e.modes };
48
+ if (n !== null && typeof n == "object" && !Array.isArray(n) && "literal" in n) {
49
+ const l = n.literal;
50
+ return typeof l == "string" ? g(l) : { light: l.light, dark: l.dark };
51
+ }
52
+ return g(e.default);
53
+ }
54
+ function p(e, n) {
55
+ return h(e, n) !== null;
56
+ }
57
+ export {
58
+ p as i,
59
+ h as r,
60
+ g as s
61
+ };