@unocss/vite 0.30.0 → 0.30.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.cjs CHANGED
@@ -370,8 +370,15 @@ function GlobalModeDevPlugin({ uno, tokens, onInvalidate, extract, filter }) {
370
370
  },
371
371
  enforce: "post",
372
372
  transform(code, id) {
373
- if (id.includes("@vite/client") || id.includes("vite/dist/client/client.mjs"))
374
- return code.replace("return hot", "hot.send = (data) => socket.send(data);return hot;");
373
+ if (id.includes("@vite/client") || id.includes("vite/dist/client/client.mjs")) {
374
+ return code.replace("return hot", [
375
+ "let __buffer = []",
376
+ "function sendBuffer() { if(socket.readyState !== 1) return; __buffer.forEach(msg => socket.send(msg)); __buffer = [] }",
377
+ 'socket.addEventListener("open", () => sendBuffer())',
378
+ "hot.send = (data) => {__buffer.push(data);sendBuffer()}",
379
+ "return hot"
380
+ ].join(";"));
381
+ }
375
382
  if (entries.has(getPath(id)) && code.includes("import.meta.hot")) {
376
383
  const snippet = `
377
384
  if (import.meta.hot) { try { import.meta.hot.send('${WS_EVENT_PREFIX}${lastServed}') } catch (e) { console.warn('[unocss-hmr]', e) } }`;
package/dist/index.mjs CHANGED
@@ -361,8 +361,15 @@ function GlobalModeDevPlugin({ uno, tokens, onInvalidate, extract, filter }) {
361
361
  },
362
362
  enforce: "post",
363
363
  transform(code, id) {
364
- if (id.includes("@vite/client") || id.includes("vite/dist/client/client.mjs"))
365
- return code.replace("return hot", "hot.send = (data) => socket.send(data);return hot;");
364
+ if (id.includes("@vite/client") || id.includes("vite/dist/client/client.mjs")) {
365
+ return code.replace("return hot", [
366
+ "let __buffer = []",
367
+ "function sendBuffer() { if(socket.readyState !== 1) return; __buffer.forEach(msg => socket.send(msg)); __buffer = [] }",
368
+ 'socket.addEventListener("open", () => sendBuffer())',
369
+ "hot.send = (data) => {__buffer.push(data);sendBuffer()}",
370
+ "return hot"
371
+ ].join(";"));
372
+ }
366
373
  if (entries.has(getPath(id)) && code.includes("import.meta.hot")) {
367
374
  const snippet = `
368
375
  if (import.meta.hot) { try { import.meta.hot.send('${WS_EVENT_PREFIX}${lastServed}') } catch (e) { console.warn('[unocss-hmr]', e) } }`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unocss/vite",
3
- "version": "0.30.0",
3
+ "version": "0.30.1",
4
4
  "description": "The Vite plugin for UnoCSS",
5
5
  "keywords": [
6
6
  "unocss",
@@ -35,11 +35,11 @@
35
35
  "sideEffects": false,
36
36
  "dependencies": {
37
37
  "@rollup/pluginutils": "^4.2.0",
38
- "@unocss/config": "0.30.0",
39
- "@unocss/core": "0.30.0",
40
- "@unocss/inspector": "0.30.0",
41
- "@unocss/scope": "0.30.0",
42
- "@unocss/transformer-directives": "0.30.0",
38
+ "@unocss/config": "0.30.1",
39
+ "@unocss/core": "0.30.1",
40
+ "@unocss/inspector": "0.30.1",
41
+ "@unocss/scope": "0.30.1",
42
+ "@unocss/transformer-directives": "0.30.1",
43
43
  "magic-string": "^0.26.1"
44
44
  },
45
45
  "devDependencies": {