@unocss/transformer-directives 0.57.7 → 0.58.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
@@ -87,7 +87,7 @@ async function parseApply({ code, uno, offset, applyVariable }, node, childNode)
87
87
  body = childNode.prelude.value.trim();
88
88
  } else if (childNode.type === "Declaration" && applyVariable.includes(childNode.property) && childNode.value.type === "Raw") {
89
89
  body = childNode.value.value.trim();
90
- if (body.match(/^(['"]).*\1$/))
90
+ if (/^(['"]).*\1$/.test(body))
91
91
  body = body.slice(1, -1);
92
92
  }
93
93
  if (!body)
@@ -130,7 +130,10 @@ async function parseApply({ code, uno, offset, applyVariable }, node, childNode)
130
130
  css = `${parent}{${css}}`;
131
131
  code.appendLeft(calcOffset(node.loc.end.offset), css);
132
132
  } else {
133
- code.appendRight(calcOffset(childNode.loc.end.offset), body2);
133
+ if (body2.includes("@"))
134
+ code.appendRight(code.original.length, body2);
135
+ else
136
+ code.appendRight(calcOffset(childNode.loc.end.offset), body2);
134
137
  }
135
138
  }
136
139
  code.remove(
@@ -143,7 +146,7 @@ function transformerDirectives(options = {}) {
143
146
  return {
144
147
  name: "@unocss/transformer-directives",
145
148
  enforce: options?.enforce,
146
- idFilter: (id) => !!id.match(core.cssIdRE),
149
+ idFilter: (id) => core.cssIdRE.test(id),
147
150
  transform: (code, id, ctx) => {
148
151
  return transformDirectives(code, ctx.uno, options, id);
149
152
  }
package/dist/index.mjs CHANGED
@@ -83,7 +83,7 @@ async function parseApply({ code, uno, offset, applyVariable }, node, childNode)
83
83
  body = childNode.prelude.value.trim();
84
84
  } else if (childNode.type === "Declaration" && applyVariable.includes(childNode.property) && childNode.value.type === "Raw") {
85
85
  body = childNode.value.value.trim();
86
- if (body.match(/^(['"]).*\1$/))
86
+ if (/^(['"]).*\1$/.test(body))
87
87
  body = body.slice(1, -1);
88
88
  }
89
89
  if (!body)
@@ -126,7 +126,10 @@ async function parseApply({ code, uno, offset, applyVariable }, node, childNode)
126
126
  css = `${parent}{${css}}`;
127
127
  code.appendLeft(calcOffset(node.loc.end.offset), css);
128
128
  } else {
129
- code.appendRight(calcOffset(childNode.loc.end.offset), body2);
129
+ if (body2.includes("@"))
130
+ code.appendRight(code.original.length, body2);
131
+ else
132
+ code.appendRight(calcOffset(childNode.loc.end.offset), body2);
130
133
  }
131
134
  }
132
135
  code.remove(
@@ -139,7 +142,7 @@ function transformerDirectives(options = {}) {
139
142
  return {
140
143
  name: "@unocss/transformer-directives",
141
144
  enforce: options?.enforce,
142
- idFilter: (id) => !!id.match(cssIdRE),
145
+ idFilter: (id) => cssIdRE.test(id),
143
146
  transform: (code, id, ctx) => {
144
147
  return transformDirectives(code, ctx.uno, options, id);
145
148
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unocss/transformer-directives",
3
- "version": "0.57.7",
3
+ "version": "0.58.0",
4
4
  "description": "UnoCSS transformer for `@apply` directive",
5
5
  "author": "hannoeru <me@hanlee.co>",
6
6
  "license": "MIT",
@@ -33,8 +33,8 @@
33
33
  ],
34
34
  "dependencies": {
35
35
  "css-tree": "^2.3.1",
36
- "@unocss/core": "0.57.7",
37
- "@unocss/rule-utils": "0.57.7"
36
+ "@unocss/core": "0.58.0",
37
+ "@unocss/rule-utils": "0.58.0"
38
38
  },
39
39
  "devDependencies": {
40
40
  "magic-string": "^0.30.5"