@unocss/extractor-pug 66.5.10 → 66.5.12
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.mts +5 -4
- package/dist/index.mjs +29 -35
- package/package.json +5 -6
- package/dist/index.d.ts +0 -6
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { Options } from "pug";
|
|
2
|
+
import { Extractor } from "@unocss/core";
|
|
3
3
|
|
|
4
|
+
//#region src/index.d.ts
|
|
4
5
|
declare function extractorPug(options?: Options): Extractor;
|
|
5
|
-
|
|
6
|
-
export { extractorPug as default };
|
|
6
|
+
//#endregion
|
|
7
|
+
export { extractorPug as default };
|
package/dist/index.mjs
CHANGED
|
@@ -1,39 +1,33 @@
|
|
|
1
|
+
//#region src/index.ts
|
|
1
2
|
const regexVueTemplate = /<template.*?lang=['"]pug['"][^>]*>([\s\S]*?)<\/template>/g;
|
|
2
3
|
function extractorPug(options = {}) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
if (tail)
|
|
30
|
-
ctx.code = `${ctx.code}
|
|
31
|
-
|
|
32
|
-
${tail}`;
|
|
33
|
-
}
|
|
34
|
-
return void 0;
|
|
35
|
-
}
|
|
36
|
-
};
|
|
4
|
+
async function compile(code, id) {
|
|
5
|
+
const Pug = await import("pug");
|
|
6
|
+
try {
|
|
7
|
+
return Pug.compile(code, {
|
|
8
|
+
filename: id,
|
|
9
|
+
doctype: "html",
|
|
10
|
+
...options
|
|
11
|
+
})();
|
|
12
|
+
} catch {}
|
|
13
|
+
}
|
|
14
|
+
return {
|
|
15
|
+
name: "pug",
|
|
16
|
+
order: -1,
|
|
17
|
+
async extract(ctx) {
|
|
18
|
+
if (!ctx.id) return;
|
|
19
|
+
if (ctx.id.endsWith(".pug") || ctx.id.includes("?vue&type=template")) try {
|
|
20
|
+
ctx.code = await compile(ctx.code, ctx.id) || ctx.code;
|
|
21
|
+
} catch {}
|
|
22
|
+
else if (ctx.id.endsWith(".vue") || ctx.id.endsWith(".svelte")) {
|
|
23
|
+
const matches = Array.from(ctx.code.matchAll(regexVueTemplate));
|
|
24
|
+
let tail = "";
|
|
25
|
+
for (const match of matches) if (match && match[1]) tail += `\n${await compile(match[1].trim(), ctx.id)}`;
|
|
26
|
+
if (tail) ctx.code = `${ctx.code}\n\n${tail}`;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
};
|
|
37
30
|
}
|
|
38
31
|
|
|
39
|
-
|
|
32
|
+
//#endregion
|
|
33
|
+
export { extractorPug as default };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unocss/extractor-pug",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "66.5.
|
|
4
|
+
"version": "66.5.12",
|
|
5
5
|
"description": "UnoCSS extractor for Pug",
|
|
6
6
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
},
|
|
30
30
|
"main": "./dist/index.mjs",
|
|
31
31
|
"module": "./dist/index.mjs",
|
|
32
|
-
"types": "./dist/index.d.
|
|
32
|
+
"types": "./dist/index.d.mts",
|
|
33
33
|
"files": [
|
|
34
34
|
"dist"
|
|
35
35
|
],
|
|
@@ -44,11 +44,10 @@
|
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@types/pug": "^2.0.10",
|
|
46
46
|
"pug": "^3.0.3",
|
|
47
|
-
"@unocss/core": "66.5.
|
|
47
|
+
"@unocss/core": "66.5.12"
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|
|
50
|
-
"build": "
|
|
51
|
-
"
|
|
52
|
-
"test:attw": "attw --pack --config-path ../../.attw-esm-only.json"
|
|
50
|
+
"build": "tsdown --config-loader unrun",
|
|
51
|
+
"dev": "tsdown --config-loader unrun --watch"
|
|
53
52
|
}
|
|
54
53
|
}
|