@unocss/core 0.54.2 → 0.55.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
@@ -213,6 +213,38 @@ class BetterMap extends Map {
213
213
  }
214
214
  }
215
215
 
216
+ class CountableSet extends Set {
217
+ constructor(values) {
218
+ super(values);
219
+ this._map ?? (this._map = /* @__PURE__ */ new Map());
220
+ for (const value of values ?? [])
221
+ this.add(value);
222
+ }
223
+ add(key) {
224
+ this._map ?? (this._map = /* @__PURE__ */ new Map());
225
+ this._map.set(key, (this._map.get(key) ?? 0) + 1);
226
+ return super.add(key);
227
+ }
228
+ delete(key) {
229
+ this._map.delete(key);
230
+ return super.delete(key);
231
+ }
232
+ clear() {
233
+ this._map.clear();
234
+ super.clear();
235
+ }
236
+ getCount(key) {
237
+ return this._map.get(key) ?? 0;
238
+ }
239
+ setCount(key, count) {
240
+ this._map.set(key, count);
241
+ return super.add(key);
242
+ }
243
+ }
244
+ function isCountableSet(value) {
245
+ return value instanceof CountableSet;
246
+ }
247
+
216
248
  function withLayer(layer, rules) {
217
249
  rules.forEach((r) => {
218
250
  if (!r[2])
@@ -371,7 +403,7 @@ function createValueHandler(handlers) {
371
403
  const defaultSplitRE = /[\\:]?[\s'"`;{}]+/g;
372
404
  const splitWithVariantGroupRE = /([\\:]?[\s"'`;<>]|:\(|\)"|\)\s)/g;
373
405
  function splitCode(code) {
374
- return [...new Set(code.split(defaultSplitRE))];
406
+ return code.split(defaultSplitRE);
375
407
  }
376
408
  const extractorSplit = {
377
409
  name: "@unocss/core/extractor-split",
@@ -567,7 +599,7 @@ function mergeAutocompleteShorthands(shorthands) {
567
599
  );
568
600
  }
569
601
 
570
- const version = "0.54.2";
602
+ const version = "0.55.0";
571
603
 
572
604
  class UnoGenerator {
573
605
  constructor(userConfig = {}, defaults = {}) {
@@ -598,11 +630,17 @@ class UnoGenerator {
598
630
  original: code,
599
631
  code,
600
632
  id,
601
- extracted
633
+ extracted,
634
+ envMode: this.config.envMode
602
635
  };
603
636
  for (const extractor of this.config.extractors) {
604
637
  const result = await extractor.extract?.(context);
605
- if (result) {
638
+ if (!result)
639
+ continue;
640
+ if (isCountableSet(result) && isCountableSet(extracted)) {
641
+ for (const token of result)
642
+ extracted.setCount(token, extracted.getCount(token) + result.getCount(token));
643
+ } else {
606
644
  for (const token of result)
607
645
  extracted.add(token);
608
646
  }
@@ -658,14 +696,23 @@ class UnoGenerator {
658
696
  scope,
659
697
  preflights = true,
660
698
  safelist = true,
661
- minify = false
699
+ minify = false,
700
+ extendedInfo = false
662
701
  } = options;
663
- const tokens = isString(input) ? await this.applyExtractors(input, id) : Array.isArray(input) ? new Set(input) : input;
664
- if (safelist)
665
- this.config.safelist.forEach((s) => tokens.add(s));
702
+ const tokens = isString(input) ? await this.applyExtractors(
703
+ input,
704
+ id,
705
+ extendedInfo ? new CountableSet() : /* @__PURE__ */ new Set()
706
+ ) : Array.isArray(input) ? new Set(input) : input;
707
+ if (safelist) {
708
+ this.config.safelist.forEach((s) => {
709
+ if (!tokens.has(s))
710
+ tokens.add(s);
711
+ });
712
+ }
666
713
  const nl = minify ? "" : "\n";
667
714
  const layerSet = /* @__PURE__ */ new Set([LAYER_DEFAULT]);
668
- const matched = /* @__PURE__ */ new Set();
715
+ const matched = extendedInfo ? /* @__PURE__ */ new Map() : /* @__PURE__ */ new Set();
669
716
  const sheet = /* @__PURE__ */ new Map();
670
717
  let preflightsMap = {};
671
718
  const tokenPromises = Array.from(tokens).map(async (raw) => {
@@ -674,7 +721,14 @@ class UnoGenerator {
674
721
  const payload = await this.parseToken(raw);
675
722
  if (payload == null)
676
723
  return;
677
- matched.add(raw);
724
+ if (matched instanceof Map) {
725
+ matched.set(raw, {
726
+ data: payload,
727
+ count: isCountableSet(tokens) ? tokens.getCount(raw) : -1
728
+ });
729
+ } else {
730
+ matched.add(raw);
731
+ }
678
732
  for (const item of payload) {
679
733
  const parent = item[3] || "";
680
734
  const layer = item[4]?.layer;
@@ -1056,6 +1110,7 @@ function defaultVariantHandler(input, next) {
1056
1110
 
1057
1111
  exports.BetterMap = BetterMap;
1058
1112
  exports.CONTROL_SHORTCUT_NO_MERGE = CONTROL_SHORTCUT_NO_MERGE;
1113
+ exports.CountableSet = CountableSet;
1059
1114
  exports.TwoKeyMap = TwoKeyMap;
1060
1115
  exports.UnoGenerator = UnoGenerator;
1061
1116
  exports.attributifyRE = attributifyRE;
@@ -1075,6 +1130,7 @@ exports.extractorDefault = extractorSplit;
1075
1130
  exports.extractorSplit = extractorSplit;
1076
1131
  exports.hasScopePlaceholder = hasScopePlaceholder;
1077
1132
  exports.isAttributifySelector = isAttributifySelector;
1133
+ exports.isCountableSet = isCountableSet;
1078
1134
  exports.isObject = isObject;
1079
1135
  exports.isRawUtil = isRawUtil;
1080
1136
  exports.isStaticRule = isStaticRule;
package/dist/index.d.ts CHANGED
@@ -51,37 +51,6 @@ declare class Emitter<Events extends EventsMap = DefaultEvents> {
51
51
  emit<K extends keyof Events>(this: this, event: K, ...args: Parameters<Events[K]>): void;
52
52
  }
53
53
 
54
- declare class UnoGenerator<Theme extends object = object> {
55
- userConfig: UserConfig<Theme>;
56
- defaults: UserConfigDefaults<Theme>;
57
- version: string;
58
- private _cache;
59
- config: ResolvedConfig<Theme>;
60
- blocked: Set<string>;
61
- parentOrders: Map<string, number>;
62
- events: Emitter<{
63
- config: (config: ResolvedConfig<Theme>) => void;
64
- }>;
65
- constructor(userConfig?: UserConfig<Theme>, defaults?: UserConfigDefaults<Theme>);
66
- setConfig(userConfig?: UserConfig<Theme>, defaults?: UserConfigDefaults<Theme>): void;
67
- applyExtractors(code: string, id?: string, extracted?: Set<string>): Promise<Set<string>>;
68
- makeContext(raw: string, applied: VariantMatchedResult<Theme>): RuleContext<Theme>;
69
- parseToken(raw: string, alias?: string): Promise<StringifiedUtil<Theme>[] | undefined | null>;
70
- generate(input: string | Set<string> | string[], options?: GenerateOptions): Promise<GenerateResult>;
71
- matchVariants(raw: string, current?: string): Promise<VariantMatchedResult<Theme>>;
72
- private applyVariants;
73
- constructCustomCSS(context: Readonly<RuleContext<Theme>>, body: CSSObject | CSSEntries, overrideSelector?: string): string;
74
- parseUtil(input: string | VariantMatchedResult<Theme>, context: RuleContext<Theme>, internal?: boolean, shortcutPrefix?: string | string[] | undefined): Promise<(ParsedUtil | RawUtil)[] | undefined>;
75
- stringifyUtil(parsed?: ParsedUtil | RawUtil, context?: RuleContext<Theme>): StringifiedUtil<Theme> | undefined;
76
- expandShortcut(input: string, context: RuleContext<Theme>, depth?: number): Promise<[ShortcutValue[], RuleMeta | undefined] | undefined>;
77
- stringifyShortcuts(parent: VariantMatchedResult<Theme>, context: RuleContext<Theme>, expanded: ShortcutValue[], meta?: RuleMeta): Promise<StringifiedUtil<Theme>[] | undefined>;
78
- isBlocked(raw: string): boolean;
79
- }
80
- declare function createGenerator<Theme extends object = object>(config?: UserConfig<Theme>, defaults?: UserConfigDefaults<Theme>): UnoGenerator<Theme>;
81
- declare const regexScopePlaceholder: RegExp;
82
- declare function hasScopePlaceholder(css: string): RegExpMatchArray | null;
83
- declare function toEscapedSelector(raw: string): string;
84
-
85
54
  declare function escapeRegExp(string: string): string;
86
55
  /**
87
56
  * CSS Selector Escape
@@ -131,6 +100,17 @@ declare class BetterMap<K, V> extends Map<K, V> {
131
100
  map<R>(mapFn: (value: V, key: K) => R): R[];
132
101
  }
133
102
 
103
+ declare class CountableSet<K> extends Set<K> {
104
+ _map: Map<K, number>;
105
+ constructor(values?: Iterable<K>);
106
+ add(key: K): this;
107
+ delete(key: K): boolean;
108
+ clear(): void;
109
+ getCount(key: K): number;
110
+ setCount(key: K, count: number): this;
111
+ }
112
+ declare function isCountableSet<T = string>(value: any): value is CountableSet<T>;
113
+
134
114
  declare function withLayer<T extends object>(layer: string, rules: Rule<T>[]): Rule<T>[];
135
115
 
136
116
  declare function makeRegexClassGroup(separators?: string[]): RegExp;
@@ -161,6 +141,39 @@ type ValueHandler<K extends string> = {
161
141
  };
162
142
  declare function createValueHandler<K extends string>(handlers: Record<K, ValueHandlerCallback>): ValueHandler<K>;
163
143
 
144
+ declare class UnoGenerator<Theme extends object = object> {
145
+ userConfig: UserConfig<Theme>;
146
+ defaults: UserConfigDefaults<Theme>;
147
+ version: string;
148
+ private _cache;
149
+ config: ResolvedConfig<Theme>;
150
+ blocked: Set<string>;
151
+ parentOrders: Map<string, number>;
152
+ events: Emitter<{
153
+ config: (config: ResolvedConfig<Theme>) => void;
154
+ }>;
155
+ constructor(userConfig?: UserConfig<Theme>, defaults?: UserConfigDefaults<Theme>);
156
+ setConfig(userConfig?: UserConfig<Theme>, defaults?: UserConfigDefaults<Theme>): void;
157
+ applyExtractors(code: string, id?: string, extracted?: Set<string>): Promise<Set<string>>;
158
+ applyExtractors(code: string, id?: string, extracted?: CountableSet<string>): Promise<CountableSet<string>>;
159
+ makeContext(raw: string, applied: VariantMatchedResult<Theme>): RuleContext<Theme>;
160
+ parseToken(raw: string, alias?: string): Promise<StringifiedUtil<Theme>[] | undefined | null>;
161
+ generate(input: string | Set<string> | CountableSet<string> | string[], options?: GenerateOptions<false>): Promise<GenerateResult<Set<string>>>;
162
+ generate(input: string | Set<string> | CountableSet<string> | string[], options?: GenerateOptions<true>): Promise<GenerateResult<Map<string, ExtendedTokenInfo<Theme>>>>;
163
+ matchVariants(raw: string, current?: string): Promise<VariantMatchedResult<Theme>>;
164
+ private applyVariants;
165
+ constructCustomCSS(context: Readonly<RuleContext<Theme>>, body: CSSObject | CSSEntries, overrideSelector?: string): string;
166
+ parseUtil(input: string | VariantMatchedResult<Theme>, context: RuleContext<Theme>, internal?: boolean, shortcutPrefix?: string | string[] | undefined): Promise<(ParsedUtil | RawUtil)[] | undefined>;
167
+ stringifyUtil(parsed?: ParsedUtil | RawUtil, context?: RuleContext<Theme>): StringifiedUtil<Theme> | undefined;
168
+ expandShortcut(input: string, context: RuleContext<Theme>, depth?: number): Promise<[ShortcutValue[], RuleMeta | undefined] | undefined>;
169
+ stringifyShortcuts(parent: VariantMatchedResult<Theme>, context: RuleContext<Theme>, expanded: ShortcutValue[], meta?: RuleMeta): Promise<StringifiedUtil<Theme>[] | undefined>;
170
+ isBlocked(raw: string): boolean;
171
+ }
172
+ declare function createGenerator<Theme extends object = object>(config?: UserConfig<Theme>, defaults?: UserConfigDefaults<Theme>): UnoGenerator<Theme>;
173
+ declare const regexScopePlaceholder: RegExp;
174
+ declare function hasScopePlaceholder(css: string): RegExpMatchArray | null;
175
+ declare function toEscapedSelector(raw: string): string;
176
+
164
177
  type Awaitable<T> = T | Promise<T>;
165
178
  type Arrayable<T> = T | T[];
166
179
  type ToArray<T> = T extends (infer U)[] ? U[] : T[];
@@ -272,7 +285,8 @@ interface ExtractorContext {
272
285
  readonly original: string;
273
286
  code: string;
274
287
  id?: string;
275
- extracted: Set<string>;
288
+ extracted: Set<string> | CountableSet<string>;
289
+ envMode?: 'dev' | 'build';
276
290
  }
277
291
  interface PreflightContext<Theme extends object = object> {
278
292
  /**
@@ -292,7 +306,7 @@ interface Extractor {
292
306
  *
293
307
  * Return `undefined` to skip this extractor.
294
308
  */
295
- extract?(ctx: ExtractorContext): Awaitable<Set<string> | string[] | undefined | void>;
309
+ extract?(ctx: ExtractorContext): Awaitable<Set<string> | CountableSet<string> | string[] | undefined | void>;
296
310
  }
297
311
  interface RuleMeta {
298
312
  /**
@@ -860,12 +874,12 @@ interface ResolvedConfig<Theme extends object = object> extends Omit<RequiredByK
860
874
  };
861
875
  separators: string[];
862
876
  }
863
- interface GenerateResult {
877
+ interface GenerateResult<T = Set<string>> {
864
878
  css: string;
865
879
  layers: string[];
866
880
  getLayer(name?: string): string | undefined;
867
881
  getLayers(includes?: string[], excludes?: string[]): string;
868
- matched: Set<string>;
882
+ matched: T;
869
883
  }
870
884
  type VariantMatchedResult<Theme extends object = object> = readonly [
871
885
  raw: string,
@@ -911,7 +925,20 @@ interface UtilObject {
911
925
  sort: number | undefined;
912
926
  noMerge: boolean | undefined;
913
927
  }
914
- interface GenerateOptions {
928
+ /**
929
+ * Returned from `uno.generate()` when `extendedInfo` option is enabled.
930
+ */
931
+ interface ExtendedTokenInfo<Theme extends object = object> {
932
+ /**
933
+ * Stringified util data
934
+ */
935
+ data: StringifiedUtil<Theme>[];
936
+ /**
937
+ * Return -1 if the data structure is not countable
938
+ */
939
+ count: number;
940
+ }
941
+ interface GenerateOptions<T extends boolean> {
915
942
  /**
916
943
  * Filepath of the file being processed.
917
944
  */
@@ -935,6 +962,10 @@ interface GenerateOptions {
935
962
  * @experimental
936
963
  */
937
964
  scope?: string;
965
+ /**
966
+ * If return extended "matched" with payload and count
967
+ */
968
+ extendedInfo?: T;
938
969
  }
939
970
 
940
971
  declare const defaultSplitRE: RegExp;
@@ -956,4 +987,4 @@ declare function resolveConfig<Theme extends object = object>(userConfig?: UserC
956
987
  */
957
988
  declare function mergeConfigs<Theme extends object = object>(configs: UserConfig<Theme>[]): UserConfig<Theme>;
958
989
 
959
- export { ArgumentType, Arrayable, AutoCompleteExtractor, AutoCompleteExtractorContext, AutoCompleteExtractorResult, AutoCompleteFunction, AutoCompleteTemplate, Awaitable, BetterMap, BlocklistRule, CONTROL_SHORTCUT_NO_MERGE, CSSColorValue, CSSEntries, CSSObject, CSSValue, CSSValues, CliEntryItem, CliOptions, ConfigBase, ContentOptions, DeepPartial, DynamicMatcher, DynamicRule, DynamicShortcut, DynamicShortcutMatcher, Extractor, ExtractorContext, FilterPattern, FlatObjectTuple, GenerateOptions, GenerateResult, GeneratorOptions, HighlightAnnotation, ParsedColorValue, ParsedUtil, PartialByKeys, PluginOptions, Postprocessor, Preflight, PreflightContext, PreparedRule, Preprocessor, Preset, PresetOptions, RGBAColorValue, RawUtil, Replacement, RequiredByKey, ResolvedConfig, RestArgs, Rule, RuleContext, RuleMeta, Shift, Shortcut, ShortcutValue, SourceCodeTransformer, SourceCodeTransformerEnforce, SourceMap, StaticRule, StaticShortcut, StaticShortcutMap, StringifiedUtil, SuggestResult, ThemeExtender, ToArray, TwoKeyMap, UnoGenerator, UnocssPluginContext, UserConfig, UserConfigDefaults, UserOnlyOptions, UserShortcuts, UtilObject, ValueHandler, ValueHandlerCallback, Variant, VariantContext, VariantFunction, VariantHandler, VariantHandlerContext, VariantMatchedResult, VariantObject, attributifyRE, clearIdenticalEntries, clone, collapseVariantGroup, createGenerator, createValueHandler, cssIdRE, defaultSplitRE, e, entriesToCss, escapeRegExp, escapeSelector, expandVariantGroup, extractorSplit as extractorDefault, extractorSplit, hasScopePlaceholder, isAttributifySelector, isObject, isRawUtil, isStaticRule, isStaticShortcut, isString, isValidSelector, makeRegexClassGroup, mergeConfigs, mergeDeep, noop, normalizeCSSEntries, normalizeCSSValues, normalizeVariant, notNull, parseVariantGroup, regexScopePlaceholder, resolveConfig, resolvePreset, resolvePresets, resolveShortcuts, splitWithVariantGroupRE, toArray, toEscapedSelector, uniq, validateFilterRE, warnOnce, withLayer };
990
+ export { ArgumentType, Arrayable, AutoCompleteExtractor, AutoCompleteExtractorContext, AutoCompleteExtractorResult, AutoCompleteFunction, AutoCompleteTemplate, Awaitable, BetterMap, BlocklistRule, CONTROL_SHORTCUT_NO_MERGE, CSSColorValue, CSSEntries, CSSObject, CSSValue, CSSValues, CliEntryItem, CliOptions, ConfigBase, ContentOptions, CountableSet, DeepPartial, DynamicMatcher, DynamicRule, DynamicShortcut, DynamicShortcutMatcher, ExtendedTokenInfo, Extractor, ExtractorContext, FilterPattern, FlatObjectTuple, GenerateOptions, GenerateResult, GeneratorOptions, HighlightAnnotation, ParsedColorValue, ParsedUtil, PartialByKeys, PluginOptions, Postprocessor, Preflight, PreflightContext, PreparedRule, Preprocessor, Preset, PresetOptions, RGBAColorValue, RawUtil, Replacement, RequiredByKey, ResolvedConfig, RestArgs, Rule, RuleContext, RuleMeta, Shift, Shortcut, ShortcutValue, SourceCodeTransformer, SourceCodeTransformerEnforce, SourceMap, StaticRule, StaticShortcut, StaticShortcutMap, StringifiedUtil, SuggestResult, ThemeExtender, ToArray, TwoKeyMap, UnoGenerator, UnocssPluginContext, UserConfig, UserConfigDefaults, UserOnlyOptions, UserShortcuts, UtilObject, ValueHandler, ValueHandlerCallback, Variant, VariantContext, VariantFunction, VariantHandler, VariantHandlerContext, VariantMatchedResult, VariantObject, attributifyRE, clearIdenticalEntries, clone, collapseVariantGroup, createGenerator, createValueHandler, cssIdRE, defaultSplitRE, e, entriesToCss, escapeRegExp, escapeSelector, expandVariantGroup, extractorSplit as extractorDefault, extractorSplit, hasScopePlaceholder, isAttributifySelector, isCountableSet, isObject, isRawUtil, isStaticRule, isStaticShortcut, isString, isValidSelector, makeRegexClassGroup, mergeConfigs, mergeDeep, noop, normalizeCSSEntries, normalizeCSSValues, normalizeVariant, notNull, parseVariantGroup, regexScopePlaceholder, resolveConfig, resolvePreset, resolvePresets, resolveShortcuts, splitWithVariantGroupRE, toArray, toEscapedSelector, uniq, validateFilterRE, warnOnce, withLayer };
package/dist/index.mjs CHANGED
@@ -209,6 +209,38 @@ class BetterMap extends Map {
209
209
  }
210
210
  }
211
211
 
212
+ class CountableSet extends Set {
213
+ constructor(values) {
214
+ super(values);
215
+ this._map ?? (this._map = /* @__PURE__ */ new Map());
216
+ for (const value of values ?? [])
217
+ this.add(value);
218
+ }
219
+ add(key) {
220
+ this._map ?? (this._map = /* @__PURE__ */ new Map());
221
+ this._map.set(key, (this._map.get(key) ?? 0) + 1);
222
+ return super.add(key);
223
+ }
224
+ delete(key) {
225
+ this._map.delete(key);
226
+ return super.delete(key);
227
+ }
228
+ clear() {
229
+ this._map.clear();
230
+ super.clear();
231
+ }
232
+ getCount(key) {
233
+ return this._map.get(key) ?? 0;
234
+ }
235
+ setCount(key, count) {
236
+ this._map.set(key, count);
237
+ return super.add(key);
238
+ }
239
+ }
240
+ function isCountableSet(value) {
241
+ return value instanceof CountableSet;
242
+ }
243
+
212
244
  function withLayer(layer, rules) {
213
245
  rules.forEach((r) => {
214
246
  if (!r[2])
@@ -367,7 +399,7 @@ function createValueHandler(handlers) {
367
399
  const defaultSplitRE = /[\\:]?[\s'"`;{}]+/g;
368
400
  const splitWithVariantGroupRE = /([\\:]?[\s"'`;<>]|:\(|\)"|\)\s)/g;
369
401
  function splitCode(code) {
370
- return [...new Set(code.split(defaultSplitRE))];
402
+ return code.split(defaultSplitRE);
371
403
  }
372
404
  const extractorSplit = {
373
405
  name: "@unocss/core/extractor-split",
@@ -563,7 +595,7 @@ function mergeAutocompleteShorthands(shorthands) {
563
595
  );
564
596
  }
565
597
 
566
- const version = "0.54.2";
598
+ const version = "0.55.0";
567
599
 
568
600
  class UnoGenerator {
569
601
  constructor(userConfig = {}, defaults = {}) {
@@ -594,11 +626,17 @@ class UnoGenerator {
594
626
  original: code,
595
627
  code,
596
628
  id,
597
- extracted
629
+ extracted,
630
+ envMode: this.config.envMode
598
631
  };
599
632
  for (const extractor of this.config.extractors) {
600
633
  const result = await extractor.extract?.(context);
601
- if (result) {
634
+ if (!result)
635
+ continue;
636
+ if (isCountableSet(result) && isCountableSet(extracted)) {
637
+ for (const token of result)
638
+ extracted.setCount(token, extracted.getCount(token) + result.getCount(token));
639
+ } else {
602
640
  for (const token of result)
603
641
  extracted.add(token);
604
642
  }
@@ -654,14 +692,23 @@ class UnoGenerator {
654
692
  scope,
655
693
  preflights = true,
656
694
  safelist = true,
657
- minify = false
695
+ minify = false,
696
+ extendedInfo = false
658
697
  } = options;
659
- const tokens = isString(input) ? await this.applyExtractors(input, id) : Array.isArray(input) ? new Set(input) : input;
660
- if (safelist)
661
- this.config.safelist.forEach((s) => tokens.add(s));
698
+ const tokens = isString(input) ? await this.applyExtractors(
699
+ input,
700
+ id,
701
+ extendedInfo ? new CountableSet() : /* @__PURE__ */ new Set()
702
+ ) : Array.isArray(input) ? new Set(input) : input;
703
+ if (safelist) {
704
+ this.config.safelist.forEach((s) => {
705
+ if (!tokens.has(s))
706
+ tokens.add(s);
707
+ });
708
+ }
662
709
  const nl = minify ? "" : "\n";
663
710
  const layerSet = /* @__PURE__ */ new Set([LAYER_DEFAULT]);
664
- const matched = /* @__PURE__ */ new Set();
711
+ const matched = extendedInfo ? /* @__PURE__ */ new Map() : /* @__PURE__ */ new Set();
665
712
  const sheet = /* @__PURE__ */ new Map();
666
713
  let preflightsMap = {};
667
714
  const tokenPromises = Array.from(tokens).map(async (raw) => {
@@ -670,7 +717,14 @@ class UnoGenerator {
670
717
  const payload = await this.parseToken(raw);
671
718
  if (payload == null)
672
719
  return;
673
- matched.add(raw);
720
+ if (matched instanceof Map) {
721
+ matched.set(raw, {
722
+ data: payload,
723
+ count: isCountableSet(tokens) ? tokens.getCount(raw) : -1
724
+ });
725
+ } else {
726
+ matched.add(raw);
727
+ }
674
728
  for (const item of payload) {
675
729
  const parent = item[3] || "";
676
730
  const layer = item[4]?.layer;
@@ -1050,4 +1104,4 @@ function defaultVariantHandler(input, next) {
1050
1104
  return next(input);
1051
1105
  }
1052
1106
 
1053
- export { BetterMap, CONTROL_SHORTCUT_NO_MERGE, TwoKeyMap, UnoGenerator, attributifyRE, clearIdenticalEntries, clone, collapseVariantGroup, createGenerator, createValueHandler, cssIdRE, defaultSplitRE, e, entriesToCss, escapeRegExp, escapeSelector, expandVariantGroup, extractorSplit as extractorDefault, extractorSplit, hasScopePlaceholder, isAttributifySelector, isObject, isRawUtil, isStaticRule, isStaticShortcut, isString, isValidSelector, makeRegexClassGroup, mergeConfigs, mergeDeep, noop, normalizeCSSEntries, normalizeCSSValues, normalizeVariant, notNull, parseVariantGroup, regexScopePlaceholder, resolveConfig, resolvePreset, resolvePresets, resolveShortcuts, splitWithVariantGroupRE, toArray, toEscapedSelector, uniq, validateFilterRE, warnOnce, withLayer };
1107
+ export { BetterMap, CONTROL_SHORTCUT_NO_MERGE, CountableSet, TwoKeyMap, UnoGenerator, attributifyRE, clearIdenticalEntries, clone, collapseVariantGroup, createGenerator, createValueHandler, cssIdRE, defaultSplitRE, e, entriesToCss, escapeRegExp, escapeSelector, expandVariantGroup, extractorSplit as extractorDefault, extractorSplit, hasScopePlaceholder, isAttributifySelector, isCountableSet, isObject, isRawUtil, isStaticRule, isStaticShortcut, isString, isValidSelector, makeRegexClassGroup, mergeConfigs, mergeDeep, noop, normalizeCSSEntries, normalizeCSSValues, normalizeVariant, notNull, parseVariantGroup, regexScopePlaceholder, resolveConfig, resolvePreset, resolvePresets, resolveShortcuts, splitWithVariantGroupRE, toArray, toEscapedSelector, uniq, validateFilterRE, warnOnce, withLayer };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unocss/core",
3
- "version": "0.54.2",
3
+ "version": "0.55.0",
4
4
  "description": "The instant on-demand Atomic CSS engine.",
5
5
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
6
6
  "license": "MIT",
@@ -26,8 +26,8 @@
26
26
  "exports": {
27
27
  ".": {
28
28
  "types": "./dist/index.d.ts",
29
- "require": "./dist/index.cjs",
30
- "import": "./dist/index.mjs"
29
+ "import": "./dist/index.mjs",
30
+ "require": "./dist/index.cjs"
31
31
  }
32
32
  },
33
33
  "main": "dist/index.cjs",