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