@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,49 @@
1
+ {
2
+ "name": "lightness",
3
+ "type": "function",
4
+ "description": "Extracts the perceptual lightness value from any color using OKLCH. Returns a value from 0 (black) to 1 (white). This is the 'L' in OKLCH, which is perceptually uniform - equal steps in L appear as equal steps in lightness to human vision. Essential for creating perceptually even color scales.",
5
+ "keyword": "lightness",
6
+ "requirements": ["/api/v1/core/srgb-color/0/", "/api/v1/core/oklch-color/0/"],
7
+ "schema": {
8
+ "type": "object",
9
+ "properties": {
10
+ "input": {
11
+ "type": "array",
12
+ "items": [
13
+ {
14
+ "description": "Color to extract lightness from",
15
+ "type": "color"
16
+ }
17
+ ],
18
+ "minItems": 1,
19
+ "maxItems": 1
20
+ }
21
+ },
22
+ "required": ["input"]
23
+ },
24
+ "returns": {
25
+ "type": "number",
26
+ "description": "Perceptual lightness value (0-1)"
27
+ },
28
+ "script": {
29
+ "type": "https://schema.tokenscript.dev.gcp.tokens.studio/api/v1/core/tokenscript/0/",
30
+ "script": "./lightness.tokenscript"
31
+ },
32
+ "examples": [
33
+ {
34
+ "description": "White has lightness 1",
35
+ "input": ["#ffffff"],
36
+ "output": 1
37
+ },
38
+ {
39
+ "description": "Black has lightness 0",
40
+ "input": ["#000000"],
41
+ "output": 0
42
+ },
43
+ {
44
+ "description": "Mid-gray has lightness ~0.6",
45
+ "input": ["#808080"],
46
+ "output": 0.6
47
+ }
48
+ ]
49
+ }
@@ -0,0 +1,99 @@
1
+ /**
2
+ * Unit tests for the lightness function
3
+ * Extracts perceptual lightness from a color
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("lightness function", () => {
11
+ describe("Schema Definition", () => {
12
+ it("should have correct schema structure", async () => {
13
+ const schema = (await getBundledSchema("lightness", "function")) as FunctionSpecification;
14
+
15
+ expect(schema.name).toBe("lightness");
16
+ expect(schema.type).toBe("function");
17
+ });
18
+ });
19
+
20
+ describe("Function Execution", () => {
21
+ it("should return 1 for white", async () => {
22
+ const result = await executeWithSchema(
23
+ "lightness",
24
+ "function",
25
+ `
26
+ variable white: Color.SRGB;
27
+ white.r = 1; white.g = 1; white.b = 1;
28
+ lightness(white)
29
+ `,
30
+ );
31
+
32
+ expect(result).toBeDefined();
33
+ const l = (result as any).value ?? result;
34
+ expect(l).toBeCloseTo(1, 1);
35
+ });
36
+
37
+ it("should return 0 for black", async () => {
38
+ const result = await executeWithSchema(
39
+ "lightness",
40
+ "function",
41
+ `
42
+ variable black: Color.SRGB;
43
+ black.r = 0; black.g = 0; black.b = 0;
44
+ lightness(black)
45
+ `,
46
+ );
47
+
48
+ expect(result).toBeDefined();
49
+ const l = (result as any).value ?? result;
50
+ expect(l).toBeCloseTo(0, 1);
51
+ });
52
+
53
+ it("should return ~0.6 for mid-gray", async () => {
54
+ const result = await executeWithSchema(
55
+ "lightness",
56
+ "function",
57
+ `
58
+ variable gray: Color.SRGB;
59
+ gray.r = 0.5; gray.g = 0.5; gray.b = 0.5;
60
+ lightness(gray)
61
+ `,
62
+ );
63
+
64
+ expect(result).toBeDefined();
65
+ const l = (result as any).value ?? result;
66
+ // OKLCH lightness for mid-gray is around 0.6
67
+ expect(l).toBeGreaterThan(0.5);
68
+ expect(l).toBeLessThan(0.8);
69
+ });
70
+
71
+ it("should show yellow is lighter than blue", async () => {
72
+ const yellowResult = await executeWithSchema(
73
+ "lightness",
74
+ "function",
75
+ `
76
+ variable yellow: Color.SRGB;
77
+ yellow.r = 1; yellow.g = 1; yellow.b = 0;
78
+ lightness(yellow)
79
+ `,
80
+ );
81
+
82
+ const blueResult = await executeWithSchema(
83
+ "lightness",
84
+ "function",
85
+ `
86
+ variable blue: Color.SRGB;
87
+ blue.r = 0; blue.g = 0; blue.b = 1;
88
+ lightness(blue)
89
+ `,
90
+ );
91
+
92
+ const yellowL = (yellowResult as any).value ?? yellowResult;
93
+ const blueL = (blueResult as any).value ?? blueResult;
94
+
95
+ // Yellow is perceptually much lighter than blue
96
+ expect(yellowL).toBeGreaterThan(blueL);
97
+ });
98
+ });
99
+ });
@@ -0,0 +1,16 @@
1
+ // Get relative luminance of a color
2
+ // Per WCAG 2.1: L = 0.2126*R + 0.7152*G + 0.0722*B (linear RGB)
3
+ //
4
+ // Returns: 0 (black) to 1 (white)
5
+ // Used for contrast calculations
6
+
7
+ variable input: List = {input};
8
+ variable color: Color.LinearSRGB = input.get(0).to.linearsrgb();
9
+
10
+ variable lum: Number = 0.2126 * color.r + 0.7152 * color.g + 0.0722 * color.b;
11
+
12
+ return lum;
13
+
14
+
15
+
16
+
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "Luminance",
3
+ "type": "function",
4
+ "description": "Returns the relative luminance of a color (0-1). Uses the WCAG formula based on linear sRGB. Useful for contrast calculations and accessibility.",
5
+ "keyword": "luminance",
6
+ "input": {
7
+ "type": "object",
8
+ "properties": {
9
+ "color": {
10
+ "type": "color",
11
+ "description": "The color to measure"
12
+ }
13
+ }
14
+ },
15
+ "script": {
16
+ "type": "/api/v1/core/tokenscript/0/",
17
+ "script": "./luminance.tokenscript"
18
+ },
19
+ "requirements": ["/api/v1/core/srgb-linear-color/0/"]
20
+ }
@@ -0,0 +1,105 @@
1
+ /**
2
+ * Unit tests for the Luminance function
3
+ * Returns relative luminance (0-1) of a color
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("Luminance Function", () => {
11
+ describe("Schema Definition", () => {
12
+ it("should have correct schema structure", async () => {
13
+ const schema = (await getBundledSchema("luminance", "function")) as FunctionSpecification;
14
+
15
+ expect(schema.name).toBe("Luminance");
16
+ expect(schema.type).toBe("function");
17
+ expect(schema.keyword).toBe("luminance");
18
+ });
19
+ });
20
+
21
+ describe("Function Execution", () => {
22
+ it("should return 1 for white", async () => {
23
+ const result = await executeWithSchema(
24
+ "luminance",
25
+ "function",
26
+ `
27
+ variable white: Color.SRGB;
28
+ white.r = 1; white.g = 1; white.b = 1;
29
+ luminance(white)
30
+ `,
31
+ );
32
+
33
+ expect(result).toBeDefined();
34
+ const lum = (result as any).value ?? result;
35
+ expect(lum).toBeCloseTo(1, 1);
36
+ });
37
+
38
+ it("should return 0 for black", async () => {
39
+ const result = await executeWithSchema(
40
+ "luminance",
41
+ "function",
42
+ `
43
+ variable black: Color.SRGB;
44
+ black.r = 0; black.g = 0; black.b = 0;
45
+ luminance(black)
46
+ `,
47
+ );
48
+
49
+ expect(result).toBeDefined();
50
+ const lum = (result as any).value ?? result;
51
+ expect(lum).toBeCloseTo(0, 1);
52
+ });
53
+
54
+ it("should return ~0.21 for pure red", async () => {
55
+ const result = await executeWithSchema(
56
+ "luminance",
57
+ "function",
58
+ `
59
+ variable red: Color.SRGB;
60
+ red.r = 1; red.g = 0; red.b = 0;
61
+ luminance(red)
62
+ `,
63
+ );
64
+
65
+ expect(result).toBeDefined();
66
+ const lum = (result as any).value ?? result;
67
+ // Red luminance coefficient is ~0.2126
68
+ expect(lum).toBeCloseTo(0.21, 1);
69
+ });
70
+
71
+ it("should return ~0.72 for pure green", async () => {
72
+ const result = await executeWithSchema(
73
+ "luminance",
74
+ "function",
75
+ `
76
+ variable green: Color.SRGB;
77
+ green.r = 0; green.g = 1; green.b = 0;
78
+ luminance(green)
79
+ `,
80
+ );
81
+
82
+ expect(result).toBeDefined();
83
+ const lum = (result as any).value ?? result;
84
+ // Green luminance coefficient is ~0.7152
85
+ expect(lum).toBeCloseTo(0.72, 1);
86
+ });
87
+
88
+ it("should return ~0.07 for pure blue", async () => {
89
+ const result = await executeWithSchema(
90
+ "luminance",
91
+ "function",
92
+ `
93
+ variable blue: Color.SRGB;
94
+ blue.r = 0; blue.g = 0; blue.b = 1;
95
+ luminance(blue)
96
+ `,
97
+ );
98
+
99
+ expect(result).toBeDefined();
100
+ const lum = (result as any).value ?? result;
101
+ // Blue luminance coefficient is ~0.0722
102
+ expect(lum).toBeCloseTo(0.07, 1);
103
+ });
104
+ });
105
+ });
@@ -0,0 +1,49 @@
1
+ // Meets Contrast (WCAG 2.1 Compliance Check)
2
+ // Reference: WCAG 2.1 Success Criteria 1.4.3 and 1.4.6
3
+ // Reference: https://www.w3.org/TR/WCAG21/#contrast-minimum
4
+ //
5
+ // WCAG 2.1 Contrast Levels:
6
+ // - Level AA (normal text): 4.5:1
7
+ // - Level AA (large text): 3:1
8
+ // - Level AAA (normal text): 7:1
9
+ // - Level AAA (large text): 4.5:1
10
+ //
11
+ // Large text is defined as:
12
+ // - 14pt (18.66px) bold
13
+ // - 18pt (24px) regular
14
+ //
15
+ // Returns true if the contrast ratio meets or exceeds the threshold.
16
+
17
+ variable input: List = {input};
18
+ variable color1: Color.LinearSRGB = input.get(0).to.linearsrgb();
19
+ variable color2: Color.LinearSRGB = input.get(1).to.linearsrgb();
20
+
21
+ // Default threshold is 4.5 (WCAG AA for normal text)
22
+ variable threshold: Number = 4.5;
23
+ if (input.length() > 2) [
24
+ threshold = input.get(2);
25
+ ];
26
+
27
+ // Calculate relative luminance for each color
28
+ // Formula: L = 0.2126 * R + 0.7152 * G + 0.0722 * B
29
+ variable lum1: Number = 0.2126 * color1.r + 0.7152 * color1.g + 0.0722 * color1.b;
30
+ variable lum2: Number = 0.2126 * color2.r + 0.7152 * color2.g + 0.0722 * color2.b;
31
+
32
+ // Ensure non-negative luminance
33
+ if (lum1 < 0) [ lum1 = 0; ];
34
+ if (lum2 < 0) [ lum2 = 0; ];
35
+
36
+ // Determine lighter and darker luminance
37
+ variable lighter: Number = lum1;
38
+ variable darker: Number = lum2;
39
+ if (lum2 > lum1) [
40
+ lighter = lum2;
41
+ darker = lum1;
42
+ ];
43
+
44
+ // Calculate contrast ratio: (L1 + 0.05) / (L2 + 0.05)
45
+ variable ratio: Number = (lighter + 0.05) / (darker + 0.05);
46
+
47
+ // Return whether it meets the threshold
48
+ return ratio >= threshold;
49
+
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "Meets Contrast",
3
+ "type": "function",
4
+ "description": "Checks if two colors meet WCAG 2.1 contrast requirements. Returns true if contrast ratio meets the specified level: 'AA' (4.5:1 for normal text, 3:1 for large text), 'AAA' (7:1 for normal text, 4.5:1 for large text), or a custom ratio.",
5
+ "keyword": "meets_contrast",
6
+ "input": {
7
+ "type": "object",
8
+ "properties": {
9
+ "color1": {
10
+ "type": "color",
11
+ "description": "First color"
12
+ },
13
+ "color2": {
14
+ "type": "color",
15
+ "description": "Second color"
16
+ },
17
+ "threshold": {
18
+ "type": "number",
19
+ "description": "Minimum contrast ratio required (default: 4.5 for AA)"
20
+ }
21
+ }
22
+ },
23
+ "script": {
24
+ "type": "/api/v1/core/tokenscript/0/",
25
+ "script": "./meets-contrast.tokenscript"
26
+ },
27
+ "requirements": ["/api/v1/core/srgb-linear-color/0/"]
28
+ }
@@ -0,0 +1,170 @@
1
+ import { executeWithSchema } from "@tests/helpers/schema-test-utils";
2
+ import { describe, expect, it } from "vitest";
3
+
4
+ describe("Meets Contrast Function", () => {
5
+ describe("Schema Definition", () => {
6
+ it("should have correct schema structure", async () => {
7
+ const { getBundledSchema } = await import("@tests/helpers/schema-test-utils");
8
+ const schema = await getBundledSchema("meets_contrast", "function");
9
+
10
+ expect(schema.name).toBe("Meets Contrast");
11
+ expect(schema.type).toBe("function");
12
+ expect((schema as any).keyword).toBe("meets_contrast");
13
+ });
14
+ });
15
+
16
+ describe("Black and White (Maximum Contrast)", () => {
17
+ it("should return true for black/white at AA threshold", async () => {
18
+ const result = await executeWithSchema(
19
+ "meets_contrast",
20
+ "function",
21
+ `
22
+ variable c1: Color.SRGB;
23
+ c1.r = 0; c1.g = 0; c1.b = 0;
24
+ variable c2: Color.SRGB;
25
+ c2.r = 1; c2.g = 1; c2.b = 1;
26
+ meets_contrast(c1, c2, 4.5)
27
+ `,
28
+ );
29
+
30
+ expect(result.value).toBe(true);
31
+ });
32
+
33
+ it("should return true for black/white at AAA threshold", async () => {
34
+ const result = await executeWithSchema(
35
+ "meets_contrast",
36
+ "function",
37
+ `
38
+ variable c1: Color.SRGB;
39
+ c1.r = 0; c1.g = 0; c1.b = 0;
40
+ variable c2: Color.SRGB;
41
+ c2.r = 1; c2.g = 1; c2.b = 1;
42
+ meets_contrast(c1, c2, 7)
43
+ `,
44
+ );
45
+
46
+ expect(result.value).toBe(true);
47
+ });
48
+ });
49
+
50
+ describe("Identical Colors (No Contrast)", () => {
51
+ it("should return false for identical colors", async () => {
52
+ const result = await executeWithSchema(
53
+ "meets_contrast",
54
+ "function",
55
+ `
56
+ variable c1: Color.SRGB;
57
+ c1.r = 0.5; c1.g = 0.5; c1.b = 0.5;
58
+ variable c2: Color.SRGB;
59
+ c2.r = 0.5; c2.g = 0.5; c2.b = 0.5;
60
+ meets_contrast(c1, c2, 4.5)
61
+ `,
62
+ );
63
+
64
+ expect(result.value).toBe(false);
65
+ });
66
+ });
67
+
68
+ describe("AA Threshold (4.5:1)", () => {
69
+ it("should return true for good contrast (dark gray on white)", async () => {
70
+ // Dark gray (#595959) on white should meet AA
71
+ const result = await executeWithSchema(
72
+ "meets_contrast",
73
+ "function",
74
+ `
75
+ variable c1: Color.SRGB;
76
+ c1.r = 0.35; c1.g = 0.35; c1.b = 0.35;
77
+ variable c2: Color.SRGB;
78
+ c2.r = 1; c2.g = 1; c2.b = 1;
79
+ meets_contrast(c1, c2, 4.5)
80
+ `,
81
+ );
82
+
83
+ expect(result.value).toBe(true);
84
+ });
85
+
86
+ it("should return false for poor contrast (light gray on white)", async () => {
87
+ // Light gray on white fails AA
88
+ const result = await executeWithSchema(
89
+ "meets_contrast",
90
+ "function",
91
+ `
92
+ variable c1: Color.SRGB;
93
+ c1.r = 0.75; c1.g = 0.75; c1.b = 0.75;
94
+ variable c2: Color.SRGB;
95
+ c2.r = 1; c2.g = 1; c2.b = 1;
96
+ meets_contrast(c1, c2, 4.5)
97
+ `,
98
+ );
99
+
100
+ expect(result.value).toBe(false);
101
+ });
102
+ });
103
+
104
+ describe("Large Text AA Threshold (3:1)", () => {
105
+ it("should return true for moderate contrast at 3:1 threshold", async () => {
106
+ const result = await executeWithSchema(
107
+ "meets_contrast",
108
+ "function",
109
+ `
110
+ variable c1: Color.SRGB;
111
+ c1.r = 0.45; c1.g = 0.45; c1.b = 0.45;
112
+ variable c2: Color.SRGB;
113
+ c2.r = 1; c2.g = 1; c2.b = 1;
114
+ meets_contrast(c1, c2, 3)
115
+ `,
116
+ );
117
+
118
+ expect(result.value).toBe(true);
119
+ });
120
+ });
121
+
122
+ describe("Default Threshold", () => {
123
+ it("should use 4.5 as default threshold", async () => {
124
+ // Dark gray on white should meet default AA (4.5:1)
125
+ const result = await executeWithSchema(
126
+ "meets_contrast",
127
+ "function",
128
+ `
129
+ variable c1: Color.SRGB;
130
+ c1.r = 0.3; c1.g = 0.3; c1.b = 0.3;
131
+ variable c2: Color.SRGB;
132
+ c2.r = 1; c2.g = 1; c2.b = 1;
133
+ meets_contrast(c1, c2)
134
+ `,
135
+ );
136
+
137
+ expect(result.value).toBe(true);
138
+ });
139
+ });
140
+
141
+ describe("Order Independence", () => {
142
+ it("should give same result regardless of color order", async () => {
143
+ const result1 = await executeWithSchema(
144
+ "meets_contrast",
145
+ "function",
146
+ `
147
+ variable c1: Color.SRGB;
148
+ c1.r = 0.2; c1.g = 0.2; c1.b = 0.2;
149
+ variable c2: Color.SRGB;
150
+ c2.r = 0.9; c2.g = 0.9; c2.b = 0.9;
151
+ meets_contrast(c1, c2, 4.5)
152
+ `,
153
+ );
154
+
155
+ const result2 = await executeWithSchema(
156
+ "meets_contrast",
157
+ "function",
158
+ `
159
+ variable c1: Color.SRGB;
160
+ c1.r = 0.9; c1.g = 0.9; c1.b = 0.9;
161
+ variable c2: Color.SRGB;
162
+ c2.r = 0.2; c2.g = 0.2; c2.b = 0.2;
163
+ meets_contrast(c1, c2, 4.5)
164
+ `,
165
+ );
166
+
167
+ expect(result1.value).toBe(result2.value);
168
+ });
169
+ });
170
+ });
@@ -0,0 +1,47 @@
1
+ // mix: Blend two colors in perceptual space
2
+ // Uses shortest hue path for natural color blending.
3
+ //
4
+ // Algorithm: Linear interpolation on L, C, and shortest-path H
5
+ //
6
+ // Input: Any color space (converted to OKLCH internally)
7
+ // Output: OKLCH (working space)
8
+ // To get sRGB: mix(color1, color2, 0.5).to.srgb()
9
+
10
+ variable input: List = {input};
11
+ variable color1: Color.OKLCH = input.get(0).to.oklch();
12
+ variable color2: Color.OKLCH = input.get(1).to.oklch();
13
+
14
+ // Default amount is 0.5 (50/50 blend)
15
+ variable amount: Number = 0.5;
16
+ if (input.length() > 2) [
17
+ amount = input.get(2);
18
+ ];
19
+
20
+ // Interpolate lightness and chroma linearly
21
+ variable new_l: Number = color1.l + (color2.l - color1.l) * amount;
22
+ variable new_c: Number = color1.c + (color2.c - color1.c) * amount;
23
+
24
+ // Interpolate hue using shortest path
25
+ variable h1: Number = color1.h;
26
+ variable h2: Number = color2.h;
27
+ variable h_diff: Number = h2 - h1;
28
+
29
+ // Normalize to shortest path (-180 to 180)
30
+ if (h_diff > 180) [ h_diff = h_diff - 360; ];
31
+ if (h_diff < -180) [ h_diff = h_diff + 360; ];
32
+
33
+ variable new_h: Number = h1 + h_diff * amount;
34
+ if (new_h < 0) [ new_h = new_h + 360; ];
35
+ if (new_h >= 360) [ new_h = new_h - 360; ];
36
+
37
+ // Create mixed color
38
+ variable result: Color.OKLCH;
39
+ result.l = new_l;
40
+ result.c = new_c;
41
+ result.h = new_h;
42
+
43
+ return result;
44
+
45
+
46
+
47
+
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "Mix",
3
+ "type": "function",
4
+ "description": "Blends two colors together in OKLCH space. Amount 0 = first color, 1 = second color, 0.5 = equal blend.",
5
+ "keyword": "mix",
6
+ "input": {
7
+ "type": "object",
8
+ "properties": {
9
+ "color1": {
10
+ "type": "color",
11
+ "description": "First color"
12
+ },
13
+ "color2": {
14
+ "type": "color",
15
+ "description": "Second color"
16
+ },
17
+ "amount": {
18
+ "type": "number",
19
+ "description": "Blend amount (0-1). Default is 0.5"
20
+ }
21
+ }
22
+ },
23
+ "script": {
24
+ "type": "/api/v1/core/tokenscript/0/",
25
+ "script": "./mix.tokenscript"
26
+ },
27
+ "requirements": ["/api/v1/core/oklch-color/0/", "/api/v1/core/srgb-color/0/"]
28
+ }