@tokens-studio/tokenscript-schemas 0.0.13 → 0.1.0

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 (153) hide show
  1. package/README.md +21 -0
  2. package/bundled/functions/adjust_chroma.json +60 -0
  3. package/bundled/functions/adjust_hue.json +60 -0
  4. package/bundled/functions/adjust_lightness.json +60 -0
  5. package/bundled/functions/adjust_to_contrast.json +67 -0
  6. package/bundled/functions/alpha_blend.json +31 -0
  7. package/bundled/functions/alpha_scale.json +27 -0
  8. package/bundled/functions/analogous.json +32 -0
  9. package/bundled/functions/apca_contrast.json +27 -0
  10. package/bundled/functions/are_similar.json +73 -0
  11. package/bundled/functions/auto_text_color.json +66 -0
  12. package/bundled/functions/best_contrast.json +28 -0
  13. package/bundled/functions/chroma.json +54 -0
  14. package/bundled/functions/clamp_chroma.json +66 -0
  15. package/bundled/functions/clamp_lightness.json +66 -0
  16. package/bundled/functions/clamp_to_gamut.json +23 -0
  17. package/bundled/functions/complement.json +24 -0
  18. package/bundled/functions/contrast_ratio.json +27 -0
  19. package/bundled/functions/cooler.json +52 -0
  20. package/bundled/functions/darken.json +28 -0
  21. package/bundled/functions/delta_e_2000.json +40 -0
  22. package/bundled/functions/delta_e_76.json +27 -0
  23. package/bundled/functions/delta_e_ok.json +27 -0
  24. package/bundled/functions/desaturate.json +28 -0
  25. package/bundled/functions/distributed.json +36 -0
  26. package/bundled/functions/diverging.json +36 -0
  27. package/bundled/functions/grayscale.json +24 -0
  28. package/bundled/functions/harmonize.json +65 -0
  29. package/bundled/functions/hue.json +54 -0
  30. package/bundled/functions/hue_difference.json +27 -0
  31. package/bundled/functions/in_gamut.json +27 -0
  32. package/bundled/functions/interpolate.json +66 -0
  33. package/bundled/functions/invert.json +1 -1
  34. package/bundled/functions/is_cool.json +23 -0
  35. package/bundled/functions/is_dark.json +27 -0
  36. package/bundled/functions/is_light.json +27 -0
  37. package/bundled/functions/is_neutral.json +65 -0
  38. package/bundled/functions/is_warm.json +23 -0
  39. package/bundled/functions/lighten.json +28 -0
  40. package/bundled/functions/lightness.json +61 -0
  41. package/bundled/functions/luminance.json +23 -0
  42. package/bundled/functions/meets_contrast.json +31 -0
  43. package/bundled/functions/mix.json +32 -0
  44. package/bundled/functions/monochromatic.json +28 -0
  45. package/bundled/functions/muted.json +59 -0
  46. package/bundled/functions/neutral_variant.json +59 -0
  47. package/bundled/functions/relative_luminance.json +61 -0
  48. package/bundled/functions/rotate_hue.json +28 -0
  49. package/bundled/functions/saturate.json +28 -0
  50. package/bundled/functions/scale_chroma.json +60 -0
  51. package/bundled/functions/scale_lightness.json +60 -0
  52. package/bundled/functions/sepia.json +59 -0
  53. package/bundled/functions/set_chroma.json +28 -0
  54. package/bundled/functions/set_hue.json +28 -0
  55. package/bundled/functions/set_lightness.json +28 -0
  56. package/bundled/functions/shade_scale.json +28 -0
  57. package/bundled/functions/split_complement.json +28 -0
  58. package/bundled/functions/steps.json +32 -0
  59. package/bundled/functions/tetradic.json +24 -0
  60. package/bundled/functions/tint_scale.json +36 -0
  61. package/bundled/functions/to_gamut.json +59 -0
  62. package/bundled/functions/triadic.json +24 -0
  63. package/bundled/functions/vibrant.json +59 -0
  64. package/bundled/functions/warmer.json +52 -0
  65. package/bundled/functions/wcag_level.json +60 -0
  66. package/bundled/functions.json +2602 -6
  67. package/bundled/registry.json +3705 -84
  68. package/bundled/types/css-color.json +151 -0
  69. package/bundled/types/hsl-color.json +66 -0
  70. package/bundled/types/hsv-color.json +57 -0
  71. package/bundled/types/hwb-color.json +66 -0
  72. package/bundled/types/lab-color.json +57 -0
  73. package/bundled/types/lch-color.json +57 -0
  74. package/bundled/types/okhsl-color.json +57 -0
  75. package/bundled/types/okhsv-color.json +57 -0
  76. package/bundled/types/oklab-color.json +87 -0
  77. package/bundled/types/oklch-color.json +57 -0
  78. package/bundled/types/p3-color.json +57 -0
  79. package/bundled/types/p3-linear-color.json +57 -0
  80. package/bundled/types/rgb-color.json +12 -3
  81. package/bundled/types/srgb-color.json +77 -0
  82. package/bundled/types/srgb-linear-color.json +67 -0
  83. package/bundled/types/xyz-d50-color.json +57 -0
  84. package/bundled/types/xyz-d65-color.json +77 -0
  85. package/bundled/types.json +1067 -43
  86. package/dist/cli/index.cjs +231 -22
  87. package/dist/cli/index.cjs.map +1 -1
  88. package/dist/cli/index.js +231 -22
  89. package/dist/cli/index.js.map +1 -1
  90. package/dist/index.cjs +5 -2
  91. package/dist/index.cjs.map +1 -1
  92. package/dist/index.d.cts +4 -1
  93. package/dist/index.d.ts +4 -1
  94. package/dist/index.js +5 -2
  95. package/dist/index.js.map +1 -1
  96. package/package.json +4 -2
  97. package/src/bundler/index.ts +7 -0
  98. package/src/bundler/presets/css.ts +21 -0
  99. package/src/bundler/presets/index.ts +47 -0
  100. package/src/bundler/presets/types.ts +10 -0
  101. package/src/bundler/selective-bundler.ts +9 -0
  102. package/src/bundler/types.ts +1 -0
  103. package/src/cli/commands/bundle.test.ts +34 -0
  104. package/src/cli/commands/bundle.ts +37 -11
  105. package/src/cli/commands/list.ts +36 -4
  106. package/src/cli/commands/presets.ts +81 -0
  107. package/src/cli/index.ts +12 -1
  108. package/src/cli/output-generator.ts +8 -2
  109. package/src/cli/version-info.ts +93 -0
  110. package/src/schemas/types/css-color/from-hsl-color.tokenscript +17 -4
  111. package/src/schemas/types/css-color/from-hwb-color.tokenscript +17 -4
  112. package/src/schemas/types/css-color/from-lab-color.tokenscript +17 -4
  113. package/src/schemas/types/css-color/from-lch-color.tokenscript +17 -4
  114. package/src/schemas/types/css-color/from-oklab-color.tokenscript +17 -4
  115. package/src/schemas/types/css-color/from-oklch-color.tokenscript +17 -4
  116. package/src/schemas/types/css-color/from-p3-color.tokenscript +17 -4
  117. package/src/schemas/types/css-color/from-rgb-color.tokenscript +17 -4
  118. package/src/schemas/types/css-color/from-srgb-color.tokenscript +17 -4
  119. package/src/schemas/types/css-color/from-xyz-d50-color.tokenscript +17 -4
  120. package/src/schemas/types/css-color/from-xyz-d65-color.tokenscript +17 -4
  121. package/src/schemas/types/css-color/unit.test.ts +216 -0
  122. package/src/schemas/types/hex-color/unit.test.ts +18 -0
  123. package/src/schemas/types/hsl-color/hsla-initializer.tokenscript +17 -0
  124. package/src/schemas/types/hsl-color/initializer.tokenscript +6 -1
  125. package/src/schemas/types/hsl-color/schema.json +9 -0
  126. package/src/schemas/types/hsl-color/unit.test.ts +95 -1
  127. package/src/schemas/types/hsv-color/initializer.tokenscript +6 -1
  128. package/src/schemas/types/hsv-color/unit.test.ts +44 -0
  129. package/src/schemas/types/hwb-color/hwba-initializer.tokenscript +17 -0
  130. package/src/schemas/types/hwb-color/initializer.tokenscript +6 -1
  131. package/src/schemas/types/hwb-color/schema.json +9 -0
  132. package/src/schemas/types/hwb-color/unit.test.ts +70 -0
  133. package/src/schemas/types/lab-color/initializer.tokenscript +6 -1
  134. package/src/schemas/types/lab-color/unit.test.ts +44 -0
  135. package/src/schemas/types/lch-color/initializer.tokenscript +6 -1
  136. package/src/schemas/types/lch-color/unit.test.ts +44 -0
  137. package/src/schemas/types/okhsl-color/initializer.tokenscript +8 -1
  138. package/src/schemas/types/okhsl-color/unit.test.ts +37 -0
  139. package/src/schemas/types/okhsv-color/initializer.tokenscript +8 -1
  140. package/src/schemas/types/okhsv-color/unit.test.ts +37 -0
  141. package/src/schemas/types/oklab-color/initializer.tokenscript +6 -1
  142. package/src/schemas/types/oklab-color/unit.test.ts +58 -0
  143. package/src/schemas/types/oklch-color/initializer.tokenscript +6 -1
  144. package/src/schemas/types/oklch-color/unit.test.ts +58 -0
  145. package/src/schemas/types/p3-color/initializer.tokenscript +6 -1
  146. package/src/schemas/types/p3-color/unit.test.ts +47 -0
  147. package/src/schemas/types/rgb-color/initializer.tokenscript +7 -1
  148. package/src/schemas/types/rgb-color/rgba-initializer.tokenscript +17 -0
  149. package/src/schemas/types/rgb-color/schema.json +9 -0
  150. package/src/schemas/types/rgb-color/unit.test.ts +110 -1
  151. package/src/schemas/types/srgb-color/initializer.tokenscript +6 -1
  152. package/src/schemas/types/srgb-color/unit.test.ts +89 -0
  153. package/bundled/types/rgba-color.json +0 -89
@@ -0,0 +1,57 @@
1
+ {
2
+ "name": "XYZD50",
3
+ "type": "color",
4
+ "description": "CIE XYZ color space with D50 white point. Used for Lab and LCH color spaces.",
5
+ "schema": {
6
+ "type": "object",
7
+ "properties": {
8
+ "x": {
9
+ "type": "number",
10
+ "description": "X tristimulus value"
11
+ },
12
+ "y": {
13
+ "type": "number",
14
+ "description": "Y tristimulus value (luminance)"
15
+ },
16
+ "z": {
17
+ "type": "number",
18
+ "description": "Z tristimulus value"
19
+ }
20
+ },
21
+ "required": [
22
+ "x",
23
+ "y",
24
+ "z"
25
+ ],
26
+ "order": [
27
+ "x",
28
+ "y",
29
+ "z"
30
+ ],
31
+ "additionalProperties": false
32
+ },
33
+ "initializers": [
34
+ {
35
+ "title": "XYZ-D50 Color Initializer",
36
+ "keyword": "xyzd50",
37
+ "description": "Creates an XYZ-D50 color from tristimulus values",
38
+ "script": {
39
+ "type": "https://schema.tokenscript.dev.gcp.tokens.studio/api/v1/core/tokenscript/0/",
40
+ "script": "// XYZ-D50 Color Initializer\n// Creates an XYZ-D50 color from tristimulus values\n// Input: List of [x, y, z] tristimulus values\n\nvariable xyz_values: List = {input};\nvariable output: Color.XYZD50;\n\noutput.x = xyz_values.get(0);\noutput.y = xyz_values.get(1);\noutput.z = xyz_values.get(2);\n\nreturn output;"
41
+ }
42
+ }
43
+ ],
44
+ "conversions": [
45
+ {
46
+ "source": "https://schema.tokenscript.dev.gcp.tokens.studio/api/v1/core/xyz-d65-color/0/",
47
+ "target": "$self",
48
+ "description": "Converts XYZ-D65 to XYZ-D50 using Bradford chromatic adaptation",
49
+ "lossless": true,
50
+ "script": {
51
+ "type": "https://schema.tokenscript.dev.gcp.tokens.studio/api/v1/core/tokenscript/0/",
52
+ "script": "// XYZ-D65 to XYZ-D50 Conversion\n// Chromatic adaptation using Bradford transform\n// Reference: https://github.com/color-js/color.js/blob/main/src/adapt.js\n//\n// Bradford CAT matrix for D65 → D50:\n// [1.0479298 0.0229469 -0.0501923]\n// [0.0296278 0.9904344 -0.0170738]\n// [-0.0092430 0.0150552 0.7518743]\n//\n// Input: Color.XYZD65 with x, y, z tristimulus (D65 white)\n// Output: Color.XYZD50 with x, y, z tristimulus (D50 white)\n\n// Get input XYZ-D65 values\nvariable x65: Number = {input}.x;\nvariable y65: Number = {input}.y;\nvariable z65: Number = {input}.z;\n\n// Bradford chromatic adaptation matrix (ColorJS exact values)\n// Row 1\nvariable x50: Number = x65 * 1.0479297925449969 + y65 * 0.022946870601609652 + z65 * -0.05019226628920524;\n// Row 2\nvariable y50: Number = x65 * 0.02962780877005599 + y65 * 0.9904344267538799 + z65 * -0.017073799063418826;\n// Row 3\nvariable z50: Number = x65 * -0.009243040646204504 + y65 * 0.015055191490298152 + z65 * 0.7518742814281371;\n\n// Create output\nvariable output: Color.XYZD50;\noutput.x = x50;\noutput.y = y50;\noutput.z = z50;\n\nreturn output;"
53
+ }
54
+ }
55
+ ],
56
+ "slug": "xyz-d50-color"
57
+ }
@@ -0,0 +1,77 @@
1
+ {
2
+ "name": "XYZD65",
3
+ "type": "color",
4
+ "description": "CIE XYZ color space with D65 white point. The primary connection hub for color space conversions.",
5
+ "schema": {
6
+ "type": "object",
7
+ "properties": {
8
+ "x": {
9
+ "type": "number",
10
+ "description": "X tristimulus value"
11
+ },
12
+ "y": {
13
+ "type": "number",
14
+ "description": "Y tristimulus value (luminance)"
15
+ },
16
+ "z": {
17
+ "type": "number",
18
+ "description": "Z tristimulus value"
19
+ }
20
+ },
21
+ "required": [
22
+ "x",
23
+ "y",
24
+ "z"
25
+ ],
26
+ "order": [
27
+ "x",
28
+ "y",
29
+ "z"
30
+ ],
31
+ "additionalProperties": false
32
+ },
33
+ "initializers": [
34
+ {
35
+ "title": "XYZ-D65 Color Initializer",
36
+ "keyword": "xyzd65",
37
+ "description": "Creates an XYZ-D65 color from tristimulus values",
38
+ "script": {
39
+ "type": "https://schema.tokenscript.dev.gcp.tokens.studio/api/v1/core/tokenscript/0/",
40
+ "script": "// XYZ-D65 Color Initializer\n// Creates an XYZ-D65 color from tristimulus values\n// Input: List of [x, y, z] tristimulus values\n\nvariable xyz_values: List = {input};\nvariable output: Color.XYZD65;\n\noutput.x = xyz_values.get(0);\noutput.y = xyz_values.get(1);\noutput.z = xyz_values.get(2);\n\nreturn output;"
41
+ }
42
+ }
43
+ ],
44
+ "conversions": [
45
+ {
46
+ "source": "https://schema.tokenscript.dev.gcp.tokens.studio/api/v1/core/srgb-linear-color/0/",
47
+ "target": "$self",
48
+ "description": "Converts Linear sRGB to XYZ-D65 using the sRGB transformation matrix",
49
+ "lossless": true,
50
+ "script": {
51
+ "type": "https://schema.tokenscript.dev.gcp.tokens.studio/api/v1/core/tokenscript/0/",
52
+ "script": "// Linear sRGB to XYZ-D65 Conversion\n// Uses the sRGB primaries transformation matrix\n// Reference: IEC 61966-2-1:1999 (sRGB specification)\n//\n// Matrix (Linear RGB → XYZ-D65):\n// [X] [0.4123908 0.3575843 0.1804808] [R]\n// [Y] = [0.2126390 0.7151687 0.0721923] [G]\n// [Z] [0.0193308 0.1191948 0.9505322] [B]\n//\n// Input: Color.LinearSRGB with r, g, b in linear 0-1 range\n// Output: Color.XYZD65 with x, y, z tristimulus values\n\n// Get input linear sRGB values\nvariable r: Number = {input}.r;\nvariable g: Number = {input}.g;\nvariable b: Number = {input}.b;\n\n// Matrix multiplication: M × [R, G, B]ᵀ\n// Row 1: X = 0.4123908 * R + 0.3575843 * G + 0.1804808 * B\nvariable x: Number = r * 0.41239079926595934 + g * 0.357584339383878 + b * 0.1804807884018343;\n\n// Row 2: Y = 0.2126390 * R + 0.7151687 * G + 0.0721923 * B\nvariable y: Number = r * 0.21263900587151027 + g * 0.715168678767756 + b * 0.07219231536073371;\n\n// Row 3: Z = 0.0193308 * R + 0.1191948 * G + 0.9505322 * B\nvariable z: Number = r * 0.01933081871559182 + g * 0.11919477979462598 + b * 0.9505321522496607;\n\n// Create output\nvariable output: Color.XYZD65;\noutput.x = x;\noutput.y = y;\noutput.z = z;\n\nreturn output;"
53
+ }
54
+ },
55
+ {
56
+ "source": "https://schema.tokenscript.dev.gcp.tokens.studio/api/v1/core/p3-linear-color/0/",
57
+ "target": "$self",
58
+ "description": "Converts Linear P3 to XYZ-D65 using the P3 transformation matrix",
59
+ "lossless": true,
60
+ "script": {
61
+ "type": "https://schema.tokenscript.dev.gcp.tokens.studio/api/v1/core/tokenscript/0/",
62
+ "script": "// Linear P3 to XYZ-D65 Conversion\n// Converts linear Display-P3 RGB to CIE XYZ (D65)\n// Reference: CSS Color Level 4 specification\n//\n// Uses the P3 to XYZ-D65 transformation matrix\n// Matrix values from ColorJS / CSS Color Level 4\n//\n// Input: Color.LinearP3 with linear r, g, b values\n// Output: Color.XYZD65 with x, y, z tristimulus values\n\n// Get linear P3 values\nvariable r: Number = {input}.r;\nvariable g: Number = {input}.g;\nvariable b: Number = {input}.b;\n\n// Linear P3 to XYZ-D65 matrix\n// Row 1\nvariable m00: Number = 0.4865709486482162;\nvariable m01: Number = 0.26566769316909306;\nvariable m02: Number = 0.1982172852343625;\n\n// Row 2\nvariable m10: Number = 0.2289745640697488;\nvariable m11: Number = 0.6917385218365064;\nvariable m12: Number = 0.079286914093745;\n\n// Row 3\nvariable m20: Number = 0.0;\nvariable m21: Number = 0.04511338185890264;\nvariable m22: Number = 1.043944368900976;\n\n// Matrix multiplication: [x, y, z] = M × [r, g, b]\nvariable x: Number = m00 * r + m01 * g + m02 * b;\nvariable y: Number = m10 * r + m11 * g + m12 * b;\nvariable z: Number = m20 * r + m21 * g + m22 * b;\n\n// Create output\nvariable output: Color.XYZD65;\noutput.x = x;\noutput.y = y;\noutput.z = z;\n\nreturn output;"
63
+ }
64
+ },
65
+ {
66
+ "source": "https://schema.tokenscript.dev.gcp.tokens.studio/api/v1/core/oklab-color/0/",
67
+ "target": "$self",
68
+ "description": "Converts OKLab to XYZ-D65 using inverse LMS transformation",
69
+ "lossless": true,
70
+ "script": {
71
+ "type": "https://schema.tokenscript.dev.gcp.tokens.studio/api/v1/core/tokenscript/0/",
72
+ "script": "// OKLab to XYZ-D65 Conversion\n// Reference: ColorJS oklab.js (inverse transformation)\n//\n// Algorithm:\n// 1. Apply inverse Lab-to-LMS matrix to get LMS cone responses\n// 2. Cube the LMS values (inverse of cube root)\n// 3. Apply inverse LMS-to-XYZ matrix\n//\n// Input: Color.OKLab with l, a, b perceptual coordinates\n// Output: Color.XYZD65 with x, y, z tristimulus values\n\n// Get input OKLab values\nvariable ok_l: Number = {input}.l;\nvariable ok_a: Number = {input}.a;\nvariable ok_b: Number = {input}.b;\n\n// Inverse LMStoLab_M matrix (Lab to LMS')\n// These are the inverse of the matrix used in from-xyz-d65.tokenscript\nvariable lms_l: Number = 1.0 * ok_l + 0.3963377773761749 * ok_a + 0.2158037573099136 * ok_b;\nvariable lms_m: Number = 1.0 * ok_l + -0.1055613458156586 * ok_a + -0.0638541728258133 * ok_b;\nvariable lms_s: Number = 1.0 * ok_l + -0.0894841775298119 * ok_a + -1.2914855480194092 * ok_b;\n\n// Cube the values (inverse of cube root)\nvariable lms_l_cubed: Number = lms_l * lms_l * lms_l;\nvariable lms_m_cubed: Number = lms_m * lms_m * lms_m;\nvariable lms_s_cubed: Number = lms_s * lms_s * lms_s;\n\n// Inverse XYZtoLMS_M matrix (LMS to XYZ)\n// From ColorJS oklab.js\nvariable x: Number = 1.2268798758459243 * lms_l_cubed + -0.5578149944602171 * lms_m_cubed + 0.2813910456659647 * lms_s_cubed;\nvariable y: Number = -0.0405757452148008 * lms_l_cubed + 1.1122868032803170 * lms_m_cubed + -0.0717110580655164 * lms_s_cubed;\nvariable z: Number = -0.0763729366746601 * lms_l_cubed + -0.4214933324022432 * lms_m_cubed + 1.5869240198367816 * lms_s_cubed;\n\n// Create output\nvariable output: Color.XYZD65;\noutput.x = x;\noutput.y = y;\noutput.z = z;\n\nreturn output;"
73
+ }
74
+ }
75
+ ],
76
+ "slug": "xyz-d65-color"
77
+ }