@unocss/core 0.48.5 → 0.49.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 +18 -7
- package/dist/index.d.ts +9 -2
- package/dist/index.mjs +18 -7
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -219,9 +219,16 @@ function withLayer(layer, rules) {
|
|
|
219
219
|
return rules;
|
|
220
220
|
}
|
|
221
221
|
|
|
222
|
-
const
|
|
222
|
+
const regexCache = {};
|
|
223
|
+
function makeRegexClassGroup(separators = ["-", ":"]) {
|
|
224
|
+
const key = separators.join("|");
|
|
225
|
+
if (!regexCache[key])
|
|
226
|
+
regexCache[key] = new RegExp(`((?:[!@\\w+:_/-]|\\[&?>?:?.*\\])+?)(${key})\\(((?:[~!\\w\\s:/\\\\,%#.$?-]|\\[.*?\\])+?)\\)(?!\\s*?=>)`, "gm");
|
|
227
|
+
regexCache[key].lastIndex = 0;
|
|
228
|
+
return regexCache[key];
|
|
229
|
+
}
|
|
223
230
|
function expandVariantGroup(str, separators = ["-", ":"], depth = 5) {
|
|
224
|
-
regexClassGroup
|
|
231
|
+
const regexClassGroup = makeRegexClassGroup(separators);
|
|
225
232
|
let hasChanged = false;
|
|
226
233
|
let content = str.toString();
|
|
227
234
|
do {
|
|
@@ -408,6 +415,9 @@ function resolveConfig(userConfig = {}, defaults = {}) {
|
|
|
408
415
|
templates: uniq(sortedPresets.map((p) => toArray(p.autocomplete?.templates)).flat()),
|
|
409
416
|
extractors: sortedPresets.map((p) => toArray(p.autocomplete?.extractors)).flat().sort((a, b) => (a.order || 0) - (b.order || 0))
|
|
410
417
|
};
|
|
418
|
+
let separators = toArray(mergePresets("separators"));
|
|
419
|
+
if (!separators.length)
|
|
420
|
+
separators = [":", "-"];
|
|
411
421
|
return {
|
|
412
422
|
mergeSelectors: true,
|
|
413
423
|
warn: true,
|
|
@@ -429,11 +439,12 @@ function resolveConfig(userConfig = {}, defaults = {}) {
|
|
|
429
439
|
variants: mergePresets("variants").map(normalizeVariant),
|
|
430
440
|
shortcuts: resolveShortcuts(mergePresets("shortcuts")).reverse(),
|
|
431
441
|
extractors,
|
|
432
|
-
safelist: mergePresets("safelist")
|
|
442
|
+
safelist: mergePresets("safelist"),
|
|
443
|
+
separators
|
|
433
444
|
};
|
|
434
445
|
}
|
|
435
446
|
|
|
436
|
-
const version = "0.
|
|
447
|
+
const version = "0.49.0";
|
|
437
448
|
|
|
438
449
|
class UnoGenerator {
|
|
439
450
|
constructor(userConfig = {}, defaults = {}) {
|
|
@@ -894,8 +905,8 @@ class UnoGenerator {
|
|
|
894
905
|
function createGenerator(config, defaults) {
|
|
895
906
|
return new UnoGenerator(config, defaults);
|
|
896
907
|
}
|
|
897
|
-
const regexScopePlaceholder =
|
|
898
|
-
const hasScopePlaceholder = (css) => css.match(
|
|
908
|
+
const regexScopePlaceholder = /\s\$\$\s+/g;
|
|
909
|
+
const hasScopePlaceholder = (css) => css.match(/\s\$\$\s/);
|
|
899
910
|
function applyScope(css, scope) {
|
|
900
911
|
if (hasScopePlaceholder(css))
|
|
901
912
|
return css.replace(regexScopePlaceholder, scope ? ` ${scope} ` : " ");
|
|
@@ -947,6 +958,7 @@ exports.isStaticRule = isStaticRule;
|
|
|
947
958
|
exports.isStaticShortcut = isStaticShortcut;
|
|
948
959
|
exports.isString = isString;
|
|
949
960
|
exports.isValidSelector = isValidSelector;
|
|
961
|
+
exports.makeRegexClassGroup = makeRegexClassGroup;
|
|
950
962
|
exports.mergeDeep = mergeDeep;
|
|
951
963
|
exports.movePseudoElementsEnd = movePseudoElementsEnd;
|
|
952
964
|
exports.noop = noop;
|
|
@@ -954,7 +966,6 @@ exports.normalizeCSSEntries = normalizeCSSEntries;
|
|
|
954
966
|
exports.normalizeCSSValues = normalizeCSSValues;
|
|
955
967
|
exports.normalizeVariant = normalizeVariant;
|
|
956
968
|
exports.notNull = notNull;
|
|
957
|
-
exports.regexClassGroup = regexClassGroup;
|
|
958
969
|
exports.regexScopePlaceholder = regexScopePlaceholder;
|
|
959
970
|
exports.toArray = toArray;
|
|
960
971
|
exports.toEscapedSelector = toEscapedSelector;
|
package/dist/index.d.ts
CHANGED
|
@@ -131,7 +131,7 @@ declare class BetterMap<K, V> extends Map<K, V> {
|
|
|
131
131
|
|
|
132
132
|
declare function withLayer<T extends {}>(layer: string, rules: Rule<T>[]): Rule<T>[];
|
|
133
133
|
|
|
134
|
-
declare
|
|
134
|
+
declare function makeRegexClassGroup(separators?: string[]): RegExp;
|
|
135
135
|
declare function expandVariantGroup(str: string, separators?: string[], depth?: number): string;
|
|
136
136
|
declare function expandVariantGroup(str: MagicString, separators?: string[], depth?: number): MagicString;
|
|
137
137
|
|
|
@@ -427,6 +427,12 @@ interface ConfigBase<Theme extends {} = {}> {
|
|
|
427
427
|
* Later entries have higher priority.
|
|
428
428
|
*/
|
|
429
429
|
rules?: Rule<Theme>[];
|
|
430
|
+
/**
|
|
431
|
+
* Variant separator
|
|
432
|
+
*
|
|
433
|
+
* @default [':', '-']
|
|
434
|
+
*/
|
|
435
|
+
separators?: Arrayable<string>;
|
|
430
436
|
/**
|
|
431
437
|
* Variants that preprocess the selectors,
|
|
432
438
|
* having the ability to rewrite the CSS object.
|
|
@@ -731,6 +737,7 @@ interface ResolvedConfig<Theme extends {} = {}> extends Omit<RequiredByKey<UserC
|
|
|
731
737
|
templates: (AutoCompleteFunction | AutoCompleteTemplate)[];
|
|
732
738
|
extractors: AutoCompleteExtractor[];
|
|
733
739
|
};
|
|
740
|
+
separators: string[];
|
|
734
741
|
}
|
|
735
742
|
interface GenerateResult {
|
|
736
743
|
css: string;
|
|
@@ -814,4 +821,4 @@ declare const extractorSplit: Extractor;
|
|
|
814
821
|
|
|
815
822
|
declare const extractorSvelte: Extractor;
|
|
816
823
|
|
|
817
|
-
export { ArgumentType, Arrayable, AutoCompleteExtractor, AutoCompleteExtractorContext, AutoCompleteExtractorResult, AutoCompleteFunction, AutoCompleteTemplate, Awaitable, BetterMap, BlocklistRule, CONTROL_SHORTCUT_NO_MERGE, CSSColorValue, CSSEntries, CSSObject, CSSValue, CSSValues, CliEntryItem, CliOptions, ConfigBase, DeepPartial, DynamicMatcher, DynamicRule, DynamicShortcut, DynamicShortcutMatcher, ExtraContentOptions, Extractor, ExtractorContext, FilterPattern, FlatObjectTuple, GenerateOptions, GenerateResult, GeneratorOptions, ParsedColorValue, ParsedUtil, PartialByKeys, PluginOptions, Postprocessor, Preflight, PreflightContext, PreparedRule, Preprocessor, Preset, PresetOptions, RGBAColorValue, RawUtil, Replacement, RequiredByKey, ResolvedConfig, RestArgs, Rule, RuleContext, RuleMeta, Shift, Shortcut, ShortcutValue, SourceCodeTransformer, SourceCodeTransformerEnforce, SourceMap, StaticRule, StaticShortcut, StaticShortcutMap, StringifiedUtil, SuggestResult, ThemeExtender, TransformResult, TwoKeyMap, UnoGenerator, UnocssPluginContext, UserConfig, UserConfigDefaults, UserOnlyOptions, UserShortcuts, UtilObject, ValueHandler, ValueHandlerCallback, Variant, VariantContext, VariantFunction, VariantHandler, VariantHandlerContext, VariantMatchedResult, VariantObject, arbitraryPropertyRE, attributifyRE, clearIdenticalEntries, clone, createGenerator, createValueHandler, cssIdRE, e, entriesToCss, escapeRegExp, escapeSelector, expandVariantGroup, extractorSplit, extractorSvelte, hasScopePlaceholder, isAttributifySelector, isObject, isRawUtil, isStaticRule, isStaticShortcut, isString, isValidSelector, mergeDeep, movePseudoElementsEnd, noop, normalizeCSSEntries, normalizeCSSValues, normalizeVariant, notNull,
|
|
824
|
+
export { ArgumentType, Arrayable, AutoCompleteExtractor, AutoCompleteExtractorContext, AutoCompleteExtractorResult, AutoCompleteFunction, AutoCompleteTemplate, Awaitable, BetterMap, BlocklistRule, CONTROL_SHORTCUT_NO_MERGE, CSSColorValue, CSSEntries, CSSObject, CSSValue, CSSValues, CliEntryItem, CliOptions, ConfigBase, DeepPartial, DynamicMatcher, DynamicRule, DynamicShortcut, DynamicShortcutMatcher, ExtraContentOptions, Extractor, ExtractorContext, FilterPattern, FlatObjectTuple, GenerateOptions, GenerateResult, GeneratorOptions, ParsedColorValue, ParsedUtil, PartialByKeys, PluginOptions, Postprocessor, Preflight, PreflightContext, PreparedRule, Preprocessor, Preset, PresetOptions, RGBAColorValue, RawUtil, Replacement, RequiredByKey, ResolvedConfig, RestArgs, Rule, RuleContext, RuleMeta, Shift, Shortcut, ShortcutValue, SourceCodeTransformer, SourceCodeTransformerEnforce, SourceMap, StaticRule, StaticShortcut, StaticShortcutMap, StringifiedUtil, SuggestResult, ThemeExtender, TransformResult, TwoKeyMap, UnoGenerator, UnocssPluginContext, UserConfig, UserConfigDefaults, UserOnlyOptions, UserShortcuts, UtilObject, ValueHandler, ValueHandlerCallback, Variant, VariantContext, VariantFunction, VariantHandler, VariantHandlerContext, VariantMatchedResult, VariantObject, arbitraryPropertyRE, attributifyRE, clearIdenticalEntries, clone, createGenerator, createValueHandler, cssIdRE, e, entriesToCss, escapeRegExp, escapeSelector, expandVariantGroup, extractorSplit, extractorSvelte, hasScopePlaceholder, isAttributifySelector, isObject, isRawUtil, isStaticRule, isStaticShortcut, isString, isValidSelector, makeRegexClassGroup, mergeDeep, movePseudoElementsEnd, noop, normalizeCSSEntries, normalizeCSSValues, normalizeVariant, notNull, regexScopePlaceholder, toArray, toEscapedSelector, uniq, validateFilterRE, warnOnce, withLayer };
|
package/dist/index.mjs
CHANGED
|
@@ -215,9 +215,16 @@ function withLayer(layer, rules) {
|
|
|
215
215
|
return rules;
|
|
216
216
|
}
|
|
217
217
|
|
|
218
|
-
const
|
|
218
|
+
const regexCache = {};
|
|
219
|
+
function makeRegexClassGroup(separators = ["-", ":"]) {
|
|
220
|
+
const key = separators.join("|");
|
|
221
|
+
if (!regexCache[key])
|
|
222
|
+
regexCache[key] = new RegExp(`((?:[!@\\w+:_/-]|\\[&?>?:?.*\\])+?)(${key})\\(((?:[~!\\w\\s:/\\\\,%#.$?-]|\\[.*?\\])+?)\\)(?!\\s*?=>)`, "gm");
|
|
223
|
+
regexCache[key].lastIndex = 0;
|
|
224
|
+
return regexCache[key];
|
|
225
|
+
}
|
|
219
226
|
function expandVariantGroup(str, separators = ["-", ":"], depth = 5) {
|
|
220
|
-
regexClassGroup
|
|
227
|
+
const regexClassGroup = makeRegexClassGroup(separators);
|
|
221
228
|
let hasChanged = false;
|
|
222
229
|
let content = str.toString();
|
|
223
230
|
do {
|
|
@@ -404,6 +411,9 @@ function resolveConfig(userConfig = {}, defaults = {}) {
|
|
|
404
411
|
templates: uniq(sortedPresets.map((p) => toArray(p.autocomplete?.templates)).flat()),
|
|
405
412
|
extractors: sortedPresets.map((p) => toArray(p.autocomplete?.extractors)).flat().sort((a, b) => (a.order || 0) - (b.order || 0))
|
|
406
413
|
};
|
|
414
|
+
let separators = toArray(mergePresets("separators"));
|
|
415
|
+
if (!separators.length)
|
|
416
|
+
separators = [":", "-"];
|
|
407
417
|
return {
|
|
408
418
|
mergeSelectors: true,
|
|
409
419
|
warn: true,
|
|
@@ -425,11 +435,12 @@ function resolveConfig(userConfig = {}, defaults = {}) {
|
|
|
425
435
|
variants: mergePresets("variants").map(normalizeVariant),
|
|
426
436
|
shortcuts: resolveShortcuts(mergePresets("shortcuts")).reverse(),
|
|
427
437
|
extractors,
|
|
428
|
-
safelist: mergePresets("safelist")
|
|
438
|
+
safelist: mergePresets("safelist"),
|
|
439
|
+
separators
|
|
429
440
|
};
|
|
430
441
|
}
|
|
431
442
|
|
|
432
|
-
const version = "0.
|
|
443
|
+
const version = "0.49.0";
|
|
433
444
|
|
|
434
445
|
class UnoGenerator {
|
|
435
446
|
constructor(userConfig = {}, defaults = {}) {
|
|
@@ -890,8 +901,8 @@ class UnoGenerator {
|
|
|
890
901
|
function createGenerator(config, defaults) {
|
|
891
902
|
return new UnoGenerator(config, defaults);
|
|
892
903
|
}
|
|
893
|
-
const regexScopePlaceholder =
|
|
894
|
-
const hasScopePlaceholder = (css) => css.match(
|
|
904
|
+
const regexScopePlaceholder = /\s\$\$\s+/g;
|
|
905
|
+
const hasScopePlaceholder = (css) => css.match(/\s\$\$\s/);
|
|
895
906
|
function applyScope(css, scope) {
|
|
896
907
|
if (hasScopePlaceholder(css))
|
|
897
908
|
return css.replace(regexScopePlaceholder, scope ? ` ${scope} ` : " ");
|
|
@@ -917,4 +928,4 @@ function defaultVariantHandler(input, next) {
|
|
|
917
928
|
return next(input);
|
|
918
929
|
}
|
|
919
930
|
|
|
920
|
-
export { BetterMap, CONTROL_SHORTCUT_NO_MERGE, TwoKeyMap, UnoGenerator, arbitraryPropertyRE, attributifyRE, clearIdenticalEntries, clone, createGenerator, createValueHandler, cssIdRE, e, entriesToCss, escapeRegExp, escapeSelector, expandVariantGroup, extractorSplit, extractorSvelte, hasScopePlaceholder, isAttributifySelector, isObject, isRawUtil, isStaticRule, isStaticShortcut, isString, isValidSelector, mergeDeep, movePseudoElementsEnd, noop, normalizeCSSEntries, normalizeCSSValues, normalizeVariant, notNull,
|
|
931
|
+
export { BetterMap, CONTROL_SHORTCUT_NO_MERGE, TwoKeyMap, UnoGenerator, arbitraryPropertyRE, attributifyRE, clearIdenticalEntries, clone, createGenerator, createValueHandler, cssIdRE, e, entriesToCss, escapeRegExp, escapeSelector, expandVariantGroup, extractorSplit, extractorSvelte, hasScopePlaceholder, isAttributifySelector, isObject, isRawUtil, isStaticRule, isStaticShortcut, isString, isValidSelector, makeRegexClassGroup, mergeDeep, movePseudoElementsEnd, noop, normalizeCSSEntries, normalizeCSSValues, normalizeVariant, notNull, regexScopePlaceholder, toArray, toEscapedSelector, uniq, validateFilterRE, warnOnce, withLayer };
|