@rien7/seji 0.0.0 → 0.6.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 (412) hide show
  1. package/bin/design-surface.mjs +6 -0
  2. package/bin/postinstall.mjs +19 -0
  3. package/bin/seji.mjs +573 -0
  4. package/dist/agent/host.d.mts +34 -0
  5. package/dist/agent/host.mjs +387 -0
  6. package/dist/agent/messages.d.mts +9 -0
  7. package/dist/agent/messages.mjs +70 -0
  8. package/dist/agent/runtimes.mjs +157 -0
  9. package/dist/cli/app.mjs +321 -0
  10. package/dist/cli/appScan.mjs +284 -0
  11. package/dist/cli/catalog.mjs +78 -0
  12. package/dist/cli/component.mjs +165 -0
  13. package/dist/cli/consolidate.mjs +159 -0
  14. package/dist/cli/cssImport.mjs +68 -0
  15. package/dist/cli/dev.mjs +335 -0
  16. package/dist/cli/doctor.mjs +306 -0
  17. package/dist/cli/init.mjs +338 -0
  18. package/dist/cli/legacyNames.mjs +266 -0
  19. package/dist/cli/migrate.mjs +163 -0
  20. package/dist/cli/prompt.mjs +34 -0
  21. package/dist/cli/propose.mjs +208 -0
  22. package/dist/cli/providers.mjs +344 -0
  23. package/dist/cli/reviewOps.mjs +110 -0
  24. package/dist/cli/semver.mjs +45 -0
  25. package/dist/cli/setup.mjs +357 -0
  26. package/dist/cli/sketches.mjs +47 -0
  27. package/dist/cli/skills.mjs +150 -0
  28. package/dist/cli/snapshot.mjs +107 -0
  29. package/dist/cli/tokenOps.mjs +120 -0
  30. package/dist/cli/types.mjs +191 -0
  31. package/dist/cli/updater.mjs +274 -0
  32. package/dist/components/astIndex.mjs +992 -0
  33. package/dist/components/ops.mjs +1069 -0
  34. package/dist/editor/AgentProposalCard.d.ts +10 -0
  35. package/dist/editor/AgentProposalCard.d.ts.map +1 -0
  36. package/dist/editor/AgentProposalCard.js +31 -0
  37. package/dist/editor/AgentProposalCard.js.map +1 -0
  38. package/dist/editor/App.d.ts +2 -0
  39. package/dist/editor/App.d.ts.map +1 -0
  40. package/dist/editor/App.js +2832 -0
  41. package/dist/editor/App.js.map +1 -0
  42. package/dist/editor/CanvasHud.d.ts +12 -0
  43. package/dist/editor/CanvasHud.d.ts.map +1 -0
  44. package/dist/editor/CanvasHud.js +13 -0
  45. package/dist/editor/CanvasHud.js.map +1 -0
  46. package/dist/editor/CanvasSurface.d.ts +31 -0
  47. package/dist/editor/CanvasSurface.d.ts.map +1 -0
  48. package/dist/editor/CanvasSurface.js +270 -0
  49. package/dist/editor/CanvasSurface.js.map +1 -0
  50. package/dist/editor/CommentPopover.d.ts +17 -0
  51. package/dist/editor/CommentPopover.d.ts.map +1 -0
  52. package/dist/editor/CommentPopover.js +62 -0
  53. package/dist/editor/CommentPopover.js.map +1 -0
  54. package/dist/editor/Comments.d.ts +13 -0
  55. package/dist/editor/Comments.d.ts.map +1 -0
  56. package/dist/editor/Comments.js +41 -0
  57. package/dist/editor/Comments.js.map +1 -0
  58. package/dist/editor/ComponentPage.d.ts +28 -0
  59. package/dist/editor/ComponentPage.d.ts.map +1 -0
  60. package/dist/editor/ComponentPage.js +55 -0
  61. package/dist/editor/ComponentPage.js.map +1 -0
  62. package/dist/editor/ComponentPanel.d.ts +38 -0
  63. package/dist/editor/ComponentPanel.d.ts.map +1 -0
  64. package/dist/editor/ComponentPanel.js +275 -0
  65. package/dist/editor/ComponentPanel.js.map +1 -0
  66. package/dist/editor/Glyph.d.ts +51 -0
  67. package/dist/editor/Glyph.d.ts.map +1 -0
  68. package/dist/editor/Glyph.js +50 -0
  69. package/dist/editor/Glyph.js.map +1 -0
  70. package/dist/editor/History.d.ts +7 -0
  71. package/dist/editor/History.d.ts.map +1 -0
  72. package/dist/editor/History.js +51 -0
  73. package/dist/editor/History.js.map +1 -0
  74. package/dist/editor/Inspector.d.ts +56 -0
  75. package/dist/editor/Inspector.d.ts.map +1 -0
  76. package/dist/editor/Inspector.js +510 -0
  77. package/dist/editor/Inspector.js.map +1 -0
  78. package/dist/editor/LazyMount.d.ts +10 -0
  79. package/dist/editor/LazyMount.d.ts.map +1 -0
  80. package/dist/editor/LazyMount.js +29 -0
  81. package/dist/editor/LazyMount.js.map +1 -0
  82. package/dist/editor/LocaleSwitch.d.ts +3 -0
  83. package/dist/editor/LocaleSwitch.d.ts.map +1 -0
  84. package/dist/editor/LocaleSwitch.js +9 -0
  85. package/dist/editor/LocaleSwitch.js.map +1 -0
  86. package/dist/editor/PreviewFrame.d.ts +10 -0
  87. package/dist/editor/PreviewFrame.d.ts.map +1 -0
  88. package/dist/editor/PreviewFrame.js +22 -0
  89. package/dist/editor/PreviewFrame.js.map +1 -0
  90. package/dist/editor/ProjectIndex.d.ts +12 -0
  91. package/dist/editor/ProjectIndex.d.ts.map +1 -0
  92. package/dist/editor/ProjectIndex.js +43 -0
  93. package/dist/editor/ProjectIndex.js.map +1 -0
  94. package/dist/editor/PromoteComponent.d.ts +28 -0
  95. package/dist/editor/PromoteComponent.d.ts.map +1 -0
  96. package/dist/editor/PromoteComponent.js +33 -0
  97. package/dist/editor/PromoteComponent.js.map +1 -0
  98. package/dist/editor/PromoteForm.d.ts +18 -0
  99. package/dist/editor/PromoteForm.d.ts.map +1 -0
  100. package/dist/editor/PromoteForm.js +35 -0
  101. package/dist/editor/PromoteForm.js.map +1 -0
  102. package/dist/editor/PromoteToken.d.ts +31 -0
  103. package/dist/editor/PromoteToken.d.ts.map +1 -0
  104. package/dist/editor/PromoteToken.js +94 -0
  105. package/dist/editor/PromoteToken.js.map +1 -0
  106. package/dist/editor/StatePreviews.d.ts +28 -0
  107. package/dist/editor/StatePreviews.d.ts.map +1 -0
  108. package/dist/editor/StatePreviews.js +113 -0
  109. package/dist/editor/StatePreviews.js.map +1 -0
  110. package/dist/editor/ValueCombo.d.ts +51 -0
  111. package/dist/editor/ValueCombo.d.ts.map +1 -0
  112. package/dist/editor/ValueCombo.js +260 -0
  113. package/dist/editor/ValueCombo.js.map +1 -0
  114. package/dist/editor/agent/AgentPanel.d.ts +19 -0
  115. package/dist/editor/agent/AgentPanel.d.ts.map +1 -0
  116. package/dist/editor/agent/AgentPanel.js +271 -0
  117. package/dist/editor/agent/AgentPanel.js.map +1 -0
  118. package/dist/editor/agent/Markdown.d.ts +5 -0
  119. package/dist/editor/agent/Markdown.d.ts.map +1 -0
  120. package/dist/editor/agent/Markdown.js +28 -0
  121. package/dist/editor/agent/Markdown.js.map +1 -0
  122. package/dist/editor/agent/agentApi.d.ts +106 -0
  123. package/dist/editor/agent/agentApi.d.ts.map +1 -0
  124. package/dist/editor/agent/agentApi.js +66 -0
  125. package/dist/editor/agent/agentApi.js.map +1 -0
  126. package/dist/editor/agent/toolLines.d.ts +38 -0
  127. package/dist/editor/agent/toolLines.d.ts.map +1 -0
  128. package/dist/editor/agent/toolLines.js +159 -0
  129. package/dist/editor/agent/toolLines.js.map +1 -0
  130. package/dist/editor/agent/useAgent.d.ts +15 -0
  131. package/dist/editor/agent/useAgent.d.ts.map +1 -0
  132. package/dist/editor/agent/useAgent.js +65 -0
  133. package/dist/editor/agent/useAgent.js.map +1 -0
  134. package/dist/editor/api.d.ts +378 -0
  135. package/dist/editor/api.d.ts.map +1 -0
  136. package/dist/editor/api.js +247 -0
  137. package/dist/editor/api.js.map +1 -0
  138. package/dist/editor/camera.d.ts +18 -0
  139. package/dist/editor/camera.d.ts.map +1 -0
  140. package/dist/editor/camera.js +40 -0
  141. package/dist/editor/camera.js.map +1 -0
  142. package/dist/editor/canvas.d.ts +25 -0
  143. package/dist/editor/canvas.d.ts.map +1 -0
  144. package/dist/editor/canvas.js +35 -0
  145. package/dist/editor/canvas.js.map +1 -0
  146. package/dist/editor/changes/ChangesPage.d.ts +25 -0
  147. package/dist/editor/changes/ChangesPage.d.ts.map +1 -0
  148. package/dist/editor/changes/ChangesPage.js +132 -0
  149. package/dist/editor/changes/ChangesPage.js.map +1 -0
  150. package/dist/editor/changes/changeModel.d.ts +25 -0
  151. package/dist/editor/changes/changeModel.d.ts.map +1 -0
  152. package/dist/editor/changes/changeModel.js +81 -0
  153. package/dist/editor/changes/changeModel.js.map +1 -0
  154. package/dist/editor/changes/changeState.d.mts +29 -0
  155. package/dist/editor/changes/changeState.mjs +187 -0
  156. package/dist/editor/chrome/EditorChrome.d.ts +49 -0
  157. package/dist/editor/chrome/EditorChrome.d.ts.map +1 -0
  158. package/dist/editor/chrome/EditorChrome.js +21 -0
  159. package/dist/editor/chrome/EditorChrome.js.map +1 -0
  160. package/dist/editor/drafts.d.ts +46 -0
  161. package/dist/editor/drafts.d.ts.map +1 -0
  162. package/dist/editor/drafts.js +38 -0
  163. package/dist/editor/drafts.js.map +1 -0
  164. package/dist/editor/i18n.d.ts +29 -0
  165. package/dist/editor/i18n.d.ts.map +1 -0
  166. package/dist/editor/i18n.js +2320 -0
  167. package/dist/editor/i18n.js.map +1 -0
  168. package/dist/editor/iconStroke.d.ts +6 -0
  169. package/dist/editor/iconStroke.d.ts.map +1 -0
  170. package/dist/editor/iconStroke.js +6 -0
  171. package/dist/editor/iconStroke.js.map +1 -0
  172. package/dist/editor/main.d.ts +2 -0
  173. package/dist/editor/main.d.ts.map +1 -0
  174. package/dist/editor/main.js +14 -0
  175. package/dist/editor/main.js.map +1 -0
  176. package/dist/editor/model.d.ts +16 -0
  177. package/dist/editor/model.d.ts.map +1 -0
  178. package/dist/editor/model.js +11 -0
  179. package/dist/editor/model.js.map +1 -0
  180. package/dist/editor/reasons.d.ts +44 -0
  181. package/dist/editor/reasons.d.ts.map +1 -0
  182. package/dist/editor/reasons.js +131 -0
  183. package/dist/editor/reasons.js.map +1 -0
  184. package/dist/editor/reviewLifecycle.d.ts +8 -0
  185. package/dist/editor/reviewLifecycle.d.ts.map +1 -0
  186. package/dist/editor/reviewLifecycle.js +21 -0
  187. package/dist/editor/reviewLifecycle.js.map +1 -0
  188. package/dist/editor/styles.css +8737 -0
  189. package/dist/editor/tokenMatch.d.ts +59 -0
  190. package/dist/editor/tokenMatch.d.ts.map +1 -0
  191. package/dist/editor/tokenMatch.js +198 -0
  192. package/dist/editor/tokenMatch.js.map +1 -0
  193. package/dist/editor/tokens/ConsolidatePage.d.ts +16 -0
  194. package/dist/editor/tokens/ConsolidatePage.d.ts.map +1 -0
  195. package/dist/editor/tokens/ConsolidatePage.js +244 -0
  196. package/dist/editor/tokens/ConsolidatePage.js.map +1 -0
  197. package/dist/editor/tokens/TokenActivity.d.ts +18 -0
  198. package/dist/editor/tokens/TokenActivity.d.ts.map +1 -0
  199. package/dist/editor/tokens/TokenActivity.js +18 -0
  200. package/dist/editor/tokens/TokenActivity.js.map +1 -0
  201. package/dist/editor/tokens/TokenDialogs.d.ts +26 -0
  202. package/dist/editor/tokens/TokenDialogs.d.ts.map +1 -0
  203. package/dist/editor/tokens/TokenDialogs.js +119 -0
  204. package/dist/editor/tokens/TokenDialogs.js.map +1 -0
  205. package/dist/editor/tokens/TokenList.d.ts +21 -0
  206. package/dist/editor/tokens/TokenList.d.ts.map +1 -0
  207. package/dist/editor/tokens/TokenList.js +98 -0
  208. package/dist/editor/tokens/TokenList.js.map +1 -0
  209. package/dist/editor/tokens/TokenPage.d.ts +25 -0
  210. package/dist/editor/tokens/TokenPage.d.ts.map +1 -0
  211. package/dist/editor/tokens/TokenPage.js +108 -0
  212. package/dist/editor/tokens/TokenPage.js.map +1 -0
  213. package/dist/editor/tokens/tokenModel.d.ts +35 -0
  214. package/dist/editor/tokens/tokenModel.d.ts.map +1 -0
  215. package/dist/editor/tokens/tokenModel.js +72 -0
  216. package/dist/editor/tokens/tokenModel.js.map +1 -0
  217. package/dist/editor/ui/Button.d.ts +3 -0
  218. package/dist/editor/ui/Button.d.ts.map +1 -0
  219. package/dist/editor/ui/Button.js +6 -0
  220. package/dist/editor/ui/Button.js.map +1 -0
  221. package/dist/editor/ui/CommentBox.d.ts +23 -0
  222. package/dist/editor/ui/CommentBox.d.ts.map +1 -0
  223. package/dist/editor/ui/CommentBox.js +41 -0
  224. package/dist/editor/ui/CommentBox.js.map +1 -0
  225. package/dist/editor/ui/Icon.d.ts +8 -0
  226. package/dist/editor/ui/Icon.d.ts.map +1 -0
  227. package/dist/editor/ui/Icon.js +6 -0
  228. package/dist/editor/ui/Icon.js.map +1 -0
  229. package/dist/editor/ui/IconButton.d.ts +11 -0
  230. package/dist/editor/ui/IconButton.d.ts.map +1 -0
  231. package/dist/editor/ui/IconButton.js +6 -0
  232. package/dist/editor/ui/IconButton.js.map +1 -0
  233. package/dist/editor/ui/NumberInput.d.ts +14 -0
  234. package/dist/editor/ui/NumberInput.d.ts.map +1 -0
  235. package/dist/editor/ui/NumberInput.js +6 -0
  236. package/dist/editor/ui/NumberInput.js.map +1 -0
  237. package/dist/editor/ui/PageLine.d.ts +14 -0
  238. package/dist/editor/ui/PageLine.d.ts.map +1 -0
  239. package/dist/editor/ui/PageLine.js +7 -0
  240. package/dist/editor/ui/PageLine.js.map +1 -0
  241. package/dist/editor/ui/SearchPicker.d.ts +41 -0
  242. package/dist/editor/ui/SearchPicker.d.ts.map +1 -0
  243. package/dist/editor/ui/SearchPicker.js +82 -0
  244. package/dist/editor/ui/SearchPicker.js.map +1 -0
  245. package/dist/editor/ui/Select.d.ts +19 -0
  246. package/dist/editor/ui/Select.d.ts.map +1 -0
  247. package/dist/editor/ui/Select.js +12 -0
  248. package/dist/editor/ui/Select.js.map +1 -0
  249. package/dist/editor/ui/TokenField.d.ts +14 -0
  250. package/dist/editor/ui/TokenField.d.ts.map +1 -0
  251. package/dist/editor/ui/TokenField.js +41 -0
  252. package/dist/editor/ui/TokenField.js.map +1 -0
  253. package/dist/editor/ui/TokenPicker.d.ts +31 -0
  254. package/dist/editor/ui/TokenPicker.d.ts.map +1 -0
  255. package/dist/editor/ui/TokenPicker.js +26 -0
  256. package/dist/editor/ui/TokenPicker.js.map +1 -0
  257. package/dist/editor/useBuildError.d.ts +7 -0
  258. package/dist/editor/useBuildError.d.ts.map +1 -0
  259. package/dist/editor/useBuildError.js +30 -0
  260. package/dist/editor/useBuildError.js.map +1 -0
  261. package/dist/editor/useLatestRequest.d.ts +22 -0
  262. package/dist/editor/useLatestRequest.d.ts.map +1 -0
  263. package/dist/editor/useLatestRequest.js +49 -0
  264. package/dist/editor/useLatestRequest.js.map +1 -0
  265. package/dist/editor-bundle/editor.css +2 -0
  266. package/dist/editor-bundle/editor.js +83 -0
  267. package/dist/editor-ui.d.ts +15 -0
  268. package/dist/editor-ui.d.ts.map +1 -0
  269. package/dist/editor-ui.js +14 -0
  270. package/dist/editor-ui.js.map +1 -0
  271. package/dist/inspector/runtime.d.ts +18 -0
  272. package/dist/inspector/runtime.d.ts.map +1 -0
  273. package/dist/inspector/runtime.js +1280 -0
  274. package/dist/inspector/runtime.js.map +1 -0
  275. package/dist/preview/main.d.ts +3 -0
  276. package/dist/preview/main.d.ts.map +1 -0
  277. package/dist/preview/main.js +320 -0
  278. package/dist/preview/main.js.map +1 -0
  279. package/dist/preview/preview.css +40 -0
  280. package/dist/runtime/index.d.ts +3 -0
  281. package/dist/runtime/index.d.ts.map +1 -0
  282. package/dist/runtime/index.js +2 -0
  283. package/dist/runtime/index.js.map +1 -0
  284. package/dist/shared/buildError.d.mts +27 -0
  285. package/dist/shared/buildError.mjs +141 -0
  286. package/dist/shared/cameraFit.d.mts +16 -0
  287. package/dist/shared/cameraFit.mjs +47 -0
  288. package/dist/shared/canvasLayout.d.mts +13 -0
  289. package/dist/shared/canvasLayout.mjs +171 -0
  290. package/dist/shared/commentShots.d.mts +12 -0
  291. package/dist/shared/commentShots.mjs +53 -0
  292. package/dist/shared/componentExtract.d.mts +43 -0
  293. package/dist/shared/componentExtract.mjs +136 -0
  294. package/dist/shared/componentMeta.d.mts +26 -0
  295. package/dist/shared/componentMeta.mjs +87 -0
  296. package/dist/shared/componentOps.d.mts +70 -0
  297. package/dist/shared/componentOps.mjs +407 -0
  298. package/dist/shared/componentTarget.d.mts +15 -0
  299. package/dist/shared/componentTarget.mjs +58 -0
  300. package/dist/shared/components.d.mts +30 -0
  301. package/dist/shared/components.mjs +106 -0
  302. package/dist/shared/consolidateCategories.d.mts +2 -0
  303. package/dist/shared/consolidateCategories.mjs +6 -0
  304. package/dist/shared/env.d.mts +4 -0
  305. package/dist/shared/env.mjs +18 -0
  306. package/dist/shared/gitChanges.d.mts +2 -0
  307. package/dist/shared/gitChanges.mjs +30 -0
  308. package/dist/shared/oklab.d.mts +6 -0
  309. package/dist/shared/oklab.mjs +56 -0
  310. package/dist/shared/optimizeEntries.d.mts +5 -0
  311. package/dist/shared/optimizeEntries.mjs +24 -0
  312. package/dist/shared/packages.d.mts +11 -0
  313. package/dist/shared/packages.mjs +96 -0
  314. package/dist/shared/projectFiles.d.mts +23 -0
  315. package/dist/shared/projectFiles.mjs +72 -0
  316. package/dist/shared/prompt.d.mts +20 -0
  317. package/dist/shared/prompt.mjs +201 -0
  318. package/dist/shared/proposals.d.mts +11 -0
  319. package/dist/shared/proposals.mjs +42 -0
  320. package/dist/shared/protocol.d.ts +122 -0
  321. package/dist/shared/protocol.d.ts.map +1 -0
  322. package/dist/shared/protocol.js +7 -0
  323. package/dist/shared/protocol.js.map +1 -0
  324. package/dist/shared/reviewArchive.d.mts +4 -0
  325. package/dist/shared/reviewArchive.mjs +19 -0
  326. package/dist/shared/reviewStore.d.mts +30 -0
  327. package/dist/shared/reviewStore.mjs +218 -0
  328. package/dist/shared/reviewVerify.d.mts +21 -0
  329. package/dist/shared/reviewVerify.mjs +158 -0
  330. package/dist/shared/sizeModes.d.mts +15 -0
  331. package/dist/shared/sizeModes.mjs +53 -0
  332. package/dist/shared/sketches.d.mts +10 -0
  333. package/dist/shared/sketches.mjs +64 -0
  334. package/dist/shared/snapshotCheck.d.mts +13 -0
  335. package/dist/shared/snapshotCheck.mjs +81 -0
  336. package/dist/shared/timeout.d.mts +1 -0
  337. package/dist/shared/timeout.mjs +15 -0
  338. package/dist/shared/tokens.d.ts +2 -0
  339. package/dist/shared/tokens.d.ts.map +1 -0
  340. package/dist/shared/tokens.js +2 -0
  341. package/dist/shared/tokens.js.map +1 -0
  342. package/dist/shared/types.d.ts +689 -0
  343. package/dist/shared/types.d.ts.map +1 -0
  344. package/dist/shared/types.js +13 -0
  345. package/dist/shared/types.js.map +1 -0
  346. package/dist/shared/wheelRouting.d.mts +9 -0
  347. package/dist/shared/wheelRouting.mjs +31 -0
  348. package/dist/shared/writeScope.mjs +96 -0
  349. package/dist/snapshots/diff.d.mts +28 -0
  350. package/dist/snapshots/diff.mjs +263 -0
  351. package/dist/snapshots/index.d.mts +110 -0
  352. package/dist/snapshots/index.mjs +638 -0
  353. package/dist/snapshots/render.d.mts +24 -0
  354. package/dist/snapshots/render.mjs +250 -0
  355. package/dist/snapshots/toolOps.d.mts +25 -0
  356. package/dist/snapshots/toolOps.mjs +69 -0
  357. package/dist/tokens/adapters/css.mjs +51 -0
  358. package/dist/tokens/adapters/cssInCode.mjs +314 -0
  359. package/dist/tokens/adapters/oxcShared.mjs +80 -0
  360. package/dist/tokens/adapters/preprocessor.mjs +63 -0
  361. package/dist/tokens/adapters/registry.mjs +53 -0
  362. package/dist/tokens/adapters/tailwindcss.mjs +424 -0
  363. package/dist/tokens/adapters/types.mjs +117 -0
  364. package/dist/tokens/consolidate/index.d.mts +42 -0
  365. package/dist/tokens/consolidate/index.mjs +111 -0
  366. package/dist/tokens/consolidate/normalize.mjs +479 -0
  367. package/dist/tokens/consolidate/plan.mjs +726 -0
  368. package/dist/tokens/consolidate/scan.mjs +928 -0
  369. package/dist/tokens/extract.mjs +441 -0
  370. package/dist/tokens/moduleData.d.mts +14 -0
  371. package/dist/tokens/moduleData.mjs +32 -0
  372. package/dist/tokens/opLock.d.mts +4 -0
  373. package/dist/tokens/opLock.mjs +108 -0
  374. package/dist/tokens/ops.d.mts +71 -0
  375. package/dist/tokens/ops.mjs +1511 -0
  376. package/dist/tokens/pipeline.mjs +813 -0
  377. package/dist/tokens/report.d.mts +47 -0
  378. package/dist/tokens/report.mjs +257 -0
  379. package/dist/tokens/rewrite/code.mjs +172 -0
  380. package/dist/tokens/rewrite/css.mjs +154 -0
  381. package/dist/tokens/rewrite/index.mjs +244 -0
  382. package/dist/tokens/rewrite/tailwind.mjs +288 -0
  383. package/dist/tokens/rewrite/text.mjs +116 -0
  384. package/dist/tokens/rewrite/value.mjs +115 -0
  385. package/dist/tokens/usage.d.mts +97 -0
  386. package/dist/tokens/usage.mjs +680 -0
  387. package/dist/vite/agent.d.ts +21 -0
  388. package/dist/vite/agent.d.ts.map +1 -0
  389. package/dist/vite/agent.js +165 -0
  390. package/dist/vite/agent.js.map +1 -0
  391. package/dist/vite/events.d.ts +27 -0
  392. package/dist/vite/events.d.ts.map +1 -0
  393. package/dist/vite/events.js +156 -0
  394. package/dist/vite/events.js.map +1 -0
  395. package/dist/vite/layout.d.ts +2 -0
  396. package/dist/vite/layout.d.ts.map +1 -0
  397. package/dist/vite/layout.js +4 -0
  398. package/dist/vite/layout.js.map +1 -0
  399. package/dist/vite/plugin.d.ts +40 -0
  400. package/dist/vite/plugin.d.ts.map +1 -0
  401. package/dist/vite/plugin.js +1255 -0
  402. package/dist/vite/plugin.js.map +1 -0
  403. package/dist/vite/requestGuard.d.mts +3 -0
  404. package/dist/vite/requestGuard.mjs +43 -0
  405. package/dist/vite/review.d.ts +11 -0
  406. package/dist/vite/review.d.ts.map +1 -0
  407. package/dist/vite/review.js +283 -0
  408. package/dist/vite/review.js.map +1 -0
  409. package/package.json +106 -1
  410. package/skills/seji/SKILL.md +395 -0
  411. package/skills/seji-authoring/SKILL.md +397 -0
  412. package/skills/seji-tokens/SKILL.md +432 -0
@@ -0,0 +1,59 @@
1
+ import type { TokenDef } from '../shared/tokens';
2
+ /** What a token (or a style field) measures; only same-kind tokens are offered. */
3
+ export type TokenKind = 'color' | 'space' | 'radius' | 'font-size' | 'line-height' | 'letter-spacing' | 'border-width' | 'shadow' | 'size' | 'other';
4
+ export declare const tokenPath: (token: TokenDef) => string;
5
+ export declare const isColorText: (value: string) => boolean;
6
+ export declare const isFormula: (token: TokenDef) => boolean;
7
+ export declare function tokenKindOf(token: TokenDef): TokenKind;
8
+ export declare const tokensOfKind: (tokens: TokenDef[], kind: TokenKind) => TokenDef[];
9
+ export declare const deprecationOf: (token: TokenDef) => {
10
+ replacement: undefined;
11
+ reason: string | (string & {
12
+ replacement?: string;
13
+ reason?: string;
14
+ });
15
+ } | {
16
+ replacement: undefined;
17
+ reason: undefined;
18
+ } | null;
19
+ /** A component should not use a primitive directly when a semantic alias exists. */
20
+ export declare const semanticFor: (token: TokenDef, tokens: TokenDef[]) => TokenDef | null;
21
+ export declare const byPath: (tokens: TokenDef[], path: string | undefined) => TokenDef | null;
22
+ export type Rgba = [number, number, number, number];
23
+ /** Resolve any CSS color (including color-mix) to channels via the browser. */
24
+ export declare function parseColor(value: string): Rgba | null;
25
+ export declare const toHex: (value: string) => string;
26
+ export declare const isTransparent: (value: string) => boolean;
27
+ /** Largest channel difference; ≤ 6 reads as the same color. */
28
+ export declare const colorDistance: (a: string, b: string) => number;
29
+ /**
30
+ * How far a candidate value is from the current one, for sorting pickers by closeness:
31
+ * colors by perceptual ΔE (OKLab × 100, shared/oklab.mjs, the scale consolidate uses), with
32
+ * `otherHue` when the hues differ; lengths by their px difference. `distance` is Infinity when
33
+ * the two cannot be compared; `delta` is the short label ("ΔE 1.6", "+2px", "=").
34
+ */
35
+ export declare function closeness(from: string, to: string): {
36
+ distance: number;
37
+ delta: string;
38
+ otherHue?: boolean;
39
+ };
40
+ export declare const pxOf: (value: string) => number | null;
41
+ /** Arithmetic typed into a numeric field, e.g. `10*2` or `(8+4)/2`. */
42
+ export declare function evalExpression(text: string): number | null;
43
+ export declare const isExpression: (text: string) => boolean;
44
+ export type Suggestion = {
45
+ type: 'exact';
46
+ token: TokenDef;
47
+ } | {
48
+ type: 'near';
49
+ token: TokenDef;
50
+ diff: number;
51
+ } | {
52
+ type: 'none';
53
+ };
54
+ /**
55
+ * Match a literal against the project's own tokens of the same kind. Formula
56
+ * tokens are shown with their computed value but never offered as "nearest".
57
+ */
58
+ export declare function suggestToken(kind: TokenKind, value: string, candidates: TokenDef[], resolve: (token: TokenDef) => string): Suggestion;
59
+ //# sourceMappingURL=tokenMatch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokenMatch.d.ts","sourceRoot":"","sources":["../../src/editor/tokenMatch.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAEhD,mFAAmF;AACnF,MAAM,MAAM,SAAS,GACjB,OAAO,GACP,OAAO,GACP,QAAQ,GACR,WAAW,GACX,aAAa,GACb,gBAAgB,GAChB,cAAc,GACd,QAAQ,GACR,MAAM,GACN,OAAO,CAAA;AAOX,eAAO,MAAM,SAAS,GAAI,OAAO,QAAQ,WACuB,CAAA;AAKhE,eAAO,MAAM,WAAW,GAAI,OAAO,MAAM,YAAmC,CAAA;AAE5E,eAAO,MAAM,SAAS,GAAI,OAAO,QAAQ,YAA0C,CAAA;AAEnF,wBAAgB,WAAW,CAAC,KAAK,EAAE,QAAQ,GAAG,SAAS,CAatD;AAED,eAAO,MAAM,YAAY,GAAI,QAAQ,QAAQ,EAAE,EAAE,MAAM,SAAS,eACT,CAAA;AAEvD,eAAO,MAAM,aAAa,GAAI,OAAO,QAAQ;;;sBA/BK,MAAM;iBAAW,MAAM;;;;;QAqCxE,CAAA;AAED,oFAAoF;AACpF,eAAO,MAAM,WAAW,GAAI,OAAO,QAAQ,EAAE,QAAQ,QAAQ,EAAE,oBAI9D,CAAA;AAED,eAAO,MAAM,MAAM,GAAI,QAAQ,QAAQ,EAAE,EAAE,MAAM,MAAM,GAAG,SAAS,oBAC6B,CAAA;AAMhG,MAAM,MAAM,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;AAInD,+EAA+E;AAC/E,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAmCrD;AAED,eAAO,MAAM,KAAK,GAAI,OAAO,MAAM,WAQlC,CAAA;AAED,eAAO,MAAM,aAAa,GAAI,OAAO,MAAM,YAG1C,CAAA;AAED,+DAA+D;AAC/D,eAAO,MAAM,aAAa,GAAI,GAAG,MAAM,EAAE,GAAG,MAAM,WAUjD,CAAA;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,CAiB3G;AAED,eAAO,MAAM,IAAI,GAAI,OAAO,MAAM,kBAGjC,CAAA;AAED,uEAAuE;AACvE,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAS1D;AAED,eAAO,MAAM,YAAY,GAAI,MAAM,MAAM,YAAgD,CAAA;AAMzF,MAAM,MAAM,UAAU,GAClB;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,QAAQ,CAAA;CAAE,GAClC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC/C;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAA;AAEpB;;;GAGG;AACH,wBAAgB,YAAY,CAC1B,IAAI,EAAE,SAAS,EACf,KAAK,EAAE,MAAM,EACb,UAAU,EAAE,QAAQ,EAAE,EACtB,OAAO,EAAE,CAAC,KAAK,EAAE,QAAQ,KAAK,MAAM,GACnC,UAAU,CA+BZ"}
@@ -0,0 +1,198 @@
1
+ import { deltaE, rgbToOklab, sameHue } from '../shared/oklab.mjs';
2
+ export const tokenPath = (token) => token.path ?? token.name.replace(/^--/, '').replace(/-/g, '.');
3
+ const COLOR_VALUE = /^(#|rgba?\(|hsla?\(|oklch\(|oklab\(|color\(|color-mix\()/i;
4
+ const FORMULA_VALUE = /(color-mix|calc|min|max|clamp)\(|var\(/i;
5
+ export const isColorText = (value) => COLOR_VALUE.test(value.trim());
6
+ export const isFormula = (token) => FORMULA_VALUE.test(token.value ?? '');
7
+ export function tokenKindOf(token) {
8
+ const path = tokenPath(token);
9
+ const value = token.value ?? '';
10
+ if (token.type === 'color' || (isColorText(value) && !/shadow/.test(path)))
11
+ return 'color';
12
+ if (/shadow/.test(path))
13
+ return 'shadow';
14
+ if (/radius/.test(path))
15
+ return 'radius';
16
+ if (/border-width|stroke-width/.test(path))
17
+ return 'border-width';
18
+ if (/^text\.|font-size/.test(path))
19
+ return 'font-size';
20
+ if (/line-height|leading/.test(path))
21
+ return 'line-height';
22
+ if (/letter-spacing|tracking/.test(path))
23
+ return 'letter-spacing';
24
+ if (/^space\.|spacing|gap|padding|inset/.test(path))
25
+ return 'space';
26
+ if (token.type === 'length')
27
+ return 'size';
28
+ return 'other';
29
+ }
30
+ export const tokensOfKind = (tokens, kind) => tokens.filter((token) => tokenKindOf(token) === kind);
31
+ export const deprecationOf = (token) => {
32
+ const value = token.deprecated;
33
+ if (!value)
34
+ return null;
35
+ if (typeof value === 'string')
36
+ return { replacement: undefined, reason: value };
37
+ if (typeof value === 'object')
38
+ return value;
39
+ return { replacement: undefined, reason: undefined };
40
+ };
41
+ /** A component should not use a primitive directly when a semantic alias exists. */
42
+ export const semanticFor = (token, tokens) => {
43
+ if (token.tier !== 'primitive')
44
+ return null;
45
+ const path = tokenPath(token);
46
+ return tokens.find((item) => item.tier === 'semantic' && item.alias === path) ?? null;
47
+ };
48
+ export const byPath = (tokens, path) => path ? tokens.find((token) => tokenPath(token) === path || token.name === path) ?? null : null;
49
+ let probe = null;
50
+ /** Resolve any CSS color (including color-mix) to channels via the browser. */
51
+ export function parseColor(value) {
52
+ const text = value.trim();
53
+ const hex = /^#([\da-f]{3,8})$/i.exec(text);
54
+ if (hex) {
55
+ const raw = hex[1];
56
+ const full = raw.length <= 4 ? raw.split('').map((char) => char + char).join('') : raw;
57
+ const channels = [0, 2, 4].map((index) => parseInt(full.slice(index, index + 2), 16));
58
+ const alpha = full.length === 8 ? parseInt(full.slice(6, 8), 16) / 255 : 1;
59
+ return [channels[0], channels[1], channels[2], alpha];
60
+ }
61
+ const rgb = /^rgba?\(\s*([\d.]+)[,\s]+([\d.]+)[,\s]+([\d.]+)(?:\s*[,/]\s*([\d.]+%?))?\s*\)$/i.exec(text);
62
+ if (rgb) {
63
+ const alpha = rgb[4] === undefined ? 1 : rgb[4].endsWith('%') ? Number.parseFloat(rgb[4]) / 100 : Number(rgb[4]);
64
+ return [Number(rgb[1]), Number(rgb[2]), Number(rgb[3]), alpha];
65
+ }
66
+ const srgb = /^color\(srgb\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)(?:\s*\/\s*([\d.]+))?\s*\)$/i.exec(text);
67
+ if (srgb) {
68
+ return [
69
+ Math.round(Number(srgb[1]) * 255),
70
+ Math.round(Number(srgb[2]) * 255),
71
+ Math.round(Number(srgb[3]) * 255),
72
+ srgb[4] === undefined ? 1 : Number(srgb[4]),
73
+ ];
74
+ }
75
+ if (!isColorText(text) || typeof document === 'undefined')
76
+ return null;
77
+ if (!probe) {
78
+ probe = document.createElement('span');
79
+ probe.style.display = 'none';
80
+ document.body.append(probe);
81
+ }
82
+ probe.style.color = '';
83
+ probe.style.color = text;
84
+ if (!probe.style.color)
85
+ return null;
86
+ const resolved = getComputedStyle(probe).color;
87
+ return resolved === text ? null : parseColor(resolved);
88
+ }
89
+ export const toHex = (value) => {
90
+ const color = parseColor(value);
91
+ if (!color)
92
+ return value;
93
+ const hex = color
94
+ .slice(0, 3)
95
+ .map((channel) => Math.round(channel).toString(16).padStart(2, '0'))
96
+ .join('');
97
+ return color[3] < 1 ? `#${hex}${Math.round(color[3] * 255).toString(16).padStart(2, '0')}` : `#${hex}`;
98
+ };
99
+ export const isTransparent = (value) => {
100
+ const color = parseColor(value);
101
+ return !color || color[3] === 0;
102
+ };
103
+ /** Largest channel difference; ≤ 6 reads as the same color. */
104
+ export const colorDistance = (a, b) => {
105
+ const left = parseColor(a);
106
+ const right = parseColor(b);
107
+ if (!left || !right)
108
+ return Number.POSITIVE_INFINITY;
109
+ return Math.max(Math.abs(left[0] - right[0]), Math.abs(left[1] - right[1]), Math.abs(left[2] - right[2]), Math.abs(left[3] - right[3]) * 255);
110
+ };
111
+ /**
112
+ * How far a candidate value is from the current one, for sorting pickers by closeness:
113
+ * colors by perceptual ΔE (OKLab × 100, shared/oklab.mjs, the scale consolidate uses), with
114
+ * `otherHue` when the hues differ; lengths by their px difference. `distance` is Infinity when
115
+ * the two cannot be compared; `delta` is the short label ("ΔE 1.6", "+2px", "=").
116
+ */
117
+ export function closeness(from, to) {
118
+ const a = parseColor(from);
119
+ const b = parseColor(to);
120
+ if (a && b) {
121
+ const lab = (color) => rgbToOklab([color[0] / 255, color[1] / 255, color[2] / 255]);
122
+ const labA = lab(a);
123
+ const labB = lab(b);
124
+ const distance = Math.round(deltaE(labA, labB, a[3], b[3]) * 10) / 10;
125
+ return { distance, delta: distance === 0 ? '=' : `ΔE ${distance}`, ...(sameHue(labA, labB) ? {} : { otherHue: true }) };
126
+ }
127
+ const pa = pxOf(from);
128
+ const pb = pxOf(to);
129
+ if (pa !== null && pb !== null) {
130
+ const diff = Math.round((pb - pa) * 100) / 100;
131
+ return { distance: Math.abs(diff), delta: diff === 0 ? '=' : `${diff > 0 ? '+' : '−'}${Math.abs(diff)}px` };
132
+ }
133
+ return { distance: from.trim().toLowerCase() === to.trim().toLowerCase() ? 0 : Number.POSITIVE_INFINITY, delta: '' };
134
+ }
135
+ export const pxOf = (value) => {
136
+ const match = /^(-?\d*\.?\d+)(px)?$/i.exec(value.trim());
137
+ return match ? Number(match[1]) : null;
138
+ };
139
+ /** Arithmetic typed into a numeric field, e.g. `10*2` or `(8+4)/2`. */
140
+ export function evalExpression(text) {
141
+ const source = text.trim().replace(/px$/i, '');
142
+ if (!source || !/^[\d\s.+\-*/()]+$/.test(source))
143
+ return null;
144
+ try {
145
+ const result = Number(new Function(`return (${source})`)());
146
+ return Number.isFinite(result) ? Math.round(result * 100) / 100 : null;
147
+ }
148
+ catch {
149
+ return null;
150
+ }
151
+ }
152
+ export const isExpression = (text) => /^[\d\s.+\-*/()]+(px)?$/i.test(text.trim());
153
+ /**
154
+ * Match a literal against the project's own tokens of the same kind. Formula
155
+ * tokens are shown with their computed value but never offered as "nearest".
156
+ */
157
+ export function suggestToken(kind, value, candidates, resolve) {
158
+ const usable = candidates.filter((token) => !deprecationOf(token));
159
+ if (kind === 'color') {
160
+ let best = null;
161
+ for (const token of usable) {
162
+ const diff = colorDistance(value, resolve(token));
163
+ if (diff === 0 && !isFormula(token))
164
+ return { type: 'exact', token };
165
+ if (isFormula(token))
166
+ continue;
167
+ if (!best || diff < best.diff || (diff === best.diff && token.tier === 'semantic')) {
168
+ best = { token, diff };
169
+ }
170
+ }
171
+ if (best && best.diff === 0)
172
+ return { type: 'exact', token: best.token };
173
+ if (best && best.diff <= 6)
174
+ return { type: 'near', token: best.token, diff: best.diff };
175
+ return { type: 'none' };
176
+ }
177
+ const number = pxOf(value);
178
+ if (number === null)
179
+ return { type: 'none' };
180
+ let best = null;
181
+ for (const token of usable) {
182
+ if (isFormula(token))
183
+ continue;
184
+ const other = pxOf(resolve(token));
185
+ if (other === null)
186
+ continue;
187
+ const diff = Math.abs(other - number);
188
+ if (!best || diff < best.diff || (diff === best.diff && token.tier === 'semantic')) {
189
+ best = { token, diff };
190
+ }
191
+ }
192
+ if (best && best.diff === 0)
193
+ return { type: 'exact', token: best.token };
194
+ if (best && best.diff <= 2)
195
+ return { type: 'near', token: best.token, diff: best.diff };
196
+ return { type: 'none' };
197
+ }
198
+ //# sourceMappingURL=tokenMatch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokenMatch.js","sourceRoot":"","sources":["../../src/editor/tokenMatch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAqBjE,MAAM,CAA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,IAAI,EAAE,MAAM,EAAE,CAAA;AACzB,CAAC","sourcesContent":["import { deltaE, rgbToOklab, sameHue } from '../shared/oklab.mjs'\nimport type { TokenDef } from '../shared/tokens'\n\n/** What a token (or a style field) measures; only same-kind tokens are offered. */\nexport type TokenKind =\n | 'color'\n | 'space'\n | 'radius'\n | 'font-size'\n | 'line-height'\n | 'letter-spacing'\n | 'border-width'\n | 'shadow'\n | 'size'\n | 'other'\n\n/** DTCG `$deprecated` as carried on a token definition when the pipeline emits it. */\ntype DeprecatedToken = TokenDef & {\n deprecated?: boolean | string | { replacement?: string; reason?: string }\n}\n\nexport const tokenPath = (token: TokenDef) =>\n token.path ?? token.name.replace(/^--/, '').replace(/-/g, '.')\n\nconst COLOR_VALUE = /^(#|rgba?\\(|hsla?\\(|oklch\\(|oklab\\(|color\\(|color-mix\\()/i\nconst FORMULA_VALUE = /(color-mix|calc|min|max|clamp)\\(|var\\(/i\n\nexport const isColorText = (value: string) => COLOR_VALUE.test(value.trim())\n\nexport const isFormula = (token: TokenDef) => FORMULA_VALUE.test(token.value ?? '')\n\nexport function tokenKindOf(token: TokenDef): TokenKind {\n const path = tokenPath(token)\n const value = token.value ?? ''\n if (token.type === 'color' || (isColorText(value) && !/shadow/.test(path))) return 'color'\n if (/shadow/.test(path)) return 'shadow'\n if (/radius/.test(path)) return 'radius'\n if (/border-width|stroke-width/.test(path)) return 'border-width'\n if (/^text\\.|font-size/.test(path)) return 'font-size'\n if (/line-height|leading/.test(path)) return 'line-height'\n if (/letter-spacing|tracking/.test(path)) return 'letter-spacing'\n if (/^space\\.|spacing|gap|padding|inset/.test(path)) return 'space'\n if (token.type === 'length') return 'size'\n return 'other'\n}\n\nexport const tokensOfKind = (tokens: TokenDef[], kind: TokenKind) =>\n tokens.filter((token) => tokenKindOf(token) === kind)\n\nexport const deprecationOf = (token: TokenDef) => {\n const value = (token as DeprecatedToken).deprecated\n if (!value) return null\n if (typeof value === 'string') return { replacement: undefined, reason: value }\n if (typeof value === 'object') return value\n return { replacement: undefined, reason: undefined }\n}\n\n/** A component should not use a primitive directly when a semantic alias exists. */\nexport const semanticFor = (token: TokenDef, tokens: TokenDef[]) => {\n if (token.tier !== 'primitive') return null\n const path = tokenPath(token)\n return tokens.find((item) => item.tier === 'semantic' && item.alias === path) ?? null\n}\n\nexport const byPath = (tokens: TokenDef[], path: string | undefined) =>\n path ? tokens.find((token) => tokenPath(token) === path || token.name === path) ?? null : null\n\n/* ------------------------------------------------------------------ */\n/* Values */\n/* ------------------------------------------------------------------ */\n\nexport type Rgba = [number, number, number, number]\n\nlet probe: HTMLElement | null = null\n\n/** Resolve any CSS color (including color-mix) to channels via the browser. */\nexport function parseColor(value: string): Rgba | null {\n const text = value.trim()\n const hex = /^#([\\da-f]{3,8})$/i.exec(text)\n if (hex) {\n const raw = hex[1]\n const full = raw.length <= 4 ? raw.split('').map((char) => char + char).join('') : raw\n const channels = [0, 2, 4].map((index) => parseInt(full.slice(index, index + 2), 16))\n const alpha = full.length === 8 ? parseInt(full.slice(6, 8), 16) / 255 : 1\n return [channels[0], channels[1], channels[2], alpha]\n }\n const rgb = /^rgba?\\(\\s*([\\d.]+)[,\\s]+([\\d.]+)[,\\s]+([\\d.]+)(?:\\s*[,/]\\s*([\\d.]+%?))?\\s*\\)$/i.exec(text)\n if (rgb) {\n const alpha = rgb[4] === undefined ? 1 : rgb[4].endsWith('%') ? Number.parseFloat(rgb[4]) / 100 : Number(rgb[4])\n return [Number(rgb[1]), Number(rgb[2]), Number(rgb[3]), alpha]\n }\n const srgb = /^color\\(srgb\\s+([\\d.]+)\\s+([\\d.]+)\\s+([\\d.]+)(?:\\s*\\/\\s*([\\d.]+))?\\s*\\)$/i.exec(text)\n if (srgb) {\n return [\n Math.round(Number(srgb[1]) * 255),\n Math.round(Number(srgb[2]) * 255),\n Math.round(Number(srgb[3]) * 255),\n srgb[4] === undefined ? 1 : Number(srgb[4]),\n ]\n }\n if (!isColorText(text) || typeof document === 'undefined') return null\n if (!probe) {\n probe = document.createElement('span')\n probe.style.display = 'none'\n document.body.append(probe)\n }\n probe.style.color = ''\n probe.style.color = text\n if (!probe.style.color) return null\n const resolved = getComputedStyle(probe).color\n return resolved === text ? null : parseColor(resolved)\n}\n\nexport const toHex = (value: string) => {\n const color = parseColor(value)\n if (!color) return value\n const hex = color\n .slice(0, 3)\n .map((channel) => Math.round(channel).toString(16).padStart(2, '0'))\n .join('')\n return color[3] < 1 ? `#${hex}${Math.round(color[3] * 255).toString(16).padStart(2, '0')}` : `#${hex}`\n}\n\nexport const isTransparent = (value: string) => {\n const color = parseColor(value)\n return !color || color[3] === 0\n}\n\n/** Largest channel difference; ≤ 6 reads as the same color. */\nexport const colorDistance = (a: string, b: string) => {\n const left = parseColor(a)\n const right = parseColor(b)\n if (!left || !right) return Number.POSITIVE_INFINITY\n return Math.max(\n Math.abs(left[0] - right[0]),\n Math.abs(left[1] - right[1]),\n Math.abs(left[2] - right[2]),\n Math.abs(left[3] - right[3]) * 255,\n )\n}\n\n/**\n * How far a candidate value is from the current one, for sorting pickers by closeness:\n * colors by perceptual ΔE (OKLab × 100, shared/oklab.mjs, the scale consolidate uses), with\n * `otherHue` when the hues differ; lengths by their px difference. `distance` is Infinity when\n * the two cannot be compared; `delta` is the short label (\"ΔE 1.6\", \"+2px\", \"=\").\n */\nexport function closeness(from: string, to: string): { distance: number; delta: string; otherHue?: boolean } {\n const a = parseColor(from)\n const b = parseColor(to)\n if (a && b) {\n const lab = (color: Rgba) => rgbToOklab([color[0] / 255, color[1] / 255, color[2] / 255])\n const labA = lab(a)\n const labB = lab(b)\n const distance = Math.round(deltaE(labA, labB, a[3], b[3]) * 10) / 10\n return { distance, delta: distance === 0 ? '=' : `ΔE ${distance}`, ...(sameHue(labA, labB) ? {} : { otherHue: true }) }\n }\n const pa = pxOf(from)\n const pb = pxOf(to)\n if (pa !== null && pb !== null) {\n const diff = Math.round((pb - pa) * 100) / 100\n return { distance: Math.abs(diff), delta: diff === 0 ? '=' : `${diff > 0 ? '+' : '−'}${Math.abs(diff)}px` }\n }\n return { distance: from.trim().toLowerCase() === to.trim().toLowerCase() ? 0 : Number.POSITIVE_INFINITY, delta: '' }\n}\n\nexport const pxOf = (value: string) => {\n const match = /^(-?\\d*\\.?\\d+)(px)?$/i.exec(value.trim())\n return match ? Number(match[1]) : null\n}\n\n/** Arithmetic typed into a numeric field, e.g. `10*2` or `(8+4)/2`. */\nexport function evalExpression(text: string): number | null {\n const source = text.trim().replace(/px$/i, '')\n if (!source || !/^[\\d\\s.+\\-*/()]+$/.test(source)) return null\n try {\n const result = Number(new Function(`return (${source})`)())\n return Number.isFinite(result) ? Math.round(result * 100) / 100 : null\n } catch {\n return null\n }\n}\n\nexport const isExpression = (text: string) => /^[\\d\\s.+\\-*/()]+(px)?$/i.test(text.trim())\n\n/* ------------------------------------------------------------------ */\n/* Suggestions */\n/* ------------------------------------------------------------------ */\n\nexport type Suggestion =\n | { type: 'exact'; token: TokenDef }\n | { type: 'near'; token: TokenDef; diff: number }\n | { type: 'none' }\n\n/**\n * Match a literal against the project's own tokens of the same kind. Formula\n * tokens are shown with their computed value but never offered as \"nearest\".\n */\nexport function suggestToken(\n kind: TokenKind,\n value: string,\n candidates: TokenDef[],\n resolve: (token: TokenDef) => string,\n): Suggestion {\n const usable = candidates.filter((token) => !deprecationOf(token))\n if (kind === 'color') {\n let best: { token: TokenDef; diff: number } | null = null\n for (const token of usable) {\n const diff = colorDistance(value, resolve(token))\n if (diff === 0 && !isFormula(token)) return { type: 'exact', token }\n if (isFormula(token)) continue\n if (!best || diff < best.diff || (diff === best.diff && token.tier === 'semantic')) {\n best = { token, diff }\n }\n }\n if (best && best.diff === 0) return { type: 'exact', token: best.token }\n if (best && best.diff <= 6) return { type: 'near', token: best.token, diff: best.diff }\n return { type: 'none' }\n }\n const number = pxOf(value)\n if (number === null) return { type: 'none' }\n let best: { token: TokenDef; diff: number } | null = null\n for (const token of usable) {\n if (isFormula(token)) continue\n const other = pxOf(resolve(token))\n if (other === null) continue\n const diff = Math.abs(other - number)\n if (!best || diff < best.diff || (diff === best.diff && token.tier === 'semantic')) {\n best = { token, diff }\n }\n }\n if (best && best.diff === 0) return { type: 'exact', token: best.token }\n if (best && best.diff <= 2) return { type: 'near', token: best.token, diff: best.diff }\n return { type: 'none' }\n}\n"]}
@@ -0,0 +1,16 @@
1
+ import type { TokenDef } from '../../shared/tokens';
2
+ import type { ComponentSummary } from '../../shared/types';
3
+ type Props = {
4
+ design: string;
5
+ planId: string | null;
6
+ components: ComponentSummary[];
7
+ tokens: TokenDef[];
8
+ values: Record<string, string>;
9
+ onOpenPlan: (id: string | null) => void;
10
+ /** The review item an apply recorded (the changes page shows it with its snapshots). */
11
+ onOpenChange: (itemId: string) => void;
12
+ };
13
+ /** 整合已有样式: scan a scope, decide each cluster, apply as one tool operation. */
14
+ export declare function ConsolidatePage({ design, planId, components, tokens, values, onOpenPlan, onOpenChange }: Props): import("react").JSX.Element;
15
+ export {};
16
+ //# sourceMappingURL=ConsolidatePage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConsolidatePage.d.ts","sourceRoot":"","sources":["../../../src/editor/tokens/ConsolidatePage.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,QAAQ,EAAa,MAAM,qBAAqB,CAAA;AAC9D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AA4B1D,KAAK,KAAK,GAAG;IACX,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,UAAU,EAAE,gBAAgB,EAAE,CAAA;IAC9B,MAAM,EAAE,QAAQ,EAAE,CAAA;IAClB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC9B,UAAU,EAAE,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAA;IACvC,wFAAwF;IACxF,YAAY,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAA;CACvC,CAAA;AAWD,8EAA8E;AAC9E,wBAAgB,eAAe,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,EAAE,KAAK,+BA4e9G"}
@@ -0,0 +1,244 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
3
+ import { Trash2Icon } from 'lucide-react';
4
+ import { CATEGORIES } from '../../shared/consolidateCategories.mjs';
5
+ import { applyConsolidatePlan, createConsolidatePlan, discardConsolidatePlan, loadConsolidatePlan, loadConsolidatePlans, revertConsolidatePlan, setConsolidateRow, } from '../api';
6
+ import { useI18n } from '../i18n';
7
+ import { errorText, issueTexts, refusalText, suggestionText, warningText } from '../reasons';
8
+ import { Button } from '../ui/Button';
9
+ import { Icon } from '../ui/Icon';
10
+ import { IconButton } from '../ui/IconButton';
11
+ import { TokenPicker } from '../ui/TokenPicker';
12
+ import { useLatestRequest } from '../useLatestRequest';
13
+ import { isTokenPath } from './tokenModel';
14
+ const ROW_ACTIONS = ['reuse', 'create', 'merge', 'skip'];
15
+ const isActive = (row) => row.action === 'reuse' || row.action === 'create' || row.action === 'merge';
16
+ const TIERS = ['primitive', 'semantic', 'component'];
17
+ const normalizeFile = (file) => file.replaceAll('\\', '/').replace(/^\.\//, '');
18
+ const isColor = (category) => category === 'color';
19
+ /** A row's "how much it changes the rendering" note, from the plan's computed deltas. */
20
+ function visibleNote(row) {
21
+ return row.visibleChange.map((change) => `${change.from} → ${change.to}`).join(', ');
22
+ }
23
+ /** 整合已有样式: scan a scope, decide each cluster, apply as one tool operation. */
24
+ export function ConsolidatePage({ design, planId, components, tokens, values, onOpenPlan, onOpenChange }) {
25
+ const { t } = useI18n();
26
+ const listSep = t('list.separator');
27
+ const [plans, setPlans] = useState(null);
28
+ const [plan, setPlan] = useState(null);
29
+ const [scope, setScope] = useState([]);
30
+ const [categories, setCategories] = useState(['color']);
31
+ const [busy, setBusy] = useState(null);
32
+ const [failure, setFailure] = useState(null);
33
+ const [rowErrors, setRowErrors] = useState({});
34
+ const refreshPlans = useCallback(() => {
35
+ loadConsolidatePlans().then((result) => setPlans(result.plans), (error) => setFailure(errorText(t, error)));
36
+ }, [t]);
37
+ useEffect(() => {
38
+ refreshPlans();
39
+ }, [refreshPlans]);
40
+ useEffect(() => {
41
+ let live = true;
42
+ setPlan(null);
43
+ setRowErrors({});
44
+ setFailure(null);
45
+ if (!planId)
46
+ return;
47
+ loadConsolidatePlan(planId).then((result) => live && setPlan(result), (error) => live && setFailure(errorText(t, error)));
48
+ return () => {
49
+ live = false;
50
+ };
51
+ // eslint-disable-next-line react-hooks/exhaustive-deps
52
+ }, [planId]);
53
+ // Component names by source file, to say which components a row touches.
54
+ const componentOf = useMemo(() => {
55
+ const map = new Map();
56
+ for (const component of components)
57
+ map.set(normalizeFile(component.file), component.name);
58
+ return (file) => map.get(normalizeFile(file)) ?? file.split('/').pop() ?? file;
59
+ }, [components]);
60
+ const scopeLabel = (files) => files.length ? files.map((file) => componentOf(file)).join(listSep) : t('consolidate.scope.all');
61
+ const run = (key, action) => {
62
+ setBusy(key);
63
+ setFailure(null);
64
+ return action()
65
+ .catch((error) => {
66
+ setFailure(errorText(t, error));
67
+ })
68
+ .finally(() => setBusy(null));
69
+ };
70
+ const scan = () => run('scan', async () => {
71
+ const created = await createConsolidatePlan({ scope, category: categories, design });
72
+ refreshPlans();
73
+ onOpenPlan(created.id);
74
+ });
75
+ const reload = async () => {
76
+ if (!plan)
77
+ return;
78
+ setPlan(await loadConsolidatePlan(plan.id));
79
+ };
80
+ const setRow = (row, input) => {
81
+ if (!plan)
82
+ return;
83
+ setBusy(`row:${row.id}`);
84
+ setRowErrors((current) => {
85
+ const next = { ...current };
86
+ delete next[row.id];
87
+ return next;
88
+ });
89
+ setConsolidateRow(plan.id, row.id, input)
90
+ .then(() => reload())
91
+ .catch((error) => setRowErrors((current) => ({ ...current, [row.id]: errorText(t, error) })))
92
+ .finally(() => setBusy(null));
93
+ };
94
+ const ready = Boolean(plan && plan.status !== 'applied' && plan.readiness?.ready);
95
+ const dryKey = plan && ready ? `${plan.id}@${plan.updatedAt}` : null;
96
+ const dry = useLatestRequest(dryKey, (key) => applyConsolidatePlan({ plan: key.slice(0, key.indexOf('@')), design, dryRun: true }));
97
+ const dryReport = dry.status === 'done' && dry.key === dryKey ? dry.result : null;
98
+ const apply = () => plan &&
99
+ run('apply', async () => {
100
+ const result = await applyConsolidatePlan({ plan: plan.id, design, snapshots: true });
101
+ refreshPlans();
102
+ if (result.itemId)
103
+ onOpenChange(result.itemId);
104
+ else
105
+ await reload();
106
+ });
107
+ const discard = (id) => run(`discard:${id}`, async () => {
108
+ await discardConsolidatePlan(id);
109
+ refreshPlans();
110
+ if (plan?.id === id)
111
+ onOpenPlan(null);
112
+ });
113
+ const revert = () => plan &&
114
+ run('revert', async () => {
115
+ await revertConsolidatePlan(plan.id);
116
+ refreshPlans();
117
+ await reload();
118
+ });
119
+ const blocked = new Map((plan?.readiness?.blocked ?? []).map((entry) => [entry.row, issueTexts(t, entry.problems, entry.issues)]));
120
+ const active = plan?.rows.filter(isActive) ?? [];
121
+ const undecidedRows = plan?.rows.filter((row) => row.action === 'undecided') ?? [];
122
+ const counts = {
123
+ reuse: active.filter((row) => row.action === 'reuse').length,
124
+ create: active.filter((row) => row.action === 'create').length,
125
+ merge: active.filter((row) => row.action === 'merge').length,
126
+ visible: active.filter((row) => row.visibleChange.length > 0).length + undecidedRows.length,
127
+ undecided: undecidedRows.length,
128
+ };
129
+ const distinctValues = plan?.rows.reduce((total, row) => total + row.values.length, 0) ?? 0;
130
+ const byPath = useMemo(() => new Map(tokens.flatMap((entry) => (entry.path ? [[entry.path, entry]] : []))), [tokens]);
131
+ // What a reuse / merge row may point at: the row's own tokens and suggestions first, then every
132
+ // token of the same category (`consolidate show` → `candidates`), searchable.
133
+ const tokenOptions = (row) => {
134
+ const names = new Set();
135
+ for (const entry of row.tokens)
136
+ if (!entry.deprecated)
137
+ names.add(entry.path);
138
+ if (row.suggestion.token)
139
+ names.add(row.suggestion.token);
140
+ for (const entry of row.suggestion.alternatives ?? [])
141
+ names.add(entry.token);
142
+ if (row.token)
143
+ names.add(row.token);
144
+ for (const name of plan?.candidates?.[row.category] ?? [])
145
+ names.add(name);
146
+ return [...names].flatMap((name) => {
147
+ const def = byPath.get(name);
148
+ return def ? [def] : [];
149
+ });
150
+ };
151
+ const resolveToken = useCallback((entry) => values[entry.name] ?? entry.value ?? '', [values]);
152
+ const swatch = (category, value) => isColor(category) ? _jsx("span", { "aria-hidden": "true", className: "token-color", style: { background: value } }) : null;
153
+ return (_jsxs("div", { className: "consolidate-page", "data-consolidate-page": true, children: [_jsxs("header", { className: "consolidate-head", children: [_jsxs("div", { children: [_jsx("p", { className: "panel-kicker", children: t('consolidate.title') }), _jsx("h1", { children: plan
154
+ ? t('consolidate.planTitle', {
155
+ categories: plan.options.categories.map((entry) => t(`consolidate.category.${entry}`)).join(listSep),
156
+ })
157
+ : t('consolidate.newTitle') }), plan ? _jsx("p", { className: "token-page-meta", children: plan.id }) : null] }), plan ? (_jsxs("dl", { className: "consolidate-scope", children: [_jsx("dt", { children: t('consolidate.scope') }), _jsx("dd", { title: plan.options.scope.join('\n'), children: scopeLabel(plan.options.scope) }), _jsx("dt", { children: t('consolidate.categories') }), _jsx("dd", { children: plan.options.categories.map((entry) => t(`consolidate.category.${entry}`)).join(listSep) })] })) : null] }), !planId ? (_jsxs(_Fragment, { children: [_jsxs("section", { className: "token-card consolidate-form", "data-consolidate-form": true, children: [_jsxs("div", { className: "token-card-head", children: [_jsx("h2", { children: t('consolidate.scope') }), _jsx("span", { children: scope.length ? t('consolidate.scope.count', { count: scope.length }) : t('consolidate.scope.all') })] }), _jsxs("div", { className: "consolidate-chips", role: "group", "aria-label": t('consolidate.scope'), children: [_jsx("button", { "aria-pressed": scope.length === 0, className: scope.length === 0 ? 'component-filter is-on' : 'component-filter', type: "button", onClick: () => setScope([]), children: t('consolidate.scope.all') }), components.map((component) => {
158
+ const on = scope.includes(component.file);
159
+ return (_jsx("button", { "aria-pressed": on, className: on ? 'component-filter is-on' : 'component-filter', title: component.file, type: "button", onClick: () => setScope((current) => on ? current.filter((file) => file !== component.file) : [...current, component.file]), children: component.name }, component.name));
160
+ })] }), _jsx("div", { className: "token-card-head", children: _jsx("h2", { children: t('consolidate.categories') }) }), _jsx("div", { className: "consolidate-chips", role: "group", "aria-label": t('consolidate.categories'), children: CATEGORIES.map((category) => {
161
+ const on = categories.includes(category);
162
+ return (_jsx("button", { "aria-pressed": on, className: on ? 'component-filter is-on' : 'component-filter', type: "button", onClick: () => setCategories((current) => on ? current.filter((entry) => entry !== category) : [...current, category]), children: t(`consolidate.category.${category}`) }, category));
163
+ }) }), _jsx("p", { className: "token-dialog-note", children: t('consolidate.scanHint') }), _jsx("div", { className: "token-edit-actions", children: _jsx(Button, { className: "primary-button", "data-consolidate-scan": true, disabled: busy !== null || categories.length === 0, type: "button", onClick: scan, children: busy === 'scan' ? t('consolidate.scanning') : t('consolidate.scan') }) })] }), _jsxs("section", { className: "token-card", "data-consolidate-plans": true, children: [_jsx("div", { className: "token-card-head", children: _jsx("h2", { children: t('consolidate.plans') }) }), plans === null ? (_jsx("p", { className: "panel-empty", children: t('tokens.page.loading') })) : plans.length === 0 ? (_jsx("p", { className: "panel-empty", children: t('consolidate.noPlans') })) : (_jsx("ul", { className: "consolidate-plans", children: plans.map((entry) => (_jsxs("li", { children: [_jsx("button", { className: "token-link", type: "button", onClick: () => onOpenPlan(entry.id), children: (entry.categories ?? []).map((category) => t(`consolidate.category.${category}`)).join(listSep) || entry.id }), _jsx("span", { children: scopeLabel(entry.scope ?? []) }), _jsx("span", { className: `token-state is-${entry.status ?? 'draft'}`, children: t(`consolidate.status.${entry.status ?? 'draft'}`) }), _jsx("em", { children: t('consolidate.rowCount', { count: entry.rows ?? 0 }) }), entry.status !== 'applied' ? (_jsx(IconButton, { className: "icon-button", disabled: busy !== null, label: t('consolidate.discard'), onClick: () => discard(entry.id), children: _jsx(Icon, { icon: Trash2Icon, size: 12 }) })) : null] }, entry.id))) }))] })] })) : !plan ? (_jsx("p", { className: "panel-empty", children: failure ?? t('tokens.page.loading') })) : (_jsxs(_Fragment, { children: [_jsxs("section", { className: "token-card consolidate-table-card", "data-consolidate-plan": plan.id, children: [_jsxs("div", { className: "token-card-head", children: [_jsx("h2", { children: t('consolidate.summary', {
164
+ occurrences: plan.counts.occurrences,
165
+ values: distinctValues,
166
+ rows: plan.rows.length,
167
+ }) }), _jsx("span", { children: t('consolidate.summaryActions', counts) })] }), plan.rows.length === 0 ? (_jsx("p", { className: "panel-empty", children: t('consolidate.noRows') })) : (_jsxs("table", { className: "consolidate-table", children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { children: t('consolidate.col.values') }), _jsx("th", { children: t('consolidate.col.count') }), _jsx("th", { children: t('consolidate.col.components') }), _jsx("th", { children: t('consolidate.col.suggestion') }), _jsx("th", { children: t('consolidate.col.note') }), _jsx("th", { children: t('consolidate.col.decision') })] }) }), _jsx("tbody", { children: plan.rows.map((row) => {
168
+ const files = [...new Set(row.values.flatMap((value) => value.files))];
169
+ const problems = blocked.get(row.id) ?? [];
170
+ const locked = plan.status === 'applied' || busy !== null;
171
+ return (_jsxs("tr", { className: [
172
+ row.action === 'skip' ? 'is-skipped' : '',
173
+ row.action === 'undecided' ? 'is-undecided' : '',
174
+ row.visibleChange.length ? 'is-visible' : '',
175
+ ]
176
+ .filter(Boolean)
177
+ .join(' '), "data-consolidate-row": row.id, children: [_jsx("td", { children: _jsxs("span", { className: "consolidate-values", children: [row.values.length === 0
178
+ ? row.tokens.map((entry) => (_jsxs("span", { title: entry.value, children: [swatch(row.category, entry.value), _jsx("code", { className: "is-token", children: entry.path })] }, entry.path)))
179
+ : null, row.values.map((value) => (_jsxs("span", { title: value.spellings.join(', '), children: [swatch(row.category, value.example), _jsx("code", { children: value.example })] }, value.canonical)))] }) }), _jsx("td", { children: row.counts.occurrences }), _jsx("td", { title: files.join('\n'), children: [...new Set(files.map(componentOf))].join(listSep) }), _jsx("td", { children: row.action === 'create' ? (_jsx(CreateFields, { disabled: locked, row: row, onCommit: (input) => setRow(row, input) })) : row.action === 'reuse' || row.action === 'merge' ? (_jsxs("span", { className: "consolidate-target", children: [_jsx(TokenPicker, { className: "consolidate-token", color: isColor(row.category), disabled: locked, label: t('consolidate.col.suggestion'), resolve: resolveToken, tokens: tokenOptions(row), value: row.token ?? '', onChange: (token) => setRow(row, { token }) }), row.action === 'merge' && row.merge?.length ? (_jsx("small", { children: t('consolidate.mergeFrom', { tokens: row.merge.join(listSep) }) })) : null] })) : (_jsx("span", { className: "token-dryrun-muted", children: "\u2014" })) }), _jsxs("td", { className: "consolidate-note", children: [_jsx("span", { children: suggestionText(t, row.suggestion) }), row.suggestion.note ? (_jsx("span", { children: row.suggestion.noteCode
180
+ ? t(`suggest.${row.suggestion.noteCode}`, undefined, row.suggestion.note)
181
+ : row.suggestion.note })) : null, row.action === 'undecided' ? (
182
+ // The proposal changes the rendering: nothing is pre-selected.
183
+ _jsxs("span", { className: "consolidate-undecided", "data-consolidate-undecided": true, children: [_jsx("strong", { children: t('consolidate.undecided') }), t('consolidate.visible', { change: visibleNote(row) })] })) : row.visibleChange.length ? (_jsxs("label", { className: "consolidate-visible", children: [_jsx("input", { checked: row.acceptVisibleChange, disabled: locked, type: "checkbox", onChange: (event) => setRow(row, { acceptVisibleChange: event.target.checked }) }), t('consolidate.visible', { change: visibleNote(row) })] })) : null, (row.warnings ?? []).map((warning) => (_jsx("span", { className: "is-warning", title: warning, children: warningText(t, warning) }, warning))), row.counts.leftovers ? (_jsx("span", { className: "token-dryrun-muted", children: t('consolidate.leftovers', { count: row.counts.leftovers }) })) : null, problems.map((problem) => (_jsx("span", { className: "is-error", children: problem }, problem))), rowErrors[row.id] ? _jsx("span", { className: "is-error", children: rowErrors[row.id] }) : null] }), _jsx("td", { children: _jsx("span", { className: "consolidate-decision", role: "group", "aria-label": t('consolidate.col.decision'), children: ROW_ACTIONS.map((action) => (_jsx("button", { "aria-pressed": row.action === action, className: row.action === action ? `is-on is-${action}` : '', "data-consolidate-action": action, disabled: locked || (action === 'merge' && row.tokens.length < 2 && row.suggestion.action !== 'merge'), type: "button", onClick: () => row.action !== action && setRow(row, { action }), children: t(`consolidate.action.${action}`) }, action))) }) })] }, row.id));
184
+ }) })] }))] }), plan.status === 'applied' ? (_jsxs("section", { className: "consolidate-footer", "data-consolidate-applied": true, children: [_jsxs("p", { children: [_jsx("strong", { children: t('consolidate.applied') }), ' ', t('consolidate.appliedHint', { batch: plan.applied?.batchId ?? '' })] }), _jsxs("div", { className: "token-edit-actions", children: [plan.applied?.itemId ? (_jsx(Button, { className: "button", type: "button", onClick: () => onOpenChange(plan.applied.itemId), children: t('consolidate.openChange') })) : null, _jsx(Button, { className: "button is-danger", disabled: busy !== null, type: "button", onClick: revert, children: busy === 'revert' ? t('changesPage.reverting') : t('consolidate.revert') })] })] })) : (_jsxs("section", { className: "consolidate-footer", "data-consolidate-confirm": true, children: [_jsxs("p", { children: [_jsx("strong", { children: t('consolidate.willHappen') }), ' ', !ready
185
+ ? t('consolidate.notReady', { count: blocked.size })
186
+ : dryReport
187
+ ? dryReport.refused
188
+ ? refusalText(t, dryReport)
189
+ : t('consolidate.dryCounts', {
190
+ changed: dryReport.counts?.changed ?? 0,
191
+ left: dryReport.counts?.leftovers ?? 0,
192
+ created: counts.create,
193
+ merged: counts.merge,
194
+ visible: counts.visible,
195
+ })
196
+ : dry.status === 'error'
197
+ ? errorText(t, dry.cause)
198
+ : t('tokens.dry.loading')] }), _jsxs("div", { className: "token-edit-actions", children: [_jsx(Button, { className: "text-button", disabled: busy !== null, type: "button", onClick: () => discard(plan.id), children: t('consolidate.discard') }), _jsx(Button, { className: "button", disabled: busy !== null, type: "button", onClick: () => onOpenPlan(null), children: t('consolidate.keepDraft') }), _jsx(Button, { className: "primary-button", "data-consolidate-apply": true, disabled: busy !== null || !ready || !dryReport || Boolean(dryReport.refused), type: "button", onClick: apply, children: busy === 'apply' ? t('tokens.op.runningSnapshots') : t('consolidate.apply') })] })] }))] })), failure && plan ? _jsx("p", { className: "token-dialog-note is-error", children: failure }) : null, failure && !planId ? _jsx("p", { className: "token-dialog-note is-error", children: failure }) : null] }));
199
+ }
200
+ /** Name, tier and usage note of a token a row creates (the tool never invents names). */
201
+ function CreateFields({ row, disabled, onCommit, }) {
202
+ const { t } = useI18n();
203
+ const [name, setName] = useState(row.name ?? '');
204
+ const [description, setDescription] = useState(row.description ?? '');
205
+ // The last value sent per field: Enter commits and blurs, and the blur must not send it again.
206
+ const sent = useRef({ name: row.name ?? '', description: row.description ?? '' });
207
+ useEffect(() => {
208
+ setName(row.name ?? '');
209
+ sent.current.name = row.name ?? '';
210
+ }, [row.name]);
211
+ useEffect(() => {
212
+ setDescription(row.description ?? '');
213
+ sent.current.description = row.description ?? '';
214
+ }, [row.description]);
215
+ const nameValid = !name || isTokenPath(name);
216
+ const commitName = () => {
217
+ if (!nameValid || name === sent.current.name)
218
+ return;
219
+ sent.current.name = name;
220
+ onCommit({ name });
221
+ };
222
+ const commitDescription = () => {
223
+ const next = description.trim();
224
+ if (next === sent.current.description)
225
+ return;
226
+ sent.current.description = next;
227
+ onCommit({ description: next });
228
+ };
229
+ const prefixes = Object.entries(row.suggestion.naming?.tiers ?? {})
230
+ .flatMap(([tier, entries]) => entries.slice(0, 2).map((entry) => `${entry.prefix}… (${t(`tokens.tier.${tier}`)})`))
231
+ .join(' · ');
232
+ return (_jsxs("span", { className: "consolidate-create", children: [_jsx("input", { "aria-invalid": !nameValid, "aria-label": t('tokenDialog.name'), className: "input", "data-consolidate-name": true, disabled: disabled, placeholder: prefixes || 'color.name', title: row.suggestion.naming?.rule ?? prefixes, value: name, onBlur: commitName, onChange: (event) => setName(event.target.value.trim()), onKeyDown: (event) => {
233
+ if (event.key === 'Enter') {
234
+ commitName();
235
+ event.currentTarget.blur();
236
+ }
237
+ } }), _jsx("span", { className: "ins-seg is-text", role: "group", "aria-label": t('tokenDialog.tier'), children: TIERS.map((tier) => (_jsx("button", { "aria-pressed": row.tier === tier, className: row.tier === tier ? 'is-on' : '', disabled: disabled, type: "button", onClick: () => onCommit({ tier }), children: t(`tokens.tier.${tier}`) }, tier))) }), _jsx("input", { "aria-label": t('tokenDialog.description'), className: "input", disabled: disabled, placeholder: t('tokens.health.promoteDescription'), value: description, onBlur: commitDescription, onChange: (event) => setDescription(event.target.value), onKeyDown: (event) => {
238
+ if (event.key === 'Enter') {
239
+ commitDescription();
240
+ event.currentTarget.blur();
241
+ }
242
+ } }), _jsx("small", { children: t('consolidate.createValue', { value: row.value ?? row.values[0]?.example ?? '' }) })] }));
243
+ }
244
+ //# sourceMappingURL=ConsolidatePage.js.map