@unocss/transformer-variant-group 0.26.3 → 0.27.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.
package/dist/index.cjs CHANGED
@@ -3,11 +3,6 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const core = require('@unocss/core');
6
- const MagicString = require('magic-string');
7
-
8
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; }
9
-
10
- const MagicString__default = /*#__PURE__*/_interopDefaultLegacy(MagicString);
11
6
 
12
7
  function transformerVariantGroup() {
13
8
  return {
@@ -18,25 +13,16 @@ function transformerVariantGroup() {
18
13
  }
19
14
  };
20
15
  }
21
- function transformVariantGroups(code, sourcemap = true) {
22
- const s = new MagicString__default(code);
23
- let hasReplaced = false;
16
+ function transformVariantGroups(code) {
24
17
  let match;
25
18
  core.regexClassGroup.lastIndex = 0;
26
- while (match = core.regexClassGroup.exec(code)) {
27
- hasReplaced = true;
19
+ while (match = core.regexClassGroup.exec(code.original)) {
28
20
  const start = match.index;
29
21
  const end = start + match[0].length;
30
22
  const [, pre, sep, body] = match;
31
23
  const replacement = body.split(/\s/g).map((i) => i.replace(/^(!?)(.*)/, `$1${pre}${sep}$2`)).join(" ");
32
- s.overwrite(start, end, replacement);
24
+ code.overwrite(start, end, replacement);
33
25
  }
34
- if (!hasReplaced)
35
- return null;
36
- return {
37
- code: s.toString(),
38
- map: sourcemap ? s.generateMap({ hires: true }) : void 0
39
- };
40
26
  }
41
27
 
42
28
  exports["default"] = transformerVariantGroup;
package/dist/index.d.ts CHANGED
@@ -1,10 +1,7 @@
1
- import * as magic_string from 'magic-string';
2
1
  import { SourceCodeTransformer } from '@unocss/core';
2
+ import MagicString from 'magic-string-extra';
3
3
 
4
4
  declare function transformerVariantGroup(): SourceCodeTransformer;
5
- declare function transformVariantGroups(code: string, sourcemap?: boolean): {
6
- code: string;
7
- map: magic_string.SourceMap | undefined;
8
- } | null;
5
+ declare function transformVariantGroups(code: MagicString): void;
9
6
 
10
7
  export { transformerVariantGroup as default, transformVariantGroups };
package/dist/index.mjs CHANGED
@@ -1,5 +1,4 @@
1
1
  import { regexClassGroup } from '@unocss/core';
2
- import MagicString from 'magic-string';
3
2
 
4
3
  function transformerVariantGroup() {
5
4
  return {
@@ -10,25 +9,16 @@ function transformerVariantGroup() {
10
9
  }
11
10
  };
12
11
  }
13
- function transformVariantGroups(code, sourcemap = true) {
14
- const s = new MagicString(code);
15
- let hasReplaced = false;
12
+ function transformVariantGroups(code) {
16
13
  let match;
17
14
  regexClassGroup.lastIndex = 0;
18
- while (match = regexClassGroup.exec(code)) {
19
- hasReplaced = true;
15
+ while (match = regexClassGroup.exec(code.original)) {
20
16
  const start = match.index;
21
17
  const end = start + match[0].length;
22
18
  const [, pre, sep, body] = match;
23
19
  const replacement = body.split(/\s/g).map((i) => i.replace(/^(!?)(.*)/, `$1${pre}${sep}$2`)).join(" ");
24
- s.overwrite(start, end, replacement);
20
+ code.overwrite(start, end, replacement);
25
21
  }
26
- if (!hasReplaced)
27
- return null;
28
- return {
29
- code: s.toString(),
30
- map: sourcemap ? s.generateMap({ hires: true }) : void 0
31
- };
32
22
  }
33
23
 
34
24
  export { transformerVariantGroup as default, transformVariantGroups };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unocss/transformer-variant-group",
3
- "version": "0.26.3",
3
+ "version": "0.27.1",
4
4
  "description": "Variant group transformer for UnoCSS",
5
5
  "keywords": [
6
6
  "unocss",
@@ -32,8 +32,10 @@
32
32
  "module": "./dist/index.mjs",
33
33
  "types": "./dist/index.d.ts",
34
34
  "dependencies": {
35
- "@unocss/core": "0.26.3",
36
- "magic-string": "^0.25.7"
35
+ "@unocss/core": "0.27.1"
36
+ },
37
+ "devDependencies": {
38
+ "magic-string-extra": "^0.1.2"
37
39
  },
38
40
  "scripts": {
39
41
  "build": "unbuild",