@unocss/core 0.44.7 → 0.45.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 +58 -39
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +58 -39
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -87,18 +87,16 @@ function entriesToCss(arr) {
|
|
|
87
87
|
function isObject(item) {
|
|
88
88
|
return item && typeof item === "object" && !Array.isArray(item);
|
|
89
89
|
}
|
|
90
|
-
function mergeDeep(original, patch
|
|
90
|
+
function mergeDeep(original, patch) {
|
|
91
91
|
const o = original;
|
|
92
92
|
const p = patch;
|
|
93
|
-
if (Array.isArray(o) && Array.isArray(p))
|
|
94
|
-
return [...o, ...p];
|
|
95
93
|
if (Array.isArray(o))
|
|
96
|
-
return [...
|
|
94
|
+
return [...p];
|
|
97
95
|
const output = { ...o };
|
|
98
96
|
if (isObject(o) && isObject(p)) {
|
|
99
97
|
Object.keys(p).forEach((key) => {
|
|
100
|
-
if (
|
|
101
|
-
output[key] = mergeDeep(o[key], p[key]
|
|
98
|
+
if (isObject(o[key]) && isObject(p[key]) || Array.isArray(o[key]) && Array.isArray(p[key]))
|
|
99
|
+
output[key] = mergeDeep(o[key], p[key]);
|
|
102
100
|
else
|
|
103
101
|
Object.assign(output, { [key]: p[key] });
|
|
104
102
|
});
|
|
@@ -198,9 +196,11 @@ class TwoKeyMap {
|
|
|
198
196
|
return this._map.delete(key1);
|
|
199
197
|
}
|
|
200
198
|
map(fn) {
|
|
201
|
-
return Array.from(this._map.entries()).flatMap(
|
|
202
|
-
|
|
203
|
-
|
|
199
|
+
return Array.from(this._map.entries()).flatMap(
|
|
200
|
+
([k1, m2]) => Array.from(m2.entries()).map(([k2, v]) => {
|
|
201
|
+
return fn(v, k1, k2);
|
|
202
|
+
})
|
|
203
|
+
);
|
|
204
204
|
}
|
|
205
205
|
}
|
|
206
206
|
class BetterMap extends Map {
|
|
@@ -230,11 +230,14 @@ function expandVariantGroup(str, seperators = ["-", ":"]) {
|
|
|
230
230
|
let content = str.toString();
|
|
231
231
|
do {
|
|
232
232
|
const before = content;
|
|
233
|
-
content = content.replace(
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
233
|
+
content = content.replace(
|
|
234
|
+
regexClassGroup,
|
|
235
|
+
(from, pre, sep, body) => {
|
|
236
|
+
if (!seperators.includes(sep))
|
|
237
|
+
return from;
|
|
238
|
+
return body.split(/\s/g).filter(Boolean).map((i) => i === "~" ? pre : i.replace(/^(!?)(.*)/, `$1${pre}${sep}$2`)).join(" ");
|
|
239
|
+
}
|
|
240
|
+
);
|
|
238
241
|
hasChanged = content !== before;
|
|
239
242
|
} while (hasChanged);
|
|
240
243
|
if (typeof str === "string")
|
|
@@ -281,7 +284,7 @@ function createValueHandler(handlers) {
|
|
|
281
284
|
return handler;
|
|
282
285
|
}
|
|
283
286
|
|
|
284
|
-
const splitCode = (code) => code.split(
|
|
287
|
+
const splitCode = (code) => code.split(/\\?[\s'"`;=]+/g).filter(isValidSelector);
|
|
285
288
|
const extractorSplit = {
|
|
286
289
|
name: "split",
|
|
287
290
|
order: 0,
|
|
@@ -383,7 +386,7 @@ function resolveConfig(userConfig = {}, defaults = {}) {
|
|
|
383
386
|
const theme = clone([
|
|
384
387
|
...sortedPresets.map((p) => p.theme || {}),
|
|
385
388
|
config.theme || {}
|
|
386
|
-
].reduce((a, p) => mergeDeep(a, p
|
|
389
|
+
].reduce((a, p) => mergeDeep(a, p), {}));
|
|
387
390
|
mergePresets("extendTheme").forEach((extendTheme) => extendTheme(theme));
|
|
388
391
|
const autocomplete = {
|
|
389
392
|
templates: uniq(sortedPresets.map((p) => toArray(p.autocomplete?.templates)).flat()),
|
|
@@ -414,7 +417,7 @@ function resolveConfig(userConfig = {}, defaults = {}) {
|
|
|
414
417
|
};
|
|
415
418
|
}
|
|
416
419
|
|
|
417
|
-
const version = "0.
|
|
420
|
+
const version = "0.45.4";
|
|
418
421
|
|
|
419
422
|
class UnoGenerator {
|
|
420
423
|
constructor(userConfig = {}, defaults = {}) {
|
|
@@ -486,7 +489,10 @@ class UnoGenerator {
|
|
|
486
489
|
this._cache.set(cacheKey, null);
|
|
487
490
|
return;
|
|
488
491
|
}
|
|
489
|
-
const context = this.makeContext(
|
|
492
|
+
const context = this.makeContext(
|
|
493
|
+
raw,
|
|
494
|
+
[alias || applied[0], applied[1], applied[2], applied[3]]
|
|
495
|
+
);
|
|
490
496
|
if (this.config.details)
|
|
491
497
|
context.variants = [...applied[3]];
|
|
492
498
|
const expanded = this.expandShortcut(context.currentSelector, context);
|
|
@@ -550,17 +556,25 @@ class UnoGenerator {
|
|
|
550
556
|
layerSet.add(layer);
|
|
551
557
|
preflightLayerSet.add(layer);
|
|
552
558
|
});
|
|
553
|
-
preflightsMap = Object.fromEntries(
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
559
|
+
preflightsMap = Object.fromEntries(
|
|
560
|
+
await Promise.all(Array.from(preflightLayerSet).map(
|
|
561
|
+
async (layer) => {
|
|
562
|
+
const preflights2 = await Promise.all(
|
|
563
|
+
this.config.preflights.filter((i) => (i.layer || LAYER_PREFLIGHTS) === layer).map(async (i) => await i.getCSS(preflightContext))
|
|
564
|
+
);
|
|
565
|
+
const css = preflights2.filter(Boolean).join(nl);
|
|
566
|
+
return [layer, css];
|
|
567
|
+
}
|
|
568
|
+
))
|
|
569
|
+
);
|
|
558
570
|
})();
|
|
559
571
|
await Promise.all([
|
|
560
572
|
...tokenPromises,
|
|
561
573
|
preflightPromise
|
|
562
574
|
]);
|
|
563
|
-
const layers = this.config.sortLayers(
|
|
575
|
+
const layers = this.config.sortLayers(
|
|
576
|
+
Array.from(layerSet).sort((a, b) => (this.config.layers[a] ?? 0) - (this.config.layers[b] ?? 0) || a.localeCompare(b))
|
|
577
|
+
);
|
|
564
578
|
const layerCache = {};
|
|
565
579
|
const getLayer = (layer) => {
|
|
566
580
|
if (layerCache[layer])
|
|
@@ -588,7 +602,9 @@ class UnoGenerator {
|
|
|
588
602
|
}
|
|
589
603
|
}
|
|
590
604
|
}
|
|
591
|
-
const selectors = selectorSortPair ? uniq(
|
|
605
|
+
const selectors = selectorSortPair ? uniq(
|
|
606
|
+
selectorSortPair.sort((a, b) => a[1] - b[1] || a[0]?.localeCompare(b[0] || "") || 0).map((pair) => pair[0]).filter(Boolean)
|
|
607
|
+
) : [];
|
|
592
608
|
return selectors.length ? `${selectors.join(`,${nl}`)}{${body}}` : body;
|
|
593
609
|
}).filter(Boolean).reverse().join(nl);
|
|
594
610
|
if (!parent)
|
|
@@ -649,19 +665,22 @@ class UnoGenerator {
|
|
|
649
665
|
return [raw, processed, handlers, variants];
|
|
650
666
|
}
|
|
651
667
|
applyVariants(parsed, variantHandlers = parsed[4], raw = parsed[1]) {
|
|
652
|
-
const handler = [...variantHandlers].sort((a, b) => (a.order || 0) - (b.order || 0)).reverse().reduce(
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
668
|
+
const handler = [...variantHandlers].sort((a, b) => (a.order || 0) - (b.order || 0)).reverse().reduce(
|
|
669
|
+
(previous, v) => (input) => {
|
|
670
|
+
const entries = v.body?.(input.entries) || input.entries;
|
|
671
|
+
const parents = Array.isArray(v.parent) ? v.parent : [v.parent, void 0];
|
|
672
|
+
return (v.handle ?? defaultVariantHandler)({
|
|
673
|
+
...input,
|
|
674
|
+
entries,
|
|
675
|
+
selector: v.selector?.(input.selector, entries) || input.selector,
|
|
676
|
+
parent: parents[0] || input.parent,
|
|
677
|
+
parentOrder: parents[1] || input.parentOrder,
|
|
678
|
+
layer: v.layer || input.layer,
|
|
679
|
+
sort: v.sort || input.sort
|
|
680
|
+
}, previous);
|
|
681
|
+
},
|
|
682
|
+
(input) => input
|
|
683
|
+
);
|
|
665
684
|
const variantContextResult = handler({
|
|
666
685
|
prefix: "",
|
|
667
686
|
selector: toEscapedSelector(raw),
|
|
@@ -864,7 +883,7 @@ function applyScope(css, scope) {
|
|
|
864
883
|
return scope ? `${scope} ${css}` : css;
|
|
865
884
|
}
|
|
866
885
|
function movePseudoElementsEnd(selector) {
|
|
867
|
-
const pseudoElements = selector.match(/::[\w-]
|
|
886
|
+
const pseudoElements = selector.match(/::[\w-]+(\([\w-]+\))?/g);
|
|
868
887
|
if (pseudoElements) {
|
|
869
888
|
pseudoElements.forEach((e2) => selector = selector.replace(e2, ""));
|
|
870
889
|
selector += pseudoElements.join("");
|
package/dist/index.d.ts
CHANGED
|
@@ -95,7 +95,7 @@ declare function normalizeCSSValues(obj: CSSValue | string | (CSSValue | string)
|
|
|
95
95
|
declare function clearIdenticalEntries(entry: CSSEntries): CSSEntries;
|
|
96
96
|
declare function entriesToCss(arr?: CSSEntries): string;
|
|
97
97
|
declare function isObject(item: any): item is Record<string, any>;
|
|
98
|
-
declare function mergeDeep<T>(original: T, patch: DeepPartial<T
|
|
98
|
+
declare function mergeDeep<T>(original: T, patch: DeepPartial<T>): T;
|
|
99
99
|
declare function clone<T>(val: T): T;
|
|
100
100
|
declare function isStaticRule(rule: Rule): rule is StaticRule;
|
|
101
101
|
declare function isStaticShortcut(sc: Shortcut): sc is StaticShortcut;
|
package/dist/index.mjs
CHANGED
|
@@ -83,18 +83,16 @@ function entriesToCss(arr) {
|
|
|
83
83
|
function isObject(item) {
|
|
84
84
|
return item && typeof item === "object" && !Array.isArray(item);
|
|
85
85
|
}
|
|
86
|
-
function mergeDeep(original, patch
|
|
86
|
+
function mergeDeep(original, patch) {
|
|
87
87
|
const o = original;
|
|
88
88
|
const p = patch;
|
|
89
|
-
if (Array.isArray(o) && Array.isArray(p))
|
|
90
|
-
return [...o, ...p];
|
|
91
89
|
if (Array.isArray(o))
|
|
92
|
-
return [...
|
|
90
|
+
return [...p];
|
|
93
91
|
const output = { ...o };
|
|
94
92
|
if (isObject(o) && isObject(p)) {
|
|
95
93
|
Object.keys(p).forEach((key) => {
|
|
96
|
-
if (
|
|
97
|
-
output[key] = mergeDeep(o[key], p[key]
|
|
94
|
+
if (isObject(o[key]) && isObject(p[key]) || Array.isArray(o[key]) && Array.isArray(p[key]))
|
|
95
|
+
output[key] = mergeDeep(o[key], p[key]);
|
|
98
96
|
else
|
|
99
97
|
Object.assign(output, { [key]: p[key] });
|
|
100
98
|
});
|
|
@@ -194,9 +192,11 @@ class TwoKeyMap {
|
|
|
194
192
|
return this._map.delete(key1);
|
|
195
193
|
}
|
|
196
194
|
map(fn) {
|
|
197
|
-
return Array.from(this._map.entries()).flatMap(
|
|
198
|
-
|
|
199
|
-
|
|
195
|
+
return Array.from(this._map.entries()).flatMap(
|
|
196
|
+
([k1, m2]) => Array.from(m2.entries()).map(([k2, v]) => {
|
|
197
|
+
return fn(v, k1, k2);
|
|
198
|
+
})
|
|
199
|
+
);
|
|
200
200
|
}
|
|
201
201
|
}
|
|
202
202
|
class BetterMap extends Map {
|
|
@@ -226,11 +226,14 @@ function expandVariantGroup(str, seperators = ["-", ":"]) {
|
|
|
226
226
|
let content = str.toString();
|
|
227
227
|
do {
|
|
228
228
|
const before = content;
|
|
229
|
-
content = content.replace(
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
229
|
+
content = content.replace(
|
|
230
|
+
regexClassGroup,
|
|
231
|
+
(from, pre, sep, body) => {
|
|
232
|
+
if (!seperators.includes(sep))
|
|
233
|
+
return from;
|
|
234
|
+
return body.split(/\s/g).filter(Boolean).map((i) => i === "~" ? pre : i.replace(/^(!?)(.*)/, `$1${pre}${sep}$2`)).join(" ");
|
|
235
|
+
}
|
|
236
|
+
);
|
|
234
237
|
hasChanged = content !== before;
|
|
235
238
|
} while (hasChanged);
|
|
236
239
|
if (typeof str === "string")
|
|
@@ -277,7 +280,7 @@ function createValueHandler(handlers) {
|
|
|
277
280
|
return handler;
|
|
278
281
|
}
|
|
279
282
|
|
|
280
|
-
const splitCode = (code) => code.split(
|
|
283
|
+
const splitCode = (code) => code.split(/\\?[\s'"`;=]+/g).filter(isValidSelector);
|
|
281
284
|
const extractorSplit = {
|
|
282
285
|
name: "split",
|
|
283
286
|
order: 0,
|
|
@@ -379,7 +382,7 @@ function resolveConfig(userConfig = {}, defaults = {}) {
|
|
|
379
382
|
const theme = clone([
|
|
380
383
|
...sortedPresets.map((p) => p.theme || {}),
|
|
381
384
|
config.theme || {}
|
|
382
|
-
].reduce((a, p) => mergeDeep(a, p
|
|
385
|
+
].reduce((a, p) => mergeDeep(a, p), {}));
|
|
383
386
|
mergePresets("extendTheme").forEach((extendTheme) => extendTheme(theme));
|
|
384
387
|
const autocomplete = {
|
|
385
388
|
templates: uniq(sortedPresets.map((p) => toArray(p.autocomplete?.templates)).flat()),
|
|
@@ -410,7 +413,7 @@ function resolveConfig(userConfig = {}, defaults = {}) {
|
|
|
410
413
|
};
|
|
411
414
|
}
|
|
412
415
|
|
|
413
|
-
const version = "0.
|
|
416
|
+
const version = "0.45.4";
|
|
414
417
|
|
|
415
418
|
class UnoGenerator {
|
|
416
419
|
constructor(userConfig = {}, defaults = {}) {
|
|
@@ -482,7 +485,10 @@ class UnoGenerator {
|
|
|
482
485
|
this._cache.set(cacheKey, null);
|
|
483
486
|
return;
|
|
484
487
|
}
|
|
485
|
-
const context = this.makeContext(
|
|
488
|
+
const context = this.makeContext(
|
|
489
|
+
raw,
|
|
490
|
+
[alias || applied[0], applied[1], applied[2], applied[3]]
|
|
491
|
+
);
|
|
486
492
|
if (this.config.details)
|
|
487
493
|
context.variants = [...applied[3]];
|
|
488
494
|
const expanded = this.expandShortcut(context.currentSelector, context);
|
|
@@ -546,17 +552,25 @@ class UnoGenerator {
|
|
|
546
552
|
layerSet.add(layer);
|
|
547
553
|
preflightLayerSet.add(layer);
|
|
548
554
|
});
|
|
549
|
-
preflightsMap = Object.fromEntries(
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
555
|
+
preflightsMap = Object.fromEntries(
|
|
556
|
+
await Promise.all(Array.from(preflightLayerSet).map(
|
|
557
|
+
async (layer) => {
|
|
558
|
+
const preflights2 = await Promise.all(
|
|
559
|
+
this.config.preflights.filter((i) => (i.layer || LAYER_PREFLIGHTS) === layer).map(async (i) => await i.getCSS(preflightContext))
|
|
560
|
+
);
|
|
561
|
+
const css = preflights2.filter(Boolean).join(nl);
|
|
562
|
+
return [layer, css];
|
|
563
|
+
}
|
|
564
|
+
))
|
|
565
|
+
);
|
|
554
566
|
})();
|
|
555
567
|
await Promise.all([
|
|
556
568
|
...tokenPromises,
|
|
557
569
|
preflightPromise
|
|
558
570
|
]);
|
|
559
|
-
const layers = this.config.sortLayers(
|
|
571
|
+
const layers = this.config.sortLayers(
|
|
572
|
+
Array.from(layerSet).sort((a, b) => (this.config.layers[a] ?? 0) - (this.config.layers[b] ?? 0) || a.localeCompare(b))
|
|
573
|
+
);
|
|
560
574
|
const layerCache = {};
|
|
561
575
|
const getLayer = (layer) => {
|
|
562
576
|
if (layerCache[layer])
|
|
@@ -584,7 +598,9 @@ class UnoGenerator {
|
|
|
584
598
|
}
|
|
585
599
|
}
|
|
586
600
|
}
|
|
587
|
-
const selectors = selectorSortPair ? uniq(
|
|
601
|
+
const selectors = selectorSortPair ? uniq(
|
|
602
|
+
selectorSortPair.sort((a, b) => a[1] - b[1] || a[0]?.localeCompare(b[0] || "") || 0).map((pair) => pair[0]).filter(Boolean)
|
|
603
|
+
) : [];
|
|
588
604
|
return selectors.length ? `${selectors.join(`,${nl}`)}{${body}}` : body;
|
|
589
605
|
}).filter(Boolean).reverse().join(nl);
|
|
590
606
|
if (!parent)
|
|
@@ -645,19 +661,22 @@ class UnoGenerator {
|
|
|
645
661
|
return [raw, processed, handlers, variants];
|
|
646
662
|
}
|
|
647
663
|
applyVariants(parsed, variantHandlers = parsed[4], raw = parsed[1]) {
|
|
648
|
-
const handler = [...variantHandlers].sort((a, b) => (a.order || 0) - (b.order || 0)).reverse().reduce(
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
664
|
+
const handler = [...variantHandlers].sort((a, b) => (a.order || 0) - (b.order || 0)).reverse().reduce(
|
|
665
|
+
(previous, v) => (input) => {
|
|
666
|
+
const entries = v.body?.(input.entries) || input.entries;
|
|
667
|
+
const parents = Array.isArray(v.parent) ? v.parent : [v.parent, void 0];
|
|
668
|
+
return (v.handle ?? defaultVariantHandler)({
|
|
669
|
+
...input,
|
|
670
|
+
entries,
|
|
671
|
+
selector: v.selector?.(input.selector, entries) || input.selector,
|
|
672
|
+
parent: parents[0] || input.parent,
|
|
673
|
+
parentOrder: parents[1] || input.parentOrder,
|
|
674
|
+
layer: v.layer || input.layer,
|
|
675
|
+
sort: v.sort || input.sort
|
|
676
|
+
}, previous);
|
|
677
|
+
},
|
|
678
|
+
(input) => input
|
|
679
|
+
);
|
|
661
680
|
const variantContextResult = handler({
|
|
662
681
|
prefix: "",
|
|
663
682
|
selector: toEscapedSelector(raw),
|
|
@@ -860,7 +879,7 @@ function applyScope(css, scope) {
|
|
|
860
879
|
return scope ? `${scope} ${css}` : css;
|
|
861
880
|
}
|
|
862
881
|
function movePseudoElementsEnd(selector) {
|
|
863
|
-
const pseudoElements = selector.match(/::[\w-]
|
|
882
|
+
const pseudoElements = selector.match(/::[\w-]+(\([\w-]+\))?/g);
|
|
864
883
|
if (pseudoElements) {
|
|
865
884
|
pseudoElements.forEach((e2) => selector = selector.replace(e2, ""));
|
|
866
885
|
selector += pseudoElements.join("");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unocss/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.45.4",
|
|
4
4
|
"description": "The instant on-demand Atomic CSS engine.",
|
|
5
5
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
],
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"magic-string": "^0.26.2",
|
|
41
|
-
"unconfig": "^0.3.
|
|
41
|
+
"unconfig": "^0.3.5"
|
|
42
42
|
},
|
|
43
43
|
"scripts": {
|
|
44
44
|
"build": "unbuild",
|