@seyuna/postcss 1.0.0-canary.15 → 1.0.0-canary.16

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.
@@ -1,46 +0,0 @@
1
- import { AtRule, ChildNode } from "postcss";
2
- import { PluginContext } from "../config";
3
- import { reportError } from "../errors";
4
-
5
- /**
6
- * Handler for @define-mixin [name] { ... }
7
- */
8
- export function defineMixin(atRule: AtRule, context: PluginContext) {
9
- const name = atRule.params.trim();
10
- if (!name) {
11
- reportError("Mixin name is required", atRule, context);
12
- return;
13
- }
14
-
15
- // Store the nodes (cloned)
16
- context.mixins[name] = atRule.nodes?.map(n => n.clone()) || [];
17
-
18
- // Remove the at-rule from the output
19
- atRule.remove();
20
- }
21
-
22
- /**
23
- * Handler for @apply [name]
24
- */
25
- export function applyMixin(atRule: AtRule, context: PluginContext) {
26
- const name = atRule.params.trim();
27
- if (!name) {
28
- reportError("Mixin name is required for @apply", atRule, context);
29
- return;
30
- }
31
-
32
- const mixinNodes = context.mixins[name];
33
- if (!mixinNodes) {
34
- reportError(`Mixin "${name}" not found`, atRule, context);
35
- return;
36
- }
37
-
38
- // Inject the nodes, ensuring they have the correct source for mapping
39
- const nodesToInject = mixinNodes.map(n => {
40
- const cloned = n.clone();
41
- cloned.source = atRule.source;
42
- return cloned;
43
- });
44
-
45
- atRule.replaceWith(...nodesToInject);
46
- }