@seyuna/postcss 1.0.0-canary.20 → 1.0.0-canary.22
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-scheme.d.ts +1 -1
- package/dist/at-rules/color-scheme.js +4 -4
- package/dist/at-rules/color.d.ts +1 -1
- package/dist/at-rules/container.d.ts +1 -1
- package/dist/at-rules/container.js +2 -2
- package/dist/at-rules/index.d.ts +1 -1
- package/dist/helpers.d.ts +3 -2
- package/dist/helpers.js +2 -2
- package/dist/plugin.d.ts +1 -1
- package/dist/plugin.js +15 -7
- package/package.json +1 -1
- package/src/at-rules/color-scheme.ts +5 -4
- package/src/at-rules/color.ts +1 -1
- package/src/at-rules/container.ts +3 -2
- package/src/at-rules/index.ts +1 -1
- package/src/helpers.ts +7 -6
- package/src/plugin.ts +15 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# [1.0.0-canary.22](https://github.com/seyuna-corp/seyuna-postcss/compare/v1.0.0-canary.21...v1.0.0-canary.22) (2026-01-10)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **esm:** convert to esm and use lazy initialization to resolve deadlock ([4179e78](https://github.com/seyuna-corp/seyuna-postcss/commit/4179e786f3264a475ae89616b6078d80e51ba978))
|
|
7
|
+
|
|
8
|
+
# [1.0.0-canary.21](https://github.com/seyuna-corp/seyuna-postcss/compare/v1.0.0-canary.20...v1.0.0-canary.21) (2026-01-10)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* resolve deadlock by switching to CJS and lazy initialization ([5ae6db2](https://github.com/seyuna-corp/seyuna-postcss/commit/5ae6db23e8fdc630787e2feb4c062af0187bf8c4))
|
|
14
|
+
|
|
1
15
|
# [1.0.0-canary.20](https://github.com/seyuna-corp/seyuna-postcss/compare/v1.0.0-canary.19...v1.0.0-canary.20) (2026-01-10)
|
|
2
16
|
|
|
3
17
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AtRule } from "postcss";
|
|
1
|
+
import type { AtRule } from "postcss";
|
|
2
2
|
import { PluginContext } from "../types.js";
|
|
3
3
|
export declare const light: (atRule: AtRule, context: PluginContext) => void;
|
|
4
4
|
export declare const dark: (atRule: AtRule, context: PluginContext) => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import postcss from "postcss";
|
|
2
2
|
/**
|
|
3
3
|
* Custom PostCSS plugin handler factory for `@light` and `@dark` at-rules.
|
|
4
4
|
*/
|
|
@@ -14,7 +14,7 @@ function createColorSchemeHandler(scheme) {
|
|
|
14
14
|
/**
|
|
15
15
|
* Rule 1: [data-mode="scheme"] & { ... } (Explicit mode)
|
|
16
16
|
*/
|
|
17
|
-
const explicitRule = new Rule({
|
|
17
|
+
const explicitRule = new postcss.Rule({
|
|
18
18
|
selector: `[${modeAttribute}="${scheme}"] &`,
|
|
19
19
|
source: atRule.source,
|
|
20
20
|
});
|
|
@@ -22,12 +22,12 @@ function createColorSchemeHandler(scheme) {
|
|
|
22
22
|
/**
|
|
23
23
|
* Rule 2: @media (prefers-color-scheme: scheme) { [data-mode="system"] & { ... } } (System preference)
|
|
24
24
|
*/
|
|
25
|
-
const mediaAtRule = new AtRule({
|
|
25
|
+
const mediaAtRule = new postcss.AtRule({
|
|
26
26
|
name: "media",
|
|
27
27
|
params: `(prefers-color-scheme: ${scheme})`,
|
|
28
28
|
source: atRule.source,
|
|
29
29
|
});
|
|
30
|
-
const systemRule = new Rule({
|
|
30
|
+
const systemRule = new postcss.Rule({
|
|
31
31
|
selector: `[${modeAttribute}="system"] &`,
|
|
32
32
|
source: atRule.source,
|
|
33
33
|
});
|
package/dist/at-rules/color.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import postcss from "postcss";
|
|
2
2
|
/**
|
|
3
3
|
* Custom PostCSS plugin handler for responsive at-rules.
|
|
4
4
|
*
|
|
@@ -37,7 +37,7 @@ export default function container(atRule, context) {
|
|
|
37
37
|
atRule.each((node) => {
|
|
38
38
|
clonedNodes.push(node.clone());
|
|
39
39
|
});
|
|
40
|
-
const containerAtRule = new AtRule({
|
|
40
|
+
const containerAtRule = new postcss.AtRule({
|
|
41
41
|
name: "container",
|
|
42
42
|
params: `(min-width: ${minWidth})`,
|
|
43
43
|
source: atRule.source,
|
package/dist/at-rules/index.d.ts
CHANGED
package/dist/helpers.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import postcss from "postcss";
|
|
2
|
+
import type { ChildNode, AtRule } from "postcss";
|
|
2
3
|
import { PluginContext } from './types.js';
|
|
3
4
|
/**
|
|
4
5
|
* Helper: clone nodes and replace {name} placeholders safely
|
|
@@ -8,4 +9,4 @@ export declare function cloneNodes(nodes: ChildNode[], name: string, context: Pl
|
|
|
8
9
|
/**
|
|
9
10
|
* Generate CSS rules from a list of names
|
|
10
11
|
*/
|
|
11
|
-
export declare function generateRules(names: string[], atRule: AtRule, context: PluginContext): Rule[];
|
|
12
|
+
export declare function generateRules(names: string[], atRule: AtRule, context: PluginContext): postcss.Rule[];
|
package/dist/helpers.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import postcss from "postcss";
|
|
2
2
|
import { processFunctions } from "./parser.js";
|
|
3
3
|
/**
|
|
4
4
|
* Helper: clone nodes and replace {name} placeholders safely
|
|
@@ -37,7 +37,7 @@ export function generateRules(names, atRule, context) {
|
|
|
37
37
|
const nodes = atRule.nodes ?? [];
|
|
38
38
|
const generatedRules = [];
|
|
39
39
|
for (const name of names) {
|
|
40
|
-
const rule = new Rule({
|
|
40
|
+
const rule = new postcss.Rule({
|
|
41
41
|
selector: `&.${name}`,
|
|
42
42
|
source: atRule.source,
|
|
43
43
|
});
|
package/dist/plugin.d.ts
CHANGED
package/dist/plugin.js
CHANGED
|
@@ -3,20 +3,28 @@ import { atRuleHandlers } from "./at-rules/index.js";
|
|
|
3
3
|
import { loadConfig } from "./config.js";
|
|
4
4
|
import { processFunctions } from "./parser.js";
|
|
5
5
|
export const dynamicFunctionsPlugin = (opts = {}) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const context = {
|
|
9
|
-
config,
|
|
10
|
-
options,
|
|
11
|
-
functions: fnMap,
|
|
12
|
-
};
|
|
6
|
+
let context;
|
|
7
|
+
let fnMap;
|
|
13
8
|
return {
|
|
14
9
|
postcssPlugin: "postcss-dynamic-functions",
|
|
10
|
+
Once() {
|
|
11
|
+
const { config, options } = loadConfig(opts);
|
|
12
|
+
fnMap = { ...functions, ...opts.functions };
|
|
13
|
+
context = {
|
|
14
|
+
config,
|
|
15
|
+
options,
|
|
16
|
+
functions: fnMap,
|
|
17
|
+
};
|
|
18
|
+
},
|
|
15
19
|
Declaration(decl) {
|
|
20
|
+
if (!context || !fnMap)
|
|
21
|
+
return;
|
|
16
22
|
decl.value = processFunctions(decl.value, fnMap, decl, context);
|
|
17
23
|
},
|
|
18
24
|
// Override AtRule handler to ensure ordered execution
|
|
19
25
|
AtRule(atRule) {
|
|
26
|
+
if (!context)
|
|
27
|
+
return;
|
|
20
28
|
// Iterate over handlers in order (array) instead of object spread
|
|
21
29
|
for (const { name, handler } of atRuleHandlers) {
|
|
22
30
|
if (atRule.name === name) {
|
package/package.json
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import postcss from "postcss";
|
|
2
|
+
import type { AtRule, ChildNode } from "postcss";
|
|
2
3
|
import { PluginContext } from "../types.js";
|
|
3
4
|
|
|
4
5
|
/**
|
|
@@ -18,7 +19,7 @@ function createColorSchemeHandler(scheme: 'light' | 'dark') {
|
|
|
18
19
|
/**
|
|
19
20
|
* Rule 1: [data-mode="scheme"] & { ... } (Explicit mode)
|
|
20
21
|
*/
|
|
21
|
-
const explicitRule = new Rule({
|
|
22
|
+
const explicitRule = new postcss.Rule({
|
|
22
23
|
selector: `[${modeAttribute}="${scheme}"] &`,
|
|
23
24
|
source: atRule.source,
|
|
24
25
|
});
|
|
@@ -27,13 +28,13 @@ function createColorSchemeHandler(scheme: 'light' | 'dark') {
|
|
|
27
28
|
/**
|
|
28
29
|
* Rule 2: @media (prefers-color-scheme: scheme) { [data-mode="system"] & { ... } } (System preference)
|
|
29
30
|
*/
|
|
30
|
-
const mediaAtRule = new AtRule({
|
|
31
|
+
const mediaAtRule = new postcss.AtRule({
|
|
31
32
|
name: "media",
|
|
32
33
|
params: `(prefers-color-scheme: ${scheme})`,
|
|
33
34
|
source: atRule.source,
|
|
34
35
|
});
|
|
35
36
|
|
|
36
|
-
const systemRule = new Rule({
|
|
37
|
+
const systemRule = new postcss.Rule({
|
|
37
38
|
selector: `[${modeAttribute}="system"] &`,
|
|
38
39
|
source: atRule.source,
|
|
39
40
|
});
|
package/src/at-rules/color.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import postcss from "postcss";
|
|
2
|
+
import type { AtRule, ChildNode } from "postcss";
|
|
2
3
|
import { PluginContext } from "../types.js";
|
|
3
4
|
|
|
4
5
|
/**
|
|
@@ -44,7 +45,7 @@ export default function container(atRule: AtRule, context: PluginContext) {
|
|
|
44
45
|
clonedNodes.push(node.clone());
|
|
45
46
|
});
|
|
46
47
|
|
|
47
|
-
const containerAtRule = new AtRule({
|
|
48
|
+
const containerAtRule = new postcss.AtRule({
|
|
48
49
|
name: "container",
|
|
49
50
|
params: `(min-width: ${minWidth})`,
|
|
50
51
|
source: atRule.source,
|
package/src/at-rules/index.ts
CHANGED
package/src/helpers.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import postcss from "postcss";
|
|
2
|
+
import type { ChildNode, Declaration, AtRule } from "postcss";
|
|
2
3
|
import { processFunctions } from "./parser.js";
|
|
3
4
|
import { PluginContext } from './types.js';
|
|
4
5
|
|
|
@@ -27,7 +28,7 @@ export function cloneNodes(
|
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
if (cloned.type === "rule") {
|
|
30
|
-
const rule = cloned as Rule;
|
|
31
|
+
const rule = cloned as postcss.Rule;
|
|
31
32
|
if (!rule.selector) return [];
|
|
32
33
|
|
|
33
34
|
rule.selector = rule.selector.replace(/\{name\}/g, name);
|
|
@@ -53,17 +54,17 @@ export function generateRules(
|
|
|
53
54
|
names: string[],
|
|
54
55
|
atRule: AtRule,
|
|
55
56
|
context: PluginContext
|
|
56
|
-
): Rule[] {
|
|
57
|
+
): postcss.Rule[] {
|
|
57
58
|
const nodes = atRule.nodes ?? [];
|
|
58
|
-
const generatedRules: Rule[] = [];
|
|
59
|
+
const generatedRules: postcss.Rule[] = [];
|
|
59
60
|
|
|
60
61
|
for (const name of names) {
|
|
61
|
-
const rule = new Rule({
|
|
62
|
+
const rule = new postcss.Rule({
|
|
62
63
|
selector: `&.${name}`,
|
|
63
64
|
source: atRule.source,
|
|
64
65
|
});
|
|
65
66
|
cloneNodes(nodes, name, context).forEach((n) => {
|
|
66
|
-
if (n.type === "rule" && n.selector && n.nodes?.length) rule.append(n);
|
|
67
|
+
if (n.type === "rule" && n.selector && (n as postcss.Rule).nodes?.length) rule.append(n);
|
|
67
68
|
if (n.type === "decl") rule.append(n);
|
|
68
69
|
});
|
|
69
70
|
|
package/src/plugin.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PluginCreator } from "postcss";
|
|
1
|
+
import type { PluginCreator } from "postcss";
|
|
2
2
|
import { functions } from "./functions/index.js";
|
|
3
3
|
import { atRuleHandlers } from "./at-rules/index.js";
|
|
4
4
|
import { loadConfig } from "./config.js";
|
|
@@ -8,23 +8,30 @@ import { processFunctions } from "./parser.js";
|
|
|
8
8
|
export const dynamicFunctionsPlugin: PluginCreator<PluginOptions> = (
|
|
9
9
|
opts = {}
|
|
10
10
|
) => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const context: PluginContext = {
|
|
14
|
-
config,
|
|
15
|
-
options,
|
|
16
|
-
functions: fnMap,
|
|
17
|
-
};
|
|
11
|
+
let context: PluginContext | undefined;
|
|
12
|
+
let fnMap: FunctionMap | undefined;
|
|
18
13
|
|
|
19
14
|
return {
|
|
20
15
|
postcssPlugin: "postcss-dynamic-functions",
|
|
21
16
|
|
|
17
|
+
Once() {
|
|
18
|
+
const { config, options } = loadConfig(opts);
|
|
19
|
+
fnMap = { ...functions, ...opts.functions };
|
|
20
|
+
context = {
|
|
21
|
+
config,
|
|
22
|
+
options,
|
|
23
|
+
functions: fnMap,
|
|
24
|
+
};
|
|
25
|
+
},
|
|
26
|
+
|
|
22
27
|
Declaration(decl) {
|
|
28
|
+
if (!context || !fnMap) return;
|
|
23
29
|
decl.value = processFunctions(decl.value, fnMap, decl, context);
|
|
24
30
|
},
|
|
25
31
|
|
|
26
32
|
// Override AtRule handler to ensure ordered execution
|
|
27
33
|
AtRule(atRule) {
|
|
34
|
+
if (!context) return;
|
|
28
35
|
// Iterate over handlers in order (array) instead of object spread
|
|
29
36
|
for (const { name, handler } of atRuleHandlers) {
|
|
30
37
|
if (atRule.name === name) {
|