@unocss/transformer-directives 0.60.1 → 0.60.2

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 +5 -4
  2. package/package.json +3 -3
package/dist/index.mjs CHANGED
@@ -71,14 +71,15 @@ async function handleApply(ctx, node) {
71
71
  }
72
72
  async function parseApply({ code, uno, offset, applyVariable }, node, childNode) {
73
73
  const calcOffset = (pos) => offset ? pos + offset : pos;
74
+ const original = code.original;
74
75
  let body;
75
76
  if (childNode.type === "Atrule" && childNode.name === "apply" && childNode.prelude && childNode.prelude.type === "Raw") {
76
77
  body = removeQuotes(childNode.prelude.value.trim());
77
78
  } else if (childNode.type === "Declaration" && applyVariable.includes(childNode.property) && childNode.value.type === "Value") {
78
- let rawValue = code.original.slice(
79
+ let rawValue = original.slice(
79
80
  calcOffset(childNode.value.loc.start.offset),
80
81
  calcOffset(childNode.value.loc.end.offset)
81
- );
82
+ ).trim();
82
83
  rawValue = removeQuotes(rawValue);
83
84
  const items = rawValue.split(/\s+/g).filter(Boolean).map((i) => removeQuotes(i));
84
85
  body = items.join(" ");
@@ -98,7 +99,7 @@ async function parseApply({ code, uno, offset, applyVariable }, node, childNode)
98
99
  }, []);
99
100
  if (!utils.length)
100
101
  return;
101
- const simicolonOffset = code.toString()[childNode.loc.end.offset] === ";" ? 1 : 0;
102
+ const simicolonOffset = original[calcOffset(childNode.loc.end.offset)] === ";" ? 1 : 0;
102
103
  for (const i of utils) {
103
104
  const [, _selector, body2, parent] = i;
104
105
  const selectorOrGroup = _selector?.replace(regexScopePlaceholder, " ") || _selector;
@@ -126,7 +127,7 @@ async function parseApply({ code, uno, offset, applyVariable }, node, childNode)
126
127
  code.appendLeft(calcOffset(node.loc.end.offset), css);
127
128
  } else {
128
129
  if (body2.includes("@"))
129
- code.appendRight(code.original.length + simicolonOffset, body2);
130
+ code.appendRight(original.length + simicolonOffset, body2);
130
131
  else
131
132
  code.appendRight(calcOffset(childNode.loc.end.offset + simicolonOffset), body2);
132
133
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@unocss/transformer-directives",
3
3
  "type": "module",
4
- "version": "0.60.1",
4
+ "version": "0.60.2",
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.60.1",
37
- "@unocss/rule-utils": "0.60.1"
36
+ "@unocss/rule-utils": "0.60.2",
37
+ "@unocss/core": "0.60.2"
38
38
  },
39
39
  "devDependencies": {
40
40
  "magic-string": "^0.30.10"