@unocss/core 0.62.3 → 0.62.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.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { LoadConfigResult } from 'unconfig';
2
1
  import MagicString from 'magic-string';
2
+ import { LoadConfigResult } from 'unconfig';
3
3
 
4
4
  type EventsMap = Record<string, any>;
5
5
  interface DefaultEvents extends EventsMap {
@@ -51,6 +51,22 @@ declare class Emitter<Events extends EventsMap = DefaultEvents> {
51
51
  emit<K extends keyof Events>(this: this, event: K, ...args: Parameters<Events[K]>): void;
52
52
  }
53
53
 
54
+ declare function toArray<T>(value?: T | T[]): T[];
55
+ declare function uniq<T>(value: T[]): T[];
56
+ declare function uniqueBy<T>(array: readonly T[], equalFn: (a: T, b: T) => boolean): T[];
57
+ declare function isString(s: any): s is string;
58
+
59
+ declare class CountableSet<K> extends Set<K> {
60
+ _map: Map<K, number>;
61
+ constructor(values?: Iterable<K>);
62
+ add(key: K): this;
63
+ delete(key: K): boolean;
64
+ clear(): void;
65
+ getCount(key: K): number;
66
+ setCount(key: K, count: number): this;
67
+ }
68
+ declare function isCountableSet<T = string>(value: any): value is CountableSet<T>;
69
+
54
70
  declare function escapeRegExp(string: string): string;
55
71
  /**
56
72
  * CSS Selector Escape
@@ -58,24 +74,6 @@ declare function escapeRegExp(string: string): string;
58
74
  declare function escapeSelector(str: string): string;
59
75
  declare const e: typeof escapeSelector;
60
76
 
61
- declare function normalizeCSSEntries(obj: string | CSSEntriesInput | CSSObjectInput): string | CSSEntries;
62
- declare function normalizeCSSValues(obj: CSSValueInput | string | (CSSValueInput | string)[]): (string | CSSEntries)[];
63
- declare function clearIdenticalEntries(entry: CSSEntries): CSSEntries;
64
- declare function entriesToCss(arr?: CSSEntries): string;
65
- declare function isObject(item: any): item is Record<string, any>;
66
- /**
67
- * Deep merge two objects
68
- */
69
- declare function mergeDeep<T>(original: T, patch: DeepPartial<T>, mergeArray?: boolean): T;
70
- declare function clone<T>(val: T): T;
71
- declare function isStaticRule(rule: Rule<any>): rule is StaticRule;
72
- declare function isStaticShortcut(sc: Shortcut<any>): sc is StaticShortcut;
73
-
74
- declare function toArray<T>(value?: T | T[]): T[];
75
- declare function uniq<T>(value: T[]): T[];
76
- declare function uniqueBy<T>(array: readonly T[], equalFn: (a: T, b: T) => boolean): T[];
77
- declare function isString(s: any): s is string;
78
-
79
77
  declare const attributifyRE: RegExp;
80
78
  declare const cssIdRE: RegExp;
81
79
  declare const validateFilterRE: RegExp;
@@ -86,6 +84,8 @@ declare function isRawUtil(util: ParsedUtil | RawUtil | StringifiedUtil): util i
86
84
  declare function notNull<T>(value: T | null | undefined): value is T;
87
85
  declare function noop(): void;
88
86
 
87
+ declare function withLayer<T extends object>(layer: string, rules: Rule<T>[]): Rule<T>[];
88
+
89
89
  declare class TwoKeyMap<K1, K2, V> {
90
90
  _map: Map<K1, Map<K2, V>>;
91
91
  get(key1: K1, key2: K2): V | undefined;
@@ -102,18 +102,18 @@ declare class BetterMap<K, V> extends Map<K, V> {
102
102
  flatMap<R extends readonly unknown[]>(mapFn: (value: V, key: K) => R): R[number][];
103
103
  }
104
104
 
105
- declare class CountableSet<K> extends Set<K> {
106
- _map: Map<K, number>;
107
- constructor(values?: Iterable<K>);
108
- add(key: K): this;
109
- delete(key: K): boolean;
110
- clear(): void;
111
- getCount(key: K): number;
112
- setCount(key: K, count: number): this;
113
- }
114
- declare function isCountableSet<T = string>(value: any): value is CountableSet<T>;
115
-
116
- declare function withLayer<T extends object>(layer: string, rules: Rule<T>[]): Rule<T>[];
105
+ declare function normalizeCSSEntries(obj: string | CSSEntriesInput | CSSObjectInput): string | CSSEntries;
106
+ declare function normalizeCSSValues(obj: CSSValueInput | string | (CSSValueInput | string)[]): (string | CSSEntries)[];
107
+ declare function clearIdenticalEntries(entry: CSSEntries): CSSEntries;
108
+ declare function entriesToCss(arr?: CSSEntries): string;
109
+ declare function isObject(item: any): item is Record<string, any>;
110
+ /**
111
+ * Deep merge two objects
112
+ */
113
+ declare function mergeDeep<T>(original: T, patch: DeepPartial<T>, mergeArray?: boolean): T;
114
+ declare function clone<T>(val: T): T;
115
+ declare function isStaticRule(rule: Rule<any>): rule is StaticRule;
116
+ declare function isStaticShortcut(sc: Shortcut<any>): sc is StaticShortcut;
117
117
 
118
118
  declare function makeRegexClassGroup(separators?: string[]): RegExp;
119
119
  interface VariantGroup {
@@ -350,13 +350,13 @@ interface RuleMeta {
350
350
  type CSSValue = CSSObject | CSSEntries;
351
351
  type CSSValues = CSSValue | CSSValue[];
352
352
  type DynamicMatcher<Theme extends object = object> = (match: RegExpMatchArray, context: Readonly<RuleContext<Theme>>) => Awaitable<CSSValueInput | string | (CSSValueInput | string)[] | undefined> | Generator<CSSValueInput | string | undefined> | AsyncGenerator<CSSValueInput | string | undefined>;
353
- type DynamicRule<Theme extends object = object> = [RegExp, DynamicMatcher<Theme>] | [RegExp, DynamicMatcher<Theme>, RuleMeta];
354
- type StaticRule = [string, CSSObject | CSSEntries] | [string, CSSObject | CSSEntries, RuleMeta];
353
+ type DynamicRule<Theme extends object = object> = [RegExp, DynamicMatcher<Theme>, RuleMeta?];
354
+ type StaticRule = [string, CSSObject | CSSEntries, RuleMeta?];
355
355
  type Rule<Theme extends object = object> = DynamicRule<Theme> | StaticRule;
356
356
  type DynamicShortcutMatcher<Theme extends object = object> = ((match: RegExpMatchArray, context: Readonly<RuleContext<Theme>>) => (string | ShortcutValue[] | undefined));
357
- type StaticShortcut = [string, string | ShortcutValue[]] | [string, string | ShortcutValue[], RuleMeta];
357
+ type StaticShortcut = [string, string | ShortcutValue[], RuleMeta?];
358
358
  type StaticShortcutMap = Record<string, string | ShortcutValue[]>;
359
- type DynamicShortcut<Theme extends object = object> = [RegExp, DynamicShortcutMatcher<Theme>] | [RegExp, DynamicShortcutMatcher<Theme>, RuleMeta];
359
+ type DynamicShortcut<Theme extends object = object> = [RegExp, DynamicShortcutMatcher<Theme>, RuleMeta?];
360
360
  type UserShortcuts<Theme extends object = object> = StaticShortcutMap | (StaticShortcut | DynamicShortcut<Theme> | StaticShortcutMap)[];
361
361
  type Shortcut<Theme extends object = object> = StaticShortcut | DynamicShortcut<Theme>;
362
362
  type ShortcutValue = string | CSSValue;
@@ -1007,10 +1007,6 @@ interface GenerateOptions<T extends boolean> {
1007
1007
  extendedInfo?: T;
1008
1008
  }
1009
1009
 
1010
- declare const defaultSplitRE: RegExp;
1011
- declare const splitWithVariantGroupRE: RegExp;
1012
- declare const extractorSplit: Extractor;
1013
-
1014
1010
  declare function resolveShortcuts<Theme extends object = object>(shortcuts: UserShortcuts<Theme>): Shortcut<Theme>[];
1015
1011
  /**
1016
1012
  * Resolve a single preset, nested presets are ignored
@@ -1028,4 +1024,8 @@ declare function mergeConfigs<Theme extends object = object>(configs: UserConfig
1028
1024
  declare function definePreset<Options extends object | undefined = undefined, Theme extends object = object>(preset: PresetFactory<Theme, Options>): PresetFactory<Theme, Options>;
1029
1025
  declare function definePreset<Theme extends object = object>(preset: Preset<Theme>): Preset<Theme>;
1030
1026
 
1027
+ declare const defaultSplitRE: RegExp;
1028
+ declare const splitWithVariantGroupRE: RegExp;
1029
+ declare const extractorSplit: Extractor;
1030
+
1031
1031
  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, type DeepPartial, type DynamicMatcher, type DynamicRule, type DynamicShortcut, type DynamicShortcutMatcher, type ExtendedTokenInfo, type Extractor, type ExtractorContext, type FilterPattern, type FlatObjectTuple, type GenerateOptions, type GenerateResult, type GeneratorOptions, type HighlightAnnotation, 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 PresetOptions, type PresetOrFactory, type RawUtil, type Replacement, type RequiredByKey, type ResolvedConfig, type RestArgs, type Rule, type RuleContext, type RuleMeta, type SafeListContext, type Shift, type Shortcut, 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 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, 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
@@ -1,5 +1,5 @@
1
- import { LoadConfigResult } from 'unconfig';
2
1
  import MagicString from 'magic-string';
2
+ import { LoadConfigResult } from 'unconfig';
3
3
 
4
4
  type EventsMap = Record<string, any>;
5
5
  interface DefaultEvents extends EventsMap {
@@ -51,6 +51,22 @@ declare class Emitter<Events extends EventsMap = DefaultEvents> {
51
51
  emit<K extends keyof Events>(this: this, event: K, ...args: Parameters<Events[K]>): void;
52
52
  }
53
53
 
54
+ declare function toArray<T>(value?: T | T[]): T[];
55
+ declare function uniq<T>(value: T[]): T[];
56
+ declare function uniqueBy<T>(array: readonly T[], equalFn: (a: T, b: T) => boolean): T[];
57
+ declare function isString(s: any): s is string;
58
+
59
+ declare class CountableSet<K> extends Set<K> {
60
+ _map: Map<K, number>;
61
+ constructor(values?: Iterable<K>);
62
+ add(key: K): this;
63
+ delete(key: K): boolean;
64
+ clear(): void;
65
+ getCount(key: K): number;
66
+ setCount(key: K, count: number): this;
67
+ }
68
+ declare function isCountableSet<T = string>(value: any): value is CountableSet<T>;
69
+
54
70
  declare function escapeRegExp(string: string): string;
55
71
  /**
56
72
  * CSS Selector Escape
@@ -58,24 +74,6 @@ declare function escapeRegExp(string: string): string;
58
74
  declare function escapeSelector(str: string): string;
59
75
  declare const e: typeof escapeSelector;
60
76
 
61
- declare function normalizeCSSEntries(obj: string | CSSEntriesInput | CSSObjectInput): string | CSSEntries;
62
- declare function normalizeCSSValues(obj: CSSValueInput | string | (CSSValueInput | string)[]): (string | CSSEntries)[];
63
- declare function clearIdenticalEntries(entry: CSSEntries): CSSEntries;
64
- declare function entriesToCss(arr?: CSSEntries): string;
65
- declare function isObject(item: any): item is Record<string, any>;
66
- /**
67
- * Deep merge two objects
68
- */
69
- declare function mergeDeep<T>(original: T, patch: DeepPartial<T>, mergeArray?: boolean): T;
70
- declare function clone<T>(val: T): T;
71
- declare function isStaticRule(rule: Rule<any>): rule is StaticRule;
72
- declare function isStaticShortcut(sc: Shortcut<any>): sc is StaticShortcut;
73
-
74
- declare function toArray<T>(value?: T | T[]): T[];
75
- declare function uniq<T>(value: T[]): T[];
76
- declare function uniqueBy<T>(array: readonly T[], equalFn: (a: T, b: T) => boolean): T[];
77
- declare function isString(s: any): s is string;
78
-
79
77
  declare const attributifyRE: RegExp;
80
78
  declare const cssIdRE: RegExp;
81
79
  declare const validateFilterRE: RegExp;
@@ -86,6 +84,8 @@ declare function isRawUtil(util: ParsedUtil | RawUtil | StringifiedUtil): util i
86
84
  declare function notNull<T>(value: T | null | undefined): value is T;
87
85
  declare function noop(): void;
88
86
 
87
+ declare function withLayer<T extends object>(layer: string, rules: Rule<T>[]): Rule<T>[];
88
+
89
89
  declare class TwoKeyMap<K1, K2, V> {
90
90
  _map: Map<K1, Map<K2, V>>;
91
91
  get(key1: K1, key2: K2): V | undefined;
@@ -102,18 +102,18 @@ declare class BetterMap<K, V> extends Map<K, V> {
102
102
  flatMap<R extends readonly unknown[]>(mapFn: (value: V, key: K) => R): R[number][];
103
103
  }
104
104
 
105
- declare class CountableSet<K> extends Set<K> {
106
- _map: Map<K, number>;
107
- constructor(values?: Iterable<K>);
108
- add(key: K): this;
109
- delete(key: K): boolean;
110
- clear(): void;
111
- getCount(key: K): number;
112
- setCount(key: K, count: number): this;
113
- }
114
- declare function isCountableSet<T = string>(value: any): value is CountableSet<T>;
115
-
116
- declare function withLayer<T extends object>(layer: string, rules: Rule<T>[]): Rule<T>[];
105
+ declare function normalizeCSSEntries(obj: string | CSSEntriesInput | CSSObjectInput): string | CSSEntries;
106
+ declare function normalizeCSSValues(obj: CSSValueInput | string | (CSSValueInput | string)[]): (string | CSSEntries)[];
107
+ declare function clearIdenticalEntries(entry: CSSEntries): CSSEntries;
108
+ declare function entriesToCss(arr?: CSSEntries): string;
109
+ declare function isObject(item: any): item is Record<string, any>;
110
+ /**
111
+ * Deep merge two objects
112
+ */
113
+ declare function mergeDeep<T>(original: T, patch: DeepPartial<T>, mergeArray?: boolean): T;
114
+ declare function clone<T>(val: T): T;
115
+ declare function isStaticRule(rule: Rule<any>): rule is StaticRule;
116
+ declare function isStaticShortcut(sc: Shortcut<any>): sc is StaticShortcut;
117
117
 
118
118
  declare function makeRegexClassGroup(separators?: string[]): RegExp;
119
119
  interface VariantGroup {
@@ -350,13 +350,13 @@ interface RuleMeta {
350
350
  type CSSValue = CSSObject | CSSEntries;
351
351
  type CSSValues = CSSValue | CSSValue[];
352
352
  type DynamicMatcher<Theme extends object = object> = (match: RegExpMatchArray, context: Readonly<RuleContext<Theme>>) => Awaitable<CSSValueInput | string | (CSSValueInput | string)[] | undefined> | Generator<CSSValueInput | string | undefined> | AsyncGenerator<CSSValueInput | string | undefined>;
353
- type DynamicRule<Theme extends object = object> = [RegExp, DynamicMatcher<Theme>] | [RegExp, DynamicMatcher<Theme>, RuleMeta];
354
- type StaticRule = [string, CSSObject | CSSEntries] | [string, CSSObject | CSSEntries, RuleMeta];
353
+ type DynamicRule<Theme extends object = object> = [RegExp, DynamicMatcher<Theme>, RuleMeta?];
354
+ type StaticRule = [string, CSSObject | CSSEntries, RuleMeta?];
355
355
  type Rule<Theme extends object = object> = DynamicRule<Theme> | StaticRule;
356
356
  type DynamicShortcutMatcher<Theme extends object = object> = ((match: RegExpMatchArray, context: Readonly<RuleContext<Theme>>) => (string | ShortcutValue[] | undefined));
357
- type StaticShortcut = [string, string | ShortcutValue[]] | [string, string | ShortcutValue[], RuleMeta];
357
+ type StaticShortcut = [string, string | ShortcutValue[], RuleMeta?];
358
358
  type StaticShortcutMap = Record<string, string | ShortcutValue[]>;
359
- type DynamicShortcut<Theme extends object = object> = [RegExp, DynamicShortcutMatcher<Theme>] | [RegExp, DynamicShortcutMatcher<Theme>, RuleMeta];
359
+ type DynamicShortcut<Theme extends object = object> = [RegExp, DynamicShortcutMatcher<Theme>, RuleMeta?];
360
360
  type UserShortcuts<Theme extends object = object> = StaticShortcutMap | (StaticShortcut | DynamicShortcut<Theme> | StaticShortcutMap)[];
361
361
  type Shortcut<Theme extends object = object> = StaticShortcut | DynamicShortcut<Theme>;
362
362
  type ShortcutValue = string | CSSValue;
@@ -1007,10 +1007,6 @@ interface GenerateOptions<T extends boolean> {
1007
1007
  extendedInfo?: T;
1008
1008
  }
1009
1009
 
1010
- declare const defaultSplitRE: RegExp;
1011
- declare const splitWithVariantGroupRE: RegExp;
1012
- declare const extractorSplit: Extractor;
1013
-
1014
1010
  declare function resolveShortcuts<Theme extends object = object>(shortcuts: UserShortcuts<Theme>): Shortcut<Theme>[];
1015
1011
  /**
1016
1012
  * Resolve a single preset, nested presets are ignored
@@ -1028,4 +1024,8 @@ declare function mergeConfigs<Theme extends object = object>(configs: UserConfig
1028
1024
  declare function definePreset<Options extends object | undefined = undefined, Theme extends object = object>(preset: PresetFactory<Theme, Options>): PresetFactory<Theme, Options>;
1029
1025
  declare function definePreset<Theme extends object = object>(preset: Preset<Theme>): Preset<Theme>;
1030
1026
 
1027
+ declare const defaultSplitRE: RegExp;
1028
+ declare const splitWithVariantGroupRE: RegExp;
1029
+ declare const extractorSplit: Extractor;
1030
+
1031
1031
  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, type DeepPartial, type DynamicMatcher, type DynamicRule, type DynamicShortcut, type DynamicShortcutMatcher, type ExtendedTokenInfo, type Extractor, type ExtractorContext, type FilterPattern, type FlatObjectTuple, type GenerateOptions, type GenerateResult, type GeneratorOptions, type HighlightAnnotation, 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 PresetOptions, type PresetOrFactory, type RawUtil, type Replacement, type RequiredByKey, type ResolvedConfig, type RestArgs, type Rule, type RuleContext, type RuleMeta, type SafeListContext, type Shift, type Shortcut, 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 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, 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
@@ -1,3 +1,82 @@
1
+ const LAYER_DEFAULT = "default";
2
+ const LAYER_PREFLIGHTS = "preflights";
3
+ const LAYER_SHORTCUTS = "shortcuts";
4
+ const LAYER_IMPORTS = "imports";
5
+ const DEFAULT_LAYERS = {
6
+ [LAYER_IMPORTS]: -200,
7
+ [LAYER_PREFLIGHTS]: -100,
8
+ [LAYER_SHORTCUTS]: -10,
9
+ [LAYER_DEFAULT]: 0
10
+ };
11
+
12
+ const defaultSplitRE = /[\\:]?[\s'"`;{}]+/g;
13
+ const splitWithVariantGroupRE = /([\\:]?[\s"'`;<>]|:\(|\)"|\)\s)/g;
14
+ function splitCode(code) {
15
+ return code.split(defaultSplitRE);
16
+ }
17
+ const extractorSplit = {
18
+ name: "@unocss/core/extractor-split",
19
+ order: 0,
20
+ extract({ code }) {
21
+ return splitCode(code);
22
+ }
23
+ };
24
+
25
+ function toArray(value = []) {
26
+ return Array.isArray(value) ? value : [value];
27
+ }
28
+ function uniq(value) {
29
+ return Array.from(new Set(value));
30
+ }
31
+ function uniqueBy(array, equalFn) {
32
+ return array.reduce((acc, cur) => {
33
+ const index = acc.findIndex((item) => equalFn(cur, item));
34
+ if (index === -1)
35
+ acc.push(cur);
36
+ return acc;
37
+ }, []);
38
+ }
39
+ function isString(s) {
40
+ return typeof s === "string";
41
+ }
42
+
43
+ var __defProp$2 = Object.defineProperty;
44
+ var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
45
+ var __publicField$2 = (obj, key, value) => {
46
+ __defNormalProp$2(obj, key + "" , value);
47
+ return value;
48
+ };
49
+ class CountableSet extends Set {
50
+ constructor(values) {
51
+ super(values);
52
+ __publicField$2(this, "_map");
53
+ this._map ?? (this._map = /* @__PURE__ */ new Map());
54
+ }
55
+ add(key) {
56
+ this._map ?? (this._map = /* @__PURE__ */ new Map());
57
+ this._map.set(key, (this._map.get(key) ?? 0) + 1);
58
+ return super.add(key);
59
+ }
60
+ delete(key) {
61
+ this._map.delete(key);
62
+ return super.delete(key);
63
+ }
64
+ clear() {
65
+ this._map.clear();
66
+ super.clear();
67
+ }
68
+ getCount(key) {
69
+ return this._map.get(key) ?? 0;
70
+ }
71
+ setCount(key, count) {
72
+ this._map.set(key, count);
73
+ return super.add(key);
74
+ }
75
+ }
76
+ function isCountableSet(value) {
77
+ return value instanceof CountableSet;
78
+ }
79
+
1
80
  function escapeRegExp(string) {
2
81
  return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
3
82
  }
@@ -47,111 +126,6 @@ function escapeSelector(str) {
47
126
  }
48
127
  const e = escapeSelector;
49
128
 
50
- function toArray(value = []) {
51
- return Array.isArray(value) ? value : [value];
52
- }
53
- function uniq(value) {
54
- return Array.from(new Set(value));
55
- }
56
- function uniqueBy(array, equalFn) {
57
- return array.reduce((acc, cur) => {
58
- const index = acc.findIndex((item) => equalFn(cur, item));
59
- if (index === -1)
60
- acc.push(cur);
61
- return acc;
62
- }, []);
63
- }
64
- function isString(s) {
65
- return typeof s === "string";
66
- }
67
-
68
- function normalizeCSSEntries(obj) {
69
- if (isString(obj))
70
- return obj;
71
- return (!Array.isArray(obj) ? Object.entries(obj) : obj).filter((i) => i[1] != null);
72
- }
73
- function normalizeCSSValues(obj) {
74
- if (Array.isArray(obj)) {
75
- if (obj.find((i) => !Array.isArray(i) || Array.isArray(i[0])))
76
- return obj.map((i) => normalizeCSSEntries(i));
77
- else
78
- return [obj];
79
- } else {
80
- return [normalizeCSSEntries(obj)];
81
- }
82
- }
83
- function clearIdenticalEntries(entry) {
84
- return entry.filter(([k, v], idx) => {
85
- if (k.startsWith("$$"))
86
- return false;
87
- for (let i = idx - 1; i >= 0; i--) {
88
- if (entry[i][0] === k && entry[i][1] === v)
89
- return false;
90
- }
91
- return true;
92
- });
93
- }
94
- function entriesToCss(arr) {
95
- if (arr == null)
96
- return "";
97
- return clearIdenticalEntries(arr).map(([key, value]) => value != null && typeof value !== "function" ? `${key}:${value};` : void 0).filter(Boolean).join("");
98
- }
99
- function isObject(item) {
100
- return item && typeof item === "object" && !Array.isArray(item);
101
- }
102
- function mergeDeep(original, patch, mergeArray = false) {
103
- const o = original;
104
- const p = patch;
105
- if (Array.isArray(p)) {
106
- if (mergeArray && Array.isArray(p))
107
- return [...o, ...p];
108
- else
109
- return [...p];
110
- }
111
- const output = { ...o };
112
- if (isObject(o) && isObject(p)) {
113
- Object.keys(p).forEach((key) => {
114
- if (isObject(o[key]) && isObject(p[key]) || Array.isArray(o[key]) && Array.isArray(p[key]))
115
- output[key] = mergeDeep(o[key], p[key], mergeArray);
116
- else
117
- Object.assign(output, { [key]: p[key] });
118
- });
119
- }
120
- return output;
121
- }
122
- function clone(val) {
123
- let k, out, tmp;
124
- if (Array.isArray(val)) {
125
- out = Array(k = val.length);
126
- while (k--)
127
- out[k] = (tmp = val[k]) && typeof tmp === "object" ? clone(tmp) : tmp;
128
- return out;
129
- }
130
- if (Object.prototype.toString.call(val) === "[object Object]") {
131
- out = {};
132
- for (k in val) {
133
- if (k === "__proto__") {
134
- Object.defineProperty(out, k, {
135
- value: clone(val[k]),
136
- configurable: true,
137
- enumerable: true,
138
- writable: true
139
- });
140
- } else {
141
- out[k] = (tmp = val[k]) && typeof tmp === "object" ? clone(tmp) : tmp;
142
- }
143
- }
144
- return out;
145
- }
146
- return val;
147
- }
148
- function isStaticRule(rule) {
149
- return isString(rule[0]);
150
- }
151
- function isStaticShortcut(sc) {
152
- return isString(sc[0]);
153
- }
154
-
155
129
  const attributifyRE = /^\[(.+?)~?="(.*)"\]$/;
156
130
  const cssIdRE = /\.(css|postcss|sass|scss|less|stylus|styl)($|\?)/;
157
131
  const validateFilterRE = /[\w\u00A0-\uFFFF%-?]/;
@@ -173,15 +147,25 @@ function notNull(value) {
173
147
  function noop() {
174
148
  }
175
149
 
176
- var __defProp$2 = Object.defineProperty;
177
- var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
178
- var __publicField$2 = (obj, key, value) => {
179
- __defNormalProp$2(obj, key + "" , value);
150
+ function withLayer(layer, rules) {
151
+ rules.forEach((r) => {
152
+ if (!r[2])
153
+ r[2] = { layer };
154
+ else
155
+ r[2].layer = layer;
156
+ });
157
+ return rules;
158
+ }
159
+
160
+ var __defProp$1 = Object.defineProperty;
161
+ var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
162
+ var __publicField$1 = (obj, key, value) => {
163
+ __defNormalProp$1(obj, key + "" , value);
180
164
  return value;
181
165
  };
182
166
  class TwoKeyMap {
183
167
  constructor() {
184
- __publicField$2(this, "_map", /* @__PURE__ */ new Map());
168
+ __publicField$1(this, "_map", /* @__PURE__ */ new Map());
185
169
  }
186
170
  get(key1, key2) {
187
171
  const m2 = this._map.get(key1);
@@ -247,51 +231,91 @@ class BetterMap extends Map {
247
231
  }
248
232
  }
249
233
 
250
- var __defProp$1 = Object.defineProperty;
251
- var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
252
- var __publicField$1 = (obj, key, value) => {
253
- __defNormalProp$1(obj, key + "" , value);
254
- return value;
255
- };
256
- class CountableSet extends Set {
257
- constructor(values) {
258
- super(values);
259
- __publicField$1(this, "_map");
260
- this._map ?? (this._map = /* @__PURE__ */ new Map());
261
- }
262
- add(key) {
263
- this._map ?? (this._map = /* @__PURE__ */ new Map());
264
- this._map.set(key, (this._map.get(key) ?? 0) + 1);
265
- return super.add(key);
234
+ function normalizeCSSEntries(obj) {
235
+ if (isString(obj))
236
+ return obj;
237
+ return (!Array.isArray(obj) ? Object.entries(obj) : obj).filter((i) => i[1] != null);
238
+ }
239
+ function normalizeCSSValues(obj) {
240
+ if (Array.isArray(obj)) {
241
+ if (obj.find((i) => !Array.isArray(i) || Array.isArray(i[0])))
242
+ return obj.map((i) => normalizeCSSEntries(i));
243
+ else
244
+ return [obj];
245
+ } else {
246
+ return [normalizeCSSEntries(obj)];
266
247
  }
267
- delete(key) {
268
- this._map.delete(key);
269
- return super.delete(key);
248
+ }
249
+ function clearIdenticalEntries(entry) {
250
+ return entry.filter(([k, v], idx) => {
251
+ if (k.startsWith("$$"))
252
+ return false;
253
+ for (let i = idx - 1; i >= 0; i--) {
254
+ if (entry[i][0] === k && entry[i][1] === v)
255
+ return false;
256
+ }
257
+ return true;
258
+ });
259
+ }
260
+ function entriesToCss(arr) {
261
+ if (arr == null)
262
+ return "";
263
+ return clearIdenticalEntries(arr).map(([key, value]) => value != null && typeof value !== "function" ? `${key}:${value};` : void 0).filter(Boolean).join("");
264
+ }
265
+ function isObject(item) {
266
+ return item && typeof item === "object" && !Array.isArray(item);
267
+ }
268
+ function mergeDeep(original, patch, mergeArray = false) {
269
+ const o = original;
270
+ const p = patch;
271
+ if (Array.isArray(p)) {
272
+ if (mergeArray && Array.isArray(p))
273
+ return [...o, ...p];
274
+ else
275
+ return [...p];
270
276
  }
271
- clear() {
272
- this._map.clear();
273
- super.clear();
277
+ const output = { ...o };
278
+ if (isObject(o) && isObject(p)) {
279
+ Object.keys(p).forEach((key) => {
280
+ if (isObject(o[key]) && isObject(p[key]) || Array.isArray(o[key]) && Array.isArray(p[key]))
281
+ output[key] = mergeDeep(o[key], p[key], mergeArray);
282
+ else
283
+ Object.assign(output, { [key]: p[key] });
284
+ });
274
285
  }
275
- getCount(key) {
276
- return this._map.get(key) ?? 0;
286
+ return output;
287
+ }
288
+ function clone(val) {
289
+ let k, out, tmp;
290
+ if (Array.isArray(val)) {
291
+ out = Array.from({ length: k = val.length });
292
+ while (k--)
293
+ out[k] = (tmp = val[k]) && typeof tmp === "object" ? clone(tmp) : tmp;
294
+ return out;
277
295
  }
278
- setCount(key, count) {
279
- this._map.set(key, count);
280
- return super.add(key);
296
+ if (Object.prototype.toString.call(val) === "[object Object]") {
297
+ out = {};
298
+ for (k in val) {
299
+ if (k === "__proto__") {
300
+ Object.defineProperty(out, k, {
301
+ value: clone(val[k]),
302
+ configurable: true,
303
+ enumerable: true,
304
+ writable: true
305
+ });
306
+ } else {
307
+ out[k] = (tmp = val[k]) && typeof tmp === "object" ? clone(tmp) : tmp;
308
+ }
309
+ }
310
+ return out;
281
311
  }
312
+ return val;
282
313
  }
283
- function isCountableSet(value) {
284
- return value instanceof CountableSet;
314
+ function isStaticRule(rule) {
315
+ return isString(rule[0]);
285
316
  }
286
-
287
- function withLayer(layer, rules) {
288
- rules.forEach((r) => {
289
- if (!r[2])
290
- r[2] = { layer };
291
- else
292
- r[2].layer = layer;
293
- });
294
- return rules;
317
+ function isStaticShortcut(sc) {
318
+ return isString(sc[0]);
295
319
  }
296
320
 
297
321
  const regexCache = {};
@@ -410,43 +434,6 @@ function warnOnce(msg) {
410
434
  warned.add(msg);
411
435
  }
412
436
 
413
- const defaultSplitRE = /[\\:]?[\s'"`;{}]+/g;
414
- const splitWithVariantGroupRE = /([\\:]?[\s"'`;<>]|:\(|\)"|\)\s)/g;
415
- function splitCode(code) {
416
- return code.split(defaultSplitRE);
417
- }
418
- const extractorSplit = {
419
- name: "@unocss/core/extractor-split",
420
- order: 0,
421
- extract({ code }) {
422
- return splitCode(code);
423
- }
424
- };
425
-
426
- function createNanoEvents() {
427
- return {
428
- events: {},
429
- emit(event, ...args) {
430
- (this.events[event] || []).forEach((i) => i(...args));
431
- },
432
- on(event, cb) {
433
- (this.events[event] = this.events[event] || []).push(cb);
434
- return () => this.events[event] = (this.events[event] || []).filter((i) => i !== cb);
435
- }
436
- };
437
- }
438
-
439
- const LAYER_DEFAULT = "default";
440
- const LAYER_PREFLIGHTS = "preflights";
441
- const LAYER_SHORTCUTS = "shortcuts";
442
- const LAYER_IMPORTS = "imports";
443
- const DEFAULT_LAYERS = {
444
- [LAYER_IMPORTS]: -200,
445
- [LAYER_PREFLIGHTS]: -100,
446
- [LAYER_SHORTCUTS]: -10,
447
- [LAYER_DEFAULT]: 0
448
- };
449
-
450
437
  function resolveShortcuts(shortcuts) {
451
438
  return toArray(shortcuts).flatMap((s) => {
452
439
  if (Array.isArray(s))
@@ -639,7 +626,20 @@ function definePreset(preset) {
639
626
  return preset;
640
627
  }
641
628
 
642
- const version = "0.62.3";
629
+ const version = "0.62.4";
630
+
631
+ function createNanoEvents() {
632
+ return {
633
+ events: {},
634
+ emit(event, ...args) {
635
+ (this.events[event] || []).forEach((i) => i(...args));
636
+ },
637
+ on(event, cb) {
638
+ (this.events[event] = this.events[event] || []).push(cb);
639
+ return () => this.events[event] = (this.events[event] || []).filter((i) => i !== cb);
640
+ }
641
+ };
642
+ }
643
643
 
644
644
  var __defProp = Object.defineProperty;
645
645
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@unocss/core",
3
3
  "type": "module",
4
- "version": "0.62.3",
4
+ "version": "0.62.4",
5
5
  "description": "The instant on-demand Atomic CSS engine.",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",