@una-ui/extractor-vue-script 0.2.0-beta.1 → 0.2.0-beta.4

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
@@ -1 +1,37 @@
1
- module.exports = require("/root/projects/OSS/una-ui/node_modules/.pnpm/jiti@1.20.0/node_modules/jiti/lib/index.js")(null, { interopDefault: true, esmResolve: true })("/root/projects/OSS/una-ui/packages/extractor-vue-script/src/index.ts")
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const core = require('@unocss/core');
6
+
7
+ function generateSelectors(prefix, values) {
8
+ return values.filter((v) => Boolean(v) && v !== ":").map((v) => `[${prefix}~="${v}"]`);
9
+ }
10
+ function splitCodeWithArbitraryVariants(code, prefixes) {
11
+ const result = [];
12
+ for (const prefix of prefixes) {
13
+ const regex = new RegExp(`^\\s*${prefix}:\\s+'.*',?\\s*$`, "mg");
14
+ const matches = code.match(regex);
15
+ if (!matches)
16
+ continue;
17
+ for (const match of matches) {
18
+ const values = match.replace(/^.*:\s*'(.*)',?\s*$/, "$1").split(core.defaultSplitRE);
19
+ const selectors = generateSelectors(prefix, values);
20
+ result.push(...selectors);
21
+ }
22
+ }
23
+ return result;
24
+ }
25
+ function extractor(options) {
26
+ return {
27
+ name: "@una-ui/extractor-vue-script",
28
+ order: 0,
29
+ async extract({ code }) {
30
+ return splitCodeWithArbitraryVariants(code, options?.prefixes ?? []);
31
+ }
32
+ };
33
+ }
34
+
35
+ exports.default = extractor;
36
+ exports.extractor = extractor;
37
+ exports.splitCodeWithArbitraryVariants = splitCodeWithArbitraryVariants;
package/dist/index.d.ts CHANGED
@@ -1,2 +1,14 @@
1
- export * from "/root/projects/OSS/una-ui/packages/extractor-vue-script/src/index";
2
- export { default } from "/root/projects/OSS/una-ui/packages/extractor-vue-script/src/index";
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
+
11
+ declare function splitCodeWithArbitraryVariants(code: string, prefixes: string[]): string[];
12
+ declare function extractor(options?: ExtractorVueScriptOptions): Extractor;
13
+
14
+ export { extractor as default, extractor, splitCodeWithArbitraryVariants };
package/dist/index.mjs CHANGED
@@ -1,8 +1,31 @@
1
- import jiti from "file:///root/projects/OSS/una-ui/node_modules/.pnpm/jiti@1.20.0/node_modules/jiti/lib/index.js";
1
+ import { defaultSplitRE } from '@unocss/core';
2
2
 
3
- /** @type {import("/root/projects/OSS/una-ui/packages/extractor-vue-script/src/index")} */
4
- const _module = jiti(null, { interopDefault: true, esmResolve: true })("/root/projects/OSS/una-ui/packages/extractor-vue-script/src/index.ts");
3
+ function generateSelectors(prefix, values) {
4
+ return values.filter((v) => Boolean(v) && v !== ":").map((v) => `[${prefix}~="${v}"]`);
5
+ }
6
+ function splitCodeWithArbitraryVariants(code, prefixes) {
7
+ const result = [];
8
+ for (const prefix of prefixes) {
9
+ const regex = new RegExp(`^\\s*${prefix}:\\s+'.*',?\\s*$`, "mg");
10
+ const matches = code.match(regex);
11
+ if (!matches)
12
+ continue;
13
+ for (const match of matches) {
14
+ const values = match.replace(/^.*:\s*'(.*)',?\s*$/, "$1").split(defaultSplitRE);
15
+ const selectors = generateSelectors(prefix, values);
16
+ result.push(...selectors);
17
+ }
18
+ }
19
+ return result;
20
+ }
21
+ function extractor(options) {
22
+ return {
23
+ name: "@una-ui/extractor-vue-script",
24
+ order: 0,
25
+ async extract({ code }) {
26
+ return splitCodeWithArbitraryVariants(code, options?.prefixes ?? []);
27
+ }
28
+ };
29
+ }
5
30
 
6
- export default _module;
7
- export const splitCodeWithArbitraryVariants = _module.splitCodeWithArbitraryVariants;
8
- export const extractor = _module.extractor;
31
+ export { extractor as default, extractor, splitCodeWithArbitraryVariants };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@una-ui/extractor-vue-script",
3
- "version": "0.2.0-beta.1",
3
+ "version": "0.2.0-beta.4",
4
4
  "description": "Unocss extractor for Vue script",
5
5
  "author": "Phojie Rengel <phojrengel@gmail.com>",
6
6
  "license": "MIT",