@metamorph-labs/polymorph 1.0.18 → 1.0.19

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 (319) hide show
  1. package/CHANGELOG.md +242 -0
  2. package/dist/design/systems/desktop.json +1 -1
  3. package/dist/design/systems/dew.json +1 -1
  4. package/dist/design/systems/flint.json +1 -1
  5. package/dist/design/systems/glassmorphic.json +1 -1
  6. package/dist/design/systems/harbor.json +1 -1
  7. package/dist/design/systems/journal.json +1 -1
  8. package/dist/design/systems/pastel.json +1 -1
  9. package/dist/design/systems/pebble.json +1 -1
  10. package/dist/design/systems/plain.json +1 -1
  11. package/dist/design/systems/pop.json +1 -1
  12. package/dist/design/systems/press.json +1 -1
  13. package/dist/packages/angular-ui/src/ai/ArtifactPane.ts +15 -4
  14. package/dist/packages/angular-ui/src/ai/PromptInput.ts +3 -1
  15. package/dist/packages/angular-ui/src/archetypes/Dashboard.ts +38 -20
  16. package/dist/packages/angular-ui/src/archetypes/dashboard.states.ts +52 -0
  17. package/dist/packages/angular-ui/src/controls/ColorInput.ts +62 -34
  18. package/dist/packages/angular-ui/src/controls/Combobox.ts +28 -7
  19. package/dist/packages/angular-ui/src/controls/DatePicker.ts +12 -11
  20. package/dist/packages/angular-ui/src/controls/DateRangePicker.ts +22 -17
  21. package/dist/packages/angular-ui/src/controls/DateRangePickerRangeCalendar.ts +3 -2
  22. package/dist/packages/angular-ui/src/controls/FileUpload.ts +18 -12
  23. package/dist/packages/angular-ui/src/controls/FileUploadRow.ts +24 -4
  24. package/dist/packages/angular-ui/src/controls/MultiSelect.ts +49 -12
  25. package/dist/packages/angular-ui/src/controls/NumberInput.ts +27 -3
  26. package/dist/packages/angular-ui/src/controls/PhoneInput.ts +9 -5
  27. package/dist/packages/angular-ui/src/controls/Select.ts +36 -7
  28. package/dist/packages/angular-ui/src/controls/TagInput.ts +61 -7
  29. package/dist/packages/angular-ui/src/controls/TimeInput.ts +15 -1
  30. package/dist/packages/angular-ui/src/controls/select.states.ts +79 -58
  31. package/dist/packages/angular-ui/src/overlays/Command.ts +50 -13
  32. package/dist/packages/angular-ui/src/overlays/CommandPanel.ts +11 -7
  33. package/dist/packages/angular-ui/src/overlays/ToastViewport.ts +1 -1
  34. package/dist/packages/angular-ui/src/structure/CodeBlock.ts +18 -4
  35. package/dist/packages/angular-ui/src/structure/Stat.ts +295 -84
  36. package/dist/packages/angular-ui/src/structure/stat.states.ts +116 -0
  37. package/dist/packages/cli/src/agents.js +4 -3
  38. package/dist/packages/cli/src/apply.js +43 -18
  39. package/dist/packages/cli/src/check.js +4 -0
  40. package/dist/packages/cli/src/cli.js +6 -2
  41. package/dist/packages/cli/src/elements.js +12 -2
  42. package/dist/packages/cli/src/emit.js +43 -8
  43. package/dist/packages/cli/src/readings.js +29 -3
  44. package/dist/packages/cli/src/skills/bridge.js +1197 -0
  45. package/dist/packages/cli/src/skills/facts.js +190 -0
  46. package/dist/packages/cli/src/skills/native.js +1580 -0
  47. package/dist/packages/cli/src/skills/rules.js +199 -0
  48. package/dist/packages/cli/src/skills/runtime.js +1020 -0
  49. package/dist/packages/cli/src/skills/screen-charts.js +334 -0
  50. package/dist/packages/cli/src/skills/screen-chat.js +247 -0
  51. package/dist/packages/cli/src/skills/screen-code.js +565 -0
  52. package/dist/packages/cli/src/skills/screen-rich-text.js +305 -0
  53. package/dist/packages/cli/src/skills/screen.js +378 -0
  54. package/dist/packages/cli/src/skills/setup-packages.js +307 -0
  55. package/dist/packages/cli/src/skills/setup.js +125 -0
  56. package/dist/packages/cli/src/skills/theme-documents.js +351 -0
  57. package/dist/packages/cli/src/skills/theme.js +208 -0
  58. package/dist/packages/cli/src/skills.js +13 -794
  59. package/dist/packages/cli/src/theme.js +42 -1
  60. package/dist/packages/cli/src/tool-verbs.js +19 -4
  61. package/dist/packages/cli/src/verbs.js +28 -2
  62. package/dist/packages/elements-ui/dist/cdn/chunks/{AppShellUserCard-0eCCnnN_.js → AppShellUserCard-XT4br4fr.js} +1 -1
  63. package/dist/packages/elements-ui/dist/cdn/chunks/{AreaChart-DftfzLG0.js → AreaChart-CXNFfbJ8.js} +1 -1
  64. package/dist/packages/elements-ui/dist/cdn/chunks/ArtifactPane-Pr9_K2uM.js +1 -0
  65. package/dist/packages/elements-ui/dist/cdn/chunks/{Avatar-DcdMgxgY.js → Avatar-3WXoBPLv.js} +1 -1
  66. package/dist/packages/elements-ui/dist/cdn/chunks/{Avatar-DcuvZwe7.js → Avatar-BKqjM8qW.js} +1 -1
  67. package/dist/packages/elements-ui/dist/cdn/chunks/{AvatarButton-D5XKVduu.js → AvatarButton-BasMQCSM.js} +1 -1
  68. package/dist/packages/elements-ui/dist/cdn/chunks/{AvatarGroup-DgFwJUNO.js → AvatarGroup-COch2-O0.js} +1 -1
  69. package/dist/packages/elements-ui/dist/cdn/chunks/{BarChart-myuR0aHc.js → BarChart-ugae8zfr.js} +1 -1
  70. package/dist/packages/elements-ui/dist/cdn/chunks/{ChatMessage-CgQ1h_JP.js → ChatMessage-Bx4yrF2x.js} +1 -1
  71. package/dist/packages/elements-ui/dist/cdn/chunks/CodeBlock-B_e5ma3K.js +1 -0
  72. package/dist/packages/elements-ui/dist/cdn/chunks/CodeBlock-Fgtr48Vb.js +1 -0
  73. package/dist/packages/elements-ui/dist/cdn/chunks/ColorInput-CD7rsWRp.js +1 -0
  74. package/dist/packages/elements-ui/dist/cdn/chunks/Combobox-CUw7z6TS.js +1 -0
  75. package/dist/packages/elements-ui/dist/cdn/chunks/{Combobox-DB2FT7so.js → Combobox-hWIFU9X_.js} +1 -1
  76. package/dist/packages/elements-ui/dist/cdn/chunks/Command-BXgqRd3I.js +1 -0
  77. package/dist/packages/elements-ui/dist/cdn/chunks/{ConfirmDialog-BtQOAHY2.js → ConfirmDialog-CAaBRKxl.js} +1 -1
  78. package/dist/packages/elements-ui/dist/cdn/chunks/{Dashboard-ChMPH4_Q.js → Dashboard-DwNw5Wnd.js} +1 -1
  79. package/dist/packages/elements-ui/dist/cdn/chunks/DatePicker-DjqtswQR.js +1 -0
  80. package/dist/packages/elements-ui/dist/cdn/chunks/DateRangePicker-LsXFHOzm.js +1 -0
  81. package/dist/packages/elements-ui/dist/cdn/chunks/{DonutChart-BEK89BeL.js → DonutChart-DYXx6eTe.js} +1 -1
  82. package/dist/packages/elements-ui/dist/cdn/chunks/FileUpload-3gbZTSSx.js +1 -0
  83. package/dist/packages/elements-ui/dist/cdn/chunks/{FormField-PlLLDKqc.js → FormField-Bvw4cLBc.js} +1 -1
  84. package/dist/packages/elements-ui/dist/cdn/chunks/{FormField-C6L3vYp4.js → FormField-DzhcinED.js} +1 -1
  85. package/dist/packages/elements-ui/dist/cdn/chunks/{FunnelChart-DVQz_gad.js → FunnelChart-D24XhrGw.js} +1 -1
  86. package/dist/packages/elements-ui/dist/cdn/chunks/{Heading-fAcu6Vrw.js → Heading-Cvfyu8pc.js} +1 -1
  87. package/dist/packages/elements-ui/dist/cdn/chunks/{Heading-CgzEi9OQ.js → Heading-XDJzlwt9.js} +1 -1
  88. package/dist/packages/elements-ui/dist/cdn/chunks/{Heatmap-BRwR-n-V.js → Heatmap-BQoUS6gY.js} +1 -1
  89. package/dist/packages/elements-ui/dist/cdn/chunks/{Hero-CV2YWeb4.js → Hero-CXuuFceS.js} +1 -1
  90. package/dist/packages/elements-ui/dist/cdn/chunks/{Histogram-CCYwlinB.js → Histogram-DW_ZPHpR.js} +1 -1
  91. package/dist/packages/elements-ui/dist/cdn/chunks/{LineChart-BH6Pq1P1.js → LineChart-kf-zlNWe.js} +1 -1
  92. package/dist/packages/elements-ui/dist/cdn/chunks/{Markdown-DmZEch4i.js → Markdown-C3rjhIbt.js} +1 -1
  93. package/dist/packages/elements-ui/dist/cdn/chunks/ModeSwitch-DQ86CK9h.js +1 -0
  94. package/dist/packages/elements-ui/dist/cdn/chunks/MultiSelect-DbSx9QtV.js +1 -0
  95. package/dist/packages/elements-ui/dist/cdn/chunks/NumberInput-B4ZZOGLl.js +7 -0
  96. package/dist/packages/elements-ui/dist/cdn/chunks/PhoneInput-BsMfbNi6.js +210 -0
  97. package/dist/packages/elements-ui/dist/cdn/chunks/PromptInput-l_-zAXSZ.js +1 -0
  98. package/dist/packages/elements-ui/dist/cdn/chunks/{RadarChart-Coje7Sb0.js → RadarChart-CwJAWRki.js} +1 -1
  99. package/dist/packages/elements-ui/dist/cdn/chunks/{RichTextContent-CufjptHF.js → RichTextContent-D51UfuWk.js} +1 -1
  100. package/dist/packages/elements-ui/dist/cdn/chunks/{RichTextInput-Dz7yBFUA.js → RichTextInput-B32fN_p9.js} +3 -3
  101. package/dist/packages/elements-ui/dist/cdn/chunks/{ScatterChart-Do5tQTC5.js → ScatterChart-Mps7l5-i.js} +1 -1
  102. package/dist/packages/elements-ui/dist/cdn/chunks/Select-CpsRP0NR.js +1 -0
  103. package/dist/packages/elements-ui/dist/cdn/chunks/Stat-CXR6bP7X.js +1 -0
  104. package/dist/packages/elements-ui/dist/cdn/chunks/Stat-DGcx2ZZq.js +1 -0
  105. package/dist/packages/elements-ui/dist/cdn/chunks/TagInput-BhkLU4gE.js +1 -0
  106. package/dist/packages/elements-ui/dist/cdn/chunks/TimeInput-r2jNTOLN.js +1 -0
  107. package/dist/packages/elements-ui/dist/cdn/chunks/{Toast-CAYGbn7g.js → Toast-BTfcZn0I.js} +1 -1
  108. package/dist/packages/elements-ui/dist/cdn/chunks/{ToastViewport-CFslglYc.js → ToastViewport-BBQMRCQT.js} +1 -1
  109. package/dist/packages/elements-ui/dist/cdn/chunks/{ToolCall-DUCoKsoE.js → ToolCall-DNU5kk9_.js} +1 -1
  110. package/dist/packages/elements-ui/dist/cdn/chunks/{Treemap-Bh3ruYGJ.js → Treemap-BV8TlZHB.js} +1 -1
  111. package/dist/packages/elements-ui/dist/cdn/chunks/agent-DfOqpL9c.js +1 -0
  112. package/dist/packages/elements-ui/dist/cdn/chunks/api-DJBiUXxK.js +4 -0
  113. package/dist/packages/elements-ui/dist/cdn/chunks/avatar.module-D4YdFevY.js +1 -0
  114. package/dist/packages/elements-ui/dist/cdn/chunks/cap-DA71oFHt.js +1 -0
  115. package/dist/packages/elements-ui/dist/cdn/chunks/{cartesian-I5uPfyqv.js → cartesian-CEn2lJCc.js} +1 -1
  116. package/dist/packages/elements-ui/dist/cdn/chunks/{chart-annotations.module-xUExw4pu.js → chart-annotations.module-hA_KO_Pe.js} +1 -1
  117. package/dist/packages/elements-ui/dist/cdn/chunks/chart-brush.module-C_8txUW5.js +1 -0
  118. package/dist/packages/elements-ui/dist/cdn/chunks/chart-twin.module-BpfyTQ9R.js +1 -0
  119. package/dist/packages/elements-ui/dist/cdn/chunks/check-CHvc4yHL.js +1 -0
  120. package/dist/packages/elements-ui/dist/cdn/chunks/css-vars-DeZ4TCna.js +1 -0
  121. package/dist/packages/elements-ui/dist/cdn/chunks/draw-BiQ3Of6N.js +1 -0
  122. package/dist/packages/elements-ui/dist/cdn/chunks/drawing-nhJNBahV.js +1 -0
  123. package/dist/packages/elements-ui/dist/cdn/chunks/field-labels-Df5HuYC5.js +1 -0
  124. package/dist/packages/elements-ui/dist/cdn/chunks/frame-CtTY4oCn.js +1 -0
  125. package/dist/packages/elements-ui/dist/cdn/chunks/on-call-YKLF3-FH.js +1 -0
  126. package/dist/packages/elements-ui/dist/cdn/chunks/runtime-QRQ3CjZg.js +1 -0
  127. package/dist/packages/elements-ui/dist/cdn/chunks/series-uUg6_JtL.js +1 -0
  128. package/dist/packages/elements-ui/dist/cdn/chunks/src-XnWjGSDr.js +67 -0
  129. package/dist/packages/elements-ui/dist/cdn/chunks/toast-pwGvxH2T.js +1 -0
  130. package/dist/packages/elements-ui/dist/cdn/chunks/urls-Qks0KJ_p.js +6 -0
  131. package/dist/packages/elements-ui/dist/cdn/chunks/webmcp-Dro53ATH.js +1 -0
  132. package/dist/packages/elements-ui/dist/cdn/polymorph-all.js +52 -50
  133. package/dist/packages/elements-ui/dist/cdn/polymorph.css +1 -1
  134. package/dist/packages/elements-ui/dist/cdn/polymorph.js +1 -1
  135. package/dist/packages/elements-ui/dist/cdn/prepaint.js +1 -1
  136. package/dist/packages/elements-ui/dist/cdn/themes/desktop.css +5 -4
  137. package/dist/packages/elements-ui/dist/cdn/themes/dew.css +5 -4
  138. package/dist/packages/elements-ui/dist/cdn/themes/flint.css +5 -4
  139. package/dist/packages/elements-ui/dist/cdn/themes/glassmorphic.css +5 -4
  140. package/dist/packages/elements-ui/dist/cdn/themes/harbor.css +5 -4
  141. package/dist/packages/elements-ui/dist/cdn/themes/journal.css +5 -4
  142. package/dist/packages/elements-ui/dist/cdn/themes/pastel.css +5 -4
  143. package/dist/packages/elements-ui/dist/cdn/themes/pebble.css +5 -4
  144. package/dist/packages/elements-ui/dist/cdn/themes/plain.css +5 -4
  145. package/dist/packages/elements-ui/dist/cdn/themes/pop.css +5 -4
  146. package/dist/packages/elements-ui/dist/cdn/themes/press.css +5 -4
  147. package/dist/packages/elements-ui/dist/cdn/themes/terminal.css +5 -4
  148. package/dist/packages/elements-ui/src/ai/ArtifactPane.ts +2 -0
  149. package/dist/packages/elements-ui/src/archetypes/dashboard.states.ts +9 -0
  150. package/dist/packages/elements-ui/src/controls/ColorInput.ts +2 -0
  151. package/dist/packages/elements-ui/src/controls/NumberInput.ts +2 -0
  152. package/dist/packages/elements-ui/src/controls/TagInput.ts +4 -0
  153. package/dist/packages/elements-ui/src/controls/TimeInput.ts +2 -0
  154. package/dist/packages/elements-ui/src/controls/select.states.ts +10 -0
  155. package/dist/packages/elements-ui/src/overlays/Command.ts +2 -0
  156. package/dist/packages/elements-ui/src/structure/CodeBlock.ts +5 -2
  157. package/dist/packages/elements-ui/src/structure/Stat.ts +6 -0
  158. package/dist/packages/elements-ui/src/structure/stat.states.ts +33 -0
  159. package/dist/packages/mcp/src/propose.js +92 -15
  160. package/dist/packages/mcp/src/server.js +19 -8
  161. package/dist/packages/mcp/src/tools.js +80 -5
  162. package/dist/packages/mcp/src/write.js +95 -13
  163. package/dist/packages/react-ui/src/ai/ArtifactPane.tsx +5 -2
  164. package/dist/packages/react-ui/src/ai/PromptInput.tsx +5 -2
  165. package/dist/packages/react-ui/src/archetypes/dashboard.states.tsx +28 -0
  166. package/dist/packages/react-ui/src/controls/ColorInput.tsx +69 -13
  167. package/dist/packages/react-ui/src/controls/Combobox.tsx +13 -5
  168. package/dist/packages/react-ui/src/controls/DatePicker.tsx +3 -0
  169. package/dist/packages/react-ui/src/controls/DateRangePicker.tsx +22 -5
  170. package/dist/packages/react-ui/src/controls/FileUpload.tsx +2 -0
  171. package/dist/packages/react-ui/src/controls/MultiSelect.tsx +30 -6
  172. package/dist/packages/react-ui/src/controls/NumberInput.tsx +19 -1
  173. package/dist/packages/react-ui/src/controls/PhoneInput.tsx +3 -3
  174. package/dist/packages/react-ui/src/controls/Select.tsx +59 -23
  175. package/dist/packages/react-ui/src/controls/TagInput.tsx +43 -10
  176. package/dist/packages/react-ui/src/controls/TimeInput.tsx +10 -0
  177. package/dist/packages/react-ui/src/controls/date-segments.tsx +16 -0
  178. package/dist/packages/react-ui/src/controls/select.states.tsx +13 -0
  179. package/dist/packages/react-ui/src/overlays/Command.tsx +23 -2
  180. package/dist/packages/react-ui/src/overlays/Toaster.tsx +2 -2
  181. package/dist/packages/react-ui/src/structure/CodeBlock.tsx +7 -3
  182. package/dist/packages/react-ui/src/structure/Stat.tsx +90 -13
  183. package/dist/packages/react-ui/src/structure/stat.states.tsx +68 -0
  184. package/dist/packages/recipes/src/ai/artifact-pane.module.css +4 -4
  185. package/dist/packages/recipes/src/controls/rich-text-input.module.css +1 -1
  186. package/dist/packages/recipes/src/structure/avatar.module.css +3 -1
  187. package/dist/packages/recipes/src/structure/heading.module.css +5 -4
  188. package/dist/packages/recipes/src/structure/hero.module.css +3 -1
  189. package/dist/packages/recipes/src/structure/stat.module.css +7 -0
  190. package/dist/packages/registry/src/card.js +4 -3
  191. package/dist/packages/registry/src/frameworks.js +28 -1
  192. package/dist/packages/registry/src/runtime-card.js +300 -0
  193. package/dist/packages/registry/src/runtime-members.js +176 -0
  194. package/dist/packages/registry/src/screen-table.js +166 -0
  195. package/dist/packages/rules/package.js +1 -1
  196. package/dist/packages/solid-ui/src/ai/ArtifactPane.tsx +11 -3
  197. package/dist/packages/solid-ui/src/ai/PromptInput.tsx +3 -1
  198. package/dist/packages/solid-ui/src/archetypes/Dashboard.tsx +3 -0
  199. package/dist/packages/solid-ui/src/archetypes/dashboard.states.tsx +39 -0
  200. package/dist/packages/solid-ui/src/controls/ColorInput.tsx +38 -17
  201. package/dist/packages/solid-ui/src/controls/Combobox.tsx +27 -6
  202. package/dist/packages/solid-ui/src/controls/DatePicker.tsx +12 -11
  203. package/dist/packages/solid-ui/src/controls/DateRangePicker.tsx +21 -16
  204. package/dist/packages/solid-ui/src/controls/DateRangePickerRangeCalendar.tsx +3 -4
  205. package/dist/packages/solid-ui/src/controls/FileUpload.tsx +1 -0
  206. package/dist/packages/solid-ui/src/controls/FileUploadRow.tsx +6 -0
  207. package/dist/packages/solid-ui/src/controls/MultiSelect.tsx +51 -11
  208. package/dist/packages/solid-ui/src/controls/NumberInput.tsx +21 -2
  209. package/dist/packages/solid-ui/src/controls/PhoneInput.tsx +8 -4
  210. package/dist/packages/solid-ui/src/controls/Select.tsx +37 -6
  211. package/dist/packages/solid-ui/src/controls/TagInput.tsx +26 -5
  212. package/dist/packages/solid-ui/src/controls/TimeInput.tsx +10 -1
  213. package/dist/packages/solid-ui/src/controls/select.states.tsx +18 -0
  214. package/dist/packages/solid-ui/src/overlays/Command.tsx +15 -2
  215. package/dist/packages/solid-ui/src/overlays/CommandPanel.tsx +7 -7
  216. package/dist/packages/solid-ui/src/overlays/ToastViewport.tsx +1 -1
  217. package/dist/packages/solid-ui/src/structure/CodeBlock.tsx +9 -5
  218. package/dist/packages/solid-ui/src/structure/Stat.tsx +86 -25
  219. package/dist/packages/solid-ui/src/structure/stat.states.tsx +73 -0
  220. package/dist/packages/svelte-ui/src/ai/ArtifactPane.svelte +8 -2
  221. package/dist/packages/svelte-ui/src/ai/PromptInput.svelte +3 -1
  222. package/dist/packages/svelte-ui/src/archetypes/Dashboard.svelte +3 -0
  223. package/dist/packages/svelte-ui/src/archetypes/dashboard.states.svelte +2 -0
  224. package/dist/packages/svelte-ui/src/controls/ColorInput.svelte +29 -8
  225. package/dist/packages/svelte-ui/src/controls/Combobox.svelte +26 -5
  226. package/dist/packages/svelte-ui/src/controls/DatePicker.svelte +7 -5
  227. package/dist/packages/svelte-ui/src/controls/DateRangePicker.svelte +15 -9
  228. package/dist/packages/svelte-ui/src/controls/DateRangePickerRangeCalendar.svelte +3 -2
  229. package/dist/packages/svelte-ui/src/controls/FileUpload.svelte +1 -0
  230. package/dist/packages/svelte-ui/src/controls/FileUploadRow.svelte +8 -1
  231. package/dist/packages/svelte-ui/src/controls/MultiSelect.svelte +36 -10
  232. package/dist/packages/svelte-ui/src/controls/NumberInput.svelte +14 -1
  233. package/dist/packages/svelte-ui/src/controls/PhoneInput.svelte +3 -3
  234. package/dist/packages/svelte-ui/src/controls/Select.svelte +20 -6
  235. package/dist/packages/svelte-ui/src/controls/TagInput.svelte +21 -3
  236. package/dist/packages/svelte-ui/src/controls/TimeInput.svelte +11 -1
  237. package/dist/packages/svelte-ui/src/controls/select.states.svelte +26 -24
  238. package/dist/packages/svelte-ui/src/overlays/Command.svelte +13 -1
  239. package/dist/packages/svelte-ui/src/overlays/CommandPanel.svelte +11 -6
  240. package/dist/packages/svelte-ui/src/overlays/ToastViewport.svelte +1 -1
  241. package/dist/packages/svelte-ui/src/structure/CodeBlock.svelte +7 -2
  242. package/dist/packages/svelte-ui/src/structure/Stat.svelte +70 -17
  243. package/dist/packages/svelte-ui/src/structure/stat.states.svelte +27 -0
  244. package/dist/packages/theme/src/admit.js +6 -3
  245. package/dist/packages/theme/src/color/resolve.js +19 -2
  246. package/dist/packages/theme/src/derive.js +13 -6
  247. package/dist/packages/theme/src/emit.js +1 -1
  248. package/dist/packages/theme/src/runtime.js +58 -0
  249. package/dist/packages/theme/src/seeds.js +30 -4
  250. package/dist/packages/theme/src/systems.js +1 -1
  251. package/dist/packages/theme/src/tokens.js +15 -6
  252. package/dist/packages/vue-ui/src/ai/ArtifactPane.vue +11 -2
  253. package/dist/packages/vue-ui/src/ai/PromptInput.vue +3 -1
  254. package/dist/packages/vue-ui/src/archetypes/Dashboard.vue +3 -0
  255. package/dist/packages/vue-ui/src/archetypes/dashboard.states.ts +49 -0
  256. package/dist/packages/vue-ui/src/controls/ColorInput.vue +33 -12
  257. package/dist/packages/vue-ui/src/controls/Combobox.vue +26 -5
  258. package/dist/packages/vue-ui/src/controls/DatePicker.vue +12 -11
  259. package/dist/packages/vue-ui/src/controls/DateRangePicker.vue +20 -15
  260. package/dist/packages/vue-ui/src/controls/DateRangePickerRangeCalendar.vue +3 -4
  261. package/dist/packages/vue-ui/src/controls/FileUpload.vue +1 -0
  262. package/dist/packages/vue-ui/src/controls/FileUploadRow.vue +6 -0
  263. package/dist/packages/vue-ui/src/controls/MultiSelect.vue +37 -10
  264. package/dist/packages/vue-ui/src/controls/NumberInput.vue +17 -1
  265. package/dist/packages/vue-ui/src/controls/PhoneInput.vue +7 -3
  266. package/dist/packages/vue-ui/src/controls/Select.vue +22 -7
  267. package/dist/packages/vue-ui/src/controls/TagInput.vue +21 -3
  268. package/dist/packages/vue-ui/src/controls/TimeInput.vue +10 -1
  269. package/dist/packages/vue-ui/src/controls/select.states.ts +17 -0
  270. package/dist/packages/vue-ui/src/overlays/Command.vue +13 -1
  271. package/dist/packages/vue-ui/src/overlays/CommandPanel.vue +7 -7
  272. package/dist/packages/vue-ui/src/overlays/ToastViewport.vue +1 -1
  273. package/dist/packages/vue-ui/src/structure/CodeBlock.vue +7 -2
  274. package/dist/packages/vue-ui/src/structure/Stat.vue +71 -18
  275. package/dist/packages/vue-ui/src/structure/stat.states.ts +67 -0
  276. package/dist/platforms/android/ui/src/generated/kotlin/dev/polymorph/ui/Contracts.kt +144 -33
  277. package/dist/platforms/android/ui/src/generated/kotlin/dev/polymorph/ui/Members.kt +17 -7
  278. package/dist/platforms/ios/Sources/PolymorphUI/Generated/Contracts.swift +204 -31
  279. package/dist/registry/registry.json +371 -75
  280. package/dist/screen/assets/{screen-CuQbskb8.css → screen-B22PTPwF.css} +1 -1
  281. package/dist/screen/assets/screen-Cpbh7XMb.js +372 -0
  282. package/dist/screen/screen.html +3 -3
  283. package/package.json +1 -1
  284. package/dist/packages/elements-ui/dist/cdn/chunks/ArtifactPane-DsmRlr6d.js +0 -1
  285. package/dist/packages/elements-ui/dist/cdn/chunks/CodeBlock-BqP8HZKM.js +0 -1
  286. package/dist/packages/elements-ui/dist/cdn/chunks/CodeBlock-D8VARz0a.js +0 -1
  287. package/dist/packages/elements-ui/dist/cdn/chunks/ColorInput-BrzZOVeL.js +0 -1
  288. package/dist/packages/elements-ui/dist/cdn/chunks/Combobox-BiUq0h-w.js +0 -1
  289. package/dist/packages/elements-ui/dist/cdn/chunks/Command-hmxVRdFg.js +0 -1
  290. package/dist/packages/elements-ui/dist/cdn/chunks/DatePicker-C8prGbJ2.js +0 -1
  291. package/dist/packages/elements-ui/dist/cdn/chunks/DateRangePicker-CO1ioqwN.js +0 -1
  292. package/dist/packages/elements-ui/dist/cdn/chunks/FileUpload-HPQe-ttb.js +0 -1
  293. package/dist/packages/elements-ui/dist/cdn/chunks/ModeSwitch-CerqbGv3.js +0 -1
  294. package/dist/packages/elements-ui/dist/cdn/chunks/MultiSelect-CQq7jPgI.js +0 -1
  295. package/dist/packages/elements-ui/dist/cdn/chunks/NumberInput-Dre9GwBy.js +0 -7
  296. package/dist/packages/elements-ui/dist/cdn/chunks/PhoneInput-D6_J6Es_.js +0 -210
  297. package/dist/packages/elements-ui/dist/cdn/chunks/PromptInput-BXcsUQ5W.js +0 -1
  298. package/dist/packages/elements-ui/dist/cdn/chunks/Select-DxGQgv2q.js +0 -1
  299. package/dist/packages/elements-ui/dist/cdn/chunks/Stat-FsMUWigK.js +0 -1
  300. package/dist/packages/elements-ui/dist/cdn/chunks/Stat-WS8v6BQv.js +0 -1
  301. package/dist/packages/elements-ui/dist/cdn/chunks/TagInput-D-uIQEGS.js +0 -1
  302. package/dist/packages/elements-ui/dist/cdn/chunks/TimeInput-Dho571vA.js +0 -1
  303. package/dist/packages/elements-ui/dist/cdn/chunks/agent-DBDk4wLH.js +0 -1
  304. package/dist/packages/elements-ui/dist/cdn/chunks/api-B9sGZiYn.js +0 -4
  305. package/dist/packages/elements-ui/dist/cdn/chunks/avatar.module-CQwnWhWo.js +0 -1
  306. package/dist/packages/elements-ui/dist/cdn/chunks/cap-Ct4k7zNC.js +0 -1
  307. package/dist/packages/elements-ui/dist/cdn/chunks/chart-brush.module-DycBfben.js +0 -1
  308. package/dist/packages/elements-ui/dist/cdn/chunks/chart-twin.module-Cks7VwS5.js +0 -1
  309. package/dist/packages/elements-ui/dist/cdn/chunks/check-dOfCSYFA.js +0 -1
  310. package/dist/packages/elements-ui/dist/cdn/chunks/draw-DclRgiWM.js +0 -1
  311. package/dist/packages/elements-ui/dist/cdn/chunks/drawing-DjkZr0z8.js +0 -1
  312. package/dist/packages/elements-ui/dist/cdn/chunks/frame-BSvl4y47.js +0 -1
  313. package/dist/packages/elements-ui/dist/cdn/chunks/on-call-Jk1sYJc_.js +0 -1
  314. package/dist/packages/elements-ui/dist/cdn/chunks/receivers-BpRfF6dV.js +0 -4
  315. package/dist/packages/elements-ui/dist/cdn/chunks/series-C_1TNd2n.js +0 -1
  316. package/dist/packages/elements-ui/dist/cdn/chunks/src-Bub3C9YP.js +0 -67
  317. package/dist/packages/elements-ui/dist/cdn/chunks/toast-AarMGYJn.js +0 -1
  318. package/dist/packages/elements-ui/dist/cdn/chunks/webmcp-eEPzSqph.js +0 -1
  319. package/dist/screen/assets/screen-Clj2u6_s.js +0 -372
@@ -90,6 +90,49 @@ value="1"
90
90
  [trend]="e11()"
91
91
  [pmOverrides]="overrides()"
92
92
  ></pm-stat>}
93
+ @case (12) {<pm-stat
94
+ label="First response"
95
+ value="26m"
96
+ [delta]="e12()"
97
+ [spark]="e13()"
98
+ [pmOverrides]="overrides()"
99
+ ></pm-stat>}
100
+ @case (13) {<pm-stat
101
+ label="Revenue"
102
+ [value]="e14()"
103
+ [trend]="e15()"
104
+ [spark]="e16()"
105
+ [pmOverrides]="overrides()"
106
+ ></pm-stat>}
107
+ @case (14) {<pm-stat
108
+ label="Open tickets"
109
+ value="128"
110
+ [spark]="e17()"
111
+ [pmOverrides]="overrides()"
112
+ ></pm-stat>}
113
+ @case (15) {<pm-stat
114
+ label="Response time"
115
+ [value]="e18()"
116
+ icon="time"
117
+ [loading]="e19()"
118
+ [pmOverrides]="overrides()"
119
+ ></pm-stat>}
120
+ @case (16) {<pm-stat
121
+ label="Resolved"
122
+ value="342"
123
+ [delta]="e20()"
124
+ [loading]="e21()"
125
+ [pmOverrides]="overrides()"
126
+ ></pm-stat>}
127
+ @case (17) {<pm-stat
128
+ label="Solved this week"
129
+ value="1,204"
130
+ [trend]="e22()"
131
+ [spark]="e23()"
132
+ [footer]="e24()"
133
+ [loading]="e25()"
134
+ [pmOverrides]="overrides()"
135
+ ></pm-stat>}
93
136
  }`,
94
137
  })
95
138
  export class StatStates {
@@ -139,6 +182,62 @@ export class StatStates {
139
182
  protected e11(): StatProps['trend'] {
140
183
  return { direction: 'down', label: '2 fewer' }
141
184
  }
185
+
186
+ protected e12(): StatProps['delta'] {
187
+ return { value: '16m', direction: 'down', positive: true }
188
+ }
189
+
190
+ protected e13(): StatProps['spark'] {
191
+ return [42, 40, 41, 38, 35, 36, 33, 31, 32, 29, 27, 26]
192
+ }
193
+
194
+ protected e14(): StatProps['value'] {
195
+ return '$48,200'
196
+ }
197
+
198
+ protected e15(): StatProps['trend'] {
199
+ return { direction: 'up', label: '+12.5%' }
200
+ }
201
+
202
+ protected e16(): StatProps['spark'] {
203
+ return [180, 195, 190, 210, 220, 216, 240, 251, 248, 262, 270, 284]
204
+ }
205
+
206
+ protected e17(): StatProps['spark'] {
207
+ return [180, 195, 190, 210, 220, 216, 240, 251, 248, 262, 270, 284]
208
+ }
209
+
210
+ protected e18(): StatProps['value'] {
211
+ return ''
212
+ }
213
+
214
+ protected e19(): StatProps['loading'] {
215
+ return true
216
+ }
217
+
218
+ protected e20(): StatProps['delta'] {
219
+ return { value: '12%', direction: 'up' }
220
+ }
221
+
222
+ protected e21(): StatProps['loading'] {
223
+ return true
224
+ }
225
+
226
+ protected e22(): StatProps['trend'] {
227
+ return { direction: 'up', label: '+12.5%' }
228
+ }
229
+
230
+ protected e23(): StatProps['spark'] {
231
+ return [180, 195, 190, 210, 220, 216, 240, 251, 248, 262, 270, 284]
232
+ }
233
+
234
+ protected e24(): StatProps['footer'] {
235
+ return { primary: 'Trending up this month', secondary: 'Against the same week last month' }
236
+ }
237
+
238
+ protected e25(): StatProps['loading'] {
239
+ return true
240
+ }
142
241
  }
143
242
 
144
243
  export const states: ComponentStates = {
@@ -157,5 +256,22 @@ export const states: ComponentStates = {
157
256
  { name: 'trend down — the same chip, the other way' },
158
257
  { name: 'a footer with no trend — the glyph goes with the chip' },
159
258
  { name: 'a trend with no footer — the whole card is the number' },
259
+ {
260
+ name: 'spark trending down beside a down-positive delta — direction is not sentiment, as a shape',
261
+ },
262
+ { name: 'spark with the trend chip — words and shape together' },
263
+ { name: 'spark alone' },
264
+ {
265
+ name: 'loading — the label stays and the number holds its place',
266
+ expect: { 'data-loading': '', 'aria-busy': 'true' },
267
+ },
268
+ {
269
+ name: 'loading with a delta — no sentiment before the number',
270
+ expect: { 'data-loading': '', 'aria-busy': 'true' },
271
+ },
272
+ {
273
+ name: 'loading a dashboard card — the chip, the spark and the footer hold their places',
274
+ expect: { 'data-loading': '', 'aria-busy': 'true' },
275
+ },
160
276
  ],
161
277
  }
@@ -5,7 +5,8 @@ import { escapes } from "./plan.js";
5
5
  import { digest, readManifest } from "./manifest.js";
6
6
  import { ESLINT_FRAGMENT } from "./patch.js";
7
7
  import { row } from "./readings.js";
8
- import { SKILL_NAMES, skillFiles } from "./skills.js";
8
+ import { SKILL_NAMES, SKILL_USES } from "./skills/facts.js";
9
+ import { skillFiles } from "./skills.js";
9
10
  import { existsSync, mkdirSync, readFileSync, readdirSync, realpathSync, rmSync, writeFileSync } from "node:fs";
10
11
  import { dirname, resolve, sep } from "node:path";
11
12
  //#region ../cli/src/agents.ts
@@ -263,7 +264,7 @@ var FRAMEWORK_NOTES = {
263
264
  boundary: "`<poly-third-party library=\"…\" reason=\"…\">`",
264
265
  themeValues: "`var(--pm-…)`",
265
266
  specs: false,
266
- extra: ["A page loads the stylesheets and `polymorph.js` from the directory `polymorph.json` names, which also holds the theme sheet. `add theme:<system>` adds a system to the sheet, `<html data-system data-palette>` chooses the one a page wears, and `update` copies the files again when polymorph changes.", "`<html data-agent=\"on-call\">` registers the page's members with the browser's WebMCP API as tools an agent in the browser calls, and loads the agent bridge on the first call; `\"eager\"` loads it at once. No page states it until its owner decides an agent may operate that page."]
267
+ extra: ["A page loads the stylesheets and `polymorph.js` from the directory `polymorph.json` names, which also holds the theme sheet. `add theme:<system>` adds a system to the sheet, `<html data-system data-palette>` chooses the one a page wears, and `update` copies the files again when polymorph changes.", "`<html data-agent=\"on-call\">` lets an agent in the browser operate the page (the `polymorph-agent-bridge` skill). A page states it only when its owner decides one may."]
267
268
  }
268
269
  };
269
270
  /** A list in a sentence: `a`, `a and b`, `a, b and c`. */
@@ -320,7 +321,7 @@ function agentsText(registry, options, where) {
320
321
  ];
321
322
  const width = Math.max(...commands.map(([command]) => `${where.run} ${command}`.length));
322
323
  lines.push("```sh", ...commands.map(([command, comment]) => `${`${where.run} ${command}`.padEnd(width)} # ${comment}`), "```", "");
323
- lines.push(bullet(`The skills ${listed(SKILL_NAMES.map((name) => `\`${name}\``))}, in ${listed(where.skillDirs.map((dir) => `\`${dir}/\``))}, hold the procedures.`));
324
+ lines.push(bullet(`The skills in ${listed(where.skillDirs.map((dir) => `\`${dir}/\``))} hold the procedures: ${SKILL_NAMES.map((name) => `\`${name}\` (${SKILL_USES[name]})`).join("; ")}.`));
324
325
  if (where.servers.length > 0) lines.push(bullet(serverSentence(options, where.servers)));
325
326
  return lines.join("\n");
326
327
  }
@@ -1,7 +1,8 @@
1
1
  import { admitTheme } from "../../theme/src/admit.js";
2
+ import { prepaintScript } from "../../theme/src/runtime.js";
2
3
  import { FrameworkMismatchError } from "./vue.js";
3
4
  import { vendoredText } from "./plan.js";
4
- import { BASE_IMPORT, THEME_SHEET, generatedFiles, hasTheme, pairingLoader, themeModule, themePairings, tokenValuesIn } from "./emit.js";
5
+ import { BASE_IMPORT, THEME_SHEET, generatedFiles, hasTheme, pairingLoader, prepaintModule, themeModule, themePairings, tokenValuesIn } from "./emit.js";
5
6
  import { digest, emptyManifest, readManifest, writeManifest } from "./manifest.js";
6
7
  import { ESLINT_FRAGMENT, STYLELINT_FRAGMENT, addDependencies, importThemes, injectPrepaint, linkEslintConfig, linkStylelintConfig } from "./patch.js";
7
8
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
@@ -55,7 +56,13 @@ function applyPlan(root, source, registry, plan, options = {}) {
55
56
  };
56
57
  const { systems, palettes } = allTheme(registry, manifest, plan);
57
58
  const components = [.../* @__PURE__ */ new Set([...manifest.components, ...plan.requested])];
58
- const themes = hasTheme(plan) ? compileThemes(root, source, manifest, plan, systems, palettes) : {};
59
+ const documentOf = themeDocuments(root, source, manifest, plan, options.force === true);
60
+ const themes = hasTheme(plan) ? compileThemes(documentOf, plan, systems, palettes) : {};
61
+ const modes = modesOf(documentOf, systems);
62
+ const prepaint = prepaintScript({
63
+ modes,
64
+ system: systems[0]?.name
65
+ });
59
66
  const sheet = `${dir}/themes/${THEME_SHEET}`;
60
67
  const compiled = tokenValuesIn(themes[sheet] ?? (existsSync(resolve(root, sheet)) ? readFileSync(resolve(root, sheet), "utf8") : ""));
61
68
  const values = Object.keys(compiled).length > 0 ? compiled : fallbackValues(registry);
@@ -81,7 +88,7 @@ function applyPlan(root, source, registry, plan, options = {}) {
81
88
  ...themes
82
89
  }).map(([path, contents]) => ({
83
90
  path,
84
- contents: path.endsWith("themes/index.ts") ? themeModule(systems, palettes, plan.base ? BASE_IMPORT : null) : contents,
91
+ contents: path.endsWith("themes/index.ts") ? themeModule(systems, palettes, plan.base ? BASE_IMPORT : null, modes) : path.endsWith(`themes/prepaint.ts`) ? prepaintModule(prepaint) : contents,
85
92
  from: null
86
93
  }))
87
94
  ];
@@ -139,7 +146,7 @@ function applyPlan(root, source, registry, plan, options = {}) {
139
146
  edit("stylelint.config.js", linkStylelintConfig, freshStylelintConfig());
140
147
  }
141
148
  if (systems.length > 0 || palettes.length > 0) {
142
- edit("index.html", (html) => injectPrepaint(html, registry.theme.prepaint));
149
+ edit("index.html", (html) => injectPrepaint(html, prepaint));
143
150
  if (manifest.appInstallsThemes !== true) {
144
151
  const entry = ENTRY_CANDIDATES.find((candidate) => existsSync(resolve(root, candidate)));
145
152
  if (entry) {
@@ -168,21 +175,12 @@ function applyPlan(root, source, registry, plan, options = {}) {
168
175
  * module the application runs derives nothing. `theme.css` holds each system
169
176
  * with its own palette, and every other pairing gets its own sheet.
170
177
  *
171
- * The compiled JSON is the JSON the application will have. That is the
172
- * upstream copy this install writes, or the application's own copy if it has
173
- * edited it, because the install does not overwrite an edit. An unlawful
174
- * pairing fails the install with the law's own message. A palette's
175
- * more-contrast partner rides in its pairing's sheet, under the media query.
178
+ * The compiled JSON is the JSON the application will have (`themeDocuments`).
179
+ * An unlawful pairing fails the install with the law's own message. A
180
+ * palette's more-contrast partner rides in its pairing's sheet, under the
181
+ * media query.
176
182
  */
177
- function compileThemes(root, source, manifest, plan, systems, palettes) {
178
- const planned = new Set([...plan.systems, ...plan.palettes].map((entry) => entry.file.to));
179
- const json = (entry) => {
180
- const vendored = resolve(root, entry.file.to);
181
- const recorded = manifest.files[entry.file.to];
182
- const edited = existsSync(vendored) && recorded !== void 0 && digest(readFileSync(vendored)) !== recorded.hash;
183
- const path = planned.has(entry.file.to) && !edited || !existsSync(vendored) ? resolve(source, entry.file.from) : vendored;
184
- return JSON.parse(readFileSync(path, "utf8"));
185
- };
183
+ function compileThemes(json, plan, systems, palettes) {
186
184
  const systemJson = new Map(systems.map((system) => [system.name, json(system)]));
187
185
  const paletteJson = new Map(palettes.map((palette) => [palette.name, json(palette)]));
188
186
  const compile = (system, palette) => {
@@ -208,6 +206,33 @@ function compileThemes(root, source, manifest, plan, systems, palettes) {
208
206
  return files;
209
207
  }
210
208
  /**
209
+ * A system's or palette's document as the application will have it: the
210
+ * upstream copy this install writes, or the application's own copy if it has
211
+ * edited it, because the install does not overwrite an edit unless it is
212
+ * forced. A document this install does not write is the application's copy.
213
+ */
214
+ function themeDocuments(root, source, manifest, plan, force) {
215
+ const planned = new Set([...plan.systems, ...plan.palettes].map((entry) => entry.file.to));
216
+ return (entry) => {
217
+ const vendored = resolve(root, entry.file.to);
218
+ const recorded = manifest.files[entry.file.to];
219
+ const edited = existsSync(vendored) && recorded !== void 0 && digest(readFileSync(vendored)) !== recorded.hash;
220
+ const path = planned.has(entry.file.to) && (!edited || force) || !existsSync(vendored) ? resolve(source, entry.file.from) : vendored;
221
+ return JSON.parse(readFileSync(path, "utf8"));
222
+ };
223
+ }
224
+ /**
225
+ * Each system's `defaultMode`, read from its document. A document that states
226
+ * no valid one follows the device, which admission refuses anyway when it
227
+ * compiles the system.
228
+ */
229
+ function modesOf(json, systems) {
230
+ return Object.fromEntries(systems.map((system) => {
231
+ const mode = json(system)?.defaultMode;
232
+ return [system.name, mode === "light" || mode === "dark" ? mode : "system"];
233
+ }));
234
+ }
235
+ /**
211
236
  * Every system and palette the install has, old and new, in the shape the
212
237
  * generator needs.
213
238
  *
@@ -256,6 +256,10 @@ function checkLines(registry, report) {
256
256
  const parts = [...violations > 0 ? [counted(violations, "violation", (file) => file.violations.length > 0)] : [], ...unread > 0 ? [`${unread} file${unread === 1 ? "" : "s"} not read`] : []];
257
257
  const warned = warnings > 0 ? ` ${counted(warnings, "warning", (file) => file.warnings.length > 0)}.` : "";
258
258
  lines.push("");
259
+ if (report.checked === 0) {
260
+ lines.push("No file read: the red rules read .ts, .tsx, .vue, .svelte, .html and .css files, and none was read here.");
261
+ return lines;
262
+ }
259
263
  lines.push(`${parts.length === 0 ? "No violations" : parts.join(", ")}.${warned}`);
260
264
  return lines;
261
265
  }
@@ -42,7 +42,8 @@ installed system can wear.
42
42
 
43
43
  \`polymorph theme\` takes your own two JSON documents by path instead — the
44
44
  same engine, the same laws, no catalogue: \`validate\` is the report,
45
- \`emit\` the sheet (--out file.css), \`schema\` the editor contract.
45
+ \`emit\` the sheet (--out file.css), \`schema\` the editor contract. \`hue\`
46
+ reads a colour such as "#1F4FD8" in OKLCH, for a palette's accentHue.
46
47
 
47
48
  \`polymorph check\` reads every .ts, .tsx, .vue, .svelte, .html and .css file
48
49
  below the directory (default: here) as application code, outside the vendored
@@ -406,7 +407,9 @@ function update(cli, flags) {
406
407
  }
407
408
  const stale = before.files.filter((file) => file.state === "upstream" || file.state === "missing" || file.state === "removed");
408
409
  const held = before.files.filter((file) => file.state === "edited" || file.state === "diverged");
409
- if (stale.length === 0 && before.installed === before.available && !flags.force) {
410
+ const themes = `${before.manifest.dir}/themes/`;
411
+ const retheme = held.some((file) => file.path.startsWith(themes) && file.path.endsWith(".json"));
412
+ if (stale.length === 0 && before.installed === before.available && !flags.force && !retheme) {
410
413
  cli.out(`polymorph ${before.installed} — nothing to update`);
411
414
  for (const file of held) cli.out(row("kept yours", file.path));
412
415
  return { code: 0 };
@@ -414,6 +417,7 @@ function update(cli, flags) {
414
417
  const result = updateInstall(cli.root, cli.source, cli.registry, { force: flags.force });
415
418
  cli.out(`polymorph ${before.installed} → ${result.manifest.version}`);
416
419
  cli.out(row("updated", `${result.written.length} files`));
420
+ if (retheme) cli.out(row("compiled", "the theme sheets, from your systems and palettes"));
417
421
  for (const path of result.removed) cli.out(row("dropped", path));
418
422
  for (const path of result.skipped) cli.out(row("kept yours", path));
419
423
  for (const note of result.notes) cli.out(` · ${note}`);
@@ -1,4 +1,5 @@
1
1
  import { admitTheme } from "../../theme/src/admit.js";
2
+ import { prepaintScript } from "../../theme/src/runtime.js";
2
3
  import { ELEMENTS_DIR, ELEMENTS_THEME_SHEET, planInstall } from "./plan.js";
3
4
  import { MANIFEST_FILE, digest, readManifest, writeManifest } from "./manifest.js";
4
5
  import { injectPrepaint } from "./patch.js";
@@ -140,6 +141,15 @@ function manifestOf(registry, dir, systems, palettes, files) {
140
141
  framework: "elements"
141
142
  };
142
143
  }
144
+ /**
145
+ * The pre-paint script of a page with no build, as `prepaint.js` holds it: built
146
+ * with every house system's default mode, because the page's theme sheet is
147
+ * compiled from the catalogue's documents. The page names its pairing on
148
+ * `<html>`, so the script reads the system there and needs no fallback.
149
+ */
150
+ function elementsPrepaint(registry) {
151
+ return prepaintScript({ modes: Object.fromEntries(registry.theme.systems.map((system) => [system.name, system.defaultMode])) });
152
+ }
143
153
  /** The example page: the stylesheets, the prepaint script and the elements, then a few members. */
144
154
  function examplePage(name, files, system, palette) {
145
155
  return `<!doctype html>
@@ -216,7 +226,7 @@ function planElementsInit(registry, source, options) {
216
226
  {
217
227
  kind: "write",
218
228
  path: page,
219
- contents: injectPrepaint(examplePage(name, posix.basename(dir), system.name, system.defaultPalette), registry.theme.prepaint)
229
+ contents: injectPrepaint(examplePage(name, posix.basename(dir), system.name, system.defaultPalette), elementsPrepaint(registry))
220
230
  },
221
231
  ...agents.steps.map((step) => ({
222
232
  kind: "write",
@@ -377,4 +387,4 @@ function updateElements(root, source, registry, manifest, force) {
377
387
  };
378
388
  }
379
389
  //#endregion
380
- export { ELEMENTS_STATIC_DIR, NoBuildFilesError, UnshippedPageError, addElements, elementsThemeSheet, noBuildFiles, planElementsInit, updateElements };
390
+ export { ELEMENTS_STATIC_DIR, NoBuildFilesError, UnshippedPageError, addElements, elementsPrepaint, elementsThemeSheet, noBuildFiles, planElementsInit, updateElements };
@@ -6,12 +6,16 @@ import { DEFAULT_SYSTEM } from "./plan.js";
6
6
  /**
7
7
  * The files `polymorph add` generates instead of copying.
8
8
  *
9
- * There are four, and the install does not work without each of them:
9
+ * There are five, and the install does not work without each of them:
10
10
  *
11
11
  * - `themes/index.ts`. Without it the system and palette are JSON files that
12
12
  * nothing reads.
13
13
  * - the font imports inside it. Without them the theme renders in its
14
14
  * fallback font stack, which is a broken install.
15
+ * - `themes/prepaint.ts`, the pre-paint script built for the installed
16
+ * systems. The install inlines it in `index.html`; an application with no
17
+ * `index.html` (a Next.js root layout) imports it. Without it a system that
18
+ * opens dark paints light first.
15
19
  * - `polymorph.eslint.js` / `polymorph.stylelint.js`. Without them the red
16
20
  * rules run only in this repository. "Open code, closed usage" requires the
17
21
  * usage to be governed in the consumer's repository.
@@ -32,6 +36,25 @@ var BANNER = (what, instead) => `/* Generated by \`polymorph add\` — ${what}.\
32
36
  var BASE_IMPORT = "../base.css";
33
37
  /** The compiled stylesheet of every installed system paired with its own palette. */
34
38
  var THEME_SHEET = "theme.css";
39
+ /** The module that exports the pre-paint script built for the installed systems. */
40
+ var PREPAINT_MODULE = "prepaint.ts";
41
+ /**
42
+ * `themes/prepaint.ts`: the pre-paint script the install built from the
43
+ * installed systems' default modes, as a string an application inlines first
44
+ * in `<head>`. It imports nothing, so a server component can import it.
45
+ */
46
+ function prepaintModule(script) {
47
+ return [
48
+ BANNER("the pre-paint script for the installed systems", "run `polymorph update`"),
49
+ "/**",
50
+ " * Inline it first in `<head>`, before any stylesheet. It applies the stored",
51
+ " * pairing and mode before the first paint, and for a reader who stored no mode",
52
+ " * the default mode of the system the page wears.",
53
+ " */",
54
+ `export const PREPAINT_SCRIPT = ${JSON.stringify(script)}`,
55
+ ""
56
+ ].join("\n");
57
+ }
35
58
  /**
36
59
  * Every pairing other than a system with its own palette, and the stylesheet
37
60
  * it compiles to. Each gets one small sheet, loaded the first time it is chosen.
@@ -81,7 +104,7 @@ function pairingLoader(sheet) {
81
104
  * it before switching. Compiling the cross-product into one sheet would
82
105
  * multiply its size by the palette count for pairings nobody selected.
83
106
  */
84
- function themeModule(systems, palettes, base = BASE_IMPORT) {
107
+ function themeModule(systems, palettes, base = BASE_IMPORT, modes = {}) {
85
108
  const orderedSystems = [...systems].sort((a, b) => a.name.localeCompare(b.name));
86
109
  const orderedPalettes = [...palettes].sort((a, b) => a.name.localeCompare(b.name));
87
110
  const fonts = [...new Set(orderedSystems.flatMap((system) => system.fonts.map((font) => font.package)))].sort().map((pkg) => {
@@ -89,9 +112,11 @@ function themeModule(systems, palettes, base = BASE_IMPORT) {
89
112
  return `import '${pkg}' // ${[...new Set(families)].join(", ")}`;
90
113
  });
91
114
  const installed = new Set(orderedPalettes.map((palette) => palette.name));
115
+ const resolvable = orderedSystems.filter((system) => installed.has(system.defaultPalette));
92
116
  const catalogue = {
93
- systems: Object.fromEntries(orderedSystems.filter((system) => installed.has(system.defaultPalette)).map((system) => [system.name, system.defaultPalette])),
94
- palettes: orderedPalettes.map((palette) => palette.name)
117
+ systems: Object.fromEntries(resolvable.map((system) => [system.name, system.defaultPalette])),
118
+ palettes: orderedPalettes.map((palette) => palette.name),
119
+ modes: Object.fromEntries(resolvable.map((system) => [system.name, modes[system.name] ?? "system"]))
95
120
  };
96
121
  const first = orderedSystems[0]?.name ?? "";
97
122
  return [
@@ -110,12 +135,21 @@ function themeModule(systems, palettes, base = BASE_IMPORT) {
110
135
  "// Every installed system with its own palette, compiled when this file was written.",
111
136
  `import './${THEME_SHEET}'`,
112
137
  "",
113
- "import { getPalette, getSystem, hydrateTheme } from '@polymorph/engine/runtime'",
138
+ "import {",
139
+ " getPalette,",
140
+ " getSystem,",
141
+ " hydrateTheme,",
142
+ " type InstalledCatalogue,",
143
+ "} from '@polymorph/engine/runtime'",
114
144
  "",
115
145
  `export const DEFAULT_SYSTEM = '${first}'`,
116
146
  "",
117
- "/** What hydration judges a stored choice against: the staleness law needs both sets. */",
118
- `const INSTALLED = ${JSON.stringify(catalogue)}`,
147
+ "/**",
148
+ " * What hydration judges a stored choice against, which the staleness law needs both sets",
149
+ " * of, and the mode each system opens in for a reader who has not chosen one. It is typed,",
150
+ " * because a mode read from a literal is a string, which the catalogue does not take.",
151
+ " */",
152
+ `const INSTALLED: InstalledCatalogue = ${JSON.stringify(catalogue)}`,
119
153
  "",
120
154
  "/** Every other pairing: its own sheet, fetched the first time it is chosen. */",
121
155
  "const PAIRINGS: Record<string, () => Promise<unknown>> = {",
@@ -736,6 +770,7 @@ function generatedFiles(plan, dir, tokens = [], values = {}) {
736
770
  if (hasTheme(plan)) {
737
771
  files[`${dir}/themes/index.ts`] = themeModule(plan.systems, plan.palettes, plan.base ? BASE_IMPORT : null);
738
772
  files[`${dir}/themes/${THEME_SHEET}`] = "";
773
+ files[`${dir}/themes/${PREPAINT_MODULE}`] = "";
739
774
  for (const pairing of themePairings(plan.systems, plan.palettes)) {
740
775
  files[`${dir}/themes/${pairing.sheet}`] = "";
741
776
  files[`${dir}/themes/${pairing.loader}`] = pairingLoader(pairing.sheet);
@@ -744,4 +779,4 @@ function generatedFiles(plan, dir, tokens = [], values = {}) {
744
779
  return files;
745
780
  }
746
781
  //#endregion
747
- export { BASE_IMPORT, THEME_SHEET, eslintFragment, generatedFiles, hasTheme, installedEslintFragment, pairingLoader, stylelintFragment, themeModule, themePairings, tokenValuesIn };
782
+ export { BASE_IMPORT, PREPAINT_MODULE, THEME_SHEET, eslintFragment, generatedFiles, hasTheme, installedEslintFragment, pairingLoader, prepaintModule, stylelintFragment, themeModule, themePairings, tokenValuesIn };
@@ -121,9 +121,22 @@ var code = (text) => {
121
121
  const fence = text.includes("`") ? "``" : "`";
122
122
  return `${fence}${fence.length > 1 ? " " : ""}${text}${fence.length > 1 ? " " : ""}${fence}`;
123
123
  };
124
+ /** The longest note a field prints whole. */
125
+ var FIELD_DOC_MAX = 320;
126
+ /**
127
+ * A field's note as the types section prints it: whole, or its first sentence
128
+ * when it is long. A few fields carry the reasoning for a decision, which the
129
+ * source keeps and a reader choosing a value does not need.
130
+ */
131
+ function fieldDoc(doc) {
132
+ if (doc.length <= FIELD_DOC_MAX) return doc;
133
+ const end = doc.search(/\.\s+[A-Z`]/);
134
+ return end === -1 ? doc : doc.slice(0, end + 1);
135
+ }
124
136
  /**
125
137
  * A member as Markdown, as the system card is: its purpose, its props (a
126
- * trailing `?` marks an optional one), its parts, its lawful cells, its
138
+ * trailing `?` marks an optional one), its parts, the fields of the data types
139
+ * its props name, its lawful cells, its
127
140
  * states, its data attributes, where it renders, and what it depends on.
128
141
  * `framework` narrows the frameworks line to that one framework.
129
142
  */
@@ -146,6 +159,14 @@ function componentLines(answer, framework) {
146
159
  lines.push(`- ${code(`${member.name}.${part.name}`)}: ${props.join(", ") || "no props"}`);
147
160
  }
148
161
  }
162
+ const types = answer.types ?? [];
163
+ if (types.length > 0) lines.push("", "## Types");
164
+ for (const type of types) {
165
+ const params = type.params.length === 0 ? "" : `<${type.params.join(", ")}>`;
166
+ lines.push("", `### ${type.name}${params}`, "");
167
+ if (type.union !== void 0) lines.push(`One of ${type.union.map(code).join(", ")}.`);
168
+ for (const field of type.fields) lines.push(`- ${code(`${field.name}${field.optional ? "?" : ""}`)}: ${code(field.type)}` + (field.doc === void 0 ? "" : ` — ${fieldDoc(field.doc)}`));
169
+ }
149
170
  if (member.grid !== null) {
150
171
  lines.push("", "## Lawful cells", "");
151
172
  for (const [variant, tones] of Object.entries(member.grid)) lines.push(`- ${variant}: ${tones.join(", ")}`);
@@ -174,6 +195,8 @@ function componentLines(answer, framework) {
174
195
  return lines;
175
196
  }
176
197
  /** The theme's parameter space as Markdown: axes, systems, palettes, roles and scales. */
198
+ /** The mode a system opens a first visit in, in words: `system` is the device's. */
199
+ var opensIn = (mode) => mode === "system" ? "in the device's mode" : mode;
177
200
  function axesLines(answer) {
178
201
  const lines = [
179
202
  "# Theme axes",
@@ -186,7 +209,7 @@ function axesLines(answer) {
186
209
  for (const system of answer.systems) {
187
210
  const axes = Object.entries(system.axes).map(([axis, value]) => `${axis} ${value}`);
188
211
  const fonts = system.fonts.map((font) => font.family).join(", ");
189
- lines.push(`- ${system.name} (${system.kind}): palette ${system.defaultPalette}, ${system.defaultMode}; ${axes.join(", ")}; fonts ${fonts}`);
212
+ lines.push(`- ${system.name} (${system.kind}): palette ${system.defaultPalette}, opens ${opensIn(system.defaultMode)}; ${axes.join(", ")}; fonts ${fonts}`);
190
213
  }
191
214
  lines.push("", "## Palettes", "");
192
215
  for (const palette of answer.palettes) lines.push(`- ${paletteLine(palette)}`);
@@ -263,7 +286,10 @@ function proposalLines(answer) {
263
286
  for (const move of entry.moves) lines.push(` ${move.field} ${move.from} → ${move.to}`);
264
287
  if (entry.moves.length === 0) lines.push(" no change: the draft already had these values");
265
288
  }
266
- if (answer.unmapped.length > 0) lines.push(` not in the table: ${answer.unmapped.join(", ")}`);
289
+ const explained = new Set(answer.unread.map((entry) => entry.word));
290
+ const unknown = answer.unmapped.filter((word) => !explained.has(word));
291
+ if (unknown.length > 0) lines.push(` not in the table: ${unknown.join(", ")}`);
292
+ for (const entry of answer.unread) lines.push(` not read: ${entry.word} — ${entry.why}`);
267
293
  lines.push(answer.lawful ? "Lawful." : "Not lawful:");
268
294
  for (const fault of answer.faults) lines.push(` ${fault}`);
269
295
  return lines;