@opensumi/ide-theme 2.12.1-next-079c1930

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 (326) hide show
  1. package/lib/browser/default-theme.d.ts +72 -0
  2. package/lib/browser/default-theme.d.ts.map +1 -0
  3. package/lib/browser/default-theme.js +556 -0
  4. package/lib/browser/default-theme.js.map +1 -0
  5. package/lib/browser/icon-theme-data.d.ts +12 -0
  6. package/lib/browser/icon-theme-data.d.ts.map +1 -0
  7. package/lib/browser/icon-theme-data.js +207 -0
  8. package/lib/browser/icon-theme-data.js.map +1 -0
  9. package/lib/browser/icon-theme-store.d.ts +11 -0
  10. package/lib/browser/icon-theme-store.d.ts.map +1 -0
  11. package/lib/browser/icon-theme-store.js +42 -0
  12. package/lib/browser/icon-theme-store.js.map +1 -0
  13. package/lib/browser/icon.less +15 -0
  14. package/lib/browser/icon.service.d.ts +41 -0
  15. package/lib/browser/icon.service.d.ts.map +1 -0
  16. package/lib/browser/icon.service.js +274 -0
  17. package/lib/browser/icon.service.js.map +1 -0
  18. package/lib/browser/index.d.ts +11 -0
  19. package/lib/browser/index.d.ts.map +1 -0
  20. package/lib/browser/index.js +49 -0
  21. package/lib/browser/index.js.map +1 -0
  22. package/lib/browser/semantic-tokens-registry.d.ts +18 -0
  23. package/lib/browser/semantic-tokens-registry.d.ts.map +1 -0
  24. package/lib/browser/semantic-tokens-registry.js +174 -0
  25. package/lib/browser/semantic-tokens-registry.js.map +1 -0
  26. package/lib/browser/style.service.d.ts +10 -0
  27. package/lib/browser/style.service.d.ts.map +1 -0
  28. package/lib/browser/style.service.js +46 -0
  29. package/lib/browser/style.service.js.map +1 -0
  30. package/lib/browser/theme-data.d.ts +57 -0
  31. package/lib/browser/theme-data.d.ts.map +1 -0
  32. package/lib/browser/theme-data.js +594 -0
  33. package/lib/browser/theme-data.js.map +1 -0
  34. package/lib/browser/theme-store.d.ts +13 -0
  35. package/lib/browser/theme-store.d.ts.map +1 -0
  36. package/lib/browser/theme-store.js +64 -0
  37. package/lib/browser/theme-store.js.map +1 -0
  38. package/lib/browser/theme.contribution.d.ts +28 -0
  39. package/lib/browser/theme.contribution.d.ts.map +1 -0
  40. package/lib/browser/theme.contribution.js +225 -0
  41. package/lib/browser/theme.contribution.js.map +1 -0
  42. package/lib/browser/workbench.theme.service.d.ts +76 -0
  43. package/lib/browser/workbench.theme.service.d.ts.map +1 -0
  44. package/lib/browser/workbench.theme.service.js +517 -0
  45. package/lib/browser/workbench.theme.service.js.map +1 -0
  46. package/lib/common/color-registry.d.ts +38 -0
  47. package/lib/common/color-registry.d.ts.map +1 -0
  48. package/lib/common/color-registry.js +162 -0
  49. package/lib/common/color-registry.js.map +1 -0
  50. package/lib/common/color-tokens/activity-bar.d.ts +9 -0
  51. package/lib/common/color-tokens/activity-bar.d.ts.map +1 -0
  52. package/lib/common/color-tokens/activity-bar.js +50 -0
  53. package/lib/common/color-tokens/activity-bar.js.map +1 -0
  54. package/lib/common/color-tokens/badge.d.ts +3 -0
  55. package/lib/common/color-tokens/badge.d.ts.map +1 -0
  56. package/lib/common/color-tokens/badge.js +9 -0
  57. package/lib/common/color-tokens/badge.js.map +1 -0
  58. package/lib/common/color-tokens/base.d.ts +11 -0
  59. package/lib/common/color-tokens/base.d.ts.map +1 -0
  60. package/lib/common/color-tokens/base.js +18 -0
  61. package/lib/common/color-tokens/base.js.map +1 -0
  62. package/lib/common/color-tokens/basic-color.d.ts +7 -0
  63. package/lib/common/color-tokens/basic-color.d.ts.map +1 -0
  64. package/lib/common/color-tokens/basic-color.js +11 -0
  65. package/lib/common/color-tokens/basic-color.js.map +1 -0
  66. package/lib/common/color-tokens/breadcrumb.d.ts +9 -0
  67. package/lib/common/color-tokens/breadcrumb.d.ts.map +1 -0
  68. package/lib/common/color-tokens/breadcrumb.js +16 -0
  69. package/lib/common/color-tokens/breadcrumb.js.map +1 -0
  70. package/lib/common/color-tokens/button.d.ts +5 -0
  71. package/lib/common/color-tokens/button.d.ts.map +1 -0
  72. package/lib/common/color-tokens/button.js +11 -0
  73. package/lib/common/color-tokens/button.js.map +1 -0
  74. package/lib/common/color-tokens/charts.d.ts +9 -0
  75. package/lib/common/color-tokens/charts.d.ts.map +1 -0
  76. package/lib/common/color-tokens/charts.js +17 -0
  77. package/lib/common/color-tokens/charts.js.map +1 -0
  78. package/lib/common/color-tokens/checkbox.d.ts +3 -0
  79. package/lib/common/color-tokens/checkbox.d.ts.map +1 -0
  80. package/lib/common/color-tokens/checkbox.js +8 -0
  81. package/lib/common/color-tokens/checkbox.js.map +1 -0
  82. package/lib/common/color-tokens/custom/actionbar.d.ts +6 -0
  83. package/lib/common/color-tokens/custom/actionbar.d.ts.map +1 -0
  84. package/lib/common/color-tokens/custom/actionbar.js +18 -0
  85. package/lib/common/color-tokens/custom/actionbar.js.map +1 -0
  86. package/lib/common/color-tokens/custom/activity-bar.d.ts +2 -0
  87. package/lib/common/color-tokens/custom/activity-bar.d.ts.map +1 -0
  88. package/lib/common/color-tokens/custom/activity-bar.js +13 -0
  89. package/lib/common/color-tokens/custom/activity-bar.js.map +1 -0
  90. package/lib/common/color-tokens/custom/badge.d.ts +3 -0
  91. package/lib/common/color-tokens/custom/badge.d.ts.map +1 -0
  92. package/lib/common/color-tokens/custom/badge.js +17 -0
  93. package/lib/common/color-tokens/custom/badge.js.map +1 -0
  94. package/lib/common/color-tokens/custom/base.d.ts +20 -0
  95. package/lib/common/color-tokens/custom/base.d.ts.map +1 -0
  96. package/lib/common/color-tokens/custom/base.js +29 -0
  97. package/lib/common/color-tokens/custom/base.js.map +1 -0
  98. package/lib/common/color-tokens/custom/button.d.ts +50 -0
  99. package/lib/common/color-tokens/custom/button.d.ts.map +1 -0
  100. package/lib/common/color-tokens/custom/button.js +74 -0
  101. package/lib/common/color-tokens/custom/button.js.map +1 -0
  102. package/lib/common/color-tokens/custom/checkbox.d.ts +7 -0
  103. package/lib/common/color-tokens/custom/checkbox.d.ts.map +1 -0
  104. package/lib/common/color-tokens/custom/checkbox.js +12 -0
  105. package/lib/common/color-tokens/custom/checkbox.js.map +1 -0
  106. package/lib/common/color-tokens/custom/decoration.d.ts +7 -0
  107. package/lib/common/color-tokens/custom/decoration.d.ts.map +1 -0
  108. package/lib/common/color-tokens/custom/decoration.js +38 -0
  109. package/lib/common/color-tokens/custom/decoration.js.map +1 -0
  110. package/lib/common/color-tokens/custom/editor.d.ts +3 -0
  111. package/lib/common/color-tokens/custom/editor.d.ts.map +1 -0
  112. package/lib/common/color-tokens/custom/editor.js +18 -0
  113. package/lib/common/color-tokens/custom/editor.js.map +1 -0
  114. package/lib/common/color-tokens/custom/extension.d.ts +2 -0
  115. package/lib/common/color-tokens/custom/extension.d.ts.map +1 -0
  116. package/lib/common/color-tokens/custom/extension.js +7 -0
  117. package/lib/common/color-tokens/custom/extension.js.map +1 -0
  118. package/lib/common/color-tokens/custom/icon.d.ts +6 -0
  119. package/lib/common/color-tokens/custom/icon.d.ts.map +1 -0
  120. package/lib/common/color-tokens/custom/icon.js +11 -0
  121. package/lib/common/color-tokens/custom/icon.js.map +1 -0
  122. package/lib/common/color-tokens/custom/index.d.ts +23 -0
  123. package/lib/common/color-tokens/custom/index.d.ts.map +1 -0
  124. package/lib/common/color-tokens/custom/index.js +28 -0
  125. package/lib/common/color-tokens/custom/index.js.map +1 -0
  126. package/lib/common/color-tokens/custom/input.d.ts +8 -0
  127. package/lib/common/color-tokens/custom/input.d.ts.map +1 -0
  128. package/lib/common/color-tokens/custom/input.js +18 -0
  129. package/lib/common/color-tokens/custom/input.js.map +1 -0
  130. package/lib/common/color-tokens/custom/menu.d.ts +8 -0
  131. package/lib/common/color-tokens/custom/menu.d.ts.map +1 -0
  132. package/lib/common/color-tokens/custom/menu.js +23 -0
  133. package/lib/common/color-tokens/custom/menu.js.map +1 -0
  134. package/lib/common/color-tokens/custom/modal.d.ts +8 -0
  135. package/lib/common/color-tokens/custom/modal.d.ts.map +1 -0
  136. package/lib/common/color-tokens/custom/modal.js +14 -0
  137. package/lib/common/color-tokens/custom/modal.js.map +1 -0
  138. package/lib/common/color-tokens/custom/notification.d.ts +2 -0
  139. package/lib/common/color-tokens/custom/notification.d.ts.map +1 -0
  140. package/lib/common/color-tokens/custom/notification.js +9 -0
  141. package/lib/common/color-tokens/custom/notification.js.map +1 -0
  142. package/lib/common/color-tokens/custom/panel.d.ts +10 -0
  143. package/lib/common/color-tokens/custom/panel.d.ts.map +1 -0
  144. package/lib/common/color-tokens/custom/panel.js +58 -0
  145. package/lib/common/color-tokens/custom/panel.js.map +1 -0
  146. package/lib/common/color-tokens/custom/popover.d.ts +5 -0
  147. package/lib/common/color-tokens/custom/popover.d.ts.map +1 -0
  148. package/lib/common/color-tokens/custom/popover.js +11 -0
  149. package/lib/common/color-tokens/custom/popover.js.map +1 -0
  150. package/lib/common/color-tokens/custom/select.d.ts +14 -0
  151. package/lib/common/color-tokens/custom/select.d.ts.map +1 -0
  152. package/lib/common/color-tokens/custom/select.js +23 -0
  153. package/lib/common/color-tokens/custom/select.js.map +1 -0
  154. package/lib/common/color-tokens/custom/settings.d.ts +3 -0
  155. package/lib/common/color-tokens/custom/settings.d.ts.map +1 -0
  156. package/lib/common/color-tokens/custom/settings.js +9 -0
  157. package/lib/common/color-tokens/custom/settings.js.map +1 -0
  158. package/lib/common/color-tokens/custom/statusbar.d.ts +2 -0
  159. package/lib/common/color-tokens/custom/statusbar.d.ts.map +1 -0
  160. package/lib/common/color-tokens/custom/statusbar.js +13 -0
  161. package/lib/common/color-tokens/custom/statusbar.js.map +1 -0
  162. package/lib/common/color-tokens/custom/tab.d.ts +5 -0
  163. package/lib/common/color-tokens/custom/tab.d.ts.map +1 -0
  164. package/lib/common/color-tokens/custom/tab.js +12 -0
  165. package/lib/common/color-tokens/custom/tab.js.map +1 -0
  166. package/lib/common/color-tokens/custom/tooltip.d.ts +5 -0
  167. package/lib/common/color-tokens/custom/tooltip.d.ts.map +1 -0
  168. package/lib/common/color-tokens/custom/tooltip.js +28 -0
  169. package/lib/common/color-tokens/custom/tooltip.js.map +1 -0
  170. package/lib/common/color-tokens/custom/tree.d.ts +10 -0
  171. package/lib/common/color-tokens/custom/tree.d.ts.map +1 -0
  172. package/lib/common/color-tokens/custom/tree.js +16 -0
  173. package/lib/common/color-tokens/custom/tree.js.map +1 -0
  174. package/lib/common/color-tokens/debug.d.ts +17 -0
  175. package/lib/common/color-tokens/debug.d.ts.map +1 -0
  176. package/lib/common/color-tokens/debug.js +23 -0
  177. package/lib/common/color-tokens/debug.js.map +1 -0
  178. package/lib/common/color-tokens/debugToolbar.d.ts +13 -0
  179. package/lib/common/color-tokens/debugToolbar.d.ts.map +1 -0
  180. package/lib/common/color-tokens/debugToolbar.js +66 -0
  181. package/lib/common/color-tokens/debugToolbar.js.map +1 -0
  182. package/lib/common/color-tokens/dropdown.d.ts +5 -0
  183. package/lib/common/color-tokens/dropdown.d.ts.map +1 -0
  184. package/lib/common/color-tokens/dropdown.js +12 -0
  185. package/lib/common/color-tokens/dropdown.js.map +1 -0
  186. package/lib/common/color-tokens/editor.d.ts +108 -0
  187. package/lib/common/color-tokens/editor.d.ts.map +1 -0
  188. package/lib/common/color-tokens/editor.js +154 -0
  189. package/lib/common/color-tokens/editor.js.map +1 -0
  190. package/lib/common/color-tokens/global.d.ts +2 -0
  191. package/lib/common/color-tokens/global.d.ts.map +1 -0
  192. package/lib/common/color-tokens/global.js +8 -0
  193. package/lib/common/color-tokens/global.js.map +1 -0
  194. package/lib/common/color-tokens/index.d.ts +35 -0
  195. package/lib/common/color-tokens/index.d.ts.map +1 -0
  196. package/lib/common/color-tokens/index.js +38 -0
  197. package/lib/common/color-tokens/index.js.map +1 -0
  198. package/lib/common/color-tokens/input.d.ts +16 -0
  199. package/lib/common/color-tokens/input.d.ts.map +1 -0
  200. package/lib/common/color-tokens/input.js +24 -0
  201. package/lib/common/color-tokens/input.js.map +1 -0
  202. package/lib/common/color-tokens/list-tree.d.ts +20 -0
  203. package/lib/common/color-tokens/list-tree.d.ts.map +1 -0
  204. package/lib/common/color-tokens/list-tree.js +27 -0
  205. package/lib/common/color-tokens/list-tree.js.map +1 -0
  206. package/lib/common/color-tokens/menu-bar.d.ts +4 -0
  207. package/lib/common/color-tokens/menu-bar.d.ts.map +1 -0
  208. package/lib/common/color-tokens/menu-bar.js +25 -0
  209. package/lib/common/color-tokens/menu-bar.js.map +1 -0
  210. package/lib/common/color-tokens/menu.d.ts +8 -0
  211. package/lib/common/color-tokens/menu.d.ts.map +1 -0
  212. package/lib/common/color-tokens/menu.js +16 -0
  213. package/lib/common/color-tokens/menu.js.map +1 -0
  214. package/lib/common/color-tokens/merge-conflict.d.ts +13 -0
  215. package/lib/common/color-tokens/merge-conflict.d.ts.map +1 -0
  216. package/lib/common/color-tokens/merge-conflict.js +28 -0
  217. package/lib/common/color-tokens/merge-conflict.js.map +1 -0
  218. package/lib/common/color-tokens/minimap.d.ts +6 -0
  219. package/lib/common/color-tokens/minimap.d.ts.map +1 -0
  220. package/lib/common/color-tokens/minimap.js +13 -0
  221. package/lib/common/color-tokens/minimap.js.map +1 -0
  222. package/lib/common/color-tokens/notification.d.ts +12 -0
  223. package/lib/common/color-tokens/notification.d.ts.map +1 -0
  224. package/lib/common/color-tokens/notification.js +65 -0
  225. package/lib/common/color-tokens/notification.js.map +1 -0
  226. package/lib/common/color-tokens/panel.d.ts +8 -0
  227. package/lib/common/color-tokens/panel.d.ts.map +1 -0
  228. package/lib/common/color-tokens/panel.js +46 -0
  229. package/lib/common/color-tokens/panel.js.map +1 -0
  230. package/lib/common/color-tokens/pick-view.d.ts +15 -0
  231. package/lib/common/color-tokens/pick-view.d.ts.map +1 -0
  232. package/lib/common/color-tokens/pick-view.js +22 -0
  233. package/lib/common/color-tokens/pick-view.js.map +1 -0
  234. package/lib/common/color-tokens/picker.d.ts +3 -0
  235. package/lib/common/color-tokens/picker.d.ts.map +1 -0
  236. package/lib/common/color-tokens/picker.js +9 -0
  237. package/lib/common/color-tokens/picker.js.map +1 -0
  238. package/lib/common/color-tokens/progress-bar.d.ts +2 -0
  239. package/lib/common/color-tokens/progress-bar.d.ts.map +1 -0
  240. package/lib/common/color-tokens/progress-bar.js +9 -0
  241. package/lib/common/color-tokens/progress-bar.js.map +1 -0
  242. package/lib/common/color-tokens/quick-input.d.ts +5 -0
  243. package/lib/common/color-tokens/quick-input.d.ts.map +1 -0
  244. package/lib/common/color-tokens/quick-input.js +16 -0
  245. package/lib/common/color-tokens/quick-input.js.map +1 -0
  246. package/lib/common/color-tokens/scrollbar.d.ts +5 -0
  247. package/lib/common/color-tokens/scrollbar.d.ts.map +1 -0
  248. package/lib/common/color-tokens/scrollbar.js +12 -0
  249. package/lib/common/color-tokens/scrollbar.js.map +1 -0
  250. package/lib/common/color-tokens/settings.d.ts +16 -0
  251. package/lib/common/color-tokens/settings.d.ts.map +1 -0
  252. package/lib/common/color-tokens/settings.js +33 -0
  253. package/lib/common/color-tokens/settings.js.map +1 -0
  254. package/lib/common/color-tokens/sidebar.d.ts +9 -0
  255. package/lib/common/color-tokens/sidebar.d.ts.map +1 -0
  256. package/lib/common/color-tokens/sidebar.js +49 -0
  257. package/lib/common/color-tokens/sidebar.js.map +1 -0
  258. package/lib/common/color-tokens/snippet.d.ts +8 -0
  259. package/lib/common/color-tokens/snippet.d.ts.map +1 -0
  260. package/lib/common/color-tokens/snippet.js +14 -0
  261. package/lib/common/color-tokens/snippet.js.map +1 -0
  262. package/lib/common/color-tokens/status-bar.d.ts +23 -0
  263. package/lib/common/color-tokens/status-bar.d.ts.map +1 -0
  264. package/lib/common/color-tokens/status-bar.js +122 -0
  265. package/lib/common/color-tokens/status-bar.js.map +1 -0
  266. package/lib/common/color-tokens/tab.d.ts +22 -0
  267. package/lib/common/color-tokens/tab.d.ts.map +1 -0
  268. package/lib/common/color-tokens/tab.js +116 -0
  269. package/lib/common/color-tokens/tab.js.map +1 -0
  270. package/lib/common/color-tokens/text.d.ts +8 -0
  271. package/lib/common/color-tokens/text.d.ts.map +1 -0
  272. package/lib/common/color-tokens/text.js +15 -0
  273. package/lib/common/color-tokens/text.js.map +1 -0
  274. package/lib/common/color-tokens/title-bar.d.ts +6 -0
  275. package/lib/common/color-tokens/title-bar.d.ts.map +1 -0
  276. package/lib/common/color-tokens/title-bar.js +33 -0
  277. package/lib/common/color-tokens/title-bar.js.map +1 -0
  278. package/lib/common/color-tokens/welcome-page.d.ts +5 -0
  279. package/lib/common/color-tokens/welcome-page.d.ts.map +1 -0
  280. package/lib/common/color-tokens/welcome-page.js +10 -0
  281. package/lib/common/color-tokens/welcome-page.js.map +1 -0
  282. package/lib/common/color.d.ts +163 -0
  283. package/lib/common/color.d.ts.map +1 -0
  284. package/lib/common/color.js +497 -0
  285. package/lib/common/color.js.map +1 -0
  286. package/lib/common/default-themes.d.ts +5 -0
  287. package/lib/common/default-themes.d.ts.map +1 -0
  288. package/lib/common/default-themes.js +184 -0
  289. package/lib/common/default-themes.js.map +1 -0
  290. package/lib/common/event.d.ts +8 -0
  291. package/lib/common/event.d.ts.map +1 -0
  292. package/lib/common/event.js +8 -0
  293. package/lib/common/event.js.map +1 -0
  294. package/lib/common/index.d.ts +9 -0
  295. package/lib/common/index.d.ts.map +1 -0
  296. package/lib/common/index.js +12 -0
  297. package/lib/common/index.js.map +1 -0
  298. package/lib/common/mocks/theme.service.d.ts +19 -0
  299. package/lib/common/mocks/theme.service.d.ts.map +1 -0
  300. package/lib/common/mocks/theme.service.js +49 -0
  301. package/lib/common/mocks/theme.service.js.map +1 -0
  302. package/lib/common/plistParser.d.ts +6 -0
  303. package/lib/common/plistParser.d.ts.map +1 -0
  304. package/lib/common/plistParser.js +458 -0
  305. package/lib/common/plistParser.js.map +1 -0
  306. package/lib/common/semantic-tokens-registry.d.ts +139 -0
  307. package/lib/common/semantic-tokens-registry.d.ts.map +1 -0
  308. package/lib/common/semantic-tokens-registry.js +296 -0
  309. package/lib/common/semantic-tokens-registry.js.map +1 -0
  310. package/lib/common/style.d.ts +7 -0
  311. package/lib/common/style.d.ts.map +1 -0
  312. package/lib/common/style.js +5 -0
  313. package/lib/common/style.js.map +1 -0
  314. package/lib/common/theme.service.d.ts +216 -0
  315. package/lib/common/theme.service.d.ts.map +1 -0
  316. package/lib/common/theme.service.js +109 -0
  317. package/lib/common/theme.service.js.map +1 -0
  318. package/lib/common/themeCompatibility.d.ts +3 -0
  319. package/lib/common/themeCompatibility.d.ts.map +1 -0
  320. package/lib/common/themeCompatibility.js +75 -0
  321. package/lib/common/themeCompatibility.js.map +1 -0
  322. package/lib/index.d.ts +2 -0
  323. package/lib/index.d.ts.map +1 -0
  324. package/lib/index.js +5 -0
  325. package/lib/index.js.map +1 -0
  326. package/package.json +29 -0
@@ -0,0 +1,163 @@
1
+ export declare class RGBA {
2
+ _rgbaBrand: void;
3
+ /**
4
+ * Red: integer in [0-255]
5
+ */
6
+ readonly r: number;
7
+ /**
8
+ * Green: integer in [0-255]
9
+ */
10
+ readonly g: number;
11
+ /**
12
+ * Blue: integer in [0-255]
13
+ */
14
+ readonly b: number;
15
+ /**
16
+ * Alpha: float in [0-1]
17
+ */
18
+ readonly a: number;
19
+ constructor(r: number, g: number, b: number, a?: number);
20
+ static equals(a: RGBA, b: RGBA): boolean;
21
+ }
22
+ export declare class HSLA {
23
+ _hslaBrand: void;
24
+ /**
25
+ * Hue: integer in [0, 360]
26
+ */
27
+ readonly h: number;
28
+ /**
29
+ * Saturation: float in [0, 1]
30
+ */
31
+ readonly s: number;
32
+ /**
33
+ * Luminosity: float in [0, 1]
34
+ */
35
+ readonly l: number;
36
+ /**
37
+ * Alpha: float in [0, 1]
38
+ */
39
+ readonly a: number;
40
+ constructor(h: number, s: number, l: number, a: number);
41
+ static equals(a: HSLA, b: HSLA): boolean;
42
+ /**
43
+ * Converts an RGB color value to HSL. Conversion formula
44
+ * adapted from http://en.wikipedia.org/wiki/HSL_color_space.
45
+ * Assumes r, g, and b are contained in the set [0, 255] and
46
+ * returns h in the set [0, 360], s, and l in the set [0, 1].
47
+ */
48
+ static fromRGBA(rgba: RGBA): HSLA;
49
+ private static _hue2rgb;
50
+ /**
51
+ * Converts an HSL color value to RGB. Conversion formula
52
+ * adapted from http://en.wikipedia.org/wiki/HSL_color_space.
53
+ * Assumes h in the set [0, 360] s, and l are contained in the set [0, 1] and
54
+ * returns r, g, and b in the set [0, 255].
55
+ */
56
+ static toRGBA(hsla: HSLA): RGBA;
57
+ }
58
+ export declare class HSVA {
59
+ _hsvaBrand: void;
60
+ /**
61
+ * Hue: integer in [0, 360]
62
+ */
63
+ readonly h: number;
64
+ /**
65
+ * Saturation: float in [0, 1]
66
+ */
67
+ readonly s: number;
68
+ /**
69
+ * Value: float in [0, 1]
70
+ */
71
+ readonly v: number;
72
+ /**
73
+ * Alpha: float in [0, 1]
74
+ */
75
+ readonly a: number;
76
+ constructor(h: number, s: number, v: number, a: number);
77
+ static equals(a: HSVA, b: HSVA): boolean;
78
+ static fromRGBA(rgba: RGBA): HSVA;
79
+ static toRGBA(hsva: HSVA): RGBA;
80
+ }
81
+ export declare class Color {
82
+ static fromHex(hex: string): Color;
83
+ readonly rgba: RGBA;
84
+ private _hsla?;
85
+ get hsla(): HSLA;
86
+ private _hsva?;
87
+ get hsva(): HSVA;
88
+ constructor(arg: RGBA | HSLA | HSVA);
89
+ equals(other: Color): boolean;
90
+ /**
91
+ * http://www.w3.org/TR/WCAG20/#relativeluminancedef
92
+ * Returns the number in the set [0, 1]. O => Darkest Black. 1 => Lightest white.
93
+ */
94
+ getRelativeLuminance(): number;
95
+ private static _relativeLuminanceForComponent;
96
+ /**
97
+ * http://www.w3.org/TR/WCAG20/#contrast-ratiodef
98
+ * Returns the contrast ration number in the set [1, 21].
99
+ */
100
+ getContrastRatio(another: Color): number;
101
+ /**
102
+ * http://24ways.org/2010/calculating-color-contrast
103
+ * Return 'true' if darker color otherwise 'false'
104
+ */
105
+ isDarker(): boolean;
106
+ /**
107
+ * http://24ways.org/2010/calculating-color-contrast
108
+ * Return 'true' if lighter color otherwise 'false'
109
+ */
110
+ isLighter(): boolean;
111
+ isLighterThan(another: Color): boolean;
112
+ isDarkerThan(another: Color): boolean;
113
+ lighten(factor: number): Color;
114
+ darken(factor: number): Color;
115
+ transparent(factor: number): Color;
116
+ isTransparent(): boolean;
117
+ isOpaque(): boolean;
118
+ opposite(): Color;
119
+ blend(c: Color): Color;
120
+ flatten(...backgrounds: Color[]): Color;
121
+ private static _flatten;
122
+ toString(): string;
123
+ static getLighterColor(of: Color, relative: Color, factor?: number): Color;
124
+ static getDarkerColor(of: Color, relative: Color, factor?: number): Color;
125
+ static readonly white: Color;
126
+ static readonly black: Color;
127
+ static readonly red: Color;
128
+ static readonly blue: Color;
129
+ static readonly green: Color;
130
+ static readonly cyan: Color;
131
+ static readonly lightgrey: Color;
132
+ static readonly transparent: Color;
133
+ }
134
+ export declare namespace Color {
135
+ namespace Format {
136
+ namespace CSS {
137
+ function formatRGB(color: Color): string;
138
+ function formatRGBA(color: Color): string;
139
+ function formatHSL(color: Color): string;
140
+ function formatHSLA(color: Color): string;
141
+ /**
142
+ * Formats the color as #RRGGBB
143
+ */
144
+ function formatHex(color: Color): string;
145
+ /**
146
+ * Formats the color as #RRGGBBAA
147
+ * If 'compact' is set, colors without transparancy will be printed as #RRGGBB
148
+ */
149
+ function formatHexA(color: Color, compact?: boolean): string;
150
+ /**
151
+ * The default format will use HEX if opaque and RGBA otherwise.
152
+ */
153
+ function format(color: Color): string | null;
154
+ /**
155
+ * Converts an Hex color value to a Color.
156
+ * returns r, g, and b are contained in the set [0, 255]
157
+ * @param hex string (#RGB, #RGBA, #RRGGBB or #RRGGBBAA).
158
+ */
159
+ function parseHex(hex: string): Color | null;
160
+ }
161
+ }
162
+ }
163
+ //# sourceMappingURL=color.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"color.d.ts","sourceRoot":"","sources":["../../src/common/color.ts"],"names":[],"mappings":"AAcA,qBAAa,IAAI;IACf,UAAU,EAAE,IAAI,CAAC;IAEjB;;OAEG;IACH,QAAQ,CAAC,CAAC,E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K,GAAG,MAAM,CAE9C;YAED;;;eAGG;YACH,SAAgB,UAAU,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,UAAQ,GAAG,MAAM,CAMhE;YAED;;eAEG;YACH,SAAgB,MAAM,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,GAAG,IAAI,CAUlD;YAED;;;;eAIG;YACH,SAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,GAAG,IAAI,CAsDlD;SA6BF;KACF;CACF"}
@@ -0,0 +1,497 @@
1
+ "use strict";
2
+ /*---------------------------------------------------------------------------------------------
3
+ * Copyright (c) Microsoft Corporation. All rights reserved.
4
+ * Licensed under the MIT License. See License.txt in the project root for license information.
5
+ *--------------------------------------------------------------------------------------------*/
6
+ // Some code copued and modified from https://github.com/microsoft/vscode/blob/1.44.0/src/vs/base/common/color.ts
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.Color = exports.HSVA = exports.HSLA = exports.RGBA = void 0;
9
+ function roundFloat(num, decimalPoints) {
10
+ const decimal = Math.pow(10, decimalPoints);
11
+ return Math.round(num * decimal) / decimal;
12
+ }
13
+ class RGBA {
14
+ constructor(r, g, b, a = 1) {
15
+ this.r = Math.min(255, Math.max(0, r)) | 0;
16
+ this.g = Math.min(255, Math.max(0, g)) | 0;
17
+ this.b = Math.min(255, Math.max(0, b)) | 0;
18
+ this.a = roundFloat(Math.max(Math.min(1, a), 0), 3);
19
+ }
20
+ static equals(a, b) {
21
+ return a.r === b.r && a.g === b.g && a.b === b.b && a.a === b.a;
22
+ }
23
+ }
24
+ exports.RGBA = RGBA;
25
+ class HSLA {
26
+ constructor(h, s, l, a) {
27
+ this.h = Math.max(Math.min(360, h), 0) | 0;
28
+ this.s = roundFloat(Math.max(Math.min(1, s), 0), 3);
29
+ this.l = roundFloat(Math.max(Math.min(1, l), 0), 3);
30
+ this.a = roundFloat(Math.max(Math.min(1, a), 0), 3);
31
+ }
32
+ static equals(a, b) {
33
+ return a.h === b.h && a.s === b.s && a.l === b.l && a.a === b.a;
34
+ }
35
+ /**
36
+ * Converts an RGB color value to HSL. Conversion formula
37
+ * adapted from http://en.wikipedia.org/wiki/HSL_color_space.
38
+ * Assumes r, g, and b are contained in the set [0, 255] and
39
+ * returns h in the set [0, 360], s, and l in the set [0, 1].
40
+ */
41
+ static fromRGBA(rgba) {
42
+ const r = rgba.r / 255;
43
+ const g = rgba.g / 255;
44
+ const b = rgba.b / 255;
45
+ const a = rgba.a;
46
+ const max = Math.max(r, g, b);
47
+ const min = Math.min(r, g, b);
48
+ let h = 0;
49
+ let s = 0;
50
+ const l = (min + max) / 2;
51
+ const chroma = max - min;
52
+ if (chroma > 0) {
53
+ s = Math.min((l <= 0.5 ? chroma / (2 * l) : chroma / (2 - (2 * l))), 1);
54
+ switch (max) {
55
+ case r:
56
+ h = (g - b) / chroma + (g < b ? 6 : 0);
57
+ break;
58
+ case g:
59
+ h = (b - r) / chroma + 2;
60
+ break;
61
+ case b:
62
+ h = (r - g) / chroma + 4;
63
+ break;
64
+ }
65
+ h *= 60;
66
+ h = Math.round(h);
67
+ }
68
+ return new HSLA(h, s, l, a);
69
+ }
70
+ static _hue2rgb(p, q, t) {
71
+ if (t < 0) {
72
+ t += 1;
73
+ }
74
+ if (t > 1) {
75
+ t -= 1;
76
+ }
77
+ if (t < 1 / 6) {
78
+ return p + (q - p) * 6 * t;
79
+ }
80
+ if (t < 1 / 2) {
81
+ return q;
82
+ }
83
+ if (t < 2 / 3) {
84
+ return p + (q - p) * (2 / 3 - t) * 6;
85
+ }
86
+ return p;
87
+ }
88
+ /**
89
+ * Converts an HSL color value to RGB. Conversion formula
90
+ * adapted from http://en.wikipedia.org/wiki/HSL_color_space.
91
+ * Assumes h in the set [0, 360] s, and l are contained in the set [0, 1] and
92
+ * returns r, g, and b in the set [0, 255].
93
+ */
94
+ static toRGBA(hsla) {
95
+ const h = hsla.h / 360;
96
+ const { s, l, a } = hsla;
97
+ let r;
98
+ let g;
99
+ let b;
100
+ if (s === 0) {
101
+ r = g = b = l; // achromatic
102
+ }
103
+ else {
104
+ const q = l < 0.5 ? l * (1 + s) : l + s - l * s;
105
+ const p = 2 * l - q;
106
+ r = HSLA._hue2rgb(p, q, h + 1 / 3);
107
+ g = HSLA._hue2rgb(p, q, h);
108
+ b = HSLA._hue2rgb(p, q, h - 1 / 3);
109
+ }
110
+ return new RGBA(Math.round(r * 255), Math.round(g * 255), Math.round(b * 255), a);
111
+ }
112
+ }
113
+ exports.HSLA = HSLA;
114
+ class HSVA {
115
+ constructor(h, s, v, a) {
116
+ this.h = Math.max(Math.min(360, h), 0) | 0;
117
+ this.s = roundFloat(Math.max(Math.min(1, s), 0), 3);
118
+ this.v = roundFloat(Math.max(Math.min(1, v), 0), 3);
119
+ this.a = roundFloat(Math.max(Math.min(1, a), 0), 3);
120
+ }
121
+ static equals(a, b) {
122
+ return a.h === b.h && a.s === b.s && a.v === b.v && a.a === b.a;
123
+ }
124
+ // from http://www.rapidtables.com/convert/color/rgb-to-hsv.htm
125
+ static fromRGBA(rgba) {
126
+ const r = rgba.r / 255;
127
+ const g = rgba.g / 255;
128
+ const b = rgba.b / 255;
129
+ const cmax = Math.max(r, g, b);
130
+ const cmin = Math.min(r, g, b);
131
+ const delta = cmax - cmin;
132
+ const s = cmax === 0 ? 0 : (delta / cmax);
133
+ let m;
134
+ if (delta === 0) {
135
+ m = 0;
136
+ }
137
+ else if (cmax === r) {
138
+ m = ((((g - b) / delta) % 6) + 6) % 6;
139
+ }
140
+ else if (cmax === g) {
141
+ m = ((b - r) / delta) + 2;
142
+ }
143
+ else {
144
+ m = ((r - g) / delta) + 4;
145
+ }
146
+ return new HSVA(Math.round(m * 60), s, cmax, rgba.a);
147
+ }
148
+ // from http://www.rapidtables.com/convert/color/hsv-to-rgb.htm
149
+ static toRGBA(hsva) {
150
+ const { h, s, v, a } = hsva;
151
+ const c = v * s;
152
+ const x = c * (1 - Math.abs((h / 60) % 2 - 1));
153
+ const m = v - c;
154
+ let [r, g, b] = [0, 0, 0];
155
+ if (h < 60) {
156
+ r = c;
157
+ g = x;
158
+ }
159
+ else if (h < 120) {
160
+ r = x;
161
+ g = c;
162
+ }
163
+ else if (h < 180) {
164
+ g = c;
165
+ b = x;
166
+ }
167
+ else if (h < 240) {
168
+ g = x;
169
+ b = c;
170
+ }
171
+ else if (h < 300) {
172
+ r = x;
173
+ b = c;
174
+ }
175
+ else if (h < 360) {
176
+ r = c;
177
+ b = x;
178
+ }
179
+ r = Math.round((r + m) * 255);
180
+ g = Math.round((g + m) * 255);
181
+ b = Math.round((b + m) * 255);
182
+ return new RGBA(r, g, b, a);
183
+ }
184
+ }
185
+ exports.HSVA = HSVA;
186
+ class Color {
187
+ constructor(arg) {
188
+ if (!arg) {
189
+ throw new Error('Color needs a value');
190
+ }
191
+ else if (arg instanceof RGBA) {
192
+ this.rgba = arg;
193
+ }
194
+ else if (arg instanceof HSLA) {
195
+ this._hsla = arg;
196
+ this.rgba = HSLA.toRGBA(arg);
197
+ }
198
+ else if (arg instanceof HSVA) {
199
+ this._hsva = arg;
200
+ this.rgba = HSVA.toRGBA(arg);
201
+ }
202
+ else {
203
+ throw new Error('Invalid color ctor argument');
204
+ }
205
+ }
206
+ static fromHex(hex) {
207
+ return Color.Format.CSS.parseHex(hex) || Color.red;
208
+ }
209
+ get hsla() {
210
+ if (this._hsla) {
211
+ return this._hsla;
212
+ }
213
+ else {
214
+ return HSLA.fromRGBA(this.rgba);
215
+ }
216
+ }
217
+ get hsva() {
218
+ if (this._hsva) {
219
+ return this._hsva;
220
+ }
221
+ return HSVA.fromRGBA(this.rgba);
222
+ }
223
+ equals(other) {
224
+ return !!other && RGBA.equals(this.rgba, other.rgba) && HSLA.equals(this.hsla, other.hsla) && HSVA.equals(this.hsva, other.hsva);
225
+ }
226
+ /**
227
+ * http://www.w3.org/TR/WCAG20/#relativeluminancedef
228
+ * Returns the number in the set [0, 1]. O => Darkest Black. 1 => Lightest white.
229
+ */
230
+ getRelativeLuminance() {
231
+ const R = Color._relativeLuminanceForComponent(this.rgba.r);
232
+ const G = Color._relativeLuminanceForComponent(this.rgba.g);
233
+ const B = Color._relativeLuminanceForComponent(this.rgba.b);
234
+ const luminance = 0.2126 * R + 0.7152 * G + 0.0722 * B;
235
+ return roundFloat(luminance, 4);
236
+ }
237
+ static _relativeLuminanceForComponent(color) {
238
+ const c = color / 255;
239
+ return (c <= 0.03928) ? c / 12.92 : Math.pow(((c + 0.055) / 1.055), 2.4);
240
+ }
241
+ /**
242
+ * http://www.w3.org/TR/WCAG20/#contrast-ratiodef
243
+ * Returns the contrast ration number in the set [1, 21].
244
+ */
245
+ getContrastRatio(another) {
246
+ const lum1 = this.getRelativeLuminance();
247
+ const lum2 = another.getRelativeLuminance();
248
+ return lum1 > lum2 ? (lum1 + 0.05) / (lum2 + 0.05) : (lum2 + 0.05) / (lum1 + 0.05);
249
+ }
250
+ /**
251
+ * http://24ways.org/2010/calculating-color-contrast
252
+ * Return 'true' if darker color otherwise 'false'
253
+ */
254
+ isDarker() {
255
+ const yiq = (this.rgba.r * 299 + this.rgba.g * 587 + this.rgba.b * 114) / 1000;
256
+ return yiq < 128;
257
+ }
258
+ /**
259
+ * http://24ways.org/2010/calculating-color-contrast
260
+ * Return 'true' if lighter color otherwise 'false'
261
+ */
262
+ isLighter() {
263
+ const yiq = (this.rgba.r * 299 + this.rgba.g * 587 + this.rgba.b * 114) / 1000;
264
+ return yiq >= 128;
265
+ }
266
+ isLighterThan(another) {
267
+ const lum1 = this.getRelativeLuminance();
268
+ const lum2 = another.getRelativeLuminance();
269
+ return lum1 > lum2;
270
+ }
271
+ isDarkerThan(another) {
272
+ const lum1 = this.getRelativeLuminance();
273
+ const lum2 = another.getRelativeLuminance();
274
+ return lum1 < lum2;
275
+ }
276
+ lighten(factor) {
277
+ return new Color(new HSLA(this.hsla.h, this.hsla.s, this.hsla.l + this.hsla.l * factor, this.hsla.a));
278
+ }
279
+ darken(factor) {
280
+ return new Color(new HSLA(this.hsla.h, this.hsla.s, this.hsla.l - this.hsla.l * factor, this.hsla.a));
281
+ }
282
+ transparent(factor) {
283
+ const { r, g, b, a } = this.rgba;
284
+ return new Color(new RGBA(r, g, b, a * factor));
285
+ }
286
+ isTransparent() {
287
+ return this.rgba.a === 0;
288
+ }
289
+ isOpaque() {
290
+ return this.rgba.a === 1;
291
+ }
292
+ opposite() {
293
+ return new Color(new RGBA(255 - this.rgba.r, 255 - this.rgba.g, 255 - this.rgba.b, this.rgba.a));
294
+ }
295
+ blend(c) {
296
+ const rgba = c.rgba;
297
+ // Convert to 0..1 opacity
298
+ const thisA = this.rgba.a;
299
+ const colorA = rgba.a;
300
+ const a = thisA + colorA * (1 - thisA);
301
+ if (a < 1e-6) {
302
+ return Color.transparent;
303
+ }
304
+ const r = this.rgba.r * thisA / a + rgba.r * colorA * (1 - thisA) / a;
305
+ const g = this.rgba.g * thisA / a + rgba.g * colorA * (1 - thisA) / a;
306
+ const b = this.rgba.b * thisA / a + rgba.b * colorA * (1 - thisA) / a;
307
+ return new Color(new RGBA(r, g, b, a));
308
+ }
309
+ flatten(...backgrounds) {
310
+ const background = backgrounds.reduceRight((accumulator, color) => {
311
+ return Color._flatten(color, accumulator);
312
+ });
313
+ return Color._flatten(this, background);
314
+ }
315
+ static _flatten(foreground, background) {
316
+ const backgroundAlpha = 1 - foreground.rgba.a;
317
+ return new Color(new RGBA(backgroundAlpha * background.rgba.r + foreground.rgba.a * foreground.rgba.r, backgroundAlpha * background.rgba.g + foreground.rgba.a * foreground.rgba.g, backgroundAlpha * background.rgba.b + foreground.rgba.a * foreground.rgba.b));
318
+ }
319
+ toString() {
320
+ return '' + Color.Format.CSS.format(this);
321
+ }
322
+ static getLighterColor(of, relative, factor) {
323
+ if (of.isLighterThan(relative)) {
324
+ return of;
325
+ }
326
+ factor = factor ? factor : 0.5;
327
+ const lum1 = of.getRelativeLuminance();
328
+ const lum2 = relative.getRelativeLuminance();
329
+ factor = factor * (lum2 - lum1) / lum2;
330
+ return of.lighten(factor);
331
+ }
332
+ static getDarkerColor(of, relative, factor) {
333
+ if (of.isDarkerThan(relative)) {
334
+ return of;
335
+ }
336
+ factor = factor ? factor : 0.5;
337
+ const lum1 = of.getRelativeLuminance();
338
+ const lum2 = relative.getRelativeLuminance();
339
+ factor = factor * (lum1 - lum2) / lum1;
340
+ return of.darken(factor);
341
+ }
342
+ }
343
+ exports.Color = Color;
344
+ Color.white = new Color(new RGBA(255, 255, 255, 1));
345
+ Color.black = new Color(new RGBA(0, 0, 0, 1));
346
+ Color.red = new Color(new RGBA(255, 0, 0, 1));
347
+ Color.blue = new Color(new RGBA(0, 0, 255, 1));
348
+ Color.green = new Color(new RGBA(0, 255, 0, 1));
349
+ Color.cyan = new Color(new RGBA(0, 255, 255, 1));
350
+ Color.lightgrey = new Color(new RGBA(211, 211, 211, 1));
351
+ Color.transparent = new Color(new RGBA(0, 0, 0, 0));
352
+ (function (Color) {
353
+ let Format;
354
+ (function (Format) {
355
+ let CSS;
356
+ (function (CSS) {
357
+ function formatRGB(color) {
358
+ if (color.rgba.a === 1) {
359
+ return `rgb(${color.rgba.r}, ${color.rgba.g}, ${color.rgba.b})`;
360
+ }
361
+ return Color.Format.CSS.formatRGBA(color);
362
+ }
363
+ CSS.formatRGB = formatRGB;
364
+ function formatRGBA(color) {
365
+ return `rgba(${color.rgba.r}, ${color.rgba.g}, ${color.rgba.b}, ${+(color.rgba.a).toFixed(2)})`;
366
+ }
367
+ CSS.formatRGBA = formatRGBA;
368
+ function formatHSL(color) {
369
+ if (color.hsla.a === 1) {
370
+ return `hsl(${color.hsla.h}, ${(color.hsla.s * 100).toFixed(2)}%, ${(color.hsla.l * 100).toFixed(2)}%)`;
371
+ }
372
+ return Color.Format.CSS.formatHSLA(color);
373
+ }
374
+ CSS.formatHSL = formatHSL;
375
+ function formatHSLA(color) {
376
+ return `hsla(${color.hsla.h}, ${(color.hsla.s * 100).toFixed(2)}%, ${(color.hsla.l * 100).toFixed(2)}%, ${color.hsla.a.toFixed(2)})`;
377
+ }
378
+ CSS.formatHSLA = formatHSLA;
379
+ function _toTwoDigitHex(n) {
380
+ const r = n.toString(16);
381
+ return r.length !== 2 ? '0' + r : r;
382
+ }
383
+ /**
384
+ * Formats the color as #RRGGBB
385
+ */
386
+ function formatHex(color) {
387
+ return `#${_toTwoDigitHex(color.rgba.r)}${_toTwoDigitHex(color.rgba.g)}${_toTwoDigitHex(color.rgba.b)}`;
388
+ }
389
+ CSS.formatHex = formatHex;
390
+ /**
391
+ * Formats the color as #RRGGBBAA
392
+ * If 'compact' is set, colors without transparancy will be printed as #RRGGBB
393
+ */
394
+ function formatHexA(color, compact = false) {
395
+ if (compact && color.rgba.a === 1) {
396
+ return Color.Format.CSS.formatHex(color);
397
+ }
398
+ return `#${_toTwoDigitHex(color.rgba.r)}${_toTwoDigitHex(color.rgba.g)}${_toTwoDigitHex(color.rgba.b)}${_toTwoDigitHex(Math.round(color.rgba.a * 255))}`;
399
+ }
400
+ CSS.formatHexA = formatHexA;
401
+ /**
402
+ * The default format will use HEX if opaque and RGBA otherwise.
403
+ */
404
+ function format(color) {
405
+ if (!color) {
406
+ return null;
407
+ }
408
+ if (color.isOpaque()) {
409
+ return Color.Format.CSS.formatHex(color);
410
+ }
411
+ return Color.Format.CSS.formatRGBA(color);
412
+ }
413
+ CSS.format = format;
414
+ /**
415
+ * Converts an Hex color value to a Color.
416
+ * returns r, g, and b are contained in the set [0, 255]
417
+ * @param hex string (#RGB, #RGBA, #RRGGBB or #RRGGBBAA).
418
+ */
419
+ function parseHex(hex) {
420
+ if (!hex) {
421
+ // Invalid color
422
+ return null;
423
+ }
424
+ const length = hex.length;
425
+ if (length === 0) {
426
+ // Invalid color
427
+ return null;
428
+ }
429
+ if (hex.charCodeAt(0) !== 35 /* Hash */) {
430
+ // Does not begin with a #
431
+ return null;
432
+ }
433
+ if (length === 7) {
434
+ // #RRGGBB format
435
+ const r = 16 * _parseHexDigit(hex.charCodeAt(1)) + _parseHexDigit(hex.charCodeAt(2));
436
+ const g = 16 * _parseHexDigit(hex.charCodeAt(3)) + _parseHexDigit(hex.charCodeAt(4));
437
+ const b = 16 * _parseHexDigit(hex.charCodeAt(5)) + _parseHexDigit(hex.charCodeAt(6));
438
+ return new Color(new RGBA(r, g, b, 1));
439
+ }
440
+ if (length === 9) {
441
+ // #RRGGBBAA format
442
+ const r = 16 * _parseHexDigit(hex.charCodeAt(1)) + _parseHexDigit(hex.charCodeAt(2));
443
+ const g = 16 * _parseHexDigit(hex.charCodeAt(3)) + _parseHexDigit(hex.charCodeAt(4));
444
+ const b = 16 * _parseHexDigit(hex.charCodeAt(5)) + _parseHexDigit(hex.charCodeAt(6));
445
+ const a = 16 * _parseHexDigit(hex.charCodeAt(7)) + _parseHexDigit(hex.charCodeAt(8));
446
+ return new Color(new RGBA(r, g, b, a / 255));
447
+ }
448
+ if (length === 4) {
449
+ // #RGB format
450
+ const r = _parseHexDigit(hex.charCodeAt(1));
451
+ const g = _parseHexDigit(hex.charCodeAt(2));
452
+ const b = _parseHexDigit(hex.charCodeAt(3));
453
+ return new Color(new RGBA(16 * r + r, 16 * g + g, 16 * b + b));
454
+ }
455
+ if (length === 5) {
456
+ // #RGBA format
457
+ const r = _parseHexDigit(hex.charCodeAt(1));
458
+ const g = _parseHexDigit(hex.charCodeAt(2));
459
+ const b = _parseHexDigit(hex.charCodeAt(3));
460
+ const a = _parseHexDigit(hex.charCodeAt(4));
461
+ return new Color(new RGBA(16 * r + r, 16 * g + g, 16 * b + b, (16 * a + a) / 255));
462
+ }
463
+ // Invalid color
464
+ return null;
465
+ }
466
+ CSS.parseHex = parseHex;
467
+ function _parseHexDigit(charCode) {
468
+ switch (charCode) {
469
+ case 48 /* Digit0 */: return 0;
470
+ case 49 /* Digit1 */: return 1;
471
+ case 50 /* Digit2 */: return 2;
472
+ case 51 /* Digit3 */: return 3;
473
+ case 52 /* Digit4 */: return 4;
474
+ case 53 /* Digit5 */: return 5;
475
+ case 54 /* Digit6 */: return 6;
476
+ case 55 /* Digit7 */: return 7;
477
+ case 56 /* Digit8 */: return 8;
478
+ case 57 /* Digit9 */: return 9;
479
+ case 97 /* a */: return 10;
480
+ case 65 /* A */: return 10;
481
+ case 98 /* b */: return 11;
482
+ case 66 /* B */: return 11;
483
+ case 99 /* c */: return 12;
484
+ case 67 /* C */: return 12;
485
+ case 100 /* d */: return 13;
486
+ case 68 /* D */: return 13;
487
+ case 101 /* e */: return 14;
488
+ case 69 /* E */: return 14;
489
+ case 102 /* f */: return 15;
490
+ case 70 /* F */: return 15;
491
+ }
492
+ return 0;
493
+ }
494
+ })(CSS = Format.CSS || (Format.CSS = {}));
495
+ })(Format = Color.Format || (Color.Format = {}));
496
+ })(Color = exports.Color || (exports.Color = {}));
497
+ //# sourceMappingURL=color.js.map