@unocss/core 66.1.0-beta.7 → 66.1.0-beta.9

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.d.mts CHANGED
@@ -265,6 +265,7 @@ interface RuleContext<Theme extends object = object> {
265
265
  variants?: Variant<Theme>[];
266
266
  }
267
267
  declare const SymbolShortcutsNoMerge: unique symbol;
268
+ declare const SymbolNoMerge: unique symbol;
268
269
  declare const SymbolVariants: unique symbol;
269
270
  declare const SymbolParent: unique symbol;
270
271
  declare const SymbolSelector: unique symbol;
@@ -275,6 +276,10 @@ interface ControlSymbols {
275
276
  * Prevent merging in shortcuts
276
277
  */
277
278
  shortcutsNoMerge: typeof SymbolShortcutsNoMerge;
279
+ /**
280
+ * Prevent merging in rules
281
+ */
282
+ noMerge: typeof SymbolNoMerge;
278
283
  /**
279
284
  * Additional variants applied to this rule
280
285
  */
@@ -298,7 +303,8 @@ interface ControlSymbols {
298
303
  }
299
304
  interface ControlSymbolsValue {
300
305
  [SymbolShortcutsNoMerge]: true;
301
- [SymbolVariants]: VariantHandler[];
306
+ [SymbolNoMerge]: true;
307
+ [SymbolVariants]: VariantHandler[] | ((handlers: VariantHandler[]) => VariantHandler[]);
302
308
  [SymbolParent]: string;
303
309
  [SymbolSelector]: (selector: string) => string;
304
310
  [SymbolLayer]: string;
@@ -1116,4 +1122,4 @@ declare const defaultSplitRE: RegExp;
1116
1122
  declare const splitWithVariantGroupRE: RegExp;
1117
1123
  declare const extractorSplit: Extractor;
1118
1124
 
1119
- export { type ArgumentType, type Arrayable, type AutoCompleteExtractor, type AutoCompleteExtractorContext, type AutoCompleteExtractorResult, type AutoCompleteFunction, type AutoCompleteTemplate, type Awaitable, BetterMap, type BlocklistMeta, type BlocklistRule, type BlocklistValue, type CSSEntries, type CSSEntriesInput, type CSSEntry, type CSSObject, type CSSObjectInput, type CSSValue, type CSSValueInput, type CSSValues, type CliEntryItem, type CliOptions, type ConfigBase, type ContentOptions, type ControlSymbols, type ControlSymbolsEntry, type ControlSymbolsValue, CountableSet, DEFAULT_LAYERS, type DeepPartial, type DynamicMatcher, type DynamicRule, type DynamicShortcut, type DynamicShortcutMatcher, Emitter, type ExtendedTokenInfo, type Extractor, type ExtractorContext, type FilterPattern, type FlatObjectTuple, type GenerateOptions, type GenerateResult, type GeneratorOptions, type HighlightAnnotation, LAYER_DEFAULT, LAYER_IMPORTS, LAYER_PREFLIGHTS, LAYER_SHORTCUTS, type ObjectToEntry, type OutputCssLayersOptions, type ParsedUtil, type PartialByKeys, type PluginOptions, type Postprocessor, type Preflight, type PreflightContext, type PreparedRule, type Preprocessor, type Preset, type PresetFactory, type PresetFactoryAwaitable, type PresetOptions, type PresetOrFactory, type PresetOrFactoryAwaitable, type RawUtil, type Replacement, type RequiredByKey, type ResolvedConfig, type RestArgs, type Rule, type RuleContext, type RuleMeta, type SafeListContext, type Shift, type Shortcut, type ShortcutInlineValue, type ShortcutValue, type SourceCodeTransformer, type SourceCodeTransformerEnforce, type SourceMap, type StaticRule, type StaticShortcut, type StaticShortcutMap, type StringifiedUtil, type SuggestResult, type ThemeExtender, type ToArray, TwoKeyMap, UnoGenerator, type UnocssPluginContext, type Unsubscribe, type UserConfig, type UserConfigDefaults, type UserOnlyOptions, type UserShortcuts, type UtilObject, type Variant, type VariantContext, type VariantFunction, type VariantHandler, type VariantHandlerContext, type VariantMatchedResult, type VariantObject, attributifyRE, clearIdenticalEntries, clone, collapseVariantGroup, createGenerator, createNanoEvents, cssIdRE, defaultSplitRE, definePreset, e, entriesToCss, escapeRegExp, escapeSelector, expandVariantGroup, extractorSplit as extractorDefault, extractorSplit, hasScopePlaceholder, isAttributifySelector, isCountableSet, isObject, isRawUtil, isStaticRule, isStaticShortcut, isString, isValidSelector, makeRegexClassGroup, mergeConfigs, mergeDeep, noop, normalizeCSSEntries, normalizeCSSValues, normalizeVariant, notNull, parseVariantGroup, regexScopePlaceholder, resolveConfig, resolvePreset, resolvePresets, resolveShortcuts, splitWithVariantGroupRE, symbols, toArray, toEscapedSelector, uniq, uniqueBy, validateFilterRE, warnOnce, withLayer };
1125
+ export { type ArgumentType, type Arrayable, type AutoCompleteExtractor, type AutoCompleteExtractorContext, type AutoCompleteExtractorResult, type AutoCompleteFunction, type AutoCompleteTemplate, type Awaitable, type BaseContext, BetterMap, type BlocklistMeta, type BlocklistRule, type BlocklistValue, type CSSEntries, type CSSEntriesInput, type CSSEntry, type CSSObject, type CSSObjectInput, type CSSValue, type CSSValueInput, type CSSValues, type CliEntryItem, type CliOptions, type ConfigBase, type ContentOptions, type ControlSymbols, type ControlSymbolsEntry, type ControlSymbolsValue, CountableSet, DEFAULT_LAYERS, type DeepPartial, type DynamicMatcher, type DynamicRule, type DynamicShortcut, type DynamicShortcutMatcher, Emitter, type ExtendedTokenInfo, type Extractor, type ExtractorContext, type FilterPattern, type FlatObjectTuple, type GenerateOptions, type GenerateResult, type GeneratorOptions, type HighlightAnnotation, LAYER_DEFAULT, LAYER_IMPORTS, LAYER_PREFLIGHTS, LAYER_SHORTCUTS, type ObjectToEntry, type OutputCssLayersOptions, type ParsedUtil, type PartialByKeys, type PluginOptions, type Postprocessor, type Preflight, type PreflightContext, type PreparedRule, type Preprocessor, type Preset, type PresetFactory, type PresetFactoryAwaitable, type PresetOptions, type PresetOrFactory, type PresetOrFactoryAwaitable, type RawUtil, type Replacement, type RequiredByKey, type ResolvedConfig, type RestArgs, type Rule, type RuleContext, type RuleMeta, type SafeListContext, type Shift, type Shortcut, type ShortcutInlineValue, type ShortcutValue, type SourceCodeTransformer, type SourceCodeTransformerEnforce, type SourceMap, type StaticRule, type StaticShortcut, type StaticShortcutMap, type StringifiedUtil, type SuggestResult, type ThemeExtender, type ToArray, TwoKeyMap, UnoGenerator, type UnocssPluginContext, type Unsubscribe, type UserConfig, type UserConfigDefaults, type UserOnlyOptions, type UserShortcuts, type UtilObject, type Variant, type VariantContext, type VariantFunction, type VariantHandler, type VariantHandlerContext, type VariantMatchedResult, type VariantObject, attributifyRE, clearIdenticalEntries, clone, collapseVariantGroup, createGenerator, createNanoEvents, cssIdRE, defaultSplitRE, definePreset, e, entriesToCss, escapeRegExp, escapeSelector, expandVariantGroup, extractorSplit as extractorDefault, extractorSplit, hasScopePlaceholder, isAttributifySelector, isCountableSet, isObject, isRawUtil, isStaticRule, isStaticShortcut, isString, isValidSelector, makeRegexClassGroup, mergeConfigs, mergeDeep, noop, normalizeCSSEntries, normalizeCSSValues, normalizeVariant, notNull, parseVariantGroup, regexScopePlaceholder, resolveConfig, resolvePreset, resolvePresets, resolveShortcuts, splitWithVariantGroupRE, symbols, toArray, toEscapedSelector, uniq, uniqueBy, validateFilterRE, warnOnce, withLayer };
package/dist/index.d.ts CHANGED
@@ -265,6 +265,7 @@ interface RuleContext<Theme extends object = object> {
265
265
  variants?: Variant<Theme>[];
266
266
  }
267
267
  declare const SymbolShortcutsNoMerge: unique symbol;
268
+ declare const SymbolNoMerge: unique symbol;
268
269
  declare const SymbolVariants: unique symbol;
269
270
  declare const SymbolParent: unique symbol;
270
271
  declare const SymbolSelector: unique symbol;
@@ -275,6 +276,10 @@ interface ControlSymbols {
275
276
  * Prevent merging in shortcuts
276
277
  */
277
278
  shortcutsNoMerge: typeof SymbolShortcutsNoMerge;
279
+ /**
280
+ * Prevent merging in rules
281
+ */
282
+ noMerge: typeof SymbolNoMerge;
278
283
  /**
279
284
  * Additional variants applied to this rule
280
285
  */
@@ -298,7 +303,8 @@ interface ControlSymbols {
298
303
  }
299
304
  interface ControlSymbolsValue {
300
305
  [SymbolShortcutsNoMerge]: true;
301
- [SymbolVariants]: VariantHandler[];
306
+ [SymbolNoMerge]: true;
307
+ [SymbolVariants]: VariantHandler[] | ((handlers: VariantHandler[]) => VariantHandler[]);
302
308
  [SymbolParent]: string;
303
309
  [SymbolSelector]: (selector: string) => string;
304
310
  [SymbolLayer]: string;
@@ -1116,4 +1122,4 @@ declare const defaultSplitRE: RegExp;
1116
1122
  declare const splitWithVariantGroupRE: RegExp;
1117
1123
  declare const extractorSplit: Extractor;
1118
1124
 
1119
- export { type ArgumentType, type Arrayable, type AutoCompleteExtractor, type AutoCompleteExtractorContext, type AutoCompleteExtractorResult, type AutoCompleteFunction, type AutoCompleteTemplate, type Awaitable, BetterMap, type BlocklistMeta, type BlocklistRule, type BlocklistValue, type CSSEntries, type CSSEntriesInput, type CSSEntry, type CSSObject, type CSSObjectInput, type CSSValue, type CSSValueInput, type CSSValues, type CliEntryItem, type CliOptions, type ConfigBase, type ContentOptions, type ControlSymbols, type ControlSymbolsEntry, type ControlSymbolsValue, CountableSet, DEFAULT_LAYERS, type DeepPartial, type DynamicMatcher, type DynamicRule, type DynamicShortcut, type DynamicShortcutMatcher, Emitter, type ExtendedTokenInfo, type Extractor, type ExtractorContext, type FilterPattern, type FlatObjectTuple, type GenerateOptions, type GenerateResult, type GeneratorOptions, type HighlightAnnotation, LAYER_DEFAULT, LAYER_IMPORTS, LAYER_PREFLIGHTS, LAYER_SHORTCUTS, type ObjectToEntry, type OutputCssLayersOptions, type ParsedUtil, type PartialByKeys, type PluginOptions, type Postprocessor, type Preflight, type PreflightContext, type PreparedRule, type Preprocessor, type Preset, type PresetFactory, type PresetFactoryAwaitable, type PresetOptions, type PresetOrFactory, type PresetOrFactoryAwaitable, type RawUtil, type Replacement, type RequiredByKey, type ResolvedConfig, type RestArgs, type Rule, type RuleContext, type RuleMeta, type SafeListContext, type Shift, type Shortcut, type ShortcutInlineValue, type ShortcutValue, type SourceCodeTransformer, type SourceCodeTransformerEnforce, type SourceMap, type StaticRule, type StaticShortcut, type StaticShortcutMap, type StringifiedUtil, type SuggestResult, type ThemeExtender, type ToArray, TwoKeyMap, UnoGenerator, type UnocssPluginContext, type Unsubscribe, type UserConfig, type UserConfigDefaults, type UserOnlyOptions, type UserShortcuts, type UtilObject, type Variant, type VariantContext, type VariantFunction, type VariantHandler, type VariantHandlerContext, type VariantMatchedResult, type VariantObject, attributifyRE, clearIdenticalEntries, clone, collapseVariantGroup, createGenerator, createNanoEvents, cssIdRE, defaultSplitRE, definePreset, e, entriesToCss, escapeRegExp, escapeSelector, expandVariantGroup, extractorSplit as extractorDefault, extractorSplit, hasScopePlaceholder, isAttributifySelector, isCountableSet, isObject, isRawUtil, isStaticRule, isStaticShortcut, isString, isValidSelector, makeRegexClassGroup, mergeConfigs, mergeDeep, noop, normalizeCSSEntries, normalizeCSSValues, normalizeVariant, notNull, parseVariantGroup, regexScopePlaceholder, resolveConfig, resolvePreset, resolvePresets, resolveShortcuts, splitWithVariantGroupRE, symbols, toArray, toEscapedSelector, uniq, uniqueBy, validateFilterRE, warnOnce, withLayer };
1125
+ export { type ArgumentType, type Arrayable, type AutoCompleteExtractor, type AutoCompleteExtractorContext, type AutoCompleteExtractorResult, type AutoCompleteFunction, type AutoCompleteTemplate, type Awaitable, type BaseContext, BetterMap, type BlocklistMeta, type BlocklistRule, type BlocklistValue, type CSSEntries, type CSSEntriesInput, type CSSEntry, type CSSObject, type CSSObjectInput, type CSSValue, type CSSValueInput, type CSSValues, type CliEntryItem, type CliOptions, type ConfigBase, type ContentOptions, type ControlSymbols, type ControlSymbolsEntry, type ControlSymbolsValue, CountableSet, DEFAULT_LAYERS, type DeepPartial, type DynamicMatcher, type DynamicRule, type DynamicShortcut, type DynamicShortcutMatcher, Emitter, type ExtendedTokenInfo, type Extractor, type ExtractorContext, type FilterPattern, type FlatObjectTuple, type GenerateOptions, type GenerateResult, type GeneratorOptions, type HighlightAnnotation, LAYER_DEFAULT, LAYER_IMPORTS, LAYER_PREFLIGHTS, LAYER_SHORTCUTS, type ObjectToEntry, type OutputCssLayersOptions, type ParsedUtil, type PartialByKeys, type PluginOptions, type Postprocessor, type Preflight, type PreflightContext, type PreparedRule, type Preprocessor, type Preset, type PresetFactory, type PresetFactoryAwaitable, type PresetOptions, type PresetOrFactory, type PresetOrFactoryAwaitable, type RawUtil, type Replacement, type RequiredByKey, type ResolvedConfig, type RestArgs, type Rule, type RuleContext, type RuleMeta, type SafeListContext, type Shift, type Shortcut, type ShortcutInlineValue, type ShortcutValue, type SourceCodeTransformer, type SourceCodeTransformerEnforce, type SourceMap, type StaticRule, type StaticShortcut, type StaticShortcutMap, type StringifiedUtil, type SuggestResult, type ThemeExtender, type ToArray, TwoKeyMap, UnoGenerator, type UnocssPluginContext, type Unsubscribe, type UserConfig, type UserConfigDefaults, type UserOnlyOptions, type UserShortcuts, type UtilObject, type Variant, type VariantContext, type VariantFunction, type VariantHandler, type VariantHandlerContext, type VariantMatchedResult, type VariantObject, attributifyRE, clearIdenticalEntries, clone, collapseVariantGroup, createGenerator, createNanoEvents, cssIdRE, defaultSplitRE, definePreset, e, entriesToCss, escapeRegExp, escapeSelector, expandVariantGroup, extractorSplit as extractorDefault, extractorSplit, hasScopePlaceholder, isAttributifySelector, isCountableSet, isObject, isRawUtil, isStaticRule, isStaticShortcut, isString, isValidSelector, makeRegexClassGroup, mergeConfigs, mergeDeep, noop, normalizeCSSEntries, normalizeCSSValues, normalizeVariant, notNull, parseVariantGroup, regexScopePlaceholder, resolveConfig, resolvePreset, resolvePresets, resolveShortcuts, splitWithVariantGroupRE, symbols, toArray, toEscapedSelector, uniq, uniqueBy, validateFilterRE, warnOnce, withLayer };
package/dist/index.mjs CHANGED
@@ -657,10 +657,11 @@ function definePreset(preset) {
657
657
  return preset;
658
658
  }
659
659
 
660
- const version = "66.1.0-beta.7";
660
+ const version = "66.1.0-beta.9";
661
661
 
662
662
  const symbols = {
663
663
  shortcutsNoMerge: "$$symbol-shortcut-no-merge",
664
+ noMerge: "$$symbol-no-merge",
664
665
  variants: "$$symbol-variants",
665
666
  parent: "$$symbol-parent",
666
667
  selector: "$$symbol-selector",
@@ -788,8 +789,9 @@ class UnoGeneratorInternal {
788
789
  theme: this.config.theme
789
790
  };
790
791
  this.config.safelist.flatMap((s) => typeof s === "function" ? s(safelistContext) : s).forEach((s) => {
791
- if (!tokens.has(s))
792
- tokens.add(s);
792
+ const trimedS = s.trim();
793
+ if (trimedS && !tokens.has(trimedS))
794
+ tokens.add(trimedS);
793
795
  });
794
796
  }
795
797
  const nl = minify ? "" : "\n";
@@ -873,7 +875,7 @@ class UnoGeneratorInternal {
873
875
  });
874
876
  if (!sorted.length)
875
877
  return void 0;
876
- const rules = sorted.reverse().map(([selectorSortPair, body, noMerge], idx) => {
878
+ const ruleLines = sorted.reverse().map(([selectorSortPair, body, noMerge], idx) => {
877
879
  if (!noMerge && this.config.mergeSelectors) {
878
880
  for (let i = idx + 1; i < size; i++) {
879
881
  const current = sorted[i];
@@ -886,7 +888,8 @@ class UnoGeneratorInternal {
886
888
  }
887
889
  const selectors = selectorSortPair ? uniq(selectorSortPair.sort((a, b) => a[1] - b[1] || a[0]?.localeCompare(b[0] || "") || 0).map((pair) => pair[0]).filter(Boolean)) : [];
888
890
  return selectors.length ? `${selectors.join(`,${nl}`)}{${body}}` : body;
889
- }).filter(Boolean).reverse().join(nl);
891
+ }).filter(Boolean);
892
+ const rules = Array.from(new Set(ruleLines)).reverse().join(nl);
890
893
  if (!parent)
891
894
  return rules;
892
895
  const parents = parent.split(" $$ ");
@@ -994,10 +997,11 @@ class UnoGeneratorInternal {
994
997
  (previous, v) => (input) => {
995
998
  const entries = v.body?.(input.entries) || input.entries;
996
999
  const parents = Array.isArray(v.parent) ? v.parent : [v.parent, void 0];
1000
+ const selector = v.selector?.(input.selector, entries);
997
1001
  return (v.handle ?? defaultVariantHandler)({
998
1002
  ...input,
999
1003
  entries,
1000
- selector: v.selector?.(input.selector, entries) || input.selector,
1004
+ selector: selector || input.selector,
1001
1005
  parent: parents[0] || input.parent,
1002
1006
  parentOrder: parents[1] || input.parentOrder,
1003
1007
  layer: v.layer || input.layer,
@@ -1115,10 +1119,14 @@ class UnoGeneratorInternal {
1115
1119
  let entryMeta = meta;
1116
1120
  for (const entry of css) {
1117
1121
  if (entry[0] === symbols.variants) {
1118
- variants = [
1119
- ...toArray(entry[1]),
1120
- ...variants
1121
- ];
1122
+ if (typeof entry[1] === "function") {
1123
+ variants = entry[1](variants) || variants;
1124
+ } else {
1125
+ variants = [
1126
+ ...toArray(entry[1]),
1127
+ ...variants
1128
+ ];
1129
+ }
1122
1130
  } else if (entry[0] === symbols.parent) {
1123
1131
  variants = [
1124
1132
  { parent: entry[1] },
@@ -1139,6 +1147,11 @@ class UnoGeneratorInternal {
1139
1147
  ...entryMeta,
1140
1148
  sort: entry[1]
1141
1149
  };
1150
+ } else if (entry[0] === symbols.noMerge) {
1151
+ entryMeta = {
1152
+ ...entryMeta,
1153
+ noMerge: entry[1]
1154
+ };
1142
1155
  }
1143
1156
  }
1144
1157
  return [index, raw, css, entryMeta, variants];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@unocss/core",
3
3
  "type": "module",
4
- "version": "66.1.0-beta.7",
4
+ "version": "66.1.0-beta.9",
5
5
  "description": "The instant on-demand Atomic CSS engine.",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",