@unocss/transformer-directives 0.60.2 → 0.60.4

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 +6 -2
  2. package/package.json +3 -3
package/dist/index.mjs CHANGED
@@ -52,7 +52,7 @@ function handleScreen({ code, uno }, node) {
52
52
  }
53
53
  }
54
54
  function calcMaxWidthBySize(size) {
55
- const value = size.match(/^-?[0-9]+\.?[0-9]*/)?.[0] || "";
55
+ const value = size.match(/^-?\d+\.?\d*/)?.[0] || "";
56
56
  const unit = size.slice(value.length);
57
57
  const maxWidth = Number.parseFloat(value) - 0.1;
58
58
  return Number.isNaN(maxWidth) ? size : `${maxWidth}${unit}`;
@@ -75,7 +75,7 @@ async function parseApply({ code, uno, offset, applyVariable }, node, childNode)
75
75
  let body;
76
76
  if (childNode.type === "Atrule" && childNode.name === "apply" && childNode.prelude && childNode.prelude.type === "Raw") {
77
77
  body = removeQuotes(childNode.prelude.value.trim());
78
- } else if (childNode.type === "Declaration" && applyVariable.includes(childNode.property) && childNode.value.type === "Value") {
78
+ } else if (childNode.type === "Declaration" && applyVariable.includes(childNode.property) && (childNode.value.type === "Value" || childNode.value.type === "Raw")) {
79
79
  let rawValue = original.slice(
80
80
  calcOffset(childNode.value.loc.start.offset),
81
81
  calcOffset(childNode.value.loc.end.offset)
@@ -86,6 +86,7 @@ async function parseApply({ code, uno, offset, applyVariable }, node, childNode)
86
86
  }
87
87
  if (!body)
88
88
  return;
89
+ body = removeComments(body);
89
90
  const classNames = expandVariantGroup(body).split(/\s+/g).map((className) => className.trim().replace(/\\/, ""));
90
91
  const utils = (await Promise.all(
91
92
  classNames.map((i) => uno.parseToken(i, "-"))
@@ -140,6 +141,9 @@ async function parseApply({ code, uno, offset, applyVariable }, node, childNode)
140
141
  function removeQuotes(value) {
141
142
  return value.replace(/^(['"])(.*)\1$/, "$2");
142
143
  }
144
+ function removeComments(value) {
145
+ return value.replace(/(\/\*(?:.|\n)*?\*\/)|(\/\/.*)/g, "");
146
+ }
143
147
 
144
148
  function handleFunction({ code, uno, options }, node) {
145
149
  const { throwOnMissing = true } = options;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@unocss/transformer-directives",
3
3
  "type": "module",
4
- "version": "0.60.2",
4
+ "version": "0.60.4",
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/rule-utils": "0.60.2",
37
- "@unocss/core": "0.60.2"
36
+ "@unocss/core": "0.60.4",
37
+ "@unocss/rule-utils": "0.60.4"
38
38
  },
39
39
  "devDependencies": {
40
40
  "magic-string": "^0.30.10"