@seyuna/postcss 1.0.0-canary.11 → 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 CHANGED
@@ -1,3 +1,10 @@
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
+
1
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)
2
9
 
3
10
 
@@ -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
  *
@@ -39,7 +40,26 @@ function eachStandardColor(atRule) {
39
40
  const cloned = node.clone();
40
41
  if (cloned.type === "decl") {
41
42
  const decl = cloned;
42
- decl.value = decl.value.replace(/\{name\}/g, name);
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;
43
63
  }
44
64
  else if (cloned.type === "rule") {
45
65
  const rule = cloned;
@@ -47,7 +67,6 @@ function eachStandardColor(atRule) {
47
67
  rule.nodes = cloneNodesWithName(name, rule.nodes || []);
48
68
  }
49
69
  else if (cloned.type === "atrule") {
50
- // If you want {name} in selectors inside at-rules too
51
70
  cloned.params = cloned.params.replace(/\{name\}/g, name);
52
71
  cloned.nodes = cloneNodesWithName(name, cloned.nodes || []);
53
72
  }
@@ -98,7 +117,26 @@ function eachFixedColor(atRule) {
98
117
  const cloned = node.clone();
99
118
  if (cloned.type === "decl") {
100
119
  const decl = cloned;
101
- decl.value = decl.value.replace(/\{name\}/g, name);
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;
102
140
  }
103
141
  else if (cloned.type === "rule") {
104
142
  const rule = cloned;
@@ -106,7 +144,6 @@ function eachFixedColor(atRule) {
106
144
  rule.nodes = cloneNodesWithName(name, rule.nodes || []);
107
145
  }
108
146
  else if (cloned.type === "atrule") {
109
- // If you want {name} in selectors inside at-rules too
110
147
  cloned.params = cloned.params.replace(/\{name\}/g, name);
111
148
  cloned.nodes = cloneNodesWithName(name, cloned.nodes || []);
112
149
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seyuna/postcss",
3
- "version": "1.0.0-canary.11",
3
+ "version": "1.0.0-canary.12",
4
4
  "description": "Seyuna UI's postcss plugin",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -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.
@@ -42,13 +43,35 @@ export function eachStandardColor(atRule: AtRule) {
42
43
 
43
44
  if (cloned.type === "decl") {
44
45
  const decl = cloned as Declaration;
45
- decl.value = decl.value.replace(/\{name\}/g, name);
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;
46
70
  } else if (cloned.type === "rule") {
47
71
  const rule = cloned as Rule;
48
72
  rule.selector = rule.selector.replace(/\{name\}/g, name);
49
73
  rule.nodes = cloneNodesWithName(name, rule.nodes || []);
50
74
  } else if (cloned.type === "atrule") {
51
- // If you want {name} in selectors inside at-rules too
52
75
  cloned.params = cloned.params.replace(/\{name\}/g, name);
53
76
  cloned.nodes = cloneNodesWithName(name, cloned.nodes || []);
54
77
  }
@@ -112,13 +135,35 @@ export function eachFixedColor(atRule: AtRule) {
112
135
 
113
136
  if (cloned.type === "decl") {
114
137
  const decl = cloned as Declaration;
115
- decl.value = decl.value.replace(/\{name\}/g, name);
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;
116
162
  } else if (cloned.type === "rule") {
117
163
  const rule = cloned as Rule;
118
164
  rule.selector = rule.selector.replace(/\{name\}/g, name);
119
165
  rule.nodes = cloneNodesWithName(name, rule.nodes || []);
120
166
  } else if (cloned.type === "atrule") {
121
- // If you want {name} in selectors inside at-rules too
122
167
  cloned.params = cloned.params.replace(/\{name\}/g, name);
123
168
  cloned.nodes = cloneNodesWithName(name, cloned.nodes || []);
124
169
  }