@moonwitness/ui 7.3.1 → 9.0.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 (260) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/package.json +2 -3
  3. package/scripts/consumer-smoke.mjs +0 -45
  4. package/scripts/generate-icons.mjs +0 -110
  5. package/scripts/generate-token-artifacts.mjs +0 -90
  6. package/scripts/icon-svg-to-jsx.mjs +0 -249
  7. package/scripts/verification-diagnostics.mjs +0 -40
  8. package/scripts/verify-package.mjs +0 -412
  9. package/src/cartoon/anime-avatar.tsx +0 -628
  10. package/src/cartoon/anime-stage.tsx +0 -458
  11. package/src/cartoon/index.tsx +0 -542
  12. package/src/cartoon.tsx +0 -645
  13. package/src/characters.ts +0 -625
  14. package/src/components/accordion.tsx +0 -77
  15. package/src/components/alert.tsx +0 -139
  16. package/src/components/appearance-menu.tsx +0 -181
  17. package/src/components/artwork-frame.tsx +0 -49
  18. package/src/components/audio.tsx +0 -97
  19. package/src/components/avatar.tsx +0 -75
  20. package/src/components/badge.tsx +0 -94
  21. package/src/components/brand-mark.tsx +0 -73
  22. package/src/components/breadcrumbs.tsx +0 -98
  23. package/src/components/button.tsx +0 -340
  24. package/src/components/card.tsx +0 -171
  25. package/src/components/character-badge.tsx +0 -58
  26. package/src/components/character-preview.tsx +0 -104
  27. package/src/components/character-stage.tsx +0 -225
  28. package/src/components/chart.tsx +0 -481
  29. package/src/components/checkbox.tsx +0 -64
  30. package/src/components/comic-panel.tsx +0 -301
  31. package/src/components/comic-theater.tsx +0 -170
  32. package/src/components/command.tsx +0 -189
  33. package/src/components/confirm-dialog.tsx +0 -129
  34. package/src/components/copy-button.tsx +0 -62
  35. package/src/components/date-picker.tsx +0 -126
  36. package/src/components/dialog.tsx +0 -164
  37. package/src/components/dna-icon.tsx +0 -77
  38. package/src/components/dropdown-menu.tsx +0 -87
  39. package/src/components/effects.tsx +0 -1021
  40. package/src/components/empty-state.tsx +0 -93
  41. package/src/components/epistemic-branch-panel.tsx +0 -101
  42. package/src/components/error-state.tsx +0 -137
  43. package/src/components/field.tsx +0 -96
  44. package/src/components/filter-facet-bar.tsx +0 -91
  45. package/src/components/inbox-popover.tsx +0 -146
  46. package/src/components/input.tsx +0 -25
  47. package/src/components/kanban-board.tsx +0 -190
  48. package/src/components/label.tsx +0 -19
  49. package/src/components/layered-scene.tsx +0 -555
  50. package/src/components/log-console.tsx +0 -261
  51. package/src/components/metric-tile.tsx +0 -99
  52. package/src/components/mode-picker.tsx +0 -149
  53. package/src/components/motion-timeline.tsx +0 -848
  54. package/src/components/number-input.tsx +0 -104
  55. package/src/components/page-header.tsx +0 -123
  56. package/src/components/pagination.tsx +0 -83
  57. package/src/components/panel.tsx +0 -121
  58. package/src/components/paper-note.tsx +0 -77
  59. package/src/components/popover.tsx +0 -72
  60. package/src/components/progress.tsx +0 -127
  61. package/src/components/quest-card.tsx +0 -319
  62. package/src/components/radio-group.tsx +0 -50
  63. package/src/components/riot-sticker.tsx +0 -151
  64. package/src/components/scene-particles.tsx +0 -196
  65. package/src/components/scene-transitions.tsx +0 -130
  66. package/src/components/section-ribbon.tsx +0 -94
  67. package/src/components/select-field.tsx +0 -27
  68. package/src/components/select.tsx +0 -81
  69. package/src/components/separator.tsx +0 -58
  70. package/src/components/sheet.tsx +0 -96
  71. package/src/components/skeleton.tsx +0 -35
  72. package/src/components/sketch-annotation.tsx +0 -87
  73. package/src/components/smart-button-box.tsx +0 -114
  74. package/src/components/speech-bubble.tsx +0 -116
  75. package/src/components/spinner.tsx +0 -69
  76. package/src/components/sprite-player.tsx +0 -412
  77. package/src/components/status-bar.tsx +0 -63
  78. package/src/components/status-pill.tsx +0 -68
  79. package/src/components/switch.tsx +0 -76
  80. package/src/components/table.tsx +0 -163
  81. package/src/components/tabs.tsx +0 -101
  82. package/src/components/tag-input.tsx +0 -170
  83. package/src/components/textarea.tsx +0 -25
  84. package/src/components/toast.tsx +0 -14
  85. package/src/components/toolbar.tsx +0 -39
  86. package/src/components/tooltip.tsx +0 -49
  87. package/src/components/update-banner.tsx +0 -220
  88. package/src/components/xv-primitives.tsx +0 -256
  89. package/src/css-exports.ts +0 -142
  90. package/src/dna.tsx +0 -137
  91. package/src/game/boss-hud.tsx +0 -384
  92. package/src/game/index.tsx +0 -886
  93. package/src/game/tactical.tsx +0 -245
  94. package/src/game.tsx +0 -770
  95. package/src/icons/activity.tsx +0 -38
  96. package/src/icons/add.tsx +0 -38
  97. package/src/icons/addon.tsx +0 -37
  98. package/src/icons/anime-anger.tsx +0 -37
  99. package/src/icons/anime-shock.tsx +0 -37
  100. package/src/icons/anime-sparkle.tsx +0 -38
  101. package/src/icons/anime-sweatdrop.tsx +0 -38
  102. package/src/icons/archive.tsx +0 -37
  103. package/src/icons/arrow-left.tsx +0 -37
  104. package/src/icons/arrow-right.tsx +0 -37
  105. package/src/icons/attachment.tsx +0 -38
  106. package/src/icons/bank.tsx +0 -37
  107. package/src/icons/bolt.tsx +0 -37
  108. package/src/icons/book-open.tsx +0 -37
  109. package/src/icons/bookmark.tsx +0 -37
  110. package/src/icons/boss-skull.tsx +0 -40
  111. package/src/icons/calendar-clock.tsx +0 -40
  112. package/src/icons/calendar.tsx +0 -38
  113. package/src/icons/check-circle.tsx +0 -38
  114. package/src/icons/check-square.tsx +0 -38
  115. package/src/icons/check.tsx +0 -37
  116. package/src/icons/chevron-right.tsx +0 -37
  117. package/src/icons/chevrons-left.tsx +0 -37
  118. package/src/icons/chevrons-right.tsx +0 -37
  119. package/src/icons/clapperboard.tsx +0 -38
  120. package/src/icons/clock.tsx +0 -38
  121. package/src/icons/close.tsx +0 -37
  122. package/src/icons/code.tsx +0 -37
  123. package/src/icons/columns.tsx +0 -38
  124. package/src/icons/combo-flame.tsx +0 -38
  125. package/src/icons/company.tsx +0 -38
  126. package/src/icons/credit-card.tsx +0 -38
  127. package/src/icons/critical-star.tsx +0 -37
  128. package/src/icons/currency.tsx +0 -38
  129. package/src/icons/delete.tsx +0 -37
  130. package/src/icons/document.tsx +0 -38
  131. package/src/icons/download.tsx +0 -37
  132. package/src/icons/dpad.tsx +0 -38
  133. package/src/icons/edit.tsx +0 -38
  134. package/src/icons/element-fire.tsx +0 -37
  135. package/src/icons/element-ice.tsx +0 -38
  136. package/src/icons/element-solar.tsx +0 -38
  137. package/src/icons/element-void.tsx +0 -38
  138. package/src/icons/element-volt.tsx +0 -38
  139. package/src/icons/element-wind.tsx +0 -37
  140. package/src/icons/error.tsx +0 -38
  141. package/src/icons/external-link.tsx +0 -38
  142. package/src/icons/field.tsx +0 -38
  143. package/src/icons/file-spreadsheet.tsx +0 -38
  144. package/src/icons/filter.tsx +0 -37
  145. package/src/icons/gacha-ticket.tsx +0 -38
  146. package/src/icons/gamepad.tsx +0 -40
  147. package/src/icons/globe.tsx +0 -38
  148. package/src/icons/grid.tsx +0 -40
  149. package/src/icons/hash.tsx +0 -37
  150. package/src/icons/heart-hp.tsx +0 -38
  151. package/src/icons/history.tsx +0 -37
  152. package/src/icons/home.tsx +0 -37
  153. package/src/icons/image.tsx +0 -39
  154. package/src/icons/impact-slash.tsx +0 -38
  155. package/src/icons/inbox.tsx +0 -38
  156. package/src/icons/index.ts +0 -120
  157. package/src/icons/info.tsx +0 -38
  158. package/src/icons/jobs.tsx +0 -38
  159. package/src/icons/katana.tsx +0 -38
  160. package/src/icons/key.tsx +0 -38
  161. package/src/icons/keyboard.tsx +0 -38
  162. package/src/icons/keyframe-diamond.tsx +0 -38
  163. package/src/icons/knowledge.tsx +0 -38
  164. package/src/icons/language.tsx +0 -39
  165. package/src/icons/lock.tsx +0 -38
  166. package/src/icons/logout.tsx +0 -37
  167. package/src/icons/loot-chest.tsx +0 -39
  168. package/src/icons/mail.tsx +0 -38
  169. package/src/icons/mana-crystal.tsx +0 -38
  170. package/src/icons/map-pin.tsx +0 -38
  171. package/src/icons/mecha-helm.tsx +0 -38
  172. package/src/icons/menu.tsx +0 -37
  173. package/src/icons/message.tsx +0 -38
  174. package/src/icons/model.tsx +0 -38
  175. package/src/icons/moon.tsx +0 -37
  176. package/src/icons/notification.tsx +0 -38
  177. package/src/icons/partner.tsx +0 -41
  178. package/src/icons/pause.tsx +0 -37
  179. package/src/icons/phone.tsx +0 -37
  180. package/src/icons/play.tsx +0 -37
  181. package/src/icons/potion-flask.tsx +0 -40
  182. package/src/icons/quest-scroll.tsx +0 -39
  183. package/src/icons/radar-ping.tsx +0 -40
  184. package/src/icons/refresh.tsx +0 -38
  185. package/src/icons/relation.tsx +0 -40
  186. package/src/icons/save.tsx +0 -38
  187. package/src/icons/search.tsx +0 -38
  188. package/src/icons/security.tsx +0 -38
  189. package/src/icons/send.tsx +0 -38
  190. package/src/icons/settings.tsx +0 -39
  191. package/src/icons/shield-crest.tsx +0 -38
  192. package/src/icons/shuriken.tsx +0 -38
  193. package/src/icons/signal-off.tsx +0 -37
  194. package/src/icons/signal.tsx +0 -37
  195. package/src/icons/skill-node.tsx +0 -40
  196. package/src/icons/smartphone.tsx +0 -38
  197. package/src/icons/sort-ascending.tsx +0 -37
  198. package/src/icons/sort-descending.tsx +0 -37
  199. package/src/icons/sort.tsx +0 -37
  200. package/src/icons/sparkle.tsx +0 -38
  201. package/src/icons/speech-burst.tsx +0 -37
  202. package/src/icons/story.tsx +0 -37
  203. package/src/icons/sun.tsx +0 -38
  204. package/src/icons/tag.tsx +0 -38
  205. package/src/icons/team.tsx +0 -40
  206. package/src/icons/trophy-crown.tsx +0 -39
  207. package/src/icons/upload.tsx +0 -37
  208. package/src/icons/user.tsx +0 -38
  209. package/src/icons/users.tsx +0 -39
  210. package/src/icons/visibility-off.tsx +0 -38
  211. package/src/icons/visibility.tsx +0 -38
  212. package/src/icons/volume-off.tsx +0 -37
  213. package/src/icons/volume.tsx +0 -37
  214. package/src/icons/warning.tsx +0 -38
  215. package/src/icons/workflow.tsx +0 -40
  216. package/src/icons.tsx +0 -965
  217. package/src/index.ts +0 -89
  218. package/src/lib/asset-registry.ts +0 -534
  219. package/src/lib/audio-runtime.ts +0 -314
  220. package/src/lib/character-adapter.ts +0 -370
  221. package/src/lib/character-registry.ts +0 -2368
  222. package/src/lib/cn.ts +0 -6
  223. package/src/lib/compose-refs.ts +0 -16
  224. package/src/lib/sanitize-url.ts +0 -51
  225. package/src/lib/scene-camera.ts +0 -483
  226. package/src/lib/scene-playback.ts +0 -622
  227. package/src/lib/scene-soundscape.ts +0 -151
  228. package/src/lib/scene-test-harness.ts +0 -200
  229. package/src/lib/scene-timeline.ts +0 -398
  230. package/src/lib/use-animation-visibility.ts +0 -45
  231. package/src/lib/use-modal-focus.ts +0 -270
  232. package/src/lib/use-reduced-motion.ts +0 -37
  233. package/src/motion/easing-presets.ts +0 -262
  234. package/src/motion/index.tsx +0 -894
  235. package/src/motion/physics.ts +0 -259
  236. package/src/motion/timeline-math.ts +0 -358
  237. package/src/motion.tsx +0 -639
  238. package/src/pixelfx-boundary.ts +0 -188
  239. package/src/pixelfx-registry.ts +0 -1190
  240. package/src/pixelfx-types.d.ts +0 -73
  241. package/src/pixelfx.tsx +0 -1022
  242. package/src/provider.tsx +0 -63
  243. package/src/skin-catalog.ts +0 -306
  244. package/src/skin-tokens.ts +0 -425
  245. package/src/ssr/init-script.ts +0 -281
  246. package/src/ssr/resolve-skin.ts +0 -217
  247. package/src/ssr/theme-mismatch-dev.ts +0 -181
  248. package/src/templates/battle-arena.tsx +0 -688
  249. package/src/templates/index.tsx +0 -314
  250. package/src/templates.tsx +0 -225
  251. package/src/themes/dna-presets.ts +0 -119
  252. package/src/themes/index.ts +0 -56
  253. package/src/themes/provider.tsx +0 -183
  254. package/src/themes/types.ts +0 -111
  255. package/src/themes.ts +0 -9
  256. package/src/token-exporter.ts +0 -12
  257. package/src/token-exporters.ts +0 -343
  258. package/src/token-seeds.ts +0 -335
  259. package/src/token-snapshot.ts +0 -179
  260. package/src/utils.ts +0 -58
@@ -1,343 +0,0 @@
1
- import {
2
- BUILTIN_SKINS,
3
- CORE_DESIGN_TOKENS,
4
- DEFAULT_SKIN_ID,
5
- TOKEN_BY_VAR,
6
- resolveW3cType,
7
- type BuiltinSkinId,
8
- type DesignTokenBundle,
9
- type DesignTokenEntry,
10
- type SkinModeTokens,
11
- type TokenParityReport,
12
- type W3cDesignTokenNode,
13
- } from "./token-seeds.js";
14
- import { BUILTIN_SKIN_TOKENS } from "./skin-tokens.js";
15
-
16
- export { BUILTIN_SKIN_TOKENS } from "./skin-tokens.js";
17
- export {
18
- BUILTIN_SKINS,
19
- DEFAULT_SKIN_ID,
20
- } from "./token-seeds.js";
21
- export type {
22
- BuiltinSkinId,
23
- DesignTokenBundle,
24
- DesignTokenCategory,
25
- DesignTokenEntry,
26
- SkinMetadata,
27
- SkinModeTokens,
28
- TokenParityReport,
29
- W3cDesignTokenNode,
30
- } from "./token-seeds.js";
31
-
32
- function freezeSkinMode(
33
- light: Record<`--mw-${string}`, string>,
34
- dark: Record<`--mw-${string}`, string>,
35
- ): SkinModeTokens {
36
- return Object.freeze({
37
- light: Object.freeze(light),
38
- dark: Object.freeze(dark),
39
- });
40
- }
41
-
42
- interface CssRuleBlock {
43
- readonly selectors: readonly string[];
44
- readonly body: string;
45
- }
46
-
47
- function splitTopLevelSelectors(prelude: string): readonly string[] {
48
- return prelude
49
- .split(",")
50
- .map((part) => part.replace(/\s+/g, " ").trim())
51
- .filter((part) => part.length > 0 && !part.startsWith("@"));
52
- }
53
- function extractCssRuleBlocks(cssSourceInput: string): readonly CssRuleBlock[] {
54
- const cssSource = cssSourceInput.replace(/\/\*[\s\S]*?\*\//gu, "");
55
- const blocks: CssRuleBlock[] = [];
56
- let index = 0;
57
- let depth = 0;
58
- let prelude = "";
59
- let bodyStart = -1;
60
- let inSingleQuote = false;
61
- let inDoubleQuote = false;
62
- let skipAtRuleBlock = false;
63
-
64
- while (index < cssSource.length) {
65
- const ch = cssSource[index];
66
- const next = cssSource[index + 1];
67
-
68
- if (!inDoubleQuote && ch === "'" && cssSource[index - 1] !== "\\") {
69
- inSingleQuote = !inSingleQuote;
70
- if (depth === 0) prelude += ch;
71
- index += 1;
72
- continue;
73
- }
74
-
75
- if (!inSingleQuote && ch === '"' && cssSource[index - 1] !== "\\") {
76
- inDoubleQuote = !inDoubleQuote;
77
- if (depth === 0) prelude += ch;
78
- index += 1;
79
- continue;
80
- }
81
-
82
- if (!inSingleQuote && !inDoubleQuote) {
83
- if (ch === "{") {
84
- if (depth === 0) {
85
- skipAtRuleBlock = prelude.replace(/\s+/g, " ").trim().startsWith("@");
86
- bodyStart = index + 1;
87
- }
88
- depth += 1;
89
- index += 1;
90
- continue;
91
- }
92
-
93
- if (ch === "}") {
94
- depth -= 1;
95
- if (depth === 0 && bodyStart >= 0) {
96
- if (!skipAtRuleBlock) {
97
- blocks.push({
98
- selectors: splitTopLevelSelectors(prelude),
99
- body: cssSource.slice(bodyStart, index),
100
- });
101
- }
102
- prelude = "";
103
- skipAtRuleBlock = false;
104
- bodyStart = -1;
105
- } else if (depth < 0) {
106
- depth = 0;
107
- }
108
- index += 1;
109
- continue;
110
- }
111
-
112
- if (depth === 0 && ch === ";") {
113
- prelude = "";
114
- index += 1;
115
- continue;
116
- }
117
- }
118
-
119
- if (depth === 0) {
120
- prelude += ch;
121
- }
122
- index += 1;
123
- }
124
-
125
- return blocks;
126
- }
127
-
128
- function normalizeCssValue(raw: string): string {
129
- return raw
130
- .replace(/\s+/g, " ")
131
- .trim()
132
- .replace(/^polygon\(\s+/, "polygon(")
133
- .replace(/\s+\)$/, ")");
134
- }
135
-
136
- /** Extract `--mw-*` custom property declarations from all matching top-level CSS rule blocks. */
137
- export function parseTokensFromCss(
138
- sanitizedSource: string,
139
- selector = ":root",
140
- ): Record<string, string> {
141
- const normalizedTarget = selector.replace(/\s+/g, " ").trim();
142
- const result: Record<string, string> = {};
143
-
144
- for (const block of extractCssRuleBlocks(sanitizedSource)) {
145
- if (!block.selectors.includes(normalizedTarget)) continue;
146
- for (const match of block.body.matchAll(/(--mw-[\w-]+)\s*:\s*([^;]+);/gu)) {
147
- const varName = match[1]?.trim();
148
- const varValue = match[2] ? normalizeCssValue(match[2]) : "";
149
- if (varName && varValue) {
150
- result[varName] = varValue;
151
- }
152
- }
153
- }
154
-
155
- return result;
156
- }
157
-
158
- /** Export the complete MoonWitness design token bundle covering all 8 built-in skins. */
159
- export function exportDesignTokenBundle(
160
- tokens: readonly DesignTokenEntry[] = CORE_DESIGN_TOKENS,
161
- ): DesignTokenBundle {
162
- return {
163
- schemaVersion: "moonwitness-design-tokens/v1",
164
- defaultSkinId: DEFAULT_SKIN_ID,
165
- skins: BUILTIN_SKINS,
166
- tokens,
167
- skinTokens: BUILTIN_SKIN_TOKENS,
168
- };
169
- }
170
-
171
- /** Export tokens grouped by category in W3C DTCG format (`$value`, `$type`, `$description`). */
172
- export function exportTokensToW3cJson(
173
- tokens: readonly DesignTokenEntry[] = CORE_DESIGN_TOKENS,
174
- ): Record<string, Record<string, W3cDesignTokenNode>> {
175
- const grouped: Record<string, Record<string, W3cDesignTokenNode>> = {};
176
- for (const entry of tokens) {
177
- const group = grouped[entry.category] ?? {};
178
- grouped[entry.category] = group;
179
- group[entry.name] = {
180
- $value: entry.value,
181
- $type: resolveW3cType(entry),
182
- ...(entry.darkValue ? { $description: `dark: ${entry.darkValue}` } : {}),
183
- };
184
- }
185
- return grouped;
186
- }
187
-
188
- /** Export per-skin overrides for all 8 built-in skins in W3C DTCG format. */
189
- export function exportSkinTokensToW3cJson(): Record<
190
- BuiltinSkinId,
191
- Record<string, W3cDesignTokenNode>
192
- > {
193
- const out = {} as Record<BuiltinSkinId, Record<string, W3cDesignTokenNode>>;
194
-
195
- for (const skin of BUILTIN_SKINS) {
196
- const id = skin.id as BuiltinSkinId;
197
- const overrides = BUILTIN_SKIN_TOKENS[id];
198
- const group: Record<string, W3cDesignTokenNode> = {
199
- "swatch-background": { $value: skin.swatch.background, $type: "color" },
200
- "swatch-surface": { $value: skin.swatch.surface, $type: "color" },
201
- "swatch-foreground": { $value: skin.swatch.foreground, $type: "color" },
202
- "swatch-accent": { $value: skin.swatch.accent, $type: "color" },
203
- };
204
-
205
- const overrideVars = new Set<`--mw-${string}`>([
206
- ...(Object.keys(overrides.light) as `--mw-${string}`[]),
207
- ...(Object.keys(overrides.dark) as `--mw-${string}`[]),
208
- ]);
209
-
210
- for (const cssVar of overrideVars) {
211
- const baseToken = TOKEN_BY_VAR.get(cssVar);
212
- const name = baseToken?.name ?? cssVar.slice(5);
213
- const lightValue = overrides.light[cssVar] ?? baseToken?.value;
214
- const darkValue = overrides.dark[cssVar];
215
- if (!lightValue) continue;
216
- group[name] = {
217
- $value: lightValue,
218
- $type: resolveW3cType({
219
- name,
220
- value: lightValue,
221
- category: baseToken?.category ?? "color",
222
- }),
223
- ...(darkValue ? { $description: `dark: ${darkValue}` } : {}),
224
- };
225
- }
226
-
227
- out[id] = group;
228
- }
229
-
230
- return out;
231
- }
232
-
233
- /** Emit deterministic `:root` and `.dark` CSS custom property declarations. */
234
- export function exportTokensToCssVariables(
235
- tokens: readonly DesignTokenEntry[] = CORE_DESIGN_TOKENS,
236
- ): string {
237
- const lightLines: string[] = [":root {"];
238
- const darkLines: string[] = [".dark {"];
239
- for (const entry of tokens) {
240
- lightLines.push(` ${entry.cssVariable}: ${entry.value};`);
241
- if (entry.darkValue) {
242
- darkLines.push(` ${entry.cssVariable}: ${entry.darkValue};`);
243
- }
244
- }
245
- lightLines.push("}");
246
- darkLines.push("}");
247
- return `${lightLines.join("\n")}\n\n${darkLines.join("\n")}\n`;
248
- }
249
-
250
- /** Emit `[data-skin]` and `[data-skin].dark` CSS override blocks for all built-in skins. */
251
- export function exportSkinsToCssVariables(): string {
252
- const blocks: string[] = [];
253
- for (const skin of BUILTIN_SKINS) {
254
- const id = skin.id as BuiltinSkinId;
255
- if (id === DEFAULT_SKIN_ID) continue;
256
- const { light, dark } = BUILTIN_SKIN_TOKENS[id];
257
- const lightEntries = Object.entries(light);
258
- if (lightEntries.length > 0) {
259
- blocks.push(
260
- `[data-skin='${id}'] {\n${lightEntries.map(([k, v]) => ` ${k}: ${v};`).join("\n")}\n}`,
261
- );
262
- }
263
- const darkEntries = Object.entries(dark);
264
- if (darkEntries.length > 0) {
265
- blocks.push(
266
- `[data-skin='${id}'].dark {\n${darkEntries.map(([k, v]) => ` ${k}: ${v};`).join("\n")}\n}`,
267
- );
268
- }
269
- }
270
- return `${blocks.join("\n\n")}\n`;
271
- }
272
-
273
- /** Emit Tailwind theme extension maps referencing `--mw-*` custom properties. */
274
- export function exportTailwindThemeExtend(
275
- tokens: readonly DesignTokenEntry[] = CORE_DESIGN_TOKENS,
276
- ): {
277
- colors: Record<string, string>;
278
- spacing: Record<string, string>;
279
- borderRadius: Record<string, string>;
280
- } {
281
- const colors: Record<string, string> = {};
282
- const spacing: Record<string, string> = {};
283
- const borderRadius: Record<string, string> = {};
284
-
285
- for (const entry of tokens) {
286
- const varRef = `var(${entry.cssVariable})`;
287
- if (entry.category === "color") {
288
- colors[`mw-${entry.name}`] = varRef;
289
- } else if (entry.category === "spacing") {
290
- spacing[`mw-${entry.name}`] = varRef;
291
- } else if (entry.category === "radius") {
292
- borderRadius[`mw-${entry.name}`] = varRef;
293
- }
294
- }
295
-
296
- return { colors, spacing, borderRadius };
297
- }
298
-
299
- const EXTERNAL_FONT_CDN_PATTERN =
300
- /https?:\/\/(?:fonts\.googleapis\.com|fonts\.gstatic\.com|use\.typekit\.net|cdn\.jsdelivr\.net\/.*font)/iu;
301
-
302
- /** Return true if a stylesheet references an external font CDN URL. */
303
- export function hasExternalCdnFontImport(sanitizedSource: string): boolean {
304
- return EXTERNAL_FONT_CDN_PATTERN.test(sanitizedSource);
305
- }
306
-
307
- /** Return a `var(--mw-...)` CSS custom property reference for a token name. */
308
- export function getCssVariableRef(tokenName: string): string {
309
- return tokenName.startsWith("--mw-")
310
- ? `var(${tokenName})`
311
- : `var(--mw-${tokenName})`;
312
- }
313
-
314
- /** Verify `:root` and `.dark` token parity and absence of external CDN font imports. */
315
- export function verifyTokenParity(
316
- sanitizedSource: string,
317
- tokens: readonly DesignTokenEntry[] = CORE_DESIGN_TOKENS,
318
- ): TokenParityReport {
319
- const lightVars = parseTokensFromCss(sanitizedSource, ":root");
320
- const darkVars = parseTokensFromCss(sanitizedSource, ".dark");
321
- const missingLightVariables: string[] = [];
322
- const missingDarkVariables: string[] = [];
323
-
324
- for (const entry of tokens) {
325
- if (lightVars[entry.cssVariable] !== entry.value) {
326
- missingLightVariables.push(entry.cssVariable);
327
- }
328
- if (entry.darkValue && darkVars[entry.cssVariable] !== entry.darkValue) {
329
- missingDarkVariables.push(entry.cssVariable);
330
- }
331
- }
332
-
333
- const hasExternalCdnFonts = hasExternalCdnFontImport(sanitizedSource);
334
- return {
335
- valid:
336
- missingLightVariables.length === 0 &&
337
- missingDarkVariables.length === 0 &&
338
- !hasExternalCdnFonts,
339
- missingLightVariables,
340
- missingDarkVariables,
341
- hasExternalCdnFonts,
342
- };
343
- }
@@ -1,335 +0,0 @@
1
- import { BUILTIN_SKINS, DEFAULT_SKIN_ID } from "./skin-catalog.js";
2
- import type { BuiltinSkinId, SkinMetadata } from "./themes/types.js";
3
-
4
- export type DesignTokenCategory =
5
- | "color"
6
- | "typography"
7
- | "spacing"
8
- | "radius"
9
- | "shadow"
10
- | "motion"
11
- | "layer"
12
- | "effect";
13
-
14
- export interface DesignTokenEntry {
15
- readonly name: string;
16
- readonly cssVariable: `--mw-${string}`;
17
- readonly value: string;
18
- readonly darkValue?: string;
19
- readonly category: DesignTokenCategory;
20
- }
21
-
22
- export interface W3cDesignTokenNode {
23
- readonly $value: string;
24
- readonly $type: string;
25
- readonly $description?: string;
26
- }
27
-
28
- export interface SkinModeTokens {
29
- readonly light: Readonly<Record<`--mw-${string}`, string>>;
30
- readonly dark: Readonly<Record<`--mw-${string}`, string>>;
31
- }
32
-
33
- export interface DesignTokenBundle {
34
- readonly schemaVersion: "moonwitness-design-tokens/v1";
35
- readonly defaultSkinId: BuiltinSkinId;
36
- readonly skins: readonly SkinMetadata[];
37
- readonly tokens: readonly DesignTokenEntry[];
38
- readonly skinTokens?: Readonly<Record<BuiltinSkinId, SkinModeTokens>>;
39
- }
40
-
41
- export interface TokenParityReport {
42
- readonly valid: boolean;
43
- readonly missingLightVariables: readonly string[];
44
- readonly missingDarkVariables: readonly string[];
45
- readonly hasExternalCdnFonts: boolean;
46
- }
47
-
48
- type TokenSeed = readonly [
49
- name: string,
50
- value: string,
51
- category: DesignTokenCategory,
52
- darkValue?: string,
53
- ];
54
-
55
- const CORE_TOKEN_SEEDS: readonly TokenSeed[] = [
56
- ["paper-cream", "#f3efe4", "color"],
57
- ["ink-black", "#0d0d0d", "color"],
58
- ["ink-panel", "#17171a", "color"],
59
- ["paper", "#f3efe4", "color", "#0e0e10"],
60
- ["paper-raised", "#fffdf6", "color", "#17171a"],
61
- ["ink", "#0d0d0d", "color", "#f3efe4"],
62
- ["ink-soft", "#3a3a36", "color", "#c9c5b8"],
63
- ["ink-faint", "#59574e", "color", "#9b988f"],
64
- ["color-ink-muted", "#59574e", "color", "#9b988f"],
65
- ["signal-blue", "#00b8f0", "color"],
66
- ["cyan", "#00b8f0", "color"],
67
- ["night", "#0d0d0d", "color"],
68
- ["night-soft", "#121216", "color"],
69
- ["night-raised", "#17171a", "color"],
70
- ["night-blue", "#092c49", "color"],
71
- ["night-magenta", "#421027", "color"],
72
- [
73
- "night-outline",
74
- "color-mix(in srgb, var(--mw-paper-cream) 22%, transparent)",
75
- "color",
76
- ],
77
- ["paper-highlight", "#e3dfd4", "color"],
78
- ["paper-muted", "#cbc7bd", "color"],
79
- ["moon", "#b6cad7", "color"],
80
- ["yellow", "#ffe031", "color"],
81
- ["magenta", "#ff2e88", "color"],
82
- ["violet", "#c084fc", "color"],
83
- ["yellow-readable", "#705900", "color", "#ffe031"],
84
- ["magenta-readable", "#b20f55", "color", "#ff2e88"],
85
- ["cyan-readable", "#00749a", "color", "#00b8f0"],
86
- ["violet-readable", "#6d28d9", "color", "#c084fc"],
87
- ["on-accent", "#0d0d0d", "color"],
88
- ["on-magenta", "#0d0d0d", "color"],
89
- ["on-violet", "#0d0d0d", "color"],
90
- ["halftone-dot", "color-mix(in srgb, #0d0d0d 13%, transparent)", "color", "color-mix(in srgb, #f3efe4 9%, transparent)"],
91
- ["highlight", "#ffffff", "color"],
92
- ["background", "#f3efe4", "color", "#0e0e10"],
93
- ["foreground", "#0d0d0d", "color", "#f3efe4"],
94
- ["surface", "#fffdf6", "color", "#17171a"],
95
- ["surface-foreground", "#0d0d0d", "color", "#f3efe4"],
96
- ["popover", "#fffdf6", "color", "#17171a"],
97
- ["popover-foreground", "#0d0d0d", "color", "#f3efe4"],
98
- ["primary", "#ffe031", "color", "#ffe031"],
99
- ["primary-foreground", "#0d0d0d", "color"],
100
- ["secondary", "#f3efe4", "color", "#0e0e10"],
101
- ["secondary-foreground", "#0d0d0d", "color", "#f3efe4"],
102
- ["muted", "#e7e2d4", "color", "#232327"],
103
- ["muted-foreground", "#3a3a36", "color", "#c9c5b8"],
104
- ["accent", "#ffe031", "color"],
105
- ["accent-foreground", "#0d0d0d", "color"],
106
- ["interactive-accent", "var(--mw-magenta)", "color"],
107
- ["error", "#b42318", "color", "#fda29b"],
108
- ["on-error", "#fffdf6", "color", "#0d0d0d"],
109
- ["destructive", "#b42318", "color", "#fda29b"],
110
- ["destructive-foreground", "#fffdf6", "color", "#0d0d0d"],
111
- ["border", "#0d0d0d", "color", "#f3efe4"],
112
- ["border-strong", "#0d0d0d", "color", "#f3efe4"],
113
- [
114
- "border-subtle",
115
- "color-mix(in srgb, var(--mw-ink) 35%, var(--mw-paper))",
116
- "color",
117
- ],
118
- ["input", "#0d0d0d", "color", "#f3efe4"],
119
- ["focus", "#0d0d0d", "color", "#f3efe4"],
120
- ["backdrop", "color-mix(in srgb, #0d0d0d 50%, transparent)", "color"],
121
- ["success", "#166534", "color"],
122
- ["on-success", "#fffdf6", "color"],
123
- ["warning", "#facc15", "color"],
124
- ["on-warning", "#0d0d0d", "color"],
125
- ["warning-readable", "#705900", "color", "#facc15"],
126
- ["success-readable", "#166534", "color", "#86efac"],
127
- ["info", "#175cd3", "color"],
128
- ["on-info", "#fffdf6", "color"],
129
- ["chart-1", "#476a2a", "color"],
130
- ["chart-2", "#ff2e88", "color"],
131
- ["chart-3", "#176b87", "color"],
132
- ["chart-4", "#936a22", "color"],
133
- ["chart-5", "#76519b", "color"],
134
- ["brand-crimson", "#D1132A", "color"],
135
- ["signal-crimson", "#9F1022", "color"],
136
- [
137
- "font-display",
138
- "'Anton', 'MoonWitness Grunge', Impact, 'Arial Narrow', sans-serif",
139
- "typography",
140
- ],
141
- [
142
- "font-grunge",
143
- "'MoonWitness Grunge', 'Road Rage', Impact, 'Arial Narrow', sans-serif",
144
- "typography",
145
- ],
146
- [
147
- "font-condensed",
148
- "'MoonWitness Grunge', 'Road Rage', Impact, 'Arial Narrow', sans-serif",
149
- "typography",
150
- ],
151
- [
152
- "font-brush",
153
- "'Road Rage', 'MoonWitness Grunge', Impact, 'Arial Narrow', sans-serif",
154
- "typography",
155
- ],
156
- [
157
- "font-sans",
158
- "'Space Grotesk', ui-sans-serif, system-ui, sans-serif",
159
- "typography",
160
- ],
161
- [
162
- "font-mono",
163
- "'JetBrains Mono', ui-monospace, SFMono-Regular, monospace",
164
- "typography",
165
- ],
166
- ["font-size-2xs", "0.75rem", "typography"],
167
- ["font-size-xs", "0.75rem", "typography"],
168
- ["font-size-sm", "0.875rem", "typography"],
169
- ["font-size-md", "1rem", "typography"],
170
- ["font-size-lg", "1.125rem", "typography"],
171
- ["font-size-xl", "1.25rem", "typography"],
172
- ["font-size-2xl", "1.5rem", "typography"],
173
- ["line-height-tight", "1.2", "typography"],
174
- ["line-height-normal", "1.5", "typography"],
175
- ["avatar-size", "2.5rem", "spacing"],
176
- ["space-1", "0.25rem", "spacing"],
177
- ["space-2", "0.5rem", "spacing"],
178
- ["space-3", "0.75rem", "spacing"],
179
- ["space-4", "1rem", "spacing"],
180
- ["space-6", "1.5rem", "spacing"],
181
- ["space-8", "2rem", "spacing"],
182
- ["panel-gap-compact", "0.375rem", "spacing"],
183
- ["panel-gap-comfortable", "0.75rem", "spacing"],
184
- ["panel-padding-compact", "0.625rem", "spacing"],
185
- ["panel-padding-comfortable", "1rem", "spacing"],
186
- ["frame-width", "2px", "spacing"],
187
- ["torn-safe-inset", "0.75rem", "spacing"],
188
- ["decorative-rotation", "1.5deg", "effect"],
189
- ["radius-xs", "2px", "radius"],
190
- ["radius-sm", "0.125rem", "radius"],
191
- ["radius-md", "0.25rem", "radius"],
192
- ["radius-lg", "0.5rem", "radius"],
193
- ["radius-full", "9999px", "radius"],
194
- ["shadow-ink", "3px 3px 0 0 var(--mw-ink)", "shadow"],
195
- ["shadow-ink-lg", "6px 6px 0 0 var(--mw-ink)", "shadow"],
196
- ["shadow-accent-cyan", "4px 4px 0 var(--mw-cyan)", "shadow"],
197
- ["shadow-accent-magenta", "4px 4px 0 var(--mw-magenta)", "shadow"],
198
- ["comic-border-width", "2px", "spacing"],
199
- ["comic-gutter", "0.75rem", "spacing"],
200
- ["shadow-comic", "4px 4px 0 0 var(--mw-ink)", "shadow"],
201
- ["dna-skew", "-8deg", "effect"],
202
- ["dna-halftone-size", "7px", "effect"],
203
- ["dna-halftone-opacity", "0.16", "effect"],
204
- ["dna-cel-highlight", "color-mix(in srgb, #ffffff 38%, transparent)", "color"],
205
- ["dna-border-heavy", "3px", "spacing"],
206
- ["dna-speedline-opacity", "0.22", "effect"],
207
- ["dna-chromatic-x", "3px", "effect"],
208
- ["anime-skin", "#fad7bf", "color"],
209
- ["anime-skin-shade", "#deb094", "color"],
210
- ["anime-skin-highlight", "#fff0e5", "color"],
211
- ["motion-pop", "180ms", "motion"],
212
- ["motion-fast", "120ms", "motion"],
213
- ["motion-normal", "160ms", "motion"],
214
- ["motion-slow", "220ms", "motion"],
215
- ["motion-delay", "200ms", "motion"],
216
- ["motion-draw", "700ms", "motion"],
217
- ["motion-effect", "1200ms", "motion"],
218
- ["motion-pulse", "1600ms", "motion"],
219
- ["motion-progress", "1400ms", "motion"],
220
- ["motion-spin", "800ms", "motion"],
221
- ["motion-anime-snap", "180ms", "motion"],
222
- ["motion-anime-slash", "360ms", "motion"],
223
- ["motion-anime-burst", "480ms", "motion"],
224
- ["motion-grunge-jitter", "900ms", "motion"],
225
- [
226
- "shadow-anime-impact",
227
- "4px 4px 0 0 var(--mw-ink), 7px 7px 0 0 var(--mw-magenta)",
228
- "shadow",
229
- ],
230
- ["grunge-grain-opacity", "0.14", "effect"],
231
- [
232
- "grunge-clip-rough",
233
- "polygon(0.5% 1.8%, 9% 0%, 21% 1.6%, 35% 0.2%, 49% 1.5%, 64% 0%, 79% 1.4%, 92% 0.2%, 99.6% 1.2%, 100% 19%, 98.8% 38%, 100% 59%, 99% 81%, 99.7% 99%, 84% 100%, 67% 98.6%, 48% 100%, 31% 98.8%, 14% 100%, 0.4% 98.7%, 1% 77%, 0% 54%, 1.1% 29%)",
234
- "effect",
235
- ],
236
- [
237
- "grunge-clip-jagged",
238
- "polygon(0% 8%, 7% 0%, 16% 6%, 28% 0%, 42% 5%, 56% 0%, 71% 6%, 85% 0%, 96% 4%, 100% 14%, 98% 35%, 100% 58%, 97% 84%, 100% 96%, 89% 100%, 74% 95%, 58% 100%, 41% 96%, 23% 100%, 8% 95%, 0% 99%, 2% 72%, 0% 45%)",
239
- "effect",
240
- ],
241
- [
242
- "grunge-clip-tape",
243
- "polygon(1.2% 6%, 14% 0%, 31% 4%, 52% 0%, 73% 5%, 90% 0%, 99.2% 7%, 98.4% 48%, 100% 92%, 86% 100%, 66% 95%, 44% 100%, 22% 96%, 0.8% 99%, 1.6% 54%)",
244
- "effect",
245
- ],
246
- [
247
- "grunge-clip-torn-card",
248
- "polygon(0.8% 1.4%, 11% 0%, 24% 1.1%, 39% 0%, 56% 1.2%, 72% 0%, 87% 1%, 99.3% 0.4%, 100% 17%, 99.1% 39%, 100% 62%, 99.2% 83%, 99.6% 99%, 85% 100%, 68% 98.8%, 49% 100%, 29% 98.9%, 12% 100%, 0.5% 98.8%, 1% 76%, 0% 51%, 0.9% 25%)",
249
- "effect",
250
- ],
251
- [
252
- "grunge-clip-brush-btn",
253
- "polygon(0.4% 14%, 9% 2%, 22% 10%, 37% 0%, 54% 8%, 71% 1%, 87% 7%, 100% 0%, 96% 32%, 100% 60%, 94% 96%, 76% 89%, 57% 100%, 35% 91%, 15% 100%, 0% 95%, 4% 62%, 0% 36%)",
254
- "effect",
255
- ],
256
- [
257
- "chalk-mask",
258
- "url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 100' preserveAspectRatio='none'%3E%3Cpath d='M0.5 0.5L28 0.2 58 0.8 92 0.2 128 0.8 166 0.2 199.5 0.5 199.2 26 199.8 54 199.2 80 199.5 99.5 164 99.2 126 99.8 88 99.2 48 99.8 14 99.2 0.5 99.5 0.8 70 0.2 40 0.8 14Z' fill='none' stroke='%23000' stroke-width='2.2' vector-effect='non-scaling-stroke' stroke-dasharray='26 3 10 2 34 4'/%3E%3Cpath d='M2 1.2L52 0.8M78 0.8L128 1.2M154 0.8L196 1.2M4 98.8L62 99.2M100 98.8L148 99.2M172 99.2L198 98.6M1.2 22L0.8 56M198.8 28L199.2 66' fill='none' stroke='%23000' stroke-width='2.2' vector-effect='non-scaling-stroke' stroke-dasharray='9 4 4 5'/%3E%3C/svg%3E\")",
259
- "effect",
260
- ],
261
- [
262
- "grunge-clip-notched",
263
- "polygon(0.6% 0%, 99.4% 0%, 100% 4%, 99.6% 96%, 99% 100%, 0.8% 100%, 0% 95%, 0.4% 5%)",
264
- "effect",
265
- ],
266
- ["grunge-radius-hand", "3px 1px 4px 1px / 1px 4px 2px 3px", "radius"],
267
- ["surface-muted", "#e7e2d4", "color", "#232327"],
268
- ["surface-elevated", "#fffdf6", "color", "#17171a"],
269
- ["error-readable", "#b42318", "color", "#fda29b"],
270
- ["font-size-base", "1rem", "typography"],
271
- ["space-5", "1.25rem", "spacing"],
272
- ["shadow-ink-sm", "2px 2px 0 0 var(--mw-ink)", "shadow", "2px 2px 0 0 var(--mw-ink)"],
273
- ["motion-ease-standard", "cubic-bezier(0.2, 0.8, 0.2, 1)", "motion"],
274
- ["anime-ink", "#111116", "color"],
275
- ["anime-face", "#f8ece0", "color"],
276
- ["anime-highlight", "#ffffff", "color"],
277
- ["fx-flash", "color-mix(in srgb, #ffffff 35%, transparent)", "color"],
278
- ["fx-chromatic-pulse", "linear-gradient( 90deg, color-mix(in srgb, #ff2e88 22%, transparent), transparent 45%, color-mix(in srgb, #00d4ff 22%, transparent))", "effect"],
279
- ["fx-speedlines-burst", "radial-gradient( circle, transparent 42%, color-mix(in srgb, #ff2e88 28%, transparent) 100%)", "effect"],
280
- ["fx-vignette", "radial-gradient( circle, transparent 50%, color-mix(in srgb, #0a0a10 45%, transparent) 100%)", "effect"],
281
- ["motion-ease", "cubic-bezier(0.2, 0.8, 0.2, 1)", "motion"],
282
- ["motion-ease-emphasis", "cubic-bezier(0.34, 1.56, 0.64, 1)", "motion"],
283
- ["layer-base", "0", "layer"],
284
- ["layer-raised", "10", "layer"],
285
- ["layer-sticky", "20", "layer"],
286
- ["layer-overlay", "40", "layer"],
287
- ["layer-dialog", "50", "layer"],
288
- ["layer-popover", "55", "layer"],
289
- ["layer-toast", "60", "layer"],
290
- ["motion-scale", "1", "motion"],
291
- ];
292
-
293
- /** Canonical MoonWitness design tokens aligned with `tokens.css` plus ROCKSOUL crimson accents. */
294
- export const CORE_DESIGN_TOKENS: readonly DesignTokenEntry[] = Object.freeze(
295
- CORE_TOKEN_SEEDS.map(([name, value, category, darkValue]) =>
296
- Object.freeze({
297
- name,
298
- cssVariable: `--mw-${name}` as const,
299
- value,
300
- ...(darkValue !== undefined ? { darkValue } : {}),
301
- category,
302
- }),
303
- ),
304
- );
305
-
306
- export { BUILTIN_SKINS, DEFAULT_SKIN_ID };
307
- export type { BuiltinSkinId, SkinMetadata } from "./themes/types.js";
308
-
309
- export function resolveW3cType(
310
- entry: Pick<DesignTokenEntry, "name" | "value" | "category">,
311
- ): string {
312
- switch (entry.category) {
313
- case "color":
314
- return "color";
315
- case "spacing":
316
- return "dimension";
317
- case "radius":
318
- return entry.name === "grunge-radius-hand" ? "string" : "dimension";
319
- case "motion":
320
- if (entry.value.endsWith("ms") || entry.value.endsWith("s"))
321
- return "duration";
322
- if (entry.value.startsWith("cubic-bezier(")) return "cubicBezier";
323
- return "number";
324
- case "typography":
325
- if (entry.name.startsWith("font-size-")) return "dimension";
326
- if (entry.name.startsWith("line-height-")) return "number";
327
- return "fontFamily";
328
- default:
329
- return "string";
330
- }
331
- }
332
-
333
- export const TOKEN_BY_VAR: ReadonlyMap<string, DesignTokenEntry> = new Map(
334
- CORE_DESIGN_TOKENS.map((entry) => [entry.cssVariable, entry]),
335
- );