@unocss/core 66.4.1 → 66.5.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.d.mts CHANGED
@@ -125,6 +125,7 @@ declare class BetterMap<K, V> extends Map<K, V> {
125
125
  declare function normalizeCSSEntries(obj: string | CSSEntriesInput | CSSObjectInput): string | CSSEntries;
126
126
  declare function normalizeCSSValues(obj: CSSValueInput | string | (CSSValueInput | string)[]): (string | CSSEntries)[];
127
127
  declare function clearIdenticalEntries(entry: CSSEntries): CSSEntries;
128
+ declare const VirtualKey = "__virtual_key__";
128
129
  declare function entriesToCss(arr?: CSSEntries): string;
129
130
  declare function isObject(item: any): item is Record<string, any>;
130
131
  /**
@@ -277,6 +278,7 @@ declare const SymbolParent: unique symbol;
277
278
  declare const SymbolSelector: unique symbol;
278
279
  declare const SymbolLayer: unique symbol;
279
280
  declare const SymbolSort: unique symbol;
281
+ declare const SymbolBody: unique symbol;
280
282
  interface ControlSymbols {
281
283
  /**
282
284
  * Prevent merging in shortcuts
@@ -306,6 +308,10 @@ interface ControlSymbols {
306
308
  * Sort modifier
307
309
  */
308
310
  sort: typeof SymbolSort;
311
+ /**
312
+ * Custom css body modifier
313
+ */
314
+ body: typeof SymbolBody;
309
315
  }
310
316
  interface ControlSymbolsValue {
311
317
  [SymbolShortcutsNoMerge]: true;
@@ -315,6 +321,7 @@ interface ControlSymbolsValue {
315
321
  [SymbolSelector]: (selector: string) => string;
316
322
  [SymbolLayer]: string;
317
323
  [SymbolSort]: number;
324
+ [SymbolBody]: string;
318
325
  }
319
326
  type ObjectToEntry<T> = {
320
327
  [K in keyof T]: [K, T[K]];
@@ -400,6 +407,12 @@ interface RuleMeta {
400
407
  * @private
401
408
  */
402
409
  __hash?: string;
410
+ /**
411
+ * Internal index of the rulelist
412
+ * @internal
413
+ * @private
414
+ */
415
+ __index?: number;
403
416
  /**
404
417
  * Custom metadata
405
418
  */
@@ -1106,5 +1119,5 @@ declare const defaultSplitRE: RegExp;
1106
1119
  declare const splitWithVariantGroupRE: RegExp;
1107
1120
  declare const extractorSplit: Extractor;
1108
1121
 
1109
- export { BetterMap, CountableSet, DEFAULT_LAYERS, Emitter, LAYER_DEFAULT, LAYER_IMPORTS, LAYER_PREFLIGHTS, LAYER_SHORTCUTS, TwoKeyMap, UnoGenerator, 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 };
1122
+ export { BetterMap, CountableSet, DEFAULT_LAYERS, Emitter, LAYER_DEFAULT, LAYER_IMPORTS, LAYER_PREFLIGHTS, LAYER_SHORTCUTS, TwoKeyMap, UnoGenerator, VirtualKey, 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 };
1110
1123
  export type { ArgumentType, Arrayable, AutoCompleteExtractor, AutoCompleteExtractorContext, AutoCompleteExtractorResult, AutoCompleteFunction, AutoCompleteTemplate, Awaitable, BaseContext, BlocklistMeta, BlocklistRule, BlocklistValue, CSSEntries, CSSEntriesInput, CSSEntry, CSSObject, CSSObjectInput, CSSValue, CSSValueInput, CSSValues, CliEntryItem, CliOptions, ConfigBase, ContentOptions, ControlSymbols, ControlSymbolsEntry, ControlSymbolsValue, DeepPartial, DynamicMatcher, DynamicRule, DynamicShortcut, DynamicShortcutMatcher, ExtendedTokenInfo, Extractor, ExtractorContext, FilterPattern, FlatObjectTuple, GenerateOptions, GenerateResult, GeneratorOptions, HighlightAnnotation, ObjectToEntry, OutputCssLayersOptions, ParsedUtil, PartialByKeys, PluginOptions, Postprocessor, Preflight, PreflightContext, PreparedRule, Preprocessor, Preset, PresetFactory, PresetFactoryAwaitable, PresetOptions, PresetOrFactory, PresetOrFactoryAwaitable, RawUtil, Replacement, RequiredByKey, ResolvedConfig, RestArgs, Rule, RuleContext, RuleMeta, SafeListContext, Shift, Shortcut, ShortcutInlineValue, ShortcutValue, SourceCodeTransformer, SourceCodeTransformerEnforce, SourceMap, StaticRule, StaticShortcut, StaticShortcutMap, StringifiedUtil, SuggestResult, ThemeExtender, ToArray, UnocssPluginContext, Unsubscribe, UserConfig, UserConfigDefaults, UserOnlyOptions, UserShortcuts, UtilObject, Variant, VariantContext, VariantFunction, VariantHandler, VariantHandlerContext, VariantMatchedResult, VariantObject };
package/dist/index.d.ts CHANGED
@@ -125,6 +125,7 @@ declare class BetterMap<K, V> extends Map<K, V> {
125
125
  declare function normalizeCSSEntries(obj: string | CSSEntriesInput | CSSObjectInput): string | CSSEntries;
126
126
  declare function normalizeCSSValues(obj: CSSValueInput | string | (CSSValueInput | string)[]): (string | CSSEntries)[];
127
127
  declare function clearIdenticalEntries(entry: CSSEntries): CSSEntries;
128
+ declare const VirtualKey = "__virtual_key__";
128
129
  declare function entriesToCss(arr?: CSSEntries): string;
129
130
  declare function isObject(item: any): item is Record<string, any>;
130
131
  /**
@@ -277,6 +278,7 @@ declare const SymbolParent: unique symbol;
277
278
  declare const SymbolSelector: unique symbol;
278
279
  declare const SymbolLayer: unique symbol;
279
280
  declare const SymbolSort: unique symbol;
281
+ declare const SymbolBody: unique symbol;
280
282
  interface ControlSymbols {
281
283
  /**
282
284
  * Prevent merging in shortcuts
@@ -306,6 +308,10 @@ interface ControlSymbols {
306
308
  * Sort modifier
307
309
  */
308
310
  sort: typeof SymbolSort;
311
+ /**
312
+ * Custom css body modifier
313
+ */
314
+ body: typeof SymbolBody;
309
315
  }
310
316
  interface ControlSymbolsValue {
311
317
  [SymbolShortcutsNoMerge]: true;
@@ -315,6 +321,7 @@ interface ControlSymbolsValue {
315
321
  [SymbolSelector]: (selector: string) => string;
316
322
  [SymbolLayer]: string;
317
323
  [SymbolSort]: number;
324
+ [SymbolBody]: string;
318
325
  }
319
326
  type ObjectToEntry<T> = {
320
327
  [K in keyof T]: [K, T[K]];
@@ -400,6 +407,12 @@ interface RuleMeta {
400
407
  * @private
401
408
  */
402
409
  __hash?: string;
410
+ /**
411
+ * Internal index of the rulelist
412
+ * @internal
413
+ * @private
414
+ */
415
+ __index?: number;
403
416
  /**
404
417
  * Custom metadata
405
418
  */
@@ -1106,5 +1119,5 @@ declare const defaultSplitRE: RegExp;
1106
1119
  declare const splitWithVariantGroupRE: RegExp;
1107
1120
  declare const extractorSplit: Extractor;
1108
1121
 
1109
- export { BetterMap, CountableSet, DEFAULT_LAYERS, Emitter, LAYER_DEFAULT, LAYER_IMPORTS, LAYER_PREFLIGHTS, LAYER_SHORTCUTS, TwoKeyMap, UnoGenerator, 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 };
1122
+ export { BetterMap, CountableSet, DEFAULT_LAYERS, Emitter, LAYER_DEFAULT, LAYER_IMPORTS, LAYER_PREFLIGHTS, LAYER_SHORTCUTS, TwoKeyMap, UnoGenerator, VirtualKey, 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 };
1110
1123
  export type { ArgumentType, Arrayable, AutoCompleteExtractor, AutoCompleteExtractorContext, AutoCompleteExtractorResult, AutoCompleteFunction, AutoCompleteTemplate, Awaitable, BaseContext, BlocklistMeta, BlocklistRule, BlocklistValue, CSSEntries, CSSEntriesInput, CSSEntry, CSSObject, CSSObjectInput, CSSValue, CSSValueInput, CSSValues, CliEntryItem, CliOptions, ConfigBase, ContentOptions, ControlSymbols, ControlSymbolsEntry, ControlSymbolsValue, DeepPartial, DynamicMatcher, DynamicRule, DynamicShortcut, DynamicShortcutMatcher, ExtendedTokenInfo, Extractor, ExtractorContext, FilterPattern, FlatObjectTuple, GenerateOptions, GenerateResult, GeneratorOptions, HighlightAnnotation, ObjectToEntry, OutputCssLayersOptions, ParsedUtil, PartialByKeys, PluginOptions, Postprocessor, Preflight, PreflightContext, PreparedRule, Preprocessor, Preset, PresetFactory, PresetFactoryAwaitable, PresetOptions, PresetOrFactory, PresetOrFactoryAwaitable, RawUtil, Replacement, RequiredByKey, ResolvedConfig, RestArgs, Rule, RuleContext, RuleMeta, SafeListContext, Shift, Shortcut, ShortcutInlineValue, ShortcutValue, SourceCodeTransformer, SourceCodeTransformerEnforce, SourceMap, StaticRule, StaticShortcut, StaticShortcutMap, StringifiedUtil, SuggestResult, ThemeExtender, ToArray, UnocssPluginContext, Unsubscribe, UserConfig, UserConfigDefaults, UserOnlyOptions, UserShortcuts, UtilObject, Variant, VariantContext, VariantFunction, VariantHandler, VariantHandlerContext, VariantMatchedResult, VariantObject };
package/dist/index.mjs CHANGED
@@ -262,10 +262,11 @@ function clearIdenticalEntries(entry) {
262
262
  return true;
263
263
  });
264
264
  }
265
+ const VirtualKey = "__virtual_key__";
265
266
  function entriesToCss(arr) {
266
267
  if (arr == null)
267
268
  return "";
268
- return clearIdenticalEntries(arr).map(([key, value]) => value != null && typeof value !== "function" ? `${key}:${value};` : void 0).filter(Boolean).join("");
269
+ return clearIdenticalEntries(arr).map(([key, value]) => value != null && typeof value !== "function" ? key !== VirtualKey ? `${key}:${value};` : value : void 0).filter(Boolean).join("");
269
270
  }
270
271
  function isObject(item) {
271
272
  return item && typeof item === "object" && !Array.isArray(item);
@@ -549,17 +550,21 @@ async function resolveConfig(userConfig = {}, defaults = {}) {
549
550
  extractors.unshift(extractorDefault);
550
551
  extractors.sort((a, b) => (a.order || 0) - (b.order || 0));
551
552
  const rules = getMerged("rules");
552
- const rulesStaticMap = {};
553
553
  const rulesSize = rules.length;
554
- const rulesDynamic = rules.filter((rule) => {
555
- if (!isStaticRule(rule))
556
- return true;
557
- const prefixes = toArray(rule[2]?.prefix || "");
558
- prefixes.forEach((prefix) => {
559
- rulesStaticMap[prefix + rule[0]] = rule;
560
- });
561
- return false;
562
- }).reverse();
554
+ const rulesStaticMap = {};
555
+ const rulesDynamic = [];
556
+ for (const [index, rule] of rules.entries()) {
557
+ const meta = rule[2] ?? (rule[2] = {});
558
+ meta.__index = index;
559
+ if (isStaticRule(rule)) {
560
+ const prefixes = toArray(meta.prefix ?? "");
561
+ prefixes.forEach((prefix) => {
562
+ rulesStaticMap[prefix + rule[0]] = rule;
563
+ });
564
+ } else {
565
+ rulesDynamic.unshift(rule);
566
+ }
567
+ }
563
568
  const autocomplete = {
564
569
  templates: uniq(sources.flatMap((p) => toArray(p.autocomplete?.templates))),
565
570
  extractors: sources.flatMap((p) => toArray(p.autocomplete?.extractors)).sort((a, b) => (a.order || 0) - (b.order || 0)),
@@ -649,7 +654,7 @@ function definePreset(preset) {
649
654
  return preset;
650
655
  }
651
656
 
652
- const version = "66.4.1";
657
+ const version = "66.5.0";
653
658
 
654
659
  const symbols = {
655
660
  shortcutsNoMerge: "$$symbol-shortcut-no-merge",
@@ -658,7 +663,8 @@ const symbols = {
658
663
  parent: "$$symbol-parent",
659
664
  selector: "$$symbol-selector",
660
665
  layer: "$$symbol-layer",
661
- sort: "$$symbol-sort"
666
+ sort: "$$symbol-sort",
667
+ body: "$$symbol-body"
662
668
  };
663
669
  class UnoGeneratorInternal {
664
670
  constructor(userConfig = {}, defaults = {}) {
@@ -1104,11 +1110,10 @@ class UnoGeneratorInternal {
1104
1110
  context.rules.push(rule);
1105
1111
  }
1106
1112
  context.generator.activatedRules.add(rule);
1107
- const index = context.generator.config.rules.indexOf(rule);
1108
1113
  const meta = rule[2];
1109
1114
  return entries.map((css) => {
1110
1115
  if (isString(css))
1111
- return [index, css, meta];
1116
+ return [meta.__index, css, meta];
1112
1117
  let variants = context.variantHandlers;
1113
1118
  let entryMeta = meta;
1114
1119
  for (const entry of css) {
@@ -1146,9 +1151,11 @@ class UnoGeneratorInternal {
1146
1151
  ...entryMeta,
1147
1152
  noMerge: entry[1]
1148
1153
  };
1154
+ } else if (entry[0] === symbols.body) {
1155
+ entry[0] = VirtualKey;
1149
1156
  }
1150
1157
  }
1151
- return [index, raw, css, entryMeta, variants];
1158
+ return [meta.__index, raw, css, entryMeta, variants];
1152
1159
  });
1153
1160
  }
1154
1161
  };
@@ -1329,4 +1336,4 @@ function defaultVariantHandler(input, next) {
1329
1336
  return next(input);
1330
1337
  }
1331
1338
 
1332
- export { BetterMap, CountableSet, DEFAULT_LAYERS, LAYER_DEFAULT, LAYER_IMPORTS, LAYER_PREFLIGHTS, LAYER_SHORTCUTS, TwoKeyMap, UnoGenerator, 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 };
1339
+ export { BetterMap, CountableSet, DEFAULT_LAYERS, LAYER_DEFAULT, LAYER_IMPORTS, LAYER_PREFLIGHTS, LAYER_SHORTCUTS, TwoKeyMap, UnoGenerator, VirtualKey, 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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@unocss/core",
3
3
  "type": "module",
4
- "version": "66.4.1",
4
+ "version": "66.5.0",
5
5
  "description": "The instant on-demand Atomic CSS engine.",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -37,8 +37,8 @@
37
37
  "dist"
38
38
  ],
39
39
  "devDependencies": {
40
- "magic-string": "^0.30.17",
41
- "unconfig": "^7.3.2"
40
+ "magic-string": "^0.30.18",
41
+ "unconfig": "^7.3.3"
42
42
  },
43
43
  "scripts": {
44
44
  "build": "unbuild",