@unocss/vite 0.65.0 → 0.65.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.d.mts CHANGED
@@ -56,7 +56,7 @@ interface VitePluginConfig<Theme extends object = object> extends UserConfig<The
56
56
  fetchMode?: 'cors' | 'navigate' | 'no-cors' | 'same-origin';
57
57
  }
58
58
 
59
- declare function ChunkModeBuildPlugin({ uno, filter }: UnocssPluginContext): Plugin;
59
+ declare function ChunkModeBuildPlugin(ctx: UnocssPluginContext): Plugin;
60
60
 
61
61
  declare function GlobalModeBuildPlugin(ctx: UnocssPluginContext<VitePluginConfig>): Plugin[];
62
62
 
@@ -64,9 +64,9 @@ declare function GlobalModeDevPlugin(ctx: UnocssPluginContext): Plugin[];
64
64
 
65
65
  declare function GlobalModePlugin(ctx: UnocssPluginContext): vite.Plugin<any>[];
66
66
 
67
- declare function PerModuleModePlugin({ uno, filter }: UnocssPluginContext): Plugin[];
67
+ declare function PerModuleModePlugin(ctx: UnocssPluginContext): Plugin[];
68
68
 
69
- declare function VueScopedPlugin({ uno, ready }: UnocssPluginContext): Plugin;
69
+ declare function VueScopedPlugin(ctx: UnocssPluginContext): Plugin;
70
70
 
71
71
  declare function defineConfig<Theme extends object>(config: VitePluginConfig<Theme>): VitePluginConfig<Theme>;
72
72
  interface UnocssVitePluginAPI {
package/dist/index.d.ts CHANGED
@@ -56,7 +56,7 @@ interface VitePluginConfig<Theme extends object = object> extends UserConfig<The
56
56
  fetchMode?: 'cors' | 'navigate' | 'no-cors' | 'same-origin';
57
57
  }
58
58
 
59
- declare function ChunkModeBuildPlugin({ uno, filter }: UnocssPluginContext): Plugin;
59
+ declare function ChunkModeBuildPlugin(ctx: UnocssPluginContext): Plugin;
60
60
 
61
61
  declare function GlobalModeBuildPlugin(ctx: UnocssPluginContext<VitePluginConfig>): Plugin[];
62
62
 
@@ -64,9 +64,9 @@ declare function GlobalModeDevPlugin(ctx: UnocssPluginContext): Plugin[];
64
64
 
65
65
  declare function GlobalModePlugin(ctx: UnocssPluginContext): vite.Plugin<any>[];
66
66
 
67
- declare function PerModuleModePlugin({ uno, filter }: UnocssPluginContext): Plugin[];
67
+ declare function PerModuleModePlugin(ctx: UnocssPluginContext): Plugin[];
68
68
 
69
- declare function VueScopedPlugin({ uno, ready }: UnocssPluginContext): Plugin;
69
+ declare function VueScopedPlugin(ctx: UnocssPluginContext): Plugin;
70
70
 
71
71
  declare function defineConfig<Theme extends object>(config: VitePluginConfig<Theme>): VitePluginConfig<Theme>;
72
72
  interface UnocssVitePluginAPI {
package/dist/index.mjs CHANGED
@@ -396,7 +396,7 @@ function getHashPlaceholder(hash) {
396
396
  return `#--unocss-hash--{content:"${hash}"}`;
397
397
  }
398
398
 
399
- function ChunkModeBuildPlugin({ uno, filter }) {
399
+ function ChunkModeBuildPlugin(ctx) {
400
400
  let cssPlugin;
401
401
  const files = {};
402
402
  return {
@@ -406,8 +406,9 @@ function ChunkModeBuildPlugin({ uno, filter }) {
406
406
  configResolved(config) {
407
407
  cssPlugin = config.plugins.find((i) => i.name === "vite:css-post");
408
408
  },
409
- transform(code, id) {
410
- if (!filter(code, id))
409
+ async transform(code, id) {
410
+ await ctx.ready;
411
+ if (!ctx.filter(code, id))
411
412
  return;
412
413
  files[id] = code;
413
414
  return null;
@@ -416,9 +417,10 @@ function ChunkModeBuildPlugin({ uno, filter }) {
416
417
  const chunks = Object.keys(chunk.modules).map((i) => files[i]).filter(Boolean);
417
418
  if (!chunks.length)
418
419
  return null;
420
+ await ctx.ready;
419
421
  const tokens = /* @__PURE__ */ new Set();
420
- await Promise.all(chunks.map((c) => uno.applyExtractors(c, void 0, tokens)));
421
- const { css } = await uno.generate(tokens);
422
+ await Promise.all(chunks.map((c) => ctx.uno.applyExtractors(c, void 0, tokens)));
423
+ const { css } = await ctx.uno.generate(tokens);
422
424
  const fakeCssId = `${chunk.fileName}.css`;
423
425
  await cssPlugin.transform(css, fakeCssId);
424
426
  chunk.modules[fakeCssId] = {
@@ -431,7 +433,8 @@ function ChunkModeBuildPlugin({ uno, filter }) {
431
433
  return null;
432
434
  },
433
435
  async transformIndexHtml(code) {
434
- const { css } = await uno.generate(code);
436
+ await ctx.ready;
437
+ const { css } = await ctx.uno.generate(code);
435
438
  if (css)
436
439
  return `${code}<style>${css}</style>`;
437
440
  }
@@ -973,7 +976,7 @@ function GlobalModePlugin(ctx) {
973
976
 
974
977
  const VIRTUAL_PREFIX = "/@unocss/";
975
978
  const SCOPE_IMPORT_RE = / from (['"])(@unocss\/scope)\1/;
976
- function PerModuleModePlugin({ uno, filter }) {
979
+ function PerModuleModePlugin(ctx) {
977
980
  const moduleMap = /* @__PURE__ */ new Map();
978
981
  let server;
979
982
  const invalidate = (hash) => {
@@ -1007,7 +1010,8 @@ function PerModuleModePlugin({ uno, filter }) {
1007
1010
  const layer = resolveLayer(getPath(id));
1008
1011
  if (!layer)
1009
1012
  return null;
1010
- const { css } = await uno.generate("", { preflights: true });
1013
+ await ctx.ready;
1014
+ const { css } = await ctx.uno.generate("", { preflights: true });
1011
1015
  if (!css)
1012
1016
  return null;
1013
1017
  return {
@@ -1016,11 +1020,12 @@ function PerModuleModePlugin({ uno, filter }) {
1016
1020
  };
1017
1021
  },
1018
1022
  async transform(code, id) {
1019
- if (!filter(code, id))
1023
+ await ctx.ready;
1024
+ if (!ctx.filter(code, id))
1020
1025
  return;
1021
1026
  const hash = getHash(id);
1022
1027
  const hasScope = SCOPE_IMPORT_RE.test(code);
1023
- const { css } = await uno.generate(code, { id, scope: hasScope ? `.${hash}` : void 0, preflights: false });
1028
+ const { css } = await ctx.uno.generate(code, { id, scope: hasScope ? `.${hash}` : void 0, preflights: false });
1024
1029
  if (!css && !hasScope)
1025
1030
  return null;
1026
1031
  if (hasScope)
@@ -1037,7 +1042,8 @@ function PerModuleModePlugin({ uno, filter }) {
1037
1042
  server = _server;
1038
1043
  },
1039
1044
  async transform(code, id) {
1040
- if (!filter(code, id))
1045
+ await ctx.ready;
1046
+ if (!ctx.filter(code, id))
1041
1047
  return;
1042
1048
  const hash = getHash(id);
1043
1049
  invalidate(hash);
@@ -1067,7 +1073,7 @@ ${css}`;
1067
1073
  ];
1068
1074
  }
1069
1075
 
1070
- function ShadowDomModuleModePlugin({ uno }) {
1076
+ function ShadowDomModuleModePlugin(ctx) {
1071
1077
  const partExtractorRegex = /^part-\[(.+)\]:/;
1072
1078
  const nameRegexp = /<([^\s^!>]+)\s*([^>]*)>/;
1073
1079
  const vueSFCStyleRE = /<style[^>]*>[\s\S]*@unocss-placeholder[\s\S]*<\/style>/;
@@ -1106,7 +1112,8 @@ function ShadowDomModuleModePlugin({ uno }) {
1106
1112
  const transformWebComponent = async (code, id) => {
1107
1113
  if (!code.match(CSS_PLACEHOLDER))
1108
1114
  return code;
1109
- let { css, matched } = await uno.generate(code, {
1115
+ await ctx.ready;
1116
+ let { css, matched } = await ctx.uno.generate(code, {
1110
1117
  preflights: true,
1111
1118
  safelist: true
1112
1119
  });
@@ -1162,20 +1169,21 @@ function ShadowDomModuleModePlugin({ uno }) {
1162
1169
  map: null
1163
1170
  };
1164
1171
  },
1165
- handleHotUpdate(ctx) {
1166
- const read = ctx.read;
1167
- ctx.read = async () => {
1172
+ handleHotUpdate(ctx2) {
1173
+ const read = ctx2.read;
1174
+ ctx2.read = async () => {
1168
1175
  const code = await read();
1169
- return await transformWebComponent(code, ctx.file);
1176
+ return await transformWebComponent(code, ctx2.file);
1170
1177
  };
1171
1178
  }
1172
1179
  };
1173
1180
  }
1174
1181
 
1175
- function VueScopedPlugin({ uno, ready }) {
1182
+ function VueScopedPlugin(ctx) {
1176
1183
  let filter = createFilter([/\.vue$/], defaultPipelineExclude);
1177
1184
  async function transformSFC(code) {
1178
- const { css } = await uno.generate(code);
1185
+ await ctx.ready;
1186
+ const { css } = await ctx.uno.generate(code);
1179
1187
  if (!css)
1180
1188
  return null;
1181
1189
  return `${code}
@@ -1185,7 +1193,7 @@ function VueScopedPlugin({ uno, ready }) {
1185
1193
  name: "unocss:vue-scoped",
1186
1194
  enforce: "pre",
1187
1195
  async configResolved() {
1188
- const { config } = await ready;
1196
+ const { config } = await ctx.ready;
1189
1197
  filter = config.content?.pipeline === false ? () => false : createFilter(
1190
1198
  config.content?.pipeline?.include ?? config.include ?? [/\.vue$/],
1191
1199
  config.content?.pipeline?.exclude ?? config.exclude ?? defaultPipelineExclude
@@ -1202,10 +1210,10 @@ function VueScopedPlugin({ uno, ready }) {
1202
1210
  };
1203
1211
  }
1204
1212
  },
1205
- handleHotUpdate(ctx) {
1206
- const read = ctx.read;
1207
- if (filter(ctx.file)) {
1208
- ctx.read = async () => {
1213
+ handleHotUpdate(ctx2) {
1214
+ const read = ctx2.read;
1215
+ if (filter(ctx2.file)) {
1216
+ ctx2.read = async () => {
1209
1217
  const code = await read();
1210
1218
  return await transformSFC(code) || code;
1211
1219
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@unocss/vite",
3
3
  "type": "module",
4
- "version": "0.65.0",
4
+ "version": "0.65.2",
5
5
  "description": "The Vite plugin for UnoCSS",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -50,20 +50,21 @@
50
50
  },
51
51
  "dependencies": {
52
52
  "@ampproject/remapping": "^2.3.0",
53
- "@rollup/pluginutils": "^5.1.3",
53
+ "@rollup/pluginutils": "^5.1.4",
54
54
  "chokidar": "^3.6.0",
55
- "magic-string": "^0.30.12",
55
+ "magic-string": "^0.30.17",
56
56
  "tinyglobby": "^0.2.10",
57
- "@unocss/inspector": "0.65.0",
58
- "@unocss/config": "0.65.0",
59
- "@unocss/core": "0.65.0"
57
+ "@unocss/config": "0.65.2",
58
+ "@unocss/core": "0.65.2",
59
+ "@unocss/inspector": "0.65.2"
60
60
  },
61
61
  "devDependencies": {
62
- "vite": "^6.0.0",
63
- "@unocss/shared-integration": "0.65.0"
62
+ "vite": "^6.0.3",
63
+ "@unocss/shared-integration": "0.65.2"
64
64
  },
65
65
  "scripts": {
66
66
  "build": "unbuild",
67
- "stub": "unbuild --stub"
67
+ "stub": "unbuild --stub",
68
+ "test:attw": "attw --pack --config-path ../../.attw-esm-only.json"
68
69
  }
69
70
  }