@unocss/cli 0.61.4 → 0.61.6

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/cli.mjs CHANGED
@@ -2,7 +2,7 @@ import process from 'node:process';
2
2
  import { cac } from 'cac';
3
3
  import { loadConfig } from '@unocss/config';
4
4
  import { toArray } from '@unocss/core';
5
- import { b as build, v as version, h as handleError } from './shared/cli.5pHrQJLZ.mjs';
5
+ import { b as build, v as version, h as handleError } from './shared/cli.DnNH4kX3.mjs';
6
6
  import 'node:fs';
7
7
  import 'pathe';
8
8
  import 'fast-glob';
package/dist/index.mjs CHANGED
@@ -6,7 +6,7 @@ import 'consola';
6
6
  import 'colorette';
7
7
  import 'perfect-debounce';
8
8
  import '@unocss/core';
9
- export { b as build, r as resolveOptions } from './shared/cli.5pHrQJLZ.mjs';
9
+ export { b as build, r as resolveOptions } from './shared/cli.DnNH4kX3.mjs';
10
10
  import '@rollup/pluginutils';
11
11
  import '@unocss/config';
12
12
  import 'magic-string';
@@ -214,7 +214,7 @@ async function applyTransformers(ctx, original, id, enforce = "default") {
214
214
  }
215
215
  }
216
216
 
217
- const version = "0.61.4";
217
+ const version = "0.61.6";
218
218
 
219
219
  const defaultConfig = {
220
220
  envMode: "build",
@@ -335,51 +335,36 @@ async function build(_options) {
335
335
  }
336
336
  async function generate(options2) {
337
337
  const sourceCache = Array.from(fileCache).map(([id, code]) => ({ id, code }));
338
- const preTransform = await transformFiles(sourceCache, "pre");
339
- const defaultTransform = await transformFiles(preTransform);
340
- const postTransform = await transformFiles(defaultTransform, "post");
338
+ const afterPreTrans = await transformFiles(sourceCache, "pre");
339
+ const afterDefaultTrans = await transformFiles(afterPreTrans);
340
+ const afterPostTrans = await transformFiles(afterDefaultTrans, "post");
341
341
  if (options2.writeTransformed) {
342
342
  await Promise.all(
343
- postTransform.filter(({ transformedCode }) => !!transformedCode).map(({ transformedCode, id }) => new Promise((resolve2) => {
343
+ afterPostTrans.filter(({ transformedCode }) => !!transformedCode).map(async ({ transformedCode, id }) => {
344
344
  if (existsSync(id))
345
- promises.writeFile(id, transformedCode, "utf-8").then(resolve2);
346
- }))
345
+ await promises.writeFile(id, transformedCode, "utf-8");
346
+ })
347
347
  );
348
348
  }
349
- const firstIdType = postTransform[0].id.split(".").pop();
350
- const isSameFileType = postTransform.every(({ id }) => id.split(".").pop() === firstIdType);
351
- let css;
352
- let matched;
353
- if (isSameFileType) {
354
- const { css: _css, matched: _matched } = await ctx.uno.generate(
355
- [...postTransform.map(({ code, transformedCode }) => (transformedCode ?? code).replace(SKIP_COMMENT_RE, ""))].join("\n"),
349
+ const tokens = /* @__PURE__ */ new Set();
350
+ for (const file of afterPostTrans) {
351
+ const { matched: matched2 } = await ctx.uno.generate(
352
+ (file.transformedCode || file.code).replace(SKIP_COMMENT_RE, ""),
356
353
  {
357
- preflights: options2.preflights,
358
- minify: options2.minify,
359
- id: postTransform[0].id
354
+ preflights: false,
355
+ minify: true,
356
+ id: file.id
360
357
  }
361
358
  );
362
- css = _css;
363
- matched = _matched;
364
- } else {
365
- const result = await Promise.all(postTransform.map(({ code, transformedCode, id }) => ctx.uno.generate(transformedCode ?? code, {
366
- preflights: options2.preflights,
367
- minify: options2.minify,
368
- id
369
- })));
370
- const cssCollection = {};
371
- result.forEach(({ css: css2, layers }) => {
372
- css2.split(/\/\*.*?\*\//g).filter(Boolean).forEach((c, i) => {
373
- if (!cssCollection[layers[i]]) {
374
- cssCollection[layers[i]] = c.split("\n");
375
- } else {
376
- cssCollection[layers[i]] = [.../* @__PURE__ */ new Set([...cssCollection[layers[i]], ...c.split("\n")])];
377
- }
378
- });
379
- });
380
- css = result[0].layers.map((layer) => `/* layer: ${layer} */${cssCollection[layer].join("\n")}`).join("\n");
381
- matched = new Set(result.map(({ matched: matched2 }) => [...matched2]).flat());
359
+ matched2.forEach((i) => tokens.add(i));
382
360
  }
361
+ const { css, matched } = await ctx.uno.generate(
362
+ tokens,
363
+ {
364
+ preflights: options2.preflights,
365
+ minify: options2.minify
366
+ }
367
+ );
383
368
  if (options2.stdout) {
384
369
  process$1.stdout.write(css);
385
370
  return;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@unocss/cli",
3
3
  "type": "module",
4
- "version": "0.61.4",
4
+ "version": "0.61.6",
5
5
  "description": "CLI for UnoCSS",
6
6
  "author": {
7
7
  "name": "Johann Schopplich",
@@ -50,9 +50,9 @@
50
50
  "magic-string": "^0.30.10",
51
51
  "pathe": "^1.1.2",
52
52
  "perfect-debounce": "^1.0.0",
53
- "@unocss/config": "0.61.4",
54
- "@unocss/core": "0.61.4",
55
- "@unocss/preset-uno": "0.61.4"
53
+ "@unocss/core": "0.61.6",
54
+ "@unocss/preset-uno": "0.61.6",
55
+ "@unocss/config": "0.61.6"
56
56
  },
57
57
  "scripts": {
58
58
  "build": "unbuild",