@unocss/core 0.12.17 → 0.14.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.d.ts +34 -5
- package/dist/index.js +37 -17
- package/dist/index.mjs +34 -17
- package/package.json +1 -1
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>;
|
|
@@ -21,6 +21,8 @@ declare class UnoGenerator {
|
|
|
21
21
|
}
|
|
22
22
|
declare function createGenerator(config?: UserConfig, defaults?: UserConfigDefaults): UnoGenerator;
|
|
23
23
|
declare const hasScopePlaceholder: (css: string) => RegExpMatchArray | null;
|
|
24
|
+
declare function normalizeCSSEntries(obj: CSSEntries | CSSObject): CSSEntries;
|
|
25
|
+
declare function normalizeCSSValues(obj: CSSValues): CSSEntries[];
|
|
24
26
|
|
|
25
27
|
declare type Awaitable<T> = T | Promise<T>;
|
|
26
28
|
declare type ArgumentType<T> = T extends ((...args: infer A) => any) ? A : never;
|
|
@@ -33,6 +35,7 @@ declare type FlatObjectTuple<T> = {
|
|
|
33
35
|
[K in keyof T]: T[K];
|
|
34
36
|
};
|
|
35
37
|
declare type PartialByKeys<T, K extends keyof T = keyof T> = FlatObjectTuple<Partial<Pick<T, Extract<keyof T, K>>> & Omit<T, K>>;
|
|
38
|
+
declare type RequiredByKey<T, K extends keyof T = keyof T> = FlatObjectTuple<Required<Pick<T, Extract<keyof T, K>>> & Omit<T, K>>;
|
|
36
39
|
declare type CSSObject = Record<string, string | number | undefined>;
|
|
37
40
|
declare type CSSEntries = [string, string | number | undefined][];
|
|
38
41
|
interface RuleContext<Theme extends {} = {}> {
|
|
@@ -85,7 +88,8 @@ interface RuleMeta {
|
|
|
85
88
|
*/
|
|
86
89
|
internal?: boolean;
|
|
87
90
|
}
|
|
88
|
-
declare type
|
|
91
|
+
declare type CSSValues = CSSObject | CSSEntries | (CSSObject | CSSEntries)[];
|
|
92
|
+
declare type DynamicMatcher<Theme extends {} = {}> = ((match: string[], context: Readonly<RuleContext<Theme>>) => Awaitable<CSSValues | string | undefined>);
|
|
89
93
|
declare type DynamicRule<Theme extends {} = {}> = [RegExp, DynamicMatcher<Theme>] | [RegExp, DynamicMatcher<Theme>, RuleMeta];
|
|
90
94
|
declare type StaticRule = [string, CSSObject | CSSEntries] | [string, CSSObject | CSSEntries, RuleMeta];
|
|
91
95
|
declare type Rule<Theme extends {} = {}> = DynamicRule<Theme> | StaticRule;
|
|
@@ -95,6 +99,7 @@ declare type StaticShortcutMap = Record<string, string | string[]>;
|
|
|
95
99
|
declare type DynamicShortcut<Theme extends {} = {}> = [RegExp, DynamicShortcutMatcher<Theme>] | [RegExp, DynamicShortcutMatcher<Theme>, RuleMeta];
|
|
96
100
|
declare type UserShortcuts<Theme extends {} = {}> = StaticShortcutMap | (StaticShortcut | DynamicShortcut<Theme> | StaticShortcutMap)[];
|
|
97
101
|
declare type Shortcut<Theme extends {} = {}> = StaticShortcut | DynamicShortcut<Theme>;
|
|
102
|
+
declare type FilterPattern = ReadonlyArray<string | RegExp> | string | RegExp | null;
|
|
98
103
|
interface Preflight {
|
|
99
104
|
getCSS: () => string | undefined;
|
|
100
105
|
layer?: string;
|
|
@@ -226,11 +231,34 @@ interface UserOnlyOptions<Theme extends {} = {}> {
|
|
|
226
231
|
*/
|
|
227
232
|
envMode?: 'dev' | 'build';
|
|
228
233
|
}
|
|
229
|
-
|
|
234
|
+
/**
|
|
235
|
+
* For other modules to aggregate the options
|
|
236
|
+
*/
|
|
237
|
+
interface PluginOptions {
|
|
238
|
+
/**
|
|
239
|
+
* Load from configs files
|
|
240
|
+
*
|
|
241
|
+
* set `false` to disable
|
|
242
|
+
*/
|
|
243
|
+
configFile?: string | false;
|
|
244
|
+
/**
|
|
245
|
+
* List of files that will also triggers config reloads
|
|
246
|
+
*/
|
|
247
|
+
configDeps?: string[];
|
|
248
|
+
/**
|
|
249
|
+
* Patterns that filter the files being extracted.
|
|
250
|
+
*/
|
|
251
|
+
include?: FilterPattern;
|
|
252
|
+
/**
|
|
253
|
+
* Patterns that filter the files NOT being extracted.
|
|
254
|
+
*/
|
|
255
|
+
exclude?: FilterPattern;
|
|
256
|
+
}
|
|
257
|
+
interface UserConfig<Theme extends {} = {}> extends ConfigBase<Theme>, UserOnlyOptions<Theme>, GeneratorOptions, PluginOptions {
|
|
230
258
|
}
|
|
231
259
|
interface UserConfigDefaults<Theme extends {} = {}> extends ConfigBase<Theme>, UserOnlyOptions<Theme> {
|
|
232
260
|
}
|
|
233
|
-
interface ResolvedConfig extends Omit<
|
|
261
|
+
interface ResolvedConfig extends Omit<RequiredByKey<UserConfig, 'mergeSelectors' | 'theme' | 'rules' | 'variants' | 'layers' | 'extractors' | 'blocklist' | 'safelist' | 'preflights' | 'sortLayers'>, 'rules' | 'shortcuts'> {
|
|
234
262
|
shortcuts: Shortcut[];
|
|
235
263
|
variants: VariantObject[];
|
|
236
264
|
rulesSize: number;
|
|
@@ -319,6 +347,7 @@ declare function isAttributifySelector(selector: string): RegExpMatchArray | nul
|
|
|
319
347
|
declare function isValidSelector(selector?: string): selector is string;
|
|
320
348
|
declare function normalizeVariant(variant: Variant): VariantObject;
|
|
321
349
|
declare function isRawUtil(util: ParsedUtil | RawUtil | StringifiedUtil): util is RawUtil;
|
|
350
|
+
declare function notNull<T>(value: T | null | undefined): value is T;
|
|
322
351
|
|
|
323
352
|
declare class TwoKeyMap<K1, K2, V> {
|
|
324
353
|
_map: Map<K1, Map<K2, V>>;
|
|
@@ -343,4 +372,4 @@ declare function warnOnce(msg: string): void;
|
|
|
343
372
|
|
|
344
373
|
declare const extractorSplit: Extractor;
|
|
345
374
|
|
|
346
|
-
export { ArgumentType, Awaitable, BetterMap, BlocklistRule, CSSEntries, CSSObject, ConfigBase, DeepPartial, DynamicMatcher, DynamicRule, DynamicShortcut, DynamicShortcutMatcher, Extractor, ExtractorContext, FlatObjectTuple, GenerateOptions, GenerateResult, GeneratorOptions, ParsedUtil, PartialByKeys, Preflight, Preset, RawUtil, 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 };
|
|
375
|
+
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, 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.js
CHANGED
|
@@ -29,7 +29,10 @@ __export(exports, {
|
|
|
29
29
|
isValidSelector: () => isValidSelector,
|
|
30
30
|
mergeDeep: () => mergeDeep,
|
|
31
31
|
mergeSet: () => mergeSet,
|
|
32
|
+
normalizeCSSEntries: () => normalizeCSSEntries,
|
|
33
|
+
normalizeCSSValues: () => normalizeCSSValues,
|
|
32
34
|
normalizeVariant: () => normalizeVariant,
|
|
35
|
+
notNull: () => notNull,
|
|
33
36
|
regexClassGroup: () => regexClassGroup,
|
|
34
37
|
toArray: () => toArray,
|
|
35
38
|
uniq: () => uniq,
|
|
@@ -164,6 +167,9 @@ function normalizeVariant(variant) {
|
|
|
164
167
|
function isRawUtil(util) {
|
|
165
168
|
return util.length === 3;
|
|
166
169
|
}
|
|
170
|
+
function notNull(value) {
|
|
171
|
+
return value != null;
|
|
172
|
+
}
|
|
167
173
|
|
|
168
174
|
// src/utils/map.ts
|
|
169
175
|
var TwoKeyMap = class {
|
|
@@ -336,7 +342,7 @@ function resolveConfig(userConfig = {}, defaults = {}) {
|
|
|
336
342
|
}
|
|
337
343
|
|
|
338
344
|
// package.json
|
|
339
|
-
var version = "0.
|
|
345
|
+
var version = "0.14.0";
|
|
340
346
|
|
|
341
347
|
// src/generator/index.ts
|
|
342
348
|
var UnoGenerator = class {
|
|
@@ -406,6 +412,7 @@ var UnoGenerator = class {
|
|
|
406
412
|
this._cache.set(raw, null);
|
|
407
413
|
};
|
|
408
414
|
await Promise.all(Array.from(tokens).map(async (raw) => {
|
|
415
|
+
var _a;
|
|
409
416
|
if (matched.has(raw) || this.blocked.has(raw))
|
|
410
417
|
return;
|
|
411
418
|
if (this._cache.has(raw)) {
|
|
@@ -436,9 +443,9 @@ var UnoGenerator = class {
|
|
|
436
443
|
if (utils == null ? void 0 : utils.length)
|
|
437
444
|
return hit(raw, utils);
|
|
438
445
|
} else {
|
|
439
|
-
const
|
|
440
|
-
if (
|
|
441
|
-
return hit(raw,
|
|
446
|
+
const utils = (_a = await this.parseUtil(applied, context)) == null ? void 0 : _a.map((i) => this.stringifyUtil(i)).filter(notNull);
|
|
447
|
+
if (utils == null ? void 0 : utils.length)
|
|
448
|
+
return hit(raw, utils);
|
|
442
449
|
}
|
|
443
450
|
this._cache.set(raw, null);
|
|
444
451
|
}));
|
|
@@ -467,18 +474,18 @@ var UnoGenerator = class {
|
|
|
467
474
|
}).map((a) => [a[1] ? applyScope(a[1], scope) : a[1], a[2]]);
|
|
468
475
|
if (!sorted.length)
|
|
469
476
|
return void 0;
|
|
470
|
-
const rules = sorted.map(([selector, body], idx) => {
|
|
477
|
+
const rules = sorted.reverse().map(([selector, body], idx) => {
|
|
471
478
|
if (selector && this.config.mergeSelectors) {
|
|
472
|
-
for (let i =
|
|
479
|
+
for (let i = idx + 1; i < size; i++) {
|
|
473
480
|
const current = sorted[i];
|
|
474
481
|
if (current && current[0] && current[1] === body) {
|
|
475
|
-
current[0] = `${
|
|
482
|
+
current[0] = `${current[0]},${selector}`;
|
|
476
483
|
return null;
|
|
477
484
|
}
|
|
478
485
|
}
|
|
479
486
|
}
|
|
480
487
|
return selector ? `${selector}{${body}}` : body;
|
|
481
|
-
}).filter(Boolean).join(nl);
|
|
488
|
+
}).filter(Boolean).reverse().join(nl);
|
|
482
489
|
return parent ? `${parent}{${nl}${rules}${nl}}` : rules;
|
|
483
490
|
}).filter(Boolean).join(nl);
|
|
484
491
|
if (preflights) {
|
|
@@ -548,7 +555,7 @@ var UnoGenerator = class {
|
|
|
548
555
|
];
|
|
549
556
|
}
|
|
550
557
|
constructCustomCSS(context, body, overrideSelector) {
|
|
551
|
-
body =
|
|
558
|
+
body = normalizeCSSEntries(body);
|
|
552
559
|
const [selector, entries, mediaQuery] = this.applyVariants([0, overrideSelector || context.rawSelector, body, void 0, context.variantHandlers]);
|
|
553
560
|
const cssBody = `${selector}{${entriesToCss(entries)}}`;
|
|
554
561
|
if (mediaQuery)
|
|
@@ -561,7 +568,7 @@ var UnoGenerator = class {
|
|
|
561
568
|
const staticMatch = this.config.rulesStaticMap[processed];
|
|
562
569
|
if (staticMatch) {
|
|
563
570
|
if (staticMatch[1] && (internal || !((_a = staticMatch[2]) == null ? void 0 : _a.internal)))
|
|
564
|
-
return [staticMatch[0], raw,
|
|
571
|
+
return [[staticMatch[0], raw, normalizeCSSEntries(staticMatch[1]), staticMatch[2], variantHandlers]];
|
|
565
572
|
}
|
|
566
573
|
context.variantHandlers = variantHandlers;
|
|
567
574
|
const { rulesDynamic, rulesSize } = this.config;
|
|
@@ -579,10 +586,10 @@ var UnoGenerator = class {
|
|
|
579
586
|
if (!result)
|
|
580
587
|
continue;
|
|
581
588
|
if (typeof result === "string")
|
|
582
|
-
return [i, result, meta];
|
|
583
|
-
const entries =
|
|
589
|
+
return [[i, result, meta]];
|
|
590
|
+
const entries = normalizeCSSValues(result).filter((i2) => i2.length);
|
|
584
591
|
if (entries.length)
|
|
585
|
-
return [i, raw,
|
|
592
|
+
return entries.map((e2) => [i, raw, e2, meta, variantHandlers]);
|
|
586
593
|
}
|
|
587
594
|
}
|
|
588
595
|
stringifyUtil(parsed) {
|
|
@@ -636,8 +643,8 @@ var UnoGenerator = class {
|
|
|
636
643
|
const result = await this.parseUtil(i, context, true);
|
|
637
644
|
if (!result)
|
|
638
645
|
warnOnce(`unmatched utility "${i}" in shortcut "${parent[1]}"`);
|
|
639
|
-
return result;
|
|
640
|
-
}))).filter(Boolean).sort((a, b) => a[0] - b[0]);
|
|
646
|
+
return result || [];
|
|
647
|
+
}))).flat(1).filter(Boolean).sort((a, b) => a[0] - b[0]);
|
|
641
648
|
const [raw, , parentVariants] = parent;
|
|
642
649
|
for (const item of parsed) {
|
|
643
650
|
if (isRawUtil(item))
|
|
@@ -676,8 +683,18 @@ function toEscapedSelector(raw) {
|
|
|
676
683
|
else
|
|
677
684
|
return `.${e(raw)}`;
|
|
678
685
|
}
|
|
679
|
-
function
|
|
680
|
-
return !Array.isArray(obj) ? Object.entries(obj) : obj;
|
|
686
|
+
function normalizeCSSEntries(obj) {
|
|
687
|
+
return (!Array.isArray(obj) ? Object.entries(obj) : obj).filter((i) => i[1] != null);
|
|
688
|
+
}
|
|
689
|
+
function normalizeCSSValues(obj) {
|
|
690
|
+
if (Array.isArray(obj)) {
|
|
691
|
+
if (obj.find((i) => !Array.isArray(i) || Array.isArray(i[0])))
|
|
692
|
+
return obj.map((i) => normalizeCSSEntries(i));
|
|
693
|
+
else
|
|
694
|
+
return [obj];
|
|
695
|
+
} else {
|
|
696
|
+
return [normalizeCSSEntries(obj)];
|
|
697
|
+
}
|
|
681
698
|
}
|
|
682
699
|
// Annotate the CommonJS export names for ESM import in node:
|
|
683
700
|
0 && (module.exports = {
|
|
@@ -702,7 +719,10 @@ function normalizeEntries(obj) {
|
|
|
702
719
|
isValidSelector,
|
|
703
720
|
mergeDeep,
|
|
704
721
|
mergeSet,
|
|
722
|
+
normalizeCSSEntries,
|
|
723
|
+
normalizeCSSValues,
|
|
705
724
|
normalizeVariant,
|
|
725
|
+
notNull,
|
|
706
726
|
regexClassGroup,
|
|
707
727
|
toArray,
|
|
708
728
|
uniq,
|
package/dist/index.mjs
CHANGED
|
@@ -124,6 +124,9 @@ function normalizeVariant(variant) {
|
|
|
124
124
|
function isRawUtil(util) {
|
|
125
125
|
return util.length === 3;
|
|
126
126
|
}
|
|
127
|
+
function notNull(value) {
|
|
128
|
+
return value != null;
|
|
129
|
+
}
|
|
127
130
|
|
|
128
131
|
// src/utils/map.ts
|
|
129
132
|
var TwoKeyMap = class {
|
|
@@ -296,7 +299,7 @@ function resolveConfig(userConfig = {}, defaults = {}) {
|
|
|
296
299
|
}
|
|
297
300
|
|
|
298
301
|
// package.json
|
|
299
|
-
var version = "0.
|
|
302
|
+
var version = "0.14.0";
|
|
300
303
|
|
|
301
304
|
// src/generator/index.ts
|
|
302
305
|
var UnoGenerator = class {
|
|
@@ -366,6 +369,7 @@ var UnoGenerator = class {
|
|
|
366
369
|
this._cache.set(raw, null);
|
|
367
370
|
};
|
|
368
371
|
await Promise.all(Array.from(tokens).map(async (raw) => {
|
|
372
|
+
var _a;
|
|
369
373
|
if (matched.has(raw) || this.blocked.has(raw))
|
|
370
374
|
return;
|
|
371
375
|
if (this._cache.has(raw)) {
|
|
@@ -396,9 +400,9 @@ var UnoGenerator = class {
|
|
|
396
400
|
if (utils == null ? void 0 : utils.length)
|
|
397
401
|
return hit(raw, utils);
|
|
398
402
|
} else {
|
|
399
|
-
const
|
|
400
|
-
if (
|
|
401
|
-
return hit(raw,
|
|
403
|
+
const utils = (_a = await this.parseUtil(applied, context)) == null ? void 0 : _a.map((i) => this.stringifyUtil(i)).filter(notNull);
|
|
404
|
+
if (utils == null ? void 0 : utils.length)
|
|
405
|
+
return hit(raw, utils);
|
|
402
406
|
}
|
|
403
407
|
this._cache.set(raw, null);
|
|
404
408
|
}));
|
|
@@ -427,18 +431,18 @@ var UnoGenerator = class {
|
|
|
427
431
|
}).map((a) => [a[1] ? applyScope(a[1], scope) : a[1], a[2]]);
|
|
428
432
|
if (!sorted.length)
|
|
429
433
|
return void 0;
|
|
430
|
-
const rules = sorted.map(([selector, body], idx) => {
|
|
434
|
+
const rules = sorted.reverse().map(([selector, body], idx) => {
|
|
431
435
|
if (selector && this.config.mergeSelectors) {
|
|
432
|
-
for (let i =
|
|
436
|
+
for (let i = idx + 1; i < size; i++) {
|
|
433
437
|
const current = sorted[i];
|
|
434
438
|
if (current && current[0] && current[1] === body) {
|
|
435
|
-
current[0] = `${
|
|
439
|
+
current[0] = `${current[0]},${selector}`;
|
|
436
440
|
return null;
|
|
437
441
|
}
|
|
438
442
|
}
|
|
439
443
|
}
|
|
440
444
|
return selector ? `${selector}{${body}}` : body;
|
|
441
|
-
}).filter(Boolean).join(nl);
|
|
445
|
+
}).filter(Boolean).reverse().join(nl);
|
|
442
446
|
return parent ? `${parent}{${nl}${rules}${nl}}` : rules;
|
|
443
447
|
}).filter(Boolean).join(nl);
|
|
444
448
|
if (preflights) {
|
|
@@ -508,7 +512,7 @@ var UnoGenerator = class {
|
|
|
508
512
|
];
|
|
509
513
|
}
|
|
510
514
|
constructCustomCSS(context, body, overrideSelector) {
|
|
511
|
-
body =
|
|
515
|
+
body = normalizeCSSEntries(body);
|
|
512
516
|
const [selector, entries, mediaQuery] = this.applyVariants([0, overrideSelector || context.rawSelector, body, void 0, context.variantHandlers]);
|
|
513
517
|
const cssBody = `${selector}{${entriesToCss(entries)}}`;
|
|
514
518
|
if (mediaQuery)
|
|
@@ -521,7 +525,7 @@ var UnoGenerator = class {
|
|
|
521
525
|
const staticMatch = this.config.rulesStaticMap[processed];
|
|
522
526
|
if (staticMatch) {
|
|
523
527
|
if (staticMatch[1] && (internal || !((_a = staticMatch[2]) == null ? void 0 : _a.internal)))
|
|
524
|
-
return [staticMatch[0], raw,
|
|
528
|
+
return [[staticMatch[0], raw, normalizeCSSEntries(staticMatch[1]), staticMatch[2], variantHandlers]];
|
|
525
529
|
}
|
|
526
530
|
context.variantHandlers = variantHandlers;
|
|
527
531
|
const { rulesDynamic, rulesSize } = this.config;
|
|
@@ -539,10 +543,10 @@ var UnoGenerator = class {
|
|
|
539
543
|
if (!result)
|
|
540
544
|
continue;
|
|
541
545
|
if (typeof result === "string")
|
|
542
|
-
return [i, result, meta];
|
|
543
|
-
const entries =
|
|
546
|
+
return [[i, result, meta]];
|
|
547
|
+
const entries = normalizeCSSValues(result).filter((i2) => i2.length);
|
|
544
548
|
if (entries.length)
|
|
545
|
-
return [i, raw,
|
|
549
|
+
return entries.map((e2) => [i, raw, e2, meta, variantHandlers]);
|
|
546
550
|
}
|
|
547
551
|
}
|
|
548
552
|
stringifyUtil(parsed) {
|
|
@@ -596,8 +600,8 @@ var UnoGenerator = class {
|
|
|
596
600
|
const result = await this.parseUtil(i, context, true);
|
|
597
601
|
if (!result)
|
|
598
602
|
warnOnce(`unmatched utility "${i}" in shortcut "${parent[1]}"`);
|
|
599
|
-
return result;
|
|
600
|
-
}))).filter(Boolean).sort((a, b) => a[0] - b[0]);
|
|
603
|
+
return result || [];
|
|
604
|
+
}))).flat(1).filter(Boolean).sort((a, b) => a[0] - b[0]);
|
|
601
605
|
const [raw, , parentVariants] = parent;
|
|
602
606
|
for (const item of parsed) {
|
|
603
607
|
if (isRawUtil(item))
|
|
@@ -636,8 +640,18 @@ function toEscapedSelector(raw) {
|
|
|
636
640
|
else
|
|
637
641
|
return `.${e(raw)}`;
|
|
638
642
|
}
|
|
639
|
-
function
|
|
640
|
-
return !Array.isArray(obj) ? Object.entries(obj) : obj;
|
|
643
|
+
function normalizeCSSEntries(obj) {
|
|
644
|
+
return (!Array.isArray(obj) ? Object.entries(obj) : obj).filter((i) => i[1] != null);
|
|
645
|
+
}
|
|
646
|
+
function normalizeCSSValues(obj) {
|
|
647
|
+
if (Array.isArray(obj)) {
|
|
648
|
+
if (obj.find((i) => !Array.isArray(i) || Array.isArray(i[0])))
|
|
649
|
+
return obj.map((i) => normalizeCSSEntries(i));
|
|
650
|
+
else
|
|
651
|
+
return [obj];
|
|
652
|
+
} else {
|
|
653
|
+
return [normalizeCSSEntries(obj)];
|
|
654
|
+
}
|
|
641
655
|
}
|
|
642
656
|
export {
|
|
643
657
|
BetterMap,
|
|
@@ -661,7 +675,10 @@ export {
|
|
|
661
675
|
isValidSelector,
|
|
662
676
|
mergeDeep,
|
|
663
677
|
mergeSet,
|
|
678
|
+
normalizeCSSEntries,
|
|
679
|
+
normalizeCSSValues,
|
|
664
680
|
normalizeVariant,
|
|
681
|
+
notNull,
|
|
665
682
|
regexClassGroup,
|
|
666
683
|
toArray,
|
|
667
684
|
uniq,
|