@unocss/transformer-compile-class 66.6.0-beta.1 → 66.6.1

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 +4 -4
  2. package/package.json +4 -8
package/dist/index.mjs CHANGED
@@ -2,18 +2,18 @@ import { escapeRegExp, expandVariantGroup } from "@unocss/core";
2
2
 
3
3
  //#region src/index.ts
4
4
  function transformerCompileClass(options = {}) {
5
- const { trigger = /(["'`]):uno-?(?<name>\S+)?:\s(.*?)\1/g, classPrefix = "uno-", hashFn = hash, keepUnknown = true, alwaysHash = false } = options;
5
+ const { trigger = /(["'`])\s*:uno-?(?<name>\S+)?:\s([\s\S]*?)\1/g, classPrefix = "uno-", hashFn = hash, keepUnknown = true, alwaysHash = false } = options;
6
6
  const compiledClass = /* @__PURE__ */ new Set();
7
- const regexp = typeof trigger === "string" ? new RegExp(`(["'\`])${escapeRegExp(trigger)}\\s([^\\1]*?)\\1`, "g") : trigger;
7
+ const regexp = typeof trigger === "string" ? new RegExp(`(["'\`])\\s*${escapeRegExp(trigger)}\\s([\\s\\S]*?)\\1`, "g") : trigger;
8
8
  return {
9
9
  name: "@unocss/transformer-compile-class",
10
10
  enforce: "pre",
11
11
  async transform(s, _, { uno, tokens, invalidate }) {
12
- const matches = [...s.original.matchAll(regexp)];
12
+ const matches = Array.from(s.original.matchAll(regexp));
13
13
  if (!matches.length) return;
14
14
  const size = compiledClass.size;
15
15
  for (const match of matches) {
16
- let body = match.length === 4 && match.groups ? expandVariantGroup(match[3].trim()) : expandVariantGroup(match[2].trim());
16
+ let body = (match.length === 4 && match.groups ? expandVariantGroup(match[3].trim()) : expandVariantGroup(match[2].trim())).replace(/\s+/g, " ");
17
17
  const start = match.index;
18
18
  const replacements = [];
19
19
  if (keepUnknown) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@unocss/transformer-compile-class",
3
3
  "type": "module",
4
- "version": "66.6.0-beta.1",
4
+ "version": "66.6.1",
5
5
  "description": "Compile group of classes into one class",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -21,19 +21,15 @@
21
21
  ],
22
22
  "sideEffects": false,
23
23
  "exports": {
24
- ".": {
25
- "types": "./dist/index.d.mts",
26
- "default": "./dist/index.mjs"
27
- }
24
+ ".": "./dist/index.mjs",
25
+ "./package.json": "./package.json"
28
26
  },
29
- "main": "./dist/index.mjs",
30
- "module": "./dist/index.mjs",
31
27
  "types": "./dist/index.d.mts",
32
28
  "files": [
33
29
  "dist"
34
30
  ],
35
31
  "dependencies": {
36
- "@unocss/core": "66.6.0-beta.1"
32
+ "@unocss/core": "66.6.1"
37
33
  },
38
34
  "devDependencies": {
39
35
  "magic-string": "^0.30.21"