@tokens-studio/tokenscript-schemas 0.0.11 → 0.0.13

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 (307) hide show
  1. package/dist/cli/index.cjs +31 -8
  2. package/dist/cli/index.cjs.map +1 -1
  3. package/dist/cli/index.js +30 -8
  4. package/dist/cli/index.js.map +1 -1
  5. package/package.json +2 -1
  6. package/src/bundler/bundle-schema.ts +146 -0
  7. package/src/bundler/index.ts +151 -0
  8. package/src/bundler/schema-dependency-resolver.ts +299 -0
  9. package/src/bundler/selective-bundler.test.ts +94 -0
  10. package/src/bundler/selective-bundler.ts +159 -0
  11. package/src/bundler/types.ts +93 -0
  12. package/src/bundler/utils.ts +74 -0
  13. package/src/cli/commands/bundle.integration.test.ts +153 -0
  14. package/src/cli/commands/bundle.test.ts +57 -0
  15. package/src/cli/commands/bundle.ts +237 -0
  16. package/src/cli/commands/list.ts +109 -0
  17. package/src/cli/config-schema.ts +36 -0
  18. package/src/cli/index.ts +50 -0
  19. package/src/cli/output-generator.ts +63 -0
  20. package/src/downloader/index.ts +248 -0
  21. package/src/downloader/types.ts +48 -0
  22. package/src/index.ts +8 -0
  23. package/src/schemas/functions/adjust_chroma/adjust-chroma.tokenscript +27 -0
  24. package/src/schemas/functions/adjust_chroma/schema.json +48 -0
  25. package/src/schemas/functions/adjust_chroma/unit.test.ts +76 -0
  26. package/src/schemas/functions/adjust_hue/adjust-hue.tokenscript +32 -0
  27. package/src/schemas/functions/adjust_hue/schema.json +48 -0
  28. package/src/schemas/functions/adjust_hue/unit.test.ts +68 -0
  29. package/src/schemas/functions/adjust_lightness/adjust-lightness.tokenscript +31 -0
  30. package/src/schemas/functions/adjust_lightness/schema.json +48 -0
  31. package/src/schemas/functions/adjust_lightness/unit.test.ts +88 -0
  32. package/src/schemas/functions/adjust_to_contrast/adjust-to-contrast.tokenscript +131 -0
  33. package/src/schemas/functions/adjust_to_contrast/schema.json +56 -0
  34. package/src/schemas/functions/adjust_to_contrast/unit.test.ts +81 -0
  35. package/src/schemas/functions/alpha_blend/alpha-blend.tokenscript +46 -0
  36. package/src/schemas/functions/alpha_blend/schema.json +28 -0
  37. package/src/schemas/functions/alpha_blend/unit.test.ts +135 -0
  38. package/src/schemas/functions/alpha_scale/alpha-scale.tokenscript +38 -0
  39. package/src/schemas/functions/alpha_scale/schema.json +24 -0
  40. package/src/schemas/functions/alpha_scale/unit.test.ts +50 -0
  41. package/src/schemas/functions/analogous/analogous.tokenscript +47 -0
  42. package/src/schemas/functions/analogous/schema.json +28 -0
  43. package/src/schemas/functions/analogous/unit.test.ts +64 -0
  44. package/src/schemas/functions/apca_contrast/apca-contrast.tokenscript +129 -0
  45. package/src/schemas/functions/apca_contrast/schema.json +24 -0
  46. package/src/schemas/functions/apca_contrast/unit.test.ts +259 -0
  47. package/src/schemas/functions/are_similar/are-similar.tokenscript +24 -0
  48. package/src/schemas/functions/are_similar/schema.json +57 -0
  49. package/src/schemas/functions/are_similar/unit.test.ts +57 -0
  50. package/src/schemas/functions/auto_text_color/auto-text-color.tokenscript +41 -0
  51. package/src/schemas/functions/auto_text_color/schema.json +53 -0
  52. package/src/schemas/functions/auto_text_color/unit.test.ts +122 -0
  53. package/src/schemas/functions/best_contrast/best-contrast.tokenscript +66 -0
  54. package/src/schemas/functions/best_contrast/schema.json +24 -0
  55. package/src/schemas/functions/best_contrast/unit.test.ts +64 -0
  56. package/src/schemas/functions/chroma/chroma.tokenscript +12 -0
  57. package/src/schemas/functions/chroma/schema.json +44 -0
  58. package/src/schemas/functions/chroma/unit.test.ts +86 -0
  59. package/src/schemas/functions/clamp_chroma/clamp-chroma.tokenscript +21 -0
  60. package/src/schemas/functions/clamp_chroma/schema.json +52 -0
  61. package/src/schemas/functions/clamp_chroma/unit.test.ts +60 -0
  62. package/src/schemas/functions/clamp_lightness/clamp-lightness.tokenscript +21 -0
  63. package/src/schemas/functions/clamp_lightness/schema.json +52 -0
  64. package/src/schemas/functions/clamp_lightness/unit.test.ts +76 -0
  65. package/src/schemas/functions/clamp_to_gamut/clamp-to-gamut.tokenscript +41 -0
  66. package/src/schemas/functions/clamp_to_gamut/schema.json +20 -0
  67. package/src/schemas/functions/clamp_to_gamut/unit.test.ts +167 -0
  68. package/src/schemas/functions/complement/complement.tokenscript +21 -0
  69. package/src/schemas/functions/complement/schema.json +20 -0
  70. package/src/schemas/functions/complement/unit.test.ts +81 -0
  71. package/src/schemas/functions/contrast_ratio/contrast-ratio.tokenscript +36 -0
  72. package/src/schemas/functions/contrast_ratio/schema.json +24 -0
  73. package/src/schemas/functions/contrast_ratio/unit.test.ts +91 -0
  74. package/src/schemas/functions/cooler/cooler.tokenscript +45 -0
  75. package/src/schemas/functions/cooler/schema.json +43 -0
  76. package/src/schemas/functions/cooler/unit.test.ts +69 -0
  77. package/src/schemas/functions/darken/darken.tokenscript +37 -0
  78. package/src/schemas/functions/darken/schema.json +24 -0
  79. package/src/schemas/functions/darken/unit.test.ts +105 -0
  80. package/src/schemas/functions/delta_e_2000/delta-e-2000.tokenscript +184 -0
  81. package/src/schemas/functions/delta_e_2000/schema.json +36 -0
  82. package/src/schemas/functions/delta_e_2000/unit.test.ts +243 -0
  83. package/src/schemas/functions/delta_e_76/delta-e-76.tokenscript +45 -0
  84. package/src/schemas/functions/delta_e_76/schema.json +24 -0
  85. package/src/schemas/functions/delta_e_76/unit.test.ts +123 -0
  86. package/src/schemas/functions/delta_e_ok/delta-e-ok.tokenscript +43 -0
  87. package/src/schemas/functions/delta_e_ok/schema.json +24 -0
  88. package/src/schemas/functions/delta_e_ok/unit.test.ts +235 -0
  89. package/src/schemas/functions/desaturate/desaturate.tokenscript +32 -0
  90. package/src/schemas/functions/desaturate/schema.json +24 -0
  91. package/src/schemas/functions/desaturate/unit.test.ts +54 -0
  92. package/src/schemas/functions/distributed/distributed.tokenscript +54 -0
  93. package/src/schemas/functions/distributed/schema.json +32 -0
  94. package/src/schemas/functions/distributed/unit.test.ts +58 -0
  95. package/src/schemas/functions/diverging/diverging.tokenscript +58 -0
  96. package/src/schemas/functions/diverging/schema.json +32 -0
  97. package/src/schemas/functions/diverging/unit.test.ts +70 -0
  98. package/src/schemas/functions/grayscale/grayscale.tokenscript +17 -0
  99. package/src/schemas/functions/grayscale/schema.json +20 -0
  100. package/src/schemas/functions/grayscale/unit.test.ts +79 -0
  101. package/src/schemas/functions/harmonize/harmonize.tokenscript +61 -0
  102. package/src/schemas/functions/harmonize/schema.json +52 -0
  103. package/src/schemas/functions/harmonize/unit.test.ts +56 -0
  104. package/src/schemas/functions/hue/hue.tokenscript +12 -0
  105. package/src/schemas/functions/hue/schema.json +44 -0
  106. package/src/schemas/functions/hue/unit.test.ts +75 -0
  107. package/src/schemas/functions/hue_difference/hue-difference.tokenscript +42 -0
  108. package/src/schemas/functions/hue_difference/schema.json +24 -0
  109. package/src/schemas/functions/hue_difference/unit.test.ts +125 -0
  110. package/src/schemas/functions/in_gamut/in-gamut.tokenscript +51 -0
  111. package/src/schemas/functions/in_gamut/schema.json +24 -0
  112. package/src/schemas/functions/in_gamut/unit.test.ts +178 -0
  113. package/src/schemas/functions/interpolate/interpolate.tokenscript +61 -0
  114. package/src/schemas/functions/interpolate/schema.json +52 -0
  115. package/src/schemas/functions/interpolate/unit.test.ts +96 -0
  116. package/src/schemas/functions/invert/invert-initializer.tokenscript +29 -0
  117. package/src/schemas/functions/invert/schema.json +20 -0
  118. package/src/schemas/functions/invert/unit.test.ts +216 -0
  119. package/src/schemas/functions/is_cool/is-cool.tokenscript +41 -0
  120. package/src/schemas/functions/is_cool/schema.json +20 -0
  121. package/src/schemas/functions/is_cool/unit.test.ts +189 -0
  122. package/src/schemas/functions/is_dark/is-dark.tokenscript +16 -0
  123. package/src/schemas/functions/is_dark/schema.json +24 -0
  124. package/src/schemas/functions/is_dark/unit.test.ts +87 -0
  125. package/src/schemas/functions/is_light/is-light.tokenscript +16 -0
  126. package/src/schemas/functions/is_light/schema.json +24 -0
  127. package/src/schemas/functions/is_light/unit.test.ts +86 -0
  128. package/src/schemas/functions/is_neutral/is-neutral.tokenscript +16 -0
  129. package/src/schemas/functions/is_neutral/schema.json +53 -0
  130. package/src/schemas/functions/is_neutral/unit.test.ts +85 -0
  131. package/src/schemas/functions/is_warm/is-warm.tokenscript +62 -0
  132. package/src/schemas/functions/is_warm/schema.json +20 -0
  133. package/src/schemas/functions/is_warm/unit.test.ts +161 -0
  134. package/src/schemas/functions/lighten/lighten.tokenscript +37 -0
  135. package/src/schemas/functions/lighten/schema.json +24 -0
  136. package/src/schemas/functions/lighten/unit.test.ts +109 -0
  137. package/src/schemas/functions/lightness/lightness.tokenscript +12 -0
  138. package/src/schemas/functions/lightness/schema.json +49 -0
  139. package/src/schemas/functions/lightness/unit.test.ts +99 -0
  140. package/src/schemas/functions/luminance/luminance.tokenscript +16 -0
  141. package/src/schemas/functions/luminance/schema.json +20 -0
  142. package/src/schemas/functions/luminance/unit.test.ts +105 -0
  143. package/src/schemas/functions/meets_contrast/meets-contrast.tokenscript +49 -0
  144. package/src/schemas/functions/meets_contrast/schema.json +28 -0
  145. package/src/schemas/functions/meets_contrast/unit.test.ts +170 -0
  146. package/src/schemas/functions/mix/mix.tokenscript +47 -0
  147. package/src/schemas/functions/mix/schema.json +28 -0
  148. package/src/schemas/functions/mix/unit.test.ts +95 -0
  149. package/src/schemas/functions/monochromatic/monochromatic.tokenscript +72 -0
  150. package/src/schemas/functions/monochromatic/schema.json +24 -0
  151. package/src/schemas/functions/monochromatic/unit.test.ts +91 -0
  152. package/src/schemas/functions/muted/muted.tokenscript +25 -0
  153. package/src/schemas/functions/muted/schema.json +48 -0
  154. package/src/schemas/functions/muted/unit.test.ts +100 -0
  155. package/src/schemas/functions/neutral_variant/neutral-variant.tokenscript +23 -0
  156. package/src/schemas/functions/neutral_variant/schema.json +48 -0
  157. package/src/schemas/functions/neutral_variant/unit.test.ts +102 -0
  158. package/src/schemas/functions/relative_luminance/relative-luminance.tokenscript +15 -0
  159. package/src/schemas/functions/relative_luminance/schema.json +49 -0
  160. package/src/schemas/functions/relative_luminance/unit.test.ts +104 -0
  161. package/src/schemas/functions/rotate_hue/rotate-hue.tokenscript +20 -0
  162. package/src/schemas/functions/rotate_hue/schema.json +24 -0
  163. package/src/schemas/functions/rotate_hue/unit.test.ts +86 -0
  164. package/src/schemas/functions/saturate/saturate.tokenscript +33 -0
  165. package/src/schemas/functions/saturate/schema.json +24 -0
  166. package/src/schemas/functions/saturate/unit.test.ts +59 -0
  167. package/src/schemas/functions/scale_chroma/scale-chroma.tokenscript +22 -0
  168. package/src/schemas/functions/scale_chroma/schema.json +48 -0
  169. package/src/schemas/functions/scale_chroma/unit.test.ts +79 -0
  170. package/src/schemas/functions/scale_lightness/scale-lightness.tokenscript +23 -0
  171. package/src/schemas/functions/scale_lightness/schema.json +48 -0
  172. package/src/schemas/functions/scale_lightness/unit.test.ts +73 -0
  173. package/src/schemas/functions/sepia/schema.json +48 -0
  174. package/src/schemas/functions/sepia/sepia.tokenscript +54 -0
  175. package/src/schemas/functions/sepia/unit.test.ts +88 -0
  176. package/src/schemas/functions/set_chroma/schema.json +24 -0
  177. package/src/schemas/functions/set_chroma/set-chroma.tokenscript +18 -0
  178. package/src/schemas/functions/set_chroma/unit.test.ts +79 -0
  179. package/src/schemas/functions/set_hue/schema.json +24 -0
  180. package/src/schemas/functions/set_hue/set-hue.tokenscript +18 -0
  181. package/src/schemas/functions/set_hue/unit.test.ts +90 -0
  182. package/src/schemas/functions/set_lightness/schema.json +24 -0
  183. package/src/schemas/functions/set_lightness/set-lightness.tokenscript +18 -0
  184. package/src/schemas/functions/set_lightness/unit.test.ts +80 -0
  185. package/src/schemas/functions/shade_scale/schema.json +24 -0
  186. package/src/schemas/functions/shade_scale/shade-scale.tokenscript +61 -0
  187. package/src/schemas/functions/shade_scale/unit.test.ts +64 -0
  188. package/src/schemas/functions/split_complement/schema.json +24 -0
  189. package/src/schemas/functions/split_complement/split-complement.tokenscript +38 -0
  190. package/src/schemas/functions/split_complement/unit.test.ts +53 -0
  191. package/src/schemas/functions/steps/schema.json +28 -0
  192. package/src/schemas/functions/steps/steps.tokenscript +54 -0
  193. package/src/schemas/functions/steps/unit.test.ts +71 -0
  194. package/src/schemas/functions/tetradic/schema.json +20 -0
  195. package/src/schemas/functions/tetradic/tetradic.tokenscript +40 -0
  196. package/src/schemas/functions/tetradic/unit.test.ts +50 -0
  197. package/src/schemas/functions/tint_scale/schema.json +32 -0
  198. package/src/schemas/functions/tint_scale/tint-scale.tokenscript +71 -0
  199. package/src/schemas/functions/tint_scale/unit.test.ts +64 -0
  200. package/src/schemas/functions/to_gamut/schema.json +48 -0
  201. package/src/schemas/functions/to_gamut/to-gamut.tokenscript +96 -0
  202. package/src/schemas/functions/to_gamut/unit.test.ts +97 -0
  203. package/src/schemas/functions/triadic/schema.json +20 -0
  204. package/src/schemas/functions/triadic/triadic.tokenscript +33 -0
  205. package/src/schemas/functions/triadic/unit.test.ts +64 -0
  206. package/src/schemas/functions/vibrant/schema.json +48 -0
  207. package/src/schemas/functions/vibrant/unit.test.ts +55 -0
  208. package/src/schemas/functions/vibrant/vibrant.tokenscript +29 -0
  209. package/src/schemas/functions/warmer/schema.json +43 -0
  210. package/src/schemas/functions/warmer/unit.test.ts +69 -0
  211. package/src/schemas/functions/warmer/warmer.tokenscript +45 -0
  212. package/src/schemas/functions/wcag_level/schema.json +48 -0
  213. package/src/schemas/functions/wcag_level/unit.test.ts +75 -0
  214. package/src/schemas/functions/wcag_level/wcag-level.tokenscript +50 -0
  215. package/src/schemas/types/css-color/from-hsl-color.tokenscript +16 -0
  216. package/src/schemas/types/css-color/from-hwb-color.tokenscript +16 -0
  217. package/src/schemas/types/css-color/from-lab-color.tokenscript +16 -0
  218. package/src/schemas/types/css-color/from-lch-color.tokenscript +16 -0
  219. package/src/schemas/types/css-color/from-oklab-color.tokenscript +16 -0
  220. package/src/schemas/types/css-color/from-oklch-color.tokenscript +16 -0
  221. package/src/schemas/types/css-color/from-p3-color.tokenscript +16 -0
  222. package/src/schemas/types/css-color/from-rgb-color.tokenscript +15 -0
  223. package/src/schemas/types/css-color/from-srgb-color.tokenscript +16 -0
  224. package/src/schemas/types/css-color/from-srgb-linear-color.tokenscript +16 -0
  225. package/src/schemas/types/css-color/from-xyz-d50-color.tokenscript +16 -0
  226. package/src/schemas/types/css-color/from-xyz-d65-color.tokenscript +16 -0
  227. package/src/schemas/types/css-color/initializer.tokenscript +13 -0
  228. package/src/schemas/types/css-color/schema.json +148 -0
  229. package/src/schemas/types/css-color/unit.test.ts +402 -0
  230. package/src/schemas/types/hex-color/initializer.tokenscript +3 -0
  231. package/src/schemas/types/hex-color/schema.json +24 -0
  232. package/src/schemas/types/hex-color/unit.test.ts +123 -0
  233. package/src/schemas/types/hsl-color/from-srgb.tokenscript +87 -0
  234. package/src/schemas/types/hsl-color/initializer.tokenscript +16 -0
  235. package/src/schemas/types/hsl-color/schema.json +48 -0
  236. package/src/schemas/types/hsl-color/unit.test.ts +201 -0
  237. package/src/schemas/types/hsv-color/from-srgb.tokenscript +80 -0
  238. package/src/schemas/types/hsv-color/initializer.tokenscript +16 -0
  239. package/src/schemas/types/hsv-color/schema.json +48 -0
  240. package/src/schemas/types/hsv-color/unit.test.ts +162 -0
  241. package/src/schemas/types/hwb-color/from-hsv.tokenscript +31 -0
  242. package/src/schemas/types/hwb-color/initializer.tokenscript +16 -0
  243. package/src/schemas/types/hwb-color/schema.json +48 -0
  244. package/src/schemas/types/hwb-color/unit.test.ts +150 -0
  245. package/src/schemas/types/lab-color/from-xyz-d50.tokenscript +78 -0
  246. package/src/schemas/types/lab-color/initializer.tokenscript +16 -0
  247. package/src/schemas/types/lab-color/schema.json +48 -0
  248. package/src/schemas/types/lab-color/unit.test.ts +263 -0
  249. package/src/schemas/types/lch-color/from-lab.tokenscript +44 -0
  250. package/src/schemas/types/lch-color/initializer.tokenscript +16 -0
  251. package/src/schemas/types/lch-color/schema.json +48 -0
  252. package/src/schemas/types/lch-color/unit.test.ts +173 -0
  253. package/src/schemas/types/okhsl-color/from-oklab.tokenscript +410 -0
  254. package/src/schemas/types/okhsl-color/initializer.tokenscript +24 -0
  255. package/src/schemas/types/okhsl-color/schema.json +48 -0
  256. package/src/schemas/types/okhsl-color/unit.test.ts +514 -0
  257. package/src/schemas/types/okhsv-color/from-oklab.tokenscript +286 -0
  258. package/src/schemas/types/okhsv-color/initializer.tokenscript +24 -0
  259. package/src/schemas/types/okhsv-color/schema.json +48 -0
  260. package/src/schemas/types/okhsv-color/unit.test.ts +499 -0
  261. package/src/schemas/types/oklab-color/from-okhsl.tokenscript +195 -0
  262. package/src/schemas/types/oklab-color/from-okhsv.tokenscript +197 -0
  263. package/src/schemas/types/oklab-color/from-oklch.tokenscript +39 -0
  264. package/src/schemas/types/oklab-color/from-xyz-d65.tokenscript +43 -0
  265. package/src/schemas/types/oklab-color/initializer.tokenscript +16 -0
  266. package/src/schemas/types/oklab-color/schema.json +78 -0
  267. package/src/schemas/types/oklab-color/unit.test.ts +345 -0
  268. package/src/schemas/types/oklch-color/from-oklab.tokenscript +45 -0
  269. package/src/schemas/types/oklch-color/initializer.tokenscript +16 -0
  270. package/src/schemas/types/oklch-color/schema.json +48 -0
  271. package/src/schemas/types/oklch-color/unit.test.ts +267 -0
  272. package/src/schemas/types/p3-color/from-p3-linear.tokenscript +59 -0
  273. package/src/schemas/types/p3-color/initializer.tokenscript +16 -0
  274. package/src/schemas/types/p3-color/schema.json +48 -0
  275. package/src/schemas/types/p3-color/unit.test.ts +119 -0
  276. package/src/schemas/types/p3-linear-color/from-xyz-d65.tokenscript +47 -0
  277. package/src/schemas/types/p3-linear-color/initializer.tokenscript +16 -0
  278. package/src/schemas/types/p3-linear-color/schema.json +48 -0
  279. package/src/schemas/types/p3-linear-color/unit.test.ts +82 -0
  280. package/src/schemas/types/rgb-color/from-hex.tokenscript +43 -0
  281. package/src/schemas/types/rgb-color/initializer.tokenscript +16 -0
  282. package/src/schemas/types/rgb-color/schema.json +55 -0
  283. package/src/schemas/types/rgb-color/to-hex.tokenscript +42 -0
  284. package/src/schemas/types/rgb-color/unit.test.ts +302 -0
  285. package/src/schemas/types/srgb-color/from-hsl.tokenscript +106 -0
  286. package/src/schemas/types/srgb-color/from-linear.tokenscript +58 -0
  287. package/src/schemas/types/srgb-color/from-rgb.tokenscript +20 -0
  288. package/src/schemas/types/srgb-color/initializer.tokenscript +16 -0
  289. package/src/schemas/types/srgb-color/schema.json +68 -0
  290. package/src/schemas/types/srgb-color/unit.test.ts +303 -0
  291. package/src/schemas/types/srgb-linear-color/from-srgb.tokenscript +55 -0
  292. package/src/schemas/types/srgb-linear-color/from-xyz-d65.tokenscript +34 -0
  293. package/src/schemas/types/srgb-linear-color/initializer.tokenscript +13 -0
  294. package/src/schemas/types/srgb-linear-color/schema.json +58 -0
  295. package/src/schemas/types/srgb-linear-color/unit.test.ts +291 -0
  296. package/src/schemas/types/xyz-d50-color/from-xyz-d65.tokenscript +36 -0
  297. package/src/schemas/types/xyz-d50-color/initializer.tokenscript +16 -0
  298. package/src/schemas/types/xyz-d50-color/schema.json +48 -0
  299. package/src/schemas/types/xyz-d50-color/unit.test.ts +240 -0
  300. package/src/schemas/types/xyz-d65-color/from-linear-p3.tokenscript +47 -0
  301. package/src/schemas/types/xyz-d65-color/from-linear-srgb.tokenscript +38 -0
  302. package/src/schemas/types/xyz-d65-color/from-oklab.tokenscript +44 -0
  303. package/src/schemas/types/xyz-d65-color/initializer.tokenscript +16 -0
  304. package/src/schemas/types/xyz-d65-color/schema.json +68 -0
  305. package/src/schemas/types/xyz-d65-color/unit.test.ts +319 -0
  306. package/src/utils/schema-uri.ts +192 -0
  307. package/src/utils/type.ts +194 -0
@@ -0,0 +1,267 @@
1
+ /**
2
+ * OKLCH Color Schema Tests
3
+ *
4
+ * Tests for the OKLCH color space (polar form of OKLab)
5
+ * Validates against ColorJS for parity
6
+ */
7
+
8
+ import { log } from "@tests/helpers/logger";
9
+ import { executeWithSchema, getBundledSchema } from "@tests/helpers/schema-test-utils";
10
+ import Color from "colorjs.io";
11
+ import { describe, expect, it } from "vitest";
12
+ import type { ColorSpecification } from "@/bundler/types";
13
+
14
+ // ColorJS reference tolerance
15
+ // Hue angles can have larger differences near 0/360
16
+ const TOLERANCE = 1e-6;
17
+ const HUE_TOLERANCE = 1e-3;
18
+
19
+ describe("OKLCH Color Schema", () => {
20
+ describe("Schema Definition", () => {
21
+ it("should have correct schema structure", async () => {
22
+ const schema = (await getBundledSchema("oklch-color")) as ColorSpecification;
23
+
24
+ expect(schema.name).toBe("OKLCH");
25
+ expect(schema.type).toBe("color");
26
+ expect(schema.schema).toBeDefined();
27
+ expect(schema.schema?.properties).toHaveProperty("l");
28
+ expect(schema.schema?.properties).toHaveProperty("c");
29
+ expect(schema.schema?.properties).toHaveProperty("h");
30
+ expect(schema.schema?.required).toEqual(["l", "c", "h"]);
31
+ });
32
+
33
+ it("should have oklch initializer", async () => {
34
+ const schema = (await getBundledSchema("oklch-color")) as ColorSpecification;
35
+
36
+ expect(schema.initializers).toHaveLength(1);
37
+ expect(schema.initializers[0].keyword).toBe("oklch");
38
+ expect(schema.initializers[0].script.script).toContain("Color.OKLCH");
39
+ });
40
+
41
+ it("should have conversion from OKLab", async () => {
42
+ const schema = (await getBundledSchema("oklch-color")) as ColorSpecification;
43
+
44
+ expect(schema.conversions).toHaveLength(1);
45
+
46
+ const oklabToOklch = schema.conversions.find((c: { source: string }) =>
47
+ c.source.includes("oklab-color"),
48
+ );
49
+ expect(oklabToOklch).toBeDefined();
50
+ expect(oklabToOklch?.lossless).toBe(true);
51
+ });
52
+ });
53
+
54
+ describe("Initialization", () => {
55
+ it("should create OKLCH color from values", async () => {
56
+ const result = await executeWithSchema(
57
+ "oklch-color",
58
+ "type",
59
+ `
60
+ variable c: Color.OKLCH;
61
+ c.l = 0.7;
62
+ c.c = 0.15;
63
+ c.h = 30;
64
+ c
65
+ `,
66
+ );
67
+
68
+ expect(result?.constructor.name).toBe("ColorSymbol");
69
+ expect((result as any).subType).toBe("OKLCH");
70
+ expect((result as any).value.l.value).toBeCloseTo(0.7, 10);
71
+ expect((result as any).value.c.value).toBeCloseTo(0.15, 10);
72
+ expect((result as any).value.h.value).toBeCloseTo(30, 10);
73
+ });
74
+ });
75
+
76
+ describe("Conversion from OKLab to OKLCH", () => {
77
+ it("should convert OKLab to OKLCH correctly", async () => {
78
+ const result = await executeWithSchema(
79
+ "oklch-color",
80
+ "type",
81
+ `
82
+ variable lab: Color.OKLab;
83
+ lab.l = 0.7;
84
+ lab.a = 0.1;
85
+ lab.b = 0.05;
86
+ lab.to.oklch()
87
+ `,
88
+ );
89
+
90
+ // ColorJS reference
91
+ const colorJS = new Color("oklab", [0.7, 0.1, 0.05]).to("oklch");
92
+
93
+ expect(result?.constructor.name).toBe("ColorSymbol");
94
+ expect((result as any).subType).toBe("OKLCH");
95
+ expect((result as any).value.l.value).toBeCloseTo(colorJS.coords[0], 9);
96
+ expect((result as any).value.c.value).toBeCloseTo(colorJS.coords[1], 9);
97
+ expect((result as any).value.h.value).toBeCloseTo(colorJS.coords[2], 3);
98
+ });
99
+ });
100
+
101
+ describe("Full Conversion Chain: sRGB → ... → OKLab → OKLCH", () => {
102
+ it("should convert sRGB red through to OKLCH", async () => {
103
+ const result = await executeWithSchema(
104
+ "oklch-color",
105
+ "type",
106
+ `
107
+ variable srgb: Color.SRGB;
108
+ srgb.r = 1;
109
+ srgb.g = 0;
110
+ srgb.b = 0;
111
+
112
+ variable linear: Color.LinearSRGB = srgb.to.linearsrgb();
113
+ variable xyz: Color.XYZD65 = linear.to.xyzd65();
114
+ variable lab: Color.OKLab = xyz.to.oklab();
115
+ lab.to.oklch()
116
+ `,
117
+ );
118
+
119
+ // ColorJS reference
120
+ const colorJS = new Color("srgb", [1, 0, 0]).to("oklch");
121
+
122
+ log.info(`\n=== sRGB RED → OKLCH (full chain) ===`);
123
+ log.info(
124
+ `TokenScript: { l: ${(result as any).value.l.value}, c: ${(result as any).value.c.value}, h: ${(result as any).value.h.value} }`,
125
+ );
126
+ log.info(
127
+ `ColorJS: { l: ${colorJS.coords[0]}, c: ${colorJS.coords[1]}, h: ${colorJS.coords[2]} }`,
128
+ );
129
+
130
+ expect((result as any).value.l.value).toBeCloseTo(colorJS.coords[0], 6);
131
+ expect((result as any).value.c.value).toBeCloseTo(colorJS.coords[1], 6);
132
+ expect((result as any).value.h.value).toBeCloseTo(colorJS.coords[2], 1); // Hue needs more tolerance
133
+ });
134
+ });
135
+
136
+ describe("ColorJS Parity", () => {
137
+ const testCases = [
138
+ { name: "red", srgb: [1, 0, 0] },
139
+ { name: "green", srgb: [0, 1, 0] },
140
+ { name: "blue", srgb: [0, 0, 1] },
141
+ { name: "cyan", srgb: [0, 1, 1] },
142
+ { name: "magenta", srgb: [1, 0, 1] },
143
+ { name: "yellow", srgb: [1, 1, 0] },
144
+ { name: "coral", srgb: [1, 0.341, 0.2] },
145
+ ];
146
+
147
+ for (const { name, srgb } of testCases) {
148
+ it(`should match ColorJS for ${name}`, async () => {
149
+ const result = await executeWithSchema(
150
+ "oklch-color",
151
+ "type",
152
+ `
153
+ variable srgb: Color.SRGB;
154
+ srgb.r = ${srgb[0]};
155
+ srgb.g = ${srgb[1]};
156
+ srgb.b = ${srgb[2]};
157
+
158
+ variable linear: Color.LinearSRGB = srgb.to.linearsrgb();
159
+ variable xyz: Color.XYZD65 = linear.to.xyzd65();
160
+ variable lab: Color.OKLab = xyz.to.oklab();
161
+ lab.to.oklch()
162
+ `,
163
+ );
164
+
165
+ // ColorJS reference
166
+ const colorJS = new Color("srgb", srgb as [number, number, number]).to("oklch");
167
+
168
+ const tsL = (result as any).value.l.value;
169
+ const tsC = (result as any).value.c.value;
170
+ const tsH = (result as any).value.h.value;
171
+
172
+ const diffL = Math.abs(tsL - colorJS.coords[0]);
173
+ const diffC = Math.abs(tsC - colorJS.coords[1]);
174
+ // For hue, handle the 0/360 wraparound
175
+ let diffH = Math.abs(tsH - colorJS.coords[2]);
176
+ if (diffH > 180) diffH = 360 - diffH;
177
+
178
+ const maxDiff = Math.max(diffL, diffC);
179
+
180
+ log.info(`\n=== ${name.toUpperCase()} ColorJS Parity ===`);
181
+ log.info(`Input sRGB: { r: ${srgb[0]}, g: ${srgb[1]}, b: ${srgb[2]} }`);
182
+ log.info(
183
+ `TokenScript: { l: ${tsL.toFixed(6)}, c: ${tsC.toFixed(6)}, h: ${tsH.toFixed(3)} }`,
184
+ );
185
+ log.info(
186
+ `ColorJS: { l: ${colorJS.coords[0].toFixed(6)}, c: ${colorJS.coords[1].toFixed(6)}, h: ${colorJS.coords[2].toFixed(3)} }`,
187
+ );
188
+ log.info(`Max Diff (L,C): ${maxDiff.toExponential(2)}`);
189
+ log.info(`Hue Diff: ${diffH.toExponential(2)}`);
190
+ log.info(
191
+ `Status: ${maxDiff < TOLERANCE && diffH < HUE_TOLERANCE ? "✅ PASS" : "❌ FAIL"}`,
192
+ );
193
+
194
+ expect(maxDiff).toBeLessThan(TOLERANCE);
195
+ expect(diffH).toBeLessThan(HUE_TOLERANCE);
196
+ });
197
+ }
198
+ });
199
+
200
+ describe("Edge Cases", () => {
201
+ it("should handle neutral gray (chroma ≈ 0)", async () => {
202
+ const result = await executeWithSchema(
203
+ "oklch-color",
204
+ "type",
205
+ `
206
+ variable srgb: Color.SRGB;
207
+ srgb.r = 0.5;
208
+ srgb.g = 0.5;
209
+ srgb.b = 0.5;
210
+
211
+ variable linear: Color.LinearSRGB = srgb.to.linearsrgb();
212
+ variable xyz: Color.XYZD65 = linear.to.xyzd65();
213
+ variable lab: Color.OKLab = xyz.to.oklab();
214
+ lab.to.oklch()
215
+ `,
216
+ );
217
+
218
+ // Gray should have chroma ≈ 0
219
+ // Hue is undefined for neutral colors (NaN in ColorJS)
220
+ expect((result as any).value.c.value).toBeLessThan(1e-5);
221
+ });
222
+
223
+ it("should handle black (L=0, C=0)", async () => {
224
+ const result = await executeWithSchema(
225
+ "oklch-color",
226
+ "type",
227
+ `
228
+ variable srgb: Color.SRGB;
229
+ srgb.r = 0;
230
+ srgb.g = 0;
231
+ srgb.b = 0;
232
+
233
+ variable linear: Color.LinearSRGB = srgb.to.linearsrgb();
234
+ variable xyz: Color.XYZD65 = linear.to.xyzd65();
235
+ variable lab: Color.OKLab = xyz.to.oklab();
236
+ lab.to.oklch()
237
+ `,
238
+ );
239
+
240
+ expect((result as any).value.l.value).toBeCloseTo(0, 6);
241
+ expect((result as any).value.c.value).toBeCloseTo(0, 6);
242
+ });
243
+
244
+ it("should handle white (L=1, C=0)", async () => {
245
+ const result = await executeWithSchema(
246
+ "oklch-color",
247
+ "type",
248
+ `
249
+ variable srgb: Color.SRGB;
250
+ srgb.r = 1;
251
+ srgb.g = 1;
252
+ srgb.b = 1;
253
+
254
+ variable linear: Color.LinearSRGB = srgb.to.linearsrgb();
255
+ variable xyz: Color.XYZD65 = linear.to.xyzd65();
256
+ variable lab: Color.OKLab = xyz.to.oklab();
257
+ lab.to.oklch()
258
+ `,
259
+ );
260
+
261
+ const colorJS = new Color("srgb", [1, 1, 1]).to("oklch");
262
+
263
+ expect((result as any).value.l.value).toBeCloseTo(colorJS.coords[0], 6);
264
+ expect((result as any).value.c.value).toBeLessThan(1e-5);
265
+ });
266
+ });
267
+ });
@@ -0,0 +1,59 @@
1
+ // Linear P3 to P3 Conversion
2
+ // Applies sRGB transfer function (gamma encoding)
3
+ // P3 uses the same transfer function as sRGB
4
+ // Reference: CSS Color Level 4
5
+ //
6
+ // Algorithm (same as sRGB):
7
+ // if linear ≤ 0.0031308: encoded = 12.92 × linear
8
+ // else: encoded = 1.055 × linear^(1/2.4) - 0.055
9
+ //
10
+ // Input: Color.LinearP3 with linear r, g, b values
11
+ // Output: Color.P3 with gamma-encoded r, g, b values
12
+
13
+ // Transfer function constants (same as sRGB)
14
+ variable threshold: Number = 0.0031308;
15
+ variable linear_scale: Number = 12.92;
16
+ variable gamma_scale: Number = 1.055;
17
+ variable gamma_offset: Number = 0.055;
18
+ variable gamma_exponent: Number = 0.4166666666666667;
19
+
20
+ // Get linear values
21
+ variable linear_r: Number = {input}.r;
22
+ variable linear_g: Number = {input}.g;
23
+ variable linear_b: Number = {input}.b;
24
+
25
+ // Convert red channel
26
+ variable encoded_r: Number = 0;
27
+ if (linear_r <= threshold) [
28
+ encoded_r = linear_scale * linear_r;
29
+ ] else [
30
+ encoded_r = gamma_scale * pow(linear_r, gamma_exponent) - gamma_offset;
31
+ ];
32
+
33
+ // Convert green channel
34
+ variable encoded_g: Number = 0;
35
+ if (linear_g <= threshold) [
36
+ encoded_g = linear_scale * linear_g;
37
+ ] else [
38
+ encoded_g = gamma_scale * pow(linear_g, gamma_exponent) - gamma_offset;
39
+ ];
40
+
41
+ // Convert blue channel
42
+ variable encoded_b: Number = 0;
43
+ if (linear_b <= threshold) [
44
+ encoded_b = linear_scale * linear_b;
45
+ ] else [
46
+ encoded_b = gamma_scale * pow(linear_b, gamma_exponent) - gamma_offset;
47
+ ];
48
+
49
+ // Create output
50
+ variable output: Color.P3;
51
+ output.r = encoded_r;
52
+ output.g = encoded_g;
53
+ output.b = encoded_b;
54
+
55
+ return output;
56
+
57
+
58
+
59
+
@@ -0,0 +1,16 @@
1
+ // Display-P3 Color Initializer
2
+ // Creates a Display-P3 color from 0-1 values
3
+ // Input: List of [r, g, b] values
4
+
5
+ variable color_values: List = {input};
6
+ variable output: Color.P3;
7
+
8
+ output.r = color_values.get(0);
9
+ output.g = color_values.get(1);
10
+ output.b = color_values.get(2);
11
+
12
+ return output;
13
+
14
+
15
+
16
+
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "P3",
3
+ "type": "color",
4
+ "description": "Display-P3 color space with sRGB transfer function. Wider gamut than sRGB, common on modern Apple displays.",
5
+ "schema": {
6
+ "type": "object",
7
+ "properties": {
8
+ "r": {
9
+ "type": "number",
10
+ "description": "Red channel (0-1, can exceed for out-of-gamut)"
11
+ },
12
+ "g": {
13
+ "type": "number",
14
+ "description": "Green channel (0-1, can exceed for out-of-gamut)"
15
+ },
16
+ "b": {
17
+ "type": "number",
18
+ "description": "Blue channel (0-1, can exceed for out-of-gamut)"
19
+ }
20
+ },
21
+ "required": ["r", "g", "b"],
22
+ "order": ["r", "g", "b"],
23
+ "additionalProperties": false
24
+ },
25
+ "initializers": [
26
+ {
27
+ "title": "Display-P3 Color Initializer",
28
+ "keyword": "p3",
29
+ "description": "Creates a Display-P3 color from 0-1 values",
30
+ "script": {
31
+ "type": "/api/v1/core/tokenscript/0/",
32
+ "script": "./initializer.tokenscript"
33
+ }
34
+ }
35
+ ],
36
+ "conversions": [
37
+ {
38
+ "source": "/api/v1/core/p3-linear-color/0/",
39
+ "target": "$self",
40
+ "description": "Converts Linear P3 to P3 by applying sRGB transfer function",
41
+ "lossless": true,
42
+ "script": {
43
+ "type": "/api/v1/core/tokenscript/0/",
44
+ "script": "./from-p3-linear.tokenscript"
45
+ }
46
+ }
47
+ ]
48
+ }
@@ -0,0 +1,119 @@
1
+ /**
2
+ * Display-P3 Color Schema Tests
3
+ */
4
+
5
+ import { log } from "@tests/helpers/logger";
6
+ import { executeWithSchema, getBundledSchema } from "@tests/helpers/schema-test-utils";
7
+ import Color from "colorjs.io";
8
+ import { describe, expect, it } from "vitest";
9
+ import type { ColorSpecification } from "@/bundler/types";
10
+
11
+ describe("Display-P3 Color Schema", () => {
12
+ describe("Schema Definition", () => {
13
+ it("should have correct schema structure", async () => {
14
+ const schema = (await getBundledSchema("p3-color")) as ColorSpecification;
15
+
16
+ expect(schema.name).toBe("P3");
17
+ expect(schema.type).toBe("color");
18
+ expect(schema.schema?.properties).toHaveProperty("r");
19
+ expect(schema.schema?.properties).toHaveProperty("g");
20
+ expect(schema.schema?.properties).toHaveProperty("b");
21
+ });
22
+ });
23
+
24
+ describe("Conversion from Linear P3", () => {
25
+ const testCases = [
26
+ { name: "black", linear: [0, 0, 0] },
27
+ { name: "white", linear: [1, 1, 1] },
28
+ { name: "mid-gray", linear: [0.214, 0.214, 0.214] },
29
+ { name: "P3 red", linear: [1, 0, 0] },
30
+ { name: "P3 green", linear: [0, 1, 0] },
31
+ ];
32
+
33
+ for (const { name, linear } of testCases) {
34
+ it(`should apply gamma encoding for ${name}`, async () => {
35
+ const result = await executeWithSchema(
36
+ "p3-color",
37
+ "type",
38
+ `
39
+ variable linear: Color.LinearP3;
40
+ linear.r = ${linear[0]}; linear.g = ${linear[1]}; linear.b = ${linear[2]};
41
+ linear.to.p3()
42
+ `,
43
+ );
44
+
45
+ // ColorJS reference
46
+ const colorJS = new Color("p3-linear", linear as [number, number, number]).to("p3");
47
+
48
+ const tsR = (result as any).value.r.value;
49
+ const tsG = (result as any).value.g.value;
50
+ const tsB = (result as any).value.b.value;
51
+
52
+ expect(tsR).toBeCloseTo(colorJS.coords[0], 8);
53
+ expect(tsG).toBeCloseTo(colorJS.coords[1], 8);
54
+ expect(tsB).toBeCloseTo(colorJS.coords[2], 8);
55
+ });
56
+ }
57
+ });
58
+
59
+ describe("Full Conversion Chain: sRGB → P3", () => {
60
+ it("should convert sRGB red through to P3", async () => {
61
+ // sRGB red converted to P3 should have slightly lower values
62
+ // because P3 has a wider gamut
63
+ const result = await executeWithSchema(
64
+ "p3-color",
65
+ "type",
66
+ `
67
+ variable srgb: Color.SRGB;
68
+ srgb.r = 1; srgb.g = 0; srgb.b = 0;
69
+ variable linear_srgb: Color.LinearSRGB = srgb.to.linearsrgb();
70
+ variable xyz: Color.XYZD65 = linear_srgb.to.xyzd65();
71
+ variable linear_p3: Color.LinearP3 = xyz.to.linearp3();
72
+ linear_p3.to.p3()
73
+ `,
74
+ );
75
+
76
+ // ColorJS reference
77
+ const colorJS = new Color("srgb", [1, 0, 0]).to("p3");
78
+
79
+ const tsR = (result as any).value.r.value;
80
+ const tsG = (result as any).value.g.value;
81
+ const tsB = (result as any).value.b.value;
82
+
83
+ log.info(`\n=== sRGB Red → P3 ===`);
84
+ log.info(`TokenScript: { r: ${tsR.toFixed(6)}, g: ${tsG.toFixed(6)}, b: ${tsB.toFixed(6)} }`);
85
+ log.info(
86
+ `ColorJS: { r: ${colorJS.coords[0].toFixed(6)}, g: ${colorJS.coords[1].toFixed(6)}, b: ${colorJS.coords[2].toFixed(6)} }`,
87
+ );
88
+
89
+ expect(tsR).toBeCloseTo(colorJS.coords[0], 8);
90
+ expect(tsG).toBeCloseTo(colorJS.coords[1], 8);
91
+ expect(tsB).toBeCloseTo(colorJS.coords[2], 8);
92
+ });
93
+
94
+ it("should demonstrate P3 has wider gamut than sRGB", async () => {
95
+ // When converting sRGB colors to P3, they will be "pulled in"
96
+ // because P3 has a larger gamut - sRGB red is less saturated in P3 space
97
+ const colorJS_srgbRed = new Color("srgb", [1, 0, 0]).to("p3");
98
+
99
+ // sRGB red (1, 0, 0) in P3 space should have r < 1
100
+ // because P3 red is more saturated
101
+ log.info(`\n=== sRGB Red expressed in P3 ===`);
102
+ log.info(
103
+ `P3: { r: ${colorJS_srgbRed.coords[0].toFixed(6)}, g: ${colorJS_srgbRed.coords[1].toFixed(6)}, b: ${colorJS_srgbRed.coords[2].toFixed(6)} }`,
104
+ );
105
+ log.info(`Note: R < 1 because P3 red primary is more saturated than sRGB red`);
106
+
107
+ // P3 green primary is way outside sRGB gamut
108
+ const colorJS_p3Green = new Color("p3", [0, 1, 0]).to("srgb");
109
+ log.info(`\n=== P3 Green expressed in sRGB (clipped) ===`);
110
+ log.info(
111
+ `sRGB: { r: ${colorJS_p3Green.coords[0].toFixed(6)}, g: ${colorJS_p3Green.coords[1].toFixed(6)}, b: ${colorJS_p3Green.coords[2].toFixed(6)} }`,
112
+ );
113
+ log.info(`Note: Negative R value indicates out-of-sRGB-gamut color`);
114
+
115
+ // P3 green in sRGB space has negative red
116
+ expect(colorJS_p3Green.coords[0]).toBeLessThan(0);
117
+ });
118
+ });
119
+ });
@@ -0,0 +1,47 @@
1
+ // XYZ-D65 to Linear P3 Conversion
2
+ // Converts CIE XYZ (D65) to linear Display-P3 RGB
3
+ // Reference: CSS Color Level 4 specification
4
+ //
5
+ // Uses the inverse of the P3 to XYZ-D65 matrix
6
+ // Matrix values from ColorJS / CSS Color Level 4
7
+ //
8
+ // Input: Color.XYZD65 with x, y, z tristimulus values
9
+ // Output: Color.LinearP3 with linear r, g, b values (may be outside 0-1 for out-of-gamut)
10
+
11
+ // Get XYZ values
12
+ variable x: Number = {input}.x;
13
+ variable y: Number = {input}.y;
14
+ variable z: Number = {input}.z;
15
+
16
+ // XYZ to Linear P3 matrix (inverse of P3 to XYZ)
17
+ // Row 1
18
+ variable m00: Number = 2.4934969119414254;
19
+ variable m01: Number = -0.9313836179191239;
20
+ variable m02: Number = -0.40271078445071684;
21
+
22
+ // Row 2
23
+ variable m10: Number = -0.8294889695615747;
24
+ variable m11: Number = 1.7626640603183463;
25
+ variable m12: Number = 0.023624685841943577;
26
+
27
+ // Row 3
28
+ variable m20: Number = 0.03584583024378447;
29
+ variable m21: Number = -0.07617238926804182;
30
+ variable m22: Number = 0.9568845240076872;
31
+
32
+ // Matrix multiplication: [r, g, b] = M × [x, y, z]
33
+ variable linear_r: Number = m00 * x + m01 * y + m02 * z;
34
+ variable linear_g: Number = m10 * x + m11 * y + m12 * z;
35
+ variable linear_b: Number = m20 * x + m21 * y + m22 * z;
36
+
37
+ // Create output (note: values may be outside 0-1 for out-of-gamut colors)
38
+ variable output: Color.LinearP3;
39
+ output.r = linear_r;
40
+ output.g = linear_g;
41
+ output.b = linear_b;
42
+
43
+ return output;
44
+
45
+
46
+
47
+
@@ -0,0 +1,16 @@
1
+ // Linear P3 Color Initializer
2
+ // Creates a linear Display-P3 color from linear 0-1 values
3
+ // Input: List of [r, g, b] linear values
4
+
5
+ variable color_values: List = {input};
6
+ variable output: Color.LinearP3;
7
+
8
+ output.r = color_values.get(0);
9
+ output.g = color_values.get(1);
10
+ output.b = color_values.get(2);
11
+
12
+ return output;
13
+
14
+
15
+
16
+
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "LinearP3",
3
+ "type": "color",
4
+ "description": "Linear Display-P3 color space (gamma-decoded). Used for matrix transformations to XYZ.",
5
+ "schema": {
6
+ "type": "object",
7
+ "properties": {
8
+ "r": {
9
+ "type": "number",
10
+ "description": "Linear red channel (0-1, can exceed for HDR)"
11
+ },
12
+ "g": {
13
+ "type": "number",
14
+ "description": "Linear green channel (0-1, can exceed for HDR)"
15
+ },
16
+ "b": {
17
+ "type": "number",
18
+ "description": "Linear blue channel (0-1, can exceed for HDR)"
19
+ }
20
+ },
21
+ "required": ["r", "g", "b"],
22
+ "order": ["r", "g", "b"],
23
+ "additionalProperties": false
24
+ },
25
+ "initializers": [
26
+ {
27
+ "title": "Linear P3 Color Initializer",
28
+ "keyword": "linearp3",
29
+ "description": "Creates a linear Display-P3 color from linear 0-1 values",
30
+ "script": {
31
+ "type": "/api/v1/core/tokenscript/0/",
32
+ "script": "./initializer.tokenscript"
33
+ }
34
+ }
35
+ ],
36
+ "conversions": [
37
+ {
38
+ "source": "/api/v1/core/xyz-d65-color/0/",
39
+ "target": "$self",
40
+ "description": "Converts XYZ-D65 to Linear P3 using the P3 transformation matrix",
41
+ "lossless": true,
42
+ "script": {
43
+ "type": "/api/v1/core/tokenscript/0/",
44
+ "script": "./from-xyz-d65.tokenscript"
45
+ }
46
+ }
47
+ ]
48
+ }