@takazudo/zdtp 0.1.0-next.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.
Files changed (130) hide show
  1. package/CHANGELOG.md +107 -0
  2. package/LICENSE +21 -0
  3. package/README.md +1044 -0
  4. package/dist/apply/apply-token-overrides.d.ts +81 -0
  5. package/dist/apply/apply-token-overrides.d.ts.map +1 -0
  6. package/dist/apply/build-apply-overrides.d.ts +71 -0
  7. package/dist/apply/build-apply-overrides.d.ts.map +1 -0
  8. package/dist/apply/route-tokens-to-files.d.ts +65 -0
  9. package/dist/apply/route-tokens-to-files.d.ts.map +1 -0
  10. package/dist/apply/tier-resolver.d.ts +75 -0
  11. package/dist/apply/tier-resolver.d.ts.map +1 -0
  12. package/dist/apply-modal.d.ts +49 -0
  13. package/dist/apply-modal.d.ts.map +1 -0
  14. package/dist/astro/DesignTokenPanelHost.astro +76 -0
  15. package/dist/astro/host-adapter.d.ts +47 -0
  16. package/dist/astro/host-adapter.d.ts.map +1 -0
  17. package/dist/astro/host-adapter.js +81 -0
  18. package/dist/astro/index.d.ts +30 -0
  19. package/dist/astro/index.d.ts.map +1 -0
  20. package/dist/astro/index.js +54 -0
  21. package/dist/bin/cors.d.ts +24 -0
  22. package/dist/bin/cors.d.ts.map +1 -0
  23. package/dist/bin/parse-args.d.ts +38 -0
  24. package/dist/bin/parse-args.d.ts.map +1 -0
  25. package/dist/bin/server.d.ts +23 -0
  26. package/dist/bin/server.d.ts.map +1 -0
  27. package/dist/bin/server.js +283 -0
  28. package/dist/color-schemes-CgzOBqGO.js +85 -0
  29. package/dist/components/color-picker/color-picker.d.ts +64 -0
  30. package/dist/components/color-picker/color-picker.d.ts.map +1 -0
  31. package/dist/components/color-picker/custom-slider.d.ts +25 -0
  32. package/dist/components/color-picker/custom-slider.d.ts.map +1 -0
  33. package/dist/components/color-picker/index.d.ts +3 -0
  34. package/dist/components/color-picker/index.d.ts.map +1 -0
  35. package/dist/config/cluster-config.d.ts +135 -0
  36. package/dist/config/cluster-config.d.ts.map +1 -0
  37. package/dist/config/color-scheme-utils.d.ts +105 -0
  38. package/dist/config/color-scheme-utils.d.ts.map +1 -0
  39. package/dist/config/color-schemes.d.ts +83 -0
  40. package/dist/config/color-schemes.d.ts.map +1 -0
  41. package/dist/config/panel-config.d.ts +258 -0
  42. package/dist/config/panel-config.d.ts.map +1 -0
  43. package/dist/controls/pill-slider-row.d.ts +37 -0
  44. package/dist/controls/pill-slider-row.d.ts.map +1 -0
  45. package/dist/controls/role-button.d.ts +18 -0
  46. package/dist/controls/role-button.d.ts.map +1 -0
  47. package/dist/controls/sanitize-css-value.d.ts +22 -0
  48. package/dist/controls/sanitize-css-value.d.ts.map +1 -0
  49. package/dist/controls/select-row.d.ts +26 -0
  50. package/dist/controls/select-row.d.ts.map +1 -0
  51. package/dist/controls/slider-row.d.ts +34 -0
  52. package/dist/controls/slider-row.d.ts.map +1 -0
  53. package/dist/controls/text-row.d.ts +28 -0
  54. package/dist/controls/text-row.d.ts.map +1 -0
  55. package/dist/controls/tier-ref-selector.d.ts +33 -0
  56. package/dist/controls/tier-ref-selector.d.ts.map +1 -0
  57. package/dist/controls/tooltip.d.ts +44 -0
  58. package/dist/controls/tooltip.d.ts.map +1 -0
  59. package/dist/export-modal.d.ts +33 -0
  60. package/dist/export-modal.d.ts.map +1 -0
  61. package/dist/highlight/find-elements.d.ts +113 -0
  62. package/dist/highlight/find-elements.d.ts.map +1 -0
  63. package/dist/highlight/highlight-orchestrator.d.ts +24 -0
  64. package/dist/highlight/highlight-orchestrator.d.ts.map +1 -0
  65. package/dist/highlight/highlight-overlay.d.ts +43 -0
  66. package/dist/highlight/highlight-overlay.d.ts.map +1 -0
  67. package/dist/highlight/highlight-settings-popover.d.ts +25 -0
  68. package/dist/highlight/highlight-settings-popover.d.ts.map +1 -0
  69. package/dist/highlight/highlight-state.d.ts +87 -0
  70. package/dist/highlight/highlight-state.d.ts.map +1 -0
  71. package/dist/highlight/highlight-toggle-button.d.ts +34 -0
  72. package/dist/highlight/highlight-toggle-button.d.ts.map +1 -0
  73. package/dist/import-modal.d.ts +33 -0
  74. package/dist/import-modal.d.ts.map +1 -0
  75. package/dist/index.d.ts +105 -0
  76. package/dist/index.d.ts.map +1 -0
  77. package/dist/index.js +5480 -0
  78. package/dist/load-routing-XyKgftpe.js +353 -0
  79. package/dist/manifest-DCReQE0k.js +24 -0
  80. package/dist/panel-config-DP2_P7dD.js +332 -0
  81. package/dist/panel.d.ts +3 -0
  82. package/dist/panel.d.ts.map +1 -0
  83. package/dist/route-tokens-to-files-1DvmWBdj.js +41 -0
  84. package/dist/server/create-apply-handler.d.ts +48 -0
  85. package/dist/server/create-apply-handler.d.ts.map +1 -0
  86. package/dist/server/index.d.ts +24 -0
  87. package/dist/server/index.d.ts.map +1 -0
  88. package/dist/server/index.js +10 -0
  89. package/dist/server/load-routing.d.ts +39 -0
  90. package/dist/server/load-routing.d.ts.map +1 -0
  91. package/dist/server/path-safety.d.ts +36 -0
  92. package/dist/server/path-safety.d.ts.map +1 -0
  93. package/dist/server/serialize-write.d.ts +7 -0
  94. package/dist/server/serialize-write.d.ts.map +1 -0
  95. package/dist/state/persist.d.ts +39 -0
  96. package/dist/state/persist.d.ts.map +1 -0
  97. package/dist/state/tweak-state.d.ts +344 -0
  98. package/dist/state/tweak-state.d.ts.map +1 -0
  99. package/dist/tabs/_generic-item-editor.d.ts +23 -0
  100. package/dist/tabs/_generic-item-editor.d.ts.map +1 -0
  101. package/dist/tabs/color-tab.d.ts +55 -0
  102. package/dist/tabs/color-tab.d.ts.map +1 -0
  103. package/dist/tabs/font-tab.d.ts +22 -0
  104. package/dist/tabs/font-tab.d.ts.map +1 -0
  105. package/dist/tabs/generic-tab.d.ts +43 -0
  106. package/dist/tabs/generic-tab.d.ts.map +1 -0
  107. package/dist/tabs/size-tab.d.ts +20 -0
  108. package/dist/tabs/size-tab.d.ts.map +1 -0
  109. package/dist/tabs/spacing-tab.d.ts +23 -0
  110. package/dist/tabs/spacing-tab.d.ts.map +1 -0
  111. package/dist/testing.d.ts +81 -0
  112. package/dist/testing.d.ts.map +1 -0
  113. package/dist/testing.js +23 -0
  114. package/dist/tokens/manifest.d.ts +148 -0
  115. package/dist/tokens/manifest.d.ts.map +1 -0
  116. package/dist/tokens/tier-model.d.ts +89 -0
  117. package/dist/tokens/tier-model.d.ts.map +1 -0
  118. package/dist/tweak-state-DSJa5csL.js +624 -0
  119. package/dist/utils/color-convert.d.ts +7 -0
  120. package/dist/utils/color-convert.d.ts.map +1 -0
  121. package/dist/utils/color-hsla.d.ts +9 -0
  122. package/dist/utils/color-hsla.d.ts.map +1 -0
  123. package/dist/utils/color-oklch.d.ts +51 -0
  124. package/dist/utils/color-oklch.d.ts.map +1 -0
  125. package/dist/utils/design-token-serde.d.ts +193 -0
  126. package/dist/utils/design-token-serde.d.ts.map +1 -0
  127. package/dist/utils/structural-equal.d.ts +22 -0
  128. package/dist/utils/structural-equal.d.ts.map +1 -0
  129. package/dist/zdtp.css +1 -0
  130. package/package.json +102 -0
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Import modal — accepts a pasted design-tokens JSON document (default schema:
3
+ * `zudo-design-tokens/v1`; configurable via `panelConfig.schemaId`) and lifts
4
+ * it into a `TweakState` via `deserialize()`. Validation and unknown-token
5
+ * reporting are delegated to serde; this component only renders status
6
+ * feedback and routes the parsed state up to the shell.
7
+ *
8
+ * Ported verbatim from zudo-doc's
9
+ * `src/components/design-token-tweak/import-modal.tsx`. Intentional deltas:
10
+ * - `deserialize` / `DesignTokenSchemaError` / `getDesignTokenSchema` come
11
+ * from this package's serde (`./utils/design-token-serde`); the schema
12
+ * id is read at render time from `panelConfig.schemaId` instead of
13
+ * being a module-level constant.
14
+ * - State types import from this package's state envelope.
15
+ * - Modal class names are derived from `panelConfig.modalClassPrefix` via
16
+ * `modalClass(...)` so a single config swap re-themes every dialog.
17
+ *
18
+ * Modal lifecycle uses the native `<dialog>` element via `showModal()` /
19
+ * `close()`. Every dismissal path (× button, backdrop click, Escape key, the
20
+ * programmatic "Close" button) routes through `dialog.close()` so the native
21
+ * `close` event — and thus `onClose` — fires exactly once per dismissal.
22
+ */
23
+ import type { ColorTweakState, TweakState } from './state/tweak-state';
24
+ export interface ImportModalProps {
25
+ onClose: () => void;
26
+ /** Called with the parsed state when the user hits "Load". The caller is
27
+ * responsible for applying it to the panel + persisting it. */
28
+ onLoad: (state: TweakState) => void;
29
+ /** Color baseline filled in for fields absent from the payload. */
30
+ colorDefaults: ColorTweakState;
31
+ }
32
+ export declare function ImportModal({ onClose, onLoad, colorDefaults }: ImportModalProps): import("preact").JSX.Element;
33
+ //# sourceMappingURL=import-modal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"import-modal.d.ts","sourceRoot":"","sources":["../src/import-modal.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAQH,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAIvE,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB;oEACgE;IAChE,MAAM,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAC;IACpC,mEAAmE;IACnE,aAAa,EAAE,eAAe,CAAC;CAChC;AAOD,wBAAgB,WAAW,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,EAAE,gBAAgB,gCA+N/E"}
@@ -0,0 +1,105 @@
1
+ /**
2
+ * Design-token panel adapter.
3
+ *
4
+ * Thin bridge between the package's Astro host adapter
5
+ * (`./astro/host-adapter.ts`) and the Preact panel component
6
+ * (`./panel.tsx`). Responsibilities:
7
+ *
8
+ * 1. Expose the public API consumed by the host adapter —
9
+ * `showDesignTokenPanel`, `hideDesignTokenPanel`, `toggleDesignPanel`.
10
+ * 2. Own the Preact mount lifecycle into the panel root element (id derived
11
+ * from `panelConfig.storagePrefix`; default: `#zudo-design-token-panel-root`).
12
+ * 3. Cooperate with `panel.tsx`'s own toggle listeners: the adapter handles
13
+ * the *initial* toggle (to mount the shell lazily) and then lets
14
+ * `panel.tsx` own steady-state toggling via its internal window listener.
15
+ * 4. Handle Astro view-transition lifecycle — unmount before swap and
16
+ * re-materialise the shell on `astro:page-load` when either the panel was
17
+ * previously visible or token overrides are persisted.
18
+ *
19
+ * Storage keys (all derived from `panelConfig` — see `config/panel-config.ts`):
20
+ *
21
+ * - `${storagePrefix}:visible` (default: `zudo-design-token-panel:visible`)
22
+ * — adapter's visibility intent flag. Owned here (adapter-level concept);
23
+ * no collision with the panel itself, so it keeps its historical colon-as-
24
+ * separator form (every other derived key uses `-`).
25
+ * - v2 storage key (imported via `getStorageKeyV2()` from `./state/tweak-state`)
26
+ * — existence probe for persisted token overrides. The actual key value
27
+ * is owned by `tweak-state.ts` (which also writes it). Routing the probe
28
+ * through the same accessor guarantees probe-key ≡ write-key.
29
+ * - `${storagePrefix}-open` (default: `zudo-design-token-panel-open`) —
30
+ * primarily owned by `panel.tsx` (its `useEffect` mirrors `open` into the
31
+ * key on every change). The adapter is read-only at steady state, but it
32
+ * *seeds* the key once before a fresh mount so `panel.tsx`'s mount-effect
33
+ * picks the desired open state on first paint instead of relying on a
34
+ * racy post-render toggle event.
35
+ */
36
+ import './styles/panel.css';
37
+ import { type PanelConfig } from './config/panel-config';
38
+ export declare const __OPEN_STATE_CHANGED_EVENT_FOR_TEST = "__zdtp:open-state-changed";
39
+ export { configurePanel, setPanelColorPresets } from './config/panel-config';
40
+ export type { PanelConfig } from './config/panel-config';
41
+ /**
42
+ * Internal-test-only accessor that returns this panel-module bundle's view of
43
+ * the active panel config singleton. Paired with the Astro host adapter's
44
+ * `loadPanelModule()` runtime guard: the adapter
45
+ * compares the reference returned here against its own `getPanelConfig()`
46
+ * result. They MUST be the same object — Vite's multi-entry build code-
47
+ * splits the shared `config/panel-config` module into one chunk so both
48
+ * surfaces observe one and the same singleton. A reference mismatch indicates
49
+ * a future packaging refactor split the singleton across two chunks; the
50
+ * adapter `console.warn`s loudly so the regression is caught in dev.
51
+ *
52
+ * Prefixed `__` to make it clear this is internal/test surface, not a
53
+ * documented public API.
54
+ */
55
+ export declare function __panelConfigForTest(): PanelConfig;
56
+ export type { ColorClusterConfig } from './state/tweak-state';
57
+ export { ZDTP_LEGACY_TYPOGRAPHY_RENAME_MAP } from './state/tweak-state';
58
+ export type { ColorScheme, ColorRef } from './config/color-schemes';
59
+ export type { TokenManifest, TokenDef } from './tokens/manifest';
60
+ export type { TierValueKind, PillSpec, TierItem, TierConfig, TabConfig, ColorClusterExtras, } from './tokens/tier-model';
61
+ export { isLengthKind, isNumberKind, isSelectKind, isTextKind, isColorKind, isCursorKind, isContentKind, isMaskImageKind, } from './tokens/tier-model';
62
+ export type { TweakState } from './state/tweak-state';
63
+ export { emptyOverrides } from './state/tweak-state';
64
+ export declare function showDesignTokenPanel(): void;
65
+ export declare function hideDesignTokenPanel(): void;
66
+ export declare function toggleDesignPanel(): void;
67
+ /**
68
+ * Apply persisted token overrides directly to `:root` BEFORE any Preact
69
+ * render. Called at adapter module init (and again on every `astro:page-load`)
70
+ * so the bundle's arrival is enough to kill the FOUT on hard navigation; the
71
+ * Preact shell still mounts separately when visibility intent requires it via
72
+ * `reapplyFromStorage()`.
73
+ *
74
+ * No-op when nothing is persisted. Swallows errors — missing storage or
75
+ * corrupt state should never block the UI thread (stylesheet defaults paint
76
+ * instead, same as before this helper existed).
77
+ */
78
+ export declare function reapplyPersistedOverrides(): void;
79
+ /**
80
+ * Framework-agnostic lifecycle hook adapter. A host that owns its own
81
+ * client-side navigation lifecycle (zfb, custom router, etc.) implements
82
+ * this and calls `setLifecycleAdapter(...)` so persisted overrides re-apply
83
+ * after every soft navigation without depending on Astro events.
84
+ *
85
+ * Each callback installer must return a cleanup function that unbinds the
86
+ * listener — `setLifecycleAdapter` calls these on re-registration and on
87
+ * `setLifecycleAdapter(null)`.
88
+ */
89
+ export interface LifecycleAdapter {
90
+ /** Install a handler that fires before a client-side navigation swaps the document. */
91
+ onBeforeSwap?: (callback: () => void) => () => void;
92
+ /** Install a handler that fires after a client-side navigation has loaded the new page. */
93
+ onPageLoad?: (callback: () => void) => () => void;
94
+ }
95
+ /**
96
+ * Register a framework-agnostic lifecycle adapter (or pass `null` to
97
+ * restore the astro fallback). Safe to call before or after the module's
98
+ * import-time bootstrap — late registration drains the astro fallback's
99
+ * cleanup fns first, so the original document listeners are actively
100
+ * unbound and never double-fire alongside the adapter.
101
+ *
102
+ * No-op outside a browser context (SSR-safe).
103
+ */
104
+ export declare function setLifecycleAdapter(adapter: LifecycleAdapter | null): void;
105
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AASH,OAAO,oBAAoB,CAAC;AAc5B,OAAO,EAKL,KAAK,WAAW,EACjB,MAAM,uBAAuB,CAAC;AAqD/B,eAAO,MAAM,mCAAmC,8BAA2B,CAAC;AAkK5E,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7E,YAAY,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEzD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,oBAAoB,IAAI,WAAW,CAElD;AAQD,YAAY,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAM9D,OAAO,EAAE,iCAAiC,EAAE,MAAM,qBAAqB,CAAC;AAGxE,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAGpE,YAAY,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAGjE,YAAY,EACV,aAAa,EACb,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,SAAS,EACT,kBAAkB,GACnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,WAAW,EACX,YAAY,EACZ,aAAa,EACb,eAAe,GAChB,MAAM,qBAAqB,CAAC;AAO7B,YAAY,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,wBAAgB,oBAAoB,IAAI,IAAI,CAoB3C;AAED,wBAAgB,oBAAoB,IAAI,IAAI,CAY3C;AAED,wBAAgB,iBAAiB,IAAI,IAAI,CAWxC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,yBAAyB,IAAI,IAAI,CAQhD;AA8HD;;;;;;;;;GASG;AACH,MAAM,WAAW,gBAAgB;IAC/B,uFAAuF;IACvF,YAAY,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,KAAK,MAAM,IAAI,CAAC;IACpD,2FAA2F;IAC3F,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,KAAK,MAAM,IAAI,CAAC;CACnD;AA4GD;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,gBAAgB,GAAG,IAAI,GAAG,IAAI,CAU1E"}