@una-ui/extractor-vue-script 0.54.0 → 0.54.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.d.ts +1 -1
- package/dist/index.mjs +3 -3
- package/package.json +4 -5
- package/dist/index.cjs +0 -37
- package/dist/index.d.cts +0 -12
package/dist/index.d.ts
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -7,15 +7,15 @@ function generateSelectors(prefix, values) {
|
|
|
7
7
|
function splitCodeWithArbitraryVariants(code, prefixes) {
|
|
8
8
|
const result = [];
|
|
9
9
|
const camelCasePrefixes = prefixes.map((prefix) => prefix.replace(/-([a-z])/g, (_, c) => c.toUpperCase()));
|
|
10
|
-
prefixes = [...prefixes, ...camelCasePrefixes];
|
|
10
|
+
prefixes = [.../* @__PURE__ */ new Set([...prefixes, ...camelCasePrefixes])];
|
|
11
11
|
for (const prefix of prefixes) {
|
|
12
|
-
const regex = new RegExp(`\\b${prefix}\\s*:\\s*'([^']*)'`, "
|
|
12
|
+
const regex = new RegExp(`\\b${prefix}\\s*:\\s*(?:'([^']*)'|{[^}]*\\bdefault\\s*:\\s*'([^']*)'\\s*,?.*?})`, "gms");
|
|
13
13
|
let match;
|
|
14
14
|
while (true) {
|
|
15
15
|
match = regex.exec(code);
|
|
16
16
|
if (match === null)
|
|
17
17
|
break;
|
|
18
|
-
const values = match[1].split(defaultSplitRE);
|
|
18
|
+
const values = (match[1] ?? match[2]).split(defaultSplitRE);
|
|
19
19
|
const selectors = generateSelectors(prefix, values);
|
|
20
20
|
result.push(...selectors);
|
|
21
21
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@una-ui/extractor-vue-script",
|
|
3
|
-
"version": "0.54.
|
|
3
|
+
"version": "0.54.1",
|
|
4
4
|
"description": "Unocss extractor for Vue script",
|
|
5
5
|
"author": "Phojie Rengel <phojrengel@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -23,11 +23,9 @@
|
|
|
23
23
|
"exports": {
|
|
24
24
|
".": {
|
|
25
25
|
"types": "./dist/index.d.ts",
|
|
26
|
-
"import": "./dist/index.mjs"
|
|
27
|
-
"require": "./dist/index.cjs"
|
|
26
|
+
"import": "./dist/index.mjs"
|
|
28
27
|
}
|
|
29
28
|
},
|
|
30
|
-
"main": "./dist/index.cjs",
|
|
31
29
|
"module": "./dist/index.mjs",
|
|
32
30
|
"types": "./dist/index.d.ts",
|
|
33
31
|
"files": [
|
|
@@ -37,7 +35,8 @@
|
|
|
37
35
|
"access": "public"
|
|
38
36
|
},
|
|
39
37
|
"devDependencies": {
|
|
40
|
-
"@unocss/core": "^66.0.0"
|
|
38
|
+
"@unocss/core": "^66.0.0",
|
|
39
|
+
"vitest": "^3.1.3"
|
|
41
40
|
},
|
|
42
41
|
"scripts": {
|
|
43
42
|
"build": "unbuild",
|
package/dist/index.cjs
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const core = require('@unocss/core');
|
|
4
|
-
|
|
5
|
-
function generateSelectors(prefix, values) {
|
|
6
|
-
prefix = prefix.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
|
|
7
|
-
return values.filter((v) => Boolean(v) && v !== ":").map((v) => `[${prefix}~="${v}"]`);
|
|
8
|
-
}
|
|
9
|
-
function splitCodeWithArbitraryVariants(code, prefixes) {
|
|
10
|
-
const result = [];
|
|
11
|
-
const camelCasePrefixes = prefixes.map((prefix) => prefix.replace(/-([a-z])/g, (_, c) => c.toUpperCase()));
|
|
12
|
-
prefixes = [...prefixes, ...camelCasePrefixes];
|
|
13
|
-
for (const prefix of prefixes) {
|
|
14
|
-
const regex = new RegExp(`\\b${prefix}\\s*:\\s*'([^']*)'`, "g");
|
|
15
|
-
let match;
|
|
16
|
-
while (true) {
|
|
17
|
-
match = regex.exec(code);
|
|
18
|
-
if (match === null)
|
|
19
|
-
break;
|
|
20
|
-
const values = match[1].split(core.defaultSplitRE);
|
|
21
|
-
const selectors = generateSelectors(prefix, values);
|
|
22
|
-
result.push(...selectors);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return result;
|
|
26
|
-
}
|
|
27
|
-
function extractorVueScript(options) {
|
|
28
|
-
return {
|
|
29
|
-
name: "@una-ui/extractor-vue-script",
|
|
30
|
-
order: 0,
|
|
31
|
-
async extract({ code }) {
|
|
32
|
-
return splitCodeWithArbitraryVariants(code, options?.prefixes ?? []);
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
module.exports = extractorVueScript;
|
package/dist/index.d.cts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Extractor } from '@unocss/core';
|
|
2
|
-
|
|
3
|
-
interface ExtractorVueScriptOptions {
|
|
4
|
-
/**
|
|
5
|
-
* @default []
|
|
6
|
-
* @description List of prefixes to extract from the vue-script code.
|
|
7
|
-
*/
|
|
8
|
-
prefixes?: string[];
|
|
9
|
-
}
|
|
10
|
-
declare function extractorVueScript(options?: ExtractorVueScriptOptions): Extractor;
|
|
11
|
-
|
|
12
|
-
export = extractorVueScript;
|