@pandacss/postcss 2.1.1 → 2.2.0

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/dist/index.cjs CHANGED
@@ -23,8 +23,8 @@ var pandacss = (options = {}) => {
23
23
  const result = helpers.result;
24
24
  const fileName = result.opts.from;
25
25
  if (shouldSkip(fileName, options.allow)) return;
26
- const inputCss = getInputCss(root, result);
27
- if (!inputCss.includes("@layer")) return;
26
+ const layerStatements = getLayerStatements(root);
27
+ if (layerStatements.length === 0) return;
28
28
  const cwd = _nodepath.resolve.call(void 0, _nullishCoalesce(options.cwd, () => ( process.cwd())));
29
29
  const key = getDriverKey(cwd, options.configPath);
30
30
  let state = driverStates.get(key);
@@ -44,15 +44,16 @@ var pandacss = (options = {}) => {
44
44
  }
45
45
  const { driver } = state;
46
46
  const polyfill = driver.config.polyfill === true;
47
- if (!driver.compiler.hasLayerDeclaration(inputCss)) return;
47
+ const pandaLayerStatements = layerStatements.filter(
48
+ (node) => driver.compiler.hasLayerDeclaration(`@layer ${node.params};`)
49
+ );
50
+ if (pandaLayerStatements.length === 0) return;
48
51
  ensureCodegen(state, { cwd, outdir: options.outdir });
49
52
  syncProjectSources(state);
50
53
  registerDependencies(driver, result, cwd, fileName);
51
54
  emitDiagnostics(root, result, _nullishCoalesce(driver.designSystemDiagnostics, () => ( [])));
52
55
  if (polyfill) {
53
- const stripped = driver.compiler.stripLayerOrderStatements(inputCss);
54
- root.removeAll();
55
- root.append(helpers.postcss.parse(stripped, { from: fileName }));
56
+ for (const node of pandaLayerStatements) node.remove();
56
57
  }
57
58
  const output = driver.cssgen({ emitLayerDeclaration: false, polyfill });
58
59
  emitDiagnostics(root, result, output.diagnostics);
@@ -88,9 +89,12 @@ var shouldSkip = (fileName, allow) => {
88
89
  function getDriverKey(cwd, configPath) {
89
90
  return `${cwd}:${_nullishCoalesce(configPath, () => ( ""))}`;
90
91
  }
91
- function getInputCss(root, result) {
92
- const opts = result.opts;
93
- return _nullishCoalesce(opts.css, () => ( root.toString()));
92
+ function getLayerStatements(root) {
93
+ const statements = [];
94
+ root.walkAtRules("layer", (node) => {
95
+ if (!node.nodes) statements.push(node);
96
+ });
97
+ return statements;
94
98
  }
95
99
  function ensureCodegen(state, options) {
96
100
  const outdirKey = state.driver.getOutdir(options.outdir);
package/dist/index.js CHANGED
@@ -23,8 +23,8 @@ var pandacss = (options = {}) => {
23
23
  const result = helpers.result;
24
24
  const fileName = result.opts.from;
25
25
  if (shouldSkip(fileName, options.allow)) return;
26
- const inputCss = getInputCss(root, result);
27
- if (!inputCss.includes("@layer")) return;
26
+ const layerStatements = getLayerStatements(root);
27
+ if (layerStatements.length === 0) return;
28
28
  const cwd = resolve(options.cwd ?? process.cwd());
29
29
  const key = getDriverKey(cwd, options.configPath);
30
30
  let state = driverStates.get(key);
@@ -44,15 +44,16 @@ var pandacss = (options = {}) => {
44
44
  }
45
45
  const { driver } = state;
46
46
  const polyfill = driver.config.polyfill === true;
47
- if (!driver.compiler.hasLayerDeclaration(inputCss)) return;
47
+ const pandaLayerStatements = layerStatements.filter(
48
+ (node) => driver.compiler.hasLayerDeclaration(`@layer ${node.params};`)
49
+ );
50
+ if (pandaLayerStatements.length === 0) return;
48
51
  ensureCodegen(state, { cwd, outdir: options.outdir });
49
52
  syncProjectSources(state);
50
53
  registerDependencies(driver, result, cwd, fileName);
51
54
  emitDiagnostics(root, result, driver.designSystemDiagnostics ?? []);
52
55
  if (polyfill) {
53
- const stripped = driver.compiler.stripLayerOrderStatements(inputCss);
54
- root.removeAll();
55
- root.append(helpers.postcss.parse(stripped, { from: fileName }));
56
+ for (const node of pandaLayerStatements) node.remove();
56
57
  }
57
58
  const output = driver.cssgen({ emitLayerDeclaration: false, polyfill });
58
59
  emitDiagnostics(root, result, output.diagnostics);
@@ -88,9 +89,12 @@ var shouldSkip = (fileName, allow) => {
88
89
  function getDriverKey(cwd, configPath) {
89
90
  return `${cwd}:${configPath ?? ""}`;
90
91
  }
91
- function getInputCss(root, result) {
92
- const opts = result.opts;
93
- return opts.css ?? root.toString();
92
+ function getLayerStatements(root) {
93
+ const statements = [];
94
+ root.walkAtRules("layer", (node) => {
95
+ if (!node.nodes) statements.push(node);
96
+ });
97
+ return statements;
94
98
  }
95
99
  function ensureCodegen(state, options) {
96
100
  const outdirKey = state.driver.getOutdir(options.outdir);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pandacss/postcss",
3
- "version": "2.1.1",
3
+ "version": "2.2.0",
4
4
  "description": "PostCSS plugin for Panda CSS",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -30,14 +30,15 @@
30
30
  "dist"
31
31
  ],
32
32
  "dependencies": {
33
- "@pandacss/compiler": "2.1.1",
34
- "@pandacss/compiler-shared": "2.1.1"
33
+ "@pandacss/compiler": "2.2.0",
34
+ "@pandacss/compiler-shared": "2.2.0"
35
35
  },
36
36
  "peerDependencies": {
37
37
  "postcss": ">=8"
38
38
  },
39
39
  "devDependencies": {
40
- "postcss": "8.5.28"
40
+ "postcss": "8.5.28",
41
+ "vite": "7.3.6"
41
42
  },
42
43
  "engines": {
43
44
  "node": ">=22"