@lushly-dev/violet-afd 0.0.0-stage → 0.3.0-preview.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 (335) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +29 -2
  3. package/dist/commands/analyze/compare.d.ts +34 -0
  4. package/dist/commands/analyze/compare.d.ts.map +1 -0
  5. package/dist/commands/analyze/compare.js +180 -0
  6. package/dist/commands/analyze/compare.js.map +1 -0
  7. package/dist/commands/analyze/compliance.d.ts +41 -0
  8. package/dist/commands/analyze/compliance.d.ts.map +1 -0
  9. package/dist/commands/analyze/compliance.js +166 -0
  10. package/dist/commands/analyze/compliance.js.map +1 -0
  11. package/dist/commands/analyze/deviations.d.ts +30 -0
  12. package/dist/commands/analyze/deviations.d.ts.map +1 -0
  13. package/dist/commands/analyze/deviations.js +201 -0
  14. package/dist/commands/analyze/deviations.js.map +1 -0
  15. package/dist/commands/analyze/health.d.ts +211 -0
  16. package/dist/commands/analyze/health.d.ts.map +1 -0
  17. package/dist/commands/analyze/health.js +697 -0
  18. package/dist/commands/analyze/health.js.map +1 -0
  19. package/dist/commands/analyze/index.d.ts +15 -0
  20. package/dist/commands/analyze/index.d.ts.map +1 -0
  21. package/dist/commands/analyze/index.js +31 -0
  22. package/dist/commands/analyze/index.js.map +1 -0
  23. package/dist/commands/analyze/snapshot.d.ts +64 -0
  24. package/dist/commands/analyze/snapshot.d.ts.map +1 -0
  25. package/dist/commands/analyze/snapshot.js +126 -0
  26. package/dist/commands/analyze/snapshot.js.map +1 -0
  27. package/dist/commands/analyze/trends.d.ts +82 -0
  28. package/dist/commands/analyze/trends.d.ts.map +1 -0
  29. package/dist/commands/analyze/trends.js +312 -0
  30. package/dist/commands/analyze/trends.js.map +1 -0
  31. package/dist/commands/analyze/violations.d.ts +84 -0
  32. package/dist/commands/analyze/violations.d.ts.map +1 -0
  33. package/dist/commands/analyze/violations.js +158 -0
  34. package/dist/commands/analyze/violations.js.map +1 -0
  35. package/dist/commands/apikeys/check.d.ts +39 -0
  36. package/dist/commands/apikeys/check.d.ts.map +1 -0
  37. package/dist/commands/apikeys/check.js +61 -0
  38. package/dist/commands/apikeys/check.js.map +1 -0
  39. package/dist/commands/apikeys/create.d.ts +36 -0
  40. package/dist/commands/apikeys/create.d.ts.map +1 -0
  41. package/dist/commands/apikeys/create.js +116 -0
  42. package/dist/commands/apikeys/create.js.map +1 -0
  43. package/dist/commands/apikeys/index.d.ts +15 -0
  44. package/dist/commands/apikeys/index.d.ts.map +1 -0
  45. package/dist/commands/apikeys/index.js +21 -0
  46. package/dist/commands/apikeys/index.js.map +1 -0
  47. package/dist/commands/apikeys/keys.d.ts +79 -0
  48. package/dist/commands/apikeys/keys.d.ts.map +1 -0
  49. package/dist/commands/apikeys/keys.js +239 -0
  50. package/dist/commands/apikeys/keys.js.map +1 -0
  51. package/dist/commands/audit/index.d.ts +11 -0
  52. package/dist/commands/audit/index.d.ts.map +1 -0
  53. package/dist/commands/audit/index.js +15 -0
  54. package/dist/commands/audit/index.js.map +1 -0
  55. package/dist/commands/audit/list.d.ts +101 -0
  56. package/dist/commands/audit/list.d.ts.map +1 -0
  57. package/dist/commands/audit/list.js +230 -0
  58. package/dist/commands/audit/list.js.map +1 -0
  59. package/dist/commands/changes/impact.d.ts +477 -0
  60. package/dist/commands/changes/impact.d.ts.map +1 -0
  61. package/dist/commands/changes/impact.js +541 -0
  62. package/dist/commands/changes/impact.js.map +1 -0
  63. package/dist/commands/changes/index.d.ts +11 -0
  64. package/dist/commands/changes/index.d.ts.map +1 -0
  65. package/dist/commands/changes/index.js +15 -0
  66. package/dist/commands/changes/index.js.map +1 -0
  67. package/dist/commands/constraints/index.d.ts +11 -0
  68. package/dist/commands/constraints/index.d.ts.map +1 -0
  69. package/dist/commands/constraints/index.js +19 -0
  70. package/dist/commands/constraints/index.js.map +1 -0
  71. package/dist/commands/constraints/list.d.ts +52 -0
  72. package/dist/commands/constraints/list.d.ts.map +1 -0
  73. package/dist/commands/constraints/list.js +103 -0
  74. package/dist/commands/constraints/list.js.map +1 -0
  75. package/dist/commands/constraints/set.d.ts +50 -0
  76. package/dist/commands/constraints/set.d.ts.map +1 -0
  77. package/dist/commands/constraints/set.js +137 -0
  78. package/dist/commands/constraints/set.js.map +1 -0
  79. package/dist/commands/constraints/validate.d.ts +38 -0
  80. package/dist/commands/constraints/validate.d.ts.map +1 -0
  81. package/dist/commands/constraints/validate.js +164 -0
  82. package/dist/commands/constraints/validate.js.map +1 -0
  83. package/dist/commands/docs/generator.d.ts +77 -0
  84. package/dist/commands/docs/generator.d.ts.map +1 -0
  85. package/dist/commands/docs/generator.js +256 -0
  86. package/dist/commands/docs/generator.js.map +1 -0
  87. package/dist/commands/docs/index.d.ts +6 -0
  88. package/dist/commands/docs/index.d.ts.map +1 -0
  89. package/dist/commands/docs/index.js +6 -0
  90. package/dist/commands/docs/index.js.map +1 -0
  91. package/dist/commands/export/export.d.ts +64 -0
  92. package/dist/commands/export/export.d.ts.map +1 -0
  93. package/dist/commands/export/export.js +193 -0
  94. package/dist/commands/export/export.js.map +1 -0
  95. package/dist/commands/export/index.d.ts +9 -0
  96. package/dist/commands/export/index.d.ts.map +1 -0
  97. package/dist/commands/export/index.js +13 -0
  98. package/dist/commands/export/index.js.map +1 -0
  99. package/dist/commands/import/flatten.d.ts +30 -0
  100. package/dist/commands/import/flatten.d.ts.map +1 -0
  101. package/dist/commands/import/flatten.js +121 -0
  102. package/dist/commands/import/flatten.js.map +1 -0
  103. package/dist/commands/import/index.d.ts +11 -0
  104. package/dist/commands/import/index.d.ts.map +1 -0
  105. package/dist/commands/import/index.js +19 -0
  106. package/dist/commands/import/index.js.map +1 -0
  107. package/dist/commands/import/json.d.ts +40 -0
  108. package/dist/commands/import/json.d.ts.map +1 -0
  109. package/dist/commands/import/json.js +209 -0
  110. package/dist/commands/import/json.js.map +1 -0
  111. package/dist/commands/import/tree.d.ts +39 -0
  112. package/dist/commands/import/tree.d.ts.map +1 -0
  113. package/dist/commands/import/tree.js +247 -0
  114. package/dist/commands/import/tree.js.map +1 -0
  115. package/dist/commands/import/validate.d.ts +53 -0
  116. package/dist/commands/import/validate.d.ts.map +1 -0
  117. package/dist/commands/import/validate.js +201 -0
  118. package/dist/commands/import/validate.js.map +1 -0
  119. package/dist/commands/index.d.ts +21 -0
  120. package/dist/commands/index.d.ts.map +1 -0
  121. package/dist/commands/index.js +21 -0
  122. package/dist/commands/index.js.map +1 -0
  123. package/dist/commands/json-schema.d.ts +21 -0
  124. package/dist/commands/json-schema.d.ts.map +1 -0
  125. package/dist/commands/json-schema.js +41 -0
  126. package/dist/commands/json-schema.js.map +1 -0
  127. package/dist/commands/node/create.d.ts +80 -0
  128. package/dist/commands/node/create.d.ts.map +1 -0
  129. package/dist/commands/node/create.js +174 -0
  130. package/dist/commands/node/create.js.map +1 -0
  131. package/dist/commands/node/delete.d.ts +28 -0
  132. package/dist/commands/node/delete.d.ts.map +1 -0
  133. package/dist/commands/node/delete.js +134 -0
  134. package/dist/commands/node/delete.js.map +1 -0
  135. package/dist/commands/node/deprecation.d.ts +23 -0
  136. package/dist/commands/node/deprecation.d.ts.map +1 -0
  137. package/dist/commands/node/deprecation.js +59 -0
  138. package/dist/commands/node/deprecation.js.map +1 -0
  139. package/dist/commands/node/get.d.ts +79 -0
  140. package/dist/commands/node/get.d.ts.map +1 -0
  141. package/dist/commands/node/get.js +106 -0
  142. package/dist/commands/node/get.js.map +1 -0
  143. package/dist/commands/node/graph.d.ts +138 -0
  144. package/dist/commands/node/graph.d.ts.map +1 -0
  145. package/dist/commands/node/graph.js +285 -0
  146. package/dist/commands/node/graph.js.map +1 -0
  147. package/dist/commands/node/index.d.ts +17 -0
  148. package/dist/commands/node/index.d.ts.map +1 -0
  149. package/dist/commands/node/index.js +31 -0
  150. package/dist/commands/node/index.js.map +1 -0
  151. package/dist/commands/node/list.d.ts +74 -0
  152. package/dist/commands/node/list.d.ts.map +1 -0
  153. package/dist/commands/node/list.js +130 -0
  154. package/dist/commands/node/list.js.map +1 -0
  155. package/dist/commands/node/operations.d.ts +35 -0
  156. package/dist/commands/node/operations.d.ts.map +1 -0
  157. package/dist/commands/node/operations.js +66 -0
  158. package/dist/commands/node/operations.js.map +1 -0
  159. package/dist/commands/node/scope.d.ts +14 -0
  160. package/dist/commands/node/scope.d.ts.map +1 -0
  161. package/dist/commands/node/scope.js +49 -0
  162. package/dist/commands/node/scope.js.map +1 -0
  163. package/dist/commands/node/update.d.ts +84 -0
  164. package/dist/commands/node/update.d.ts.map +1 -0
  165. package/dist/commands/node/update.js +229 -0
  166. package/dist/commands/node/update.js.map +1 -0
  167. package/dist/commands/registry.d.ts +114 -0
  168. package/dist/commands/registry.d.ts.map +1 -0
  169. package/dist/commands/registry.js +141 -0
  170. package/dist/commands/registry.js.map +1 -0
  171. package/dist/commands/specimen/get.d.ts +46 -0
  172. package/dist/commands/specimen/get.d.ts.map +1 -0
  173. package/dist/commands/specimen/get.js +121 -0
  174. package/dist/commands/specimen/get.js.map +1 -0
  175. package/dist/commands/specimen/index.d.ts +10 -0
  176. package/dist/commands/specimen/index.d.ts.map +1 -0
  177. package/dist/commands/specimen/index.js +16 -0
  178. package/dist/commands/specimen/index.js.map +1 -0
  179. package/dist/commands/specimen/set.d.ts +31 -0
  180. package/dist/commands/specimen/set.d.ts.map +1 -0
  181. package/dist/commands/specimen/set.js +188 -0
  182. package/dist/commands/specimen/set.js.map +1 -0
  183. package/dist/commands/specimen/shared.d.ts +16 -0
  184. package/dist/commands/specimen/shared.d.ts.map +1 -0
  185. package/dist/commands/specimen/shared.js +27 -0
  186. package/dist/commands/specimen/shared.js.map +1 -0
  187. package/dist/commands/system/doctor.d.ts +48 -0
  188. package/dist/commands/system/doctor.d.ts.map +1 -0
  189. package/dist/commands/system/doctor.js +224 -0
  190. package/dist/commands/system/doctor.js.map +1 -0
  191. package/dist/commands/system/index.d.ts +12 -0
  192. package/dist/commands/system/index.d.ts.map +1 -0
  193. package/dist/commands/system/index.js +17 -0
  194. package/dist/commands/system/index.js.map +1 -0
  195. package/dist/commands/system/validate.d.ts +47 -0
  196. package/dist/commands/system/validate.d.ts.map +1 -0
  197. package/dist/commands/system/validate.js +245 -0
  198. package/dist/commands/system/validate.js.map +1 -0
  199. package/dist/commands/token/add.d.ts +94 -0
  200. package/dist/commands/token/add.d.ts.map +1 -0
  201. package/dist/commands/token/add.js +162 -0
  202. package/dist/commands/token/add.js.map +1 -0
  203. package/dist/commands/token/catalog.d.ts +69 -0
  204. package/dist/commands/token/catalog.d.ts.map +1 -0
  205. package/dist/commands/token/catalog.js +175 -0
  206. package/dist/commands/token/catalog.js.map +1 -0
  207. package/dist/commands/token/compare.d.ts +140 -0
  208. package/dist/commands/token/compare.d.ts.map +1 -0
  209. package/dist/commands/token/compare.js +207 -0
  210. package/dist/commands/token/compare.js.map +1 -0
  211. package/dist/commands/token/copy.d.ts +31 -0
  212. package/dist/commands/token/copy.d.ts.map +1 -0
  213. package/dist/commands/token/copy.js +179 -0
  214. package/dist/commands/token/copy.js.map +1 -0
  215. package/dist/commands/token/definitions.d.ts +29 -0
  216. package/dist/commands/token/definitions.d.ts.map +1 -0
  217. package/dist/commands/token/definitions.js +63 -0
  218. package/dist/commands/token/definitions.js.map +1 -0
  219. package/dist/commands/token/index.d.ts +22 -0
  220. package/dist/commands/token/index.d.ts.map +1 -0
  221. package/dist/commands/token/index.js +44 -0
  222. package/dist/commands/token/index.js.map +1 -0
  223. package/dist/commands/token/lineage.d.ts +43 -0
  224. package/dist/commands/token/lineage.d.ts.map +1 -0
  225. package/dist/commands/token/lineage.js +187 -0
  226. package/dist/commands/token/lineage.js.map +1 -0
  227. package/dist/commands/token/matrix.d.ts +249 -0
  228. package/dist/commands/token/matrix.d.ts.map +1 -0
  229. package/dist/commands/token/matrix.js +658 -0
  230. package/dist/commands/token/matrix.js.map +1 -0
  231. package/dist/commands/token/override.d.ts +51 -0
  232. package/dist/commands/token/override.d.ts.map +1 -0
  233. package/dist/commands/token/override.js +158 -0
  234. package/dist/commands/token/override.js.map +1 -0
  235. package/dist/commands/token/previous-value.d.ts +23 -0
  236. package/dist/commands/token/previous-value.d.ts.map +1 -0
  237. package/dist/commands/token/previous-value.js +26 -0
  238. package/dist/commands/token/previous-value.js.map +1 -0
  239. package/dist/commands/token/reset.d.ts +29 -0
  240. package/dist/commands/token/reset.d.ts.map +1 -0
  241. package/dist/commands/token/reset.js +143 -0
  242. package/dist/commands/token/reset.js.map +1 -0
  243. package/dist/commands/token/resolve.d.ts +43 -0
  244. package/dist/commands/token/resolve.d.ts.map +1 -0
  245. package/dist/commands/token/resolve.js +136 -0
  246. package/dist/commands/token/resolve.js.map +1 -0
  247. package/dist/commands/token/subtract.d.ts +27 -0
  248. package/dist/commands/token/subtract.d.ts.map +1 -0
  249. package/dist/commands/token/subtract.js +129 -0
  250. package/dist/commands/token/subtract.js.map +1 -0
  251. package/dist/commands/webhooks/delete.d.ts +31 -0
  252. package/dist/commands/webhooks/delete.d.ts.map +1 -0
  253. package/dist/commands/webhooks/delete.js +94 -0
  254. package/dist/commands/webhooks/delete.js.map +1 -0
  255. package/dist/commands/webhooks/get.d.ts +50 -0
  256. package/dist/commands/webhooks/get.d.ts.map +1 -0
  257. package/dist/commands/webhooks/get.js +122 -0
  258. package/dist/commands/webhooks/get.js.map +1 -0
  259. package/dist/commands/webhooks/index.d.ts +24 -0
  260. package/dist/commands/webhooks/index.d.ts.map +1 -0
  261. package/dist/commands/webhooks/index.js +41 -0
  262. package/dist/commands/webhooks/index.js.map +1 -0
  263. package/dist/commands/webhooks/list.d.ts +72 -0
  264. package/dist/commands/webhooks/list.d.ts.map +1 -0
  265. package/dist/commands/webhooks/list.js +116 -0
  266. package/dist/commands/webhooks/list.js.map +1 -0
  267. package/dist/commands/webhooks/logs.d.ts +65 -0
  268. package/dist/commands/webhooks/logs.d.ts.map +1 -0
  269. package/dist/commands/webhooks/logs.js +138 -0
  270. package/dist/commands/webhooks/logs.js.map +1 -0
  271. package/dist/commands/webhooks/redact.d.ts +18 -0
  272. package/dist/commands/webhooks/redact.d.ts.map +1 -0
  273. package/dist/commands/webhooks/redact.js +24 -0
  274. package/dist/commands/webhooks/redact.js.map +1 -0
  275. package/dist/commands/webhooks/register.d.ts +78 -0
  276. package/dist/commands/webhooks/register.d.ts.map +1 -0
  277. package/dist/commands/webhooks/register.js +175 -0
  278. package/dist/commands/webhooks/register.js.map +1 -0
  279. package/dist/commands/webhooks/test.d.ts +32 -0
  280. package/dist/commands/webhooks/test.d.ts.map +1 -0
  281. package/dist/commands/webhooks/test.js +101 -0
  282. package/dist/commands/webhooks/test.js.map +1 -0
  283. package/dist/commands/webhooks/update.d.ts +77 -0
  284. package/dist/commands/webhooks/update.d.ts.map +1 -0
  285. package/dist/commands/webhooks/update.js +198 -0
  286. package/dist/commands/webhooks/update.js.map +1 -0
  287. package/dist/css.d.ts +3 -0
  288. package/dist/css.d.ts.map +1 -0
  289. package/dist/css.js +3 -0
  290. package/dist/css.js.map +1 -0
  291. package/dist/demo/index.d.ts +8 -0
  292. package/dist/demo/index.d.ts.map +1 -0
  293. package/dist/demo/index.js +8 -0
  294. package/dist/demo/index.js.map +1 -0
  295. package/dist/demo/realistic-system.d.ts +54 -0
  296. package/dist/demo/realistic-system.d.ts.map +1 -0
  297. package/dist/demo/realistic-system.js +919 -0
  298. package/dist/demo/realistic-system.js.map +1 -0
  299. package/dist/index.d.ts +21 -0
  300. package/dist/index.d.ts.map +1 -0
  301. package/dist/index.js +60 -0
  302. package/dist/index.js.map +1 -0
  303. package/dist/types/command-result.d.ts +10 -0
  304. package/dist/types/command-result.d.ts.map +1 -0
  305. package/dist/types/command-result.js +11 -0
  306. package/dist/types/command-result.js.map +1 -0
  307. package/dist/types/index.d.ts +8 -0
  308. package/dist/types/index.d.ts.map +1 -0
  309. package/dist/types/index.js +10 -0
  310. package/dist/types/index.js.map +1 -0
  311. package/dist/version.d.ts +3 -0
  312. package/dist/version.d.ts.map +1 -0
  313. package/dist/version.js +4 -0
  314. package/dist/version.js.map +1 -0
  315. package/dist/webhooks/dispatcher.d.ts +147 -0
  316. package/dist/webhooks/dispatcher.d.ts.map +1 -0
  317. package/dist/webhooks/dispatcher.js +420 -0
  318. package/dist/webhooks/dispatcher.js.map +1 -0
  319. package/dist/webhooks/index.d.ts +9 -0
  320. package/dist/webhooks/index.d.ts.map +1 -0
  321. package/dist/webhooks/index.js +9 -0
  322. package/dist/webhooks/index.js.map +1 -0
  323. package/dist/webhooks/signer.d.ts +119 -0
  324. package/dist/webhooks/signer.d.ts.map +1 -0
  325. package/dist/webhooks/signer.js +149 -0
  326. package/dist/webhooks/signer.js.map +1 -0
  327. package/dist/webhooks/url-policy.d.ts +73 -0
  328. package/dist/webhooks/url-policy.d.ts.map +1 -0
  329. package/dist/webhooks/url-policy.js +250 -0
  330. package/dist/webhooks/url-policy.js.map +1 -0
  331. package/dist/worker.d.ts +11 -0
  332. package/dist/worker.d.ts.map +1 -0
  333. package/dist/worker.js +31 -0
  334. package/dist/worker.js.map +1 -0
  335. package/package.json +84 -3
@@ -0,0 +1,919 @@
1
+ /**
2
+ * Realistic demo design system
3
+ *
4
+ * Builds a design system shaped like a real multi-product one through the
5
+ * command layer (so every write is validated exactly like user input):
6
+ *
7
+ * - a root with ~1,150 tokens across every category and tier
8
+ * - 5 products, each with platforms, devices, themes, locales
9
+ * - two mixin roots (high contrast, reduced motion) included with the
10
+ * `override` policy, sibling copies, resets, subtractions
11
+ * - owners, deprecated and experimental nodes, deprecated tokens
12
+ * - constraints that some nodes violate, and a few redundant overrides
13
+ * - a sunset date and replacement on the deprecated branch, and five rule
14
+ * check snapshots taken as the history unfolds (one issue is fixed along
15
+ * the way); each costs a full rule check, so there are only a few
16
+ *
17
+ * Used for user sessions, the UI, and performance work. Deterministic for a
18
+ * given seed. Its audit events are dated across the 12 weeks before the seed
19
+ * runs (the catalog first, the deliberate problems last), so trends have
20
+ * history to show.
21
+ */
22
+ import { recordCheckSnapshot } from '../commands/analyze/snapshot.js';
23
+ import { setCommand as constraintsSetCommand } from '../commands/constraints/set.js';
24
+ import { nodeCreateCommand } from '../commands/node/create.js';
25
+ import { tokenAddCommand } from '../commands/token/add.js';
26
+ import { tokenCopyCommand } from '../commands/token/copy.js';
27
+ import { tokenOverrideCommand } from '../commands/token/override.js';
28
+ import { tokenResetCommand } from '../commands/token/reset.js';
29
+ import { tokenSubtractCommand } from '../commands/token/subtract.js';
30
+ // ─────────────────────────────────────────────────────────────────────────────
31
+ // Deterministic helpers
32
+ // ─────────────────────────────────────────────────────────────────────────────
33
+ /** mulberry32: small, fast, deterministic PRNG */
34
+ function createRandom(seed) {
35
+ let state = seed >>> 0;
36
+ return () => {
37
+ state = (state + 0x6d2b79f5) >>> 0;
38
+ let t = state;
39
+ t = Math.imul(t ^ (t >>> 15), t | 1);
40
+ t ^= t + Math.imul(t ^ (t >>> 7), t | 61);
41
+ return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
42
+ };
43
+ }
44
+ function pick(random, items, count) {
45
+ const pool = [...items];
46
+ const picked = [];
47
+ while (picked.length < count && pool.length > 0) {
48
+ picked.push(pool.splice(Math.floor(random() * pool.length), 1)[0]);
49
+ }
50
+ return picked;
51
+ }
52
+ /** HSL (degrees, 0–100, 0–100) to #RRGGBB */
53
+ export function hsl(hue, saturation, lightness) {
54
+ const s = saturation / 100;
55
+ const l = lightness / 100;
56
+ const a = s * Math.min(l, 1 - l);
57
+ const channel = (n) => {
58
+ const k = (n + hue / 30) % 12;
59
+ const value = l - a * Math.max(-1, Math.min(k - 3, 9 - k, 1));
60
+ return Math.round(value * 255)
61
+ .toString(16)
62
+ .padStart(2, '0');
63
+ };
64
+ return `#${channel(0)}${channel(8)}${channel(4)}`.toUpperCase();
65
+ }
66
+ // ─────────────────────────────────────────────────────────────────────────────
67
+ // Token catalog (root)
68
+ // ─────────────────────────────────────────────────────────────────────────────
69
+ const HUES = [
70
+ ['red', 4, 72],
71
+ ['orange', 24, 85],
72
+ ['yellow', 48, 90],
73
+ ['lime', 84, 60],
74
+ ['green', 130, 55],
75
+ ['teal', 172, 60],
76
+ ['cyan', 190, 70],
77
+ ['blue', 210, 80],
78
+ ['indigo', 235, 60],
79
+ ['purple', 270, 55],
80
+ ['pink', 330, 65],
81
+ ['gray', 220, 8],
82
+ ];
83
+ const STEPS = [5, 10, 20, 30, 40, 50, 60, 70, 80, 90, 95, 100];
84
+ function paletteValue(hue, step) {
85
+ const [, angle, saturation] = HUES.find(([name]) => name === hue) ?? HUES[0];
86
+ const lightness = Math.round(98 - (step / 100) * 90);
87
+ return hsl(angle, saturation, lightness);
88
+ }
89
+ /** Interactive and overlay components; each gets the same family of tokens */
90
+ export const COMPONENTS = [
91
+ 'button',
92
+ 'icon-button',
93
+ 'link',
94
+ 'input',
95
+ 'textarea',
96
+ 'select',
97
+ 'checkbox',
98
+ 'radio',
99
+ 'switch',
100
+ 'slider',
101
+ 'chip',
102
+ 'badge',
103
+ 'avatar',
104
+ 'card',
105
+ 'list',
106
+ 'table',
107
+ 'tabs',
108
+ 'nav',
109
+ 'breadcrumb',
110
+ 'pagination',
111
+ 'menu',
112
+ 'popover',
113
+ 'tooltip',
114
+ 'dialog',
115
+ 'drawer',
116
+ 'toast',
117
+ 'banner',
118
+ 'progress',
119
+ 'spinner',
120
+ 'skeleton',
121
+ ];
122
+ const OVERLAYS = new Set(['menu', 'popover', 'tooltip', 'dialog', 'drawer', 'toast']);
123
+ const TOUCH_TARGETS = [
124
+ 'button',
125
+ 'icon-button',
126
+ 'input',
127
+ 'select',
128
+ 'checkbox',
129
+ 'radio',
130
+ 'switch',
131
+ 'chip',
132
+ 'tabs',
133
+ ];
134
+ function componentTokens(component, index) {
135
+ const brand = index % 3 === 0 ? 'blue' : index % 3 === 1 ? 'gray' : 'indigo';
136
+ const filled = ['button', 'chip', 'badge', 'tabs', 'switch', 'progress'].includes(component);
137
+ const c = (id) => `${component}.${id}`;
138
+ const color = (id, value) => ({
139
+ id: c(id),
140
+ value,
141
+ category: 'color',
142
+ tier: 'component',
143
+ });
144
+ const tokens = [
145
+ color('background', filled ? paletteValue(brand, 60) : paletteValue('gray', 5)),
146
+ color('background.hover', filled ? paletteValue(brand, 70) : paletteValue('gray', 10)),
147
+ color('background.pressed', filled ? paletteValue(brand, 80) : paletteValue('gray', 20)),
148
+ color('foreground', filled ? '#FFFFFF' : paletteValue('gray', 90)),
149
+ color('border', paletteValue('gray', 30)),
150
+ color('border.focus', paletteValue('blue', 60)),
151
+ color('border.hover', paletteValue('gray', 40)),
152
+ color('background.disabled', paletteValue('gray', 10)),
153
+ color('background.selected', filled ? paletteValue(brand, 70) : paletteValue('blue', 5)),
154
+ color('foreground.hover', filled ? '#FFFFFF' : paletteValue('gray', 95)),
155
+ color('foreground.disabled', paletteValue('gray', 40)),
156
+ color('icon.color', filled ? '#FFFFFF' : paletteValue('gray', 70)),
157
+ {
158
+ id: c('padding.x'),
159
+ value: `${8 + (index % 3) * 4}px`,
160
+ category: 'spacing',
161
+ tier: 'component',
162
+ },
163
+ {
164
+ id: c('padding.y'),
165
+ value: `${4 + (index % 2) * 4}px`,
166
+ category: 'spacing',
167
+ tier: 'component',
168
+ },
169
+ { id: c('gap'), value: '8px', category: 'spacing', tier: 'component' },
170
+ {
171
+ id: c('min.height'),
172
+ value: `${32 + (index % 2) * 4}px`,
173
+ category: 'spacing',
174
+ tier: 'component',
175
+ },
176
+ { id: c('icon.size'), value: '16px', category: 'spacing', tier: 'component' },
177
+ { id: c('outline.width'), value: '2px', category: 'spacing', tier: 'component' },
178
+ { id: c('outline.offset'), value: '2px', category: 'spacing', tier: 'component' },
179
+ { id: c('radius'), value: `${[4, 6, 8][index % 3]}px`, category: 'radius', tier: 'component' },
180
+ { id: c('font.size'), value: '14px', category: 'typography', tier: 'component' },
181
+ { id: c('font.weight'), value: filled ? 600 : 400, category: 'typography', tier: 'component' },
182
+ { id: c('line.height'), value: 1.43, category: 'typography', tier: 'component' },
183
+ {
184
+ id: c('shadow'),
185
+ value: OVERLAYS.has(component) ? '0 8px 24px rgba(0, 0, 0, 0.14)' : 'none',
186
+ category: 'shadow',
187
+ tier: 'component',
188
+ },
189
+ { id: c('transition.duration'), value: '200ms', category: 'motion', tier: 'component' },
190
+ {
191
+ id: c('transition.easing'),
192
+ value: 'cubic-bezier(0.33, 0, 0.67, 1)',
193
+ category: 'motion',
194
+ tier: 'component',
195
+ },
196
+ { id: c('opacity.disabled'), value: 0.4, category: 'opacity', tier: 'component' },
197
+ ];
198
+ if (OVERLAYS.has(component)) {
199
+ tokens.push({ id: c('z'), value: 1300 + index, category: 'z-index', tier: 'component' });
200
+ }
201
+ return tokens;
202
+ }
203
+ export function buildTokenCatalog() {
204
+ const tokens = [];
205
+ // Primitive palette (global tier)
206
+ for (const [hue] of HUES) {
207
+ for (const step of STEPS) {
208
+ tokens.push({
209
+ id: `color.palette.${hue}.${step}`,
210
+ value: paletteValue(hue, step),
211
+ category: 'color',
212
+ tier: 'global',
213
+ });
214
+ }
215
+ }
216
+ // Semantic colours
217
+ const semantic = {
218
+ 'color.brand.primary': paletteValue('blue', 60),
219
+ 'color.brand.secondary': paletteValue('indigo', 60),
220
+ 'color.brand.tertiary': paletteValue('teal', 60),
221
+ 'color.accent.primary': paletteValue('blue', 60),
222
+ 'color.accent.hover': paletteValue('blue', 70),
223
+ 'color.accent.pressed': paletteValue('blue', 80),
224
+ 'color.surface.base': '#FFFFFF',
225
+ 'color.surface.raised': paletteValue('gray', 5),
226
+ 'color.surface.sunken': paletteValue('gray', 10),
227
+ 'color.surface.overlay': '#FFFFFF',
228
+ 'color.surface.inverse': paletteValue('gray', 90),
229
+ 'color.text.primary': paletteValue('gray', 95),
230
+ 'color.text.secondary': paletteValue('gray', 70),
231
+ 'color.text.muted': paletteValue('gray', 60),
232
+ 'color.text.inverse': '#FFFFFF',
233
+ 'color.text.link': paletteValue('blue', 70),
234
+ 'color.text.disabled': paletteValue('gray', 40),
235
+ 'color.border.subtle': paletteValue('gray', 20),
236
+ 'color.border.default': paletteValue('gray', 30),
237
+ 'color.border.strong': paletteValue('gray', 50),
238
+ 'color.border.focus': paletteValue('blue', 60),
239
+ 'color.interactive.default': paletteValue('blue', 60),
240
+ 'color.interactive.hover': paletteValue('blue', 70),
241
+ 'color.interactive.pressed': paletteValue('blue', 80),
242
+ 'color.interactive.disabled': paletteValue('gray', 30),
243
+ };
244
+ for (const [status, hue] of [
245
+ ['success', 'green'],
246
+ ['warning', 'yellow'],
247
+ ['danger', 'red'],
248
+ ['info', 'cyan'],
249
+ ]) {
250
+ semantic[`color.status.${status}.foreground`] = paletteValue(hue, 80);
251
+ semantic[`color.status.${status}.background`] = paletteValue(hue, 5);
252
+ semantic[`color.status.${status}.border`] = paletteValue(hue, 40);
253
+ }
254
+ for (const [id, value] of Object.entries(semantic)) {
255
+ tokens.push({ id, value, category: 'color', tier: 'semantic' });
256
+ }
257
+ // Spacing scale and semantic spacing
258
+ for (let step = 0; step <= 20; step++) {
259
+ tokens.push({
260
+ id: `spacing.${step}`,
261
+ value: `${step * 4}px`,
262
+ category: 'spacing',
263
+ tier: 'global',
264
+ });
265
+ }
266
+ const sizes = ['xs', 'sm', 'md', 'lg', 'xl'];
267
+ const insets = [4, 8, 12, 16, 24];
268
+ for (const kind of ['inset', 'stack', 'inline']) {
269
+ sizes.forEach((size, i) => {
270
+ tokens.push({
271
+ id: `spacing.${kind}.${size}`,
272
+ value: `${insets[i]}px`,
273
+ category: 'spacing',
274
+ tier: 'semantic',
275
+ });
276
+ });
277
+ }
278
+ // Typography
279
+ const families = {
280
+ sans: 'Segoe UI, system-ui, sans-serif',
281
+ serif: 'Georgia, serif',
282
+ mono: 'Cascadia Code, Consolas, monospace',
283
+ display: 'Segoe UI Variable Display, Segoe UI, sans-serif',
284
+ };
285
+ for (const [name, value] of Object.entries(families)) {
286
+ tokens.push({ id: `typography.family.${name}`, value, category: 'typography', tier: 'global' });
287
+ }
288
+ const typeSizes = [
289
+ ['xs', 12],
290
+ ['sm', 14],
291
+ ['md', 16],
292
+ ['lg', 18],
293
+ ['xl', 20],
294
+ ['2xl', 24],
295
+ ['3xl', 30],
296
+ ['4xl', 36],
297
+ ['5xl', 48],
298
+ ['6xl', 60],
299
+ ];
300
+ for (const [name, px] of typeSizes) {
301
+ tokens.push({
302
+ id: `typography.size.${name}`,
303
+ value: `${px}px`,
304
+ category: 'typography',
305
+ tier: 'global',
306
+ });
307
+ }
308
+ for (const [name, weight] of [
309
+ ['light', 300],
310
+ ['regular', 400],
311
+ ['medium', 500],
312
+ ['semibold', 600],
313
+ ['bold', 700],
314
+ ]) {
315
+ tokens.push({
316
+ id: `typography.weight.${name}`,
317
+ value: weight,
318
+ category: 'typography',
319
+ tier: 'global',
320
+ });
321
+ }
322
+ for (const [name, height] of [
323
+ ['none', 1],
324
+ ['tight', 1.1],
325
+ ['snug', 1.25],
326
+ ['normal', 1.5],
327
+ ['relaxed', 1.625],
328
+ ['loose', 2],
329
+ ]) {
330
+ tokens.push({
331
+ id: `typography.line-height.${name}`,
332
+ value: height,
333
+ category: 'typography',
334
+ tier: 'global',
335
+ });
336
+ }
337
+ for (const [name, spacing] of [
338
+ ['tight', '-0.02em'],
339
+ ['normal', '0em'],
340
+ ['wide', '0.02em'],
341
+ ['wider', '0.05em'],
342
+ ]) {
343
+ tokens.push({
344
+ id: `typography.tracking.${name}`,
345
+ value: spacing,
346
+ category: 'typography',
347
+ tier: 'global',
348
+ });
349
+ }
350
+ const styles = [
351
+ ['display', [60, 48, 36]],
352
+ ['headline', [32, 28, 24]],
353
+ ['title', [22, 18, 16]],
354
+ ['body', [18, 16, 14]],
355
+ ['label', [16, 14, 12]],
356
+ ['caption', [13, 12, 11]],
357
+ ];
358
+ for (const [style, scale] of styles) {
359
+ ['lg', 'md', 'sm'].forEach((size, i) => {
360
+ const prefix = `typography.${style}.${size}`;
361
+ const strong = style === 'display' || style === 'headline' || style === 'title';
362
+ tokens.push({ id: `${prefix}.size`, value: `${scale[i]}px`, category: 'typography', tier: 'semantic' }, {
363
+ id: `${prefix}.weight`,
364
+ value: strong ? 600 : 400,
365
+ category: 'typography',
366
+ tier: 'semantic',
367
+ }, {
368
+ id: `${prefix}.line-height`,
369
+ value: strong ? 1.25 : 1.5,
370
+ category: 'typography',
371
+ tier: 'semantic',
372
+ });
373
+ });
374
+ }
375
+ // Radius, shadow, motion, opacity, z-index
376
+ for (const [name, px] of [
377
+ ['none', 0],
378
+ ['xs', 2],
379
+ ['sm', 4],
380
+ ['md', 6],
381
+ ['lg', 8],
382
+ ['xl', 12],
383
+ ['2xl', 16],
384
+ ['full', 9999],
385
+ ]) {
386
+ tokens.push({ id: `radius.${name}`, value: `${px}px`, category: 'radius', tier: 'global' });
387
+ }
388
+ const shadows = {
389
+ none: 'none',
390
+ xs: '0 1px 1px rgba(0, 0, 0, 0.06)',
391
+ sm: '0 1px 2px rgba(0, 0, 0, 0.12)',
392
+ md: '0 4px 8px rgba(0, 0, 0, 0.12)',
393
+ lg: '0 8px 16px rgba(0, 0, 0, 0.14)',
394
+ xl: '0 16px 32px rgba(0, 0, 0, 0.18)',
395
+ };
396
+ for (const [name, value] of Object.entries(shadows)) {
397
+ tokens.push({
398
+ id: `shadow.${name}`,
399
+ value,
400
+ category: 'shadow',
401
+ tier: 'global',
402
+ ...(name === 'xs' ? { status: 'deprecated', deprecatedBy: 'shadow.sm' } : {}),
403
+ });
404
+ }
405
+ for (const [name, ms] of [
406
+ ['instant', 0],
407
+ ['fast', 100],
408
+ ['normal', 200],
409
+ ['slow', 300],
410
+ ['slower', 500],
411
+ ['slowest', 800],
412
+ ]) {
413
+ tokens.push({
414
+ id: `motion.duration.${name}`,
415
+ value: `${ms}ms`,
416
+ category: 'motion',
417
+ tier: 'global',
418
+ });
419
+ }
420
+ for (const [name, value] of [
421
+ ['standard', 'cubic-bezier(0.33, 0, 0.67, 1)'],
422
+ ['decelerate', 'cubic-bezier(0, 0, 0, 1)'],
423
+ ['accelerate', 'cubic-bezier(1, 0, 1, 1)'],
424
+ ['emphasized', 'cubic-bezier(0.2, 0, 0, 1)'],
425
+ ['linear', 'linear'],
426
+ ]) {
427
+ tokens.push({
428
+ id: `motion.easing.${name}`,
429
+ value,
430
+ category: 'motion',
431
+ tier: 'global',
432
+ ...(name === 'emphasized' ? { status: 'beta' } : {}),
433
+ });
434
+ }
435
+ for (const [name, value] of [
436
+ ['0', 0],
437
+ ['10', 0.1],
438
+ ['25', 0.25],
439
+ ['50', 0.5],
440
+ ['75', 0.75],
441
+ ['100', 1],
442
+ ]) {
443
+ tokens.push({ id: `opacity.${name}`, value, category: 'opacity', tier: 'global' });
444
+ }
445
+ for (const [name, value] of [
446
+ ['base', 0],
447
+ ['dropdown', 1000],
448
+ ['sticky', 1100],
449
+ ['overlay', 1200],
450
+ ['modal', 1300],
451
+ ['popover', 1400],
452
+ ['toast', 1500],
453
+ ['tooltip', 1600],
454
+ ]) {
455
+ tokens.push({ id: `z-index.${name}`, value, category: 'z-index', tier: 'global' });
456
+ }
457
+ // Component tokens
458
+ COMPONENTS.forEach((component, index) => {
459
+ tokens.push(...componentTokens(component, index));
460
+ });
461
+ // A deprecated semantic token pointing at its replacement
462
+ const tertiary = tokens.find((token) => token.id === 'color.brand.tertiary');
463
+ if (tertiary) {
464
+ tertiary.status = 'deprecated';
465
+ tertiary.deprecatedBy = 'color.brand.secondary';
466
+ tertiary.description = 'Use color.brand.secondary';
467
+ }
468
+ return tokens;
469
+ }
470
+ const PRODUCTS = [
471
+ { id: 'xbox', hue: 120, tag: 'gaming' },
472
+ { id: 'vscode', hue: 205, tag: 'developer' },
473
+ { id: 'azure', hue: 212, tag: 'cloud' },
474
+ { id: 'office', hue: 14, tag: 'productivity' },
475
+ { id: 'teams', hue: 248, tag: 'communication' },
476
+ ];
477
+ function owner(id) {
478
+ return `${id}-design@contoso.example`;
479
+ }
480
+ export const REALISTIC_NODES = [
481
+ { id: 'global', parentId: null, type: 'root', owner: owner('design-system') },
482
+ { id: 'a11y-high-contrast', parentId: null, type: 'shared', owner: owner('accessibility') },
483
+ { id: 'motion-reduced', parentId: null, type: 'shared', owner: owner('accessibility') },
484
+ ...PRODUCTS.map((product) => ({
485
+ id: product.id,
486
+ parentId: 'global',
487
+ type: 'product',
488
+ owner: owner(product.id),
489
+ tags: [product.tag],
490
+ })),
491
+ { id: 'xbox-console', parentId: 'xbox', type: 'device', owner: owner('xbox') },
492
+ { id: 'xbox-tv', parentId: 'xbox', type: 'device', owner: owner('xbox') },
493
+ { id: 'xbox-ios', parentId: 'xbox', type: 'platform', owner: owner('xbox') },
494
+ { id: 'xbox-ios-dark', parentId: 'xbox-ios', type: 'theme', owner: owner('xbox') },
495
+ { id: 'xbox-android', parentId: 'xbox', type: 'platform', owner: owner('xbox') },
496
+ { id: 'xbox-dark', parentId: 'xbox', type: 'theme', owner: owner('xbox') },
497
+ { id: 'vscode-web', parentId: 'vscode', type: 'platform', owner: owner('vscode') },
498
+ { id: 'vscode-desktop', parentId: 'vscode', type: 'platform', owner: owner('vscode') },
499
+ { id: 'vscode-dark', parentId: 'vscode', type: 'theme', owner: owner('vscode') },
500
+ {
501
+ id: 'vscode-high-contrast',
502
+ parentId: 'vscode',
503
+ type: 'theme',
504
+ owner: owner('vscode'),
505
+ includes: ['a11y-high-contrast'],
506
+ },
507
+ { id: 'azure-portal', parentId: 'azure', type: 'platform', owner: owner('azure') },
508
+ { id: 'azure-portal-de-DE', parentId: 'azure-portal', type: 'locale', owner: owner('azure') },
509
+ { id: 'azure-portal-ja-JP', parentId: 'azure-portal', type: 'locale', owner: owner('azure') },
510
+ { id: 'azure-mobile', parentId: 'azure', type: 'platform', owner: owner('azure') },
511
+ { id: 'azure-dark', parentId: 'azure', type: 'theme', owner: owner('azure') },
512
+ {
513
+ id: 'azure-classic',
514
+ parentId: 'azure',
515
+ type: 'custom',
516
+ owner: owner('azure'),
517
+ status: 'deprecated',
518
+ sunsetInDays: 45,
519
+ replacedBy: 'azure-portal',
520
+ },
521
+ {
522
+ // A sunset date with no replacement: analyze.health flags it
523
+ id: 'azure-classic-dark',
524
+ parentId: 'azure-classic',
525
+ type: 'theme',
526
+ owner: owner('azure'),
527
+ status: 'deprecated',
528
+ sunsetInDays: 45,
529
+ },
530
+ { id: 'office-web', parentId: 'office', type: 'platform', owner: owner('office') },
531
+ { id: 'office-web-ar-SA', parentId: 'office-web', type: 'locale', owner: owner('office') },
532
+ { id: 'office-windows', parentId: 'office', type: 'platform', owner: owner('office') },
533
+ { id: 'office-mac', parentId: 'office', type: 'platform', owner: owner('office') },
534
+ { id: 'office-ios', parentId: 'office', type: 'platform', owner: owner('office') },
535
+ { id: 'office-android', parentId: 'office', type: 'platform', owner: owner('office') },
536
+ { id: 'office-dark', parentId: 'office', type: 'theme', owner: owner('office') },
537
+ { id: 'teams-desktop', parentId: 'teams', type: 'platform', owner: owner('teams') },
538
+ { id: 'teams-web', parentId: 'teams', type: 'platform', owner: owner('teams') },
539
+ {
540
+ id: 'teams-mobile',
541
+ parentId: 'teams',
542
+ type: 'platform',
543
+ owner: owner('teams'),
544
+ includes: ['motion-reduced'],
545
+ },
546
+ { id: 'teams-dark', parentId: 'teams', type: 'theme', owner: owner('teams') },
547
+ {
548
+ id: 'teams-experiment-compact',
549
+ parentId: 'teams',
550
+ type: 'experiment',
551
+ owner: owner('teams'),
552
+ status: 'experimental',
553
+ },
554
+ ];
555
+ const MOBILE = [
556
+ 'xbox-ios',
557
+ 'xbox-android',
558
+ 'azure-mobile',
559
+ 'office-ios',
560
+ 'office-android',
561
+ 'teams-mobile',
562
+ ];
563
+ const DARK = [
564
+ 'xbox-dark',
565
+ 'vscode-dark',
566
+ 'azure-dark',
567
+ 'office-dark',
568
+ 'teams-dark',
569
+ 'azure-classic-dark',
570
+ ];
571
+ // ─────────────────────────────────────────────────────────────────────────────
572
+ // Seeding
573
+ // ─────────────────────────────────────────────────────────────────────────────
574
+ /**
575
+ * Commands between yields to the event loop. A memory or SQLite database
576
+ * resolves every command in a microtask, so without this the whole seed (about
577
+ * 2,700 commands) holds the event loop and starves timers and I/O in the host.
578
+ * A vitest worker then misses its RPC replies and fails with
579
+ * `Timeout calling "onTaskUpdate"` once a test file runs past 60s.
580
+ */
581
+ const COMMANDS_PER_YIELD = 50;
582
+ function yieldToEventLoop() {
583
+ return new Promise((resolve) => setTimeout(resolve, 0));
584
+ }
585
+ const DAY_MS = 24 * 60 * 60 * 1000;
586
+ /**
587
+ * A database whose audit events are stamped by `clock` instead of the time they
588
+ * are written. Everything else goes straight to `db`.
589
+ */
590
+ function datedDatabase(db, clock) {
591
+ return new Proxy(db, {
592
+ get(target, key) {
593
+ if (key === 'addAuditEvent') {
594
+ return (event) => target.addAuditEvent({ ...event, timestamp: clock() });
595
+ }
596
+ const value = Reflect.get(target, key, target);
597
+ return typeof value === 'function' ? value.bind(target) : value;
598
+ },
599
+ });
600
+ }
601
+ /**
602
+ * Seed the realistic demo system into an empty database through the command
603
+ * layer. Throws if a command fails, so a broken seed is never half-silent.
604
+ */
605
+ export async function seedRealisticSystem(target, options = {}) {
606
+ const random = createRandom(options.seed ?? 20261016);
607
+ // Each phase starts on its own day; events within it are a second apart
608
+ const end = options.now ?? Date.now();
609
+ let time = end;
610
+ const at = (daysAgo) => {
611
+ time = Math.max(time, end - daysAgo * DAY_MS);
612
+ };
613
+ const clock = () => {
614
+ time += 1000;
615
+ return new Date(Math.min(time, end)).toISOString();
616
+ };
617
+ const context = options.history === false ? target : { ...target, db: datedDatabase(target.db, clock) };
618
+ time = end - 84 * DAY_MS;
619
+ let operations = 0;
620
+ let commands = 0;
621
+ // Rule check snapshots, stamped with the history's clock
622
+ let snapshots = 0;
623
+ const check = async () => {
624
+ if (options.checks === false)
625
+ return;
626
+ await run('snapshot', recordCheckSnapshot(context, undefined, clock()), false);
627
+ snapshots += 1;
628
+ };
629
+ const run = async (label, call, countsAsOperation = true) => {
630
+ const result = await call;
631
+ commands += 1;
632
+ if (commands % COMMANDS_PER_YIELD === 0)
633
+ await yieldToEventLoop();
634
+ if (!result.success) {
635
+ throw new Error(`Seeding failed at ${label}: ${result.error?.message ?? 'unknown error'}`);
636
+ }
637
+ if (countsAsOperation)
638
+ operations += 1;
639
+ return result.data;
640
+ };
641
+ const override = (nodeId, tokenId, value, reason) => run(`override ${nodeId} ${tokenId}`, tokenOverrideCommand.handler({ nodeId, tokenId, value, reason }, context));
642
+ const subtract = (nodeId, tokenId, reason) => run(`subtract ${nodeId} ${tokenId}`, tokenSubtractCommand.handler({ nodeId, tokenId, reason }, context));
643
+ const add = (nodeId, spec) => run(`add ${nodeId} ${spec.id}`, tokenAddCommand.handler({
644
+ nodeId,
645
+ tokenId: spec.id,
646
+ value: spec.value,
647
+ metadata: {
648
+ category: spec.category,
649
+ tier: spec.tier,
650
+ status: spec.status ?? 'stable',
651
+ platforms: [],
652
+ tags: [],
653
+ ...(spec.deprecatedBy ? { deprecatedBy: spec.deprecatedBy } : {}),
654
+ ...(spec.description ? { description: spec.description } : {}),
655
+ },
656
+ }, context));
657
+ // Nodes: mixin roots before the nodes that include them
658
+ const nodes = [...REALISTIC_NODES];
659
+ for (const node of nodes) {
660
+ await run(`create ${node.id}`, nodeCreateCommand.handler({
661
+ id: node.id,
662
+ name: node.id,
663
+ parentId: node.parentId,
664
+ type: node.type,
665
+ owner: node.owner,
666
+ status: node.status ?? 'active',
667
+ ...(node.sunsetInDays === undefined
668
+ ? {}
669
+ : { sunsetAt: new Date(end + node.sunsetInDays * DAY_MS).toISOString().slice(0, 10) }),
670
+ ...(node.replacedBy ? { replacedBy: node.replacedBy } : {}),
671
+ includes: node.includes ?? [],
672
+ includePolicy: node.includes ? 'override' : 'merge',
673
+ tags: node.tags ?? [],
674
+ }, context), false);
675
+ }
676
+ // Root catalog, and the rules every node is checked against from the start
677
+ const catalog = buildTokenCatalog();
678
+ for (const spec of catalog) {
679
+ await add('global', spec);
680
+ }
681
+ const constraints = [
682
+ {
683
+ id: 'text-contrast',
684
+ name: 'Body text contrast',
685
+ config: { type: 'contrast', against: 'color.surface.base', min: 4.5 },
686
+ severity: 'error',
687
+ applyTo: 'color.text.primary',
688
+ enabled: true,
689
+ },
690
+ {
691
+ id: 'button-contrast',
692
+ name: 'Button label contrast',
693
+ config: { type: 'contrast', against: 'button.background', min: 4.5 },
694
+ severity: 'error',
695
+ applyTo: 'button.foreground',
696
+ enabled: true,
697
+ },
698
+ {
699
+ id: 'spacing-scale',
700
+ name: 'Spacing on the 4px scale',
701
+ config: { type: 'scale', base: 4, tolerance: 0 },
702
+ severity: 'warning',
703
+ applyTo: 'spacing.*',
704
+ enabled: true,
705
+ },
706
+ ];
707
+ await run('constraints global', constraintsSetCommand.handler({ nodeId: 'global', constraints }, context), false);
708
+ // Mixins
709
+ at(80);
710
+ const highContrast = [
711
+ { id: 'color.text.primary', value: '#000000', category: 'color', tier: 'semantic' },
712
+ { id: 'color.text.secondary', value: '#000000', category: 'color', tier: 'semantic' },
713
+ { id: 'color.border.default', value: '#000000', category: 'color', tier: 'semantic' },
714
+ { id: 'color.border.focus', value: '#0000EE', category: 'color', tier: 'semantic' },
715
+ { id: 'a11y.focus.ring.width', value: '3px', category: 'spacing', tier: 'semantic' },
716
+ { id: 'a11y.focus.ring.offset', value: '2px', category: 'spacing', tier: 'semantic' },
717
+ ];
718
+ for (const spec of highContrast)
719
+ await add('a11y-high-contrast', spec);
720
+ for (const name of ['fast', 'normal', 'slow', 'slower', 'slowest']) {
721
+ await add('motion-reduced', {
722
+ id: `motion.duration.${name}`,
723
+ value: '0ms',
724
+ category: 'motion',
725
+ tier: 'global',
726
+ });
727
+ }
728
+ // Products: brand colours, type, radius, and a few customized components
729
+ for (const [index, product] of PRODUCTS.entries()) {
730
+ at(70 - index * 3);
731
+ const brand = (lightness) => hsl(product.hue, 70, lightness);
732
+ for (const [id, lightness] of [
733
+ ['color.brand.primary', 40],
734
+ ['color.brand.secondary', 32],
735
+ ['color.accent.primary', 40],
736
+ ['color.accent.hover', 34],
737
+ ['color.accent.pressed', 28],
738
+ ['color.text.link', 34],
739
+ ['color.border.focus', 40],
740
+ ['color.interactive.default', 40],
741
+ ['color.interactive.hover', 34],
742
+ ['color.interactive.pressed', 28],
743
+ ]) {
744
+ await override(product.id, id, brand(lightness), `${product.id} brand`);
745
+ }
746
+ for (const component of pick(random, COMPONENTS, 8)) {
747
+ await override(product.id, `${component}.background`, brand(42));
748
+ await override(product.id, `${component}.border.focus`, brand(40));
749
+ await override(product.id, `${component}.radius`, product.id === 'xbox' ? '12px' : '4px');
750
+ }
751
+ }
752
+ at(55);
753
+ await override('xbox', 'typography.family.sans', 'Segoe UI Variable, system-ui, sans-serif');
754
+ await override('xbox', 'radius.md', '10px');
755
+ await override('xbox', 'radius.lg', '14px');
756
+ await override('office', 'typography.family.sans', 'Aptos, Segoe UI, sans-serif');
757
+ await override('office', 'radius.md', '4px');
758
+ await override('azure', 'typography.size.md', '14px');
759
+ await override('teams', 'typography.size.md', '15px');
760
+ // Redundant: the same value the root already provides
761
+ at(52);
762
+ await override('teams', 'typography.family.sans', 'Segoe UI, system-ui, sans-serif', 'Pin family');
763
+ await override('office-web', 'radius.md', '4px', 'Match office');
764
+ await subtract('vscode', 'typography.family.display', 'VS Code has no display type');
765
+ // Dark themes: surfaces, text, borders, and component colours
766
+ for (const [index, nodeId] of DARK.entries()) {
767
+ at(46 - index * 2);
768
+ const product = PRODUCTS.find((entry) => nodeId.startsWith(entry.id)) ?? PRODUCTS[0];
769
+ const tint = (lightness) => hsl(product.hue, 8, lightness);
770
+ for (const [id, value] of [
771
+ ['color.surface.base', tint(10)],
772
+ ['color.surface.raised', tint(14)],
773
+ ['color.surface.sunken', tint(7)],
774
+ ['color.surface.overlay', tint(16)],
775
+ ['color.surface.inverse', tint(92)],
776
+ ['color.text.primary', tint(95)],
777
+ ['color.text.secondary', tint(75)],
778
+ ['color.text.muted', tint(62)],
779
+ ['color.text.inverse', tint(10)],
780
+ ['color.border.subtle', tint(20)],
781
+ ['color.border.default', tint(28)],
782
+ ['color.border.strong', tint(45)],
783
+ ]) {
784
+ await override(nodeId, id, value);
785
+ }
786
+ for (const component of COMPONENTS) {
787
+ await override(nodeId, `${component}.border`, tint(30));
788
+ }
789
+ for (const component of pick(random, COMPONENTS, 12)) {
790
+ await override(nodeId, `${component}.background`, tint(18));
791
+ await override(nodeId, `${component}.foreground`, tint(92));
792
+ }
793
+ }
794
+ // Mobile platforms: touch targets, larger body type, no hover or tooltips
795
+ for (const [index, nodeId] of MOBILE.entries()) {
796
+ at(32 - index);
797
+ await add(nodeId, {
798
+ id: 'touch.target.min',
799
+ value: '44px',
800
+ category: 'spacing',
801
+ tier: 'semantic',
802
+ });
803
+ for (const component of TOUCH_TARGETS) {
804
+ await override(nodeId, `${component}.min.height`, '44px', 'Touch target');
805
+ }
806
+ await override(nodeId, 'typography.body.md.size', '17px');
807
+ // Tooltips are removed wholesale below, so leave them out of the hover pick
808
+ const hoverable = COMPONENTS.filter((component) => component !== 'tooltip');
809
+ for (const component of pick(random, hoverable, 6)) {
810
+ await subtract(nodeId, `${component}.background.hover`, 'No hover on touch');
811
+ }
812
+ for (const spec of componentTokens('tooltip', COMPONENTS.indexOf('tooltip'))) {
813
+ await subtract(nodeId, spec.id, 'No tooltips on touch');
814
+ }
815
+ }
816
+ // Devices, desktop, web
817
+ at(24);
818
+ await check();
819
+ for (const nodeId of ['xbox-console', 'xbox-tv']) {
820
+ await add(nodeId, {
821
+ id: 'controller.focus.scale',
822
+ value: 1.05,
823
+ category: 'custom',
824
+ tier: 'semantic',
825
+ });
826
+ await override(nodeId, 'typography.body.md.size', nodeId === 'xbox-tv' ? '24px' : '20px');
827
+ await override(nodeId, 'button.min.height', '48px');
828
+ for (const component of TOUCH_TARGETS) {
829
+ await subtract(nodeId, `${component}.background.hover`, 'Controller focus replaces hover');
830
+ }
831
+ }
832
+ await add('xbox-tv', {
833
+ id: 'layout.safe-area',
834
+ value: '5%',
835
+ category: 'spacing',
836
+ tier: 'semantic',
837
+ });
838
+ await override('office-mac', 'typography.family.sans', '-apple-system, SF Pro Text, sans-serif');
839
+ await override('office-windows', 'typography.family.sans', 'Aptos, Segoe UI Variable, sans-serif');
840
+ for (const nodeId of ['vscode-web', 'teams-web', 'office-web', 'azure-portal']) {
841
+ await add(nodeId, {
842
+ id: 'scrollbar.width',
843
+ value: '10px',
844
+ category: 'spacing',
845
+ tier: 'semantic',
846
+ });
847
+ }
848
+ await override('vscode-desktop', 'typography.family.mono', 'Cascadia Mono, Consolas, monospace');
849
+ await override('xbox-ios-dark', 'color.surface.base', '#000000', 'True black on OLED');
850
+ // Locales
851
+ await add('azure-portal-de-DE', {
852
+ id: 'typography.hyphens',
853
+ value: 'auto',
854
+ category: 'typography',
855
+ tier: 'semantic',
856
+ });
857
+ await override('azure-portal-de-DE', 'button.padding.x', '16px', 'Longer labels');
858
+ await override('azure-portal-ja-JP', 'typography.family.sans', 'Yu Gothic UI, Meiryo, sans-serif');
859
+ await override('azure-portal-ja-JP', 'typography.body.md.line-height', 1.75);
860
+ await add('office-web-ar-SA', {
861
+ id: 'layout.direction',
862
+ value: 'rtl',
863
+ category: 'custom',
864
+ tier: 'semantic',
865
+ });
866
+ await override('office-web-ar-SA', 'typography.family.sans', 'Segoe UI Arabic, Tahoma, sans-serif');
867
+ // A lighter text trial on Android fails contrast; it is reset a week later
868
+ at(20);
869
+ await override('office-android', 'color.text.primary', '#A19F9D', 'Lighter text trial');
870
+ await check();
871
+ // Experiment and deprecated branch
872
+ at(17);
873
+ for (const [id, value] of [
874
+ ['spacing.inset.sm', '4px'],
875
+ ['spacing.inset.md', '8px'],
876
+ ['spacing.inset.lg', '12px'],
877
+ ['button.min.height', '28px'],
878
+ ['list.padding.y', '2px'],
879
+ ]) {
880
+ await override('teams-experiment-compact', id, value, 'Compact density experiment');
881
+ }
882
+ await run('reset teams-experiment-compact typography.size.md', tokenResetCommand.handler({ nodeId: 'teams-experiment-compact', tokenId: 'typography.size.md', toAncestor: 'global' }, context));
883
+ await override('azure-classic', 'color.brand.primary', '#0072C6', 'Classic portal blue');
884
+ await override('azure-classic', 'radius.md', '0px');
885
+ // Cross-branch copies and a reset back to the root
886
+ at(12);
887
+ await run('reset office-android color.text.primary', tokenResetCommand.handler({ nodeId: 'office-android', tokenId: 'color.text.primary' }, context));
888
+ for (const [nodeId, tokenId, fromNode] of [
889
+ ['vscode-dark', 'color.text.primary', 'xbox-dark'],
890
+ ['teams-dark', 'color.surface.base', 'office-dark'],
891
+ ['office-ios', 'button.min.height', 'xbox-ios'],
892
+ ]) {
893
+ await run(`copy ${nodeId} ${tokenId}`, tokenCopyCommand.handler({ nodeId, tokenId, fromNode }, context));
894
+ }
895
+ await run('reset azure-dark color.brand.primary', tokenResetCommand.handler({ nodeId: 'azure-dark', tokenId: 'color.brand.primary', toAncestor: 'global' }, context));
896
+ // Deliberate problems for health and constraint views
897
+ at(10);
898
+ await check();
899
+ at(8);
900
+ await override('azure-mobile', 'color.text.primary', '#9E9E9E', 'Softer text (fails contrast)');
901
+ at(5);
902
+ await override('office-ios', 'spacing.inset.md', '18px', 'Off the 4px scale');
903
+ await check();
904
+ at(2);
905
+ // Pale brand button under a white label: fails whatever the seed picked
906
+ await override('xbox-dark', 'button.background', hsl(120, 60, 80), 'Light brand button');
907
+ await override('xbox-dark', 'button.foreground', '#FFFFFF', 'White label (fails contrast)');
908
+ // The last check closes the history
909
+ at(0);
910
+ await check();
911
+ return {
912
+ nodes: nodes.length,
913
+ tokens: catalog.length,
914
+ operations,
915
+ constraints: constraints.length,
916
+ snapshots,
917
+ };
918
+ }
919
+ //# sourceMappingURL=realistic-system.js.map