@unocss/core 0.33.5 → 0.35.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.cjs +13 -3
- package/dist/index.d.ts +6 -5
- package/dist/index.mjs +13 -4
- package/package.json +19 -19
package/dist/index.cjs
CHANGED
|
@@ -457,7 +457,7 @@ function resolveConfig(userConfig = {}, defaults = {}) {
|
|
|
457
457
|
};
|
|
458
458
|
}
|
|
459
459
|
|
|
460
|
-
const version = "0.
|
|
460
|
+
const version = "0.35.0";
|
|
461
461
|
|
|
462
462
|
class UnoGenerator {
|
|
463
463
|
constructor(userConfig = {}, defaults = {}) {
|
|
@@ -661,7 +661,7 @@ class UnoGenerator {
|
|
|
661
661
|
processed = handler.matcher;
|
|
662
662
|
if (Array.isArray(handler.parent))
|
|
663
663
|
this.parentOrders.set(handler.parent[0], handler.parent[1]);
|
|
664
|
-
handlers.
|
|
664
|
+
handlers.unshift(handler);
|
|
665
665
|
variants.add(v);
|
|
666
666
|
applied = true;
|
|
667
667
|
break;
|
|
@@ -676,8 +676,9 @@ class UnoGenerator {
|
|
|
676
676
|
applyVariants(parsed, variantHandlers = parsed[4], raw = parsed[1]) {
|
|
677
677
|
const handlers = [...variantHandlers].sort((a, b) => (a.order || 0) - (b.order || 0));
|
|
678
678
|
const entries = handlers.reduce((p, v) => v.body?.(p) || p, parsed[2]);
|
|
679
|
+
const selector = handlers.reduce((p, v) => v.selector?.(p, entries) || p, toEscapedSelector(raw));
|
|
679
680
|
const obj = {
|
|
680
|
-
selector:
|
|
681
|
+
selector: movePseudoElementsEnd(selector),
|
|
681
682
|
entries,
|
|
682
683
|
parent: handlers.reduce((p, v) => Array.isArray(v.parent) ? v.parent[0] : v.parent || p, void 0),
|
|
683
684
|
layer: handlers.reduce((p, v) => v.layer || p, void 0),
|
|
@@ -840,6 +841,14 @@ function applyScope(css, scope) {
|
|
|
840
841
|
else
|
|
841
842
|
return scope ? `${scope} ${css}` : css;
|
|
842
843
|
}
|
|
844
|
+
function movePseudoElementsEnd(selector) {
|
|
845
|
+
const pseudoElements = selector.match(/::[\w-]+/g);
|
|
846
|
+
if (pseudoElements) {
|
|
847
|
+
pseudoElements.forEach((e2) => selector = selector.replace(e2, ""));
|
|
848
|
+
selector += pseudoElements.join("");
|
|
849
|
+
}
|
|
850
|
+
return selector;
|
|
851
|
+
}
|
|
843
852
|
const attributifyRe = /^\[(.+?)(~?=)"(.*)"\]$/;
|
|
844
853
|
function toEscapedSelector(raw) {
|
|
845
854
|
if (attributifyRe.test(raw))
|
|
@@ -875,6 +884,7 @@ exports.isValidSelector = isValidSelector;
|
|
|
875
884
|
exports.matchingPair = matchingPair;
|
|
876
885
|
exports.mergeDeep = mergeDeep;
|
|
877
886
|
exports.mergeSet = mergeSet;
|
|
887
|
+
exports.movePseudoElementsEnd = movePseudoElementsEnd;
|
|
878
888
|
exports.noop = noop;
|
|
879
889
|
exports.normalizeCSSEntries = normalizeCSSEntries;
|
|
880
890
|
exports.normalizeCSSValues = normalizeCSSValues;
|
package/dist/index.d.ts
CHANGED
|
@@ -80,6 +80,7 @@ declare class UnoGenerator {
|
|
|
80
80
|
declare function createGenerator(config?: UserConfig, defaults?: UserConfigDefaults): UnoGenerator;
|
|
81
81
|
declare const regexScopePlaceholder: RegExp;
|
|
82
82
|
declare const hasScopePlaceholder: (css: string) => RegExpMatchArray | null;
|
|
83
|
+
declare function movePseudoElementsEnd(selector: string): string;
|
|
83
84
|
declare function toEscapedSelector(raw: string): string;
|
|
84
85
|
|
|
85
86
|
declare function escapeRegExp(string: string): string;
|
|
@@ -326,8 +327,8 @@ declare type DynamicShortcut<Theme extends {} = {}> = [RegExp, DynamicShortcutMa
|
|
|
326
327
|
declare type UserShortcuts<Theme extends {} = {}> = StaticShortcutMap | (StaticShortcut | DynamicShortcut<Theme> | StaticShortcutMap)[];
|
|
327
328
|
declare type Shortcut<Theme extends {} = {}> = StaticShortcut | DynamicShortcut<Theme>;
|
|
328
329
|
declare type FilterPattern = ReadonlyArray<string | RegExp> | string | RegExp | null;
|
|
329
|
-
interface Preflight {
|
|
330
|
-
getCSS: (context: PreflightContext) => Promise<string | undefined> | string | undefined;
|
|
330
|
+
interface Preflight<Theme extends {} = {}> {
|
|
331
|
+
getCSS: (context: PreflightContext<Theme>) => Promise<string | undefined> | string | undefined;
|
|
331
332
|
layer?: string;
|
|
332
333
|
}
|
|
333
334
|
declare type BlocklistRule = string | RegExp;
|
|
@@ -418,7 +419,7 @@ interface ConfigBase<Theme extends {} = {}> {
|
|
|
418
419
|
/**
|
|
419
420
|
* Raw CSS injections.
|
|
420
421
|
*/
|
|
421
|
-
preflights?: Preflight[];
|
|
422
|
+
preflights?: Preflight<Theme>[];
|
|
422
423
|
/**
|
|
423
424
|
* Theme object for shared configuration between rules
|
|
424
425
|
*/
|
|
@@ -553,7 +554,7 @@ interface UserOnlyOptions<Theme extends {} = {}> {
|
|
|
553
554
|
/**
|
|
554
555
|
* Presets
|
|
555
556
|
*/
|
|
556
|
-
presets?: (Preset | Preset[])[];
|
|
557
|
+
presets?: (Preset<Theme> | Preset<Theme>[])[];
|
|
557
558
|
/**
|
|
558
559
|
* Environment mode
|
|
559
560
|
*
|
|
@@ -721,4 +722,4 @@ declare const extractorSplit: Extractor;
|
|
|
721
722
|
|
|
722
723
|
declare const extractorSvelte: Extractor;
|
|
723
724
|
|
|
724
|
-
export { ArgumentType, Arrayable, AutoCompleteExtractor, AutoCompleteExtractorContext, AutoCompleteExtractorResult, AutoCompleteFunction, AutoCompleteTemplate, Awaitable, BetterMap, BlocklistRule, CONTROL_SHORTCUT_NO_MERGE, CSSColorValue, CSSEntries, CSSObject, CSSValues, ConfigBase, DeepPartial, DetailString, DynamicMatcher, DynamicRule, DynamicShortcut, DynamicShortcutMatcher, ExtractStringOptions, Extractor, ExtractorContext, FilterPattern, FlatObjectTuple, GenerateOptions, GenerateResult, GeneratorOptions, ParsedColorValue, ParsedUtil, PartialByKeys, PluginOptions, Postprocessor, Preflight, PreflightContext, Preprocessor, Preset, PresetOptions, RGBAColorValue, Range, RawUtil, Replacement, RequiredByKey, ResolvedConfig, RestArgs, Rule, RuleContext, RuleMeta, Shift, Shortcut, SourceCodeTransformer, SourceMap, StaticRule, StaticShortcut, StaticShortcutMap, StringifiedUtil, SuggestResult, ThemeExtender, TransformResult, TwoKeyMap, UnoGenerator, UnocssPluginContext, UserConfig, UserConfigDefaults, UserOnlyOptions, UserShortcuts, UtilObject, ValueHandler, ValueHandlerCallback, Variant, VariantContext, VariantFunction, VariantHandler, VariantMatchedResult, VariantObject, attributifyRE, clearIdenticalEntries, clone, createGenerator, createValueHandler, cssIdRE, e, entriesToCss, escapeRegExp, escapeSelector, expandVariantGroup, extractQuoted, extractorSplit, extractorSvelte, hasScopePlaceholder, isAttributifySelector, isObject, isRawUtil, isStaticRule, isStaticShortcut, isValidSelector, matchingPair, mergeDeep, mergeSet, noop, normalizeCSSEntries, normalizeCSSValues, normalizeVariant, notNull, regexClassGroup, regexScopePlaceholder, toArray, toEscapedSelector, uniq, validateFilterRE, warnOnce, withLayer };
|
|
725
|
+
export { ArgumentType, Arrayable, AutoCompleteExtractor, AutoCompleteExtractorContext, AutoCompleteExtractorResult, AutoCompleteFunction, AutoCompleteTemplate, Awaitable, BetterMap, BlocklistRule, CONTROL_SHORTCUT_NO_MERGE, CSSColorValue, CSSEntries, CSSObject, CSSValues, ConfigBase, DeepPartial, DetailString, DynamicMatcher, DynamicRule, DynamicShortcut, DynamicShortcutMatcher, ExtractStringOptions, Extractor, ExtractorContext, FilterPattern, FlatObjectTuple, GenerateOptions, GenerateResult, GeneratorOptions, ParsedColorValue, ParsedUtil, PartialByKeys, PluginOptions, Postprocessor, Preflight, PreflightContext, Preprocessor, Preset, PresetOptions, RGBAColorValue, Range, RawUtil, Replacement, RequiredByKey, ResolvedConfig, RestArgs, Rule, RuleContext, RuleMeta, Shift, Shortcut, SourceCodeTransformer, SourceMap, StaticRule, StaticShortcut, StaticShortcutMap, StringifiedUtil, SuggestResult, ThemeExtender, TransformResult, TwoKeyMap, UnoGenerator, UnocssPluginContext, UserConfig, UserConfigDefaults, UserOnlyOptions, UserShortcuts, UtilObject, ValueHandler, ValueHandlerCallback, Variant, VariantContext, VariantFunction, VariantHandler, VariantMatchedResult, VariantObject, attributifyRE, clearIdenticalEntries, clone, createGenerator, createValueHandler, cssIdRE, e, entriesToCss, escapeRegExp, escapeSelector, expandVariantGroup, extractQuoted, extractorSplit, extractorSvelte, hasScopePlaceholder, isAttributifySelector, isObject, isRawUtil, isStaticRule, isStaticShortcut, isValidSelector, matchingPair, mergeDeep, mergeSet, movePseudoElementsEnd, noop, normalizeCSSEntries, normalizeCSSValues, normalizeVariant, notNull, regexClassGroup, regexScopePlaceholder, toArray, toEscapedSelector, uniq, validateFilterRE, warnOnce, withLayer };
|
package/dist/index.mjs
CHANGED
|
@@ -453,7 +453,7 @@ function resolveConfig(userConfig = {}, defaults = {}) {
|
|
|
453
453
|
};
|
|
454
454
|
}
|
|
455
455
|
|
|
456
|
-
const version = "0.
|
|
456
|
+
const version = "0.35.0";
|
|
457
457
|
|
|
458
458
|
class UnoGenerator {
|
|
459
459
|
constructor(userConfig = {}, defaults = {}) {
|
|
@@ -657,7 +657,7 @@ class UnoGenerator {
|
|
|
657
657
|
processed = handler.matcher;
|
|
658
658
|
if (Array.isArray(handler.parent))
|
|
659
659
|
this.parentOrders.set(handler.parent[0], handler.parent[1]);
|
|
660
|
-
handlers.
|
|
660
|
+
handlers.unshift(handler);
|
|
661
661
|
variants.add(v);
|
|
662
662
|
applied = true;
|
|
663
663
|
break;
|
|
@@ -672,8 +672,9 @@ class UnoGenerator {
|
|
|
672
672
|
applyVariants(parsed, variantHandlers = parsed[4], raw = parsed[1]) {
|
|
673
673
|
const handlers = [...variantHandlers].sort((a, b) => (a.order || 0) - (b.order || 0));
|
|
674
674
|
const entries = handlers.reduce((p, v) => v.body?.(p) || p, parsed[2]);
|
|
675
|
+
const selector = handlers.reduce((p, v) => v.selector?.(p, entries) || p, toEscapedSelector(raw));
|
|
675
676
|
const obj = {
|
|
676
|
-
selector:
|
|
677
|
+
selector: movePseudoElementsEnd(selector),
|
|
677
678
|
entries,
|
|
678
679
|
parent: handlers.reduce((p, v) => Array.isArray(v.parent) ? v.parent[0] : v.parent || p, void 0),
|
|
679
680
|
layer: handlers.reduce((p, v) => v.layer || p, void 0),
|
|
@@ -836,6 +837,14 @@ function applyScope(css, scope) {
|
|
|
836
837
|
else
|
|
837
838
|
return scope ? `${scope} ${css}` : css;
|
|
838
839
|
}
|
|
840
|
+
function movePseudoElementsEnd(selector) {
|
|
841
|
+
const pseudoElements = selector.match(/::[\w-]+/g);
|
|
842
|
+
if (pseudoElements) {
|
|
843
|
+
pseudoElements.forEach((e2) => selector = selector.replace(e2, ""));
|
|
844
|
+
selector += pseudoElements.join("");
|
|
845
|
+
}
|
|
846
|
+
return selector;
|
|
847
|
+
}
|
|
839
848
|
const attributifyRe = /^\[(.+?)(~?=)"(.*)"\]$/;
|
|
840
849
|
function toEscapedSelector(raw) {
|
|
841
850
|
if (attributifyRe.test(raw))
|
|
@@ -843,4 +852,4 @@ function toEscapedSelector(raw) {
|
|
|
843
852
|
return `.${e(raw)}`;
|
|
844
853
|
}
|
|
845
854
|
|
|
846
|
-
export { BetterMap, CONTROL_SHORTCUT_NO_MERGE, TwoKeyMap, UnoGenerator, attributifyRE, clearIdenticalEntries, clone, createGenerator, createValueHandler, cssIdRE, e, entriesToCss, escapeRegExp, escapeSelector, expandVariantGroup, extractQuoted, extractorSplit, extractorSvelte, hasScopePlaceholder, isAttributifySelector, isObject, isRawUtil, isStaticRule, isStaticShortcut, isValidSelector, matchingPair, mergeDeep, mergeSet, noop, normalizeCSSEntries, normalizeCSSValues, normalizeVariant, notNull, regexClassGroup, regexScopePlaceholder, toArray, toEscapedSelector, uniq, validateFilterRE, warnOnce, withLayer };
|
|
855
|
+
export { BetterMap, CONTROL_SHORTCUT_NO_MERGE, TwoKeyMap, UnoGenerator, attributifyRE, clearIdenticalEntries, clone, createGenerator, createValueHandler, cssIdRE, e, entriesToCss, escapeRegExp, escapeSelector, expandVariantGroup, extractQuoted, extractorSplit, extractorSvelte, hasScopePlaceholder, isAttributifySelector, isObject, isRawUtil, isStaticRule, isStaticShortcut, isValidSelector, matchingPair, mergeDeep, mergeSet, movePseudoElementsEnd, noop, normalizeCSSEntries, normalizeCSSValues, normalizeVariant, notNull, regexClassGroup, regexScopePlaceholder, toArray, toEscapedSelector, uniq, validateFilterRE, warnOnce, withLayer };
|
package/package.json
CHANGED
|
@@ -1,7 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unocss/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.35.0",
|
|
4
4
|
"description": "The instant on-demand Atomic CSS engine.",
|
|
5
|
+
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"funding": "https://github.com/sponsors/antfu",
|
|
8
|
+
"homepage": "https://github.com/unocss/unocss/tree/main/packages/core#readme",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/unocss/unocss.git",
|
|
12
|
+
"directory": "packages/core"
|
|
13
|
+
},
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/unocss/unocss/issues"
|
|
16
|
+
},
|
|
5
17
|
"keywords": [
|
|
6
18
|
"unocss",
|
|
7
19
|
"atomic-css",
|
|
@@ -10,32 +22,20 @@
|
|
|
10
22
|
"tailwind",
|
|
11
23
|
"windicss"
|
|
12
24
|
],
|
|
13
|
-
"
|
|
14
|
-
"bugs": {
|
|
15
|
-
"url": "https://github.com/unocss/unocss/issues"
|
|
16
|
-
},
|
|
17
|
-
"license": "MIT",
|
|
18
|
-
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
19
|
-
"repository": {
|
|
20
|
-
"type": "git",
|
|
21
|
-
"url": "git+https://github.com/unocss/unocss.git",
|
|
22
|
-
"directory": "packages/core"
|
|
23
|
-
},
|
|
24
|
-
"funding": "https://github.com/sponsors/antfu",
|
|
25
|
-
"main": "dist/index.cjs",
|
|
26
|
-
"module": "dist/index.mjs",
|
|
27
|
-
"types": "dist/index.d.ts",
|
|
25
|
+
"sideEffects": false,
|
|
28
26
|
"exports": {
|
|
29
27
|
".": {
|
|
30
|
-
"
|
|
28
|
+
"types": "./dist/index.d.ts",
|
|
31
29
|
"import": "./dist/index.mjs",
|
|
32
|
-
"
|
|
30
|
+
"require": "./dist/index.cjs"
|
|
33
31
|
}
|
|
34
32
|
},
|
|
33
|
+
"main": "dist/index.cjs",
|
|
34
|
+
"module": "dist/index.mjs",
|
|
35
|
+
"types": "dist/index.d.ts",
|
|
35
36
|
"files": [
|
|
36
37
|
"dist"
|
|
37
38
|
],
|
|
38
|
-
"sideEffects": false,
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"magic-string": "^0.26.2",
|
|
41
41
|
"unconfig": "^0.3.4"
|