@unocss/core 0.12.18 → 0.14.1
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 +35 -5
- package/dist/index.js +50 -19
- package/dist/index.mjs +46 -19
- 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>;
|
|
@@ -33,6 +33,7 @@ declare type FlatObjectTuple<T> = {
|
|
|
33
33
|
[K in keyof T]: T[K];
|
|
34
34
|
};
|
|
35
35
|
declare type PartialByKeys<T, K extends keyof T = keyof T> = FlatObjectTuple<Partial<Pick<T, Extract<keyof T, K>>> & Omit<T, K>>;
|
|
36
|
+
declare type RequiredByKey<T, K extends keyof T = keyof T> = FlatObjectTuple<Required<Pick<T, Extract<keyof T, K>>> & Omit<T, K>>;
|
|
36
37
|
declare type CSSObject = Record<string, string | number | undefined>;
|
|
37
38
|
declare type CSSEntries = [string, string | number | undefined][];
|
|
38
39
|
interface RuleContext<Theme extends {} = {}> {
|
|
@@ -85,7 +86,8 @@ interface RuleMeta {
|
|
|
85
86
|
*/
|
|
86
87
|
internal?: boolean;
|
|
87
88
|
}
|
|
88
|
-
declare type
|
|
89
|
+
declare type CSSValues = CSSObject | CSSEntries | (CSSObject | CSSEntries)[];
|
|
90
|
+
declare type DynamicMatcher<Theme extends {} = {}> = ((match: string[], context: Readonly<RuleContext<Theme>>) => Awaitable<CSSValues | string | undefined>);
|
|
89
91
|
declare type DynamicRule<Theme extends {} = {}> = [RegExp, DynamicMatcher<Theme>] | [RegExp, DynamicMatcher<Theme>, RuleMeta];
|
|
90
92
|
declare type StaticRule = [string, CSSObject | CSSEntries] | [string, CSSObject | CSSEntries, RuleMeta];
|
|
91
93
|
declare type Rule<Theme extends {} = {}> = DynamicRule<Theme> | StaticRule;
|
|
@@ -95,6 +97,7 @@ declare type StaticShortcutMap = Record<string, string | string[]>;
|
|
|
95
97
|
declare type DynamicShortcut<Theme extends {} = {}> = [RegExp, DynamicShortcutMatcher<Theme>] | [RegExp, DynamicShortcutMatcher<Theme>, RuleMeta];
|
|
96
98
|
declare type UserShortcuts<Theme extends {} = {}> = StaticShortcutMap | (StaticShortcut | DynamicShortcut<Theme> | StaticShortcutMap)[];
|
|
97
99
|
declare type Shortcut<Theme extends {} = {}> = StaticShortcut | DynamicShortcut<Theme>;
|
|
100
|
+
declare type FilterPattern = ReadonlyArray<string | RegExp> | string | RegExp | null;
|
|
98
101
|
interface Preflight {
|
|
99
102
|
getCSS: () => string | undefined;
|
|
100
103
|
layer?: string;
|
|
@@ -226,11 +229,34 @@ interface UserOnlyOptions<Theme extends {} = {}> {
|
|
|
226
229
|
*/
|
|
227
230
|
envMode?: 'dev' | 'build';
|
|
228
231
|
}
|
|
229
|
-
|
|
232
|
+
/**
|
|
233
|
+
* For other modules to aggregate the options
|
|
234
|
+
*/
|
|
235
|
+
interface PluginOptions {
|
|
236
|
+
/**
|
|
237
|
+
* Load from configs files
|
|
238
|
+
*
|
|
239
|
+
* set `false` to disable
|
|
240
|
+
*/
|
|
241
|
+
configFile?: string | false;
|
|
242
|
+
/**
|
|
243
|
+
* List of files that will also triggers config reloads
|
|
244
|
+
*/
|
|
245
|
+
configDeps?: string[];
|
|
246
|
+
/**
|
|
247
|
+
* Patterns that filter the files being extracted.
|
|
248
|
+
*/
|
|
249
|
+
include?: FilterPattern;
|
|
250
|
+
/**
|
|
251
|
+
* Patterns that filter the files NOT being extracted.
|
|
252
|
+
*/
|
|
253
|
+
exclude?: FilterPattern;
|
|
254
|
+
}
|
|
255
|
+
interface UserConfig<Theme extends {} = {}> extends ConfigBase<Theme>, UserOnlyOptions<Theme>, GeneratorOptions, PluginOptions {
|
|
230
256
|
}
|
|
231
257
|
interface UserConfigDefaults<Theme extends {} = {}> extends ConfigBase<Theme>, UserOnlyOptions<Theme> {
|
|
232
258
|
}
|
|
233
|
-
interface ResolvedConfig extends Omit<
|
|
259
|
+
interface ResolvedConfig extends Omit<RequiredByKey<UserConfig, 'mergeSelectors' | 'theme' | 'rules' | 'variants' | 'layers' | 'extractors' | 'blocklist' | 'safelist' | 'preflights' | 'sortLayers'>, 'rules' | 'shortcuts'> {
|
|
234
260
|
shortcuts: Shortcut[];
|
|
235
261
|
variants: VariantObject[];
|
|
236
262
|
rulesSize: number;
|
|
@@ -301,6 +327,9 @@ declare function escapeRegExp(string: string): string;
|
|
|
301
327
|
declare function escapeSelector(str: string): string;
|
|
302
328
|
declare const e: typeof escapeSelector;
|
|
303
329
|
|
|
330
|
+
declare function normalizeCSSEntries(obj: CSSEntries | CSSObject): CSSEntries;
|
|
331
|
+
declare function normalizeCSSValues(obj: CSSValues): CSSEntries[];
|
|
332
|
+
declare function clearIdenticalEntries(entry: CSSEntries): CSSEntries;
|
|
304
333
|
declare function entriesToCss(arr?: CSSEntries): string;
|
|
305
334
|
declare function isObject(item: any): item is Record<string, any>;
|
|
306
335
|
declare function mergeDeep<T>(original: T, patch: DeepPartial<T>): T;
|
|
@@ -319,6 +348,7 @@ declare function isAttributifySelector(selector: string): RegExpMatchArray | nul
|
|
|
319
348
|
declare function isValidSelector(selector?: string): selector is string;
|
|
320
349
|
declare function normalizeVariant(variant: Variant): VariantObject;
|
|
321
350
|
declare function isRawUtil(util: ParsedUtil | RawUtil | StringifiedUtil): util is RawUtil;
|
|
351
|
+
declare function notNull<T>(value: T | null | undefined): value is T;
|
|
322
352
|
|
|
323
353
|
declare class TwoKeyMap<K1, K2, V> {
|
|
324
354
|
_map: Map<K1, Map<K2, V>>;
|
|
@@ -343,4 +373,4 @@ declare function warnOnce(msg: string): void;
|
|
|
343
373
|
|
|
344
374
|
declare const extractorSplit: Extractor;
|
|
345
375
|
|
|
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 };
|
|
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.js
CHANGED
|
@@ -12,6 +12,7 @@ __export(exports, {
|
|
|
12
12
|
TwoKeyMap: () => TwoKeyMap,
|
|
13
13
|
UnoGenerator: () => UnoGenerator,
|
|
14
14
|
attributifyRE: () => attributifyRE,
|
|
15
|
+
clearIdenticalEntries: () => clearIdenticalEntries,
|
|
15
16
|
createGenerator: () => createGenerator,
|
|
16
17
|
e: () => e,
|
|
17
18
|
entriesToCss: () => entriesToCss,
|
|
@@ -29,7 +30,10 @@ __export(exports, {
|
|
|
29
30
|
isValidSelector: () => isValidSelector,
|
|
30
31
|
mergeDeep: () => mergeDeep,
|
|
31
32
|
mergeSet: () => mergeSet,
|
|
33
|
+
normalizeCSSEntries: () => normalizeCSSEntries,
|
|
34
|
+
normalizeCSSValues: () => normalizeCSSValues,
|
|
32
35
|
normalizeVariant: () => normalizeVariant,
|
|
36
|
+
notNull: () => notNull,
|
|
33
37
|
regexClassGroup: () => regexClassGroup,
|
|
34
38
|
toArray: () => toArray,
|
|
35
39
|
uniq: () => uniq,
|
|
@@ -77,10 +81,32 @@ function escapeSelector(str) {
|
|
|
77
81
|
var e = escapeSelector;
|
|
78
82
|
|
|
79
83
|
// src/utils/object.ts
|
|
84
|
+
function normalizeCSSEntries(obj) {
|
|
85
|
+
return (!Array.isArray(obj) ? Object.entries(obj) : obj).filter((i) => i[1] != null);
|
|
86
|
+
}
|
|
87
|
+
function normalizeCSSValues(obj) {
|
|
88
|
+
if (Array.isArray(obj)) {
|
|
89
|
+
if (obj.find((i) => !Array.isArray(i) || Array.isArray(i[0])))
|
|
90
|
+
return obj.map((i) => normalizeCSSEntries(i));
|
|
91
|
+
else
|
|
92
|
+
return [obj];
|
|
93
|
+
} else {
|
|
94
|
+
return [normalizeCSSEntries(obj)];
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
function clearIdenticalEntries(entry) {
|
|
98
|
+
return entry.filter(([k, v], idx) => {
|
|
99
|
+
for (let i = idx - 1; i >= 0; i--) {
|
|
100
|
+
if (entry[i][0] === k && entry[i][1] === v)
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
return true;
|
|
104
|
+
});
|
|
105
|
+
}
|
|
80
106
|
function entriesToCss(arr) {
|
|
81
107
|
if (arr == null)
|
|
82
108
|
return "";
|
|
83
|
-
return arr.map(([key, value]) => value != null ? `${key}:${value};` : void 0).filter(Boolean).join("");
|
|
109
|
+
return clearIdenticalEntries(arr).map(([key, value]) => value != null ? `${key}:${value};` : void 0).filter(Boolean).join("");
|
|
84
110
|
}
|
|
85
111
|
function isObject(item) {
|
|
86
112
|
return item && typeof item === "object" && !Array.isArray(item);
|
|
@@ -164,6 +190,9 @@ function normalizeVariant(variant) {
|
|
|
164
190
|
function isRawUtil(util) {
|
|
165
191
|
return util.length === 3;
|
|
166
192
|
}
|
|
193
|
+
function notNull(value) {
|
|
194
|
+
return value != null;
|
|
195
|
+
}
|
|
167
196
|
|
|
168
197
|
// src/utils/map.ts
|
|
169
198
|
var TwoKeyMap = class {
|
|
@@ -336,7 +365,7 @@ function resolveConfig(userConfig = {}, defaults = {}) {
|
|
|
336
365
|
}
|
|
337
366
|
|
|
338
367
|
// package.json
|
|
339
|
-
var version = "0.
|
|
368
|
+
var version = "0.14.1";
|
|
340
369
|
|
|
341
370
|
// src/generator/index.ts
|
|
342
371
|
var UnoGenerator = class {
|
|
@@ -406,6 +435,7 @@ var UnoGenerator = class {
|
|
|
406
435
|
this._cache.set(raw, null);
|
|
407
436
|
};
|
|
408
437
|
await Promise.all(Array.from(tokens).map(async (raw) => {
|
|
438
|
+
var _a;
|
|
409
439
|
if (matched.has(raw) || this.blocked.has(raw))
|
|
410
440
|
return;
|
|
411
441
|
if (this._cache.has(raw)) {
|
|
@@ -436,9 +466,9 @@ var UnoGenerator = class {
|
|
|
436
466
|
if (utils == null ? void 0 : utils.length)
|
|
437
467
|
return hit(raw, utils);
|
|
438
468
|
} else {
|
|
439
|
-
const
|
|
440
|
-
if (
|
|
441
|
-
return hit(raw,
|
|
469
|
+
const utils = (_a = await this.parseUtil(applied, context)) == null ? void 0 : _a.map((i) => this.stringifyUtil(i)).filter(notNull);
|
|
470
|
+
if (utils == null ? void 0 : utils.length)
|
|
471
|
+
return hit(raw, utils);
|
|
442
472
|
}
|
|
443
473
|
this._cache.set(raw, null);
|
|
444
474
|
}));
|
|
@@ -467,18 +497,18 @@ var UnoGenerator = class {
|
|
|
467
497
|
}).map((a) => [a[1] ? applyScope(a[1], scope) : a[1], a[2]]);
|
|
468
498
|
if (!sorted.length)
|
|
469
499
|
return void 0;
|
|
470
|
-
const rules = sorted.map(([selector, body], idx) => {
|
|
500
|
+
const rules = sorted.reverse().map(([selector, body], idx) => {
|
|
471
501
|
if (selector && this.config.mergeSelectors) {
|
|
472
|
-
for (let i =
|
|
502
|
+
for (let i = idx + 1; i < size; i++) {
|
|
473
503
|
const current = sorted[i];
|
|
474
504
|
if (current && current[0] && current[1] === body) {
|
|
475
|
-
current[0] = `${
|
|
505
|
+
current[0] = `${current[0]},${selector}`;
|
|
476
506
|
return null;
|
|
477
507
|
}
|
|
478
508
|
}
|
|
479
509
|
}
|
|
480
510
|
return selector ? `${selector}{${body}}` : body;
|
|
481
|
-
}).filter(Boolean).join(nl);
|
|
511
|
+
}).filter(Boolean).reverse().join(nl);
|
|
482
512
|
return parent ? `${parent}{${nl}${rules}${nl}}` : rules;
|
|
483
513
|
}).filter(Boolean).join(nl);
|
|
484
514
|
if (preflights) {
|
|
@@ -548,7 +578,7 @@ var UnoGenerator = class {
|
|
|
548
578
|
];
|
|
549
579
|
}
|
|
550
580
|
constructCustomCSS(context, body, overrideSelector) {
|
|
551
|
-
body =
|
|
581
|
+
body = normalizeCSSEntries(body);
|
|
552
582
|
const [selector, entries, mediaQuery] = this.applyVariants([0, overrideSelector || context.rawSelector, body, void 0, context.variantHandlers]);
|
|
553
583
|
const cssBody = `${selector}{${entriesToCss(entries)}}`;
|
|
554
584
|
if (mediaQuery)
|
|
@@ -561,7 +591,7 @@ var UnoGenerator = class {
|
|
|
561
591
|
const staticMatch = this.config.rulesStaticMap[processed];
|
|
562
592
|
if (staticMatch) {
|
|
563
593
|
if (staticMatch[1] && (internal || !((_a = staticMatch[2]) == null ? void 0 : _a.internal)))
|
|
564
|
-
return [staticMatch[0], raw,
|
|
594
|
+
return [[staticMatch[0], raw, normalizeCSSEntries(staticMatch[1]), staticMatch[2], variantHandlers]];
|
|
565
595
|
}
|
|
566
596
|
context.variantHandlers = variantHandlers;
|
|
567
597
|
const { rulesDynamic, rulesSize } = this.config;
|
|
@@ -579,10 +609,10 @@ var UnoGenerator = class {
|
|
|
579
609
|
if (!result)
|
|
580
610
|
continue;
|
|
581
611
|
if (typeof result === "string")
|
|
582
|
-
return [i, result, meta];
|
|
583
|
-
const entries =
|
|
612
|
+
return [[i, result, meta]];
|
|
613
|
+
const entries = normalizeCSSValues(result).filter((i2) => i2.length);
|
|
584
614
|
if (entries.length)
|
|
585
|
-
return [i, raw,
|
|
615
|
+
return entries.map((e2) => [i, raw, e2, meta, variantHandlers]);
|
|
586
616
|
}
|
|
587
617
|
}
|
|
588
618
|
stringifyUtil(parsed) {
|
|
@@ -636,8 +666,8 @@ var UnoGenerator = class {
|
|
|
636
666
|
const result = await this.parseUtil(i, context, true);
|
|
637
667
|
if (!result)
|
|
638
668
|
warnOnce(`unmatched utility "${i}" in shortcut "${parent[1]}"`);
|
|
639
|
-
return result;
|
|
640
|
-
}))).filter(Boolean).sort((a, b) => a[0] - b[0]);
|
|
669
|
+
return result || [];
|
|
670
|
+
}))).flat(1).filter(Boolean).sort((a, b) => a[0] - b[0]);
|
|
641
671
|
const [raw, , parentVariants] = parent;
|
|
642
672
|
for (const item of parsed) {
|
|
643
673
|
if (isRawUtil(item))
|
|
@@ -676,15 +706,13 @@ function toEscapedSelector(raw) {
|
|
|
676
706
|
else
|
|
677
707
|
return `.${e(raw)}`;
|
|
678
708
|
}
|
|
679
|
-
function normalizeEntries(obj) {
|
|
680
|
-
return !Array.isArray(obj) ? Object.entries(obj) : obj;
|
|
681
|
-
}
|
|
682
709
|
// Annotate the CommonJS export names for ESM import in node:
|
|
683
710
|
0 && (module.exports = {
|
|
684
711
|
BetterMap,
|
|
685
712
|
TwoKeyMap,
|
|
686
713
|
UnoGenerator,
|
|
687
714
|
attributifyRE,
|
|
715
|
+
clearIdenticalEntries,
|
|
688
716
|
createGenerator,
|
|
689
717
|
e,
|
|
690
718
|
entriesToCss,
|
|
@@ -702,7 +730,10 @@ function normalizeEntries(obj) {
|
|
|
702
730
|
isValidSelector,
|
|
703
731
|
mergeDeep,
|
|
704
732
|
mergeSet,
|
|
733
|
+
normalizeCSSEntries,
|
|
734
|
+
normalizeCSSValues,
|
|
705
735
|
normalizeVariant,
|
|
736
|
+
notNull,
|
|
706
737
|
regexClassGroup,
|
|
707
738
|
toArray,
|
|
708
739
|
uniq,
|
package/dist/index.mjs
CHANGED
|
@@ -37,10 +37,32 @@ function escapeSelector(str) {
|
|
|
37
37
|
var e = escapeSelector;
|
|
38
38
|
|
|
39
39
|
// src/utils/object.ts
|
|
40
|
+
function normalizeCSSEntries(obj) {
|
|
41
|
+
return (!Array.isArray(obj) ? Object.entries(obj) : obj).filter((i) => i[1] != null);
|
|
42
|
+
}
|
|
43
|
+
function normalizeCSSValues(obj) {
|
|
44
|
+
if (Array.isArray(obj)) {
|
|
45
|
+
if (obj.find((i) => !Array.isArray(i) || Array.isArray(i[0])))
|
|
46
|
+
return obj.map((i) => normalizeCSSEntries(i));
|
|
47
|
+
else
|
|
48
|
+
return [obj];
|
|
49
|
+
} else {
|
|
50
|
+
return [normalizeCSSEntries(obj)];
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function clearIdenticalEntries(entry) {
|
|
54
|
+
return entry.filter(([k, v], idx) => {
|
|
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);
|
|
@@ -124,6 +146,9 @@ function normalizeVariant(variant) {
|
|
|
124
146
|
function isRawUtil(util) {
|
|
125
147
|
return util.length === 3;
|
|
126
148
|
}
|
|
149
|
+
function notNull(value) {
|
|
150
|
+
return value != null;
|
|
151
|
+
}
|
|
127
152
|
|
|
128
153
|
// src/utils/map.ts
|
|
129
154
|
var TwoKeyMap = class {
|
|
@@ -296,7 +321,7 @@ function resolveConfig(userConfig = {}, defaults = {}) {
|
|
|
296
321
|
}
|
|
297
322
|
|
|
298
323
|
// package.json
|
|
299
|
-
var version = "0.
|
|
324
|
+
var version = "0.14.1";
|
|
300
325
|
|
|
301
326
|
// src/generator/index.ts
|
|
302
327
|
var UnoGenerator = class {
|
|
@@ -366,6 +391,7 @@ var UnoGenerator = class {
|
|
|
366
391
|
this._cache.set(raw, null);
|
|
367
392
|
};
|
|
368
393
|
await Promise.all(Array.from(tokens).map(async (raw) => {
|
|
394
|
+
var _a;
|
|
369
395
|
if (matched.has(raw) || this.blocked.has(raw))
|
|
370
396
|
return;
|
|
371
397
|
if (this._cache.has(raw)) {
|
|
@@ -396,9 +422,9 @@ var UnoGenerator = class {
|
|
|
396
422
|
if (utils == null ? void 0 : utils.length)
|
|
397
423
|
return hit(raw, utils);
|
|
398
424
|
} else {
|
|
399
|
-
const
|
|
400
|
-
if (
|
|
401
|
-
return hit(raw,
|
|
425
|
+
const utils = (_a = await this.parseUtil(applied, context)) == null ? void 0 : _a.map((i) => this.stringifyUtil(i)).filter(notNull);
|
|
426
|
+
if (utils == null ? void 0 : utils.length)
|
|
427
|
+
return hit(raw, utils);
|
|
402
428
|
}
|
|
403
429
|
this._cache.set(raw, null);
|
|
404
430
|
}));
|
|
@@ -427,18 +453,18 @@ var UnoGenerator = class {
|
|
|
427
453
|
}).map((a) => [a[1] ? applyScope(a[1], scope) : a[1], a[2]]);
|
|
428
454
|
if (!sorted.length)
|
|
429
455
|
return void 0;
|
|
430
|
-
const rules = sorted.map(([selector, body], idx) => {
|
|
456
|
+
const rules = sorted.reverse().map(([selector, body], idx) => {
|
|
431
457
|
if (selector && this.config.mergeSelectors) {
|
|
432
|
-
for (let i =
|
|
458
|
+
for (let i = idx + 1; i < size; i++) {
|
|
433
459
|
const current = sorted[i];
|
|
434
460
|
if (current && current[0] && current[1] === body) {
|
|
435
|
-
current[0] = `${
|
|
461
|
+
current[0] = `${current[0]},${selector}`;
|
|
436
462
|
return null;
|
|
437
463
|
}
|
|
438
464
|
}
|
|
439
465
|
}
|
|
440
466
|
return selector ? `${selector}{${body}}` : body;
|
|
441
|
-
}).filter(Boolean).join(nl);
|
|
467
|
+
}).filter(Boolean).reverse().join(nl);
|
|
442
468
|
return parent ? `${parent}{${nl}${rules}${nl}}` : rules;
|
|
443
469
|
}).filter(Boolean).join(nl);
|
|
444
470
|
if (preflights) {
|
|
@@ -508,7 +534,7 @@ var UnoGenerator = class {
|
|
|
508
534
|
];
|
|
509
535
|
}
|
|
510
536
|
constructCustomCSS(context, body, overrideSelector) {
|
|
511
|
-
body =
|
|
537
|
+
body = normalizeCSSEntries(body);
|
|
512
538
|
const [selector, entries, mediaQuery] = this.applyVariants([0, overrideSelector || context.rawSelector, body, void 0, context.variantHandlers]);
|
|
513
539
|
const cssBody = `${selector}{${entriesToCss(entries)}}`;
|
|
514
540
|
if (mediaQuery)
|
|
@@ -521,7 +547,7 @@ var UnoGenerator = class {
|
|
|
521
547
|
const staticMatch = this.config.rulesStaticMap[processed];
|
|
522
548
|
if (staticMatch) {
|
|
523
549
|
if (staticMatch[1] && (internal || !((_a = staticMatch[2]) == null ? void 0 : _a.internal)))
|
|
524
|
-
return [staticMatch[0], raw,
|
|
550
|
+
return [[staticMatch[0], raw, normalizeCSSEntries(staticMatch[1]), staticMatch[2], variantHandlers]];
|
|
525
551
|
}
|
|
526
552
|
context.variantHandlers = variantHandlers;
|
|
527
553
|
const { rulesDynamic, rulesSize } = this.config;
|
|
@@ -539,10 +565,10 @@ var UnoGenerator = class {
|
|
|
539
565
|
if (!result)
|
|
540
566
|
continue;
|
|
541
567
|
if (typeof result === "string")
|
|
542
|
-
return [i, result, meta];
|
|
543
|
-
const entries =
|
|
568
|
+
return [[i, result, meta]];
|
|
569
|
+
const entries = normalizeCSSValues(result).filter((i2) => i2.length);
|
|
544
570
|
if (entries.length)
|
|
545
|
-
return [i, raw,
|
|
571
|
+
return entries.map((e2) => [i, raw, e2, meta, variantHandlers]);
|
|
546
572
|
}
|
|
547
573
|
}
|
|
548
574
|
stringifyUtil(parsed) {
|
|
@@ -596,8 +622,8 @@ var UnoGenerator = class {
|
|
|
596
622
|
const result = await this.parseUtil(i, context, true);
|
|
597
623
|
if (!result)
|
|
598
624
|
warnOnce(`unmatched utility "${i}" in shortcut "${parent[1]}"`);
|
|
599
|
-
return result;
|
|
600
|
-
}))).filter(Boolean).sort((a, b) => a[0] - b[0]);
|
|
625
|
+
return result || [];
|
|
626
|
+
}))).flat(1).filter(Boolean).sort((a, b) => a[0] - b[0]);
|
|
601
627
|
const [raw, , parentVariants] = parent;
|
|
602
628
|
for (const item of parsed) {
|
|
603
629
|
if (isRawUtil(item))
|
|
@@ -636,14 +662,12 @@ function toEscapedSelector(raw) {
|
|
|
636
662
|
else
|
|
637
663
|
return `.${e(raw)}`;
|
|
638
664
|
}
|
|
639
|
-
function normalizeEntries(obj) {
|
|
640
|
-
return !Array.isArray(obj) ? Object.entries(obj) : obj;
|
|
641
|
-
}
|
|
642
665
|
export {
|
|
643
666
|
BetterMap,
|
|
644
667
|
TwoKeyMap,
|
|
645
668
|
UnoGenerator,
|
|
646
669
|
attributifyRE,
|
|
670
|
+
clearIdenticalEntries,
|
|
647
671
|
createGenerator,
|
|
648
672
|
e,
|
|
649
673
|
entriesToCss,
|
|
@@ -661,7 +685,10 @@ export {
|
|
|
661
685
|
isValidSelector,
|
|
662
686
|
mergeDeep,
|
|
663
687
|
mergeSet,
|
|
688
|
+
normalizeCSSEntries,
|
|
689
|
+
normalizeCSSValues,
|
|
664
690
|
normalizeVariant,
|
|
691
|
+
notNull,
|
|
665
692
|
regexClassGroup,
|
|
666
693
|
toArray,
|
|
667
694
|
uniq,
|