@unocss/astro 0.55.0 → 0.55.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 +14 -11
- package/dist/index.d.cts +25 -0
- package/dist/index.d.mts +25 -0
- package/dist/index.mjs +13 -10
- package/package.json +5 -5
package/dist/index.cjs
CHANGED
|
@@ -4,28 +4,32 @@ const node_path = require('node:path');
|
|
|
4
4
|
const node_url = require('node:url');
|
|
5
5
|
const VitePlugin = require('@unocss/vite');
|
|
6
6
|
|
|
7
|
-
function
|
|
7
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
8
8
|
|
|
9
|
-
const VitePlugin__default = /*#__PURE__*/
|
|
9
|
+
const VitePlugin__default = /*#__PURE__*/_interopDefaultCompat(VitePlugin);
|
|
10
|
+
|
|
11
|
+
const RESOLVED_ID_RE = /[\/\\]__uno(?:(_.*?))?\.css$/;
|
|
10
12
|
|
|
11
13
|
const UNO_INJECT_ID = "uno-astro";
|
|
12
|
-
const UNO_QUERY_KEY = "uno-with-astro-key";
|
|
13
14
|
const astroCSSKeyRE = /(\?|\&)lang\.css/;
|
|
14
15
|
function AstroVitePlugin(options) {
|
|
15
16
|
const { injects, injectReset } = options;
|
|
16
17
|
const resetInjectPath = injectReset ? injects[0] : void 0;
|
|
17
18
|
let command;
|
|
18
|
-
let
|
|
19
|
+
let root;
|
|
19
20
|
let resetCSSInjected = false;
|
|
20
21
|
const resolveCSSQueue = /* @__PURE__ */ new Set();
|
|
21
22
|
return {
|
|
22
23
|
name: "unocss:astro",
|
|
23
24
|
enforce: "pre",
|
|
24
25
|
configResolved(config) {
|
|
26
|
+
root = config.root;
|
|
25
27
|
command = config.command;
|
|
26
|
-
nodeModulesPath = `${config.root}/node_modules`;
|
|
27
28
|
},
|
|
28
29
|
async resolveId(id, importer) {
|
|
30
|
+
if (RESOLVED_ID_RE.test(id)) {
|
|
31
|
+
return this.resolve(node_path.join(root, id), importer, { skipSelf: true });
|
|
32
|
+
}
|
|
29
33
|
if (id === UNO_INJECT_ID) {
|
|
30
34
|
if (injectReset) {
|
|
31
35
|
resetCSSInjected = false;
|
|
@@ -38,7 +42,6 @@ function AstroVitePlugin(options) {
|
|
|
38
42
|
const resolved = await this.resolve(id, importer, { skipSelf: true });
|
|
39
43
|
if (resolved) {
|
|
40
44
|
const fsPath = resolved.id;
|
|
41
|
-
const realId = `${fsPath}${fsPath.includes("?") ? "&" : "?"}${UNO_QUERY_KEY}`;
|
|
42
45
|
if (injectReset) {
|
|
43
46
|
if (resetInjectPath.includes(id)) {
|
|
44
47
|
setTimeout(() => {
|
|
@@ -50,19 +53,19 @@ function AstroVitePlugin(options) {
|
|
|
50
53
|
resetCSSInjected = true;
|
|
51
54
|
} else if (id.includes(".css") && !resetCSSInjected) {
|
|
52
55
|
return new Promise((resolve2) => {
|
|
53
|
-
resolveCSSQueue.add(() =>
|
|
56
|
+
resolveCSSQueue.add(() => {
|
|
57
|
+
resolve2(fsPath);
|
|
58
|
+
});
|
|
54
59
|
});
|
|
55
60
|
}
|
|
56
61
|
}
|
|
57
|
-
return
|
|
62
|
+
return fsPath;
|
|
58
63
|
}
|
|
59
64
|
}
|
|
60
65
|
},
|
|
61
|
-
load(id
|
|
66
|
+
load(id) {
|
|
62
67
|
if (id.endsWith(UNO_INJECT_ID))
|
|
63
68
|
return injects.join("\n");
|
|
64
|
-
if (!options2?.ssr && id.includes(UNO_QUERY_KEY) && id.includes(".css") && !id.startsWith(nodeModulesPath))
|
|
65
|
-
return "";
|
|
66
69
|
}
|
|
67
70
|
};
|
|
68
71
|
}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { AstroIntegration } from 'astro';
|
|
2
|
+
import { VitePluginConfig } from '@unocss/vite';
|
|
3
|
+
import { UserConfigDefaults } from '@unocss/core';
|
|
4
|
+
|
|
5
|
+
interface AstroIntegrationConfig<Theme extends object = object> extends VitePluginConfig<Theme> {
|
|
6
|
+
/**
|
|
7
|
+
* Include reset styles
|
|
8
|
+
* When passing `true`, `@unocss/reset/tailwind.css` will be used
|
|
9
|
+
* @default false
|
|
10
|
+
*/
|
|
11
|
+
injectReset?: string | boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Inject UnoCSS entry import for every astro page
|
|
14
|
+
* @default true
|
|
15
|
+
*/
|
|
16
|
+
injectEntry?: boolean | string;
|
|
17
|
+
/**
|
|
18
|
+
* Inject extra imports for every astro page
|
|
19
|
+
* @default []
|
|
20
|
+
*/
|
|
21
|
+
injectExtra?: string[];
|
|
22
|
+
}
|
|
23
|
+
declare function UnoCSSAstroIntegration<Theme extends object>(options?: AstroIntegrationConfig<Theme>, defaults?: UserConfigDefaults): AstroIntegration;
|
|
24
|
+
|
|
25
|
+
export { AstroIntegrationConfig, UnoCSSAstroIntegration as default };
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { AstroIntegration } from 'astro';
|
|
2
|
+
import { VitePluginConfig } from '@unocss/vite';
|
|
3
|
+
import { UserConfigDefaults } from '@unocss/core';
|
|
4
|
+
|
|
5
|
+
interface AstroIntegrationConfig<Theme extends object = object> extends VitePluginConfig<Theme> {
|
|
6
|
+
/**
|
|
7
|
+
* Include reset styles
|
|
8
|
+
* When passing `true`, `@unocss/reset/tailwind.css` will be used
|
|
9
|
+
* @default false
|
|
10
|
+
*/
|
|
11
|
+
injectReset?: string | boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Inject UnoCSS entry import for every astro page
|
|
14
|
+
* @default true
|
|
15
|
+
*/
|
|
16
|
+
injectEntry?: boolean | string;
|
|
17
|
+
/**
|
|
18
|
+
* Inject extra imports for every astro page
|
|
19
|
+
* @default []
|
|
20
|
+
*/
|
|
21
|
+
injectExtra?: string[];
|
|
22
|
+
}
|
|
23
|
+
declare function UnoCSSAstroIntegration<Theme extends object>(options?: AstroIntegrationConfig<Theme>, defaults?: UserConfigDefaults): AstroIntegration;
|
|
24
|
+
|
|
25
|
+
export { AstroIntegrationConfig, UnoCSSAstroIntegration as default };
|
package/dist/index.mjs
CHANGED
|
@@ -1,25 +1,29 @@
|
|
|
1
|
-
import { resolve } from 'node:path';
|
|
1
|
+
import { resolve, join } from 'node:path';
|
|
2
2
|
import { fileURLToPath } from 'node:url';
|
|
3
3
|
import VitePlugin from '@unocss/vite';
|
|
4
4
|
|
|
5
|
+
const RESOLVED_ID_RE = /[\/\\]__uno(?:(_.*?))?\.css$/;
|
|
6
|
+
|
|
5
7
|
const UNO_INJECT_ID = "uno-astro";
|
|
6
|
-
const UNO_QUERY_KEY = "uno-with-astro-key";
|
|
7
8
|
const astroCSSKeyRE = /(\?|\&)lang\.css/;
|
|
8
9
|
function AstroVitePlugin(options) {
|
|
9
10
|
const { injects, injectReset } = options;
|
|
10
11
|
const resetInjectPath = injectReset ? injects[0] : void 0;
|
|
11
12
|
let command;
|
|
12
|
-
let
|
|
13
|
+
let root;
|
|
13
14
|
let resetCSSInjected = false;
|
|
14
15
|
const resolveCSSQueue = /* @__PURE__ */ new Set();
|
|
15
16
|
return {
|
|
16
17
|
name: "unocss:astro",
|
|
17
18
|
enforce: "pre",
|
|
18
19
|
configResolved(config) {
|
|
20
|
+
root = config.root;
|
|
19
21
|
command = config.command;
|
|
20
|
-
nodeModulesPath = `${config.root}/node_modules`;
|
|
21
22
|
},
|
|
22
23
|
async resolveId(id, importer) {
|
|
24
|
+
if (RESOLVED_ID_RE.test(id)) {
|
|
25
|
+
return this.resolve(join(root, id), importer, { skipSelf: true });
|
|
26
|
+
}
|
|
23
27
|
if (id === UNO_INJECT_ID) {
|
|
24
28
|
if (injectReset) {
|
|
25
29
|
resetCSSInjected = false;
|
|
@@ -32,7 +36,6 @@ function AstroVitePlugin(options) {
|
|
|
32
36
|
const resolved = await this.resolve(id, importer, { skipSelf: true });
|
|
33
37
|
if (resolved) {
|
|
34
38
|
const fsPath = resolved.id;
|
|
35
|
-
const realId = `${fsPath}${fsPath.includes("?") ? "&" : "?"}${UNO_QUERY_KEY}`;
|
|
36
39
|
if (injectReset) {
|
|
37
40
|
if (resetInjectPath.includes(id)) {
|
|
38
41
|
setTimeout(() => {
|
|
@@ -44,19 +47,19 @@ function AstroVitePlugin(options) {
|
|
|
44
47
|
resetCSSInjected = true;
|
|
45
48
|
} else if (id.includes(".css") && !resetCSSInjected) {
|
|
46
49
|
return new Promise((resolve2) => {
|
|
47
|
-
resolveCSSQueue.add(() =>
|
|
50
|
+
resolveCSSQueue.add(() => {
|
|
51
|
+
resolve2(fsPath);
|
|
52
|
+
});
|
|
48
53
|
});
|
|
49
54
|
}
|
|
50
55
|
}
|
|
51
|
-
return
|
|
56
|
+
return fsPath;
|
|
52
57
|
}
|
|
53
58
|
}
|
|
54
59
|
},
|
|
55
|
-
load(id
|
|
60
|
+
load(id) {
|
|
56
61
|
if (id.endsWith(UNO_INJECT_ID))
|
|
57
62
|
return injects.join("\n");
|
|
58
|
-
if (!options2?.ssr && id.includes(UNO_QUERY_KEY) && id.includes(".css") && !id.startsWith(nodeModulesPath))
|
|
59
|
-
return "";
|
|
60
63
|
}
|
|
61
64
|
};
|
|
62
65
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unocss/astro",
|
|
3
|
-
"version": "0.55.
|
|
3
|
+
"version": "0.55.2",
|
|
4
4
|
"description": "UnoCSS integration for Astro",
|
|
5
5
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -45,12 +45,12 @@
|
|
|
45
45
|
}
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@unocss/core": "0.55.
|
|
49
|
-
"@unocss/reset": "0.55.
|
|
50
|
-
"@unocss/vite": "0.55.
|
|
48
|
+
"@unocss/core": "0.55.2",
|
|
49
|
+
"@unocss/reset": "0.55.2",
|
|
50
|
+
"@unocss/vite": "0.55.2"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"astro": "^2.10.
|
|
53
|
+
"astro": "^2.10.9"
|
|
54
54
|
},
|
|
55
55
|
"scripts": {
|
|
56
56
|
"build": "unbuild",
|