@tokens-studio/tokenscript-schemas 0.2.0 → 0.3.1
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.
- package/package.json +2 -2
- package/src/schemas/functions/adjust_chroma/adjust-chroma.tokenscript +1 -0
- package/src/schemas/functions/adjust_chroma/unit.test.ts +14 -0
- package/src/schemas/functions/adjust_hue/adjust-hue.tokenscript +1 -0
- package/src/schemas/functions/adjust_hue/unit.test.ts +14 -0
- package/src/schemas/functions/adjust_lightness/adjust-lightness.tokenscript +1 -0
- package/src/schemas/functions/adjust_lightness/unit.test.ts +14 -0
- package/src/schemas/functions/clamp_chroma/clamp-chroma.tokenscript +1 -0
- package/src/schemas/functions/clamp_chroma/unit.test.ts +14 -0
- package/src/schemas/functions/clamp_lightness/clamp-lightness.tokenscript +1 -0
- package/src/schemas/functions/clamp_lightness/unit.test.ts +14 -0
- package/src/schemas/functions/scale_chroma/scale-chroma.tokenscript +1 -0
- package/src/schemas/functions/scale_chroma/unit.test.ts +14 -0
- package/src/schemas/functions/scale_lightness/scale-lightness.tokenscript +1 -0
- package/src/schemas/functions/scale_lightness/unit.test.ts +14 -0
- package/src/schemas/functions/set_chroma/set-chroma.tokenscript +1 -0
- package/src/schemas/functions/set_chroma/unit.test.ts +14 -0
- package/src/schemas/functions/set_hue/set-hue.tokenscript +1 -0
- package/src/schemas/functions/set_hue/unit.test.ts +14 -0
- package/src/schemas/functions/set_lightness/set-lightness.tokenscript +1 -0
- package/src/schemas/functions/set_lightness/unit.test.ts +14 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tokens-studio/tokenscript-schemas",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Schema registry for TokenScript with bundled schemas and validation",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"author": "Tokens Studio (https://tokens.studio)",
|
|
70
70
|
"license": "MPL-2.0",
|
|
71
71
|
"dependencies": {
|
|
72
|
-
"@tokens-studio/tokenscript-interpreter": "^0.
|
|
72
|
+
"@tokens-studio/tokenscript-interpreter": "^0.21.0",
|
|
73
73
|
"arktype": "^2.1.25",
|
|
74
74
|
"cac": "^6.7.14",
|
|
75
75
|
"ulog": "^2.0.0-beta.19"
|
|
@@ -72,5 +72,19 @@ describe("adjust_chroma function", () => {
|
|
|
72
72
|
expect(Math.abs(r - g)).toBeLessThan(0.02);
|
|
73
73
|
expect(Math.abs(g - b)).toBeLessThan(0.02);
|
|
74
74
|
});
|
|
75
|
+
|
|
76
|
+
it("should preserve alpha channel", async () => {
|
|
77
|
+
const result = await executeWithSchema(
|
|
78
|
+
"adjust_chroma",
|
|
79
|
+
"function",
|
|
80
|
+
`
|
|
81
|
+
variable color: Color.OKLCH = oklch(0.5, 0.15, 30, 0.7);
|
|
82
|
+
adjust_chroma(color, 0.05)
|
|
83
|
+
`,
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
expect(result?.constructor.name).toBe("ColorSymbol");
|
|
87
|
+
expect((result as any).alpha).toBe(0.7);
|
|
88
|
+
});
|
|
75
89
|
});
|
|
76
90
|
});
|
|
@@ -64,5 +64,19 @@ describe("adjust_hue function", () => {
|
|
|
64
64
|
const r = (result as any).value?.r?.value ?? (result as any).value?.r;
|
|
65
65
|
expect(r).toBeGreaterThan(0.7);
|
|
66
66
|
});
|
|
67
|
+
|
|
68
|
+
it("should preserve alpha channel", async () => {
|
|
69
|
+
const result = await executeWithSchema(
|
|
70
|
+
"adjust_hue",
|
|
71
|
+
"function",
|
|
72
|
+
`
|
|
73
|
+
variable color: Color.OKLCH = oklch(0.5, 0.15, 30, 0.7);
|
|
74
|
+
adjust_hue(color, 90)
|
|
75
|
+
`,
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
expect(result?.constructor.name).toBe("ColorSymbol");
|
|
79
|
+
expect((result as any).alpha).toBe(0.7);
|
|
80
|
+
});
|
|
67
81
|
});
|
|
68
82
|
});
|
|
@@ -84,5 +84,19 @@ describe("adjust_lightness function", () => {
|
|
|
84
84
|
const r = (result as any).value?.r?.value ?? (result as any).value?.r;
|
|
85
85
|
expect(r).toBeCloseTo(1, 1);
|
|
86
86
|
});
|
|
87
|
+
|
|
88
|
+
it("should preserve alpha channel", async () => {
|
|
89
|
+
const result = await executeWithSchema(
|
|
90
|
+
"adjust_lightness",
|
|
91
|
+
"function",
|
|
92
|
+
`
|
|
93
|
+
variable color: Color.OKLCH = oklch(0.5, 0.15, 30, 0.7);
|
|
94
|
+
adjust_lightness(color, 0.1)
|
|
95
|
+
`,
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
expect(result?.constructor.name).toBe("ColorSymbol");
|
|
99
|
+
expect((result as any).alpha).toBe(0.7);
|
|
100
|
+
});
|
|
87
101
|
});
|
|
88
102
|
});
|
|
@@ -56,5 +56,19 @@ describe("clamp_chroma function", () => {
|
|
|
56
56
|
expect(Math.abs(r - g)).toBeLessThan(0.1);
|
|
57
57
|
expect(Math.abs(g - b)).toBeLessThan(0.1);
|
|
58
58
|
});
|
|
59
|
+
|
|
60
|
+
it("should preserve alpha channel", async () => {
|
|
61
|
+
const result = await executeWithSchema(
|
|
62
|
+
"clamp_chroma",
|
|
63
|
+
"function",
|
|
64
|
+
`
|
|
65
|
+
variable color: Color.OKLCH = oklch(0.5, 0.15, 30, 0.7);
|
|
66
|
+
clamp_chroma(color, 0.05, 0.2)
|
|
67
|
+
`,
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
expect(result?.constructor.name).toBe("ColorSymbol");
|
|
71
|
+
expect((result as any).alpha).toBe(0.7);
|
|
72
|
+
});
|
|
59
73
|
});
|
|
60
74
|
});
|
|
@@ -72,5 +72,19 @@ describe("clamp_lightness function", () => {
|
|
|
72
72
|
expect(r).toBeGreaterThan(0.3);
|
|
73
73
|
expect(r).toBeLessThan(0.7);
|
|
74
74
|
});
|
|
75
|
+
|
|
76
|
+
it("should preserve alpha channel", async () => {
|
|
77
|
+
const result = await executeWithSchema(
|
|
78
|
+
"clamp_lightness",
|
|
79
|
+
"function",
|
|
80
|
+
`
|
|
81
|
+
variable color: Color.OKLCH = oklch(0.5, 0.15, 30, 0.7);
|
|
82
|
+
clamp_lightness(color, 0.3, 0.7)
|
|
83
|
+
`,
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
expect(result?.constructor.name).toBe("ColorSymbol");
|
|
87
|
+
expect((result as any).alpha).toBe(0.7);
|
|
88
|
+
});
|
|
75
89
|
});
|
|
76
90
|
});
|
|
@@ -75,5 +75,19 @@ describe("scale_chroma function", () => {
|
|
|
75
75
|
expect(Math.abs(r - g)).toBeLessThan(0.05);
|
|
76
76
|
expect(Math.abs(g - b)).toBeLessThan(0.05);
|
|
77
77
|
});
|
|
78
|
+
|
|
79
|
+
it("should preserve alpha channel", async () => {
|
|
80
|
+
const result = await executeWithSchema(
|
|
81
|
+
"scale_chroma",
|
|
82
|
+
"function",
|
|
83
|
+
`
|
|
84
|
+
variable color: Color.OKLCH = oklch(0.5, 0.15, 30, 0.7);
|
|
85
|
+
scale_chroma(color, 1.5)
|
|
86
|
+
`,
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
expect(result?.constructor.name).toBe("ColorSymbol");
|
|
90
|
+
expect((result as any).alpha).toBe(0.7);
|
|
91
|
+
});
|
|
78
92
|
});
|
|
79
93
|
});
|
|
@@ -69,5 +69,19 @@ describe("scale_lightness function", () => {
|
|
|
69
69
|
const r = (result as any).value?.r?.value ?? (result as any).value?.r;
|
|
70
70
|
expect(r).toBeCloseTo(0, 1);
|
|
71
71
|
});
|
|
72
|
+
|
|
73
|
+
it("should preserve alpha channel", async () => {
|
|
74
|
+
const result = await executeWithSchema(
|
|
75
|
+
"scale_lightness",
|
|
76
|
+
"function",
|
|
77
|
+
`
|
|
78
|
+
variable color: Color.OKLCH = oklch(0.5, 0.15, 30, 0.7);
|
|
79
|
+
scale_lightness(color, 1.2)
|
|
80
|
+
`,
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
expect(result?.constructor.name).toBe("ColorSymbol");
|
|
84
|
+
expect((result as any).alpha).toBe(0.7);
|
|
85
|
+
});
|
|
72
86
|
});
|
|
73
87
|
});
|
|
@@ -75,5 +75,19 @@ describe("Set Chroma Function", () => {
|
|
|
75
75
|
const b = (result as any).value.b.value;
|
|
76
76
|
expect((r + g + b) / 3).toBeGreaterThan(0.5);
|
|
77
77
|
});
|
|
78
|
+
|
|
79
|
+
it("should preserve alpha channel", async () => {
|
|
80
|
+
const result = await executeWithSchema(
|
|
81
|
+
"set_chroma",
|
|
82
|
+
"function",
|
|
83
|
+
`
|
|
84
|
+
variable color: Color.OKLCH = oklch(0.5, 0.15, 30, 0.7);
|
|
85
|
+
set_chroma(color, 0.1)
|
|
86
|
+
`,
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
expect(result?.constructor.name).toBe("ColorSymbol");
|
|
90
|
+
expect((result as any).alpha).toBe(0.7);
|
|
91
|
+
});
|
|
78
92
|
});
|
|
79
93
|
});
|
|
@@ -86,5 +86,19 @@ describe("Set Hue Function", () => {
|
|
|
86
86
|
|
|
87
87
|
expect(result?.constructor.name).toBe("ColorSymbol");
|
|
88
88
|
});
|
|
89
|
+
|
|
90
|
+
it("should preserve alpha channel", async () => {
|
|
91
|
+
const result = await executeWithSchema(
|
|
92
|
+
"set_hue",
|
|
93
|
+
"function",
|
|
94
|
+
`
|
|
95
|
+
variable color: Color.OKLCH = oklch(0.5, 0.15, 30, 0.7);
|
|
96
|
+
set_hue(color, 180)
|
|
97
|
+
`,
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
expect(result?.constructor.name).toBe("ColorSymbol");
|
|
101
|
+
expect((result as any).alpha).toBe(0.7);
|
|
102
|
+
});
|
|
89
103
|
});
|
|
90
104
|
});
|
|
@@ -76,5 +76,19 @@ describe("Set Lightness Function", () => {
|
|
|
76
76
|
expect(r).toBeGreaterThan(g);
|
|
77
77
|
expect(r).toBeGreaterThan(b);
|
|
78
78
|
});
|
|
79
|
+
|
|
80
|
+
it("should preserve alpha channel", async () => {
|
|
81
|
+
const result = await executeWithSchema(
|
|
82
|
+
"set_lightness",
|
|
83
|
+
"function",
|
|
84
|
+
`
|
|
85
|
+
variable color: Color.OKLCH = oklch(0.5, 0.15, 30, 0.7);
|
|
86
|
+
set_lightness(color, 0.8)
|
|
87
|
+
`,
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
expect(result?.constructor.name).toBe("ColorSymbol");
|
|
91
|
+
expect((result as any).alpha).toBe(0.7);
|
|
92
|
+
});
|
|
79
93
|
});
|
|
80
94
|
});
|