@unocss/transformer-variant-group 0.26.2 → 0.27.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/README.md CHANGED
@@ -28,7 +28,7 @@ Unocss({
28
28
  Will be transformed to:
29
29
 
30
30
  ```html
31
- <div class="hover:bg-gray-400 hover-font-medium font-light font-mono"/>
31
+ <div class="hover:bg-gray-400 hover:font-medium font-light font-mono"/>
32
32
  ```
33
33
 
34
34
  ## License
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.2",
3
+ "version": "0.27.0",
4
4
  "description": "Variant group transformer for UnoCSS",
5
5
  "keywords": [
6
6
  "unocss",
@@ -10,15 +10,18 @@
10
10
  "bugs": {
11
11
  "url": "https://github.com/unocss/unocss/issues"
12
12
  },
13
+ "license": "MIT",
13
14
  "repository": {
14
15
  "type": "git",
15
16
  "url": "git+https://github.com/unocss/unocss.git",
16
17
  "directory": "packages/transformer-variant-group"
17
18
  },
18
19
  "funding": "https://github.com/sponsors/antfu",
19
- "license": "MIT",
20
20
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
21
21
  "sideEffects": false,
22
+ "files": [
23
+ "dist"
24
+ ],
22
25
  "exports": {
23
26
  ".": {
24
27
  "require": "./dist/index.cjs",
@@ -28,17 +31,11 @@
28
31
  "main": "./dist/index.cjs",
29
32
  "module": "./dist/index.mjs",
30
33
  "types": "./dist/index.d.ts",
31
- "files": [
32
- "dist"
33
- ],
34
- "peerDependencies": {
35
- "@unocss/core": "0.26.2"
34
+ "dependencies": {
35
+ "@unocss/core": "0.27.0"
36
36
  },
37
37
  "devDependencies": {
38
- "@unocss/core": "0.26.2"
39
- },
40
- "dependencies": {
41
- "magic-string": "^0.25.7"
38
+ "magic-string-extra": "^0.1.2"
42
39
  },
43
40
  "scripts": {
44
41
  "build": "unbuild",