@unocss/core 0.19.0 → 0.20.4
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 +23 -26
- package/dist/index.d.ts +29 -11
- package/dist/index.mjs +24 -26
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -110,13 +110,6 @@ function mergeSet(target, append) {
|
|
|
110
110
|
append.forEach((i) => target.add(i));
|
|
111
111
|
return target;
|
|
112
112
|
}
|
|
113
|
-
function cacheFunction(fn) {
|
|
114
|
-
const cache = Object.create(null);
|
|
115
|
-
return (str) => {
|
|
116
|
-
const hit = cache[str];
|
|
117
|
-
return hit || (cache[str] = fn(str));
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
113
|
|
|
121
114
|
const hexRE = /^#?([\da-f]+)$/i;
|
|
122
115
|
function hex2rgba(hex = "") {
|
|
@@ -256,7 +249,6 @@ function createValueHandler(handlers) {
|
|
|
256
249
|
if (res != null)
|
|
257
250
|
return res;
|
|
258
251
|
}
|
|
259
|
-
return void 0;
|
|
260
252
|
};
|
|
261
253
|
function addProcessor(that, name) {
|
|
262
254
|
if (!that.__options) {
|
|
@@ -360,6 +352,8 @@ function resolveConfig(userConfig = {}, defaults = {}) {
|
|
|
360
352
|
rulesSize,
|
|
361
353
|
rulesDynamic: rules,
|
|
362
354
|
rulesStaticMap,
|
|
355
|
+
preprocess: mergePresets("preprocess"),
|
|
356
|
+
postprocess: mergePresets("postprocess"),
|
|
363
357
|
preflights: mergePresets("preflights"),
|
|
364
358
|
variants: mergePresets("variants").map(normalizeVariant),
|
|
365
359
|
shortcuts: resolveShortcuts(mergePresets("shortcuts")),
|
|
@@ -368,7 +362,7 @@ function resolveConfig(userConfig = {}, defaults = {}) {
|
|
|
368
362
|
};
|
|
369
363
|
}
|
|
370
364
|
|
|
371
|
-
const version = "0.
|
|
365
|
+
const version = "0.20.4";
|
|
372
366
|
|
|
373
367
|
class UnoGenerator {
|
|
374
368
|
constructor(userConfig = {}, defaults = {}) {
|
|
@@ -446,8 +440,8 @@ class UnoGenerator {
|
|
|
446
440
|
return;
|
|
447
441
|
}
|
|
448
442
|
let current = raw;
|
|
449
|
-
|
|
450
|
-
current =
|
|
443
|
+
for (const p of this.config.preprocess)
|
|
444
|
+
current = p(raw);
|
|
451
445
|
if (this.isBlocked(current))
|
|
452
446
|
return block(current);
|
|
453
447
|
const applied = this.matchVariants(raw, current);
|
|
@@ -485,7 +479,7 @@ class UnoGenerator {
|
|
|
485
479
|
const getLayer = (layer) => {
|
|
486
480
|
if (layerCache[layer])
|
|
487
481
|
return layerCache[layer];
|
|
488
|
-
let css = Array.from(sheet).sort((a, b) => (this.parentOrders.get(a[0])
|
|
482
|
+
let css = Array.from(sheet).sort((a, b) => (this.parentOrders.get(a[0]) ?? 0) - (this.parentOrders.get(b[0]) ?? 0) || a[0]?.localeCompare(b[0] || "") || 0).map(([parent, items]) => {
|
|
489
483
|
const size = items.length;
|
|
490
484
|
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]]);
|
|
491
485
|
if (!sorted.length)
|
|
@@ -495,7 +489,7 @@ class UnoGenerator {
|
|
|
495
489
|
for (let i = idx + 1; i < size; i++) {
|
|
496
490
|
const current = sorted[i];
|
|
497
491
|
if (current && current[0] && current[1] === body) {
|
|
498
|
-
current[0] = `${current[0]},${selector}`;
|
|
492
|
+
current[0] = `${current[0]},${nl}${selector}`;
|
|
499
493
|
return null;
|
|
500
494
|
}
|
|
501
495
|
}
|
|
@@ -564,19 +558,23 @@ class UnoGenerator {
|
|
|
564
558
|
return [raw, processed, handlers];
|
|
565
559
|
}
|
|
566
560
|
applyVariants(parsed, variantHandlers = parsed[4], raw = parsed[1]) {
|
|
567
|
-
const
|
|
568
|
-
|
|
569
|
-
|
|
561
|
+
const handlers = [...variantHandlers].sort((a, b) => (a.order || 0) - (b.order || 0));
|
|
562
|
+
const entries = handlers.reduce((p, v) => v.body?.(p) || p, parsed[2]);
|
|
563
|
+
const obj = {
|
|
564
|
+
selector: handlers.reduce((p, v) => v.selector?.(p, entries) || p, toEscapedSelector(raw)),
|
|
570
565
|
entries,
|
|
571
|
-
|
|
572
|
-
|
|
566
|
+
parent: handlers.reduce((p, v) => Array.isArray(v.parent) ? v.parent[0] : v.parent || p, void 0)
|
|
567
|
+
};
|
|
568
|
+
for (const p of this.config.postprocess)
|
|
569
|
+
p(obj);
|
|
570
|
+
return obj;
|
|
573
571
|
}
|
|
574
572
|
constructCustomCSS(context, body, overrideSelector) {
|
|
575
573
|
body = normalizeCSSEntries(body);
|
|
576
|
-
const
|
|
574
|
+
const { selector, entries, parent } = this.applyVariants([0, overrideSelector || context.rawSelector, body, void 0, context.variantHandlers]);
|
|
577
575
|
const cssBody = `${selector}{${entriesToCss(entries)}}`;
|
|
578
|
-
if (
|
|
579
|
-
return `${
|
|
576
|
+
if (parent)
|
|
577
|
+
return `${parent}{${cssBody}}`;
|
|
580
578
|
return cssBody;
|
|
581
579
|
}
|
|
582
580
|
async parseUtil(input, context, internal = false) {
|
|
@@ -613,11 +611,11 @@ class UnoGenerator {
|
|
|
613
611
|
return;
|
|
614
612
|
if (isRawUtil(parsed))
|
|
615
613
|
return [parsed[0], void 0, parsed[1], void 0, parsed[2]];
|
|
616
|
-
const
|
|
614
|
+
const { selector, entries, parent } = this.applyVariants(parsed);
|
|
617
615
|
const body = entriesToCss(entries);
|
|
618
616
|
if (!body)
|
|
619
617
|
return;
|
|
620
|
-
return [parsed[0], selector, body,
|
|
618
|
+
return [parsed[0], selector, body, parent, parsed[3]];
|
|
621
619
|
}
|
|
622
620
|
expandShortcut(processed, context, depth = 3) {
|
|
623
621
|
if (depth === 0)
|
|
@@ -662,8 +660,8 @@ class UnoGenerator {
|
|
|
662
660
|
for (const item of parsed) {
|
|
663
661
|
if (isRawUtil(item))
|
|
664
662
|
continue;
|
|
665
|
-
const
|
|
666
|
-
const mapItem = selectorMap.getFallback(selector,
|
|
663
|
+
const { selector, entries, parent: parent2 } = this.applyVariants(item, [...item[4], ...parentVariants], raw);
|
|
664
|
+
const mapItem = selectorMap.getFallback(selector, parent2, [[], item[0]]);
|
|
667
665
|
mapItem[0].push(...entries);
|
|
668
666
|
if (item[0] > mapItem[1])
|
|
669
667
|
mapItem[1] = item[0];
|
|
@@ -701,7 +699,6 @@ exports.BetterMap = BetterMap;
|
|
|
701
699
|
exports.TwoKeyMap = TwoKeyMap;
|
|
702
700
|
exports.UnoGenerator = UnoGenerator;
|
|
703
701
|
exports.attributifyRE = attributifyRE;
|
|
704
|
-
exports.cacheFunction = cacheFunction;
|
|
705
702
|
exports.clearIdenticalEntries = clearIdenticalEntries;
|
|
706
703
|
exports.createGenerator = createGenerator;
|
|
707
704
|
exports.createValueHandler = createValueHandler;
|
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):
|
|
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,13 +51,17 @@ declare type ParsedColorValue = {
|
|
|
51
51
|
*/
|
|
52
52
|
name: string;
|
|
53
53
|
/**
|
|
54
|
-
* Color scale
|
|
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
|
};
|
|
62
66
|
declare type PresetOptions = Record<string, any>;
|
|
63
67
|
interface RuleContext<Theme extends {} = {}> {
|
|
@@ -167,6 +171,10 @@ interface VariantHandler {
|
|
|
167
171
|
* Provide a parent selector(e.g. media query) to the output css.
|
|
168
172
|
*/
|
|
169
173
|
parent?: string | [string, number] | undefined;
|
|
174
|
+
/**
|
|
175
|
+
* Variant ordering.
|
|
176
|
+
*/
|
|
177
|
+
order?: number;
|
|
170
178
|
}
|
|
171
179
|
declare type VariantFunction<Theme extends {} = {}> = (matcher: string, context: Readonly<VariantContext<Theme>>) => string | VariantHandler | undefined;
|
|
172
180
|
declare type VariantObject<Theme extends {} = {}> = {
|
|
@@ -182,6 +190,8 @@ declare type VariantObject<Theme extends {} = {}> = {
|
|
|
182
190
|
multiPass?: boolean;
|
|
183
191
|
};
|
|
184
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;
|
|
185
195
|
interface ConfigBase<Theme extends {} = {}> {
|
|
186
196
|
/**
|
|
187
197
|
* Rules to generate CSS utilities
|
|
@@ -227,6 +237,14 @@ interface ConfigBase<Theme extends {} = {}> {
|
|
|
227
237
|
* Custom function to sort layers.
|
|
228
238
|
*/
|
|
229
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[];
|
|
230
248
|
}
|
|
231
249
|
interface Preset<Theme extends {} = {}> extends ConfigBase<Theme> {
|
|
232
250
|
name: string;
|
|
@@ -234,7 +252,7 @@ interface Preset<Theme extends {} = {}> extends ConfigBase<Theme> {
|
|
|
234
252
|
/**
|
|
235
253
|
* Preset options for other tools like IDE to consume
|
|
236
254
|
*/
|
|
237
|
-
options?:
|
|
255
|
+
options?: PresetOptions;
|
|
238
256
|
}
|
|
239
257
|
interface GeneratorOptions {
|
|
240
258
|
/**
|
|
@@ -255,10 +273,6 @@ interface UserOnlyOptions<Theme extends {} = {}> {
|
|
|
255
273
|
* The theme object, will be merged with the theme provides by presets
|
|
256
274
|
*/
|
|
257
275
|
theme?: Theme;
|
|
258
|
-
/**
|
|
259
|
-
* Preprocess the incoming utilities, return falsy value to exclude
|
|
260
|
-
*/
|
|
261
|
-
preprocess?: (matcher: string) => string | undefined;
|
|
262
276
|
/**
|
|
263
277
|
* Layout name of shortcuts
|
|
264
278
|
*
|
|
@@ -306,6 +320,8 @@ interface UserConfigDefaults<Theme extends {} = {}> extends ConfigBase<Theme>, U
|
|
|
306
320
|
interface ResolvedConfig extends Omit<RequiredByKey<UserConfig, 'mergeSelectors' | 'theme' | 'rules' | 'variants' | 'layers' | 'extractors' | 'blocklist' | 'safelist' | 'preflights' | 'sortLayers'>, 'rules' | 'shortcuts'> {
|
|
307
321
|
shortcuts: Shortcut[];
|
|
308
322
|
variants: VariantObject[];
|
|
323
|
+
preprocess: Preprocessor[];
|
|
324
|
+
postprocess: Postprocessor[];
|
|
309
325
|
rulesSize: number;
|
|
310
326
|
rulesDynamic: (DynamicRule | undefined)[];
|
|
311
327
|
rulesStaticMap: Record<string, [number, CSSObject | CSSEntries, RuleMeta | undefined] | undefined>;
|
|
@@ -342,6 +358,11 @@ declare type StringifiedUtil = readonly [
|
|
|
342
358
|
parent: string | undefined,
|
|
343
359
|
meta: RuleMeta | undefined
|
|
344
360
|
];
|
|
361
|
+
interface UtilObject {
|
|
362
|
+
selector: string;
|
|
363
|
+
entries: CSSEntries;
|
|
364
|
+
parent: string | undefined;
|
|
365
|
+
}
|
|
345
366
|
interface GenerateOptions {
|
|
346
367
|
/**
|
|
347
368
|
* Filepath of the file being processed.
|
|
@@ -387,9 +408,6 @@ declare function isStaticShortcut(sc: Shortcut): sc is StaticShortcut;
|
|
|
387
408
|
declare function toArray<T>(value?: T | T[]): T[];
|
|
388
409
|
declare function uniq<T>(value: T[]): T[];
|
|
389
410
|
declare function mergeSet<T>(target: Set<T>, append: Set<T>): Set<T>;
|
|
390
|
-
declare function cacheFunction<T extends (str: string) => R, R extends string | {
|
|
391
|
-
readonly [key: string]: string | number;
|
|
392
|
-
}>(fn: T): T;
|
|
393
411
|
|
|
394
412
|
declare function hex2rgba(hex?: string): RGBAColorValue | undefined;
|
|
395
413
|
|
|
@@ -437,4 +455,4 @@ declare const extractorSplit: Extractor;
|
|
|
437
455
|
|
|
438
456
|
declare const extractorSvelte: Extractor;
|
|
439
457
|
|
|
440
|
-
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, PresetOptions, RGBAColorValue, RawUtil, RequiredByKey, ResolvedConfig, RestArgs, Rule, RuleContext, RuleMeta, Shift, Shortcut, StaticRule, StaticShortcut, StaticShortcutMap, StringifiedUtil, TwoKeyMap, UnoGenerator, UserConfig, UserConfigDefaults, UserOnlyOptions, UserShortcuts, ValueHandler, ValueHandlerCallback, Variant, VariantContext, VariantFunction, VariantHandler, VariantMatchedResult, VariantObject, attributifyRE,
|
|
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
|
@@ -106,13 +106,6 @@ function mergeSet(target, append) {
|
|
|
106
106
|
append.forEach((i) => target.add(i));
|
|
107
107
|
return target;
|
|
108
108
|
}
|
|
109
|
-
function cacheFunction(fn) {
|
|
110
|
-
const cache = Object.create(null);
|
|
111
|
-
return (str) => {
|
|
112
|
-
const hit = cache[str];
|
|
113
|
-
return hit || (cache[str] = fn(str));
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
109
|
|
|
117
110
|
const hexRE = /^#?([\da-f]+)$/i;
|
|
118
111
|
function hex2rgba(hex = "") {
|
|
@@ -252,7 +245,6 @@ function createValueHandler(handlers) {
|
|
|
252
245
|
if (res != null)
|
|
253
246
|
return res;
|
|
254
247
|
}
|
|
255
|
-
return void 0;
|
|
256
248
|
};
|
|
257
249
|
function addProcessor(that, name) {
|
|
258
250
|
if (!that.__options) {
|
|
@@ -356,6 +348,8 @@ function resolveConfig(userConfig = {}, defaults = {}) {
|
|
|
356
348
|
rulesSize,
|
|
357
349
|
rulesDynamic: rules,
|
|
358
350
|
rulesStaticMap,
|
|
351
|
+
preprocess: mergePresets("preprocess"),
|
|
352
|
+
postprocess: mergePresets("postprocess"),
|
|
359
353
|
preflights: mergePresets("preflights"),
|
|
360
354
|
variants: mergePresets("variants").map(normalizeVariant),
|
|
361
355
|
shortcuts: resolveShortcuts(mergePresets("shortcuts")),
|
|
@@ -364,7 +358,7 @@ function resolveConfig(userConfig = {}, defaults = {}) {
|
|
|
364
358
|
};
|
|
365
359
|
}
|
|
366
360
|
|
|
367
|
-
const version = "0.
|
|
361
|
+
const version = "0.20.4";
|
|
368
362
|
|
|
369
363
|
class UnoGenerator {
|
|
370
364
|
constructor(userConfig = {}, defaults = {}) {
|
|
@@ -442,8 +436,8 @@ class UnoGenerator {
|
|
|
442
436
|
return;
|
|
443
437
|
}
|
|
444
438
|
let current = raw;
|
|
445
|
-
|
|
446
|
-
current =
|
|
439
|
+
for (const p of this.config.preprocess)
|
|
440
|
+
current = p(raw);
|
|
447
441
|
if (this.isBlocked(current))
|
|
448
442
|
return block(current);
|
|
449
443
|
const applied = this.matchVariants(raw, current);
|
|
@@ -481,7 +475,7 @@ class UnoGenerator {
|
|
|
481
475
|
const getLayer = (layer) => {
|
|
482
476
|
if (layerCache[layer])
|
|
483
477
|
return layerCache[layer];
|
|
484
|
-
let css = Array.from(sheet).sort((a, b) => (this.parentOrders.get(a[0])
|
|
478
|
+
let css = Array.from(sheet).sort((a, b) => (this.parentOrders.get(a[0]) ?? 0) - (this.parentOrders.get(b[0]) ?? 0) || a[0]?.localeCompare(b[0] || "") || 0).map(([parent, items]) => {
|
|
485
479
|
const size = items.length;
|
|
486
480
|
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]]);
|
|
487
481
|
if (!sorted.length)
|
|
@@ -491,7 +485,7 @@ class UnoGenerator {
|
|
|
491
485
|
for (let i = idx + 1; i < size; i++) {
|
|
492
486
|
const current = sorted[i];
|
|
493
487
|
if (current && current[0] && current[1] === body) {
|
|
494
|
-
current[0] = `${current[0]},${selector}`;
|
|
488
|
+
current[0] = `${current[0]},${nl}${selector}`;
|
|
495
489
|
return null;
|
|
496
490
|
}
|
|
497
491
|
}
|
|
@@ -560,19 +554,23 @@ class UnoGenerator {
|
|
|
560
554
|
return [raw, processed, handlers];
|
|
561
555
|
}
|
|
562
556
|
applyVariants(parsed, variantHandlers = parsed[4], raw = parsed[1]) {
|
|
563
|
-
const
|
|
564
|
-
|
|
565
|
-
|
|
557
|
+
const handlers = [...variantHandlers].sort((a, b) => (a.order || 0) - (b.order || 0));
|
|
558
|
+
const entries = handlers.reduce((p, v) => v.body?.(p) || p, parsed[2]);
|
|
559
|
+
const obj = {
|
|
560
|
+
selector: handlers.reduce((p, v) => v.selector?.(p, entries) || p, toEscapedSelector(raw)),
|
|
566
561
|
entries,
|
|
567
|
-
|
|
568
|
-
|
|
562
|
+
parent: handlers.reduce((p, v) => Array.isArray(v.parent) ? v.parent[0] : v.parent || p, void 0)
|
|
563
|
+
};
|
|
564
|
+
for (const p of this.config.postprocess)
|
|
565
|
+
p(obj);
|
|
566
|
+
return obj;
|
|
569
567
|
}
|
|
570
568
|
constructCustomCSS(context, body, overrideSelector) {
|
|
571
569
|
body = normalizeCSSEntries(body);
|
|
572
|
-
const
|
|
570
|
+
const { selector, entries, parent } = this.applyVariants([0, overrideSelector || context.rawSelector, body, void 0, context.variantHandlers]);
|
|
573
571
|
const cssBody = `${selector}{${entriesToCss(entries)}}`;
|
|
574
|
-
if (
|
|
575
|
-
return `${
|
|
572
|
+
if (parent)
|
|
573
|
+
return `${parent}{${cssBody}}`;
|
|
576
574
|
return cssBody;
|
|
577
575
|
}
|
|
578
576
|
async parseUtil(input, context, internal = false) {
|
|
@@ -609,11 +607,11 @@ class UnoGenerator {
|
|
|
609
607
|
return;
|
|
610
608
|
if (isRawUtil(parsed))
|
|
611
609
|
return [parsed[0], void 0, parsed[1], void 0, parsed[2]];
|
|
612
|
-
const
|
|
610
|
+
const { selector, entries, parent } = this.applyVariants(parsed);
|
|
613
611
|
const body = entriesToCss(entries);
|
|
614
612
|
if (!body)
|
|
615
613
|
return;
|
|
616
|
-
return [parsed[0], selector, body,
|
|
614
|
+
return [parsed[0], selector, body, parent, parsed[3]];
|
|
617
615
|
}
|
|
618
616
|
expandShortcut(processed, context, depth = 3) {
|
|
619
617
|
if (depth === 0)
|
|
@@ -658,8 +656,8 @@ class UnoGenerator {
|
|
|
658
656
|
for (const item of parsed) {
|
|
659
657
|
if (isRawUtil(item))
|
|
660
658
|
continue;
|
|
661
|
-
const
|
|
662
|
-
const mapItem = selectorMap.getFallback(selector,
|
|
659
|
+
const { selector, entries, parent: parent2 } = this.applyVariants(item, [...item[4], ...parentVariants], raw);
|
|
660
|
+
const mapItem = selectorMap.getFallback(selector, parent2, [[], item[0]]);
|
|
663
661
|
mapItem[0].push(...entries);
|
|
664
662
|
if (item[0] > mapItem[1])
|
|
665
663
|
mapItem[1] = item[0];
|
|
@@ -693,4 +691,4 @@ function toEscapedSelector(raw) {
|
|
|
693
691
|
return `.${e(raw)}`;
|
|
694
692
|
}
|
|
695
693
|
|
|
696
|
-
export { BetterMap, TwoKeyMap, UnoGenerator, attributifyRE,
|
|
694
|
+
export { BetterMap, TwoKeyMap, UnoGenerator, 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 };
|