@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,48 @@
1
+ {
2
+ "name": "wcag_level",
3
+ "type": "function",
4
+ "description": "Returns the WCAG 2.1 compliance level for a foreground/background color pair. Returns 'AAA' (ratio >= 7:1), 'AA' (ratio >= 4.5:1), 'AA-large' (ratio >= 3:1), or 'fail' (ratio < 3:1). Based on W3C WCAG 2.1 Success Criteria 1.4.3 and 1.4.6.",
5
+ "keyword": "wcag_level",
6
+ "requirements": ["/api/v1/core/srgb-color/0/", "/api/v1/core/xyz-d65-color/0/"],
7
+ "schema": {
8
+ "type": "object",
9
+ "properties": {
10
+ "input": {
11
+ "type": "array",
12
+ "items": [
13
+ {
14
+ "description": "Foreground color (text)",
15
+ "type": "color"
16
+ },
17
+ {
18
+ "description": "Background color",
19
+ "type": "color"
20
+ }
21
+ ],
22
+ "minItems": 2,
23
+ "maxItems": 2
24
+ }
25
+ },
26
+ "required": ["input"]
27
+ },
28
+ "returns": {
29
+ "type": "string",
30
+ "description": "WCAG level: 'AAA', 'AA', 'AA-large', or 'fail'"
31
+ },
32
+ "script": {
33
+ "type": "https://schema.tokenscript.dev.gcp.tokens.studio/api/v1/core/tokenscript/0/",
34
+ "script": "./wcag-level.tokenscript"
35
+ },
36
+ "examples": [
37
+ {
38
+ "description": "Black on white passes AAA",
39
+ "input": ["#000000", "#ffffff"],
40
+ "output": "AAA"
41
+ },
42
+ {
43
+ "description": "Gray on white may only pass AA-large",
44
+ "input": ["#767676", "#ffffff"],
45
+ "output": "AA"
46
+ }
47
+ ]
48
+ }
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Unit tests for the wcag_level function
3
+ * Returns WCAG compliance level for a color pair
4
+ */
5
+
6
+ import { executeWithSchema, getBundledSchema } from "@tests/helpers/schema-test-utils";
7
+ import { describe, expect, it } from "vitest";
8
+ import type { FunctionSpecification } from "@/bundler/types";
9
+
10
+ describe("wcag_level function", () => {
11
+ describe("Schema Definition", () => {
12
+ it("should have correct schema structure", async () => {
13
+ const schema = (await getBundledSchema("wcag_level", "function")) as FunctionSpecification;
14
+
15
+ expect(schema.name).toBe("wcag_level");
16
+ expect(schema.type).toBe("function");
17
+ });
18
+ });
19
+
20
+ describe("Function Execution", () => {
21
+ it("should return AAA for black on white (ratio 21:1)", async () => {
22
+ const result = await executeWithSchema(
23
+ "wcag_level",
24
+ "function",
25
+ `
26
+ variable black: Color.SRGB;
27
+ black.r = 0; black.g = 0; black.b = 0;
28
+ variable white: Color.SRGB;
29
+ white.r = 1; white.g = 1; white.b = 1;
30
+ wcag_level(black, white)
31
+ `,
32
+ );
33
+
34
+ expect(result).toBeDefined();
35
+ const level = (result as any).value ?? result;
36
+ expect(level).toBe("AAA");
37
+ });
38
+
39
+ it("should return AAA for white on black", async () => {
40
+ const result = await executeWithSchema(
41
+ "wcag_level",
42
+ "function",
43
+ `
44
+ variable black: Color.SRGB;
45
+ black.r = 0; black.g = 0; black.b = 0;
46
+ variable white: Color.SRGB;
47
+ white.r = 1; white.g = 1; white.b = 1;
48
+ wcag_level(white, black)
49
+ `,
50
+ );
51
+
52
+ expect(result).toBeDefined();
53
+ const level = (result as any).value ?? result;
54
+ expect(level).toBe("AAA");
55
+ });
56
+
57
+ it("should return fail for low contrast colors", async () => {
58
+ const result = await executeWithSchema(
59
+ "wcag_level",
60
+ "function",
61
+ `
62
+ variable light_gray: Color.SRGB;
63
+ light_gray.r = 0.8; light_gray.g = 0.8; light_gray.b = 0.8;
64
+ variable white: Color.SRGB;
65
+ white.r = 1; white.g = 1; white.b = 1;
66
+ wcag_level(light_gray, white)
67
+ `,
68
+ );
69
+
70
+ expect(result).toBeDefined();
71
+ const level = (result as any).value ?? result;
72
+ expect(level).toBe("fail");
73
+ });
74
+ });
75
+ });
@@ -0,0 +1,50 @@
1
+ // wcag_level: Determine WCAG 2.1 compliance level for a color pair
2
+ // Reference: WCAG 2.1 Success Criterion 1.4.3 (Contrast Minimum)
3
+ // Reference: WCAG 2.1 Success Criterion 1.4.6 (Contrast Enhanced)
4
+ // Reference: https://www.w3.org/TR/WCAG21/#contrast-minimum
5
+ //
6
+ // Returns one of:
7
+ // "AAA" - Ratio >= 7:1 (enhanced contrast for normal text)
8
+ // "AA" - Ratio >= 4.5:1 (minimum for normal text)
9
+ // "AA-large" - Ratio >= 3:1 (minimum for large text: 18pt or 14pt bold)
10
+ // "fail" - Ratio < 3:1 (does not meet any criterion)
11
+
12
+ variable input: List = {input};
13
+ variable fg_xyz: Color.XYZD65 = input.get(0).to.xyzd65();
14
+ variable bg_xyz: Color.XYZD65 = input.get(1).to.xyzd65();
15
+
16
+ variable l1: Number = fg_xyz.y;
17
+ variable l2: Number = bg_xyz.y;
18
+
19
+ // Ensure l1 is the lighter of the two
20
+ if (l2 > l1) [
21
+ variable temp: Number = l1;
22
+ l1 = l2;
23
+ l2 = temp;
24
+ ];
25
+
26
+ // Calculate contrast ratio per WCAG formula
27
+ // Ratio = (L1 + 0.05) / (L2 + 0.05)
28
+ variable ratio: Number = (l1 + 0.05) / (l2 + 0.05);
29
+
30
+ // Determine WCAG level
31
+ // AAA: ratio >= 7:1 (enhanced contrast)
32
+ // AA: ratio >= 4.5:1 (minimum for normal text)
33
+ // AA-large: ratio >= 3:1 (minimum for large text, 18pt+ or 14pt+ bold)
34
+ // fail: ratio < 3:1
35
+
36
+ variable result: String = "fail";
37
+
38
+ if (ratio >= 7) [
39
+ result = "AAA";
40
+ ] else [
41
+ if (ratio >= 4.5) [
42
+ result = "AA";
43
+ ] else [
44
+ if (ratio >= 3) [
45
+ result = "AA-large";
46
+ ];
47
+ ];
48
+ ];
49
+
50
+ return result;
@@ -0,0 +1,16 @@
1
+ // HSL to CSS Conversion
2
+ // Converts HSL to CSS hsl() syntax
3
+ // CSS Color Level 4: hsl(h s l) where s and l are percentages
4
+ //
5
+ // Input: Color.HSL with h (0-360), s (0-1), l (0-1)
6
+ // Output: Color.CSS with value like "hsl(120 50% 75%)"
7
+
8
+ variable precision: Number = 100;
9
+ variable h: Number = round({input}.h * precision) / precision;
10
+ variable s: Number = round({input}.s * 100 * precision) / precision;
11
+ variable l: Number = round({input}.l * 100 * precision) / precision;
12
+
13
+ variable output: Color.CSS;
14
+ output.value = "hsl(".concat(h.to_string()).concat(" ").concat(s.to_string()).concat("% ").concat(l.to_string()).concat("%)");
15
+ return output;
16
+
@@ -0,0 +1,16 @@
1
+ // HWB to CSS Conversion
2
+ // Converts HWB to CSS hwb() syntax
3
+ // CSS Color Level 4: hwb(h w b) where w and b are percentages
4
+ //
5
+ // Input: Color.HWB with h (0-360), w (0-1), b (0-1)
6
+ // Output: Color.CSS with value like "hwb(120 10% 20%)"
7
+
8
+ variable precision: Number = 100;
9
+ variable h: Number = round({input}.h * precision) / precision;
10
+ variable w: Number = round({input}.w * 100 * precision) / precision;
11
+ variable b_val: Number = round({input}.b * 100 * precision) / precision;
12
+
13
+ variable output: Color.CSS;
14
+ output.value = "hwb(".concat(h.to_string()).concat(" ").concat(w.to_string()).concat("% ").concat(b_val.to_string()).concat("%)");
15
+ return output;
16
+
@@ -0,0 +1,16 @@
1
+ // CIE Lab to CSS Conversion
2
+ // Converts CIE Lab to CSS lab() syntax
3
+ // CSS Color Level 4: lab(L a b) where L is a percentage
4
+ //
5
+ // Input: Color.Lab with l (0-100), a, b
6
+ // Output: Color.CSS with value like "lab(75% 20 -30)"
7
+
8
+ variable precision: Number = 10000;
9
+ variable l: Number = round({input}.l * precision) / precision;
10
+ variable a: Number = round({input}.a * precision) / precision;
11
+ variable b_val: Number = round({input}.b * precision) / precision;
12
+
13
+ variable output: Color.CSS;
14
+ output.value = "lab(".concat(l.to_string()).concat("% ").concat(a.to_string()).concat(" ").concat(b_val.to_string()).concat(")");
15
+ return output;
16
+
@@ -0,0 +1,16 @@
1
+ // CIE LCH to CSS Conversion
2
+ // Converts CIE LCH to CSS lch() syntax
3
+ // CSS Color Level 4: lch(L C H) where L is a percentage
4
+ //
5
+ // Input: Color.LCH with l (0-100), c, h (0-360)
6
+ // Output: Color.CSS with value like "lch(75% 50 180)"
7
+
8
+ variable precision: Number = 10000;
9
+ variable l: Number = round({input}.l * precision) / precision;
10
+ variable c: Number = round({input}.c * precision) / precision;
11
+ variable h: Number = round({input}.h * precision) / precision;
12
+
13
+ variable output: Color.CSS;
14
+ output.value = "lch(".concat(l.to_string()).concat("% ").concat(c.to_string()).concat(" ").concat(h.to_string()).concat(")");
15
+ return output;
16
+
@@ -0,0 +1,16 @@
1
+ // OKLab to CSS Conversion
2
+ // Converts OKLab to CSS oklab() syntax
3
+ // CSS Color Level 4: oklab(L a b) where L is 0-1 decimal
4
+ //
5
+ // Input: Color.OKLab with l (0-1), a, b
6
+ // Output: Color.CSS with value like "oklab(0.7 0.1 -0.05)"
7
+
8
+ variable precision: Number = 100000;
9
+ variable l: Number = round({input}.l * precision) / precision;
10
+ variable a: Number = round({input}.a * precision) / precision;
11
+ variable b_val: Number = round({input}.b * precision) / precision;
12
+
13
+ variable output: Color.CSS;
14
+ output.value = "oklab(".concat(l.to_string()).concat(" ").concat(a.to_string()).concat(" ").concat(b_val.to_string()).concat(")");
15
+ return output;
16
+
@@ -0,0 +1,16 @@
1
+ // OKLCH to CSS Conversion
2
+ // Converts OKLCH to CSS oklch() syntax
3
+ // CSS Color Level 4: oklch(L C H) where L is 0-1 decimal
4
+ //
5
+ // Input: Color.OKLCH with l (0-1), c, h (0-360)
6
+ // Output: Color.CSS with value like "oklch(0.7 0.15 180)"
7
+
8
+ variable precision: Number = 100000;
9
+ variable l: Number = round({input}.l * precision) / precision;
10
+ variable c: Number = round({input}.c * precision) / precision;
11
+ variable h: Number = round({input}.h * precision) / precision;
12
+
13
+ variable output: Color.CSS;
14
+ output.value = "oklch(".concat(l.to_string()).concat(" ").concat(c.to_string()).concat(" ").concat(h.to_string()).concat(")");
15
+ return output;
16
+
@@ -0,0 +1,16 @@
1
+ // Display-P3 to CSS Conversion
2
+ // Converts Display-P3 to CSS color(display-p3) syntax
3
+ // CSS Color Level 4: color(display-p3 r g b)
4
+ //
5
+ // Input: Color.P3 with r, g, b in 0-1 range
6
+ // Output: Color.CSS with value like "color(display-p3 1 0.5 0.25)"
7
+
8
+ variable precision: Number = 100000;
9
+ variable r: Number = round({input}.r * precision) / precision;
10
+ variable g: Number = round({input}.g * precision) / precision;
11
+ variable b: Number = round({input}.b * precision) / precision;
12
+
13
+ variable output: Color.CSS;
14
+ output.value = "color(display-p3 ".concat(r.to_string()).concat(" ").concat(g.to_string()).concat(" ").concat(b.to_string()).concat(")");
15
+ return output;
16
+
@@ -0,0 +1,15 @@
1
+ // RGB to CSS Conversion
2
+ // Converts RGB (0-255) to CSS rgb() syntax
3
+ // CSS Color Level 4 modern syntax: rgb(r g b)
4
+ //
5
+ // Input: Color.Rgb with r, g, b in 0-255 range
6
+ // Output: Color.CSS with value like "rgb(255 128 64)"
7
+
8
+ variable r: Number = round({input}.r);
9
+ variable g: Number = round({input}.g);
10
+ variable b: Number = round({input}.b);
11
+
12
+ variable output: Color.CSS;
13
+ output.value = "rgb(".concat(r.to_string()).concat(" ").concat(g.to_string()).concat(" ").concat(b.to_string()).concat(")");
14
+ return output;
15
+
@@ -0,0 +1,16 @@
1
+ // sRGB to CSS Conversion
2
+ // Converts sRGB (0-1) to CSS color(srgb) syntax
3
+ // CSS Color Level 4: color(srgb r g b)
4
+ //
5
+ // Input: Color.SRGB with r, g, b in 0-1 range
6
+ // Output: Color.CSS with value like "color(srgb 1 0.5 0.25)"
7
+
8
+ variable precision: Number = 100000;
9
+ variable r: Number = round({input}.r * precision) / precision;
10
+ variable g: Number = round({input}.g * precision) / precision;
11
+ variable b: Number = round({input}.b * precision) / precision;
12
+
13
+ variable output: Color.CSS;
14
+ output.value = "color(srgb ".concat(r.to_string()).concat(" ").concat(g.to_string()).concat(" ").concat(b.to_string()).concat(")");
15
+ return output;
16
+
@@ -0,0 +1,16 @@
1
+ // Linear sRGB to CSS Conversion
2
+ // Converts Linear sRGB to CSS color(srgb-linear) syntax
3
+ // CSS Color Level 4: color(srgb-linear r g b)
4
+ //
5
+ // Input: Color.LinearSRGB with r, g, b in 0-1 range
6
+ // Output: Color.CSS with value like "color(srgb-linear 1 0.25 0.0625)"
7
+
8
+ variable precision: Number = 100000;
9
+ variable r: Number = round({input}.r * precision) / precision;
10
+ variable g: Number = round({input}.g * precision) / precision;
11
+ variable b: Number = round({input}.b * precision) / precision;
12
+
13
+ variable output: Color.CSS;
14
+ output.value = "color(srgb-linear ".concat(r.to_string()).concat(" ").concat(g.to_string()).concat(" ").concat(b.to_string()).concat(")");
15
+ return output;
16
+
@@ -0,0 +1,16 @@
1
+ // XYZ-D50 to CSS Conversion
2
+ // Converts XYZ-D50 to CSS color(xyz-d50) syntax
3
+ // CSS Color Level 4: color(xyz-d50 x y z)
4
+ //
5
+ // Input: Color.XYZD50 with x, y, z tristimulus values
6
+ // Output: Color.CSS with value like "color(xyz-d50 0.4360 0.2225 0.0139)"
7
+
8
+ variable precision: Number = 100000;
9
+ variable x: Number = round({input}.x * precision) / precision;
10
+ variable y: Number = round({input}.y * precision) / precision;
11
+ variable z: Number = round({input}.z * precision) / precision;
12
+
13
+ variable output: Color.CSS;
14
+ output.value = "color(xyz-d50 ".concat(x.to_string()).concat(" ").concat(y.to_string()).concat(" ").concat(z.to_string()).concat(")");
15
+ return output;
16
+
@@ -0,0 +1,16 @@
1
+ // XYZ-D65 to CSS Conversion
2
+ // Converts XYZ-D65 to CSS color(xyz-d65) syntax
3
+ // CSS Color Level 4: color(xyz-d65 x y z) or color(xyz x y z)
4
+ //
5
+ // Input: Color.XYZD65 with x, y, z tristimulus values
6
+ // Output: Color.CSS with value like "color(xyz-d65 0.4124 0.2126 0.0193)"
7
+
8
+ variable precision: Number = 100000;
9
+ variable x: Number = round({input}.x * precision) / precision;
10
+ variable y: Number = round({input}.y * precision) / precision;
11
+ variable z: Number = round({input}.z * precision) / precision;
12
+
13
+ variable output: Color.CSS;
14
+ output.value = "color(xyz-d65 ".concat(x.to_string()).concat(" ").concat(y.to_string()).concat(" ").concat(z.to_string()).concat(")");
15
+ return output;
16
+
@@ -0,0 +1,13 @@
1
+ // CSS Color Initializer
2
+ // Accepts a CSS color string and returns it
3
+ // This is primarily used for type registration;
4
+ // the main usage is converting TO css from other color types
5
+ //
6
+ // Input: String (CSS color value)
7
+ // Output: String (same value)
8
+
9
+ variable input: List = {input};
10
+ variable value: String = input.get(0);
11
+
12
+ return value;
13
+
@@ -0,0 +1,148 @@
1
+ {
2
+ "name": "CSS",
3
+ "type": "color",
4
+ "description": "CSS color string representation. Outputs the appropriate CSS syntax for any color space.",
5
+ "schema": {
6
+ "type": "object",
7
+ "properties": {
8
+ "value": {
9
+ "type": "string",
10
+ "description": "CSS color string (e.g., 'rgb(255 128 64)', 'oklch(0.7 0.15 180)')"
11
+ }
12
+ },
13
+ "required": ["value"]
14
+ },
15
+ "initializers": [
16
+ {
17
+ "title": "CSS Color Initializer",
18
+ "keyword": "css",
19
+ "description": "Creates a CSS color from a string value",
20
+ "script": {
21
+ "type": "/api/v1/core/tokenscript/0/",
22
+ "script": "./initializer.tokenscript"
23
+ }
24
+ }
25
+ ],
26
+ "conversions": [
27
+ {
28
+ "source": "/api/v1/core/rgb-color/0/",
29
+ "target": "$self",
30
+ "description": "Converts RGB (0-255) to CSS rgb() syntax",
31
+ "lossless": true,
32
+ "script": {
33
+ "type": "/api/v1/core/tokenscript/0/",
34
+ "script": "./from-rgb-color.tokenscript"
35
+ }
36
+ },
37
+ {
38
+ "source": "/api/v1/core/srgb-color/0/",
39
+ "target": "$self",
40
+ "description": "Converts sRGB (0-1) to CSS color(srgb) syntax",
41
+ "lossless": true,
42
+ "script": {
43
+ "type": "/api/v1/core/tokenscript/0/",
44
+ "script": "./from-srgb-color.tokenscript"
45
+ }
46
+ },
47
+ {
48
+ "source": "/api/v1/core/hsl-color/0/",
49
+ "target": "$self",
50
+ "description": "Converts HSL to CSS hsl() syntax",
51
+ "lossless": true,
52
+ "script": {
53
+ "type": "/api/v1/core/tokenscript/0/",
54
+ "script": "./from-hsl-color.tokenscript"
55
+ }
56
+ },
57
+ {
58
+ "source": "/api/v1/core/hwb-color/0/",
59
+ "target": "$self",
60
+ "description": "Converts HWB to CSS hwb() syntax",
61
+ "lossless": true,
62
+ "script": {
63
+ "type": "/api/v1/core/tokenscript/0/",
64
+ "script": "./from-hwb-color.tokenscript"
65
+ }
66
+ },
67
+ {
68
+ "source": "/api/v1/core/lab-color/0/",
69
+ "target": "$self",
70
+ "description": "Converts CIE Lab to CSS lab() syntax",
71
+ "lossless": true,
72
+ "script": {
73
+ "type": "/api/v1/core/tokenscript/0/",
74
+ "script": "./from-lab-color.tokenscript"
75
+ }
76
+ },
77
+ {
78
+ "source": "/api/v1/core/lch-color/0/",
79
+ "target": "$self",
80
+ "description": "Converts CIE LCH to CSS lch() syntax",
81
+ "lossless": true,
82
+ "script": {
83
+ "type": "/api/v1/core/tokenscript/0/",
84
+ "script": "./from-lch-color.tokenscript"
85
+ }
86
+ },
87
+ {
88
+ "source": "/api/v1/core/oklab-color/0/",
89
+ "target": "$self",
90
+ "description": "Converts OKLab to CSS oklab() syntax",
91
+ "lossless": true,
92
+ "script": {
93
+ "type": "/api/v1/core/tokenscript/0/",
94
+ "script": "./from-oklab-color.tokenscript"
95
+ }
96
+ },
97
+ {
98
+ "source": "/api/v1/core/oklch-color/0/",
99
+ "target": "$self",
100
+ "description": "Converts OKLCH to CSS oklch() syntax",
101
+ "lossless": true,
102
+ "script": {
103
+ "type": "/api/v1/core/tokenscript/0/",
104
+ "script": "./from-oklch-color.tokenscript"
105
+ }
106
+ },
107
+ {
108
+ "source": "/api/v1/core/srgb-linear-color/0/",
109
+ "target": "$self",
110
+ "description": "Converts Linear sRGB to CSS color(srgb-linear) syntax",
111
+ "lossless": true,
112
+ "script": {
113
+ "type": "/api/v1/core/tokenscript/0/",
114
+ "script": "./from-srgb-linear-color.tokenscript"
115
+ }
116
+ },
117
+ {
118
+ "source": "/api/v1/core/xyz-d65-color/0/",
119
+ "target": "$self",
120
+ "description": "Converts XYZ-D65 to CSS color(xyz-d65) syntax",
121
+ "lossless": true,
122
+ "script": {
123
+ "type": "/api/v1/core/tokenscript/0/",
124
+ "script": "./from-xyz-d65-color.tokenscript"
125
+ }
126
+ },
127
+ {
128
+ "source": "/api/v1/core/xyz-d50-color/0/",
129
+ "target": "$self",
130
+ "description": "Converts XYZ-D50 to CSS color(xyz-d50) syntax",
131
+ "lossless": true,
132
+ "script": {
133
+ "type": "/api/v1/core/tokenscript/0/",
134
+ "script": "./from-xyz-d50-color.tokenscript"
135
+ }
136
+ },
137
+ {
138
+ "source": "/api/v1/core/p3-color/0/",
139
+ "target": "$self",
140
+ "description": "Converts Display-P3 to CSS color(display-p3) syntax",
141
+ "lossless": true,
142
+ "script": {
143
+ "type": "/api/v1/core/tokenscript/0/",
144
+ "script": "./from-p3-color.tokenscript"
145
+ }
146
+ }
147
+ ]
148
+ }