@unocss/core 0.51.2 → 0.51.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 +25 -27
- package/dist/index.d.ts +2 -1
- package/dist/index.mjs +25 -27
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -413,21 +413,23 @@ function resolveConfig(userConfig = {}, defaults = {}) {
|
|
|
413
413
|
...rawPresets.filter((p) => !p.enforce),
|
|
414
414
|
...rawPresets.filter((p) => p.enforce === "post")
|
|
415
415
|
];
|
|
416
|
-
const
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
416
|
+
const sources = [
|
|
417
|
+
...sortedPresets,
|
|
418
|
+
config
|
|
419
|
+
];
|
|
420
|
+
const sourcesReversed = [...sources].reverse();
|
|
421
|
+
const layers = Object.assign({}, DEFAULT_LAYERS, ...sources.map((i) => i.layers));
|
|
422
|
+
function getMerged(key) {
|
|
423
|
+
return uniq(sources.flatMap((p) => toArray(p[key] || [])));
|
|
424
|
+
}
|
|
425
|
+
const extractors = getMerged("extractors");
|
|
426
|
+
let extractorDefault = sourcesReversed.find((i) => i.extractorDefault !== void 0)?.extractorDefault;
|
|
425
427
|
if (extractorDefault === void 0)
|
|
426
428
|
extractorDefault = extractorSplit;
|
|
427
429
|
if (extractorDefault && !extractors.includes(extractorDefault))
|
|
428
430
|
extractors.unshift(extractorDefault);
|
|
429
431
|
extractors.sort((a, b) => (a.order || 0) - (b.order || 0));
|
|
430
|
-
const rules =
|
|
432
|
+
const rules = getMerged("rules");
|
|
431
433
|
const rulesStaticMap = {};
|
|
432
434
|
const rulesSize = rules.length;
|
|
433
435
|
const rulesDynamic = rules.map((rule, i) => {
|
|
@@ -440,18 +442,15 @@ function resolveConfig(userConfig = {}, defaults = {}) {
|
|
|
440
442
|
}
|
|
441
443
|
return [i, ...rule];
|
|
442
444
|
}).filter(Boolean).reverse();
|
|
443
|
-
let theme = clone(
|
|
444
|
-
|
|
445
|
-
config.theme || {}
|
|
446
|
-
].reduce((a, p) => mergeDeep(a, p), {}));
|
|
447
|
-
const extendThemes = toArray(mergePresets("extendTheme"));
|
|
445
|
+
let theme = sources.map((p) => p.theme ? clone(p.theme) : {}).reduce((a, p) => mergeDeep(a, p), {});
|
|
446
|
+
const extendThemes = getMerged("extendTheme");
|
|
448
447
|
for (const extendTheme of extendThemes)
|
|
449
448
|
theme = extendTheme(theme) || theme;
|
|
450
449
|
const autocomplete = {
|
|
451
|
-
templates: uniq(
|
|
452
|
-
extractors:
|
|
450
|
+
templates: uniq(sources.flatMap((p) => toArray(p.autocomplete?.templates))),
|
|
451
|
+
extractors: sources.flatMap((p) => toArray(p.autocomplete?.extractors)).sort((a, b) => (a.order || 0) - (b.order || 0))
|
|
453
452
|
};
|
|
454
|
-
let separators =
|
|
453
|
+
let separators = getMerged("separators");
|
|
455
454
|
if (!separators.length)
|
|
456
455
|
separators = [":", "-"];
|
|
457
456
|
const resolved = {
|
|
@@ -468,23 +467,22 @@ function resolveConfig(userConfig = {}, defaults = {}) {
|
|
|
468
467
|
rulesSize,
|
|
469
468
|
rulesDynamic,
|
|
470
469
|
rulesStaticMap,
|
|
471
|
-
preprocess:
|
|
472
|
-
postprocess:
|
|
473
|
-
preflights:
|
|
470
|
+
preprocess: getMerged("preprocess"),
|
|
471
|
+
postprocess: getMerged("postprocess"),
|
|
472
|
+
preflights: getMerged("preflights"),
|
|
474
473
|
autocomplete,
|
|
475
|
-
variants:
|
|
476
|
-
shortcuts: resolveShortcuts(
|
|
474
|
+
variants: getMerged("variants").map(normalizeVariant).sort((a, b) => (a.order || 0) - (b.order || 0)),
|
|
475
|
+
shortcuts: resolveShortcuts(getMerged("shortcuts")).reverse(),
|
|
477
476
|
extractors,
|
|
478
|
-
safelist:
|
|
477
|
+
safelist: getMerged("safelist"),
|
|
479
478
|
separators
|
|
480
479
|
};
|
|
481
|
-
for (const p of
|
|
480
|
+
for (const p of sources)
|
|
482
481
|
p?.configResolved?.(resolved);
|
|
483
|
-
userConfig?.configResolved?.(resolved);
|
|
484
482
|
return resolved;
|
|
485
483
|
}
|
|
486
484
|
|
|
487
|
-
const version = "0.51.
|
|
485
|
+
const version = "0.51.4";
|
|
488
486
|
|
|
489
487
|
class UnoGenerator {
|
|
490
488
|
constructor(userConfig = {}, defaults = {}) {
|
package/dist/index.d.ts
CHANGED
|
@@ -158,6 +158,7 @@ declare function createValueHandler<K extends string>(handlers: Record<K, ValueH
|
|
|
158
158
|
|
|
159
159
|
type Awaitable<T> = T | Promise<T>;
|
|
160
160
|
type Arrayable<T> = T | T[];
|
|
161
|
+
type ToArray<T> = T extends (infer U)[] ? U[] : T[];
|
|
161
162
|
type ArgumentType<T> = T extends ((...args: infer A) => any) ? A : never;
|
|
162
163
|
type Shift<T> = T extends [_: any, ...args: infer A] ? A : never;
|
|
163
164
|
type RestArgs<T> = Shift<ArgumentType<T>>;
|
|
@@ -863,4 +864,4 @@ declare const defaultSplitRE: RegExp;
|
|
|
863
864
|
declare const splitWithVariantGroupRE: RegExp;
|
|
864
865
|
declare const extractorSplit: Extractor;
|
|
865
866
|
|
|
866
|
-
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, attributifyRE, clearIdenticalEntries, clone, collapseVariantGroup, createGenerator, createValueHandler, cssIdRE, defaultSplitRE, e, entriesToCss, escapeRegExp, escapeSelector, expandVariantGroup, extractorSplit as extractorDefault, extractorSplit, hasScopePlaceholder, isAttributifySelector, isObject, isRawUtil, isStaticRule, isStaticShortcut, isString, isValidSelector, makeRegexClassGroup, mergeDeep, noop, normalizeCSSEntries, normalizeCSSValues, normalizeVariant, notNull, parseVariantGroup, regexScopePlaceholder, splitWithVariantGroupRE, toArray, toEscapedSelector, uniq, validateFilterRE, warnOnce, withLayer };
|
|
867
|
+
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, ToArray, TransformResult, TwoKeyMap, UnoGenerator, UnocssPluginContext, UserConfig, UserConfigDefaults, UserOnlyOptions, UserShortcuts, UtilObject, ValueHandler, ValueHandlerCallback, Variant, VariantContext, VariantFunction, VariantHandler, VariantHandlerContext, VariantMatchedResult, VariantObject, attributifyRE, clearIdenticalEntries, clone, collapseVariantGroup, createGenerator, createValueHandler, cssIdRE, defaultSplitRE, e, entriesToCss, escapeRegExp, escapeSelector, expandVariantGroup, extractorSplit as extractorDefault, extractorSplit, hasScopePlaceholder, isAttributifySelector, isObject, isRawUtil, isStaticRule, isStaticShortcut, isString, isValidSelector, makeRegexClassGroup, mergeDeep, noop, normalizeCSSEntries, normalizeCSSValues, normalizeVariant, notNull, parseVariantGroup, regexScopePlaceholder, splitWithVariantGroupRE, toArray, toEscapedSelector, uniq, validateFilterRE, warnOnce, withLayer };
|
package/dist/index.mjs
CHANGED
|
@@ -409,21 +409,23 @@ function resolveConfig(userConfig = {}, defaults = {}) {
|
|
|
409
409
|
...rawPresets.filter((p) => !p.enforce),
|
|
410
410
|
...rawPresets.filter((p) => p.enforce === "post")
|
|
411
411
|
];
|
|
412
|
-
const
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
412
|
+
const sources = [
|
|
413
|
+
...sortedPresets,
|
|
414
|
+
config
|
|
415
|
+
];
|
|
416
|
+
const sourcesReversed = [...sources].reverse();
|
|
417
|
+
const layers = Object.assign({}, DEFAULT_LAYERS, ...sources.map((i) => i.layers));
|
|
418
|
+
function getMerged(key) {
|
|
419
|
+
return uniq(sources.flatMap((p) => toArray(p[key] || [])));
|
|
420
|
+
}
|
|
421
|
+
const extractors = getMerged("extractors");
|
|
422
|
+
let extractorDefault = sourcesReversed.find((i) => i.extractorDefault !== void 0)?.extractorDefault;
|
|
421
423
|
if (extractorDefault === void 0)
|
|
422
424
|
extractorDefault = extractorSplit;
|
|
423
425
|
if (extractorDefault && !extractors.includes(extractorDefault))
|
|
424
426
|
extractors.unshift(extractorDefault);
|
|
425
427
|
extractors.sort((a, b) => (a.order || 0) - (b.order || 0));
|
|
426
|
-
const rules =
|
|
428
|
+
const rules = getMerged("rules");
|
|
427
429
|
const rulesStaticMap = {};
|
|
428
430
|
const rulesSize = rules.length;
|
|
429
431
|
const rulesDynamic = rules.map((rule, i) => {
|
|
@@ -436,18 +438,15 @@ function resolveConfig(userConfig = {}, defaults = {}) {
|
|
|
436
438
|
}
|
|
437
439
|
return [i, ...rule];
|
|
438
440
|
}).filter(Boolean).reverse();
|
|
439
|
-
let theme = clone(
|
|
440
|
-
|
|
441
|
-
config.theme || {}
|
|
442
|
-
].reduce((a, p) => mergeDeep(a, p), {}));
|
|
443
|
-
const extendThemes = toArray(mergePresets("extendTheme"));
|
|
441
|
+
let theme = sources.map((p) => p.theme ? clone(p.theme) : {}).reduce((a, p) => mergeDeep(a, p), {});
|
|
442
|
+
const extendThemes = getMerged("extendTheme");
|
|
444
443
|
for (const extendTheme of extendThemes)
|
|
445
444
|
theme = extendTheme(theme) || theme;
|
|
446
445
|
const autocomplete = {
|
|
447
|
-
templates: uniq(
|
|
448
|
-
extractors:
|
|
446
|
+
templates: uniq(sources.flatMap((p) => toArray(p.autocomplete?.templates))),
|
|
447
|
+
extractors: sources.flatMap((p) => toArray(p.autocomplete?.extractors)).sort((a, b) => (a.order || 0) - (b.order || 0))
|
|
449
448
|
};
|
|
450
|
-
let separators =
|
|
449
|
+
let separators = getMerged("separators");
|
|
451
450
|
if (!separators.length)
|
|
452
451
|
separators = [":", "-"];
|
|
453
452
|
const resolved = {
|
|
@@ -464,23 +463,22 @@ function resolveConfig(userConfig = {}, defaults = {}) {
|
|
|
464
463
|
rulesSize,
|
|
465
464
|
rulesDynamic,
|
|
466
465
|
rulesStaticMap,
|
|
467
|
-
preprocess:
|
|
468
|
-
postprocess:
|
|
469
|
-
preflights:
|
|
466
|
+
preprocess: getMerged("preprocess"),
|
|
467
|
+
postprocess: getMerged("postprocess"),
|
|
468
|
+
preflights: getMerged("preflights"),
|
|
470
469
|
autocomplete,
|
|
471
|
-
variants:
|
|
472
|
-
shortcuts: resolveShortcuts(
|
|
470
|
+
variants: getMerged("variants").map(normalizeVariant).sort((a, b) => (a.order || 0) - (b.order || 0)),
|
|
471
|
+
shortcuts: resolveShortcuts(getMerged("shortcuts")).reverse(),
|
|
473
472
|
extractors,
|
|
474
|
-
safelist:
|
|
473
|
+
safelist: getMerged("safelist"),
|
|
475
474
|
separators
|
|
476
475
|
};
|
|
477
|
-
for (const p of
|
|
476
|
+
for (const p of sources)
|
|
478
477
|
p?.configResolved?.(resolved);
|
|
479
|
-
userConfig?.configResolved?.(resolved);
|
|
480
478
|
return resolved;
|
|
481
479
|
}
|
|
482
480
|
|
|
483
|
-
const version = "0.51.
|
|
481
|
+
const version = "0.51.4";
|
|
484
482
|
|
|
485
483
|
class UnoGenerator {
|
|
486
484
|
constructor(userConfig = {}, defaults = {}) {
|