react-cheminfo 0.50.0 → 0.52.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 (314) hide show
  1. package/README.md +71 -16
  2. package/bin/check-seo.mjs +0 -0
  3. package/lib/clipboard/core/index.d.ts +0 -1
  4. package/lib/clipboard/core/index.d.ts.map +1 -1
  5. package/lib/clipboard/core/index.js +0 -1
  6. package/lib/clipboard/core/index.js.map +1 -1
  7. package/lib/clipboard/ui/CopyButton.d.ts +6 -0
  8. package/lib/clipboard/ui/CopyButton.d.ts.map +1 -1
  9. package/lib/clipboard/ui/CopyButton.js +5 -2
  10. package/lib/clipboard/ui/CopyButton.js.map +1 -1
  11. package/lib/color/core/index.d.ts +3 -0
  12. package/lib/color/core/index.d.ts.map +1 -1
  13. package/lib/color/core/index.js +2 -0
  14. package/lib/color/core/index.js.map +1 -1
  15. package/lib/color/core/interpolate.d.ts +4 -2
  16. package/lib/color/core/interpolate.d.ts.map +1 -1
  17. package/lib/color/core/interpolate.js +34 -12
  18. package/lib/color/core/interpolate.js.map +1 -1
  19. package/lib/color/core/stops.d.ts +43 -0
  20. package/lib/color/core/stops.d.ts.map +1 -0
  21. package/lib/color/core/stops.js +66 -0
  22. package/lib/color/core/stops.js.map +1 -0
  23. package/lib/color/core/tone.d.ts +25 -0
  24. package/lib/color/core/tone.d.ts.map +1 -0
  25. package/lib/color/core/tone.js +67 -0
  26. package/lib/color/core/tone.js.map +1 -0
  27. package/lib/color/core/uniform.d.ts +36 -0
  28. package/lib/color/core/uniform.d.ts.map +1 -0
  29. package/lib/color/core/uniform.js +61 -0
  30. package/lib/color/core/uniform.js.map +1 -0
  31. package/lib/color/ui/ColorScaleEditor.d.ts +5 -6
  32. package/lib/color/ui/ColorScaleEditor.d.ts.map +1 -1
  33. package/lib/color/ui/ColorScaleEditor.js +74 -84
  34. package/lib/color/ui/ColorScaleEditor.js.map +1 -1
  35. package/lib/color/ui/ColorScaleSelect.d.ts +16 -0
  36. package/lib/color/ui/ColorScaleSelect.d.ts.map +1 -1
  37. package/lib/color/ui/ColorScaleSelect.js +69 -17
  38. package/lib/color/ui/ColorScaleSelect.js.map +1 -1
  39. package/lib/color/ui/ColorScaleTone.d.ts +17 -0
  40. package/lib/color/ui/ColorScaleTone.d.ts.map +1 -0
  41. package/lib/color/ui/ColorScaleTone.js +55 -0
  42. package/lib/color/ui/ColorScaleTone.js.map +1 -0
  43. package/lib/color/ui/ColorScaleTrack.d.ts +29 -0
  44. package/lib/color/ui/ColorScaleTrack.d.ts.map +1 -0
  45. package/lib/color/ui/ColorScaleTrack.js +143 -0
  46. package/lib/color/ui/ColorScaleTrack.js.map +1 -0
  47. package/lib/download/core/copyFigure.d.ts +14 -0
  48. package/lib/download/core/copyFigure.d.ts.map +1 -0
  49. package/lib/download/core/copyFigure.js +18 -0
  50. package/lib/download/core/copyFigure.js.map +1 -0
  51. package/lib/download/core/figureHtml.js +1 -0
  52. package/lib/download/core/figureHtml.js.map +1 -1
  53. package/lib/download/core/figureHtmlMarkup.d.ts +10 -0
  54. package/lib/download/core/figureHtmlMarkup.d.ts.map +1 -1
  55. package/lib/download/core/figureHtmlMarkup.js +7 -1
  56. package/lib/download/core/figureHtmlMarkup.js.map +1 -1
  57. package/lib/download/core/index.d.ts +2 -0
  58. package/lib/download/core/index.d.ts.map +1 -1
  59. package/lib/download/core/index.js +1 -0
  60. package/lib/download/core/index.js.map +1 -1
  61. package/lib/download/ui/FigureDownloadPanel.d.ts +2 -3
  62. package/lib/download/ui/FigureDownloadPanel.d.ts.map +1 -1
  63. package/lib/download/ui/FigureDownloadPanel.js +1 -1
  64. package/lib/download/ui/FigureDownloadPanel.js.map +1 -1
  65. package/lib/download/ui/figureDownloadHint.d.ts +1 -1
  66. package/lib/download/ui/figureDownloadHint.d.ts.map +1 -1
  67. package/lib/download/ui/figureDownloadHint.js.map +1 -1
  68. package/lib/download/ui/index.d.ts +0 -1
  69. package/lib/download/ui/index.d.ts.map +1 -1
  70. package/lib/download/ui/useFigureActions.d.ts +2 -11
  71. package/lib/download/ui/useFigureActions.d.ts.map +1 -1
  72. package/lib/download/ui/useFigureActions.js +4 -23
  73. package/lib/download/ui/useFigureActions.js.map +1 -1
  74. package/lib/download/ui/useFigureTask.d.ts +21 -0
  75. package/lib/download/ui/useFigureTask.d.ts.map +1 -0
  76. package/lib/download/ui/useFigureTask.js +27 -0
  77. package/lib/download/ui/useFigureTask.js.map +1 -0
  78. package/lib/host/core/connectHost.d.ts +75 -0
  79. package/lib/host/core/connectHost.d.ts.map +1 -0
  80. package/lib/host/core/connectHost.js +171 -0
  81. package/lib/host/core/connectHost.js.map +1 -0
  82. package/lib/host/core/hostStructure.d.ts +52 -0
  83. package/lib/host/core/hostStructure.d.ts.map +1 -0
  84. package/lib/host/core/hostStructure.js +106 -0
  85. package/lib/host/core/hostStructure.js.map +1 -0
  86. package/lib/host/core/index.d.ts +9 -0
  87. package/lib/host/core/index.d.ts.map +1 -0
  88. package/lib/host/core/index.js +5 -0
  89. package/lib/host/core/index.js.map +1 -0
  90. package/lib/host/core/kinds.d.ts +73 -0
  91. package/lib/host/core/kinds.d.ts.map +1 -0
  92. package/lib/host/core/kinds.js +88 -0
  93. package/lib/host/core/kinds.js.map +1 -0
  94. package/lib/host/core/protocol.d.ts +134 -0
  95. package/lib/host/core/protocol.d.ts.map +1 -0
  96. package/lib/host/core/protocol.js +92 -0
  97. package/lib/host/core/protocol.js.map +1 -0
  98. package/lib/host/testing/sciPeaks.d.ts +21 -0
  99. package/lib/host/testing/sciPeaks.d.ts.map +1 -0
  100. package/lib/host/testing/sciPeaks.js +62 -0
  101. package/lib/host/testing/sciPeaks.js.map +1 -0
  102. package/lib/host/testing/standInHost.d.ts +47 -0
  103. package/lib/host/testing/standInHost.d.ts.map +1 -0
  104. package/lib/host/testing/standInHost.js +85 -0
  105. package/lib/host/testing/standInHost.js.map +1 -0
  106. package/lib/host/ui/index.d.ts +3 -0
  107. package/lib/host/ui/index.d.ts.map +1 -0
  108. package/lib/host/ui/index.js +2 -0
  109. package/lib/host/ui/index.js.map +1 -0
  110. package/lib/host/ui/useHostConnection.d.ts +36 -0
  111. package/lib/host/ui/useHostConnection.d.ts.map +1 -0
  112. package/lib/host/ui/useHostConnection.js +62 -0
  113. package/lib/host/ui/useHostConnection.js.map +1 -0
  114. package/lib/host-testing.d.ts +8 -0
  115. package/lib/host-testing.d.ts.map +1 -0
  116. package/lib/host-testing.js +7 -0
  117. package/lib/host-testing.js.map +1 -0
  118. package/lib/host.d.ts +11 -0
  119. package/lib/host.d.ts.map +1 -0
  120. package/lib/host.js +11 -0
  121. package/lib/host.js.map +1 -0
  122. package/lib/i18n/core/chromeCatalog.d.ts +1 -1
  123. package/lib/i18n/core/chromeCatalog.d.ts.map +1 -1
  124. package/lib/locales/de.json +28 -2
  125. package/lib/locales/en.json +28 -2
  126. package/lib/locales/es.json +28 -2
  127. package/lib/locales/fr.json +28 -2
  128. package/lib/locales/it.json +28 -2
  129. package/lib/molecule3d/core/index.d.ts +1 -1
  130. package/lib/molecule3d/core/index.d.ts.map +1 -1
  131. package/lib/molecule3d/core/index.js +1 -1
  132. package/lib/molecule3d/core/index.js.map +1 -1
  133. package/lib/molecule3d/core/settings.d.ts +15 -0
  134. package/lib/molecule3d/core/settings.d.ts.map +1 -1
  135. package/lib/molecule3d/core/settings.js +25 -0
  136. package/lib/molecule3d/core/settings.js.map +1 -1
  137. package/lib/molecule3d/ui/Molecule3DExport.d.ts +3 -0
  138. package/lib/molecule3d/ui/Molecule3DExport.d.ts.map +1 -1
  139. package/lib/molecule3d/ui/Molecule3DExport.js +10 -16
  140. package/lib/molecule3d/ui/Molecule3DExport.js.map +1 -1
  141. package/lib/molecule3d/ui/Molecule3DOptions.d.ts +3 -1
  142. package/lib/molecule3d/ui/Molecule3DOptions.d.ts.map +1 -1
  143. package/lib/molecule3d/ui/Molecule3DOptions.js +22 -6
  144. package/lib/molecule3d/ui/Molecule3DOptions.js.map +1 -1
  145. package/lib/molecule3d/ui/MoleculeCanvas3D.d.ts.map +1 -1
  146. package/lib/molecule3d/ui/MoleculeCanvas3D.js +4 -3
  147. package/lib/molecule3d/ui/MoleculeCanvas3D.js.map +1 -1
  148. package/lib/molecule3d/ui/exportMoleculeImage.d.ts +9 -0
  149. package/lib/molecule3d/ui/exportMoleculeImage.d.ts.map +1 -1
  150. package/lib/molecule3d/ui/exportMoleculeImage.js +15 -0
  151. package/lib/molecule3d/ui/exportMoleculeImage.js.map +1 -1
  152. package/lib/molecule3d/ui/moleculeViewer3DProps.d.ts +2 -1
  153. package/lib/molecule3d/ui/moleculeViewer3DProps.d.ts.map +1 -1
  154. package/lib/molecule3d/ui/useImageExport.d.ts +7 -1
  155. package/lib/molecule3d/ui/useImageExport.d.ts.map +1 -1
  156. package/lib/molecule3d/ui/useImageExport.js +12 -3
  157. package/lib/molecule3d/ui/useImageExport.js.map +1 -1
  158. package/lib/overlay/ui/FigureBar.d.ts +41 -0
  159. package/lib/overlay/ui/FigureBar.d.ts.map +1 -0
  160. package/lib/overlay/ui/FigureBar.js +43 -0
  161. package/lib/overlay/ui/FigureBar.js.map +1 -0
  162. package/lib/overlay/ui/OverlayBar.d.ts +13 -4
  163. package/lib/overlay/ui/OverlayBar.d.ts.map +1 -1
  164. package/lib/overlay/ui/OverlayBar.js +2 -2
  165. package/lib/overlay/ui/OverlayBar.js.map +1 -1
  166. package/lib/overlay/ui/OverlayBarStrip.d.ts +2 -1
  167. package/lib/overlay/ui/OverlayBarStrip.d.ts.map +1 -1
  168. package/lib/overlay/ui/OverlayBarStrip.js +9 -5
  169. package/lib/overlay/ui/OverlayBarStrip.js.map +1 -1
  170. package/lib/overlay/ui/OverlayIconButton.d.ts +8 -2
  171. package/lib/overlay/ui/OverlayIconButton.d.ts.map +1 -1
  172. package/lib/overlay/ui/OverlayIconButton.js +2 -1
  173. package/lib/overlay/ui/OverlayIconButton.js.map +1 -1
  174. package/lib/overlay/ui/index.d.ts +4 -0
  175. package/lib/overlay/ui/index.d.ts.map +1 -1
  176. package/lib/overlay/ui/index.js +2 -0
  177. package/lib/overlay/ui/index.js.map +1 -1
  178. package/lib/overlay/ui/overlayBarShape.d.ts +18 -0
  179. package/lib/overlay/ui/overlayBarShape.d.ts.map +1 -1
  180. package/lib/overlay/ui/overlayStyles.d.ts +30 -0
  181. package/lib/overlay/ui/overlayStyles.d.ts.map +1 -1
  182. package/lib/overlay/ui/overlayStyles.js +52 -0
  183. package/lib/overlay/ui/overlayStyles.js.map +1 -1
  184. package/lib/overlay/ui/useFigureBarAwake.d.ts +12 -0
  185. package/lib/overlay/ui/useFigureBarAwake.d.ts.map +1 -0
  186. package/lib/overlay/ui/useFigureBarAwake.js +51 -0
  187. package/lib/overlay/ui/useFigureBarAwake.js.map +1 -0
  188. package/lib/periodic/core/elements.d.ts +6 -3
  189. package/lib/periodic/core/elements.d.ts.map +1 -1
  190. package/lib/periodic/core/elements.js +9 -3
  191. package/lib/periodic/core/elements.js.map +1 -1
  192. package/lib/periodic/core/index.d.ts +2 -2
  193. package/lib/periodic/core/index.d.ts.map +1 -1
  194. package/lib/periodic/core/index.js +1 -1
  195. package/lib/periodic/core/index.js.map +1 -1
  196. package/lib/periodic/core/layout.d.ts +33 -3
  197. package/lib/periodic/core/layout.d.ts.map +1 -1
  198. package/lib/periodic/core/layout.js +14 -0
  199. package/lib/periodic/core/layout.js.map +1 -1
  200. package/lib/periodic/ui/BlockStrip.d.ts +20 -0
  201. package/lib/periodic/ui/BlockStrip.d.ts.map +1 -0
  202. package/lib/periodic/ui/BlockStrip.js +48 -0
  203. package/lib/periodic/ui/BlockStrip.js.map +1 -0
  204. package/lib/periodic/ui/ElementCell.d.ts.map +1 -1
  205. package/lib/periodic/ui/ElementCell.js +9 -8
  206. package/lib/periodic/ui/ElementCell.js.map +1 -1
  207. package/lib/periodic/ui/PeriodicTable.d.ts.map +1 -1
  208. package/lib/periodic/ui/PeriodicTable.js +3 -1
  209. package/lib/periodic/ui/PeriodicTable.js.map +1 -1
  210. package/lib/periodic/ui/PeriodicTableHelp.d.ts +33 -0
  211. package/lib/periodic/ui/PeriodicTableHelp.d.ts.map +1 -0
  212. package/lib/periodic/ui/PeriodicTableHelp.js +107 -0
  213. package/lib/periodic/ui/PeriodicTableHelp.js.map +1 -0
  214. package/lib/periodic/ui/cellStyles.d.ts +3 -2
  215. package/lib/periodic/ui/cellStyles.d.ts.map +1 -1
  216. package/lib/periodic/ui/cellStyles.js +3 -2
  217. package/lib/periodic/ui/cellStyles.js.map +1 -1
  218. package/lib/periodic/ui/index.d.ts +2 -0
  219. package/lib/periodic/ui/index.d.ts.map +1 -1
  220. package/lib/periodic/ui/index.js +1 -0
  221. package/lib/periodic/ui/index.js.map +1 -1
  222. package/lib/periodic/ui/periodicTableProps.d.ts +5 -4
  223. package/lib/periodic/ui/periodicTableProps.d.ts.map +1 -1
  224. package/lib/periodic/ui/tableLayout.d.ts +3 -1
  225. package/lib/periodic/ui/tableLayout.d.ts.map +1 -1
  226. package/lib/periodic/ui/tableLayout.js +8 -3
  227. package/lib/periodic/ui/tableLayout.js.map +1 -1
  228. package/lib/share/ui/ShareDialogContent.d.ts +3 -2
  229. package/lib/share/ui/ShareDialogContent.d.ts.map +1 -1
  230. package/lib/share/ui/ShareDialogContent.js +5 -6
  231. package/lib/share/ui/ShareDialogContent.js.map +1 -1
  232. package/lib/share/ui/ShareLinkBar.d.ts +8 -2
  233. package/lib/share/ui/ShareLinkBar.d.ts.map +1 -1
  234. package/lib/share/ui/ShareLinkBar.js +6 -5
  235. package/lib/share/ui/ShareLinkBar.js.map +1 -1
  236. package/lib/share/ui/SharePreview.d.ts.map +1 -1
  237. package/lib/share/ui/SharePreview.js +2 -2
  238. package/lib/share/ui/SharePreview.js.map +1 -1
  239. package/lib/structure/ui/StructurePicturePane.js +3 -3
  240. package/lib/structure/ui/StructurePicturePane.js.map +1 -1
  241. package/package.json +4 -1
  242. package/src/clipboard/core/index.ts +0 -1
  243. package/src/clipboard/ui/CopyButton.tsx +12 -1
  244. package/src/color/core/index.ts +9 -0
  245. package/src/color/core/interpolate.ts +51 -22
  246. package/src/color/core/stops.ts +98 -0
  247. package/src/color/core/tone.ts +79 -0
  248. package/src/color/core/uniform.ts +67 -0
  249. package/src/color/ui/ColorScaleEditor.tsx +115 -141
  250. package/src/color/ui/ColorScaleSelect.tsx +160 -36
  251. package/src/color/ui/ColorScaleTone.tsx +103 -0
  252. package/src/color/ui/ColorScaleTrack.tsx +239 -0
  253. package/src/download/core/copyFigure.ts +20 -0
  254. package/src/download/core/figureHtml.ts +1 -0
  255. package/src/download/core/figureHtmlMarkup.ts +14 -1
  256. package/src/download/core/index.ts +2 -0
  257. package/src/download/ui/FigureDownloadPanel.tsx +8 -11
  258. package/src/download/ui/figureDownloadHint.ts +1 -2
  259. package/src/download/ui/index.ts +0 -1
  260. package/src/download/ui/useFigureActions.ts +6 -42
  261. package/src/download/ui/useFigureTask.ts +46 -0
  262. package/src/host/core/connectHost.ts +240 -0
  263. package/src/host/core/hostStructure.ts +129 -0
  264. package/src/host/core/index.ts +46 -0
  265. package/src/host/core/kinds.ts +128 -0
  266. package/src/host/core/protocol.ts +197 -0
  267. package/src/host/testing/sciPeaks.ts +66 -0
  268. package/src/host/testing/standInHost.ts +116 -0
  269. package/src/host/ui/index.ts +2 -0
  270. package/src/host/ui/useHostConnection.ts +85 -0
  271. package/src/host-testing.ts +18 -0
  272. package/src/host.ts +11 -0
  273. package/src/locales/de.json +28 -2
  274. package/src/locales/en.json +28 -2
  275. package/src/locales/es.json +28 -2
  276. package/src/locales/fr.json +28 -2
  277. package/src/locales/it.json +28 -2
  278. package/src/molecule3d/core/index.ts +2 -0
  279. package/src/molecule3d/core/settings.ts +35 -0
  280. package/src/molecule3d/ui/Molecule3DExport.tsx +18 -17
  281. package/src/molecule3d/ui/Molecule3DOptions.tsx +51 -3
  282. package/src/molecule3d/ui/MoleculeCanvas3D.tsx +11 -3
  283. package/src/molecule3d/ui/exportMoleculeImage.ts +20 -0
  284. package/src/molecule3d/ui/moleculeViewer3DProps.ts +2 -1
  285. package/src/molecule3d/ui/useImageExport.ts +25 -3
  286. package/src/overlay/ui/FigureBar.tsx +96 -0
  287. package/src/overlay/ui/OverlayBar.tsx +15 -5
  288. package/src/overlay/ui/OverlayBarStrip.tsx +34 -22
  289. package/src/overlay/ui/OverlayIconButton.tsx +10 -2
  290. package/src/overlay/ui/index.ts +4 -0
  291. package/src/overlay/ui/overlayBarShape.ts +19 -0
  292. package/src/overlay/ui/overlayStyles.ts +61 -0
  293. package/src/overlay/ui/useFigureBarAwake.ts +56 -0
  294. package/src/periodic/core/elements.ts +8 -3
  295. package/src/periodic/core/index.ts +8 -1
  296. package/src/periodic/core/layout.ts +45 -3
  297. package/src/periodic/ui/BlockStrip.tsx +81 -0
  298. package/src/periodic/ui/ElementCell.tsx +9 -8
  299. package/src/periodic/ui/PeriodicTable.tsx +4 -1
  300. package/src/periodic/ui/PeriodicTableHelp.tsx +205 -0
  301. package/src/periodic/ui/cellStyles.ts +3 -2
  302. package/src/periodic/ui/index.ts +5 -0
  303. package/src/periodic/ui/periodicTableProps.ts +5 -4
  304. package/src/periodic/ui/tableLayout.ts +9 -3
  305. package/src/share/ui/ShareDialogContent.tsx +9 -13
  306. package/src/share/ui/ShareLinkBar.tsx +16 -4
  307. package/src/share/ui/SharePreview.tsx +6 -2
  308. package/src/structure/ui/StructurePicturePane.tsx +3 -3
  309. package/styles/chrome.css +43 -32
  310. package/lib/clipboard/core/copyPng.d.ts +0 -13
  311. package/lib/clipboard/core/copyPng.d.ts.map +0 -1
  312. package/lib/clipboard/core/copyPng.js +0 -19
  313. package/lib/clipboard/core/copyPng.js.map +0 -1
  314. package/src/clipboard/core/copyPng.ts +0 -20
package/README.md CHANGED
@@ -30,22 +30,24 @@ would mean two Blueprint style trees in one page.
30
30
  Subpaths are **bundle boundaries, not taxonomy**: a feature gets its own door
31
31
  only when it drags a heavy dependency behind it.
32
32
 
33
- | Import | Holds | Costs |
34
- | ---------------------------------- | ------------------------------------------------- | ------------------------------------------------ |
35
- | `react-cheminfo/core` | every framework-free helper — 140 value exports | nothing |
36
- | `react-cheminfo/ui` | every React component and hook — 60 value exports | React |
37
- | `react-cheminfo/vite` | the prerender plugin and the OG card | nothing; React on the card |
38
- | `react-cheminfo/pages` | the Cloudflare Pages analytics middleware | nothing |
39
- | `react-cheminfo/orbital` | the 3D atomic-orbital viewer | React, molstar |
40
- | `react-cheminfo/molecule3d` | the 3D molecule viewer and its toolbar | React, molstar |
41
- | `react-cheminfo/structure` | the structure editor and renderer | React, react-ocl, OCL |
42
- | `react-cheminfo/conformers` | conformer generation, ranking and refinement | OCL |
43
- | `react-cheminfo/slides` | the deck format and the slideshow player | React, react-markdown |
44
- | `react-cheminfo/spectra` | the spectra processing settings editors | React; types only from spectra-processor, ml-pca |
45
- | `react-cheminfo/ir` | the infrared chart, band table and editor | React, ir-spectrum, convert-to-jcamp |
46
- | `react-cheminfo/xtb` | GFN2-xTB as a geometry relaxer | nothing on import; xtb-wasm on the first call |
47
- | `react-cheminfo/styles/chrome.css` | the shared tokens and site-header stylesheet | nothing |
48
- | `react-cheminfo/styles/slides.css` | the deck stylesheet, themed on the site's colours | nothing |
33
+ | Import | Holds | Costs |
34
+ | ---------------------------------- | ----------------------------------------------------- | ------------------------------------------------ |
35
+ | `react-cheminfo/core` | every framework-free helper — 140 value exports | nothing |
36
+ | `react-cheminfo/ui` | every React component and hook — 60 value exports | React |
37
+ | `react-cheminfo/vite` | the prerender plugin and the OG card | nothing; React on the card |
38
+ | `react-cheminfo/pages` | the Cloudflare Pages analytics middleware | nothing |
39
+ | `react-cheminfo/orbital` | the 3D atomic-orbital viewer | React, molstar |
40
+ | `react-cheminfo/molecule3d` | the 3D molecule viewer and its toolbar | React, molstar |
41
+ | `react-cheminfo/structure` | the structure editor and renderer | React, react-ocl, OCL |
42
+ | `react-cheminfo/conformers` | conformer generation, ranking and refinement | OCL |
43
+ | `react-cheminfo/slides` | the deck format and the slideshow player | React, react-markdown |
44
+ | `react-cheminfo/spectra` | the spectra processing settings editors | React; types only from spectra-processor, ml-pca |
45
+ | `react-cheminfo/ir` | the infrared chart, band table and editor | React, ir-spectrum, convert-to-jcamp |
46
+ | `react-cheminfo/xtb` | GFN2-xTB as a geometry relaxer | nothing on import; xtb-wasm on the first call |
47
+ | `react-cheminfo/host` | data handed over by a page that frames the tool | nothing on import; ajv once the page is framed |
48
+ | `react-cheminfo/host-testing` | a stand-in host and SciPeaks' messages, for e2e tests | nothing; Node only |
49
+ | `react-cheminfo/styles/chrome.css` | the shared tokens and site-header stylesheet | nothing |
50
+ | `react-cheminfo/styles/slides.css` | the deck stylesheet, themed on the site's colours | nothing |
49
51
 
50
52
  A backend serving an RIS endpoint, a prerender script writing a sitemap, and
51
53
  every unit test of that logic therefore load no React at all — and a worker
@@ -116,6 +118,7 @@ through a wildcard subpath exactly as `react-science` serves its own.
116
118
  | **Parallel coordinates** | `parallelAxisOf`, `parallelAxisLayouts`, `parallelIncludedMask`, `parallelKeptCount`, `parallelNearestRow`, `parallelSegmentAt`, `parallelBandAt`, `parallelRangeOf`, `parallelPalette`, `parallelColorSteps`, `paintParallelLines` | `ParallelCoordinates` |
117
119
  | **Periodic table** | `PERIODIC_ELEMENTS`, `elementBySymbol`, `elementByAtomicNumber`, `cellOf`, `placedElements`, `elementByArrowKey`, `EMPTY_BLOCK`, `categorySwatch`, `CATEGORY_LABELS` | `PeriodicTable`, `ElementCell`, `CategoryLegend` |
118
120
  | **Taxonomy** | `TAXON_RANKS`, `PRINCIPAL_RANKS`, `rankOrder`, `isPrincipalRank`, `isGenusOrBelow`, `isAboveGenus`, `principalLineage`, `lineageFromNodes`, `lineageFromRanks`, `genusOrBelow`, `ncbiTaxonomyUrl`, `splitOrganismName` | `TaxonLineage`, `OrganismName`, `useRankLabel` |
121
+ | **Framed by a host** | `hostStructureLoader`, `readHostMolecule`, `STRUCTURE_KINDS`, `connectHost`, `selectInputs`, `checkValue`, `kindAccepts`, `parseRequest` (all `/host`); `startStandInHost`, `SCIPEAKS_ETHYLBENZENE_LOAD` (`/host-testing`) | `useHostConnection` (`/host`) |
119
122
 
120
123
  Everything in that table is exported from `./core`, `./ui`, `./slides`,
121
124
  `./vite` or `./structure` and nothing else is: the sub-components a component is built
@@ -836,6 +839,58 @@ const included = useMemo(
836
839
  subject — a formula through `react-mf`, a structure, a name — and a readout of
837
840
  strings cannot hold any of that.
838
841
 
842
+ ## Framed by a notebook
843
+
844
+ A page that frames a tool — an electronic lab notebook such as SciPeaks, a
845
+ course — can hand it typed data instead of writing it into the link. The tool
846
+ says `cheminfo:hello` to its parent, the parent answers `cheminfo:connect` with
847
+ a private `MessageChannel` port, and the data arrives on that port as
848
+ `{ kind, value }` items, each checked against pipeline.cheminfo.org's JSON
849
+ Schema before the tool reads it. A tool taking a structure writes two things:
850
+
851
+ ```ts
852
+ // src/tool.ts
853
+ import type { ToolInterface } from 'react-cheminfo/host';
854
+ import { STRUCTURE_KINDS, hostStructureLoader } from 'react-cheminfo/host';
855
+
856
+ export const TOOL: ToolInterface = {
857
+ name: '3d',
858
+ inputs: [{ key: 'structure', kinds: STRUCTURE_KINDS }],
859
+ outputs: [],
860
+ };
861
+
862
+ export const loadFromHost = hostStructureLoader((molecule, label) => {
863
+ loadSmiles(molecule.toIsomericSmiles(), label);
864
+ });
865
+ ```
866
+
867
+ ```tsx
868
+ // App.tsx, right after the hook that applies the address
869
+ useHostConnection(TOOL, { load: loadFromHost, build: BUILD_INFO });
870
+ ```
871
+
872
+ - **Nothing is downloaded unless the page is framed**: the connection and ajv
873
+ are one lazy chunk, fetched once a parent or an opener exists.
874
+ - **A structure that does not read is answered, not shown**: the host gets
875
+ `unreadable` with one sentence it can display, and the screen does not change.
876
+ A molfile whose atoms all sit on one point — SciPeaks stores some that way —
877
+ is laid out again.
878
+ - **The same document twice is applied once**, so a host re-sending a sample
879
+ never overwrites what the visitor did with it.
880
+
881
+ `react-cheminfo/host-testing` serves a stand-in host for Playwright on
882
+ `127.0.0.1`, and exports `SCIPEAKS_ETHYLBENZENE_LOAD`: the message SciPeaks'
883
+ tool tab sends for a sample, byte for byte. visualizer-helper's tests pin the
884
+ same message, so a change on either side fails a test rather than a notebook.
885
+
886
+ ```ts
887
+ const host = await startStandInHost();
888
+ await page.goto(
889
+ host.pageUrl(`${origin}/?embed=1`, [SCIPEAKS_ETHYLBENZENE_LOAD]),
890
+ );
891
+ const { results } = await page.evaluate(readStandInHostLog);
892
+ ```
893
+
839
894
  ## Speaking four languages
840
895
 
841
896
  Every word this library puts on a page — the header, the Tools menu, the Cite
package/bin/check-seo.mjs CHANGED
File without changes
@@ -1,4 +1,3 @@
1
- export { writeImageToClipboard } from './copyPng.ts';
2
1
  export type { WriteBlobToClipboardOptions } from './writeBlobToClipboard.ts';
3
2
  export { writeBlobToClipboard } from './writeBlobToClipboard.ts';
4
3
  export type { ClipboardContent, ClipboardText } from './writeToClipboard.ts';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/clipboard/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACrD,YAAY,EAAE,2BAA2B,EAAE,MAAM,2BAA2B,CAAC;AAC7E,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,YAAY,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/clipboard/core/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,2BAA2B,EAAE,MAAM,2BAA2B,CAAC;AAC7E,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,YAAY,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC"}
@@ -1,4 +1,3 @@
1
- export { writeImageToClipboard } from "./copyPng.js";
2
1
  export { writeBlobToClipboard } from "./writeBlobToClipboard.js";
3
2
  export { writeToClipboard } from "./writeToClipboard.js";
4
3
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/clipboard/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAErD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/clipboard/core/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC"}
@@ -61,6 +61,12 @@ export interface CopyButtonProps {
61
61
  * @default undefined
62
62
  */
63
63
  className?: string;
64
+ /**
65
+ * Called once the clipboard has taken the content — never when it refused —
66
+ * for a dialog whose whole purpose was that copy and that closes on it.
67
+ * @default undefined
68
+ */
69
+ onCopied?: () => void;
64
70
  }
65
71
  /**
66
72
  * A button that puts a piece of text on the clipboard and says so — with a
@@ -1 +1 @@
1
- {"version":3,"file":"CopyButton.d.ts","sourceRoot":"","sources":["../../../src/clipboard/ui/CopyButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAU,MAAM,mBAAmB,CAAC;AAE1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAU1C,wDAAwD;AACxD,MAAM,WAAW,eAAe;IAC9B;;;;;OAKG;IACH,OAAO,EAAE,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,CAAC;IACjC;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,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pB;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;CACvB;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,GAAG,YAAY,CA+C/D"}
@@ -10,7 +10,7 @@ import { DEFAULT_COPY_RESET_AFTER, useCopyToClipboard, } from "./useCopyToClipbo
10
10
  * @returns The copy button.
11
11
  */
12
12
  export function CopyButton(props) {
13
- const { content, label, copiedLabel, failedLabel, minimal = false, small = false, icon = 'clipboard', disabled = false, resetAfter = DEFAULT_COPY_RESET_AFTER, title, className, } = props;
13
+ const { content, label, copiedLabel, failedLabel, minimal = false, small = false, icon = 'clipboard', disabled = false, resetAfter = DEFAULT_COPY_RESET_AFTER, title, className, onCopied, } = props;
14
14
  const t = useChromeT();
15
15
  const { copied, failed, copy } = useCopyToClipboard(resetAfter);
16
16
  const hoverTitle = title ?? t('clipboard.copyToClipboard');
@@ -23,7 +23,10 @@ export function CopyButton(props) {
23
23
  failedLabel: failedLabel ?? t('clipboard.failed'),
24
24
  });
25
25
  return (_jsx(Button, { className: joinClassNames('no-print', className), variant: minimal ? 'minimal' : 'solid', size: small ? 'small' : 'medium', icon: look.icon, intent: look.intent, text: look.text, disabled: disabled, title: hoverTitle, "aria-label": label ?? hoverTitle, onClick: () => {
26
- void copy(typeof content === 'function' ? content() : content);
26
+ void copy(typeof content === 'function' ? content() : content).then((written) => {
27
+ if (written)
28
+ onCopied?.();
29
+ });
27
30
  } }));
28
31
  }
29
32
  function buttonLook(input) {
@@ -1 +1 @@
1
- {"version":3,"file":"CopyButton.js","sourceRoot":"","sources":["../../../src/clipboard/ui/CopyButton.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAG3C,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAu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QAAQ,EAAE,EAAE,CAAC;YAC5B,CAAC,CACF,CAAC;QACJ,CAAC,GACD,CACH,CAAC;AACJ,CAAC;AAWD,SAAS,UAAU,CAAC,KAAsB;IAKxC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,GAAG,KAAK,CAAC;IACxE,MAAM,QAAQ,GAAG,KAAK,KAAK,SAAS,CAAC;IACrC,IAAI,MAAM,EAAE,CAAC;QACX,OAAO;YACL,IAAI,EAAE,MAAM;YACZ,MAAM,EAAE,SAAS;YACjB,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS;SACzC,CAAC;IACJ,CAAC;IACD,IAAI,MAAM,EAAE,CAAC;QACX,OAAO;YACL,IAAI,EAAE,OAAO;YACb,MAAM,EAAE,QAAQ;YAChB,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS;SACzC,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;AAC/C,CAAC"}
@@ -11,6 +11,9 @@ export type { PositionInRangeOptions } from './scale.ts';
11
11
  export { positionInRange } from './scale.ts';
12
12
  export type { ColorScaleKind, NamedColorScale } from './scales.ts';
13
13
  export { COLOR_SCALES, COLOR_SCALE_KIND_LABELS, DEFAULT_COLOR_SCALE_ID, colorScaleById, } from './scales.ts';
14
+ export { UNIFORM_COLOR_SCALE_ID, UNIFORM_SWATCH, formatUniformColorScale, isUniformColorScale, uniformSwatch, } from './uniform.ts';
15
+ export type { ScaleTone } from './tone.ts';
16
+ export { scaleTone, setScaleTone } from './tone.ts';
14
17
  export type { ResolvedColorScale } from './scaleText.ts';
15
18
  export { MAXIMUM_CUSTOM_STOPS, formatColorScale, parseColorScale, resolveColorScale, } from './scaleText.ts';
16
19
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/color/core/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAC9E,YAAY,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,YAAY,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACvD,YAAY,EACV,kBAAkB,EAClB,UAAU,EACV,SAAS,EACT,MAAM,GACP,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC7E,YAAY,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,YAAY,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EACL,YAAY,EACZ,uBAAuB,EACvB,sBAAsB,EACtB,cAAc,GACf,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EACL,oBAAoB,EACpB,gBAAgB,EAChB,eAAe,EACf,iBAAiB,GAClB,MAAM,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/color/core/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,aAA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ate.js";
6
6
  export { positionInRange } from "./scale.js";
7
7
  export { COLOR_SCALES, COLOR_SCALE_KIND_LABELS, DEFAULT_COLOR_SCALE_ID, colorScaleById, } from "./scales.js";
8
+ export { UNIFORM_COLOR_SCALE_ID, UNIFORM_SWATCH, formatUniformColorScale, isUniformColorScale, uniformSwatch, } from "./uniform.js";
9
+ export { scaleTone, setScaleTone } from "./tone.js";
8
10
  export { MAXIMUM_CUSTOM_STOPS, formatColorScale, parseColorScale, resolveColorScale, } from "./scaleText.js";
9
11
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/color/core/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAE9E,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEnD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAOvD,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE7E,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7C,OAAO,EACL,YAAY,EACZ,uBAAuB,EACvB,sBAAsB,EACtB,cAAc,GACf,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,oBAAoB,EACpB,gBAAgB,EAChB,eAAe,EACf,iBAAiB,GAClB,MAAM,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/color/core/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAE9E,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEnD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAOvD,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE7E,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7C,OAAO,EACL,YAAY,EACZ,uBAAuB,EACvB,sBAAsB,EACtB,cAAc,GACf,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,sBAAsB,EACtB,cAAc,EACd,uBAAuB,EACvB,mBAAmB,EACnB,aAAa,GACd,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEpD,OAAO,EACL,oBAAoB,EACpB,gBAAgB,EAChB,eAAe,EACf,iBAAiB,GAClB,MAAM,gBAAgB,CAAC"}
@@ -21,8 +21,10 @@ export interface ColorStop {
21
21
  * - `hsv` turns along the colour wheel the short way round, so two anchors
22
22
  * already describe a ramp that keeps its saturation instead of fading
23
23
  * through the grey in the middle of the straight line between them.
24
- * - `hsv-long` turns the other way round, which is how two anchors of the same
25
- * hue draw a full rainbow.
24
+ * - `hsv-long` turns the whole scale one way round the wheel: the long way
25
+ * between its two ends, which is how two anchors draw a rainbow. Each anchor
26
+ * in between is reached by turning that same way, never by a turn of its own,
27
+ * so adding one where the scale already has its colour changes nothing.
26
28
  */
27
29
  export type ColorInterpolation = 'rgb' | 'hsv' | 'hsv-long';
28
30
  /** A colour scale: its anchors, and how it moves between them. */
@@ -1 +1 @@
1
- {"version":3,"file":"interpolate.d.ts","sourceRoot":"","sources":["../../../src/color/core/interpolate.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AASxD,uDAAuD;AACvD,MAAM,WAAW,MAAM;IACrB,mCAAmC;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,qCAAqC;IACrC,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,iEAAiE;AACjE,MAAM,WAAW,SAAS;IACxB,gFAAgF;IAChF,QAAQ,EAAE,MAAM,CAAC;IACjB,gDAAgD;IAChD,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;;;GAUG;AACH,MAAM,MAAM,kBAAkB,GAAG,KAAK,GAAG,KAAK,GAAG,UAAU,CAAC;AAE5D,kEAAkE;AAClE,MAAM,WAAW,UAAU;IACzB,gDAAgD;IAChD,KAAK,EAAE,SAAS,SAAS,EAAE,CAAC;IAC5B,gDAAgD;IAChD,aAAa,EAAE,kBAAkB,CAAC;CACnC;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CACvB,MAAM,EAAE,SAAS,MAAM,EAAE,EACzB,aAAa,GAAE,kBAA0B,GACxC,UAAU,CASZ;AAED;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAwBnE;AAED;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CACtB,KAAK,EAAE,UAAU,EACjB,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,kBAAuB,GAC/B,MAAM,CAGR;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAStE"}
1
+ {"version":3,"file":"interpolate.d.ts","sourceRoot":"","sources":["../../../src/color/core/interpolate.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAUxD,uDAAuD;AACvD,MAAM,WAAW,MAAM;IACrB,mCAAmC;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,qCAAqC;IACrC,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,iEAAiE;AACjE,MAAM,WAAW,SAAS;IACxB,gFAAgF;IAChF,QAAQ,EAAE,MAAM,CAAC;IACjB,gDAAgD;IAChD,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,kBAAkB,GAAG,KAAK,GAAG,KAAK,GAAG,UAAU,CAAC;AAE5D,kEAAkE;AAClE,MAAM,WAAW,UAAU;IACzB,gDAAgD;IAChD,KAAK,EAAE,SAAS,SAAS,EAAE,CAAC;IAC5B,gDAAgD;IAChD,aAAa,EAAE,kBAAkB,CAAC;CACnC;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CACvB,MAAM,EAAE,SAAS,MAAM,EAAE,EACzB,aAAa,GAAE,kBAA0B,GACxC,UAAU,CASZ;AAED;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CA4BnE;AAED;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CACtB,KAAK,EAAE,UAAU,EACjB,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,kBAAuB,GAC/B,MAAM,CAGR;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAStE"}
@@ -53,7 +53,11 @@ export function colorAt(scale, position) {
53
53
  continue;
54
54
  const span = end.position - start.position;
55
55
  const ratio = span <= 0 ? 0 : (at - start.position) / span;
56
- return mix(start.color, end.color, ratio, interpolation);
56
+ return mix(start.color, end.color, ratio, {
57
+ interpolation,
58
+ turn: longTurn(first.color, last.color),
59
+ whole: stops.length === MINIMUM_SAMPLES,
60
+ });
57
61
  }
58
62
  return toHexColor(parseHexColor(last.color));
59
63
  }
@@ -86,10 +90,10 @@ export function sampleScale(scale, count) {
86
90
  }
87
91
  return colors;
88
92
  }
89
- function mix(start, end, ratio, interpolation) {
93
+ function mix(start, end, ratio, path) {
90
94
  const from = parseHexColor(start);
91
95
  const to = parseHexColor(end);
92
- if (interpolation === 'rgb') {
96
+ if (path.interpolation === 'rgb') {
93
97
  return toHexColor({
94
98
  red: from.red + (to.red - from.red) * ratio,
95
99
  green: from.green + (to.green - from.green) * ratio,
@@ -98,20 +102,38 @@ function mix(start, end, ratio, interpolation) {
98
102
  }
99
103
  const one = rgbToHsv(from);
100
104
  const other = rgbToHsv(to);
101
- const hue = one.hue + hueStep(one.hue, other.hue, interpolation) * ratio;
105
+ const [fromHue, toHue] = pairHues(one, other);
106
+ const hue = fromHue + hueStep(fromHue, toHue, path) * ratio;
102
107
  return toHexColor(hsvToRgb({
103
108
  hue: wrapHue(hue),
104
109
  saturation: one.saturation + (other.saturation - one.saturation) * ratio,
105
110
  value: one.value + (other.value - one.value) * ratio,
106
111
  }));
107
112
  }
108
- function hueStep(from, to, interpolation) {
109
- const short = (((to - from) % TURN) + TURN + HALF_TURN) % TURN;
110
- const shortest = short - HALF_TURN;
111
- if (interpolation !== 'hsv-long')
112
- return shortest;
113
- // Two anchors of the same hue are a full turn apart the long way round,
114
- // which is what draws a rainbow from one colour back to itself.
115
- return shortest > 0 ? shortest - TURN : shortest + TURN;
113
+ // A grey, black or white has no hue of its own, so it takes the other one's:
114
+ // the path then fades to it instead of sweeping through red on the way.
115
+ function pairHues(one, other) {
116
+ if (one.saturation === 0)
117
+ return [other.hue, other.hue];
118
+ if (other.saturation === 0)
119
+ return [one.hue, one.hue];
120
+ return [one.hue, other.hue];
121
+ }
122
+ function hueStep(from, to, path) {
123
+ if (path.interpolation !== 'hsv-long')
124
+ return shortestStep(from, to);
125
+ const step = path.turn > 0 ? upStep(from, to) : -upStep(to, from);
126
+ return step === 0 && path.whole ? path.turn * TURN : step;
127
+ }
128
+ function longTurn(first, last) {
129
+ const [from, to] = pairHues(rgbToHsv(parseHexColor(first)), rgbToHsv(parseHexColor(last)));
130
+ // Two ends of one hue are a full turn apart, taken up the wheel.
131
+ return shortestStep(from, to) > 0 ? -1 : 1;
132
+ }
133
+ function shortestStep(from, to) {
134
+ return ((((to - from) % TURN) + TURN + HALF_TURN) % TURN) - HALF_TURN;
135
+ }
136
+ function upStep(from, to) {
137
+ return (((to - from) % TURN) + TURN) % TURN;
116
138
  }
117
139
  //# sourceMappingURL=interpolate.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"interpolate.js","sourceRoot":"","sources":["../../../src/color/core/interpolate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAGnD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAEvD,MAAM,SAAS,GAAG,GAAG,CAAC;AACtB,MAAM,IAAI,GAAG,GAAG,CAAC;AACjB,MAAM,eAAe,GAAG,CAAC,CAAC;AAuC1B;;;;;GAKG;AACH,MAAM,UAAU,SAAS,CACvB,MAAyB,EACzB,gBAAoC,KAAK;IAEzC,MAAM,KAAK,GAAgB,EAAE,CAAC;IAC9B,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;IAC/B,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC;QACnD,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;QAC5B,IAAI,KAAK,KAAK,SAAS;YAAE,SAAS;QAClC,KAAK,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IAChE,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,CAAC;AAClC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAA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Aa,CAAC,IAAI,CAAC,CAAC,CAC9B,CAAC;IACF,iEAAiE;IACjE,OAAO,YAAY,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC7C,CAAC;AAED,SAAS,YAAY,CAAC,IAAY,EAAE,EAAU;IAC5C,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC,GAAG,IAAI,CAAC,GAAG,SAAS,CAAC;AACxE,CAAC;AAED,SAAS,MAAM,CAAC,IAAY,EAAE,EAAU;IACtC,OAAO,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC;AAC9C,CAAC"}
@@ -0,0 +1,43 @@
1
+ import type { ColorScale, ColorStop } from './interpolate.ts';
2
+ /** How few anchors a scale may have: one at each end of what it draws. */
3
+ export declare const MINIMUM_CUSTOM_STOPS = 2;
4
+ /** The anchors after an edit, and where the edited one now stands among them. */
5
+ export interface EditedStops {
6
+ /** The anchors, from the low end. */
7
+ stops: ColorStop[];
8
+ /** The index of the anchor that was added or moved. */
9
+ index: number;
10
+ }
11
+ /**
12
+ * Add an anchor where the reader clicked, in the colour the scale already has
13
+ * there — so adding one changes nothing until it is moved or recoloured.
14
+ * @param scale - The scale being edited.
15
+ * @param position - Where to add it, from 0 at the low end to 1 at the high end.
16
+ * @returns The anchors with the new one, or `null` when the scale already holds as many as a link may carry.
17
+ */
18
+ export declare function addColorStop(scale: ColorScale, position: number): EditedStops | null;
19
+ /**
20
+ * Move an anchor. It may pass its neighbours: the anchors are kept in order,
21
+ * and the returned index follows the one that moved.
22
+ * @param stops - The anchors, from the low end.
23
+ * @param index - Which of them moves.
24
+ * @param position - Where to, clamped to the scale.
25
+ * @returns The anchors in their new order, and where the moved one landed.
26
+ */
27
+ export declare function moveColorStop(stops: readonly ColorStop[], index: number, position: number): EditedStops;
28
+ /**
29
+ * Remove an anchor, unless the scale would be left with fewer than two.
30
+ * @param stops - The anchors, from the low end.
31
+ * @param index - Which of them to remove.
32
+ * @returns The remaining anchors, or the same ones when none may go.
33
+ */
34
+ export declare function removeColorStop(stops: readonly ColorStop[], index: number): ColorStop[];
35
+ /**
36
+ * Recolour an anchor.
37
+ * @param stops - The anchors, from the low end.
38
+ * @param index - Which of them to recolour.
39
+ * @param color - Its new colour.
40
+ * @returns The anchors, with that one recoloured.
41
+ */
42
+ export declare function recolorColorStop(stops: readonly ColorStop[], index: number, color: string): ColorStop[];
43
+ //# sourceMappingURL=stops.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stops.d.ts","sourceRoot":"","sources":["../../../src/color/core/stops.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAI9D,0EAA0E;AAC1E,eAAO,MAAM,oBAAoB,IAAI,CAAC;AAKtC,iFAAiF;AACjF,MAAM,WAAW,WAAW;IAC1B,qCAAqC;IACrC,KAAK,EAAE,SAAS,EAAE,CAAC;IACnB,uDAAuD;IACvD,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,UAAU,EACjB,QAAQ,EAAE,MAAM,GACf,WAAW,GAAG,IAAI,CAKpB;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,SAAS,SAAS,EAAE,EAC3B,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,GACf,WAAW,CAUb;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,SAAS,SAAS,EAAE,EAC3B,KAAK,EAAE,MAAM,GACZ,SAAS,EAAE,CAGb;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,SAAS,SAAS,EAAE,EAC3B,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,GACZ,SAAS,EAAE,CAEb"}
@@ -0,0 +1,66 @@
1
+ import { clamp } from "../../format/core/clamp.js";
2
+ import { colorAt } from "./interpolate.js";
3
+ import { MAXIMUM_CUSTOM_STOPS } from "./scaleText.js";
4
+ /** How few anchors a scale may have: one at each end of what it draws. */
5
+ export const MINIMUM_CUSTOM_STOPS = 2;
6
+ // A link writes three decimals, so an anchor is held where the link puts it.
7
+ const POSITION_FACTOR = 1000;
8
+ /**
9
+ * Add an anchor where the reader clicked, in the colour the scale already has
10
+ * there — so adding one changes nothing until it is moved or recoloured.
11
+ * @param scale - The scale being edited.
12
+ * @param position - Where to add it, from 0 at the low end to 1 at the high end.
13
+ * @returns The anchors with the new one, or `null` when the scale already holds as many as a link may carry.
14
+ */
15
+ export function addColorStop(scale, position) {
16
+ if (scale.stops.length >= MAXIMUM_CUSTOM_STOPS)
17
+ return null;
18
+ const at = roundPosition(position);
19
+ const added = { position: at, color: colorAt(scale, at) };
20
+ return sortAround([...scale.stops, added], added);
21
+ }
22
+ /**
23
+ * Move an anchor. It may pass its neighbours: the anchors are kept in order,
24
+ * and the returned index follows the one that moved.
25
+ * @param stops - The anchors, from the low end.
26
+ * @param index - Which of them moves.
27
+ * @param position - Where to, clamped to the scale.
28
+ * @returns The anchors in their new order, and where the moved one landed.
29
+ */
30
+ export function moveColorStop(stops, index, position) {
31
+ const stop = stops[index];
32
+ if (stop === undefined || !Number.isFinite(position)) {
33
+ return { stops: [...stops], index };
34
+ }
35
+ const moved = { ...stop, position: roundPosition(position) };
36
+ return sortAround(stops.map((other, at) => (at === index ? moved : other)), moved);
37
+ }
38
+ /**
39
+ * Remove an anchor, unless the scale would be left with fewer than two.
40
+ * @param stops - The anchors, from the low end.
41
+ * @param index - Which of them to remove.
42
+ * @returns The remaining anchors, or the same ones when none may go.
43
+ */
44
+ export function removeColorStop(stops, index) {
45
+ if (stops.length <= MINIMUM_CUSTOM_STOPS)
46
+ return [...stops];
47
+ return stops.filter((_, at) => at !== index);
48
+ }
49
+ /**
50
+ * Recolour an anchor.
51
+ * @param stops - The anchors, from the low end.
52
+ * @param index - Which of them to recolour.
53
+ * @param color - Its new colour.
54
+ * @returns The anchors, with that one recoloured.
55
+ */
56
+ export function recolorColorStop(stops, index, color) {
57
+ return stops.map((stop, at) => (at === index ? { ...stop, color } : stop));
58
+ }
59
+ function roundPosition(position) {
60
+ return Math.round(clamp(position, 0, 1) * POSITION_FACTOR) / POSITION_FACTOR;
61
+ }
62
+ function sortAround(stops, edited) {
63
+ const sorted = stops.toSorted((one, other) => one.position - other.position);
64
+ return { stops: sorted, index: sorted.indexOf(edited) };
65
+ }
66
+ //# sourceMappingURL=stops.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stops.js","sourceRoot":"","sources":["../../../src/color/core/stops.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAGnD,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAEtD,0EAA0E;AAC1E,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC;AAEtC,6EAA6E;AAC7E,MAAM,eAAe,GAAG,IAAI,CAAC;AAU7B;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAC1B,KAAiB,EACjB,QAAgB;IAEhB,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,IAAI,oBAAoB;QAAE,OAAO,IAAI,CAAC;IAC5D,MAAM,EAAE,GAAG,aAAa,CAAC,QAAQ,CAAC,CAAC;IACnC,MAAM,KAAK,GAAc,EAAE,QAAQ,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,EAAE,CAAC;IACrE,OAAO,UAAU,CAAC,CAAC,GAAG,KAAK,CAAC,KAAK,EAA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AC7E,CAAC;AAED,SAAS,aAAa,CAAC,QAAgB;IACrC,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,EAAE,CAAC,CAAC,GAAG,eAAe,CAAC,GAAG,eAAe,CAAC;AAC/E,CAAC;AAED,SAAS,UAAU,CAAC,KAAkB,EAAE,MAAiB;IACvD,MAAM,MAAM,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC,GAAG,CAAC,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC7E,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;AAC1D,CAAC"}
@@ -0,0 +1,25 @@
1
+ import type { ColorStop } from './interpolate.ts';
2
+ /** How strong and how bright a scale's colours are, taken over all its anchors. */
3
+ export interface ScaleTone {
4
+ /** How far the anchors are from grey, from 0 to 1. */
5
+ saturation: number;
6
+ /** How bright they are, from 0 for black to 1. */
7
+ value: number;
8
+ }
9
+ /**
10
+ * The saturation and the brightness of a scale's anchors, averaged: what a
11
+ * control setting both for the whole scale opens on.
12
+ * @param stops - The anchors.
13
+ * @returns Their mean saturation and mean value; both 0 when there is no anchor.
14
+ */
15
+ export declare function scaleTone(stops: readonly ColorStop[]): ScaleTone;
16
+ /**
17
+ * Give every anchor the same saturation, the same brightness, or both, keeping
18
+ * each one's hue — so the scale then only turns round the wheel. A grey anchor
19
+ * has no hue of its own and takes the hue of the nearest one that has.
20
+ * @param stops - The anchors.
21
+ * @param tone - What to set; a field left out keeps each anchor's own.
22
+ * @returns The recoloured anchors, in the same order.
23
+ */
24
+ export declare function setScaleTone(stops: readonly ColorStop[], tone: Partial<ScaleTone>): ColorStop[];
25
+ //# sourceMappingURL=tone.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tone.d.ts","sourceRoot":"","sources":["../../../src/color/core/tone.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAElD,mFAAmF;AACnF,MAAM,WAAW,SAAS;IACxB,sDAAsD;IACtD,UAAU,EAAE,MAAM,CAAC;IACnB,kDAAkD;IAClD,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,SAAS,SAAS,EAAE,GAAG,SAAS,CAahE;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,SAAS,SAAS,EAAE,EAC3B,IAAI,EAAE,OAAO,CAAC,SAAS,CAAC,GACvB,SAAS,EAAE,CAeb"}
@@ -0,0 +1,67 @@
1
+ import { clamp } from "../../format/core/clamp.js";
2
+ import { parseHexColor, toHexColor } from "./hex.js";
3
+ import { hsvToRgb, rgbToHsv } from "./hsv.js";
4
+ /**
5
+ * The saturation and the brightness of a scale's anchors, averaged: what a
6
+ * control setting both for the whole scale opens on.
7
+ * @param stops - The anchors.
8
+ * @returns Their mean saturation and mean value; both 0 when there is no anchor.
9
+ */
10
+ export function scaleTone(stops) {
11
+ const colors = toHsv(stops);
12
+ if (colors.length === 0)
13
+ return { saturation: 0, value: 0 };
14
+ let saturation = 0;
15
+ let value = 0;
16
+ for (const color of colors) {
17
+ saturation += color.saturation;
18
+ value += color.value;
19
+ }
20
+ return {
21
+ saturation: saturation / colors.length,
22
+ value: value / colors.length,
23
+ };
24
+ }
25
+ /**
26
+ * Give every anchor the same saturation, the same brightness, or both, keeping
27
+ * each one's hue — so the scale then only turns round the wheel. A grey anchor
28
+ * has no hue of its own and takes the hue of the nearest one that has.
29
+ * @param stops - The anchors.
30
+ * @param tone - What to set; a field left out keeps each anchor's own.
31
+ * @returns The recoloured anchors, in the same order.
32
+ */
33
+ export function setScaleTone(stops, tone) {
34
+ const colors = toHsv(stops);
35
+ const result = [];
36
+ for (let index = 0; index < stops.length; index++) {
37
+ const stop = stops[index];
38
+ const color = colors[index];
39
+ if (stop === undefined || color === undefined)
40
+ continue;
41
+ const toned = hsvToRgb({
42
+ hue: hueNear(colors, index),
43
+ saturation: clamp(tone.saturation ?? color.saturation, 0, 1),
44
+ value: clamp(tone.value ?? color.value, 0, 1),
45
+ });
46
+ result.push({ ...stop, color: toHexColor(toned) });
47
+ }
48
+ return result;
49
+ }
50
+ function toHsv(stops) {
51
+ const colors = [];
52
+ for (const stop of stops)
53
+ colors.push(rgbToHsv(parseHexColor(stop.color)));
54
+ return colors;
55
+ }
56
+ function hueNear(colors, index) {
57
+ for (let distance = 0; distance < colors.length; distance++) {
58
+ const before = colors[index - distance];
59
+ if (before !== undefined && before.saturation > 0)
60
+ return before.hue;
61
+ const after = colors[index + distance];
62
+ if (after !== undefined && after.saturation > 0)
63
+ return after.hue;
64
+ }
65
+ return 0;
66
+ }
67
+ //# sourceMappingURL=tone.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tone.js","sourceRoot":"","sources":["../../../src/color/core/tone.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAEnD,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAErD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAW9C;;;;;GAKG;AACH,MAAM,UAAU,SAAS,CAAC,KAA2B;IACnD,MAAM,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;IAC5B,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,UAAU,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;IAC5D,IAAI,UAAU,GAAG,CAAC,CAAC;IACnB,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,UAAU,IAAI,KAAK,CAAC,UAAU,CAAC;QAC/B,KAAK,IAAI,K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,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC3E,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,OAAO,CAAC,MAA2B,EAAE,KAAa;IACzD,KAAK,IAAI,QAAQ,GAAG,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,QAAQ,EAAE,EAAE,CAAC;QAC5D,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,GAAG,QAAQ,CAAC,CAAC;QACxC,IAAI,MAAM,KAAK,SAAS,IAAI,MAAM,CAAC,UAAU,GAAG,CAAC;YAAE,OAAO,MAAM,CAAC,GAAG,CAAC;QACrE,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,GAAG,QAAQ,CAAC,CAAC;QACvC,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,UAAU,GAAG,CAAC;YAAE,OAAO,KAAK,CAAC,GAAG,CAAC;IACpE,CAAC;IACD,OAAO,CAAC,CAAC;AACX,CAAC"}
@@ -0,0 +1,36 @@
1
+ import type { Swatch } from './interpolate.ts';
2
+ /**
3
+ * What a colour-scale picker offering one colour writes for it, and a link
4
+ * carries: every value the same colour, so the figure needs no key. Followed by
5
+ * `-` and a hex colour, e.g. `uniform-1c6e42`, it names that colour.
6
+ */
7
+ export declare const UNIFORM_COLOR_SCALE_ID = "uniform";
8
+ /**
9
+ * The one colour of a uniform scale that names none: the family's border grey
10
+ * rather than white, so a cell still stands out from a white page and from the
11
+ * white ground of a saved figure.
12
+ */
13
+ export declare const UNIFORM_SWATCH: Swatch;
14
+ /**
15
+ * Whether a scale text asks for one colour.
16
+ * @param text - A scale id or a custom scale, as a link carries it.
17
+ * @returns `true` for {@link UNIFORM_COLOR_SCALE_ID}, with or without a colour.
18
+ */
19
+ export declare function isUniformColorScale(text: string | undefined): boolean;
20
+ /**
21
+ * The colour a uniform scale text names, and the ink to write on it.
22
+ *
23
+ * A colour with a typo in it falls back to the grey rather than failing, so a
24
+ * link written by hand still opens the figure.
25
+ * @param text - A scale text, e.g. `uniform` or `uniform-1c6e42`.
26
+ * @returns The swatch it names, or {@link UNIFORM_SWATCH}.
27
+ */
28
+ export declare function uniformSwatch(text: string | undefined): Swatch;
29
+ /**
30
+ * Write one colour as the scale text a link carries; the `#` is dropped, since
31
+ * a query string is cut in two at the first one.
32
+ * @param color - The colour, as `#rgb` or `#rrggbb`.
33
+ * @returns E.g. `uniform-1c6e42`, or {@link UNIFORM_COLOR_SCALE_ID} when the colour is not a hex colour.
34
+ */
35
+ export declare function formatUniformColorScale(color: string): string;
36
+ //# sourceMappingURL=uniform.d.ts.map