@unocss/core 0.45.30 → 0.46.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.cjs +14 -12
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +14 -12
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -416,7 +416,7 @@ function resolveConfig(userConfig = {}, defaults = {}) {
|
|
|
416
416
|
};
|
|
417
417
|
}
|
|
418
418
|
|
|
419
|
-
const version = "0.
|
|
419
|
+
const version = "0.46.1";
|
|
420
420
|
|
|
421
421
|
class UnoGenerator {
|
|
422
422
|
constructor(userConfig = {}, defaults = {}) {
|
|
@@ -535,7 +535,8 @@ class UnoGenerator {
|
|
|
535
535
|
layerSet.add(layer);
|
|
536
536
|
}
|
|
537
537
|
});
|
|
538
|
-
|
|
538
|
+
await Promise.all(tokenPromises);
|
|
539
|
+
await (async () => {
|
|
539
540
|
if (!preflights)
|
|
540
541
|
return;
|
|
541
542
|
const preflightContext = {
|
|
@@ -559,10 +560,6 @@ class UnoGenerator {
|
|
|
559
560
|
))
|
|
560
561
|
);
|
|
561
562
|
})();
|
|
562
|
-
await Promise.all([
|
|
563
|
-
...tokenPromises,
|
|
564
|
-
preflightPromise
|
|
565
|
-
]);
|
|
566
563
|
const layers = this.config.sortLayers(
|
|
567
564
|
Array.from(layerSet).sort((a, b) => (this.config.layers[a] ?? 0) - (this.config.layers[b] ?? 0) || a.localeCompare(b))
|
|
568
565
|
);
|
|
@@ -656,7 +653,7 @@ class UnoGenerator {
|
|
|
656
653
|
return [raw, processed, handlers, variants];
|
|
657
654
|
}
|
|
658
655
|
applyVariants(parsed, variantHandlers = parsed[4], raw = parsed[1]) {
|
|
659
|
-
const handler =
|
|
656
|
+
const handler = variantHandlers.slice().sort((a, b) => (a.order || 0) - (b.order || 0)).reduceRight(
|
|
660
657
|
(previous, v) => (input) => {
|
|
661
658
|
const entries = v.body?.(input.entries) || input.entries;
|
|
662
659
|
const parents = Array.isArray(v.parent) ? v.parent : [v.parent, void 0];
|
|
@@ -707,7 +704,7 @@ class UnoGenerator {
|
|
|
707
704
|
return `${parent}{${cssBody}}`;
|
|
708
705
|
return cssBody;
|
|
709
706
|
}
|
|
710
|
-
async parseUtil(input, context, internal = false) {
|
|
707
|
+
async parseUtil(input, context, internal = false, shortcutPrefix = void 0) {
|
|
711
708
|
const [raw, processed, variantHandlers] = isString(input) ? this.matchVariants(input) : input;
|
|
712
709
|
if (this.config.details)
|
|
713
710
|
context.rules = context.rules ?? [];
|
|
@@ -732,9 +729,14 @@ class UnoGenerator {
|
|
|
732
729
|
continue;
|
|
733
730
|
let unprefixed = processed;
|
|
734
731
|
if (meta?.prefix) {
|
|
735
|
-
if (
|
|
736
|
-
|
|
737
|
-
|
|
732
|
+
if (shortcutPrefix) {
|
|
733
|
+
if (shortcutPrefix !== meta.prefix)
|
|
734
|
+
continue;
|
|
735
|
+
} else {
|
|
736
|
+
if (!processed.startsWith(meta.prefix))
|
|
737
|
+
continue;
|
|
738
|
+
unprefixed = processed.slice(meta.prefix.length);
|
|
739
|
+
}
|
|
738
740
|
}
|
|
739
741
|
const match = unprefixed.match(matcher);
|
|
740
742
|
if (!match)
|
|
@@ -821,7 +823,7 @@ class UnoGenerator {
|
|
|
821
823
|
async stringifyShortcuts(parent, context, expanded, meta = { layer: this.config.shortcutsLayer }) {
|
|
822
824
|
const selectorMap = new TwoKeyMap();
|
|
823
825
|
const parsed = (await Promise.all(uniq(expanded).map(async (i) => {
|
|
824
|
-
const result = isString(i) ? await this.parseUtil(i, context, true) : [[Infinity, "{inline}", normalizeCSSEntries(i), void 0, []]];
|
|
826
|
+
const result = isString(i) ? await this.parseUtil(i, context, true, meta.prefix) : [[Infinity, "{inline}", normalizeCSSEntries(i), void 0, []]];
|
|
825
827
|
if (!result)
|
|
826
828
|
warnOnce(`unmatched utility "${i}" in shortcut "${parent[1]}"`);
|
|
827
829
|
return result || [];
|
package/dist/index.d.ts
CHANGED
|
@@ -71,7 +71,7 @@ declare class UnoGenerator {
|
|
|
71
71
|
matchVariants(raw: string, current?: string): VariantMatchedResult;
|
|
72
72
|
private applyVariants;
|
|
73
73
|
constructCustomCSS(context: Readonly<RuleContext>, body: CSSObject | CSSEntries, overrideSelector?: string): string;
|
|
74
|
-
parseUtil(input: string | VariantMatchedResult, context: RuleContext, internal?: boolean): Promise<(ParsedUtil | RawUtil)[] | undefined>;
|
|
74
|
+
parseUtil(input: string | VariantMatchedResult, context: RuleContext, internal?: boolean, shortcutPrefix?: string | undefined): Promise<(ParsedUtil | RawUtil)[] | undefined>;
|
|
75
75
|
stringifyUtil(parsed?: ParsedUtil | RawUtil, context?: RuleContext): StringifiedUtil | undefined;
|
|
76
76
|
expandShortcut(input: string, context: RuleContext, depth?: number): [ShortcutValue[], RuleMeta | undefined] | undefined;
|
|
77
77
|
stringifyShortcuts(parent: VariantMatchedResult, context: RuleContext, expanded: ShortcutValue[], meta?: RuleMeta): Promise<StringifiedUtil[] | undefined>;
|
package/dist/index.mjs
CHANGED
|
@@ -412,7 +412,7 @@ function resolveConfig(userConfig = {}, defaults = {}) {
|
|
|
412
412
|
};
|
|
413
413
|
}
|
|
414
414
|
|
|
415
|
-
const version = "0.
|
|
415
|
+
const version = "0.46.1";
|
|
416
416
|
|
|
417
417
|
class UnoGenerator {
|
|
418
418
|
constructor(userConfig = {}, defaults = {}) {
|
|
@@ -531,7 +531,8 @@ class UnoGenerator {
|
|
|
531
531
|
layerSet.add(layer);
|
|
532
532
|
}
|
|
533
533
|
});
|
|
534
|
-
|
|
534
|
+
await Promise.all(tokenPromises);
|
|
535
|
+
await (async () => {
|
|
535
536
|
if (!preflights)
|
|
536
537
|
return;
|
|
537
538
|
const preflightContext = {
|
|
@@ -555,10 +556,6 @@ class UnoGenerator {
|
|
|
555
556
|
))
|
|
556
557
|
);
|
|
557
558
|
})();
|
|
558
|
-
await Promise.all([
|
|
559
|
-
...tokenPromises,
|
|
560
|
-
preflightPromise
|
|
561
|
-
]);
|
|
562
559
|
const layers = this.config.sortLayers(
|
|
563
560
|
Array.from(layerSet).sort((a, b) => (this.config.layers[a] ?? 0) - (this.config.layers[b] ?? 0) || a.localeCompare(b))
|
|
564
561
|
);
|
|
@@ -652,7 +649,7 @@ class UnoGenerator {
|
|
|
652
649
|
return [raw, processed, handlers, variants];
|
|
653
650
|
}
|
|
654
651
|
applyVariants(parsed, variantHandlers = parsed[4], raw = parsed[1]) {
|
|
655
|
-
const handler =
|
|
652
|
+
const handler = variantHandlers.slice().sort((a, b) => (a.order || 0) - (b.order || 0)).reduceRight(
|
|
656
653
|
(previous, v) => (input) => {
|
|
657
654
|
const entries = v.body?.(input.entries) || input.entries;
|
|
658
655
|
const parents = Array.isArray(v.parent) ? v.parent : [v.parent, void 0];
|
|
@@ -703,7 +700,7 @@ class UnoGenerator {
|
|
|
703
700
|
return `${parent}{${cssBody}}`;
|
|
704
701
|
return cssBody;
|
|
705
702
|
}
|
|
706
|
-
async parseUtil(input, context, internal = false) {
|
|
703
|
+
async parseUtil(input, context, internal = false, shortcutPrefix = void 0) {
|
|
707
704
|
const [raw, processed, variantHandlers] = isString(input) ? this.matchVariants(input) : input;
|
|
708
705
|
if (this.config.details)
|
|
709
706
|
context.rules = context.rules ?? [];
|
|
@@ -728,9 +725,14 @@ class UnoGenerator {
|
|
|
728
725
|
continue;
|
|
729
726
|
let unprefixed = processed;
|
|
730
727
|
if (meta?.prefix) {
|
|
731
|
-
if (
|
|
732
|
-
|
|
733
|
-
|
|
728
|
+
if (shortcutPrefix) {
|
|
729
|
+
if (shortcutPrefix !== meta.prefix)
|
|
730
|
+
continue;
|
|
731
|
+
} else {
|
|
732
|
+
if (!processed.startsWith(meta.prefix))
|
|
733
|
+
continue;
|
|
734
|
+
unprefixed = processed.slice(meta.prefix.length);
|
|
735
|
+
}
|
|
734
736
|
}
|
|
735
737
|
const match = unprefixed.match(matcher);
|
|
736
738
|
if (!match)
|
|
@@ -817,7 +819,7 @@ class UnoGenerator {
|
|
|
817
819
|
async stringifyShortcuts(parent, context, expanded, meta = { layer: this.config.shortcutsLayer }) {
|
|
818
820
|
const selectorMap = new TwoKeyMap();
|
|
819
821
|
const parsed = (await Promise.all(uniq(expanded).map(async (i) => {
|
|
820
|
-
const result = isString(i) ? await this.parseUtil(i, context, true) : [[Infinity, "{inline}", normalizeCSSEntries(i), void 0, []]];
|
|
822
|
+
const result = isString(i) ? await this.parseUtil(i, context, true, meta.prefix) : [[Infinity, "{inline}", normalizeCSSEntries(i), void 0, []]];
|
|
821
823
|
if (!result)
|
|
822
824
|
warnOnce(`unmatched utility "${i}" in shortcut "${parent[1]}"`);
|
|
823
825
|
return result || [];
|