@tokens-studio/tokenscript-schemas 0.0.11 → 0.0.12

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 (311) hide show
  1. package/dist/cli/index.cjs +30 -4
  2. package/dist/cli/index.cjs.map +1 -1
  3. package/dist/cli/index.js +29 -4
  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 +240 -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
  308. package/dist/cli/index.d.cts +0 -1
  309. package/dist/cli/index.d.ts +0 -1
  310. package/dist/index.d.cts +0 -158
  311. package/dist/index.d.ts +0 -158
@@ -0,0 +1,109 @@
1
+ /**
2
+ * List command - Display available schemas
3
+ */
4
+
5
+ /// <reference types="../../../types/ulog" />
6
+
7
+ import { readdir } from "node:fs/promises";
8
+ import { join } from "node:path";
9
+ import anylogger from "ulog";
10
+
11
+ const log = anylogger("list");
12
+
13
+ export interface ListOptions {
14
+ types?: boolean;
15
+ functions?: boolean;
16
+ }
17
+
18
+ interface ListResult {
19
+ types: string[];
20
+ functions: string[];
21
+ }
22
+
23
+ /**
24
+ * List all available schemas
25
+ */
26
+ export async function listSchemas(
27
+ schemasDir: string = join(process.cwd(), "src/schemas"),
28
+ options: ListOptions = {},
29
+ ): Promise<ListResult> {
30
+ const showTypes = options.types || (!options.types && !options.functions);
31
+ const showFunctions = options.functions || (!options.types && !options.functions);
32
+
33
+ const types: string[] = [];
34
+ const functions: string[] = [];
35
+
36
+ // List type schemas
37
+ if (showTypes) {
38
+ try {
39
+ const typesDir = join(schemasDir, "types");
40
+ const typeEntries = await readdir(typesDir, { withFileTypes: true });
41
+ types.push(
42
+ ...typeEntries
43
+ .filter((entry) => entry.isDirectory())
44
+ .map((entry) => entry.name)
45
+ .sort(),
46
+ );
47
+ } catch (error) {
48
+ log.warn("Could not read types directory:", error);
49
+ }
50
+ }
51
+
52
+ // List function schemas
53
+ if (showFunctions) {
54
+ try {
55
+ const functionsDir = join(schemasDir, "functions");
56
+ const funcEntries = await readdir(functionsDir, { withFileTypes: true });
57
+ functions.push(
58
+ ...funcEntries
59
+ .filter((entry) => entry.isDirectory())
60
+ .map((entry) => entry.name)
61
+ .sort(),
62
+ );
63
+ } catch (error) {
64
+ log.warn("Could not read functions directory:", error);
65
+ }
66
+ }
67
+
68
+ return { types, functions };
69
+ }
70
+
71
+ /**
72
+ * Format list output for display
73
+ */
74
+ export function formatListOutput(result: ListResult, options: ListOptions = {}): string {
75
+ const lines: string[] = [];
76
+
77
+ const showTypes = options.types || (!options.types && !options.functions);
78
+ const showFunctions = options.functions || (!options.types && !options.functions);
79
+
80
+ if (showTypes && result.types.length > 0) {
81
+ lines.push("Types:");
82
+ for (const type of result.types) {
83
+ lines.push(` ${type}`);
84
+ }
85
+ }
86
+
87
+ if (showFunctions && result.functions.length > 0) {
88
+ if (lines.length > 0) lines.push("");
89
+ lines.push("Functions:");
90
+ for (const func of result.functions) {
91
+ lines.push(` function:${func}`);
92
+ }
93
+ }
94
+
95
+ if (lines.length === 0) {
96
+ lines.push("No schemas found.");
97
+ }
98
+
99
+ return lines.join("\n");
100
+ }
101
+
102
+ /**
103
+ * CLI action handler for list command
104
+ */
105
+ export async function handleListCommand(options: ListOptions = {}): Promise<void> {
106
+ const result = await listSchemas(undefined, options);
107
+ const output = formatListOutput(result, options);
108
+ console.log(output);
109
+ }
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Config file schema validation
3
+ */
4
+
5
+ export interface BundleConfig {
6
+ schemas: string[];
7
+ output?: string;
8
+ }
9
+
10
+ /**
11
+ * Validate bundle config
12
+ */
13
+ export function validateBundleConfig(data: unknown): BundleConfig {
14
+ if (typeof data !== "object" || data === null) {
15
+ throw new Error("Config must be an object");
16
+ }
17
+
18
+ const config = data as Record<string, unknown>;
19
+
20
+ if (!Array.isArray(config.schemas)) {
21
+ throw new Error("Config must have a 'schemas' array");
22
+ }
23
+
24
+ if (!config.schemas.every((s) => typeof s === "string")) {
25
+ throw new Error("All schemas must be strings");
26
+ }
27
+
28
+ if (config.output !== undefined && typeof config.output !== "string") {
29
+ throw new Error("Config 'output' must be a string if provided");
30
+ }
31
+
32
+ return {
33
+ schemas: config.schemas,
34
+ output: config.output as string | undefined,
35
+ };
36
+ }
@@ -0,0 +1,50 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * CLI entry point for @tokens-studio/tokenscript-schemas
5
+ */
6
+
7
+ /// <reference types="../../types/ulog" />
8
+
9
+ import cac from "cac";
10
+ import anylogger from "ulog";
11
+ import { type BundleOptions, handleBundleCommand } from "./commands/bundle.js";
12
+ import { handleListCommand, type ListOptions } from "./commands/list.js";
13
+
14
+ const log = anylogger("cli");
15
+
16
+ const cli = cac("tokenscript-schemas");
17
+
18
+ // Bundle command
19
+ cli
20
+ .command("bundle [...schemas]", "Bundle schemas into a JS file")
21
+ .option("-c, --config <path>", "Path to config file")
22
+ .option("-o, --output <path>", "Output file path", { default: "./tokenscript-schemas.js" })
23
+ .option("-d, --dry-run", "Preview what would be bundled without writing")
24
+ .action(async (schemas: string[], options: BundleOptions) => {
25
+ try {
26
+ await handleBundleCommand(schemas, options);
27
+ } catch (error) {
28
+ log.error("Error:", error);
29
+ process.exit(1);
30
+ }
31
+ });
32
+
33
+ // List command
34
+ cli
35
+ .command("list", "List available schemas")
36
+ .option("--types", "List only type schemas")
37
+ .option("--functions", "List only function schemas")
38
+ .action(async (options: ListOptions) => {
39
+ try {
40
+ await handleListCommand(options);
41
+ } catch (error) {
42
+ log.error("Error:", error);
43
+ process.exit(1);
44
+ }
45
+ });
46
+
47
+ cli.help();
48
+ cli.version("0.0.12");
49
+
50
+ cli.parse();
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Generate JavaScript output for bundled schemas
3
+ */
4
+
5
+ import type { BundledSchemaEntry } from "@/bundler/selective-bundler.js";
6
+
7
+ export interface OutputGeneratorOptions {
8
+ schemas: BundledSchemaEntry[];
9
+ includeHelper?: boolean; // Include makeConfig() helper
10
+ }
11
+
12
+ /**
13
+ * Generate JavaScript code for bundled schemas
14
+ */
15
+ export function generateOutput(options: OutputGeneratorOptions): string {
16
+ const { schemas, includeHelper = true } = options;
17
+
18
+ const timestamp = new Date().toISOString();
19
+ const schemaList = schemas.map((s) => s.uri).join(", ");
20
+
21
+ const lines: string[] = [];
22
+
23
+ // Header comment
24
+ lines.push("// Auto-generated by @tokens-studio/tokenscript-schemas");
25
+ lines.push(`// Generated: ${timestamp}`);
26
+ lines.push(`// Schemas: ${schemaList}`);
27
+ lines.push("");
28
+
29
+ // Import statement
30
+ lines.push('import { Config } from "@tokens-studio/tokenscript-interpreter";');
31
+ lines.push("");
32
+
33
+ // SCHEMAS export
34
+ lines.push("export const SCHEMAS = [");
35
+ for (const entry of schemas) {
36
+ // Format each schema entry - we need to serialize both uri and schema
37
+ const schemaJson = JSON.stringify(entry.schema, null, 2);
38
+ const uriJson = JSON.stringify(entry.uri);
39
+
40
+ // Indent the schema JSON
41
+ const indentedSchema = schemaJson
42
+ .split("\n")
43
+ .map((line) => ` ${line}`)
44
+ .join("\n");
45
+
46
+ lines.push(` {`);
47
+ lines.push(` uri: ${uriJson},`);
48
+ lines.push(` schema: ${indentedSchema.trim()}`);
49
+ lines.push(` },`);
50
+ }
51
+ lines.push("];");
52
+ lines.push("");
53
+
54
+ // Helper function
55
+ if (includeHelper) {
56
+ lines.push("export function makeConfig() {");
57
+ lines.push(" return new Config().registerSchemas(SCHEMAS);");
58
+ lines.push("}");
59
+ lines.push("");
60
+ }
61
+
62
+ return lines.join("\n");
63
+ }
@@ -0,0 +1,248 @@
1
+ /**
2
+ * Schema downloader - fetches schemas from the TokenScript API
3
+ */
4
+
5
+ import { mkdir, writeFile } from "node:fs/promises";
6
+ import { join } from "node:path";
7
+ import type {
8
+ SchemaConfig,
9
+ SchemaDetails,
10
+ SchemaListItem,
11
+ SchemaVersion,
12
+ } from "@/downloader/types.js";
13
+
14
+ const DEFAULT_CONFIG: SchemaConfig = {
15
+ apiBaseUrl: "https://schema.tokenscript.dev.gcp.tokens.studio/api/v1",
16
+ outputDir: "src/schemas",
17
+ targetVersion: "0.0.10",
18
+ };
19
+
20
+ /**
21
+ * Fetch all schemas from the API
22
+ */
23
+ export async function fetchSchemaList(
24
+ config: SchemaConfig = DEFAULT_CONFIG,
25
+ ): Promise<SchemaListItem[]> {
26
+ const url = `${config.apiBaseUrl}/schema/?format=json`;
27
+
28
+ console.log(`Fetching schema list from ${url}...`);
29
+ const response = await fetch(url);
30
+
31
+ if (!response.ok) {
32
+ throw new Error(`Failed to fetch schemas: ${response.statusText}`);
33
+ }
34
+
35
+ const data = (await response.json()) as SchemaListItem[];
36
+ console.log(`Found ${data.length} schemas`);
37
+
38
+ return data;
39
+ }
40
+
41
+ /**
42
+ * Fetch versions for a schema
43
+ */
44
+ export async function fetchSchemaVersions(
45
+ schemaSlug: string,
46
+ config: SchemaConfig = DEFAULT_CONFIG,
47
+ ): Promise<SchemaVersion[]> {
48
+ const url = `${config.apiBaseUrl}/schema/${schemaSlug}/versions/?format=json`;
49
+
50
+ const response = await fetch(url);
51
+
52
+ if (!response.ok) {
53
+ throw new Error(`Failed to fetch versions for ${schemaSlug}: ${response.statusText}`);
54
+ }
55
+
56
+ return (await response.json()) as SchemaVersion[];
57
+ }
58
+
59
+ /**
60
+ * Create the folder structure for a schema
61
+ */
62
+ async function createSchemaFolder(
63
+ schemaSlug: string,
64
+ schemaType: "type" | "function",
65
+ baseDir: string,
66
+ ): Promise<string> {
67
+ const schemaPath = join(baseDir, schemaType === "type" ? "types" : "functions", schemaSlug);
68
+ await mkdir(schemaPath, { recursive: true });
69
+ return schemaPath;
70
+ }
71
+
72
+ /**
73
+ * Write schema.json file
74
+ */
75
+ async function writeSchemaJson(
76
+ schemaPath: string,
77
+ schema: SchemaDetails,
78
+ targetVersion: string,
79
+ ): Promise<void> {
80
+ const content = schema.content as any;
81
+
82
+ const schemaJson = {
83
+ id: schema.id,
84
+ slug: schema.slug,
85
+ name: schema.name,
86
+ description: schema.description,
87
+ type: schema.type,
88
+ version: targetVersion,
89
+ originalVersion: schema.version,
90
+ contentType: content.type || null,
91
+ metadata: schema.metadata || {},
92
+ };
93
+
94
+ await writeFile(join(schemaPath, "schema.json"), JSON.stringify(schemaJson, null, 2));
95
+ }
96
+
97
+ /**
98
+ * Generate a unit test stub
99
+ */
100
+ async function createUnitTestStub(
101
+ schemaPath: string,
102
+ schemaName: string,
103
+ schemaType: "type" | "function",
104
+ ): Promise<void> {
105
+ const testContent = `import { describe, test, expect } from "vitest";
106
+
107
+ describe("${schemaName}", () => {
108
+ test.todo("should implement ${schemaType} functionality");
109
+ });
110
+ `;
111
+
112
+ await writeFile(join(schemaPath, "unit.test.ts"), testContent);
113
+ }
114
+
115
+ /**
116
+ * Extract conversion script name from source/target
117
+ */
118
+ function getConversionFileName(source: string, target: string): string {
119
+ // Extract the type name from URLs like "https://schema.../core/hex-color/0/"
120
+ const extractType = (url: string): string => {
121
+ const match = url.match(/\/([^/]+)\/\d+\/?$/);
122
+ return match ? match[1] : url;
123
+ };
124
+
125
+ const sourceType = extractType(source);
126
+ const targetType = extractType(target);
127
+
128
+ if (target === "$self") {
129
+ return `to-${sourceType}.tokenscript`;
130
+ }
131
+ if (source === "$self") {
132
+ return `from-${targetType}.tokenscript`;
133
+ }
134
+
135
+ return `${sourceType}-to-${targetType}.tokenscript`;
136
+ }
137
+
138
+ /**
139
+ * Write TokenScript files from schema content
140
+ */
141
+ async function writeTokenScriptFiles(schemaPath: string, schema: SchemaDetails): Promise<void> {
142
+ const content = schema.content as any;
143
+
144
+ // Write the main schema definition as JSON
145
+ if (content.schema) {
146
+ await writeFile(
147
+ join(schemaPath, "schema-definition.json"),
148
+ JSON.stringify(content.schema, null, 2),
149
+ );
150
+ }
151
+
152
+ // Extract and write conversion scripts
153
+ if (content.conversions && Array.isArray(content.conversions)) {
154
+ for (const conversion of content.conversions) {
155
+ if (conversion.script?.script) {
156
+ const fileName = getConversionFileName(conversion.source || "", conversion.target || "");
157
+
158
+ // Add description as comment if available
159
+ let scriptContent = "";
160
+ if (conversion.description) {
161
+ scriptContent += `# ${conversion.description}\n`;
162
+ scriptContent += `# Source: ${conversion.source}\n`;
163
+ scriptContent += `# Target: ${conversion.target}\n`;
164
+ scriptContent += `# Lossless: ${conversion.lossless || false}\n\n`;
165
+ }
166
+
167
+ scriptContent += conversion.script.script;
168
+
169
+ await writeFile(join(schemaPath, fileName), scriptContent);
170
+ }
171
+ }
172
+ }
173
+
174
+ // Create initializer if no conversions found
175
+ if (!content.conversions || content.conversions.length === 0) {
176
+ const initializerContent = `# ${schema.name} Initializer
177
+ # TODO: Implement initialization logic
178
+
179
+ `;
180
+ await writeFile(join(schemaPath, "initializer.tokenscript"), initializerContent);
181
+ }
182
+ }
183
+
184
+ /**
185
+ * Download and organize a single schema
186
+ */
187
+ export async function downloadSchema(
188
+ schema: SchemaListItem,
189
+ config: SchemaConfig = DEFAULT_CONFIG,
190
+ ): Promise<void> {
191
+ console.log(`Downloading ${schema.slug}...`);
192
+
193
+ // Fetch all versions
194
+ const versions = await fetchSchemaVersions(schema.slug, config);
195
+
196
+ if (versions.length === 0) {
197
+ console.warn(`No versions found for ${schema.slug}, skipping`);
198
+ return;
199
+ }
200
+
201
+ // Get the latest version (first one)
202
+ const latestVersion = versions[0];
203
+
204
+ // Create folder structure
205
+ const schemaPath = await createSchemaFolder(schema.slug, schema.type, config.outputDir);
206
+
207
+ // Combine schema info with version info
208
+ const details: SchemaDetails = {
209
+ id: schema.id,
210
+ slug: schema.slug,
211
+ name: schema.name,
212
+ description: schema.description,
213
+ type: schema.type,
214
+ version: latestVersion.version,
215
+ content: latestVersion.content,
216
+ };
217
+
218
+ // Write files
219
+ await writeSchemaJson(schemaPath, details, config.targetVersion);
220
+ await writeTokenScriptFiles(schemaPath, details);
221
+ await createUnitTestStub(schemaPath, schema.name, schema.type);
222
+
223
+ console.log(`✓ Downloaded ${schema.slug} to ${schemaPath}`);
224
+ }
225
+
226
+ /**
227
+ * Download all schemas from the API
228
+ */
229
+ export async function downloadAllSchemas(config: Partial<SchemaConfig> = {}): Promise<void> {
230
+ const fullConfig = { ...DEFAULT_CONFIG, ...config };
231
+
232
+ // Fetch schema list
233
+ const schemas = await fetchSchemaList(fullConfig);
234
+
235
+ // Download each schema
236
+ for (const schema of schemas) {
237
+ try {
238
+ await downloadSchema(schema, fullConfig);
239
+ } catch (error) {
240
+ console.error(`Failed to download ${schema.slug}:`, error);
241
+ }
242
+ }
243
+
244
+ console.log("\n✓ All schemas downloaded successfully!");
245
+ }
246
+
247
+ export { DEFAULT_CONFIG };
248
+ export type * from "@/downloader/types.js";
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Types for schema downloader
3
+ */
4
+
5
+ export interface LatestVersion {
6
+ id: string;
7
+ version: string;
8
+ created_at: string;
9
+ }
10
+
11
+ export interface SchemaListItem {
12
+ id: string;
13
+ slug: string;
14
+ name: string;
15
+ description: string;
16
+ license_name: string | null;
17
+ type: "type" | "function";
18
+ latest: LatestVersion;
19
+ }
20
+
21
+ export interface SchemaVersion {
22
+ id: string;
23
+ type: "type" | "function";
24
+ schema: string;
25
+ slug: string;
26
+ version: string;
27
+ content: unknown;
28
+ status?: string;
29
+ created_at?: string;
30
+ updated_at?: string;
31
+ }
32
+
33
+ export interface SchemaDetails {
34
+ id: string;
35
+ slug: string;
36
+ name: string;
37
+ description: string;
38
+ type: "type" | "function";
39
+ version: string;
40
+ content: unknown;
41
+ metadata?: Record<string, unknown>;
42
+ }
43
+
44
+ export interface SchemaConfig {
45
+ apiBaseUrl: string;
46
+ outputDir: string;
47
+ targetVersion: string;
48
+ }
package/src/index.ts ADDED
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @tokens-studio/tokenscript-schemas
3
+ *
4
+ * Schema registry for TokenScript with bundled schemas and validation
5
+ */
6
+
7
+ export * from "@/bundler/index.js";
8
+ export * from "@/downloader/index.js";
@@ -0,0 +1,27 @@
1
+ // adjust_chroma: Adjust chroma by a relative amount
2
+ //
3
+ // Modifies the chroma (colorfulness) of a color by adding the
4
+ // specified amount. Positive values increase saturation,
5
+ // negative values decrease it. Result is clamped to [0, ∞).
6
+ //
7
+ // Uses OKLCH for perceptually uniform results.
8
+ // Preserves lightness and hue.
9
+
10
+ variable input: List = {input};
11
+ variable color: Color.OKLCH = input.get(0).to.oklch();
12
+ variable amount: Number = input.get(1);
13
+
14
+ // Calculate new chroma
15
+ variable new_c: Number = color.c + amount;
16
+
17
+ // Clamp to valid range (chroma cannot be negative)
18
+ if (new_c < 0) [ new_c = 0; ];
19
+
20
+ // Create result
21
+ variable result: Color.OKLCH;
22
+ result.l = color.l;
23
+ result.c = new_c;
24
+ result.h = color.h;
25
+
26
+ return result;
27
+
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "adjust_chroma",
3
+ "type": "function",
4
+ "description": "Adjusts a color's chroma by a relative amount. Positive values increase saturation, negative values decrease it. Unlike set_chroma which sets an absolute value, adjust_chroma adds to the current chroma. Result is clamped to valid range [0, ~0.4].",
5
+ "keyword": "adjust_chroma",
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 adjust",
15
+ "type": "color"
16
+ },
17
+ {
18
+ "description": "Amount to adjust chroma (+/-)",
19
+ "type": "number"
20
+ }
21
+ ],
22
+ "minItems": 2,
23
+ "maxItems": 2
24
+ }
25
+ },
26
+ "required": ["input"]
27
+ },
28
+ "returns": {
29
+ "type": "color",
30
+ "description": "Color with adjusted chroma"
31
+ },
32
+ "script": {
33
+ "type": "https://schema.tokenscript.dev.gcp.tokens.studio/api/v1/core/tokenscript/0/",
34
+ "script": "./adjust-chroma.tokenscript"
35
+ },
36
+ "examples": [
37
+ {
38
+ "description": "Increase saturation",
39
+ "input": ["#808080", 0.1],
40
+ "output": "More saturated color"
41
+ },
42
+ {
43
+ "description": "Decrease saturation",
44
+ "input": ["#ff6600", -0.1],
45
+ "output": "Less saturated orange"
46
+ }
47
+ ]
48
+ }