@unocss/core 0.18.1 → 0.20.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.cjs CHANGED
@@ -337,6 +337,7 @@ function resolveConfig(userConfig = {}, defaults = {}) {
337
337
  ...sortedPresets.map((p) => p.theme || {}),
338
338
  config.theme || {}
339
339
  ].reduce((a, p) => mergeDeep(a, p), {});
340
+ const options = Object.assign({}, ...config.presets?.map((p) => Array.isArray(p) ? p : [p]).flat(1).map((p) => p.options ?? {}) || []);
340
341
  return {
341
342
  mergeSelectors: true,
342
343
  warn: true,
@@ -352,14 +353,17 @@ function resolveConfig(userConfig = {}, defaults = {}) {
352
353
  rulesSize,
353
354
  rulesDynamic: rules,
354
355
  rulesStaticMap,
356
+ preprocess: mergePresets("preprocess"),
357
+ postprocess: mergePresets("postprocess"),
355
358
  preflights: mergePresets("preflights"),
356
359
  variants: mergePresets("variants").map(normalizeVariant),
357
360
  shortcuts: resolveShortcuts(mergePresets("shortcuts")),
358
- extractors
361
+ extractors,
362
+ options
359
363
  };
360
364
  }
361
365
 
362
- const version = "0.18.1";
366
+ const version = "0.20.2";
363
367
 
364
368
  class UnoGenerator {
365
369
  constructor(userConfig = {}, defaults = {}) {
@@ -388,7 +392,8 @@ class UnoGenerator {
388
392
  return code;
389
393
  },
390
394
  code,
391
- id
395
+ id,
396
+ options: this.config.options
392
397
  };
393
398
  for (const extractor of this.config.extractors) {
394
399
  const result = await extractor.extract(context);
@@ -436,8 +441,8 @@ class UnoGenerator {
436
441
  return;
437
442
  }
438
443
  let current = raw;
439
- if (this.config.preprocess)
440
- current = this.config.preprocess(raw);
444
+ for (const p of this.config.preprocess)
445
+ current = p(raw);
441
446
  if (this.isBlocked(current))
442
447
  return block(current);
443
448
  const applied = this.matchVariants(raw, current);
@@ -449,7 +454,8 @@ class UnoGenerator {
449
454
  theme: this.config.theme,
450
455
  generator: this,
451
456
  variantHandlers: applied[2],
452
- constructCSS: (...args) => this.constructCustomCSS(context, ...args)
457
+ constructCSS: (...args) => this.constructCustomCSS(context, ...args),
458
+ options: this.config.options
453
459
  };
454
460
  const expanded = this.expandShortcut(applied[1], context);
455
461
  if (expanded) {
@@ -474,7 +480,13 @@ class UnoGenerator {
474
480
  const getLayer = (layer) => {
475
481
  if (layerCache[layer])
476
482
  return layerCache[layer];
477
- let css = Array.from(sheet).sort((a, b) => (this.parentOrders.get(a[0]) || 0) - (this.parentOrders.get(b[0]) || 0)).map(([parent, items]) => {
483
+ let css = Array.from(sheet).sort((a, b) => {
484
+ const parentOrderA = this.parentOrders.get(a[0]);
485
+ const parentOrderB = this.parentOrders.get(b[0]);
486
+ if (parentOrderA !== void 0 && parentOrderB !== void 0)
487
+ return parentOrderA - parentOrderB;
488
+ return a[0]?.localeCompare(b[0] || "");
489
+ }).map(([parent, items]) => {
478
490
  const size = items.length;
479
491
  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]]);
480
492
  if (!sorted.length)
@@ -519,12 +531,18 @@ class UnoGenerator {
519
531
  const handlers = [];
520
532
  let processed = current || raw;
521
533
  let applied = false;
534
+ const context = {
535
+ rawSelector: raw,
536
+ theme: this.config.theme,
537
+ generator: this,
538
+ options: this.config.options
539
+ };
522
540
  while (true) {
523
541
  applied = false;
524
542
  for (const v of this.config.variants) {
525
543
  if (!v.multiPass && usedVariants.has(v))
526
544
  continue;
527
- let handler = v.match(processed, raw, this.config.theme);
545
+ let handler = v.match(processed, context);
528
546
  if (!handler)
529
547
  continue;
530
548
  if (typeof handler === "string")
@@ -547,19 +565,23 @@ class UnoGenerator {
547
565
  return [raw, processed, handlers];
548
566
  }
549
567
  applyVariants(parsed, variantHandlers = parsed[4], raw = parsed[1]) {
550
- const entries = variantHandlers.reduce((p, v) => v.body?.(p) || p, parsed[2]);
551
- return [
552
- variantHandlers.reduce((p, v) => v.selector?.(p, entries) || p, toEscapedSelector(raw)),
568
+ const handlers = [...variantHandlers].sort((a, b) => (a.order || 0) - (b.order || 0));
569
+ const entries = handlers.reduce((p, v) => v.body?.(p) || p, parsed[2]);
570
+ const obj = {
571
+ selector: handlers.reduce((p, v) => v.selector?.(p, entries) || p, toEscapedSelector(raw)),
553
572
  entries,
554
- variantHandlers.reduce((p, v) => Array.isArray(v.parent) ? v.parent[0] : v.parent || p, void 0)
555
- ];
573
+ parent: handlers.reduce((p, v) => Array.isArray(v.parent) ? v.parent[0] : v.parent || p, void 0)
574
+ };
575
+ for (const p of this.config.postprocess)
576
+ p(obj);
577
+ return obj;
556
578
  }
557
579
  constructCustomCSS(context, body, overrideSelector) {
558
580
  body = normalizeCSSEntries(body);
559
- const [selector, entries, mediaQuery] = this.applyVariants([0, overrideSelector || context.rawSelector, body, void 0, context.variantHandlers]);
581
+ const { selector, entries, parent } = this.applyVariants([0, overrideSelector || context.rawSelector, body, void 0, context.variantHandlers]);
560
582
  const cssBody = `${selector}{${entriesToCss(entries)}}`;
561
- if (mediaQuery)
562
- return `${mediaQuery}{${cssBody}}`;
583
+ if (parent)
584
+ return `${parent}{${cssBody}}`;
563
585
  return cssBody;
564
586
  }
565
587
  async parseUtil(input, context, internal = false) {
@@ -596,11 +618,11 @@ class UnoGenerator {
596
618
  return;
597
619
  if (isRawUtil(parsed))
598
620
  return [parsed[0], void 0, parsed[1], void 0, parsed[2]];
599
- const [selector, entries, mediaQuery] = this.applyVariants(parsed);
621
+ const { selector, entries, parent } = this.applyVariants(parsed);
600
622
  const body = entriesToCss(entries);
601
623
  if (!body)
602
624
  return;
603
- return [parsed[0], selector, body, mediaQuery, parsed[3]];
625
+ return [parsed[0], selector, body, parent, parsed[3]];
604
626
  }
605
627
  expandShortcut(processed, context, depth = 3) {
606
628
  if (depth === 0)
@@ -645,8 +667,8 @@ class UnoGenerator {
645
667
  for (const item of parsed) {
646
668
  if (isRawUtil(item))
647
669
  continue;
648
- const [selector, entries, mediaQuery] = this.applyVariants(item, [...item[4], ...parentVariants], raw);
649
- const mapItem = selectorMap.getFallback(selector, mediaQuery, [[], item[0]]);
670
+ const { selector, entries, parent: parent2 } = this.applyVariants(item, [...item[4], ...parentVariants], raw);
671
+ const mapItem = selectorMap.getFallback(selector, parent2, [[], item[0]]);
650
672
  mapItem[0].push(...entries);
651
673
  if (item[0] > mapItem[1])
652
674
  mapItem[1] = item[0];
package/dist/index.d.ts CHANGED
@@ -11,7 +11,7 @@ declare class UnoGenerator {
11
11
  applyExtractors(code: string, id?: string, set?: Set<string>): Promise<Set<string>>;
12
12
  generate(input: string | Set<string>, { id, scope, preflights, safelist, minify, }?: GenerateOptions): Promise<GenerateResult>;
13
13
  matchVariants(raw: string, current?: string): VariantMatchedResult;
14
- applyVariants(parsed: ParsedUtil, variantHandlers?: VariantHandler[], raw?: string): readonly [string, CSSEntries, string | undefined];
14
+ applyVariants(parsed: ParsedUtil, variantHandlers?: VariantHandler[], raw?: string): UtilObject;
15
15
  constructCustomCSS(context: Readonly<RuleContext>, body: CSSObject | CSSEntries, overrideSelector?: string): string;
16
16
  parseUtil(input: string | VariantMatchedResult, context: RuleContext, internal?: boolean): Promise<ParsedUtil[] | RawUtil[] | undefined>;
17
17
  stringifyUtil(parsed?: ParsedUtil | RawUtil): StringifiedUtil | undefined;
@@ -51,14 +51,19 @@ declare type ParsedColorValue = {
51
51
  */
52
52
  name: string;
53
53
  /**
54
- * Color scale. Preferrably 000 - 999
54
+ * Color scale, preferrably 000 - 999.
55
55
  */
56
56
  no: string;
57
57
  /**
58
58
  * {@link RGBAColorValue}
59
59
  */
60
60
  rgba?: RGBAColorValue;
61
+ /**
62
+ * Parsed rgba's alpha value.
63
+ */
64
+ alpha?: number | string;
61
65
  };
66
+ declare type PresetOptions = Record<string, any>;
62
67
  interface RuleContext<Theme extends {} = {}> {
63
68
  /**
64
69
  * Unprocessed selector from user input.
@@ -86,11 +91,34 @@ interface RuleContext<Theme extends {} = {}> {
86
91
  * Variants and selector escaping will be handled automatically.
87
92
  */
88
93
  constructCSS: (body: CSSEntries | CSSObject, overrideSelector?: string) => string;
94
+ /**
95
+ * User-provided options from preset.
96
+ */
97
+ readonly options: PresetOptions;
98
+ }
99
+ interface VariantContext<Theme extends {} = {}> {
100
+ /**
101
+ * Unprocessed selector from user input.
102
+ */
103
+ rawSelector: string;
104
+ /**
105
+ * UnoCSS generator instance
106
+ */
107
+ generator: UnoGenerator;
108
+ /**
109
+ * The theme object
110
+ */
111
+ theme: Theme;
112
+ /**
113
+ * User-provided options from preset.
114
+ */
115
+ readonly options: PresetOptions;
89
116
  }
90
117
  interface ExtractorContext {
91
118
  readonly original: string;
92
119
  code: string;
93
120
  id?: string;
121
+ readonly options: PresetOptions;
94
122
  }
95
123
  interface Extractor {
96
124
  name: string;
@@ -143,8 +171,12 @@ interface VariantHandler {
143
171
  * Provide a parent selector(e.g. media query) to the output css.
144
172
  */
145
173
  parent?: string | [string, number] | undefined;
174
+ /**
175
+ * Variant ordering.
176
+ */
177
+ order?: number;
146
178
  }
147
- declare type VariantFunction<Theme extends {} = {}> = (matcher: string, raw: string, theme: Theme) => string | VariantHandler | undefined;
179
+ declare type VariantFunction<Theme extends {} = {}> = (matcher: string, context: Readonly<VariantContext<Theme>>) => string | VariantHandler | undefined;
148
180
  declare type VariantObject<Theme extends {} = {}> = {
149
181
  /**
150
182
  * The entry function to match and rewrite the selector for futher processing.
@@ -158,6 +190,8 @@ declare type VariantObject<Theme extends {} = {}> = {
158
190
  multiPass?: boolean;
159
191
  };
160
192
  declare type Variant<Theme extends {} = {}> = VariantFunction<Theme> | VariantObject<Theme>;
193
+ declare type Preprocessor = (matcher: string) => string | undefined;
194
+ declare type Postprocessor = (util: UtilObject) => void;
161
195
  interface ConfigBase<Theme extends {} = {}> {
162
196
  /**
163
197
  * Rules to generate CSS utilities
@@ -203,6 +237,14 @@ interface ConfigBase<Theme extends {} = {}> {
203
237
  * Custom function to sort layers.
204
238
  */
205
239
  sortLayers?: (layers: string[]) => string[];
240
+ /**
241
+ * Preprocess the incoming utilities, return falsy value to exclude
242
+ */
243
+ preprocess?: Preprocessor | Preprocessor[];
244
+ /**
245
+ * Process the generate utils object
246
+ */
247
+ postprocess?: Postprocessor | Postprocessor[];
206
248
  }
207
249
  interface Preset<Theme extends {} = {}> extends ConfigBase<Theme> {
208
250
  name: string;
@@ -210,7 +252,7 @@ interface Preset<Theme extends {} = {}> extends ConfigBase<Theme> {
210
252
  /**
211
253
  * Preset options for other tools like IDE to consume
212
254
  */
213
- options?: any;
255
+ options?: PresetOptions;
214
256
  }
215
257
  interface GeneratorOptions {
216
258
  /**
@@ -231,10 +273,6 @@ interface UserOnlyOptions<Theme extends {} = {}> {
231
273
  * The theme object, will be merged with the theme provides by presets
232
274
  */
233
275
  theme?: Theme;
234
- /**
235
- * Preprocess the incoming utilities, return falsy value to exclude
236
- */
237
- preprocess?: (matcher: string) => string | undefined;
238
276
  /**
239
277
  * Layout name of shortcuts
240
278
  *
@@ -282,9 +320,12 @@ interface UserConfigDefaults<Theme extends {} = {}> extends ConfigBase<Theme>, U
282
320
  interface ResolvedConfig extends Omit<RequiredByKey<UserConfig, 'mergeSelectors' | 'theme' | 'rules' | 'variants' | 'layers' | 'extractors' | 'blocklist' | 'safelist' | 'preflights' | 'sortLayers'>, 'rules' | 'shortcuts'> {
283
321
  shortcuts: Shortcut[];
284
322
  variants: VariantObject[];
323
+ preprocess: Preprocessor[];
324
+ postprocess: Postprocessor[];
285
325
  rulesSize: number;
286
326
  rulesDynamic: (DynamicRule | undefined)[];
287
327
  rulesStaticMap: Record<string, [number, CSSObject | CSSEntries, RuleMeta | undefined] | undefined>;
328
+ options: PresetOptions;
288
329
  }
289
330
  interface GenerateResult {
290
331
  css: string;
@@ -317,6 +358,11 @@ declare type StringifiedUtil = readonly [
317
358
  parent: string | undefined,
318
359
  meta: RuleMeta | undefined
319
360
  ];
361
+ interface UtilObject {
362
+ selector: string;
363
+ entries: CSSEntries;
364
+ parent: string | undefined;
365
+ }
320
366
  interface GenerateOptions {
321
367
  /**
322
368
  * Filepath of the file being processed.
@@ -409,4 +455,4 @@ declare const extractorSplit: Extractor;
409
455
 
410
456
  declare const extractorSvelte: Extractor;
411
457
 
412
- export { ArgumentType, Awaitable, BetterMap, BlocklistRule, CSSEntries, CSSObject, CSSValues, ConfigBase, DeepPartial, DynamicMatcher, DynamicRule, DynamicShortcut, DynamicShortcutMatcher, Extractor, ExtractorContext, FilterPattern, FlatObjectTuple, GenerateOptions, GenerateResult, GeneratorOptions, ParsedColorValue, ParsedUtil, PartialByKeys, PluginOptions, Preflight, Preset, RGBAColorValue, RawUtil, RequiredByKey, ResolvedConfig, RestArgs, Rule, RuleContext, RuleMeta, Shift, Shortcut, StaticRule, StaticShortcut, StaticShortcutMap, StringifiedUtil, TwoKeyMap, UnoGenerator, UserConfig, UserConfigDefaults, UserOnlyOptions, UserShortcuts, ValueHandler, ValueHandlerCallback, Variant, VariantFunction, VariantHandler, VariantMatchedResult, VariantObject, attributifyRE, clearIdenticalEntries, createGenerator, createValueHandler, e, entriesToCss, escapeRegExp, escapeSelector, expandVariantGroup, extractorSplit, extractorSvelte, hasScopePlaceholder, hex2rgba, isAttributifySelector, isObject, isRawUtil, isStaticRule, isStaticShortcut, isValidSelector, mergeDeep, mergeSet, normalizeCSSEntries, normalizeCSSValues, normalizeVariant, notNull, regexClassGroup, toArray, uniq, validateFilterRE, warnOnce, withLayer };
458
+ export { ArgumentType, Awaitable, BetterMap, BlocklistRule, CSSEntries, CSSObject, CSSValues, ConfigBase, DeepPartial, DynamicMatcher, DynamicRule, DynamicShortcut, DynamicShortcutMatcher, Extractor, ExtractorContext, FilterPattern, FlatObjectTuple, GenerateOptions, GenerateResult, GeneratorOptions, ParsedColorValue, ParsedUtil, PartialByKeys, PluginOptions, Postprocessor, Preflight, Preprocessor, Preset, PresetOptions, RGBAColorValue, RawUtil, RequiredByKey, ResolvedConfig, RestArgs, Rule, RuleContext, RuleMeta, Shift, Shortcut, StaticRule, StaticShortcut, StaticShortcutMap, StringifiedUtil, TwoKeyMap, UnoGenerator, UserConfig, UserConfigDefaults, UserOnlyOptions, UserShortcuts, UtilObject, ValueHandler, ValueHandlerCallback, Variant, VariantContext, VariantFunction, VariantHandler, VariantMatchedResult, VariantObject, attributifyRE, clearIdenticalEntries, createGenerator, createValueHandler, e, entriesToCss, escapeRegExp, escapeSelector, expandVariantGroup, extractorSplit, extractorSvelte, 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
@@ -333,6 +333,7 @@ function resolveConfig(userConfig = {}, defaults = {}) {
333
333
  ...sortedPresets.map((p) => p.theme || {}),
334
334
  config.theme || {}
335
335
  ].reduce((a, p) => mergeDeep(a, p), {});
336
+ const options = Object.assign({}, ...config.presets?.map((p) => Array.isArray(p) ? p : [p]).flat(1).map((p) => p.options ?? {}) || []);
336
337
  return {
337
338
  mergeSelectors: true,
338
339
  warn: true,
@@ -348,14 +349,17 @@ function resolveConfig(userConfig = {}, defaults = {}) {
348
349
  rulesSize,
349
350
  rulesDynamic: rules,
350
351
  rulesStaticMap,
352
+ preprocess: mergePresets("preprocess"),
353
+ postprocess: mergePresets("postprocess"),
351
354
  preflights: mergePresets("preflights"),
352
355
  variants: mergePresets("variants").map(normalizeVariant),
353
356
  shortcuts: resolveShortcuts(mergePresets("shortcuts")),
354
- extractors
357
+ extractors,
358
+ options
355
359
  };
356
360
  }
357
361
 
358
- const version = "0.18.1";
362
+ const version = "0.20.2";
359
363
 
360
364
  class UnoGenerator {
361
365
  constructor(userConfig = {}, defaults = {}) {
@@ -384,7 +388,8 @@ class UnoGenerator {
384
388
  return code;
385
389
  },
386
390
  code,
387
- id
391
+ id,
392
+ options: this.config.options
388
393
  };
389
394
  for (const extractor of this.config.extractors) {
390
395
  const result = await extractor.extract(context);
@@ -432,8 +437,8 @@ class UnoGenerator {
432
437
  return;
433
438
  }
434
439
  let current = raw;
435
- if (this.config.preprocess)
436
- current = this.config.preprocess(raw);
440
+ for (const p of this.config.preprocess)
441
+ current = p(raw);
437
442
  if (this.isBlocked(current))
438
443
  return block(current);
439
444
  const applied = this.matchVariants(raw, current);
@@ -445,7 +450,8 @@ class UnoGenerator {
445
450
  theme: this.config.theme,
446
451
  generator: this,
447
452
  variantHandlers: applied[2],
448
- constructCSS: (...args) => this.constructCustomCSS(context, ...args)
453
+ constructCSS: (...args) => this.constructCustomCSS(context, ...args),
454
+ options: this.config.options
449
455
  };
450
456
  const expanded = this.expandShortcut(applied[1], context);
451
457
  if (expanded) {
@@ -470,7 +476,13 @@ class UnoGenerator {
470
476
  const getLayer = (layer) => {
471
477
  if (layerCache[layer])
472
478
  return layerCache[layer];
473
- let css = Array.from(sheet).sort((a, b) => (this.parentOrders.get(a[0]) || 0) - (this.parentOrders.get(b[0]) || 0)).map(([parent, items]) => {
479
+ let css = Array.from(sheet).sort((a, b) => {
480
+ const parentOrderA = this.parentOrders.get(a[0]);
481
+ const parentOrderB = this.parentOrders.get(b[0]);
482
+ if (parentOrderA !== void 0 && parentOrderB !== void 0)
483
+ return parentOrderA - parentOrderB;
484
+ return a[0]?.localeCompare(b[0] || "");
485
+ }).map(([parent, items]) => {
474
486
  const size = items.length;
475
487
  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]]);
476
488
  if (!sorted.length)
@@ -515,12 +527,18 @@ class UnoGenerator {
515
527
  const handlers = [];
516
528
  let processed = current || raw;
517
529
  let applied = false;
530
+ const context = {
531
+ rawSelector: raw,
532
+ theme: this.config.theme,
533
+ generator: this,
534
+ options: this.config.options
535
+ };
518
536
  while (true) {
519
537
  applied = false;
520
538
  for (const v of this.config.variants) {
521
539
  if (!v.multiPass && usedVariants.has(v))
522
540
  continue;
523
- let handler = v.match(processed, raw, this.config.theme);
541
+ let handler = v.match(processed, context);
524
542
  if (!handler)
525
543
  continue;
526
544
  if (typeof handler === "string")
@@ -543,19 +561,23 @@ class UnoGenerator {
543
561
  return [raw, processed, handlers];
544
562
  }
545
563
  applyVariants(parsed, variantHandlers = parsed[4], raw = parsed[1]) {
546
- const entries = variantHandlers.reduce((p, v) => v.body?.(p) || p, parsed[2]);
547
- return [
548
- variantHandlers.reduce((p, v) => v.selector?.(p, entries) || p, toEscapedSelector(raw)),
564
+ const handlers = [...variantHandlers].sort((a, b) => (a.order || 0) - (b.order || 0));
565
+ const entries = handlers.reduce((p, v) => v.body?.(p) || p, parsed[2]);
566
+ const obj = {
567
+ selector: handlers.reduce((p, v) => v.selector?.(p, entries) || p, toEscapedSelector(raw)),
549
568
  entries,
550
- variantHandlers.reduce((p, v) => Array.isArray(v.parent) ? v.parent[0] : v.parent || p, void 0)
551
- ];
569
+ parent: handlers.reduce((p, v) => Array.isArray(v.parent) ? v.parent[0] : v.parent || p, void 0)
570
+ };
571
+ for (const p of this.config.postprocess)
572
+ p(obj);
573
+ return obj;
552
574
  }
553
575
  constructCustomCSS(context, body, overrideSelector) {
554
576
  body = normalizeCSSEntries(body);
555
- const [selector, entries, mediaQuery] = this.applyVariants([0, overrideSelector || context.rawSelector, body, void 0, context.variantHandlers]);
577
+ const { selector, entries, parent } = this.applyVariants([0, overrideSelector || context.rawSelector, body, void 0, context.variantHandlers]);
556
578
  const cssBody = `${selector}{${entriesToCss(entries)}}`;
557
- if (mediaQuery)
558
- return `${mediaQuery}{${cssBody}}`;
579
+ if (parent)
580
+ return `${parent}{${cssBody}}`;
559
581
  return cssBody;
560
582
  }
561
583
  async parseUtil(input, context, internal = false) {
@@ -592,11 +614,11 @@ class UnoGenerator {
592
614
  return;
593
615
  if (isRawUtil(parsed))
594
616
  return [parsed[0], void 0, parsed[1], void 0, parsed[2]];
595
- const [selector, entries, mediaQuery] = this.applyVariants(parsed);
617
+ const { selector, entries, parent } = this.applyVariants(parsed);
596
618
  const body = entriesToCss(entries);
597
619
  if (!body)
598
620
  return;
599
- return [parsed[0], selector, body, mediaQuery, parsed[3]];
621
+ return [parsed[0], selector, body, parent, parsed[3]];
600
622
  }
601
623
  expandShortcut(processed, context, depth = 3) {
602
624
  if (depth === 0)
@@ -641,8 +663,8 @@ class UnoGenerator {
641
663
  for (const item of parsed) {
642
664
  if (isRawUtil(item))
643
665
  continue;
644
- const [selector, entries, mediaQuery] = this.applyVariants(item, [...item[4], ...parentVariants], raw);
645
- const mapItem = selectorMap.getFallback(selector, mediaQuery, [[], item[0]]);
666
+ const { selector, entries, parent: parent2 } = this.applyVariants(item, [...item[4], ...parentVariants], raw);
667
+ const mapItem = selectorMap.getFallback(selector, parent2, [[], item[0]]);
646
668
  mapItem[0].push(...entries);
647
669
  if (item[0] > mapItem[1])
648
670
  mapItem[1] = item[0];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unocss/core",
3
- "version": "0.18.1",
3
+ "version": "0.20.2",
4
4
  "description": "The instant on-demand Atomic CSS engine.",
5
5
  "keywords": [
6
6
  "unocss",