@unocss/core 0.60.4 → 0.61.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
@@ -58,8 +58,8 @@ declare function escapeRegExp(string: string): string;
58
58
  declare function escapeSelector(str: string): string;
59
59
  declare const e: typeof escapeSelector;
60
60
 
61
- declare function normalizeCSSEntries(obj: string | CSSEntries | CSSObject): string | CSSEntries;
62
- declare function normalizeCSSValues(obj: CSSValue | string | (CSSValue | string)[]): (string | CSSEntries)[];
61
+ declare function normalizeCSSEntries(obj: string | CSSEntriesInput | CSSObjectInput): string | CSSEntries;
62
+ declare function normalizeCSSValues(obj: CSSValueInput | string | (CSSValueInput | string)[]): (string | CSSEntries)[];
63
63
  declare function clearIdenticalEntries(entry: CSSEntries): CSSEntries;
64
64
  declare function entriesToCss(arr?: CSSEntries): string;
65
65
  declare function isObject(item: any): item is Record<string, any>;
@@ -79,7 +79,6 @@ declare function isString(s: any): s is string;
79
79
  declare const attributifyRE: RegExp;
80
80
  declare const cssIdRE: RegExp;
81
81
  declare const validateFilterRE: RegExp;
82
- declare const CONTROL_SHORTCUT_NO_MERGE = "$$shortcut-no-merge";
83
82
  declare function isAttributifySelector(selector: string): RegExpMatchArray | null;
84
83
  declare function isValidSelector(selector?: string): selector is string;
85
84
  declare function normalizeVariant(variant: Variant<any>): VariantObject<any>;
@@ -133,6 +132,7 @@ declare function expandVariantGroup(str: MagicString, separators?: string[], dep
133
132
 
134
133
  declare function warnOnce(msg: string): void;
135
134
 
135
+ declare const symbols: ControlSymbols;
136
136
  declare class UnoGenerator<Theme extends object = object> {
137
137
  userConfig: UserConfig<Theme>;
138
138
  defaults: UserConfigDefaults<Theme>;
@@ -182,39 +182,11 @@ type FlatObjectTuple<T> = {
182
182
  type PartialByKeys<T, K extends keyof T = keyof T> = FlatObjectTuple<Partial<Pick<T, Extract<keyof T, K>>> & Omit<T, K>>;
183
183
  type RequiredByKey<T, K extends keyof T = keyof T> = FlatObjectTuple<Required<Pick<T, Extract<keyof T, K>>> & Omit<T, K>>;
184
184
  type CSSObject = Record<string, string | number | undefined>;
185
- type CSSEntries = [string, string | number | undefined][];
186
- interface CSSColorValue {
187
- type: string;
188
- components: (string | number)[];
189
- alpha: string | number | undefined;
190
- }
191
- type RGBAColorValue = [number, number, number, number] | [number, number, number];
192
- interface ParsedColorValue {
193
- /**
194
- * Parsed color value.
195
- */
196
- color?: string;
197
- /**
198
- * Parsed opacity value.
199
- */
200
- opacity: string;
201
- /**
202
- * Color name.
203
- */
204
- name: string;
205
- /**
206
- * Color scale, preferably 000 - 999.
207
- */
208
- no: string;
209
- /**
210
- * {@link CSSColorValue}
211
- */
212
- cssColor: CSSColorValue | undefined;
213
- /**
214
- * Parsed alpha value from opacity
215
- */
216
- alpha: string | number | undefined;
217
- }
185
+ type CSSEntry = [string, string | number | undefined];
186
+ type CSSEntries = CSSEntry[];
187
+ type CSSObjectInput = CSSObject | Partial<ControlSymbolsValue>;
188
+ type CSSEntriesInput = (CSSEntry | ControlSymbolsEntry)[];
189
+ type CSSValueInput = CSSObjectInput | CSSEntriesInput | CSSValue;
218
190
  type PresetOptions = Record<string, any>;
219
191
  interface RuleContext<Theme extends object = object> {
220
192
  /**
@@ -230,6 +202,10 @@ interface RuleContext<Theme extends object = object> {
230
202
  * UnoCSS generator instance
231
203
  */
232
204
  generator: UnoGenerator<Theme>;
205
+ /**
206
+ * Symbols for special handling
207
+ */
208
+ symbols: ControlSymbols;
233
209
  /**
234
210
  * The theme object
235
211
  */
@@ -260,6 +236,38 @@ interface RuleContext<Theme extends object = object> {
260
236
  */
261
237
  variants?: Variant<Theme>[];
262
238
  }
239
+ declare const SymbolShortcutsNoMerge: unique symbol;
240
+ declare const SymbolVariants: unique symbol;
241
+ declare const SymbolParent: unique symbol;
242
+ declare const SymbolSelector: unique symbol;
243
+ interface ControlSymbols {
244
+ /**
245
+ * Prevent merging in shortcuts
246
+ */
247
+ shortcutsNoMerge: typeof SymbolShortcutsNoMerge;
248
+ /**
249
+ * Additional variants applied to this rule
250
+ */
251
+ variants: typeof SymbolVariants;
252
+ /**
253
+ * Parent selector (`@media`, `@supports`, etc.)
254
+ */
255
+ parent: typeof SymbolParent;
256
+ /**
257
+ * Selector modifier
258
+ */
259
+ selector: typeof SymbolSelector;
260
+ }
261
+ interface ControlSymbolsValue {
262
+ [SymbolShortcutsNoMerge]: true;
263
+ [SymbolVariants]: VariantHandler[];
264
+ [SymbolParent]: string;
265
+ [SymbolSelector]: (selector: string) => string;
266
+ }
267
+ type ObjectToEntry<T> = {
268
+ [K in keyof T]: [K, T[K]];
269
+ }[keyof T];
270
+ type ControlSymbolsEntry = ObjectToEntry<ControlSymbolsValue>;
263
271
  interface VariantContext<Theme extends object = object> {
264
272
  /**
265
273
  * Unprocessed selector from user input.
@@ -341,7 +349,7 @@ interface RuleMeta {
341
349
  }
342
350
  type CSSValue = CSSObject | CSSEntries;
343
351
  type CSSValues = CSSValue | CSSValue[];
344
- type DynamicMatcher<Theme extends object = object> = ((match: RegExpMatchArray, context: Readonly<RuleContext<Theme>>) => Awaitable<CSSValue | string | (CSSValue | string)[] | undefined>);
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>;
345
353
  type DynamicRule<Theme extends object = object> = [RegExp, DynamicMatcher<Theme>] | [RegExp, DynamicMatcher<Theme>, RuleMeta];
346
354
  type StaticRule = [string, CSSObject | CSSEntries] | [string, CSSObject | CSSEntries, RuleMeta];
347
355
  type Rule<Theme extends object = object> = DynamicRule<Theme> | StaticRule;
@@ -412,7 +420,7 @@ interface VariantHandler {
412
420
  /**
413
421
  * The result rewritten selector for the next round of matching
414
422
  */
415
- matcher: string;
423
+ matcher?: string;
416
424
  /**
417
425
  * Order in which the variant is applied to selector.
418
426
  */
@@ -703,6 +711,12 @@ interface UserOnlyOptions<Theme extends object = object> {
703
711
  * @default 'build'
704
712
  */
705
713
  envMode?: 'dev' | 'build';
714
+ /**
715
+ * legacy.renderModernChunks need to be consistent with @vitejs/plugin-legacy
716
+ */
717
+ legacy?: {
718
+ renderModernChunks: boolean;
719
+ };
706
720
  }
707
721
  /**
708
722
  * For unocss-cli config
@@ -1005,4 +1019,4 @@ declare function mergeConfigs<Theme extends object = object>(configs: UserConfig
1005
1019
  declare function definePreset<Options extends object | undefined = undefined, Theme extends object = object>(preset: PresetFactory<Theme, Options>): PresetFactory<Theme, Options>;
1006
1020
  declare function definePreset<Theme extends object = object>(preset: Preset<Theme>): Preset<Theme>;
1007
1021
 
1008
- export { type ArgumentType, type Arrayable, type AutoCompleteExtractor, type AutoCompleteExtractorContext, type AutoCompleteExtractorResult, type AutoCompleteFunction, type AutoCompleteTemplate, type Awaitable, BetterMap, type BlocklistMeta, type BlocklistRule, type BlocklistValue, CONTROL_SHORTCUT_NO_MERGE, type CSSColorValue, type CSSEntries, type CSSObject, type CSSValue, type CSSValues, type CliEntryItem, type CliOptions, type ConfigBase, type ContentOptions, 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 OutputCssLayersOptions, type ParsedColorValue, 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 RGBAColorValue, 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, toArray, toEscapedSelector, uniq, uniqueBy, validateFilterRE, warnOnce, withLayer };
1022
+ 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
@@ -58,8 +58,8 @@ declare function escapeRegExp(string: string): string;
58
58
  declare function escapeSelector(str: string): string;
59
59
  declare const e: typeof escapeSelector;
60
60
 
61
- declare function normalizeCSSEntries(obj: string | CSSEntries | CSSObject): string | CSSEntries;
62
- declare function normalizeCSSValues(obj: CSSValue | string | (CSSValue | string)[]): (string | CSSEntries)[];
61
+ declare function normalizeCSSEntries(obj: string | CSSEntriesInput | CSSObjectInput): string | CSSEntries;
62
+ declare function normalizeCSSValues(obj: CSSValueInput | string | (CSSValueInput | string)[]): (string | CSSEntries)[];
63
63
  declare function clearIdenticalEntries(entry: CSSEntries): CSSEntries;
64
64
  declare function entriesToCss(arr?: CSSEntries): string;
65
65
  declare function isObject(item: any): item is Record<string, any>;
@@ -79,7 +79,6 @@ declare function isString(s: any): s is string;
79
79
  declare const attributifyRE: RegExp;
80
80
  declare const cssIdRE: RegExp;
81
81
  declare const validateFilterRE: RegExp;
82
- declare const CONTROL_SHORTCUT_NO_MERGE = "$$shortcut-no-merge";
83
82
  declare function isAttributifySelector(selector: string): RegExpMatchArray | null;
84
83
  declare function isValidSelector(selector?: string): selector is string;
85
84
  declare function normalizeVariant(variant: Variant<any>): VariantObject<any>;
@@ -133,6 +132,7 @@ declare function expandVariantGroup(str: MagicString, separators?: string[], dep
133
132
 
134
133
  declare function warnOnce(msg: string): void;
135
134
 
135
+ declare const symbols: ControlSymbols;
136
136
  declare class UnoGenerator<Theme extends object = object> {
137
137
  userConfig: UserConfig<Theme>;
138
138
  defaults: UserConfigDefaults<Theme>;
@@ -182,39 +182,11 @@ type FlatObjectTuple<T> = {
182
182
  type PartialByKeys<T, K extends keyof T = keyof T> = FlatObjectTuple<Partial<Pick<T, Extract<keyof T, K>>> & Omit<T, K>>;
183
183
  type RequiredByKey<T, K extends keyof T = keyof T> = FlatObjectTuple<Required<Pick<T, Extract<keyof T, K>>> & Omit<T, K>>;
184
184
  type CSSObject = Record<string, string | number | undefined>;
185
- type CSSEntries = [string, string | number | undefined][];
186
- interface CSSColorValue {
187
- type: string;
188
- components: (string | number)[];
189
- alpha: string | number | undefined;
190
- }
191
- type RGBAColorValue = [number, number, number, number] | [number, number, number];
192
- interface ParsedColorValue {
193
- /**
194
- * Parsed color value.
195
- */
196
- color?: string;
197
- /**
198
- * Parsed opacity value.
199
- */
200
- opacity: string;
201
- /**
202
- * Color name.
203
- */
204
- name: string;
205
- /**
206
- * Color scale, preferably 000 - 999.
207
- */
208
- no: string;
209
- /**
210
- * {@link CSSColorValue}
211
- */
212
- cssColor: CSSColorValue | undefined;
213
- /**
214
- * Parsed alpha value from opacity
215
- */
216
- alpha: string | number | undefined;
217
- }
185
+ type CSSEntry = [string, string | number | undefined];
186
+ type CSSEntries = CSSEntry[];
187
+ type CSSObjectInput = CSSObject | Partial<ControlSymbolsValue>;
188
+ type CSSEntriesInput = (CSSEntry | ControlSymbolsEntry)[];
189
+ type CSSValueInput = CSSObjectInput | CSSEntriesInput | CSSValue;
218
190
  type PresetOptions = Record<string, any>;
219
191
  interface RuleContext<Theme extends object = object> {
220
192
  /**
@@ -230,6 +202,10 @@ interface RuleContext<Theme extends object = object> {
230
202
  * UnoCSS generator instance
231
203
  */
232
204
  generator: UnoGenerator<Theme>;
205
+ /**
206
+ * Symbols for special handling
207
+ */
208
+ symbols: ControlSymbols;
233
209
  /**
234
210
  * The theme object
235
211
  */
@@ -260,6 +236,38 @@ interface RuleContext<Theme extends object = object> {
260
236
  */
261
237
  variants?: Variant<Theme>[];
262
238
  }
239
+ declare const SymbolShortcutsNoMerge: unique symbol;
240
+ declare const SymbolVariants: unique symbol;
241
+ declare const SymbolParent: unique symbol;
242
+ declare const SymbolSelector: unique symbol;
243
+ interface ControlSymbols {
244
+ /**
245
+ * Prevent merging in shortcuts
246
+ */
247
+ shortcutsNoMerge: typeof SymbolShortcutsNoMerge;
248
+ /**
249
+ * Additional variants applied to this rule
250
+ */
251
+ variants: typeof SymbolVariants;
252
+ /**
253
+ * Parent selector (`@media`, `@supports`, etc.)
254
+ */
255
+ parent: typeof SymbolParent;
256
+ /**
257
+ * Selector modifier
258
+ */
259
+ selector: typeof SymbolSelector;
260
+ }
261
+ interface ControlSymbolsValue {
262
+ [SymbolShortcutsNoMerge]: true;
263
+ [SymbolVariants]: VariantHandler[];
264
+ [SymbolParent]: string;
265
+ [SymbolSelector]: (selector: string) => string;
266
+ }
267
+ type ObjectToEntry<T> = {
268
+ [K in keyof T]: [K, T[K]];
269
+ }[keyof T];
270
+ type ControlSymbolsEntry = ObjectToEntry<ControlSymbolsValue>;
263
271
  interface VariantContext<Theme extends object = object> {
264
272
  /**
265
273
  * Unprocessed selector from user input.
@@ -341,7 +349,7 @@ interface RuleMeta {
341
349
  }
342
350
  type CSSValue = CSSObject | CSSEntries;
343
351
  type CSSValues = CSSValue | CSSValue[];
344
- type DynamicMatcher<Theme extends object = object> = ((match: RegExpMatchArray, context: Readonly<RuleContext<Theme>>) => Awaitable<CSSValue | string | (CSSValue | string)[] | undefined>);
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>;
345
353
  type DynamicRule<Theme extends object = object> = [RegExp, DynamicMatcher<Theme>] | [RegExp, DynamicMatcher<Theme>, RuleMeta];
346
354
  type StaticRule = [string, CSSObject | CSSEntries] | [string, CSSObject | CSSEntries, RuleMeta];
347
355
  type Rule<Theme extends object = object> = DynamicRule<Theme> | StaticRule;
@@ -412,7 +420,7 @@ interface VariantHandler {
412
420
  /**
413
421
  * The result rewritten selector for the next round of matching
414
422
  */
415
- matcher: string;
423
+ matcher?: string;
416
424
  /**
417
425
  * Order in which the variant is applied to selector.
418
426
  */
@@ -703,6 +711,12 @@ interface UserOnlyOptions<Theme extends object = object> {
703
711
  * @default 'build'
704
712
  */
705
713
  envMode?: 'dev' | 'build';
714
+ /**
715
+ * legacy.renderModernChunks need to be consistent with @vitejs/plugin-legacy
716
+ */
717
+ legacy?: {
718
+ renderModernChunks: boolean;
719
+ };
706
720
  }
707
721
  /**
708
722
  * For unocss-cli config
@@ -1005,4 +1019,4 @@ declare function mergeConfigs<Theme extends object = object>(configs: UserConfig
1005
1019
  declare function definePreset<Options extends object | undefined = undefined, Theme extends object = object>(preset: PresetFactory<Theme, Options>): PresetFactory<Theme, Options>;
1006
1020
  declare function definePreset<Theme extends object = object>(preset: Preset<Theme>): Preset<Theme>;
1007
1021
 
1008
- export { type ArgumentType, type Arrayable, type AutoCompleteExtractor, type AutoCompleteExtractorContext, type AutoCompleteExtractorResult, type AutoCompleteFunction, type AutoCompleteTemplate, type Awaitable, BetterMap, type BlocklistMeta, type BlocklistRule, type BlocklistValue, CONTROL_SHORTCUT_NO_MERGE, type CSSColorValue, type CSSEntries, type CSSObject, type CSSValue, type CSSValues, type CliEntryItem, type CliOptions, type ConfigBase, type ContentOptions, 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 OutputCssLayersOptions, type ParsedColorValue, 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 RGBAColorValue, 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, toArray, toEscapedSelector, uniq, uniqueBy, validateFilterRE, warnOnce, withLayer };
1022
+ 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
@@ -155,7 +155,6 @@ function isStaticShortcut(sc) {
155
155
  const attributifyRE = /^\[(.+?)~?="(.*)"\]$/;
156
156
  const cssIdRE = /\.(css|postcss|sass|scss|less|stylus|styl)($|\?)/;
157
157
  const validateFilterRE = /[\w\u00A0-\uFFFF%-?]/;
158
- const CONTROL_SHORTCUT_NO_MERGE = "$$shortcut-no-merge";
159
158
  function isAttributifySelector(selector) {
160
159
  return selector.match(attributifyRE);
161
160
  }
@@ -603,7 +602,7 @@ function definePreset(preset) {
603
602
  return preset;
604
603
  }
605
604
 
606
- const version = "0.60.4";
605
+ const version = "0.61.0";
607
606
 
608
607
  var __defProp = Object.defineProperty;
609
608
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
@@ -611,6 +610,12 @@ var __publicField = (obj, key, value) => {
611
610
  __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
612
611
  return value;
613
612
  };
613
+ const symbols = {
614
+ shortcutsNoMerge: "$$symbol-shortcut-no-merge",
615
+ variants: "$$symbol-variants",
616
+ parent: "$$symbol-parent",
617
+ selector: "$$symbol-selector"
618
+ };
614
619
  class UnoGenerator {
615
620
  constructor(userConfig = {}, defaults = {}) {
616
621
  this.userConfig = userConfig;
@@ -664,6 +669,7 @@ class UnoGenerator {
664
669
  currentSelector: applied[1],
665
670
  theme: this.config.theme,
666
671
  generator: this,
672
+ symbols,
667
673
  variantHandlers: applied[2],
668
674
  constructCSS: (...args) => this.constructCustomCSS(context, ...args),
669
675
  variantMatch: applied
@@ -868,7 +874,7 @@ class UnoGenerator {
868
874
  continue;
869
875
  handler = { matcher: handler };
870
876
  }
871
- processed = handler.matcher;
877
+ processed = handler.matcher ?? processed;
872
878
  handlers.unshift(handler);
873
879
  variants.add(v);
874
880
  applied = true;
@@ -973,18 +979,49 @@ class UnoGenerator {
973
979
  const match = unprefixed.match(matcher);
974
980
  if (!match)
975
981
  continue;
976
- const result = await handler(match, context);
982
+ let result = await handler(match, context);
977
983
  if (!result)
978
984
  continue;
979
985
  if (this.config.details)
980
986
  context.rules.push([matcher, handler, meta]);
987
+ if (typeof result !== "string") {
988
+ if (Symbol.asyncIterator in result) {
989
+ const entries2 = [];
990
+ for await (const r of result) {
991
+ if (r)
992
+ entries2.push(r);
993
+ }
994
+ result = entries2;
995
+ } else if (Symbol.iterator in result && !Array.isArray(result)) {
996
+ result = Array.from(result).filter(notNull);
997
+ }
998
+ }
981
999
  const entries = normalizeCSSValues(result).filter((i2) => i2.length);
982
1000
  if (entries.length) {
983
- return entries.map((e2) => {
984
- if (isString(e2))
985
- return [i, e2, meta];
986
- else
987
- return [i, raw, e2, meta, variantHandlers];
1001
+ return entries.map((css) => {
1002
+ if (isString(css)) {
1003
+ return [i, css, meta];
1004
+ }
1005
+ let variants = variantHandlers;
1006
+ for (const entry of css) {
1007
+ if (entry[0] === symbols.variants) {
1008
+ variants = [
1009
+ ...toArray(entry[1]),
1010
+ ...variants
1011
+ ];
1012
+ } else if (entry[0] === symbols.parent) {
1013
+ variants = [
1014
+ { parent: entry[1] },
1015
+ ...variants
1016
+ ];
1017
+ } else if (entry[0] === symbols.selector) {
1018
+ variants = [
1019
+ { selector: entry[1] },
1020
+ ...variants
1021
+ ];
1022
+ }
1023
+ }
1024
+ return [i, raw, css, meta, variants];
988
1025
  });
989
1026
  }
990
1027
  }
@@ -994,7 +1031,14 @@ class UnoGenerator {
994
1031
  return;
995
1032
  if (isRawUtil(parsed))
996
1033
  return [parsed[0], void 0, parsed[1], void 0, parsed[2], this.config.details ? context : void 0, void 0];
997
- const { selector, entries, parent, layer: variantLayer, sort: variantSort, noMerge } = this.applyVariants(parsed);
1034
+ const {
1035
+ selector,
1036
+ entries,
1037
+ parent,
1038
+ layer: variantLayer,
1039
+ sort: variantSort,
1040
+ noMerge
1041
+ } = this.applyVariants(parsed);
998
1042
  const body = entriesToCss(entries);
999
1043
  if (!body)
1000
1044
  return;
@@ -1096,8 +1140,8 @@ class UnoGenerator {
1096
1140
  [e2.filter(([, noMerge]) => !noMerge).map(([entries, , sort]) => [entries, sort]), false]
1097
1141
  ];
1098
1142
  return merges.map(([e3, noMerge]) => [
1099
- ...stringify(false, noMerge, e3.filter(([entries]) => entries.some((entry) => entry[0] === CONTROL_SHORTCUT_NO_MERGE))),
1100
- ...stringify(true, noMerge, e3.filter(([entries]) => entries.every((entry) => entry[0] !== CONTROL_SHORTCUT_NO_MERGE)))
1143
+ ...stringify(false, noMerge, e3.filter(([entries]) => entries.some((entry) => entry[0] === symbols.shortcutsNoMerge))),
1144
+ ...stringify(true, noMerge, e3.filter(([entries]) => entries.every((entry) => entry[0] !== symbols.shortcutsNoMerge)))
1101
1145
  ]);
1102
1146
  }).flat(2).filter(Boolean)
1103
1147
  ));
@@ -1136,4 +1180,4 @@ function defaultVariantHandler(input, next) {
1136
1180
  return next(input);
1137
1181
  }
1138
1182
 
1139
- export { BetterMap, CONTROL_SHORTCUT_NO_MERGE, CountableSet, TwoKeyMap, UnoGenerator, 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, toArray, toEscapedSelector, uniq, uniqueBy, validateFilterRE, warnOnce, withLayer };
1183
+ export { BetterMap, CountableSet, TwoKeyMap, UnoGenerator, 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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@unocss/core",
3
3
  "type": "module",
4
- "version": "0.60.4",
4
+ "version": "0.61.0",
5
5
  "description": "The instant on-demand Atomic CSS engine.",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",