@unocss/transformer-directives 0.62.1 → 0.62.3

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.
Files changed (2) hide show
  1. package/dist/index.mjs +8 -6
  2. package/package.json +3 -3
package/dist/index.mjs CHANGED
@@ -98,7 +98,7 @@ async function parseApply({ code, uno, applyVariable }, node, childNode) {
98
98
  }, []);
99
99
  if (!utils.length)
100
100
  return;
101
- const simicolonOffset = original[childNode.loc.end.offset] === ";" ? 1 : 0;
101
+ let simicolonOffset = original[childNode.loc.end.offset] === ";" ? 1 : original[childNode.loc.end.offset] === "@" ? -1 : 0;
102
102
  for (const i of utils) {
103
103
  const [, _selector, body2, parent] = i;
104
104
  const selectorOrGroup = _selector?.replace(regexScopePlaceholder, " ") || _selector;
@@ -124,10 +124,11 @@ async function parseApply({ code, uno, applyVariable }, node, childNode) {
124
124
  let css = `${newSelector.replace(/.\\-/g, className)}{${body2}}`;
125
125
  if (parent)
126
126
  css = `${parent}{${css}}`;
127
+ simicolonOffset = 0;
127
128
  code.appendLeft(node.loc.end.offset, css);
128
129
  } else {
129
130
  if (body2.includes("@"))
130
- code.appendRight(original.length + simicolonOffset, body2);
131
+ code.appendRight(original.length, body2);
131
132
  else
132
133
  code.appendRight(childNode.loc.end.offset + simicolonOffset, body2);
133
134
  }
@@ -167,12 +168,13 @@ async function transformDirectives(code, uno, options, filename, originalCode, o
167
168
  applyVariable = ["--at-apply", "--uno-apply", "--uno"];
168
169
  }
169
170
  applyVariable = toArray(applyVariable || []);
170
- const hasApply = code.original.includes("@apply") || applyVariable.some((s) => code.original.includes(s));
171
- const hasScreen = code.original.includes("@screen");
172
- const hasThemeFn$1 = hasThemeFn(code.original);
171
+ const parseCode = originalCode || code.original;
172
+ const hasApply = parseCode.includes("@apply") || applyVariable.some((s) => parseCode.includes(s));
173
+ const hasScreen = parseCode.includes("@screen");
174
+ const hasThemeFn$1 = hasThemeFn(parseCode);
173
175
  if (!hasApply && !hasThemeFn$1 && !hasScreen)
174
176
  return;
175
- const ast = parse(originalCode || code.original, {
177
+ const ast = parse(parseCode, {
176
178
  parseCustomProperty: true,
177
179
  parseAtrulePrelude: false,
178
180
  positions: true,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@unocss/transformer-directives",
3
3
  "type": "module",
4
- "version": "0.62.1",
4
+ "version": "0.62.3",
5
5
  "description": "UnoCSS transformer for `@apply` directive",
6
6
  "author": "hannoeru <me@hanlee.co>",
7
7
  "license": "MIT",
@@ -33,8 +33,8 @@
33
33
  ],
34
34
  "dependencies": {
35
35
  "css-tree": "^2.3.1",
36
- "@unocss/core": "0.62.1",
37
- "@unocss/rule-utils": "0.62.1"
36
+ "@unocss/core": "0.62.3",
37
+ "@unocss/rule-utils": "0.62.3"
38
38
  },
39
39
  "devDependencies": {
40
40
  "magic-string": "^0.30.11"