@unocss/core 0.53.4 → 0.53.5

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 CHANGED
@@ -288,7 +288,7 @@ function expandVariantGroup(str, separators = ["-", ":"], depth = 5) {
288
288
  if (typeof str === "string") {
289
289
  return expanded;
290
290
  } else {
291
- return str.length() ? str.overwrite(0, str.length(), expanded) : str;
291
+ return str.length() ? str.overwrite(0, str.original.length, expanded) : str;
292
292
  }
293
293
  }
294
294
 
@@ -507,7 +507,7 @@ function mergeThemes(themes) {
507
507
  return themes.map((theme) => theme ? clone(theme) : {}).reduce((a, b) => mergeDeep(a, b), {});
508
508
  }
509
509
 
510
- const version = "0.53.4";
510
+ const version = "0.53.5";
511
511
 
512
512
  class UnoGenerator {
513
513
  constructor(userConfig = {}, defaults = {}) {
@@ -927,7 +927,7 @@ class UnoGenerator {
927
927
  async stringifyShortcuts(parent, context, expanded, meta = { layer: this.config.shortcutsLayer }) {
928
928
  const selectorMap = new TwoKeyMap();
929
929
  const parsed = (await Promise.all(uniq(expanded).map(async (i) => {
930
- const result = isString(i) ? await this.parseUtil(i, context, true, meta.prefix) : [[Infinity, "{inline}", normalizeCSSEntries(i), void 0, []]];
930
+ const result = isString(i) ? await this.parseUtil(i, context, true, meta.prefix) : [[Number.POSITIVE_INFINITY, "{inline}", normalizeCSSEntries(i), void 0, []]];
931
931
  if (!result)
932
932
  warnOnce(`unmatched utility "${i}" in shortcut "${parent[1]}"`);
933
933
  return result || [];
package/dist/index.d.ts CHANGED
@@ -51,7 +51,7 @@ 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 class UnoGenerator<Theme extends {} = {}> {
54
+ declare class UnoGenerator<Theme extends object = object> {
55
55
  userConfig: UserConfig<Theme>;
56
56
  defaults: UserConfigDefaults<Theme>;
57
57
  version: string;
@@ -77,7 +77,7 @@ declare class UnoGenerator<Theme extends {} = {}> {
77
77
  stringifyShortcuts(parent: VariantMatchedResult<Theme>, context: RuleContext<Theme>, expanded: ShortcutValue[], meta?: RuleMeta): Promise<StringifiedUtil<Theme>[] | undefined>;
78
78
  isBlocked(raw: string): boolean;
79
79
  }
80
- declare function createGenerator<Theme extends {} = {}>(config?: UserConfig<Theme>, defaults?: UserConfigDefaults<Theme>): UnoGenerator<Theme>;
80
+ declare function createGenerator<Theme extends object = object>(config?: UserConfig<Theme>, defaults?: UserConfigDefaults<Theme>): UnoGenerator<Theme>;
81
81
  declare const regexScopePlaceholder: RegExp;
82
82
  declare function hasScopePlaceholder(css: string): RegExpMatchArray | null;
83
83
  declare function toEscapedSelector(raw: string): string;
@@ -131,7 +131,7 @@ declare class BetterMap<K, V> extends Map<K, V> {
131
131
  map<R>(mapFn: (value: V, key: K) => R): R[];
132
132
  }
133
133
 
134
- declare function withLayer<T extends {}>(layer: string, rules: Rule<T>[]): Rule<T>[];
134
+ declare function withLayer<T extends object>(layer: string, rules: Rule<T>[]): Rule<T>[];
135
135
 
136
136
  declare function makeRegexClassGroup(separators?: string[]): RegExp;
137
137
  declare function parseVariantGroup(str: string, separators?: string[], depth?: number): {
@@ -205,7 +205,7 @@ interface ParsedColorValue {
205
205
  alpha: string | number | undefined;
206
206
  }
207
207
  type PresetOptions = Record<string, any>;
208
- interface RuleContext<Theme extends {} = {}> {
208
+ interface RuleContext<Theme extends object = object> {
209
209
  /**
210
210
  * Unprocessed selector from user input.
211
211
  * Useful for generating CSS rule.
@@ -249,7 +249,7 @@ interface RuleContext<Theme extends {} = {}> {
249
249
  */
250
250
  variants?: Variant<Theme>[];
251
251
  }
252
- interface VariantContext<Theme extends {} = {}> {
252
+ interface VariantContext<Theme extends object = object> {
253
253
  /**
254
254
  * Unprocessed selector from user input.
255
255
  */
@@ -269,7 +269,7 @@ interface ExtractorContext {
269
269
  id?: string;
270
270
  extracted: Set<string>;
271
271
  }
272
- interface PreflightContext<Theme extends {} = {}> {
272
+ interface PreflightContext<Theme extends object = object> {
273
273
  /**
274
274
  * UnoCSS generator instance
275
275
  */
@@ -327,19 +327,19 @@ interface RuleMeta {
327
327
  }
328
328
  type CSSValue = CSSObject | CSSEntries;
329
329
  type CSSValues = CSSValue | CSSValue[];
330
- type DynamicMatcher<Theme extends {} = {}> = ((match: RegExpMatchArray, context: Readonly<RuleContext<Theme>>) => Awaitable<CSSValue | string | (CSSValue | string)[] | undefined>);
331
- type DynamicRule<Theme extends {} = {}> = [RegExp, DynamicMatcher<Theme>] | [RegExp, DynamicMatcher<Theme>, RuleMeta];
330
+ type DynamicMatcher<Theme extends object = object> = ((match: RegExpMatchArray, context: Readonly<RuleContext<Theme>>) => Awaitable<CSSValue | string | (CSSValue | string)[] | undefined>);
331
+ type DynamicRule<Theme extends object = object> = [RegExp, DynamicMatcher<Theme>] | [RegExp, DynamicMatcher<Theme>, RuleMeta];
332
332
  type StaticRule = [string, CSSObject | CSSEntries] | [string, CSSObject | CSSEntries, RuleMeta];
333
- type Rule<Theme extends {} = {}> = DynamicRule<Theme> | StaticRule;
334
- type DynamicShortcutMatcher<Theme extends {} = {}> = ((match: RegExpMatchArray, context: Readonly<RuleContext<Theme>>) => (string | ShortcutValue[] | undefined));
333
+ type Rule<Theme extends object = object> = DynamicRule<Theme> | StaticRule;
334
+ type DynamicShortcutMatcher<Theme extends object = object> = ((match: RegExpMatchArray, context: Readonly<RuleContext<Theme>>) => (string | ShortcutValue[] | undefined));
335
335
  type StaticShortcut = [string, string | ShortcutValue[]] | [string, string | ShortcutValue[], RuleMeta];
336
336
  type StaticShortcutMap = Record<string, string | ShortcutValue[]>;
337
- type DynamicShortcut<Theme extends {} = {}> = [RegExp, DynamicShortcutMatcher<Theme>] | [RegExp, DynamicShortcutMatcher<Theme>, RuleMeta];
338
- type UserShortcuts<Theme extends {} = {}> = StaticShortcutMap | (StaticShortcut | DynamicShortcut<Theme> | StaticShortcutMap)[];
339
- type Shortcut<Theme extends {} = {}> = StaticShortcut | DynamicShortcut<Theme>;
337
+ type DynamicShortcut<Theme extends object = object> = [RegExp, DynamicShortcutMatcher<Theme>] | [RegExp, DynamicShortcutMatcher<Theme>, RuleMeta];
338
+ type UserShortcuts<Theme extends object = object> = StaticShortcutMap | (StaticShortcut | DynamicShortcut<Theme> | StaticShortcutMap)[];
339
+ type Shortcut<Theme extends object = object> = StaticShortcut | DynamicShortcut<Theme>;
340
340
  type ShortcutValue = string | CSSValue;
341
341
  type FilterPattern = ReadonlyArray<string | RegExp> | string | RegExp | null;
342
- interface Preflight<Theme extends {} = {}> {
342
+ interface Preflight<Theme extends object = object> {
343
343
  getCSS: (context: PreflightContext<Theme>) => Promise<string | undefined> | string | undefined;
344
344
  layer?: string;
345
345
  }
@@ -417,8 +417,8 @@ interface VariantHandler {
417
417
  */
418
418
  layer?: string | undefined;
419
419
  }
420
- type VariantFunction<Theme extends {} = {}> = (matcher: string, context: Readonly<VariantContext<Theme>>) => Awaitable<string | VariantHandler | undefined>;
421
- interface VariantObject<Theme extends {} = {}> {
420
+ type VariantFunction<Theme extends object = object> = (matcher: string, context: Readonly<VariantContext<Theme>>) => Awaitable<string | VariantHandler | undefined>;
421
+ interface VariantObject<Theme extends object = object> {
422
422
  /**
423
423
  * The name of the variant.
424
424
  */
@@ -442,11 +442,11 @@ interface VariantObject<Theme extends {} = {}> {
442
442
  */
443
443
  autocomplete?: Arrayable<AutoCompleteFunction | AutoCompleteTemplate>;
444
444
  }
445
- type Variant<Theme extends {} = {}> = VariantFunction<Theme> | VariantObject<Theme>;
445
+ type Variant<Theme extends object = object> = VariantFunction<Theme> | VariantObject<Theme>;
446
446
  type Preprocessor = (matcher: string) => string | undefined;
447
447
  type Postprocessor = (util: UtilObject) => void;
448
448
  type ThemeExtender<T> = (theme: T) => T | void;
449
- interface ConfigBase<Theme extends {} = {}> {
449
+ interface ConfigBase<Theme extends object = object> {
450
450
  /**
451
451
  * Rules to generate CSS utilities.
452
452
  *
@@ -613,7 +613,7 @@ interface AutoCompleteExtractor {
613
613
  extract: (context: AutoCompleteExtractorContext) => Awaitable<AutoCompleteExtractorResult | null>;
614
614
  order?: number;
615
615
  }
616
- interface Preset<Theme extends {} = {}> extends ConfigBase<Theme> {
616
+ interface Preset<Theme extends object = object> extends ConfigBase<Theme> {
617
617
  name: string;
618
618
  /**
619
619
  * Enforce the preset to be applied before or after other presets
@@ -646,7 +646,7 @@ interface GeneratorOptions {
646
646
  */
647
647
  warn?: boolean;
648
648
  }
649
- interface UserOnlyOptions<Theme extends {} = {}> {
649
+ interface UserOnlyOptions<Theme extends object = object> {
650
650
  /**
651
651
  * The theme object, will be merged with the theme provides by presets
652
652
  */
@@ -830,11 +830,11 @@ interface PluginOptions {
830
830
  */
831
831
  exclude?: FilterPattern;
832
832
  }
833
- interface UserConfig<Theme extends {} = {}> extends ConfigBase<Theme>, UserOnlyOptions<Theme>, GeneratorOptions, PluginOptions, CliOptions {
833
+ interface UserConfig<Theme extends object = object> extends ConfigBase<Theme>, UserOnlyOptions<Theme>, GeneratorOptions, PluginOptions, CliOptions {
834
834
  }
835
- interface UserConfigDefaults<Theme extends {} = {}> extends ConfigBase<Theme>, UserOnlyOptions<Theme> {
835
+ interface UserConfigDefaults<Theme extends object = object> extends ConfigBase<Theme>, UserOnlyOptions<Theme> {
836
836
  }
837
- interface ResolvedConfig<Theme extends {} = {}> extends Omit<RequiredByKey<UserConfig<Theme>, 'mergeSelectors' | 'theme' | 'rules' | 'variants' | 'layers' | 'extractors' | 'blocklist' | 'safelist' | 'preflights' | 'sortLayers'>, 'rules' | 'shortcuts' | 'autocomplete'> {
837
+ interface ResolvedConfig<Theme extends object = object> extends Omit<RequiredByKey<UserConfig<Theme>, 'mergeSelectors' | 'theme' | 'rules' | 'variants' | 'layers' | 'extractors' | 'blocklist' | 'safelist' | 'preflights' | 'sortLayers'>, 'rules' | 'shortcuts' | 'autocomplete'> {
838
838
  presets: Preset<Theme>[];
839
839
  shortcuts: Shortcut<Theme>[];
840
840
  variants: VariantObject<Theme>[];
@@ -856,7 +856,7 @@ interface GenerateResult {
856
856
  getLayers(includes?: string[], excludes?: string[]): string;
857
857
  matched: Set<string>;
858
858
  }
859
- type VariantMatchedResult<Theme extends {} = {}> = readonly [
859
+ type VariantMatchedResult<Theme extends object = object> = readonly [
860
860
  raw: string,
861
861
  current: string,
862
862
  variantHandlers: VariantHandler[],
@@ -874,7 +874,7 @@ type RawUtil = readonly [
874
874
  rawCSS: string,
875
875
  meta: RuleMeta | undefined
876
876
  ];
877
- type StringifiedUtil<Theme extends {} = {}> = readonly [
877
+ type StringifiedUtil<Theme extends object = object> = readonly [
878
878
  index: number,
879
879
  selector: string | undefined,
880
880
  body: string,
@@ -930,19 +930,19 @@ declare const defaultSplitRE: RegExp;
930
930
  declare const splitWithVariantGroupRE: RegExp;
931
931
  declare const extractorSplit: Extractor;
932
932
 
933
- declare function resolveShortcuts<Theme extends {} = {}>(shortcuts: UserShortcuts<Theme>): Shortcut<Theme>[];
933
+ declare function resolveShortcuts<Theme extends object = object>(shortcuts: UserShortcuts<Theme>): Shortcut<Theme>[];
934
934
  /**
935
935
  * Resolve a single preset, nested presets are ignored
936
936
  */
937
- declare function resolvePreset<Theme extends {} = {}>(preset: Preset<Theme>): Preset<Theme>;
937
+ declare function resolvePreset<Theme extends object = object>(preset: Preset<Theme>): Preset<Theme>;
938
938
  /**
939
939
  * Resolve presets with nested presets
940
940
  */
941
- declare function resolvePresets<Theme extends {} = {}>(preset: Preset<Theme>): Preset<Theme>[];
942
- declare function resolveConfig<Theme extends {} = {}>(userConfig?: UserConfig<Theme>, defaults?: UserConfigDefaults<Theme>): ResolvedConfig<Theme>;
941
+ declare function resolvePresets<Theme extends object = object>(preset: Preset<Theme>): Preset<Theme>[];
942
+ declare function resolveConfig<Theme extends object = object>(userConfig?: UserConfig<Theme>, defaults?: UserConfigDefaults<Theme>): ResolvedConfig<Theme>;
943
943
  /**
944
944
  * Merge multiple configs into one, later ones have higher priority
945
945
  */
946
- declare function mergeConfigs<Theme extends {} = {}>(configs: UserConfig<Theme>[]): UserConfig<Theme>;
946
+ declare function mergeConfigs<Theme extends object = object>(configs: UserConfig<Theme>[]): UserConfig<Theme>;
947
947
 
948
948
  export { ArgumentType, Arrayable, AutoCompleteExtractor, AutoCompleteExtractorContext, AutoCompleteExtractorResult, AutoCompleteFunction, AutoCompleteTemplate, Awaitable, BetterMap, BlocklistRule, CONTROL_SHORTCUT_NO_MERGE, CSSColorValue, CSSEntries, CSSObject, CSSValue, CSSValues, CliEntryItem, CliOptions, ConfigBase, ContentOptions, DeepPartial, DynamicMatcher, DynamicRule, DynamicShortcut, DynamicShortcutMatcher, 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, mergeConfigs, mergeDeep, noop, normalizeCSSEntries, normalizeCSSValues, normalizeVariant, notNull, parseVariantGroup, regexScopePlaceholder, resolveConfig, resolvePreset, resolvePresets, resolveShortcuts, splitWithVariantGroupRE, toArray, toEscapedSelector, uniq, validateFilterRE, warnOnce, withLayer };
package/dist/index.mjs CHANGED
@@ -284,7 +284,7 @@ function expandVariantGroup(str, separators = ["-", ":"], depth = 5) {
284
284
  if (typeof str === "string") {
285
285
  return expanded;
286
286
  } else {
287
- return str.length() ? str.overwrite(0, str.length(), expanded) : str;
287
+ return str.length() ? str.overwrite(0, str.original.length, expanded) : str;
288
288
  }
289
289
  }
290
290
 
@@ -503,7 +503,7 @@ function mergeThemes(themes) {
503
503
  return themes.map((theme) => theme ? clone(theme) : {}).reduce((a, b) => mergeDeep(a, b), {});
504
504
  }
505
505
 
506
- const version = "0.53.4";
506
+ const version = "0.53.5";
507
507
 
508
508
  class UnoGenerator {
509
509
  constructor(userConfig = {}, defaults = {}) {
@@ -923,7 +923,7 @@ class UnoGenerator {
923
923
  async stringifyShortcuts(parent, context, expanded, meta = { layer: this.config.shortcutsLayer }) {
924
924
  const selectorMap = new TwoKeyMap();
925
925
  const parsed = (await Promise.all(uniq(expanded).map(async (i) => {
926
- const result = isString(i) ? await this.parseUtil(i, context, true, meta.prefix) : [[Infinity, "{inline}", normalizeCSSEntries(i), void 0, []]];
926
+ const result = isString(i) ? await this.parseUtil(i, context, true, meta.prefix) : [[Number.POSITIVE_INFINITY, "{inline}", normalizeCSSEntries(i), void 0, []]];
927
927
  if (!result)
928
928
  warnOnce(`unmatched utility "${i}" in shortcut "${parent[1]}"`);
929
929
  return result || [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unocss/core",
3
- "version": "0.53.4",
3
+ "version": "0.53.5",
4
4
  "description": "The instant on-demand Atomic CSS engine.",
5
5
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
6
6
  "license": "MIT",
@@ -37,7 +37,7 @@
37
37
  "dist"
38
38
  ],
39
39
  "devDependencies": {
40
- "magic-string": "^0.30.0",
40
+ "magic-string": "^0.30.1",
41
41
  "unconfig": "^0.3.9"
42
42
  },
43
43
  "scripts": {