@xtyle/core 0.6.0 → 0.7.1

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 (375) hide show
  1. package/README.md +43 -10
  2. package/dist/algorithms/factory.d.ts +37 -1
  3. package/dist/algorithms/factory.d.ts.map +1 -1
  4. package/dist/algorithms/factory.js +407 -60
  5. package/dist/algorithms/factory.js.map +1 -1
  6. package/dist/audit.d.ts +36 -0
  7. package/dist/audit.d.ts.map +1 -1
  8. package/dist/audit.js +22 -0
  9. package/dist/audit.js.map +1 -1
  10. package/dist/authoring.d.ts +10 -1
  11. package/dist/authoring.d.ts.map +1 -1
  12. package/dist/authoring.js +6 -1
  13. package/dist/authoring.js.map +1 -1
  14. package/dist/baked.d.ts +14 -1
  15. package/dist/baked.d.ts.map +1 -1
  16. package/dist/baked.js +17 -0
  17. package/dist/baked.js.map +1 -1
  18. package/dist/batteries.js +11 -2
  19. package/dist/cli.js +58 -19
  20. package/dist/cli.js.map +1 -1
  21. package/dist/color.d.ts +6 -0
  22. package/dist/color.d.ts.map +1 -1
  23. package/dist/color.js +20 -0
  24. package/dist/color.js.map +1 -1
  25. package/dist/css/components/app-shell.d.ts.map +1 -1
  26. package/dist/css/components/app-shell.js +10 -0
  27. package/dist/css/components/app-shell.js.map +1 -1
  28. package/dist/css/components/avatar.d.ts.map +1 -1
  29. package/dist/css/components/avatar.js +8 -19
  30. package/dist/css/components/avatar.js.map +1 -1
  31. package/dist/css/components/badge.d.ts.map +1 -1
  32. package/dist/css/components/badge.js +3 -87
  33. package/dist/css/components/badge.js.map +1 -1
  34. package/dist/css/components/bottom-nav.d.ts +2 -0
  35. package/dist/css/components/bottom-nav.d.ts.map +1 -0
  36. package/dist/css/components/bottom-nav.js +72 -0
  37. package/dist/css/components/bottom-nav.js.map +1 -0
  38. package/dist/css/components/carousel.d.ts.map +1 -1
  39. package/dist/css/components/carousel.js +144 -1
  40. package/dist/css/components/carousel.js.map +1 -1
  41. package/dist/css/components/dialog.d.ts.map +1 -1
  42. package/dist/css/components/dialog.js +10 -4
  43. package/dist/css/components/dialog.js.map +1 -1
  44. package/dist/css/components/dot.d.ts +2 -0
  45. package/dist/css/components/dot.d.ts.map +1 -0
  46. package/dist/css/components/dot.js +72 -0
  47. package/dist/css/components/dot.js.map +1 -0
  48. package/dist/css/components/heatmap.d.ts.map +1 -1
  49. package/dist/css/components/heatmap.js +23 -0
  50. package/dist/css/components/heatmap.js.map +1 -1
  51. package/dist/css/components/image.d.ts.map +1 -1
  52. package/dist/css/components/image.js +41 -0
  53. package/dist/css/components/image.js.map +1 -1
  54. package/dist/css/components/mobile-shell.d.ts +2 -0
  55. package/dist/css/components/mobile-shell.d.ts.map +1 -0
  56. package/dist/css/components/mobile-shell.js +63 -0
  57. package/dist/css/components/mobile-shell.js.map +1 -0
  58. package/dist/css/components/panel.js +1 -1
  59. package/dist/css/components/qr.d.ts +2 -0
  60. package/dist/css/components/qr.d.ts.map +1 -0
  61. package/dist/css/components/qr.js +134 -0
  62. package/dist/css/components/qr.js.map +1 -0
  63. package/dist/css/components/radio.d.ts.map +1 -1
  64. package/dist/css/components/radio.js +49 -0
  65. package/dist/css/components/radio.js.map +1 -1
  66. package/dist/css/components/ribbon.d.ts +2 -0
  67. package/dist/css/components/ribbon.d.ts.map +1 -0
  68. package/dist/css/components/ribbon.js +65 -0
  69. package/dist/css/components/ribbon.js.map +1 -0
  70. package/dist/css/components/tree.d.ts.map +1 -1
  71. package/dist/css/components/tree.js +4 -1
  72. package/dist/css/components/tree.js.map +1 -1
  73. package/dist/css/components.d.ts.map +1 -1
  74. package/dist/css/components.js +14 -1
  75. package/dist/css/components.js.map +1 -1
  76. package/dist/css/index.d.ts +2 -0
  77. package/dist/css/index.d.ts.map +1 -1
  78. package/dist/css/index.js +2 -0
  79. package/dist/css/index.js.map +1 -1
  80. package/dist/elements/avatar.d.ts +18 -3
  81. package/dist/elements/avatar.d.ts.map +1 -1
  82. package/dist/elements/avatar.js +35 -6
  83. package/dist/elements/avatar.js.map +1 -1
  84. package/dist/elements/bottom-nav.d.ts +30 -0
  85. package/dist/elements/bottom-nav.d.ts.map +1 -0
  86. package/dist/elements/bottom-nav.js +114 -0
  87. package/dist/elements/bottom-nav.js.map +1 -0
  88. package/dist/elements/carousel.d.ts +61 -0
  89. package/dist/elements/carousel.d.ts.map +1 -1
  90. package/dist/elements/carousel.js +282 -22
  91. package/dist/elements/carousel.js.map +1 -1
  92. package/dist/elements/dialog.d.ts +3 -3
  93. package/dist/elements/dialog.d.ts.map +1 -1
  94. package/dist/elements/dialog.js.map +1 -1
  95. package/dist/elements/dot.d.ts +37 -0
  96. package/dist/elements/dot.d.ts.map +1 -0
  97. package/dist/elements/dot.js +104 -0
  98. package/dist/elements/dot.js.map +1 -0
  99. package/dist/elements/fragment-ssr.d.ts.map +1 -1
  100. package/dist/elements/fragment-ssr.js +10 -0
  101. package/dist/elements/fragment-ssr.js.map +1 -1
  102. package/dist/elements/fragments/avatar/source.generated.d.ts.map +1 -1
  103. package/dist/elements/fragments/avatar/source.generated.js +1 -1
  104. package/dist/elements/fragments/avatar/source.generated.js.map +1 -1
  105. package/dist/elements/fragments/badge/source.generated.d.ts.map +1 -1
  106. package/dist/elements/fragments/badge/source.generated.js +1 -1
  107. package/dist/elements/fragments/badge/source.generated.js.map +1 -1
  108. package/dist/elements/fragments/bottom-nav/source.generated.d.ts +25 -0
  109. package/dist/elements/fragments/bottom-nav/source.generated.d.ts.map +1 -0
  110. package/dist/elements/fragments/bottom-nav/source.generated.js +4 -0
  111. package/dist/elements/fragments/bottom-nav/source.generated.js.map +1 -0
  112. package/dist/elements/fragments/component-host.json +147 -77
  113. package/dist/elements/fragments/dot/source.generated.d.ts +25 -0
  114. package/dist/elements/fragments/dot/source.generated.d.ts.map +1 -0
  115. package/dist/elements/fragments/dot/source.generated.js +4 -0
  116. package/dist/elements/fragments/dot/source.generated.js.map +1 -0
  117. package/dist/elements/fragments/heatmap/source.generated.d.ts.map +1 -1
  118. package/dist/elements/fragments/heatmap/source.generated.js +1 -1
  119. package/dist/elements/fragments/heatmap/source.generated.js.map +1 -1
  120. package/dist/elements/fragments/icon/source.generated.d.ts.map +1 -1
  121. package/dist/elements/fragments/icon/source.generated.js +1 -1
  122. package/dist/elements/fragments/icon/source.generated.js.map +1 -1
  123. package/dist/elements/fragments/image/source.generated.d.ts.map +1 -1
  124. package/dist/elements/fragments/image/source.generated.js +1 -1
  125. package/dist/elements/fragments/image/source.generated.js.map +1 -1
  126. package/dist/elements/fragments/mobile-shell/source.generated.d.ts +25 -0
  127. package/dist/elements/fragments/mobile-shell/source.generated.d.ts.map +1 -0
  128. package/dist/elements/fragments/mobile-shell/source.generated.js +4 -0
  129. package/dist/elements/fragments/mobile-shell/source.generated.js.map +1 -0
  130. package/dist/elements/fragments/qr/source.generated.d.ts +25 -0
  131. package/dist/elements/fragments/qr/source.generated.d.ts.map +1 -0
  132. package/dist/elements/fragments/qr/source.generated.js +4 -0
  133. package/dist/elements/fragments/qr/source.generated.js.map +1 -0
  134. package/dist/elements/fragments/radio/source.generated.d.ts.map +1 -1
  135. package/dist/elements/fragments/radio/source.generated.js +1 -1
  136. package/dist/elements/fragments/radio/source.generated.js.map +1 -1
  137. package/dist/elements/fragments/ribbon/source.generated.d.ts +25 -0
  138. package/dist/elements/fragments/ribbon/source.generated.d.ts.map +1 -0
  139. package/dist/elements/fragments/ribbon/source.generated.js +4 -0
  140. package/dist/elements/fragments/ribbon/source.generated.js.map +1 -0
  141. package/dist/elements/fragments/segmented/source.generated.d.ts.map +1 -1
  142. package/dist/elements/fragments/segmented/source.generated.js +1 -1
  143. package/dist/elements/fragments/segmented/source.generated.js.map +1 -1
  144. package/dist/elements/fragments/slider/source.generated.d.ts.map +1 -1
  145. package/dist/elements/fragments/slider/source.generated.js +1 -1
  146. package/dist/elements/fragments/slider/source.generated.js.map +1 -1
  147. package/dist/elements/fragments/tree/source.generated.d.ts.map +1 -1
  148. package/dist/elements/fragments/tree/source.generated.js +1 -1
  149. package/dist/elements/fragments/tree/source.generated.js.map +1 -1
  150. package/dist/elements/heatmap.d.ts +14 -3
  151. package/dist/elements/heatmap.d.ts.map +1 -1
  152. package/dist/elements/heatmap.js +49 -18
  153. package/dist/elements/heatmap.js.map +1 -1
  154. package/dist/elements/image.d.ts +20 -1
  155. package/dist/elements/image.d.ts.map +1 -1
  156. package/dist/elements/image.js +171 -1
  157. package/dist/elements/image.js.map +1 -1
  158. package/dist/elements/index.d.ts +10 -0
  159. package/dist/elements/index.d.ts.map +1 -1
  160. package/dist/elements/index.js +10 -0
  161. package/dist/elements/index.js.map +1 -1
  162. package/dist/elements/mobile-shell.d.ts +24 -0
  163. package/dist/elements/mobile-shell.d.ts.map +1 -0
  164. package/dist/elements/mobile-shell.js +53 -0
  165. package/dist/elements/mobile-shell.js.map +1 -0
  166. package/dist/elements/qr.d.ts +65 -0
  167. package/dist/elements/qr.d.ts.map +1 -0
  168. package/dist/elements/qr.js +244 -0
  169. package/dist/elements/qr.js.map +1 -0
  170. package/dist/elements/radio.d.ts +1 -0
  171. package/dist/elements/radio.d.ts.map +1 -1
  172. package/dist/elements/radio.js +7 -1
  173. package/dist/elements/radio.js.map +1 -1
  174. package/dist/elements/ribbon.d.ts +36 -0
  175. package/dist/elements/ribbon.d.ts.map +1 -0
  176. package/dist/elements/ribbon.js +91 -0
  177. package/dist/elements/ribbon.js.map +1 -0
  178. package/dist/elements/segmented.d.ts.map +1 -1
  179. package/dist/elements/segmented.js +3 -0
  180. package/dist/elements/segmented.js.map +1 -1
  181. package/dist/elements/slider.d.ts +25 -1
  182. package/dist/elements/slider.d.ts.map +1 -1
  183. package/dist/elements/slider.js +122 -16
  184. package/dist/elements/slider.js.map +1 -1
  185. package/dist/elements/sparkline.d.ts +3 -1
  186. package/dist/elements/sparkline.d.ts.map +1 -1
  187. package/dist/elements/sparkline.js +13 -3
  188. package/dist/elements/sparkline.js.map +1 -1
  189. package/dist/emit/css.d.ts.map +1 -1
  190. package/dist/emit/css.js +5 -1
  191. package/dist/emit/css.js.map +1 -1
  192. package/dist/emit/index.d.ts +2 -1
  193. package/dist/emit/index.d.ts.map +1 -1
  194. package/dist/emit/index.js +3 -1
  195. package/dist/emit/index.js.map +1 -1
  196. package/dist/emit/monaco.d.ts.map +1 -1
  197. package/dist/emit/monaco.js +2 -18
  198. package/dist/emit/monaco.js.map +1 -1
  199. package/dist/emit/terminal.d.ts +9 -0
  200. package/dist/emit/terminal.d.ts.map +1 -0
  201. package/dist/emit/terminal.js +32 -0
  202. package/dist/emit/terminal.js.map +1 -0
  203. package/dist/gauntlet.d.ts.map +1 -1
  204. package/dist/gauntlet.js +26 -0
  205. package/dist/gauntlet.js.map +1 -1
  206. package/dist/host/algorithms-bundle.generated.d.ts.map +1 -1
  207. package/dist/host/algorithms-bundle.generated.js +1 -1
  208. package/dist/host/algorithms-bundle.generated.js.map +1 -1
  209. package/dist/host/authoring-prelude.generated.d.ts +1 -1
  210. package/dist/host/authoring-prelude.generated.d.ts.map +1 -1
  211. package/dist/host/authoring-prelude.generated.js +1 -1
  212. package/dist/host/authoring-prelude.generated.js.map +1 -1
  213. package/dist/host/index.d.ts.map +1 -1
  214. package/dist/host/index.js +12 -0
  215. package/dist/host/index.js.map +1 -1
  216. package/dist/host/registry.d.ts +34 -7
  217. package/dist/host/registry.d.ts.map +1 -1
  218. package/dist/host/registry.js +45 -11
  219. package/dist/host/registry.js.map +1 -1
  220. package/dist/icon-builder.d.ts +41 -0
  221. package/dist/icon-builder.d.ts.map +1 -1
  222. package/dist/icon-builder.js +129 -8
  223. package/dist/icon-builder.js.map +1 -1
  224. package/dist/icons.d.ts +1 -1
  225. package/dist/icons.d.ts.map +1 -1
  226. package/dist/icons.js +2 -0
  227. package/dist/icons.js.map +1 -1
  228. package/dist/index.d.ts +12 -5
  229. package/dist/index.d.ts.map +1 -1
  230. package/dist/index.js +9 -4
  231. package/dist/index.js.map +1 -1
  232. package/dist/knobs.d.ts +22 -0
  233. package/dist/knobs.d.ts.map +1 -0
  234. package/dist/knobs.js +63 -0
  235. package/dist/knobs.js.map +1 -0
  236. package/dist/manifest/avatar.manifest.d.ts.map +1 -1
  237. package/dist/manifest/avatar.manifest.js +37 -17
  238. package/dist/manifest/avatar.manifest.js.map +1 -1
  239. package/dist/manifest/badge.manifest.js +1 -1
  240. package/dist/manifest/badge.manifest.js.map +1 -1
  241. package/dist/manifest/bottom-nav.manifest.d.ts +3 -0
  242. package/dist/manifest/bottom-nav.manifest.d.ts.map +1 -0
  243. package/dist/manifest/bottom-nav.manifest.js +149 -0
  244. package/dist/manifest/bottom-nav.manifest.js.map +1 -0
  245. package/dist/manifest/carousel.manifest.d.ts.map +1 -1
  246. package/dist/manifest/carousel.manifest.js +58 -4
  247. package/dist/manifest/carousel.manifest.js.map +1 -1
  248. package/dist/manifest/dialog.manifest.d.ts.map +1 -1
  249. package/dist/manifest/dialog.manifest.js +7 -4
  250. package/dist/manifest/dialog.manifest.js.map +1 -1
  251. package/dist/manifest/dot.manifest.d.ts +3 -0
  252. package/dist/manifest/dot.manifest.d.ts.map +1 -0
  253. package/dist/manifest/dot.manifest.js +172 -0
  254. package/dist/manifest/dot.manifest.js.map +1 -0
  255. package/dist/manifest/heatmap.manifest.d.ts.map +1 -1
  256. package/dist/manifest/heatmap.manifest.js +60 -2
  257. package/dist/manifest/heatmap.manifest.js.map +1 -1
  258. package/dist/manifest/icon.manifest.d.ts.map +1 -1
  259. package/dist/manifest/icon.manifest.js +28 -1
  260. package/dist/manifest/icon.manifest.js.map +1 -1
  261. package/dist/manifest/image.manifest.d.ts.map +1 -1
  262. package/dist/manifest/image.manifest.js +100 -1
  263. package/dist/manifest/image.manifest.js.map +1 -1
  264. package/dist/manifest/mobile-shell.manifest.d.ts +3 -0
  265. package/dist/manifest/mobile-shell.manifest.d.ts.map +1 -0
  266. package/dist/manifest/mobile-shell.manifest.js +177 -0
  267. package/dist/manifest/mobile-shell.manifest.js.map +1 -0
  268. package/dist/manifest/panel.manifest.d.ts.map +1 -1
  269. package/dist/manifest/panel.manifest.js +2 -1
  270. package/dist/manifest/panel.manifest.js.map +1 -1
  271. package/dist/manifest/qr.manifest.d.ts +3 -0
  272. package/dist/manifest/qr.manifest.d.ts.map +1 -0
  273. package/dist/manifest/qr.manifest.js +314 -0
  274. package/dist/manifest/qr.manifest.js.map +1 -0
  275. package/dist/manifest/radio.manifest.d.ts.map +1 -1
  276. package/dist/manifest/radio.manifest.js +54 -1
  277. package/dist/manifest/radio.manifest.js.map +1 -1
  278. package/dist/manifest/registry.d.ts.map +1 -1
  279. package/dist/manifest/registry.js +10 -0
  280. package/dist/manifest/registry.js.map +1 -1
  281. package/dist/manifest/ribbon.manifest.d.ts +3 -0
  282. package/dist/manifest/ribbon.manifest.d.ts.map +1 -0
  283. package/dist/manifest/ribbon.manifest.js +173 -0
  284. package/dist/manifest/ribbon.manifest.js.map +1 -0
  285. package/dist/manifest/segmented.manifest.js +5 -5
  286. package/dist/manifest/segmented.manifest.js.map +1 -1
  287. package/dist/manifest/slider.manifest.d.ts.map +1 -1
  288. package/dist/manifest/slider.manifest.js +62 -4
  289. package/dist/manifest/slider.manifest.js.map +1 -1
  290. package/dist/manifest/sparkline.manifest.d.ts.map +1 -1
  291. package/dist/manifest/sparkline.manifest.js +27 -1
  292. package/dist/manifest/sparkline.manifest.js.map +1 -1
  293. package/dist/manifest/tree.manifest.d.ts.map +1 -1
  294. package/dist/manifest/tree.manifest.js +24 -10
  295. package/dist/manifest/tree.manifest.js.map +1 -1
  296. package/dist/markup/avatar.d.ts +33 -0
  297. package/dist/markup/avatar.d.ts.map +1 -1
  298. package/dist/markup/avatar.js +55 -5
  299. package/dist/markup/avatar.js.map +1 -1
  300. package/dist/markup/bottom-nav.d.ts +11 -0
  301. package/dist/markup/bottom-nav.d.ts.map +1 -0
  302. package/dist/markup/bottom-nav.js +3 -0
  303. package/dist/markup/bottom-nav.js.map +1 -0
  304. package/dist/markup/dialog.d.ts +3 -0
  305. package/dist/markup/dialog.d.ts.map +1 -1
  306. package/dist/markup/dialog.js.map +1 -1
  307. package/dist/markup/dot.d.ts +27 -0
  308. package/dist/markup/dot.d.ts.map +1 -0
  309. package/dist/markup/dot.js +27 -0
  310. package/dist/markup/dot.js.map +1 -0
  311. package/dist/markup/heatmap.d.ts +2 -2
  312. package/dist/markup/heatmap.d.ts.map +1 -1
  313. package/dist/markup/heatmap.js.map +1 -1
  314. package/dist/markup/image.d.ts +9 -0
  315. package/dist/markup/image.d.ts.map +1 -1
  316. package/dist/markup/image.js +24 -0
  317. package/dist/markup/image.js.map +1 -1
  318. package/dist/markup/index.d.ts +17 -7
  319. package/dist/markup/index.d.ts.map +1 -1
  320. package/dist/markup/index.js +9 -4
  321. package/dist/markup/index.js.map +1 -1
  322. package/dist/markup/mobile-shell.d.ts +3 -0
  323. package/dist/markup/mobile-shell.d.ts.map +1 -0
  324. package/dist/markup/mobile-shell.js +3 -0
  325. package/dist/markup/mobile-shell.js.map +1 -0
  326. package/dist/markup/qr.d.ts +77 -0
  327. package/dist/markup/qr.d.ts.map +1 -0
  328. package/dist/markup/qr.js +37 -0
  329. package/dist/markup/qr.js.map +1 -0
  330. package/dist/markup/radio.d.ts +1 -1
  331. package/dist/markup/radio.d.ts.map +1 -1
  332. package/dist/markup/radio.js +1 -1
  333. package/dist/markup/radio.js.map +1 -1
  334. package/dist/markup/ribbon.d.ts +23 -0
  335. package/dist/markup/ribbon.d.ts.map +1 -0
  336. package/dist/markup/ribbon.js +23 -0
  337. package/dist/markup/ribbon.js.map +1 -0
  338. package/dist/markup/segmented.d.ts +2 -0
  339. package/dist/markup/segmented.d.ts.map +1 -1
  340. package/dist/markup/segmented.js +2 -0
  341. package/dist/markup/segmented.js.map +1 -1
  342. package/dist/markup/sparkline.d.ts +8 -0
  343. package/dist/markup/sparkline.d.ts.map +1 -1
  344. package/dist/markup/sparkline.js +37 -0
  345. package/dist/markup/sparkline.js.map +1 -1
  346. package/dist/markup/tree.d.ts +15 -4
  347. package/dist/markup/tree.d.ts.map +1 -1
  348. package/dist/markup/tree.js +16 -4
  349. package/dist/markup/tree.js.map +1 -1
  350. package/dist/mcp/tools.d.ts +7 -0
  351. package/dist/mcp/tools.d.ts.map +1 -1
  352. package/dist/mcp/tools.js +65 -29
  353. package/dist/mcp/tools.js.map +1 -1
  354. package/dist/qr.d.ts +84 -0
  355. package/dist/qr.d.ts.map +1 -0
  356. package/dist/qr.js +596 -0
  357. package/dist/qr.js.map +1 -0
  358. package/dist/series.d.ts +29 -0
  359. package/dist/series.d.ts.map +1 -1
  360. package/dist/series.js +36 -0
  361. package/dist/series.js.map +1 -1
  362. package/dist/theme-file.d.ts +21 -0
  363. package/dist/theme-file.d.ts.map +1 -1
  364. package/dist/theme-file.js +42 -0
  365. package/dist/theme-file.js.map +1 -1
  366. package/dist/token-meta.d.ts.map +1 -1
  367. package/dist/token-meta.js +6 -0
  368. package/dist/token-meta.js.map +1 -1
  369. package/dist/types.d.ts +99 -2
  370. package/dist/types.d.ts.map +1 -1
  371. package/dist/vocab.d.ts +5 -0
  372. package/dist/vocab.d.ts.map +1 -1
  373. package/dist/vocab.js.map +1 -1
  374. package/manifest.json +25 -2
  375. package/package.json +1 -1
@@ -9,14 +9,43 @@ export const BORDER_SEPARATION = 1.5;
9
9
  export const DIVIDER_SEPARATION = 1.8;
10
10
  const DEFAULT_SHIFT_STEP = 90;
11
11
  const DEFAULT_ACCENT_SPLIT = 45;
12
+ /**
13
+ * The magnitude of one step on the surface stack. The *sign* is scheme-derived rather than constant
14
+ * (see {@link defaultSurfaceRamp}), so this is a magnitude and never a `surfaceRamp` value on its own.
15
+ */
16
+ const DEFAULT_SURFACE_STEP = 0.045;
17
+ /** The `surfaceRamp` a scheme resolves to when the knob is unset: dark ascends the stack, light descends it. */
18
+ function defaultSurfaceRamp(scheme) {
19
+ return scheme === "dark" ? DEFAULT_SURFACE_STEP : -DEFAULT_SURFACE_STEP;
20
+ }
12
21
  // Chroma of the faint accent-hue wash on a surface synthesized from an accent (the "keep the tone"
13
22
  // derivation); kept low enough that any hue stays a neutral-reading surface rather than a muddy fill.
14
23
  const DERIVED_SURFACE_TINT_C = 0.02;
15
- // How accent-2/3/4 fan off the primary accent. "split-complement": 2 and 3 flank the
16
- // accent at ∓the accentSplit knob, 4 is its 180° complement; if a theme pins either wing, the
17
- // other mirrors its hue across the accent instead of the fixed knob, so the pair stays symmetric
18
- // around the author's choice. "wheel": an even fan, each accent one accentShiftStep past the last.
19
- const ACCENT_FAN = "split-complement";
24
+ const DEFAULT_ACCENT_STRATEGY = "fan";
25
+ const ACCENT_STRATEGIES = ["fan", "step", "shade", "duo"];
26
+ /**
27
+ * The accent strategy in force for one derivation. It is both an algorithm's taste (a preset picks
28
+ * the posture it ships with) and a knob (a theme overrides it), so the knob wins where it is set and
29
+ * the preset's own choice is the default — the same layering anchors and every other knob follow.
30
+ */
31
+ function accentStrategyOf(preset, knobs) {
32
+ const knob = knobs.accentStrategy;
33
+ if (typeof knob === "string" && ACCENT_STRATEGIES.includes(knob))
34
+ return knob;
35
+ return preset.accentStrategy ?? DEFAULT_ACCENT_STRATEGY;
36
+ }
37
+ /**
38
+ * Everything the accent family is built from, resolved in one place. The derivation and the
39
+ * invariant that grades it must read these identically — if they drift, the gauntlet grades a fan
40
+ * the engine never built.
41
+ */
42
+ function resolveAccentKnobs(preset, knobs) {
43
+ return {
44
+ strategy: accentStrategyOf(preset, knobs),
45
+ split: typeof knobs.accentSplit === "number" ? knobs.accentSplit : DEFAULT_ACCENT_SPLIT,
46
+ shiftStep: typeof knobs.accentShiftStep === "number" ? knobs.accentShiftStep : DEFAULT_SHIFT_STEP,
47
+ };
48
+ }
20
49
  const ACHROMATIC_CHROMA = 0.02;
21
50
  const DERIVED_ACCENT_HUE_ROTATION = 150;
22
51
  const DERIVED_ACCENT_FALLBACK_HUE = 250;
@@ -24,6 +53,12 @@ const DERIVED_ACCENT_L = 0.62;
24
53
  const DERIVED_ACCENT_C = 0.16;
25
54
  const ACCENT_RAMP_L_MIN = 0.1;
26
55
  const ACCENT_RAMP_L_MAX = 0.95;
56
+ // The `shade` strategy steps lightness (not hue) by this much per rung: `accent-2` a tint one step
57
+ // up, `accent-3`/`-4` one and two steps down, so the four read as distinct shades of the one brand hue.
58
+ const SHADE_LADDER_L_STEP = 0.12;
59
+ // How far `duo`'s two derived shades sit from the mean lightness of its two brand anchors. Larger than
60
+ // a single `shade` rung: the shades must clear *both* anchors, not just step away from one.
61
+ const DUO_L_STEP = 0.16;
27
62
  const HUE_STABLE_CHROMA = 0.1;
28
63
  // The fan (accent-2/3/4) varies hue at the accent's L/C, which collapses to identical grays when the
29
64
  // accent has near-zero chroma. Floor the fan's *base* chroma (not the primary accent) so a near-gray
@@ -102,6 +137,23 @@ const CODE_HUE_RANK = [0, 4, 2, 6, 1, 5, 3, 7];
102
137
  const CODE_STRUCTURAL_ROLES = ["comment", "operator", "punctuation", "variable"];
103
138
  const CODE_SCOPES = [...CODE_VIVID_ROLES, ...CODE_STRUCTURAL_ROLES];
104
139
  const CODE_SURFACES = ["--code-bg", "--code-fg", "--code-line-highlight", "--code-selection"];
140
+ // The ANSI palette. The four chrome roles map to xterm.js's ITheme
141
+ // (background / foreground / cursor / cursorAccent), and the sixteen colors are the
142
+ // standard 8 + 8-bright set. The six chromatic slots take fixed hue angles (aligned
143
+ // with the named `--color-*` palette) so a terminal skin re-colours with the chrome
144
+ // while staying recognisably red/green/yellow/blue/magenta/cyan; `black` and `white`
145
+ // are the achromatic endpoints (bg-fill / text) that a terminal uses regardless of scheme.
146
+ const TERMINAL_CHROME = ["bg", "fg", "cursor", "cursor-accent"];
147
+ const ANSI_ORDER = ["black", "red", "green", "yellow", "blue", "magenta", "cyan", "white"];
148
+ const ANSI_HUES = {
149
+ red: 25,
150
+ green: 145,
151
+ yellow: 95,
152
+ blue: 250,
153
+ magenta: 330,
154
+ cyan: 200,
155
+ };
156
+ const ANSI_CHROMATIC = ["red", "green", "yellow", "blue", "magenta", "cyan"];
105
157
  const SURFACES = ["--body-bg", "--bg-0", "--bg-1", "--bg-2", "--bg-3"];
106
158
  const PANEL_REF_INDEX = SURFACES.indexOf("--bg-2");
107
159
  const PANEL_SURFACES = ["--bg-1", "--bg-2"];
@@ -150,6 +202,9 @@ function buildProduces() {
150
202
  add("--placeholder", "color");
151
203
  add("--line", "color");
152
204
  add("--line-2", "color");
205
+ add("--scrollbar-track", "color");
206
+ add("--scrollbar-thumb", "color");
207
+ add("--scrollbar-thumb-hover", "color");
153
208
  add("--ring", "color");
154
209
  add("--ring-bg", "color");
155
210
  add("--accent", "color");
@@ -204,6 +259,12 @@ function buildProduces() {
204
259
  add(t, "color");
205
260
  for (const role of CODE_SCOPES)
206
261
  add(`--code-${role}`, "color");
262
+ for (const role of TERMINAL_CHROME)
263
+ add(`--terminal-${role}`, "color");
264
+ for (const name of ANSI_ORDER) {
265
+ add(`--terminal-${name}`, "color");
266
+ add(`--terminal-bright-${name}`, "color");
267
+ }
207
268
  add("--font-sans", "font");
208
269
  add("--font-mono", "font");
209
270
  add("--font-display", "font");
@@ -237,10 +298,6 @@ const { produces: PRODUCES, categories: CATEGORIES } = buildProduces();
237
298
  export const KEYWORD_DOMAINS = {
238
299
  "--selection-cue": ["tint", "marker"],
239
300
  };
240
- function stepLightness(base, scheme, step, index) {
241
- const direction = scheme === "dark" ? 1 : -1;
242
- return base + direction * step * index;
243
- }
244
301
  function contrastBandFloor(knobs) {
245
302
  const band = knobs.contrastBand;
246
303
  if (typeof band === "number")
@@ -737,7 +794,32 @@ function resolveStatusHue(role, pinned) {
737
794
  const pin = parseChromaticPin(pinned[`--${name}`] ?? pinned[`--color-${name}-base`] ?? pinned[`--color-${name}`]);
738
795
  return pin ? pin.h : paletteHueAngle(name);
739
796
  }
797
+ /**
798
+ * A single derivation is pure in `(preset, opts)`, and a live editor asks for the same one
799
+ * several ways at once: `derive` resolves the graph, `lineage` reads its edges, an inspector
800
+ * reads it again. Without this they each pay a full OKLCH pass over the whole register. The
801
+ * cache is per-preset and bounded — a slider drag mints a new key per settled value, so it
802
+ * evicts oldest-first rather than growing for the life of the page.
803
+ */
804
+ const GRAPH_CACHE_LIMIT = 16;
805
+ const graphCaches = new WeakMap();
740
806
  export function buildGraph(preset, opts) {
807
+ let cache = graphCaches.get(preset);
808
+ if (!cache)
809
+ graphCaches.set(preset, (cache = new Map()));
810
+ const key = JSON.stringify(opts ?? {});
811
+ const hit = cache.get(key);
812
+ if (hit)
813
+ return hit;
814
+ const nodes = buildGraphUncached(preset, opts);
815
+ cache.set(key, nodes);
816
+ if (cache.size > GRAPH_CACHE_LIMIT) {
817
+ const oldest = cache.keys().next().value;
818
+ cache.delete(oldest);
819
+ }
820
+ return nodes;
821
+ }
822
+ function buildGraphUncached(preset, opts) {
741
823
  const completed = completeAnchors(preset, opts);
742
824
  const bg = completed.bg;
743
825
  const fgAnchor = completed.fg;
@@ -745,8 +827,7 @@ export function buildGraph(preset, opts) {
745
827
  const accent = pinned["--accent"] ? toOklchColor(pinned["--accent"]) : completed.accent;
746
828
  const scheme = completed.scheme;
747
829
  const knobs = opts.knobs ?? {};
748
- const shiftStep = typeof knobs.accentShiftStep === "number" ? knobs.accentShiftStep : DEFAULT_SHIFT_STEP;
749
- const accentSplit = typeof knobs.accentSplit === "number" ? knobs.accentSplit : DEFAULT_ACCENT_SPLIT;
830
+ const { strategy, split: accentSplit, shiftStep } = resolveAccentKnobs(preset, knobs);
750
831
  const band = contrastBandFloor(knobs);
751
832
  const floor = Math.max(ENFORCE, preset.contrastFloor, (band ?? 0) + 0.2);
752
833
  const extreme = preset.extreme === true;
@@ -757,7 +838,11 @@ export function buildGraph(preset, opts) {
757
838
  const radiusScale = radiusScaleOf(knobs);
758
839
  const density = densityOf(knobs);
759
840
  const fonts = fontsOf(knobs);
760
- const surfaceStep = 0.045;
841
+ // The signed lightness delta the surface stack walks from `--bg-0`. Unset, it resolves to the
842
+ // scheme-derived direction (dark ascends, light descends) at the default magnitude, so output is
843
+ // unchanged; set, the author's sign wins and the whole stack (body-bg, bg-1/2/3, bg-sunken)
844
+ // follows the one number instead of six hand-pinned surfaces.
845
+ const surfaceRamp = typeof knobs.surfaceRamp === "number" ? knobs.surfaceRamp : defaultSurfaceRamp(scheme);
761
846
  const nodes = [];
762
847
  const lit = (name, value, refs) => {
763
848
  nodes.push(refs && refs.length ? { name, value, refs } : { name, value });
@@ -769,14 +854,13 @@ export function buildGraph(preset, opts) {
769
854
  ? toOklchColor(pinned["--bg-0"])
770
855
  : extreme
771
856
  ? oklch(scheme === "dark" ? 0 : 1, 0, 0)
772
- : ensureTextHeadroom(withLightness(bg, stepLightness(bg.l, scheme, surfaceStep, 1)), scheme, floor);
857
+ : ensureTextHeadroom(withLightness(bg, bg.l + surfaceRamp), scheme, floor);
773
858
  const pageFloor = (fill) => separateFillFromSurface(fill, bg0, SURFACE_SEPARATION, floor);
774
- const direction = scheme === "dark" ? 1 : -1;
775
- const surfaceColors = SURFACES.map((_, index) => withLightness(bg0, bg0.l + direction * surfaceStep * (index - 1)));
859
+ const surfaceColors = SURFACES.map((_, index) => withLightness(bg0, bg0.l + surfaceRamp * (index - 1)));
776
860
  SURFACES.forEach((name, index) => {
777
861
  lit(name, formatCss(surfaceColors[index]), refIfPinned("--bg-0"));
778
862
  });
779
- lit("--bg-sunken", formatCss(withLightness(bg0, bg0.l - direction * surfaceStep * 2)), refIfPinned("--bg-0"));
863
+ lit("--bg-sunken", formatCss(withLightness(bg0, bg0.l - surfaceRamp * 2)), refIfPinned("--bg-0"));
780
864
  lit("--scrim", formatCss(oklch(scheme === "dark" ? 0 : 0.1, 0, 0, 0.6)));
781
865
  const overlayBase = withLightness(bg0, scheme === "dark" ? bg0.l + 0.07 : bg0.l + 0.03);
782
866
  lit("--surface-overlay", formatCss(overlayBase), refIfPinned("--bg-0"));
@@ -897,7 +981,11 @@ export function buildGraph(preset, opts) {
897
981
  const line2Seed = extreme
898
982
  ? oklch(scheme === "dark" ? 0.85 : 0.15, 0, 0)
899
983
  : withLightness(bg0, scheme === "dark" ? bg0.l + 0.2 : bg0.l - 0.2);
900
- lit("--line-2", formatCss(borderForContrast(line2Seed, bg0, DIVIDER_SEPARATION)), refIfPinned("--bg-0"));
984
+ const line2Color = borderForContrast(line2Seed, bg0, DIVIDER_SEPARATION);
985
+ lit("--line-2", formatCss(line2Color), refIfPinned("--bg-0"));
986
+ lit("--scrollbar-track", "transparent");
987
+ lit("--scrollbar-thumb", formatCss(line2Color), ["--line-2", ...refIfPinned("--bg-0")]);
988
+ lit("--scrollbar-thumb-hover", formatCss(withLightness(line2Color, line2Color.l + (scheme === "dark" ? 0.12 : -0.12))), ["--scrollbar-thumb"]);
901
989
  lit("--ring", formatCss(withAlpha(accentFill, 0.7)), ["--accent"]);
902
990
  lit("--ring-bg", formatCss(withAlpha(accentFill, 0.18)), ["--accent"]);
903
991
  const fieldBg = withLightness(bg0, scheme === "dark" ? bg0.l - 0.03 : bg0.l + 0.02);
@@ -937,13 +1025,14 @@ export function buildGraph(preset, opts) {
937
1025
  let a2;
938
1026
  let a3;
939
1027
  let a4;
940
- // The lineage edges differ per fan: a split-complement's 2/3 flank the accent and 4 is its
941
- // complement (all off `--accent`, so a pinned flank pulls its mirror in), while a wheel chains
942
- // 3 off 2 and 4 off 3. Declared per-branch so `lineage()` names what each token actually reads.
1028
+ // The lineage edges differ per strategy: a `fan`'s 2/3 flank the accent and 4 is its complement
1029
+ // (all off `--accent`, so a pinned flank pulls its mirror in), a `step` chains 3 off 2 and 4 off 3,
1030
+ // and a `duo` reads *both* anchors into each shade. Declared per-branch so `lineage()` names what
1031
+ // each token actually reads.
943
1032
  let a2Refs;
944
1033
  let a3Refs;
945
1034
  let a4Refs;
946
- if (ACCENT_FAN === "split-complement") {
1035
+ if (strategy === "fan") {
947
1036
  // The two flanks are symmetric either way: pin either wing and the other mirrors its hue
948
1037
  // across the accent, so the fan stays balanced around the author's choice. With neither
949
1038
  // pinned it's the default ∓split; with both pinned each holds its own value. Lightness and
@@ -964,10 +1053,56 @@ export function buildGraph(preset, opts) {
964
1053
  a3Refs = a2Pin && !a3Pin ? ["--accent", "--accent-2"] : ["--accent"];
965
1054
  a4Refs = ["--accent"];
966
1055
  }
1056
+ else if (strategy === "shade") {
1057
+ // 2/3/4 hold the accent's hue and step its lightness: a tint one step up, two shades down, so
1058
+ // the fan reads as one brand color in four depths. The separation is on lightness, so a
1059
+ // near-gray accent still fans into four distinguishable rungs where a hue rotation is a no-op.
1060
+ // Each rung reads off `--accent` and is independently pinnable.
1061
+ a2 = fanned("2", applyAccentDelta(fanBase, { dL: SHADE_LADDER_L_STEP, dC: 0, dH: 0 }));
1062
+ a3 = fanned("3", applyAccentDelta(fanBase, { dL: -SHADE_LADDER_L_STEP, dC: 0, dH: 0 }));
1063
+ a4 = fanned("4", applyAccentDelta(fanBase, { dL: -2 * SHADE_LADDER_L_STEP, dC: 0, dH: 0 }));
1064
+ a2Refs = ["--accent"];
1065
+ a3Refs = ["--accent"];
1066
+ a4Refs = ["--accent"];
1067
+ }
1068
+ else if (strategy === "duo") {
1069
+ // Two brand colors, not one. `--accent` and `--accent-2` are both *inputs* — the only strategy
1070
+ // where a fan slot is an anchor rather than an output — and 3/4 are their shades. Unpinned,
1071
+ // `--accent-2` still has to come from somewhere, so it falls out of `--accent` by the same fan
1072
+ // distance the split uses; a duo theme that never sets a second color is just a fan that kept
1073
+ // two of its wings.
1074
+ //
1075
+ // The shades are placed against the *pair's* mean lightness rather than each anchor's own, which
1076
+ // is what makes this more than two ladders side by side: both land on one common lightness, so
1077
+ // they read as a matched secondary pair belonging to the same system. They step away from the
1078
+ // surface (up from a dark scheme, down from a light one) and flip if that pole has no headroom
1079
+ // left, so a pair of already-light brand colors on a light theme still yields separable rungs.
1080
+ a2 = fanned("2", applyAccentDelta(fanBase, rotate(accentSplit)));
1081
+ const midL = (a1.l + a2.l) / 2;
1082
+ const away = scheme === "dark" ? 1 : -1;
1083
+ const room = (dir) => {
1084
+ const target = midL + dir * DUO_L_STEP;
1085
+ return target <= ACCENT_RAMP_L_MAX && target >= ACCENT_RAMP_L_MIN;
1086
+ };
1087
+ const dir = room(away) ? away : -away;
1088
+ const shadeL = Math.min(ACCENT_RAMP_L_MAX, Math.max(ACCENT_RAMP_L_MIN, midL + dir * DUO_L_STEP));
1089
+ const shadeOf = (brand) => ({
1090
+ l: shadeL,
1091
+ c: Math.max(brand.c, FAN_MIN_CHROMA),
1092
+ h: brand.h,
1093
+ alpha: 1,
1094
+ });
1095
+ a3 = fanned("3", shadeOf(a1));
1096
+ a4 = fanned("4", shadeOf(a2));
1097
+ a2Refs = ["--accent"];
1098
+ // Both shades read both anchors: the hue is one brand's, the lightness is the pair's mean.
1099
+ a3Refs = ["--accent", "--accent-2"];
1100
+ a4Refs = ["--accent-2", "--accent"];
1101
+ }
967
1102
  else {
968
- // Each accent is one hue-step past the last. Chaining off `fanBase` (not `a1`) keeps the whole
969
- // wheel at the floored chroma for a near-gray accent instead of escalating it down the chain; a
970
- // chromatic accent has `fanBase === a1`, so the step stays byte-identical.
1103
+ // `step`: each accent is one hue-step past the last. Chaining off `fanBase` (not `a1`) keeps the
1104
+ // whole walk at the floored chroma for a near-gray accent instead of escalating it down the
1105
+ // chain; a chromatic accent has `fanBase === a1`, so the step stays byte-identical.
971
1106
  a2 = fanned("2", applyAccentDelta(fanBase, rotate(shiftStep)));
972
1107
  a3 = fanned("3", applyAccentDelta(a2, accentDelta(fanBase, a2)));
973
1108
  a4 = fanned("4", applyAccentDelta(a3, accentDelta(a2, a3)));
@@ -1098,15 +1233,15 @@ export function buildGraph(preset, opts) {
1098
1233
  const codeTowardLight = contrast("#ffffff", codeBgCss) >= contrast("#000000", codeBgCss);
1099
1234
  const codePole = codeTowardLight ? 1 : 0;
1100
1235
  const codeFloor = AA;
1101
- const readableHuedOnCode = (l, c, h, fl) => {
1236
+ const readableHuedOn = (bgCss, pole, l, c, h, fl) => {
1102
1237
  const seed = oklch(l, c, h);
1103
1238
  let best = seed;
1104
- let bestContrast = emittedContrast(seed, codeBgCss);
1239
+ let bestContrast = emittedContrast(seed, bgCss);
1105
1240
  if (bestContrast >= fl)
1106
1241
  return seed;
1107
1242
  for (let i = 1; i <= 100; i++) {
1108
- const cand = withLightness(seed, seed.l + (codePole - seed.l) * (i / 100));
1109
- const ct = emittedContrast(cand, codeBgCss);
1243
+ const cand = withLightness(seed, seed.l + (pole - seed.l) * (i / 100));
1244
+ const ct = emittedContrast(cand, bgCss);
1110
1245
  if (ct >= fl)
1111
1246
  return cand;
1112
1247
  if (ct > bestContrast) {
@@ -1116,6 +1251,7 @@ export function buildGraph(preset, opts) {
1116
1251
  }
1117
1252
  return best;
1118
1253
  };
1254
+ const readableHuedOnCode = (l, c, h, fl) => readableHuedOn(codeBgCss, codePole, l, c, h, fl);
1119
1255
  const codeChroma = Math.max(0.08, Math.max(0.1, accent.c) * (0.7 + vibrancy * 0.7) * preset.paletteChromaMul);
1120
1256
  // A near-gray accent has no hue to anchor the spread to, so seed the code wheel
1121
1257
  // from the fallback hue rather than letting `NaN` collapse every scope to one ink.
@@ -1145,6 +1281,42 @@ export function buildGraph(preset, opts) {
1145
1281
  lit("--code-operator", formatCss(readableHuedOnCode(codeBaseL, codeChroma * 0.5, codeBaseHue, codeFloor)), ["--accent", "--code-bg"]);
1146
1282
  lit("--code-punctuation", formatCss(enforceContrastFloor(withLightness(codeFg, codeFg.l + (codePole - codeFg.l) * 0.18), codeBg, scheme, codeFloor)), ["--code-fg", "--code-bg"]);
1147
1283
  lit("--code-variable", codeFgCss, ["--code-fg"]);
1284
+ const terminalBg = ensureTextHeadroom(withLightness(bg0, scheme === "dark" ? bg0.l - 0.035 : bg0.l + 0.02), scheme, floor);
1285
+ const terminalBgCss = formatCss(terminalBg);
1286
+ lit("--terminal-bg", terminalBgCss, refIfPinned("--bg-0"));
1287
+ const terminalFg = enforceContrastFloor(fg0, terminalBg, scheme, floor);
1288
+ lit("--terminal-fg", formatCss(terminalFg), ["--fg-0", ...refIfPinned("--bg-0")]);
1289
+ // A block cursor reads as the accent; the glyph under it flips to whichever pole
1290
+ // stays legible against that block.
1291
+ const terminalCursor = separateFillFromSurface(accentFill, terminalBg, SURFACE_SEPARATION, floor);
1292
+ lit("--terminal-cursor", formatCss(terminalCursor), ["--accent"]);
1293
+ lit("--terminal-cursor-accent", pickReadable(terminalCursor, TEXT_POLES, floor), ["--accent"]);
1294
+ // The six chromatic slots sit at a mid band that clears AA on the terminal bg; the
1295
+ // bright tier pushes each toward the readable pole (and up in chroma) so bright and
1296
+ // normal stay separable while both stay legible.
1297
+ const terminalTowardLight = contrast("#ffffff", terminalBgCss) >= contrast("#000000", terminalBgCss);
1298
+ const terminalPole = terminalTowardLight ? 1 : 0;
1299
+ const terminalFloor = AA;
1300
+ const terminalChroma = Math.max(0.07, Math.max(0.1, accent.c) * (0.55 + vibrancy * 0.7) * preset.paletteChromaMul);
1301
+ const terminalNormalL = terminalTowardLight ? 0.5 : 0.62;
1302
+ const terminalBrightL = terminalNormalL + (terminalPole - terminalNormalL) * 0.34;
1303
+ for (const name of ANSI_CHROMATIC) {
1304
+ const hue = ANSI_HUES[name];
1305
+ const normal = readableHuedOn(terminalBgCss, terminalPole, terminalNormalL, terminalChroma, hue, terminalFloor);
1306
+ const bright = readableHuedOn(terminalBgCss, terminalPole, terminalBrightL, terminalChroma * 1.08, hue, terminalFloor);
1307
+ lit(`--terminal-${name}`, formatCss(normal), ["--accent", "--terminal-bg"]);
1308
+ lit(`--terminal-bright-${name}`, formatCss(bright), ["--accent", "--terminal-bg"]);
1309
+ }
1310
+ // `black` and `white` are the achromatic endpoints — a terminal uses them as
1311
+ // fills / ink, not as legible-on-bg scopes, so they anchor to fixed dark / light
1312
+ // lightnesses (carrying a whisper of the bg hue for cohesion) rather than sweeping
1313
+ // for contrast like the chromatic slots.
1314
+ const terminalHue = Number.isFinite(bg0.h) ? bg0.h : 0;
1315
+ const terminalAchroma = (l) => oklch(l, 0.006, terminalHue);
1316
+ lit("--terminal-black", formatCss(terminalAchroma(0.2)), refIfPinned("--bg-0"));
1317
+ lit("--terminal-bright-black", formatCss(terminalAchroma(0.42)), refIfPinned("--bg-0"));
1318
+ lit("--terminal-white", formatCss(terminalAchroma(0.85)), ["--fg-0"]);
1319
+ lit("--terminal-bright-white", formatCss(terminalAchroma(0.97)), ["--fg-0"]);
1148
1320
  lit("--font-sans", fonts.sans);
1149
1321
  lit("--font-mono", fonts.mono);
1150
1322
  lit("--font-display", fonts.display);
@@ -1778,27 +1950,32 @@ export function makeInvariants(preset) {
1778
1950
  if (accent.c < HUE_STABLE_CHROMA) {
1779
1951
  return { name, ok: true };
1780
1952
  }
1781
- const step = typeof ctx.knobs.accentShiftStep === "number"
1782
- ? ctx.knobs.accentShiftStep
1783
- : DEFAULT_SHIFT_STEP;
1784
- const split = typeof ctx.knobs.accentSplit === "number"
1785
- ? ctx.knobs.accentSplit
1786
- : DEFAULT_ACCENT_SPLIT;
1953
+ const { strategy, split, shiftStep: step } = resolveAccentKnobs(preset, ctx.knobs);
1787
1954
  const accent2Value = ctx.register["--accent-2"];
1788
1955
  const accent3Value = ctx.register["--accent-3"];
1789
1956
  const pinnedAccent2 = ctx.constraints["--accent-2"] && accent2Value ? toOklchColor(accent2Value) : null;
1790
1957
  const pinnedAccent3 = ctx.constraints["--accent-3"] && accent3Value ? toOklchColor(accent3Value) : null;
1791
- const fanOffset = (n) => ACCENT_FAN === "split-complement"
1792
- ? n === 2
1793
- ? pinnedAccent3
1794
- ? -hueDelta(accent.h, pinnedAccent3.h)
1795
- : -split
1796
- : n === 3
1797
- ? pinnedAccent2
1798
- ? -hueDelta(accent.h, pinnedAccent2.h)
1799
- : split
1800
- : 180
1801
- : step * (n - 1);
1958
+ // The hue each slot owes the accent. A `shade` holds one hue and steps lightness, so every
1959
+ // rung wants the accent's own. A `duo` carries two hues: 3 is brand one's (the accent's), 4 is
1960
+ // brand two's — whatever `--accent-2` actually landed on, pinned or derived.
1961
+ const duoSecondHue = () => pinnedAccent2 ? hueDelta(accent.h, pinnedAccent2.h) : split;
1962
+ const fanOffset = (n) => {
1963
+ if (strategy === "shade")
1964
+ return 0;
1965
+ if (strategy === "step")
1966
+ return step * (n - 1);
1967
+ // 3 shades brand one (the accent's own hue); 2 and 4 are brand two's.
1968
+ if (strategy === "duo")
1969
+ return n === 3 ? 0 : duoSecondHue();
1970
+ if (n === 2)
1971
+ return pinnedAccent3 ? -hueDelta(accent.h, pinnedAccent3.h) : -split;
1972
+ if (n === 3)
1973
+ return pinnedAccent2 ? -hueDelta(accent.h, pinnedAccent2.h) : split;
1974
+ return 180;
1975
+ };
1976
+ // `shade` and `duo` both deliberately move lightness off the accent's, so the constant-L/C
1977
+ // checks below belong only to the hue-rotating postures.
1978
+ const stepsLightness = strategy === "shade" || strategy === "duo";
1802
1979
  for (let n = 2; n <= 4; n++) {
1803
1980
  if (ctx.constraints[`--accent-${n}`])
1804
1981
  continue;
@@ -1819,21 +1996,25 @@ export function makeInvariants(preset) {
1819
1996
  };
1820
1997
  }
1821
1998
  }
1822
- if (Math.abs(rotated.l - accent.l) > LIGHTNESS_TOLERANCE) {
1823
- return {
1824
- name,
1825
- ok: false,
1826
- detail: `--accent-${n} l=${rotated.l.toFixed(3)} want ${accent.l.toFixed(3)}`,
1827
- };
1828
- }
1829
- const maxChroma = clampToGamut({ l: accent.l, c: accent.c, h: wantH, alpha: 1 }).c;
1830
- const expectedChroma = Math.min(accent.c, maxChroma);
1831
- if (Math.abs(rotated.c - expectedChroma) > 0.02) {
1832
- return {
1833
- name,
1834
- ok: false,
1835
- detail: `--accent-${n} chroma ${rotated.c.toFixed(3)} want max-at-hue ${expectedChroma.toFixed(3)}`,
1836
- };
1999
+ // A lightness-stepping strategy gamut-clamps chroma per rung, so only the shared-hue check
2000
+ // above is a promise it makes; the constant-L/C pair below is the hue-fan postures' promise.
2001
+ if (!stepsLightness) {
2002
+ if (Math.abs(rotated.l - accent.l) > LIGHTNESS_TOLERANCE) {
2003
+ return {
2004
+ name,
2005
+ ok: false,
2006
+ detail: `--accent-${n} l=${rotated.l.toFixed(3)} want ${accent.l.toFixed(3)}`,
2007
+ };
2008
+ }
2009
+ const maxChroma = clampToGamut({ l: accent.l, c: accent.c, h: wantH, alpha: 1 }).c;
2010
+ const expectedChroma = Math.min(accent.c, maxChroma);
2011
+ if (Math.abs(rotated.c - expectedChroma) > 0.02) {
2012
+ return {
2013
+ name,
2014
+ ok: false,
2015
+ detail: `--accent-${n} chroma ${rotated.c.toFixed(3)} want max-at-hue ${expectedChroma.toFixed(3)}`,
2016
+ };
2017
+ }
1837
2018
  }
1838
2019
  }
1839
2020
  return { name, ok: true };
@@ -2109,6 +2290,51 @@ export function makeInvariants(preset) {
2109
2290
  }
2110
2291
  return { name, ok: true };
2111
2292
  },
2293
+ (ctx) => {
2294
+ const name = "terminal palette readable on --terminal-bg";
2295
+ const bg = ctx.register["--terminal-bg"];
2296
+ if (!bg)
2297
+ return { name, ok: false, detail: "--terminal-bg missing" };
2298
+ const readFloor = achievableFloor(AA, bg);
2299
+ const inks = [
2300
+ "--terminal-fg",
2301
+ ...ANSI_CHROMATIC.map((n) => `--terminal-${n}`),
2302
+ ...ANSI_CHROMATIC.map((n) => `--terminal-bright-${n}`),
2303
+ ];
2304
+ for (const token of inks) {
2305
+ const v = ctx.register[token];
2306
+ const ratio = v ? contrast(v, bg) : 0;
2307
+ if (ratio < readFloor - 0.05) {
2308
+ return { name, ok: false, detail: `${token} on --terminal-bg = ${ratio.toFixed(2)} (floor ${readFloor.toFixed(2)})` };
2309
+ }
2310
+ }
2311
+ return { name, ok: true };
2312
+ },
2313
+ (ctx) => {
2314
+ // OKLab distance, not WCAG contrast — two equally-light hues (a red and a green
2315
+ // both readable on the bg) can still be one indistinguishable colour to a reader.
2316
+ // Floored under the muted reality (the warm red/magenta pair converges to ~0.020
2317
+ // once a low-chroma seed floors the palette), so it guards a real collapse, not the
2318
+ // legitimate warm-family closeness a muted terminal skin is allowed.
2319
+ const name = "terminal ANSI hues mutually distinguishable";
2320
+ const MIN_DE = 0.012;
2321
+ const slots = ANSI_CHROMATIC.map((n) => `--terminal-${n}`);
2322
+ for (let i = 0; i < slots.length; i++) {
2323
+ for (let j = i + 1; j < slots.length; j++) {
2324
+ const ni = slots[i];
2325
+ const nj = slots[j];
2326
+ const a = ctx.register[ni];
2327
+ const b = ctx.register[nj];
2328
+ if (!a || !b)
2329
+ continue;
2330
+ const d = oklabDist(a, b);
2331
+ if (d < MIN_DE) {
2332
+ return { name, ok: false, detail: `${ni} vs ${nj} ΔE=${d.toFixed(4)} (min ${MIN_DE})` };
2333
+ }
2334
+ }
2335
+ }
2336
+ return { name, ok: true };
2337
+ },
2112
2338
  (ctx) => {
2113
2339
  // Mistaking success for danger is a usability failure WCAG contrast can't see — two
2114
2340
  // equally-light status hues read as one. Floored well under the muted reality
@@ -2154,6 +2380,7 @@ export function makeXtylePipelineAlgorithm(preset, buildPasses) {
2154
2380
  id: preset.id,
2155
2381
  produces: PRODUCES,
2156
2382
  knobs: preset.knobs,
2383
+ knobSpecs: resolveKnobSpecs(preset.knobs, preset.knobSpecs),
2157
2384
  categories: CATEGORIES,
2158
2385
  derive: (opts = {}) => run(opts).register,
2159
2386
  lineage: (opts = {}) => singlePass
@@ -2169,6 +2396,8 @@ export function makeXtyleAlgorithm(preset) {
2169
2396
  }
2170
2397
  export const SHARED_KNOBS = [
2171
2398
  "scheme",
2399
+ "surfaceRamp",
2400
+ "accentStrategy",
2172
2401
  "accentShiftStep",
2173
2402
  "accentSplit",
2174
2403
  "contrastBand",
@@ -2180,6 +2409,124 @@ export const SHARED_KNOBS = [
2180
2409
  "fonts",
2181
2410
  "anchors",
2182
2411
  ];
2412
+ /**
2413
+ * The rendered *domain* of every knob the shared xtyle derivation reads — the kind, range, and
2414
+ * accepted values a consumer needs to build a control.
2415
+ *
2416
+ * Strictly the *shared* knobs: a knob only one algorithm reads belongs to that algorithm's own
2417
+ * `knobSpecs`, not here (`hour` is nxi-nite's, and lives there). A shared registry carrying a
2418
+ * single algorithm's domain would be the same hardcoded name-keyed table `knobSpecs` exists to
2419
+ * delete, moved one layer down.
2420
+ *
2421
+ * `fonts` and `anchors` carry `kind: "composite"` rather than a scalar domain: they are groups a
2422
+ * consumer expands into multiple controls (font stacks, anchor pickers), so their orchestration stays
2423
+ * with the consumer. They are declared here all the same, so that "this knob is a composite" is a fact
2424
+ * the algorithm states rather than a list of names the engine keeps. Cosmetic concerns (localized
2425
+ * labels, unit suffixes, digit precision) are deliberately not here — they belong to the consumer; the
2426
+ * `label` hints below are just defaults a consumer may override.
2427
+ */
2428
+ export const SHARED_KNOB_SPECS = [
2429
+ {
2430
+ name: "scheme",
2431
+ kind: "select",
2432
+ label: "Scheme",
2433
+ options: [
2434
+ { value: "dark", label: "dark" },
2435
+ { value: "light", label: "light" },
2436
+ ],
2437
+ },
2438
+ {
2439
+ name: "contrastBand",
2440
+ kind: "select",
2441
+ label: "Contrast band",
2442
+ default: "aa",
2443
+ options: [
2444
+ { value: "aa", label: "AA" },
2445
+ { value: "aaa", label: "AAA" },
2446
+ ],
2447
+ },
2448
+ {
2449
+ name: "density",
2450
+ kind: "select",
2451
+ label: "Density",
2452
+ default: "normal",
2453
+ options: [
2454
+ { value: "compact", label: "compact" },
2455
+ { value: "normal", label: "normal" },
2456
+ { value: "comfortable", label: "comfortable" },
2457
+ ],
2458
+ },
2459
+ {
2460
+ name: "cues",
2461
+ kind: "select",
2462
+ label: "Cues",
2463
+ default: "color",
2464
+ options: [
2465
+ { value: "color", label: "color only" },
2466
+ { value: "redundant", label: "redundant markers" },
2467
+ ],
2468
+ },
2469
+ {
2470
+ name: "accentStrategy",
2471
+ kind: "select",
2472
+ label: "Accent strategy",
2473
+ options: [
2474
+ { value: "fan", label: "fan (flanks + complement)" },
2475
+ { value: "step", label: "step (even hue wheel)" },
2476
+ { value: "shade", label: "shade (one hue, four depths)" },
2477
+ { value: "duo", label: "duo (two brands + their shades)" },
2478
+ ],
2479
+ },
2480
+ { name: "vibrancy", kind: "range", label: "Vibrancy", min: 0, max: 1, step: 0.05, default: 0.5 },
2481
+ { name: "typeScale", kind: "range", label: "Type scale", min: 1.05, max: 1.6, step: 0.01, default: 1.2 },
2482
+ { name: "radiusScale", kind: "range", label: "Radius scale", min: 0, max: 3, step: 0.1, default: 1 },
2483
+ // The defaults are the engine's own constants, not a second copy of them: a slider that opens on a
2484
+ // value the derivation does not actually use is a lie the control surface tells about the engine.
2485
+ // `surfaceRamp` is signed and its sign is scheme-derived, so it declares a default per scheme; a
2486
+ // lone `+0.045` would open the control on an *ascending* stack under a light theme, which is the
2487
+ // exact inversion of what that theme derives.
2488
+ {
2489
+ name: "surfaceRamp",
2490
+ kind: "range",
2491
+ label: "Surface ramp",
2492
+ min: -0.06,
2493
+ max: 0.06,
2494
+ step: 0.005,
2495
+ default: DEFAULT_SURFACE_STEP,
2496
+ defaultByScheme: { dark: defaultSurfaceRamp("dark"), light: defaultSurfaceRamp("light") },
2497
+ },
2498
+ { name: "accentSplit", kind: "range", label: "Accent split", min: 0, max: 90, step: 1, default: DEFAULT_ACCENT_SPLIT, unit: "°" },
2499
+ { name: "accentShiftStep", kind: "range", label: "Accent shift step", min: 0, max: 180, step: 5, default: DEFAULT_SHIFT_STEP, unit: "°" },
2500
+ // Groups a consumer expands into a cluster of its own, not single scalar controls. They *declare*
2501
+ // that rather than being named in a list the engine keeps: an algorithm with its own composite knob
2502
+ // (a palette array, a per-role font map) has to be able to say so, and a name-keyed table of knob
2503
+ // identities held by the engine is exactly what `knobSpecs` exists to delete.
2504
+ { name: "anchors", kind: "composite", label: "Anchors" },
2505
+ { name: "fonts", kind: "composite", label: "Fonts" },
2506
+ ];
2507
+ const SHARED_KNOB_SPEC_BY_NAME = new Map(SHARED_KNOB_SPECS.map((spec) => [spec.name, spec]));
2508
+ /**
2509
+ * Resolve a declared knob-name list to the render specs a consumer needs. A name matching the shared
2510
+ * registry gets its domain; a novel knob resolves from `extra` when the algorithm supplies its own
2511
+ * spec. This is the one place a knob name becomes a renderable domain, so both baked and hosted
2512
+ * facades — and a host facade rebuilding from a name list — agree.
2513
+ *
2514
+ * A name that resolves to nothing degrades to a `text` control rather than vanishing. An algorithm
2515
+ * that declares a knob it never described still *reads* that knob, so dropping it silently would
2516
+ * leave the one thing the author asked for unreachable, with nothing on screen to say why. A
2517
+ * permissive text field is the honest floor: the knob stays editable, and the missing domain shows up
2518
+ * as a crude control instead of an absent one. `undeclared` marks it, so a discovery surface can say
2519
+ * *why* it looks crude — a typo'd knob name surfaces as a named gap rather than a mystery text box.
2520
+ */
2521
+ export function resolveKnobSpecs(names, extra = []) {
2522
+ const byName = new Map(extra.map((spec) => [spec.name, spec]));
2523
+ const out = [];
2524
+ for (const name of names) {
2525
+ const spec = byName.get(name) ?? SHARED_KNOB_SPEC_BY_NAME.get(name) ?? { name, kind: "text", undeclared: true };
2526
+ out.push(spec);
2527
+ }
2528
+ return out;
2529
+ }
2183
2530
  export const DEFAULT_ANCHORS = {
2184
2531
  bg: "#0f1115",
2185
2532
  fg: "#e8eaed",