@unocss/core 0.26.4 → 0.27.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.
package/dist/index.cjs CHANGED
@@ -221,20 +221,10 @@ function withLayer(layer, rules) {
221
221
 
222
222
  const regexClassGroup = /([!\w+:_/-]+?)([:-])\(((?:[!\w\s:/\\,%#.$-]|\[.*?\])*?)\)/gm;
223
223
  function expandVariantGroup(str) {
224
- const replaces = [];
225
- let match;
226
- while (match = regexClassGroup.exec(str)) {
227
- const start = match.index;
228
- const end = start + match[0].length;
229
- const [, pre, sep, body] = match;
230
- const replacement = body.split(/\s/g).map((i) => i.replace(/^(!?)(.*)/, `$1${pre}${sep}$2`)).join(" ");
231
- replaces.unshift([start, end, replacement]);
232
- }
233
- let result = str;
234
- replaces.forEach(([start, end, replacement]) => {
235
- result = result.slice(0, start) + replacement + result.slice(end);
224
+ regexClassGroup.lastIndex = 0;
225
+ return str.replace(regexClassGroup, (_, pre, sep, body) => {
226
+ return body.split(/\s/g).map((i) => i.replace(/^(!?)(.*)/, `$1${pre}${sep}$2`)).join(" ");
236
227
  });
237
- return result;
238
228
  }
239
229
 
240
230
  const warned = /* @__PURE__ */ new Set();
@@ -366,7 +356,7 @@ function resolveConfig(userConfig = {}, defaults = {}) {
366
356
  };
367
357
  }
368
358
 
369
- const version = "0.26.4";
359
+ const version = "0.27.2";
370
360
 
371
361
  class UnoGenerator {
372
362
  constructor(userConfig = {}, defaults = {}) {
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { LoadConfigResult } from 'unconfig';
2
+ import MagicString from 'magic-string';
2
3
 
3
4
  declare class UnoGenerator {
4
5
  userConfig: UserConfig;
@@ -75,6 +76,7 @@ declare function withLayer<T>(layer: string, rules: Rule<T>[]): Rule<T>[];
75
76
 
76
77
  declare const regexClassGroup: RegExp;
77
78
  declare function expandVariantGroup(str: string): string;
79
+ declare function expandVariantGroup(str: MagicString): MagicString;
78
80
 
79
81
  declare function warnOnce(msg: string): void;
80
82
 
@@ -420,7 +422,7 @@ interface SourceCodeTransformer {
420
422
  /**
421
423
  * The transform function
422
424
  */
423
- transform: (code: string, id: string, ctx: UnocssPluginContext) => Awaitable<string | TransformResult | null | undefined>;
425
+ transform: (code: MagicString, id: string, ctx: UnocssPluginContext) => Awaitable<void>;
424
426
  }
425
427
  /**
426
428
  * For other modules to aggregate the options
package/dist/index.mjs CHANGED
@@ -217,20 +217,10 @@ function withLayer(layer, rules) {
217
217
 
218
218
  const regexClassGroup = /([!\w+:_/-]+?)([:-])\(((?:[!\w\s:/\\,%#.$-]|\[.*?\])*?)\)/gm;
219
219
  function expandVariantGroup(str) {
220
- const replaces = [];
221
- let match;
222
- while (match = regexClassGroup.exec(str)) {
223
- const start = match.index;
224
- const end = start + match[0].length;
225
- const [, pre, sep, body] = match;
226
- const replacement = body.split(/\s/g).map((i) => i.replace(/^(!?)(.*)/, `$1${pre}${sep}$2`)).join(" ");
227
- replaces.unshift([start, end, replacement]);
228
- }
229
- let result = str;
230
- replaces.forEach(([start, end, replacement]) => {
231
- result = result.slice(0, start) + replacement + result.slice(end);
220
+ regexClassGroup.lastIndex = 0;
221
+ return str.replace(regexClassGroup, (_, pre, sep, body) => {
222
+ return body.split(/\s/g).map((i) => i.replace(/^(!?)(.*)/, `$1${pre}${sep}$2`)).join(" ");
232
223
  });
233
- return result;
234
224
  }
235
225
 
236
226
  const warned = /* @__PURE__ */ new Set();
@@ -362,7 +352,7 @@ function resolveConfig(userConfig = {}, defaults = {}) {
362
352
  };
363
353
  }
364
354
 
365
- const version = "0.26.4";
355
+ const version = "0.27.2";
366
356
 
367
357
  class UnoGenerator {
368
358
  constructor(userConfig = {}, defaults = {}) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unocss/core",
3
- "version": "0.26.4",
3
+ "version": "0.27.2",
4
4
  "description": "The instant on-demand Atomic CSS engine.",
5
5
  "keywords": [
6
6
  "unocss",
@@ -14,15 +14,18 @@
14
14
  "bugs": {
15
15
  "url": "https://github.com/unocss/unocss/issues"
16
16
  },
17
+ "license": "MIT",
17
18
  "repository": {
18
19
  "type": "git",
19
20
  "url": "git+https://github.com/unocss/unocss.git",
20
21
  "directory": "packages/core"
21
22
  },
22
23
  "funding": "https://github.com/sponsors/antfu",
23
- "license": "MIT",
24
24
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
25
25
  "sideEffects": false,
26
+ "files": [
27
+ "dist"
28
+ ],
26
29
  "exports": {
27
30
  ".": {
28
31
  "require": "./dist/index.cjs",
@@ -33,9 +36,10 @@
33
36
  "main": "dist/index.cjs",
34
37
  "module": "dist/index.mjs",
35
38
  "types": "dist/index.d.ts",
36
- "files": [
37
- "dist"
38
- ],
39
+ "devDependencies": {
40
+ "magic-string": "^0.26.1",
41
+ "unconfig": "^0.3.1"
42
+ },
39
43
  "scripts": {
40
44
  "build": "unbuild",
41
45
  "stub": "unbuild --stub"