@unocss/core 0.13.1 → 0.14.3

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.
@@ -1,44 +1,7 @@
1
- var __defProp = Object.defineProperty;
2
- var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
3
- var __export = (target, all) => {
4
- __markAsModule(target);
5
- for (var name in all)
6
- __defProp(target, name, { get: all[name], enumerable: true });
7
- };
1
+ 'use strict';
8
2
 
9
- // src/index.ts
10
- __export(exports, {
11
- BetterMap: () => BetterMap,
12
- TwoKeyMap: () => TwoKeyMap,
13
- UnoGenerator: () => UnoGenerator,
14
- attributifyRE: () => attributifyRE,
15
- createGenerator: () => createGenerator,
16
- e: () => e,
17
- entriesToCss: () => entriesToCss,
18
- escapeRegExp: () => escapeRegExp,
19
- escapeSelector: () => escapeSelector,
20
- expandVariantGroup: () => expandVariantGroup,
21
- extractorSplit: () => extractorSplit,
22
- hasScopePlaceholder: () => hasScopePlaceholder,
23
- hex2rgba: () => hex2rgba,
24
- isAttributifySelector: () => isAttributifySelector,
25
- isObject: () => isObject,
26
- isRawUtil: () => isRawUtil,
27
- isStaticRule: () => isStaticRule,
28
- isStaticShortcut: () => isStaticShortcut,
29
- isValidSelector: () => isValidSelector,
30
- mergeDeep: () => mergeDeep,
31
- mergeSet: () => mergeSet,
32
- normalizeVariant: () => normalizeVariant,
33
- regexClassGroup: () => regexClassGroup,
34
- toArray: () => toArray,
35
- uniq: () => uniq,
36
- validateFilterRE: () => validateFilterRE,
37
- warnOnce: () => warnOnce,
38
- withLayer: () => withLayer
39
- });
3
+ Object.defineProperty(exports, '__esModule', { value: true });
40
4
 
41
- // src/utils/escape.ts
42
5
  function escapeRegExp(string) {
43
6
  return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
44
7
  }
@@ -74,13 +37,36 @@ function escapeSelector(str) {
74
37
  }
75
38
  return result;
76
39
  }
77
- var e = escapeSelector;
40
+ const e = escapeSelector;
78
41
 
79
- // src/utils/object.ts
42
+ function normalizeCSSEntries(obj) {
43
+ return (!Array.isArray(obj) ? Object.entries(obj) : obj).filter((i) => i[1] != null);
44
+ }
45
+ function normalizeCSSValues(obj) {
46
+ if (Array.isArray(obj)) {
47
+ if (obj.find((i) => !Array.isArray(i) || Array.isArray(i[0])))
48
+ return obj.map((i) => normalizeCSSEntries(i));
49
+ else
50
+ return [obj];
51
+ } else {
52
+ return [normalizeCSSEntries(obj)];
53
+ }
54
+ }
55
+ function clearIdenticalEntries(entry) {
56
+ return entry.filter(([k, v], idx) => {
57
+ if (k.startsWith("$$"))
58
+ return false;
59
+ for (let i = idx - 1; i >= 0; i--) {
60
+ if (entry[i][0] === k && entry[i][1] === v)
61
+ return false;
62
+ }
63
+ return true;
64
+ });
65
+ }
80
66
  function entriesToCss(arr) {
81
67
  if (arr == null)
82
68
  return "";
83
- return arr.map(([key, value]) => value != null ? `${key}:${value};` : void 0).filter(Boolean).join("");
69
+ return clearIdenticalEntries(arr).map(([key, value]) => value != null ? `${key}:${value};` : void 0).filter(Boolean).join("");
84
70
  }
85
71
  function isObject(item) {
86
72
  return item && typeof item === "object" && !Array.isArray(item);
@@ -114,7 +100,6 @@ function isStaticShortcut(sc) {
114
100
  return typeof sc[0] === "string";
115
101
  }
116
102
 
117
- // src/utils/basic.ts
118
103
  function toArray(value = []) {
119
104
  return Array.isArray(value) ? value : [value];
120
105
  }
@@ -126,8 +111,7 @@ function mergeSet(target, append) {
126
111
  return target;
127
112
  }
128
113
 
129
- // src/utils/colors.ts
130
- var hexRE = /^#?([\da-f]+)$/i;
114
+ const hexRE = /^#?([\da-f]+)$/i;
131
115
  function hex2rgba(hex = "") {
132
116
  const [, body] = hex.match(hexRE) || [];
133
117
  if (!body)
@@ -149,9 +133,8 @@ function hex2rgba(hex = "") {
149
133
  }
150
134
  }
151
135
 
152
- // src/utils/helpers.ts
153
- var attributifyRE = /^\[(.+?)~?="(.*)"\]$/;
154
- var validateFilterRE = /[a-z?]/;
136
+ const attributifyRE = /^\[(.+?)~?="(.*)"\]$/;
137
+ const validateFilterRE = /(?!\d|-{2}|-\d)[a-zA-Z0-9\u00A0-\uFFFF-_:%-?]/;
155
138
  function isAttributifySelector(selector) {
156
139
  return selector.match(attributifyRE);
157
140
  }
@@ -164,9 +147,11 @@ function normalizeVariant(variant) {
164
147
  function isRawUtil(util) {
165
148
  return util.length === 3;
166
149
  }
150
+ function notNull(value) {
151
+ return value != null;
152
+ }
167
153
 
168
- // src/utils/map.ts
169
- var TwoKeyMap = class {
154
+ class TwoKeyMap {
170
155
  constructor() {
171
156
  this._map = new Map();
172
157
  }
@@ -195,12 +180,10 @@ var TwoKeyMap = class {
195
180
  return this;
196
181
  }
197
182
  has(key1, key2) {
198
- var _a;
199
- return (_a = this._map.get(key1)) == null ? void 0 : _a.has(key2);
183
+ return this._map.get(key1)?.has(key2);
200
184
  }
201
185
  delete(key1, key2) {
202
- var _a;
203
- return ((_a = this._map.get(key1)) == null ? void 0 : _a.delete(key2)) || false;
186
+ return this._map.get(key1)?.delete(key2) || false;
204
187
  }
205
188
  deleteTop(key1) {
206
189
  return this._map.delete(key1);
@@ -210,8 +193,8 @@ var TwoKeyMap = class {
210
193
  return fn(v, k1, k2);
211
194
  }));
212
195
  }
213
- };
214
- var BetterMap = class extends Map {
196
+ }
197
+ class BetterMap extends Map {
215
198
  map(mapFn) {
216
199
  const result = [];
217
200
  this.forEach((v, k) => {
@@ -219,9 +202,8 @@ var BetterMap = class extends Map {
219
202
  });
220
203
  return result;
221
204
  }
222
- };
205
+ }
223
206
 
224
- // src/utils/layer.ts
225
207
  function withLayer(layer, rules) {
226
208
  rules.forEach((r) => {
227
209
  if (!r[2])
@@ -232,8 +214,7 @@ function withLayer(layer, rules) {
232
214
  return rules;
233
215
  }
234
216
 
235
- // src/utils/variantGroup.ts
236
- var regexClassGroup = /([!\w+:_/-]+?)([:-])\(((?:[!\w\s:/\\,%#.$-]|\[.*?\])*?)\)/gm;
217
+ const regexClassGroup = /([!\w+:_/-]+?)([:-])\(((?:[!\w\s:/\\,%#.$-]|\[.*?\])*?)\)/gm;
237
218
  function expandVariantGroup(str) {
238
219
  const replaces = [];
239
220
  let match;
@@ -251,8 +232,7 @@ function expandVariantGroup(str) {
251
232
  return result;
252
233
  }
253
234
 
254
- // src/utils/warn.ts
255
- var warned = new Set();
235
+ const warned = new Set();
256
236
  function warnOnce(msg) {
257
237
  if (warned.has(msg))
258
238
  return;
@@ -260,8 +240,7 @@ function warnOnce(msg) {
260
240
  warned.add(msg);
261
241
  }
262
242
 
263
- // src/extractors/split.ts
264
- var extractorSplit = {
243
+ const extractorSplit = {
265
244
  name: "split",
266
245
  order: 0,
267
246
  extract({ code }) {
@@ -269,7 +248,6 @@ var extractorSplit = {
269
248
  }
270
249
  };
271
250
 
272
- // src/config.ts
273
251
  function resolveShortcuts(shortcuts) {
274
252
  return toArray(shortcuts).flatMap((s) => {
275
253
  if (Array.isArray(s))
@@ -277,7 +255,7 @@ function resolveShortcuts(shortcuts) {
277
255
  return Object.entries(s);
278
256
  });
279
257
  }
280
- var defaultLayers = {
258
+ const defaultLayers = {
281
259
  shortcuts: -1,
282
260
  default: 0
283
261
  };
@@ -335,11 +313,9 @@ function resolveConfig(userConfig = {}, defaults = {}) {
335
313
  };
336
314
  }
337
315
 
338
- // package.json
339
- var version = "0.13.1";
316
+ const version = "0.14.3";
340
317
 
341
- // src/generator/index.ts
342
- var UnoGenerator = class {
318
+ class UnoGenerator {
343
319
  constructor(userConfig = {}, defaults = {}) {
344
320
  this.userConfig = userConfig;
345
321
  this.defaults = defaults;
@@ -370,7 +346,7 @@ var UnoGenerator = class {
370
346
  };
371
347
  for (const extractor of this.config.extractors) {
372
348
  const result = await extractor.extract(context);
373
- result == null ? void 0 : result.forEach((t) => set.add(t));
349
+ result?.forEach((t) => set.add(t));
374
350
  }
375
351
  return set;
376
352
  }
@@ -389,7 +365,6 @@ var UnoGenerator = class {
389
365
  const matched = new Set();
390
366
  const sheet = new Map();
391
367
  const hit = (raw, payload) => {
392
- var _a;
393
368
  this._cache.set(raw, payload);
394
369
  matched.add(raw);
395
370
  for (const item of payload) {
@@ -397,7 +372,7 @@ var UnoGenerator = class {
397
372
  if (!sheet.has(parent))
398
373
  sheet.set(parent, []);
399
374
  sheet.get(parent).push(item);
400
- if ((_a = item[4]) == null ? void 0 : _a.layer)
375
+ if (item[4]?.layer)
401
376
  layerSet.add(item[4].layer);
402
377
  }
403
378
  };
@@ -433,12 +408,12 @@ var UnoGenerator = class {
433
408
  const expanded = this.expandShortcut(applied[1], context);
434
409
  if (expanded) {
435
410
  const utils = await this.stringifyShortcuts(applied, context, expanded[0], expanded[1]);
436
- if (utils == null ? void 0 : utils.length)
411
+ if (utils?.length)
437
412
  return hit(raw, utils);
438
413
  } else {
439
- const util = this.stringifyUtil(await this.parseUtil(applied, context));
440
- if (util)
441
- return hit(raw, [util]);
414
+ const utils = (await this.parseUtil(applied, context))?.map((i) => this.stringifyUtil(i)).filter(notNull);
415
+ if (utils?.length)
416
+ return hit(raw, utils);
442
417
  }
443
418
  this._cache.set(raw, null);
444
419
  }));
@@ -449,36 +424,27 @@ var UnoGenerator = class {
449
424
  });
450
425
  }
451
426
  const layerCache = {};
452
- const layers = this.config.sortLayers(Array.from(layerSet).sort((a, b) => {
453
- var _a, _b;
454
- return ((_a = this.config.layers[a]) != null ? _a : 0) - ((_b = this.config.layers[b]) != null ? _b : 0) || a.localeCompare(b);
455
- }));
427
+ const layers = this.config.sortLayers(Array.from(layerSet).sort((a, b) => (this.config.layers[a] ?? 0) - (this.config.layers[b] ?? 0) || a.localeCompare(b)));
456
428
  const getLayer = (layer) => {
457
429
  if (layerCache[layer])
458
430
  return layerCache[layer];
459
431
  let css = Array.from(sheet).sort((a, b) => (this.parentOrders.get(a[0]) || 0) - (this.parentOrders.get(b[0]) || 0)).map(([parent, items]) => {
460
432
  const size = items.length;
461
- const sorted = items.filter((i) => {
462
- var _a;
463
- return (((_a = i[4]) == null ? void 0 : _a.layer) || "default") === layer;
464
- }).sort((a, b) => {
465
- var _a;
466
- return a[0] - b[0] || ((_a = a[1]) == null ? void 0 : _a.localeCompare(b[1] || "")) || 0;
467
- }).map((a) => [a[1] ? applyScope(a[1], scope) : a[1], a[2]]);
433
+ const sorted = items.filter((i) => (i[4]?.layer || "default") === layer).sort((a, b) => a[0] - b[0] || a[1]?.localeCompare(b[1] || "") || 0).map((a) => [a[1] ? applyScope(a[1], scope) : a[1], a[2]]);
468
434
  if (!sorted.length)
469
435
  return void 0;
470
- const rules = sorted.map(([selector, body], idx) => {
436
+ const rules = sorted.reverse().map(([selector, body], idx) => {
471
437
  if (selector && this.config.mergeSelectors) {
472
- for (let i = size - 1; i > idx; i--) {
438
+ for (let i = idx + 1; i < size; i++) {
473
439
  const current = sorted[i];
474
440
  if (current && current[0] && current[1] === body) {
475
- current[0] = `${selector},${current[0]}`;
441
+ current[0] = `${current[0]},${selector}`;
476
442
  return null;
477
443
  }
478
444
  }
479
445
  }
480
446
  return selector ? `${selector}{${body}}` : body;
481
- }).filter(Boolean).join(nl);
447
+ }).filter(Boolean).reverse().join(nl);
482
448
  return parent ? `${parent}{${nl}${rules}${nl}}` : rules;
483
449
  }).filter(Boolean).join(nl);
484
450
  if (preflights) {
@@ -490,7 +456,7 @@ var UnoGenerator = class {
490
456
  return layerCache[layer] = !minify && css ? `/* layer: ${layer} */${nl}${css}` : css;
491
457
  };
492
458
  const getLayers = (includes = layers, excludes) => {
493
- return includes.filter((i) => !(excludes == null ? void 0 : excludes.includes(i))).map((i) => getLayer(i) || "").filter(Boolean).join(nl);
459
+ return includes.filter((i) => !excludes?.includes(i)).map((i) => getLayer(i) || "").filter(Boolean).join(nl);
494
460
  };
495
461
  return {
496
462
  get css() {
@@ -535,20 +501,15 @@ var UnoGenerator = class {
535
501
  return [raw, processed, handlers];
536
502
  }
537
503
  applyVariants(parsed, variantHandlers = parsed[4], raw = parsed[1]) {
504
+ const entries = variantHandlers.reduce((p, v) => v.body?.(p) || p, parsed[2]);
538
505
  return [
539
- variantHandlers.reduce((p, v) => {
540
- var _a;
541
- return ((_a = v.selector) == null ? void 0 : _a.call(v, p)) || p;
542
- }, toEscapedSelector(raw)),
543
- variantHandlers.reduce((p, v) => {
544
- var _a;
545
- return ((_a = v.body) == null ? void 0 : _a.call(v, p)) || p;
546
- }, parsed[2]),
506
+ variantHandlers.reduce((p, v) => v.selector?.(p, entries) || p, toEscapedSelector(raw)),
507
+ entries,
547
508
  variantHandlers.reduce((p, v) => Array.isArray(v.parent) ? v.parent[0] : v.parent || p, void 0)
548
509
  ];
549
510
  }
550
511
  constructCustomCSS(context, body, overrideSelector) {
551
- body = normalizeEntries(body);
512
+ body = normalizeCSSEntries(body);
552
513
  const [selector, entries, mediaQuery] = this.applyVariants([0, overrideSelector || context.rawSelector, body, void 0, context.variantHandlers]);
553
514
  const cssBody = `${selector}{${entriesToCss(entries)}}`;
554
515
  if (mediaQuery)
@@ -556,12 +517,11 @@ var UnoGenerator = class {
556
517
  return cssBody;
557
518
  }
558
519
  async parseUtil(input, context, internal = false) {
559
- var _a, _b;
560
520
  const [raw, processed, variantHandlers] = typeof input === "string" ? this.matchVariants(input) : input;
561
521
  const staticMatch = this.config.rulesStaticMap[processed];
562
522
  if (staticMatch) {
563
- if (staticMatch[1] && (internal || !((_a = staticMatch[2]) == null ? void 0 : _a.internal)))
564
- return [staticMatch[0], raw, normalizeEntries(staticMatch[1]), staticMatch[2], variantHandlers];
523
+ if (staticMatch[1] && (internal || !staticMatch[2]?.internal))
524
+ return [[staticMatch[0], raw, normalizeCSSEntries(staticMatch[1]), staticMatch[2], variantHandlers]];
565
525
  }
566
526
  context.variantHandlers = variantHandlers;
567
527
  const { rulesDynamic, rulesSize } = this.config;
@@ -569,7 +529,7 @@ var UnoGenerator = class {
569
529
  const rule = rulesDynamic[i];
570
530
  if (!rule)
571
531
  continue;
572
- if (((_b = rule[2]) == null ? void 0 : _b.internal) && !internal)
532
+ if (rule[2]?.internal && !internal)
573
533
  continue;
574
534
  const [matcher, handler, meta] = rule;
575
535
  const match = processed.match(matcher);
@@ -579,10 +539,10 @@ var UnoGenerator = class {
579
539
  if (!result)
580
540
  continue;
581
541
  if (typeof result === "string")
582
- return [i, result, meta];
583
- const entries = normalizeEntries(result).filter((i2) => i2[1] != null);
542
+ return [[i, result, meta]];
543
+ const entries = normalizeCSSValues(result).filter((i2) => i2.length);
584
544
  if (entries.length)
585
- return [i, raw, entries, meta, variantHandlers];
545
+ return entries.map((e2) => [i, raw, e2, meta, variantHandlers]);
586
546
  }
587
547
  }
588
548
  stringifyUtil(parsed) {
@@ -623,10 +583,7 @@ var UnoGenerator = class {
623
583
  if (!result)
624
584
  return;
625
585
  return [
626
- result.flatMap((r) => {
627
- var _a;
628
- return ((_a = this.expandShortcut(r, context, depth - 1)) == null ? void 0 : _a[0]) || [r];
629
- }),
586
+ result.flatMap((r) => this.expandShortcut(r, context, depth - 1)?.[0] || [r]),
630
587
  meta
631
588
  ];
632
589
  }
@@ -636,8 +593,8 @@ var UnoGenerator = class {
636
593
  const result = await this.parseUtil(i, context, true);
637
594
  if (!result)
638
595
  warnOnce(`unmatched utility "${i}" in shortcut "${parent[1]}"`);
639
- return result;
640
- }))).filter(Boolean).sort((a, b) => a[0] - b[0]);
596
+ return result || [];
597
+ }))).flat(1).filter(Boolean).sort((a, b) => a[0] - b[0]);
641
598
  const [raw, , parentVariants] = parent;
642
599
  for (const item of parsed) {
643
600
  if (isRawUtil(item))
@@ -658,12 +615,12 @@ var UnoGenerator = class {
658
615
  isBlocked(raw) {
659
616
  return !raw || this.config.blocklist.some((e2) => typeof e2 === "string" ? e2 === raw : e2.test(raw));
660
617
  }
661
- };
618
+ }
662
619
  function createGenerator(config, defaults) {
663
620
  return new UnoGenerator(config, defaults);
664
621
  }
665
- var reScopePlaceholder = / \$\$ /;
666
- var hasScopePlaceholder = (css) => css.match(reScopePlaceholder);
622
+ const reScopePlaceholder = / \$\$ /;
623
+ const hasScopePlaceholder = (css) => css.match(reScopePlaceholder);
667
624
  function applyScope(css, scope) {
668
625
  if (hasScopePlaceholder(css))
669
626
  return css.replace(reScopePlaceholder, scope ? ` ${scope} ` : " ");
@@ -676,37 +633,36 @@ function toEscapedSelector(raw) {
676
633
  else
677
634
  return `.${e(raw)}`;
678
635
  }
679
- function normalizeEntries(obj) {
680
- return !Array.isArray(obj) ? Object.entries(obj) : obj;
681
- }
682
- // Annotate the CommonJS export names for ESM import in node:
683
- 0 && (module.exports = {
684
- BetterMap,
685
- TwoKeyMap,
686
- UnoGenerator,
687
- attributifyRE,
688
- createGenerator,
689
- e,
690
- entriesToCss,
691
- escapeRegExp,
692
- escapeSelector,
693
- expandVariantGroup,
694
- extractorSplit,
695
- hasScopePlaceholder,
696
- hex2rgba,
697
- isAttributifySelector,
698
- isObject,
699
- isRawUtil,
700
- isStaticRule,
701
- isStaticShortcut,
702
- isValidSelector,
703
- mergeDeep,
704
- mergeSet,
705
- normalizeVariant,
706
- regexClassGroup,
707
- toArray,
708
- uniq,
709
- validateFilterRE,
710
- warnOnce,
711
- withLayer
712
- });
636
+
637
+ exports.BetterMap = BetterMap;
638
+ exports.TwoKeyMap = TwoKeyMap;
639
+ exports.UnoGenerator = UnoGenerator;
640
+ exports.attributifyRE = attributifyRE;
641
+ exports.clearIdenticalEntries = clearIdenticalEntries;
642
+ exports.createGenerator = createGenerator;
643
+ exports.e = e;
644
+ exports.entriesToCss = entriesToCss;
645
+ exports.escapeRegExp = escapeRegExp;
646
+ exports.escapeSelector = escapeSelector;
647
+ exports.expandVariantGroup = expandVariantGroup;
648
+ exports.extractorSplit = extractorSplit;
649
+ exports.hasScopePlaceholder = hasScopePlaceholder;
650
+ exports.hex2rgba = hex2rgba;
651
+ exports.isAttributifySelector = isAttributifySelector;
652
+ exports.isObject = isObject;
653
+ exports.isRawUtil = isRawUtil;
654
+ exports.isStaticRule = isStaticRule;
655
+ exports.isStaticShortcut = isStaticShortcut;
656
+ exports.isValidSelector = isValidSelector;
657
+ exports.mergeDeep = mergeDeep;
658
+ exports.mergeSet = mergeSet;
659
+ exports.normalizeCSSEntries = normalizeCSSEntries;
660
+ exports.normalizeCSSValues = normalizeCSSValues;
661
+ exports.normalizeVariant = normalizeVariant;
662
+ exports.notNull = notNull;
663
+ exports.regexClassGroup = regexClassGroup;
664
+ exports.toArray = toArray;
665
+ exports.uniq = uniq;
666
+ exports.validateFilterRE = validateFilterRE;
667
+ exports.warnOnce = warnOnce;
668
+ exports.withLayer = withLayer;
package/dist/index.d.ts CHANGED
@@ -13,7 +13,7 @@ declare class UnoGenerator {
13
13
  matchVariants(raw: string, current?: string): VariantMatchedResult;
14
14
  applyVariants(parsed: ParsedUtil, variantHandlers?: VariantHandler[], raw?: string): readonly [string, CSSEntries, string | undefined];
15
15
  constructCustomCSS(context: Readonly<RuleContext>, body: CSSObject | CSSEntries, overrideSelector?: string): string;
16
- parseUtil(input: string | VariantMatchedResult, context: RuleContext, internal?: boolean): Promise<ParsedUtil | RawUtil | undefined>;
16
+ parseUtil(input: string | VariantMatchedResult, context: RuleContext, internal?: boolean): Promise<ParsedUtil[] | RawUtil[] | undefined>;
17
17
  stringifyUtil(parsed?: ParsedUtil | RawUtil): StringifiedUtil | undefined;
18
18
  expandShortcut(processed: string, context: RuleContext, depth?: number): [string[], RuleMeta | undefined] | undefined;
19
19
  stringifyShortcuts(parent: VariantMatchedResult, context: RuleContext, expanded: string[], meta?: RuleMeta): Promise<StringifiedUtil[] | undefined>;
@@ -86,7 +86,8 @@ interface RuleMeta {
86
86
  */
87
87
  internal?: boolean;
88
88
  }
89
- declare type DynamicMatcher<Theme extends {} = {}> = ((match: string[], context: Readonly<RuleContext<Theme>>) => Awaitable<CSSObject | CSSEntries | string | undefined>);
89
+ declare type CSSValues = CSSObject | CSSEntries | (CSSObject | CSSEntries)[];
90
+ declare type DynamicMatcher<Theme extends {} = {}> = ((match: string[], context: Readonly<RuleContext<Theme>>) => Awaitable<CSSValues | string | undefined>);
90
91
  declare type DynamicRule<Theme extends {} = {}> = [RegExp, DynamicMatcher<Theme>] | [RegExp, DynamicMatcher<Theme>, RuleMeta];
91
92
  declare type StaticRule = [string, CSSObject | CSSEntries] | [string, CSSObject | CSSEntries, RuleMeta];
92
93
  declare type Rule<Theme extends {} = {}> = DynamicRule<Theme> | StaticRule;
@@ -110,7 +111,7 @@ interface VariantHandler {
110
111
  /**
111
112
  * Rewrite the output selector. Often be used to append pesudo classes or parents.
112
113
  */
113
- selector?: (input: string) => string | undefined;
114
+ selector?: (input: string, body: CSSEntries) => string | undefined;
114
115
  /**
115
116
  * Rewrite the output css body. The input come in [key,value][] pairs.
116
117
  */
@@ -326,6 +327,9 @@ declare function escapeRegExp(string: string): string;
326
327
  declare function escapeSelector(str: string): string;
327
328
  declare const e: typeof escapeSelector;
328
329
 
330
+ declare function normalizeCSSEntries(obj: CSSEntries | CSSObject): CSSEntries;
331
+ declare function normalizeCSSValues(obj: CSSValues): CSSEntries[];
332
+ declare function clearIdenticalEntries(entry: CSSEntries): CSSEntries;
329
333
  declare function entriesToCss(arr?: CSSEntries): string;
330
334
  declare function isObject(item: any): item is Record<string, any>;
331
335
  declare function mergeDeep<T>(original: T, patch: DeepPartial<T>): T;
@@ -344,6 +348,7 @@ declare function isAttributifySelector(selector: string): RegExpMatchArray | nul
344
348
  declare function isValidSelector(selector?: string): selector is string;
345
349
  declare function normalizeVariant(variant: Variant): VariantObject;
346
350
  declare function isRawUtil(util: ParsedUtil | RawUtil | StringifiedUtil): util is RawUtil;
351
+ declare function notNull<T>(value: T | null | undefined): value is T;
347
352
 
348
353
  declare class TwoKeyMap<K1, K2, V> {
349
354
  _map: Map<K1, Map<K2, V>>;
@@ -368,4 +373,4 @@ declare function warnOnce(msg: string): void;
368
373
 
369
374
  declare const extractorSplit: Extractor;
370
375
 
371
- export { ArgumentType, Awaitable, BetterMap, BlocklistRule, CSSEntries, CSSObject, ConfigBase, DeepPartial, DynamicMatcher, DynamicRule, DynamicShortcut, DynamicShortcutMatcher, Extractor, ExtractorContext, FilterPattern, FlatObjectTuple, GenerateOptions, GenerateResult, GeneratorOptions, ParsedUtil, PartialByKeys, PluginOptions, Preflight, Preset, RawUtil, RequiredByKey, ResolvedConfig, RestArgs, Rule, RuleContext, RuleMeta, Shift, Shortcut, StaticRule, StaticShortcut, StaticShortcutMap, StringifiedUtil, TwoKeyMap, UnoGenerator, UserConfig, UserConfigDefaults, UserOnlyOptions, UserShortcuts, Variant, VariantFunction, VariantHandler, VariantMatchedResult, VariantObject, attributifyRE, createGenerator, e, entriesToCss, escapeRegExp, escapeSelector, expandVariantGroup, extractorSplit, hasScopePlaceholder, hex2rgba, isAttributifySelector, isObject, isRawUtil, isStaticRule, isStaticShortcut, isValidSelector, mergeDeep, mergeSet, normalizeVariant, regexClassGroup, toArray, uniq, validateFilterRE, warnOnce, withLayer };
376
+ export { ArgumentType, Awaitable, BetterMap, BlocklistRule, CSSEntries, CSSObject, CSSValues, ConfigBase, DeepPartial, DynamicMatcher, DynamicRule, DynamicShortcut, DynamicShortcutMatcher, Extractor, ExtractorContext, FilterPattern, FlatObjectTuple, GenerateOptions, GenerateResult, GeneratorOptions, ParsedUtil, PartialByKeys, PluginOptions, Preflight, Preset, RawUtil, RequiredByKey, ResolvedConfig, RestArgs, Rule, RuleContext, RuleMeta, Shift, Shortcut, StaticRule, StaticShortcut, StaticShortcutMap, StringifiedUtil, TwoKeyMap, UnoGenerator, UserConfig, UserConfigDefaults, UserOnlyOptions, UserShortcuts, Variant, VariantFunction, VariantHandler, VariantMatchedResult, VariantObject, attributifyRE, clearIdenticalEntries, createGenerator, e, entriesToCss, escapeRegExp, escapeSelector, expandVariantGroup, extractorSplit, hasScopePlaceholder, hex2rgba, isAttributifySelector, isObject, isRawUtil, isStaticRule, isStaticShortcut, isValidSelector, mergeDeep, mergeSet, normalizeCSSEntries, normalizeCSSValues, normalizeVariant, notNull, regexClassGroup, toArray, uniq, validateFilterRE, warnOnce, withLayer };
package/dist/index.mjs CHANGED
@@ -1,4 +1,3 @@
1
- // src/utils/escape.ts
2
1
  function escapeRegExp(string) {
3
2
  return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
4
3
  }
@@ -34,13 +33,36 @@ function escapeSelector(str) {
34
33
  }
35
34
  return result;
36
35
  }
37
- var e = escapeSelector;
36
+ const e = escapeSelector;
38
37
 
39
- // src/utils/object.ts
38
+ function normalizeCSSEntries(obj) {
39
+ return (!Array.isArray(obj) ? Object.entries(obj) : obj).filter((i) => i[1] != null);
40
+ }
41
+ function normalizeCSSValues(obj) {
42
+ if (Array.isArray(obj)) {
43
+ if (obj.find((i) => !Array.isArray(i) || Array.isArray(i[0])))
44
+ return obj.map((i) => normalizeCSSEntries(i));
45
+ else
46
+ return [obj];
47
+ } else {
48
+ return [normalizeCSSEntries(obj)];
49
+ }
50
+ }
51
+ function clearIdenticalEntries(entry) {
52
+ return entry.filter(([k, v], idx) => {
53
+ if (k.startsWith("$$"))
54
+ return false;
55
+ for (let i = idx - 1; i >= 0; i--) {
56
+ if (entry[i][0] === k && entry[i][1] === v)
57
+ return false;
58
+ }
59
+ return true;
60
+ });
61
+ }
40
62
  function entriesToCss(arr) {
41
63
  if (arr == null)
42
64
  return "";
43
- return arr.map(([key, value]) => value != null ? `${key}:${value};` : void 0).filter(Boolean).join("");
65
+ return clearIdenticalEntries(arr).map(([key, value]) => value != null ? `${key}:${value};` : void 0).filter(Boolean).join("");
44
66
  }
45
67
  function isObject(item) {
46
68
  return item && typeof item === "object" && !Array.isArray(item);
@@ -74,7 +96,6 @@ function isStaticShortcut(sc) {
74
96
  return typeof sc[0] === "string";
75
97
  }
76
98
 
77
- // src/utils/basic.ts
78
99
  function toArray(value = []) {
79
100
  return Array.isArray(value) ? value : [value];
80
101
  }
@@ -86,8 +107,7 @@ function mergeSet(target, append) {
86
107
  return target;
87
108
  }
88
109
 
89
- // src/utils/colors.ts
90
- var hexRE = /^#?([\da-f]+)$/i;
110
+ const hexRE = /^#?([\da-f]+)$/i;
91
111
  function hex2rgba(hex = "") {
92
112
  const [, body] = hex.match(hexRE) || [];
93
113
  if (!body)
@@ -109,9 +129,8 @@ function hex2rgba(hex = "") {
109
129
  }
110
130
  }
111
131
 
112
- // src/utils/helpers.ts
113
- var attributifyRE = /^\[(.+?)~?="(.*)"\]$/;
114
- var validateFilterRE = /[a-z?]/;
132
+ const attributifyRE = /^\[(.+?)~?="(.*)"\]$/;
133
+ const validateFilterRE = /(?!\d|-{2}|-\d)[a-zA-Z0-9\u00A0-\uFFFF-_:%-?]/;
115
134
  function isAttributifySelector(selector) {
116
135
  return selector.match(attributifyRE);
117
136
  }
@@ -124,9 +143,11 @@ function normalizeVariant(variant) {
124
143
  function isRawUtil(util) {
125
144
  return util.length === 3;
126
145
  }
146
+ function notNull(value) {
147
+ return value != null;
148
+ }
127
149
 
128
- // src/utils/map.ts
129
- var TwoKeyMap = class {
150
+ class TwoKeyMap {
130
151
  constructor() {
131
152
  this._map = new Map();
132
153
  }
@@ -155,12 +176,10 @@ var TwoKeyMap = class {
155
176
  return this;
156
177
  }
157
178
  has(key1, key2) {
158
- var _a;
159
- return (_a = this._map.get(key1)) == null ? void 0 : _a.has(key2);
179
+ return this._map.get(key1)?.has(key2);
160
180
  }
161
181
  delete(key1, key2) {
162
- var _a;
163
- return ((_a = this._map.get(key1)) == null ? void 0 : _a.delete(key2)) || false;
182
+ return this._map.get(key1)?.delete(key2) || false;
164
183
  }
165
184
  deleteTop(key1) {
166
185
  return this._map.delete(key1);
@@ -170,8 +189,8 @@ var TwoKeyMap = class {
170
189
  return fn(v, k1, k2);
171
190
  }));
172
191
  }
173
- };
174
- var BetterMap = class extends Map {
192
+ }
193
+ class BetterMap extends Map {
175
194
  map(mapFn) {
176
195
  const result = [];
177
196
  this.forEach((v, k) => {
@@ -179,9 +198,8 @@ var BetterMap = class extends Map {
179
198
  });
180
199
  return result;
181
200
  }
182
- };
201
+ }
183
202
 
184
- // src/utils/layer.ts
185
203
  function withLayer(layer, rules) {
186
204
  rules.forEach((r) => {
187
205
  if (!r[2])
@@ -192,8 +210,7 @@ function withLayer(layer, rules) {
192
210
  return rules;
193
211
  }
194
212
 
195
- // src/utils/variantGroup.ts
196
- var regexClassGroup = /([!\w+:_/-]+?)([:-])\(((?:[!\w\s:/\\,%#.$-]|\[.*?\])*?)\)/gm;
213
+ const regexClassGroup = /([!\w+:_/-]+?)([:-])\(((?:[!\w\s:/\\,%#.$-]|\[.*?\])*?)\)/gm;
197
214
  function expandVariantGroup(str) {
198
215
  const replaces = [];
199
216
  let match;
@@ -211,8 +228,7 @@ function expandVariantGroup(str) {
211
228
  return result;
212
229
  }
213
230
 
214
- // src/utils/warn.ts
215
- var warned = new Set();
231
+ const warned = new Set();
216
232
  function warnOnce(msg) {
217
233
  if (warned.has(msg))
218
234
  return;
@@ -220,8 +236,7 @@ function warnOnce(msg) {
220
236
  warned.add(msg);
221
237
  }
222
238
 
223
- // src/extractors/split.ts
224
- var extractorSplit = {
239
+ const extractorSplit = {
225
240
  name: "split",
226
241
  order: 0,
227
242
  extract({ code }) {
@@ -229,7 +244,6 @@ var extractorSplit = {
229
244
  }
230
245
  };
231
246
 
232
- // src/config.ts
233
247
  function resolveShortcuts(shortcuts) {
234
248
  return toArray(shortcuts).flatMap((s) => {
235
249
  if (Array.isArray(s))
@@ -237,7 +251,7 @@ function resolveShortcuts(shortcuts) {
237
251
  return Object.entries(s);
238
252
  });
239
253
  }
240
- var defaultLayers = {
254
+ const defaultLayers = {
241
255
  shortcuts: -1,
242
256
  default: 0
243
257
  };
@@ -295,11 +309,9 @@ function resolveConfig(userConfig = {}, defaults = {}) {
295
309
  };
296
310
  }
297
311
 
298
- // package.json
299
- var version = "0.13.1";
312
+ const version = "0.14.3";
300
313
 
301
- // src/generator/index.ts
302
- var UnoGenerator = class {
314
+ class UnoGenerator {
303
315
  constructor(userConfig = {}, defaults = {}) {
304
316
  this.userConfig = userConfig;
305
317
  this.defaults = defaults;
@@ -330,7 +342,7 @@ var UnoGenerator = class {
330
342
  };
331
343
  for (const extractor of this.config.extractors) {
332
344
  const result = await extractor.extract(context);
333
- result == null ? void 0 : result.forEach((t) => set.add(t));
345
+ result?.forEach((t) => set.add(t));
334
346
  }
335
347
  return set;
336
348
  }
@@ -349,7 +361,6 @@ var UnoGenerator = class {
349
361
  const matched = new Set();
350
362
  const sheet = new Map();
351
363
  const hit = (raw, payload) => {
352
- var _a;
353
364
  this._cache.set(raw, payload);
354
365
  matched.add(raw);
355
366
  for (const item of payload) {
@@ -357,7 +368,7 @@ var UnoGenerator = class {
357
368
  if (!sheet.has(parent))
358
369
  sheet.set(parent, []);
359
370
  sheet.get(parent).push(item);
360
- if ((_a = item[4]) == null ? void 0 : _a.layer)
371
+ if (item[4]?.layer)
361
372
  layerSet.add(item[4].layer);
362
373
  }
363
374
  };
@@ -393,12 +404,12 @@ var UnoGenerator = class {
393
404
  const expanded = this.expandShortcut(applied[1], context);
394
405
  if (expanded) {
395
406
  const utils = await this.stringifyShortcuts(applied, context, expanded[0], expanded[1]);
396
- if (utils == null ? void 0 : utils.length)
407
+ if (utils?.length)
397
408
  return hit(raw, utils);
398
409
  } else {
399
- const util = this.stringifyUtil(await this.parseUtil(applied, context));
400
- if (util)
401
- return hit(raw, [util]);
410
+ const utils = (await this.parseUtil(applied, context))?.map((i) => this.stringifyUtil(i)).filter(notNull);
411
+ if (utils?.length)
412
+ return hit(raw, utils);
402
413
  }
403
414
  this._cache.set(raw, null);
404
415
  }));
@@ -409,36 +420,27 @@ var UnoGenerator = class {
409
420
  });
410
421
  }
411
422
  const layerCache = {};
412
- const layers = this.config.sortLayers(Array.from(layerSet).sort((a, b) => {
413
- var _a, _b;
414
- return ((_a = this.config.layers[a]) != null ? _a : 0) - ((_b = this.config.layers[b]) != null ? _b : 0) || a.localeCompare(b);
415
- }));
423
+ const layers = this.config.sortLayers(Array.from(layerSet).sort((a, b) => (this.config.layers[a] ?? 0) - (this.config.layers[b] ?? 0) || a.localeCompare(b)));
416
424
  const getLayer = (layer) => {
417
425
  if (layerCache[layer])
418
426
  return layerCache[layer];
419
427
  let css = Array.from(sheet).sort((a, b) => (this.parentOrders.get(a[0]) || 0) - (this.parentOrders.get(b[0]) || 0)).map(([parent, items]) => {
420
428
  const size = items.length;
421
- const sorted = items.filter((i) => {
422
- var _a;
423
- return (((_a = i[4]) == null ? void 0 : _a.layer) || "default") === layer;
424
- }).sort((a, b) => {
425
- var _a;
426
- return a[0] - b[0] || ((_a = a[1]) == null ? void 0 : _a.localeCompare(b[1] || "")) || 0;
427
- }).map((a) => [a[1] ? applyScope(a[1], scope) : a[1], a[2]]);
429
+ const sorted = items.filter((i) => (i[4]?.layer || "default") === layer).sort((a, b) => a[0] - b[0] || a[1]?.localeCompare(b[1] || "") || 0).map((a) => [a[1] ? applyScope(a[1], scope) : a[1], a[2]]);
428
430
  if (!sorted.length)
429
431
  return void 0;
430
- const rules = sorted.map(([selector, body], idx) => {
432
+ const rules = sorted.reverse().map(([selector, body], idx) => {
431
433
  if (selector && this.config.mergeSelectors) {
432
- for (let i = size - 1; i > idx; i--) {
434
+ for (let i = idx + 1; i < size; i++) {
433
435
  const current = sorted[i];
434
436
  if (current && current[0] && current[1] === body) {
435
- current[0] = `${selector},${current[0]}`;
437
+ current[0] = `${current[0]},${selector}`;
436
438
  return null;
437
439
  }
438
440
  }
439
441
  }
440
442
  return selector ? `${selector}{${body}}` : body;
441
- }).filter(Boolean).join(nl);
443
+ }).filter(Boolean).reverse().join(nl);
442
444
  return parent ? `${parent}{${nl}${rules}${nl}}` : rules;
443
445
  }).filter(Boolean).join(nl);
444
446
  if (preflights) {
@@ -450,7 +452,7 @@ var UnoGenerator = class {
450
452
  return layerCache[layer] = !minify && css ? `/* layer: ${layer} */${nl}${css}` : css;
451
453
  };
452
454
  const getLayers = (includes = layers, excludes) => {
453
- return includes.filter((i) => !(excludes == null ? void 0 : excludes.includes(i))).map((i) => getLayer(i) || "").filter(Boolean).join(nl);
455
+ return includes.filter((i) => !excludes?.includes(i)).map((i) => getLayer(i) || "").filter(Boolean).join(nl);
454
456
  };
455
457
  return {
456
458
  get css() {
@@ -495,20 +497,15 @@ var UnoGenerator = class {
495
497
  return [raw, processed, handlers];
496
498
  }
497
499
  applyVariants(parsed, variantHandlers = parsed[4], raw = parsed[1]) {
500
+ const entries = variantHandlers.reduce((p, v) => v.body?.(p) || p, parsed[2]);
498
501
  return [
499
- variantHandlers.reduce((p, v) => {
500
- var _a;
501
- return ((_a = v.selector) == null ? void 0 : _a.call(v, p)) || p;
502
- }, toEscapedSelector(raw)),
503
- variantHandlers.reduce((p, v) => {
504
- var _a;
505
- return ((_a = v.body) == null ? void 0 : _a.call(v, p)) || p;
506
- }, parsed[2]),
502
+ variantHandlers.reduce((p, v) => v.selector?.(p, entries) || p, toEscapedSelector(raw)),
503
+ entries,
507
504
  variantHandlers.reduce((p, v) => Array.isArray(v.parent) ? v.parent[0] : v.parent || p, void 0)
508
505
  ];
509
506
  }
510
507
  constructCustomCSS(context, body, overrideSelector) {
511
- body = normalizeEntries(body);
508
+ body = normalizeCSSEntries(body);
512
509
  const [selector, entries, mediaQuery] = this.applyVariants([0, overrideSelector || context.rawSelector, body, void 0, context.variantHandlers]);
513
510
  const cssBody = `${selector}{${entriesToCss(entries)}}`;
514
511
  if (mediaQuery)
@@ -516,12 +513,11 @@ var UnoGenerator = class {
516
513
  return cssBody;
517
514
  }
518
515
  async parseUtil(input, context, internal = false) {
519
- var _a, _b;
520
516
  const [raw, processed, variantHandlers] = typeof input === "string" ? this.matchVariants(input) : input;
521
517
  const staticMatch = this.config.rulesStaticMap[processed];
522
518
  if (staticMatch) {
523
- if (staticMatch[1] && (internal || !((_a = staticMatch[2]) == null ? void 0 : _a.internal)))
524
- return [staticMatch[0], raw, normalizeEntries(staticMatch[1]), staticMatch[2], variantHandlers];
519
+ if (staticMatch[1] && (internal || !staticMatch[2]?.internal))
520
+ return [[staticMatch[0], raw, normalizeCSSEntries(staticMatch[1]), staticMatch[2], variantHandlers]];
525
521
  }
526
522
  context.variantHandlers = variantHandlers;
527
523
  const { rulesDynamic, rulesSize } = this.config;
@@ -529,7 +525,7 @@ var UnoGenerator = class {
529
525
  const rule = rulesDynamic[i];
530
526
  if (!rule)
531
527
  continue;
532
- if (((_b = rule[2]) == null ? void 0 : _b.internal) && !internal)
528
+ if (rule[2]?.internal && !internal)
533
529
  continue;
534
530
  const [matcher, handler, meta] = rule;
535
531
  const match = processed.match(matcher);
@@ -539,10 +535,10 @@ var UnoGenerator = class {
539
535
  if (!result)
540
536
  continue;
541
537
  if (typeof result === "string")
542
- return [i, result, meta];
543
- const entries = normalizeEntries(result).filter((i2) => i2[1] != null);
538
+ return [[i, result, meta]];
539
+ const entries = normalizeCSSValues(result).filter((i2) => i2.length);
544
540
  if (entries.length)
545
- return [i, raw, entries, meta, variantHandlers];
541
+ return entries.map((e2) => [i, raw, e2, meta, variantHandlers]);
546
542
  }
547
543
  }
548
544
  stringifyUtil(parsed) {
@@ -583,10 +579,7 @@ var UnoGenerator = class {
583
579
  if (!result)
584
580
  return;
585
581
  return [
586
- result.flatMap((r) => {
587
- var _a;
588
- return ((_a = this.expandShortcut(r, context, depth - 1)) == null ? void 0 : _a[0]) || [r];
589
- }),
582
+ result.flatMap((r) => this.expandShortcut(r, context, depth - 1)?.[0] || [r]),
590
583
  meta
591
584
  ];
592
585
  }
@@ -596,8 +589,8 @@ var UnoGenerator = class {
596
589
  const result = await this.parseUtil(i, context, true);
597
590
  if (!result)
598
591
  warnOnce(`unmatched utility "${i}" in shortcut "${parent[1]}"`);
599
- return result;
600
- }))).filter(Boolean).sort((a, b) => a[0] - b[0]);
592
+ return result || [];
593
+ }))).flat(1).filter(Boolean).sort((a, b) => a[0] - b[0]);
601
594
  const [raw, , parentVariants] = parent;
602
595
  for (const item of parsed) {
603
596
  if (isRawUtil(item))
@@ -618,12 +611,12 @@ var UnoGenerator = class {
618
611
  isBlocked(raw) {
619
612
  return !raw || this.config.blocklist.some((e2) => typeof e2 === "string" ? e2 === raw : e2.test(raw));
620
613
  }
621
- };
614
+ }
622
615
  function createGenerator(config, defaults) {
623
616
  return new UnoGenerator(config, defaults);
624
617
  }
625
- var reScopePlaceholder = / \$\$ /;
626
- var hasScopePlaceholder = (css) => css.match(reScopePlaceholder);
618
+ const reScopePlaceholder = / \$\$ /;
619
+ const hasScopePlaceholder = (css) => css.match(reScopePlaceholder);
627
620
  function applyScope(css, scope) {
628
621
  if (hasScopePlaceholder(css))
629
622
  return css.replace(reScopePlaceholder, scope ? ` ${scope} ` : " ");
@@ -636,36 +629,5 @@ function toEscapedSelector(raw) {
636
629
  else
637
630
  return `.${e(raw)}`;
638
631
  }
639
- function normalizeEntries(obj) {
640
- return !Array.isArray(obj) ? Object.entries(obj) : obj;
641
- }
642
- export {
643
- BetterMap,
644
- TwoKeyMap,
645
- UnoGenerator,
646
- attributifyRE,
647
- createGenerator,
648
- e,
649
- entriesToCss,
650
- escapeRegExp,
651
- escapeSelector,
652
- expandVariantGroup,
653
- extractorSplit,
654
- hasScopePlaceholder,
655
- hex2rgba,
656
- isAttributifySelector,
657
- isObject,
658
- isRawUtil,
659
- isStaticRule,
660
- isStaticShortcut,
661
- isValidSelector,
662
- mergeDeep,
663
- mergeSet,
664
- normalizeVariant,
665
- regexClassGroup,
666
- toArray,
667
- uniq,
668
- validateFilterRE,
669
- warnOnce,
670
- withLayer
671
- };
632
+
633
+ export { BetterMap, TwoKeyMap, UnoGenerator, attributifyRE, clearIdenticalEntries, createGenerator, e, entriesToCss, escapeRegExp, escapeSelector, expandVariantGroup, extractorSplit, hasScopePlaceholder, hex2rgba, isAttributifySelector, isObject, isRawUtil, isStaticRule, isStaticShortcut, isValidSelector, mergeDeep, mergeSet, normalizeCSSEntries, normalizeCSSValues, normalizeVariant, notNull, regexClassGroup, toArray, uniq, validateFilterRE, warnOnce, withLayer };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unocss/core",
3
- "version": "0.13.1",
3
+ "version": "0.14.3",
4
4
  "description": "The instant on-demand Atomic CSS engine.",
5
5
  "keywords": [
6
6
  "unocss",
@@ -25,19 +25,19 @@
25
25
  "sideEffects": false,
26
26
  "exports": {
27
27
  ".": {
28
- "require": "./dist/index.js",
28
+ "require": "./dist/index.cjs",
29
29
  "import": "./dist/index.mjs",
30
30
  "types": "./dist/index.d.ts"
31
31
  }
32
32
  },
33
- "main": "dist/index.js",
33
+ "main": "dist/index.cjs",
34
34
  "module": "dist/index.mjs",
35
35
  "types": "dist/index.d.ts",
36
36
  "files": [
37
37
  "dist"
38
38
  ],
39
39
  "scripts": {
40
- "build": "tsup",
41
- "dev": "tsup --watch src"
40
+ "build": "unbuild",
41
+ "stub": "unbuild --stub"
42
42
  }
43
43
  }