@seyuna/postcss 1.0.0-canary.10 → 1.0.0-canary.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.
- package/CHANGELOG.md +14 -0
- package/dist/at-rules/color.js +61 -6
- package/package.json +1 -1
- package/src/at-rules/color.ts +73 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# [1.0.0-canary.12](https://github.com/seyuna-corp/seyuna-postcss/compare/v1.0.0-canary.11...v1.0.0-canary.12) (2025-09-15)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* color functions not running when used inside at-each rules ([995fd98](https://github.com/seyuna-corp/seyuna-postcss/commit/995fd9816f2c2d51caa67add4d3172cee41d0c65))
|
|
7
|
+
|
|
8
|
+
# [1.0.0-canary.11](https://github.com/seyuna-corp/seyuna-postcss/compare/v1.0.0-canary.10...v1.0.0-canary.11) (2025-09-15)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* nested rules for at-each-standard-color & at-each-fixed-color ([197a755](https://github.com/seyuna-corp/seyuna-postcss/commit/197a75542798ecacaa071802b2abbf962bcd6538))
|
|
14
|
+
|
|
1
15
|
# [1.0.0-canary.10](https://github.com/seyuna-corp/seyuna-postcss/compare/v1.0.0-canary.9...v1.0.0-canary.10) (2025-09-10)
|
|
2
16
|
|
|
3
17
|
|
package/dist/at-rules/color.js
CHANGED
|
@@ -8,6 +8,7 @@ exports.eachFixedColor = eachFixedColor;
|
|
|
8
8
|
const postcss_1 = require("postcss");
|
|
9
9
|
const fs_1 = __importDefault(require("fs"));
|
|
10
10
|
const path_1 = __importDefault(require("path"));
|
|
11
|
+
const color_1 = require("../functions/color");
|
|
11
12
|
/**
|
|
12
13
|
* Custom PostCSS plugin handler for `@each-standard-color` at-rules.
|
|
13
14
|
*
|
|
@@ -35,12 +36,39 @@ function eachStandardColor(atRule) {
|
|
|
35
36
|
const nodes = atRule.nodes ?? [];
|
|
36
37
|
const generatedRules = [];
|
|
37
38
|
// Helper to clone nodes and replace {name} placeholder
|
|
38
|
-
const cloneNodesWithName = (name) =>
|
|
39
|
+
const cloneNodesWithName = (name, nodeList = nodes) => nodeList.map((node) => {
|
|
39
40
|
const cloned = node.clone();
|
|
40
|
-
// Only process declarations
|
|
41
41
|
if (cloned.type === "decl") {
|
|
42
42
|
const decl = cloned;
|
|
43
|
-
|
|
43
|
+
// First replace {name} placeholders
|
|
44
|
+
let value = decl.value.replace(/\{name\}/g, name);
|
|
45
|
+
// Detect sc(...) or fc(...) calls and evaluate them
|
|
46
|
+
if (/sc\(/.test(value)) {
|
|
47
|
+
const args = value
|
|
48
|
+
.match(/sc\(([^)]*)\)/)?.[1]
|
|
49
|
+
.split(",")
|
|
50
|
+
.map((s) => s.trim().replace(/\{name\}/g, name));
|
|
51
|
+
if (args)
|
|
52
|
+
value = (0, color_1.sc)(...args);
|
|
53
|
+
}
|
|
54
|
+
if (/fc\(/.test(value)) {
|
|
55
|
+
const args = value
|
|
56
|
+
.match(/fc\(([^)]*)\)/)?.[1]
|
|
57
|
+
.split(",")
|
|
58
|
+
.map((s) => s.trim().replace(/\{name\}/g, name));
|
|
59
|
+
if (args)
|
|
60
|
+
value = (0, color_1.fc)(...args);
|
|
61
|
+
}
|
|
62
|
+
decl.value = value;
|
|
63
|
+
}
|
|
64
|
+
else if (cloned.type === "rule") {
|
|
65
|
+
const rule = cloned;
|
|
66
|
+
rule.selector = rule.selector.replace(/\{name\}/g, name);
|
|
67
|
+
rule.nodes = cloneNodesWithName(name, rule.nodes || []);
|
|
68
|
+
}
|
|
69
|
+
else if (cloned.type === "atrule") {
|
|
70
|
+
cloned.params = cloned.params.replace(/\{name\}/g, name);
|
|
71
|
+
cloned.nodes = cloneNodesWithName(name, cloned.nodes || []);
|
|
44
72
|
}
|
|
45
73
|
return cloned;
|
|
46
74
|
});
|
|
@@ -85,12 +113,39 @@ function eachFixedColor(atRule) {
|
|
|
85
113
|
const nodes = atRule.nodes ?? [];
|
|
86
114
|
const generatedRules = [];
|
|
87
115
|
// Helper to clone nodes and replace {name} placeholder
|
|
88
|
-
const cloneNodesWithName = (name) =>
|
|
116
|
+
const cloneNodesWithName = (name, nodeList = nodes) => nodeList.map((node) => {
|
|
89
117
|
const cloned = node.clone();
|
|
90
|
-
// Only process declarations
|
|
91
118
|
if (cloned.type === "decl") {
|
|
92
119
|
const decl = cloned;
|
|
93
|
-
|
|
120
|
+
// First replace {name} placeholders
|
|
121
|
+
let value = decl.value.replace(/\{name\}/g, name);
|
|
122
|
+
// Detect sc(...) or fc(...) calls and evaluate them
|
|
123
|
+
if (/sc\(/.test(value)) {
|
|
124
|
+
const args = value
|
|
125
|
+
.match(/sc\(([^)]*)\)/)?.[1]
|
|
126
|
+
.split(",")
|
|
127
|
+
.map((s) => s.trim().replace(/\{name\}/g, name));
|
|
128
|
+
if (args)
|
|
129
|
+
value = (0, color_1.sc)(...args);
|
|
130
|
+
}
|
|
131
|
+
if (/fc\(/.test(value)) {
|
|
132
|
+
const args = value
|
|
133
|
+
.match(/fc\(([^)]*)\)/)?.[1]
|
|
134
|
+
.split(",")
|
|
135
|
+
.map((s) => s.trim().replace(/\{name\}/g, name));
|
|
136
|
+
if (args)
|
|
137
|
+
value = (0, color_1.fc)(...args);
|
|
138
|
+
}
|
|
139
|
+
decl.value = value;
|
|
140
|
+
}
|
|
141
|
+
else if (cloned.type === "rule") {
|
|
142
|
+
const rule = cloned;
|
|
143
|
+
rule.selector = rule.selector.replace(/\{name\}/g, name);
|
|
144
|
+
rule.nodes = cloneNodesWithName(name, rule.nodes || []);
|
|
145
|
+
}
|
|
146
|
+
else if (cloned.type === "atrule") {
|
|
147
|
+
cloned.params = cloned.params.replace(/\{name\}/g, name);
|
|
148
|
+
cloned.nodes = cloneNodesWithName(name, cloned.nodes || []);
|
|
94
149
|
}
|
|
95
150
|
return cloned;
|
|
96
151
|
});
|
package/package.json
CHANGED
package/src/at-rules/color.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { AtRule, Rule, ChildNode, Declaration } from "postcss";
|
|
|
2
2
|
import fs from "fs";
|
|
3
3
|
import path from "path";
|
|
4
4
|
import { SeyunaConfig } from "../types";
|
|
5
|
+
import { fc, sc } from "../functions/color";
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Custom PostCSS plugin handler for `@each-standard-color` at-rules.
|
|
@@ -33,14 +34,46 @@ export function eachStandardColor(atRule: AtRule) {
|
|
|
33
34
|
const generatedRules: Rule[] = [];
|
|
34
35
|
|
|
35
36
|
// Helper to clone nodes and replace {name} placeholder
|
|
36
|
-
const cloneNodesWithName = (
|
|
37
|
-
|
|
37
|
+
const cloneNodesWithName = (
|
|
38
|
+
name: string,
|
|
39
|
+
nodeList: ChildNode[] = nodes
|
|
40
|
+
): ChildNode[] =>
|
|
41
|
+
nodeList.map((node) => {
|
|
38
42
|
const cloned = node.clone();
|
|
39
43
|
|
|
40
|
-
// Only process declarations
|
|
41
44
|
if (cloned.type === "decl") {
|
|
42
45
|
const decl = cloned as Declaration;
|
|
43
|
-
|
|
46
|
+
|
|
47
|
+
// First replace {name} placeholders
|
|
48
|
+
let value = decl.value.replace(/\{name\}/g, name);
|
|
49
|
+
|
|
50
|
+
// Detect sc(...) or fc(...) calls and evaluate them
|
|
51
|
+
if (/sc\(/.test(value)) {
|
|
52
|
+
const args = value
|
|
53
|
+
.match(/sc\(([^)]*)\)/)?.[1]
|
|
54
|
+
.split(",")
|
|
55
|
+
.map((s: string) => s.trim().replace(/\{name\}/g, name));
|
|
56
|
+
if (args)
|
|
57
|
+
value = sc(...(args as [string, string?, string?, string?]));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (/fc\(/.test(value)) {
|
|
61
|
+
const args = value
|
|
62
|
+
.match(/fc\(([^)]*)\)/)?.[1]
|
|
63
|
+
.split(",")
|
|
64
|
+
.map((s: string) => s.trim().replace(/\{name\}/g, name));
|
|
65
|
+
if (args)
|
|
66
|
+
value = fc(...(args as [string, string?, string?, string?]));
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
decl.value = value;
|
|
70
|
+
} else if (cloned.type === "rule") {
|
|
71
|
+
const rule = cloned as Rule;
|
|
72
|
+
rule.selector = rule.selector.replace(/\{name\}/g, name);
|
|
73
|
+
rule.nodes = cloneNodesWithName(name, rule.nodes || []);
|
|
74
|
+
} else if (cloned.type === "atrule") {
|
|
75
|
+
cloned.params = cloned.params.replace(/\{name\}/g, name);
|
|
76
|
+
cloned.nodes = cloneNodesWithName(name, cloned.nodes || []);
|
|
44
77
|
}
|
|
45
78
|
|
|
46
79
|
return cloned;
|
|
@@ -93,14 +126,46 @@ export function eachFixedColor(atRule: AtRule) {
|
|
|
93
126
|
const generatedRules: Rule[] = [];
|
|
94
127
|
|
|
95
128
|
// Helper to clone nodes and replace {name} placeholder
|
|
96
|
-
const cloneNodesWithName = (
|
|
97
|
-
|
|
129
|
+
const cloneNodesWithName = (
|
|
130
|
+
name: string,
|
|
131
|
+
nodeList: ChildNode[] = nodes
|
|
132
|
+
): ChildNode[] =>
|
|
133
|
+
nodeList.map((node) => {
|
|
98
134
|
const cloned = node.clone();
|
|
99
135
|
|
|
100
|
-
// Only process declarations
|
|
101
136
|
if (cloned.type === "decl") {
|
|
102
137
|
const decl = cloned as Declaration;
|
|
103
|
-
|
|
138
|
+
|
|
139
|
+
// First replace {name} placeholders
|
|
140
|
+
let value = decl.value.replace(/\{name\}/g, name);
|
|
141
|
+
|
|
142
|
+
// Detect sc(...) or fc(...) calls and evaluate them
|
|
143
|
+
if (/sc\(/.test(value)) {
|
|
144
|
+
const args = value
|
|
145
|
+
.match(/sc\(([^)]*)\)/)?.[1]
|
|
146
|
+
.split(",")
|
|
147
|
+
.map((s: string) => s.trim().replace(/\{name\}/g, name));
|
|
148
|
+
if (args)
|
|
149
|
+
value = sc(...(args as [string, string?, string?, string?]));
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (/fc\(/.test(value)) {
|
|
153
|
+
const args = value
|
|
154
|
+
.match(/fc\(([^)]*)\)/)?.[1]
|
|
155
|
+
.split(",")
|
|
156
|
+
.map((s: string) => s.trim().replace(/\{name\}/g, name));
|
|
157
|
+
if (args)
|
|
158
|
+
value = fc(...(args as [string, string?, string?, string?]));
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
decl.value = value;
|
|
162
|
+
} else if (cloned.type === "rule") {
|
|
163
|
+
const rule = cloned as Rule;
|
|
164
|
+
rule.selector = rule.selector.replace(/\{name\}/g, name);
|
|
165
|
+
rule.nodes = cloneNodesWithName(name, rule.nodes || []);
|
|
166
|
+
} else if (cloned.type === "atrule") {
|
|
167
|
+
cloned.params = cloned.params.replace(/\{name\}/g, name);
|
|
168
|
+
cloned.nodes = cloneNodesWithName(name, cloned.nodes || []);
|
|
104
169
|
}
|
|
105
170
|
|
|
106
171
|
return cloned;
|