@unocss/astro 0.56.5 → 0.57.0

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
@@ -12,57 +12,21 @@ const VitePlugin__default = /*#__PURE__*/_interopDefaultCompat(VitePlugin);
12
12
  const RESOLVED_ID_RE = /[\/\\]__uno(?:(_.*?))?\.css$/;
13
13
 
14
14
  const UNO_INJECT_ID = "uno-astro";
15
- const astroCSSKeyRE = /(\?|\&)lang\.css/;
16
15
  function AstroVitePlugin(options) {
17
- const { injects, injectReset } = options;
18
- const resetInjectPath = injectReset ? injects[0] : void 0;
19
- let command;
16
+ const { injects } = options;
20
17
  let root;
21
- let resetCSSInjected = false;
22
- const resolveCSSQueue = /* @__PURE__ */ new Set();
23
18
  return {
24
19
  name: "unocss:astro",
25
20
  enforce: "pre",
26
21
  configResolved(config) {
27
22
  root = config.root;
28
- command = config.command;
29
23
  },
30
24
  async resolveId(id, importer) {
31
25
  if (RESOLVED_ID_RE.test(id)) {
32
26
  return this.resolve(vite.normalizePath(node_path.join(root, id)), importer, { skipSelf: true });
33
27
  }
34
- if (id === UNO_INJECT_ID) {
35
- if (injectReset) {
36
- resetCSSInjected = false;
37
- }
28
+ if (id === UNO_INJECT_ID)
38
29
  return id;
39
- }
40
- if (injectReset && command === "serve" && astroCSSKeyRE.test(id) && !resetCSSInjected)
41
- return new Promise((resolve2) => resolveCSSQueue.add(() => resolve2()));
42
- if (importer?.endsWith(UNO_INJECT_ID) && command === "serve") {
43
- const resolved = await this.resolve(id, importer, { skipSelf: true });
44
- if (resolved) {
45
- const fsPath = resolved.id;
46
- if (injectReset) {
47
- if (resetInjectPath.includes(id)) {
48
- setTimeout(() => {
49
- resolveCSSQueue.forEach((res) => {
50
- res();
51
- resolveCSSQueue.delete(res);
52
- });
53
- });
54
- resetCSSInjected = true;
55
- } else if (id.includes(".css") && !resetCSSInjected) {
56
- return new Promise((resolve2) => {
57
- resolveCSSQueue.add(() => {
58
- resolve2(fsPath);
59
- });
60
- });
61
- }
62
- }
63
- return fsPath;
64
- }
65
- }
66
30
  },
67
31
  load(id) {
68
32
  if (id.endsWith(UNO_INJECT_ID))
@@ -98,7 +62,6 @@ function UnoCSSAstroIntegration(options = {}, defaults) {
98
62
  updateConfig({
99
63
  vite: {
100
64
  plugins: [AstroVitePlugin({
101
- injectReset: !!injectReset,
102
65
  injects
103
66
  }), ...VitePlugin__default(options, defaults)]
104
67
  }
package/dist/index.mjs CHANGED
@@ -6,57 +6,21 @@ import { normalizePath } from 'vite';
6
6
  const RESOLVED_ID_RE = /[\/\\]__uno(?:(_.*?))?\.css$/;
7
7
 
8
8
  const UNO_INJECT_ID = "uno-astro";
9
- const astroCSSKeyRE = /(\?|\&)lang\.css/;
10
9
  function AstroVitePlugin(options) {
11
- const { injects, injectReset } = options;
12
- const resetInjectPath = injectReset ? injects[0] : void 0;
13
- let command;
10
+ const { injects } = options;
14
11
  let root;
15
- let resetCSSInjected = false;
16
- const resolveCSSQueue = /* @__PURE__ */ new Set();
17
12
  return {
18
13
  name: "unocss:astro",
19
14
  enforce: "pre",
20
15
  configResolved(config) {
21
16
  root = config.root;
22
- command = config.command;
23
17
  },
24
18
  async resolveId(id, importer) {
25
19
  if (RESOLVED_ID_RE.test(id)) {
26
20
  return this.resolve(normalizePath(join(root, id)), importer, { skipSelf: true });
27
21
  }
28
- if (id === UNO_INJECT_ID) {
29
- if (injectReset) {
30
- resetCSSInjected = false;
31
- }
22
+ if (id === UNO_INJECT_ID)
32
23
  return id;
33
- }
34
- if (injectReset && command === "serve" && astroCSSKeyRE.test(id) && !resetCSSInjected)
35
- return new Promise((resolve2) => resolveCSSQueue.add(() => resolve2()));
36
- if (importer?.endsWith(UNO_INJECT_ID) && command === "serve") {
37
- const resolved = await this.resolve(id, importer, { skipSelf: true });
38
- if (resolved) {
39
- const fsPath = resolved.id;
40
- if (injectReset) {
41
- if (resetInjectPath.includes(id)) {
42
- setTimeout(() => {
43
- resolveCSSQueue.forEach((res) => {
44
- res();
45
- resolveCSSQueue.delete(res);
46
- });
47
- });
48
- resetCSSInjected = true;
49
- } else if (id.includes(".css") && !resetCSSInjected) {
50
- return new Promise((resolve2) => {
51
- resolveCSSQueue.add(() => {
52
- resolve2(fsPath);
53
- });
54
- });
55
- }
56
- }
57
- return fsPath;
58
- }
59
- }
60
24
  },
61
25
  load(id) {
62
26
  if (id.endsWith(UNO_INJECT_ID))
@@ -92,7 +56,6 @@ function UnoCSSAstroIntegration(options = {}, defaults) {
92
56
  updateConfig({
93
57
  vite: {
94
58
  plugins: [AstroVitePlugin({
95
- injectReset: !!injectReset,
96
59
  injects
97
60
  }), ...VitePlugin(options, defaults)]
98
61
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unocss/astro",
3
- "version": "0.56.5",
3
+ "version": "0.57.0",
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.56.5",
49
- "@unocss/reset": "0.56.5",
50
- "@unocss/vite": "0.56.5"
48
+ "@unocss/core": "0.57.0",
49
+ "@unocss/reset": "0.57.0",
50
+ "@unocss/vite": "0.57.0"
51
51
  },
52
52
  "devDependencies": {
53
- "astro": "^3.1.4"
53
+ "astro": "^3.3.2"
54
54
  },
55
55
  "scripts": {
56
56
  "build": "unbuild",