@unocss/core 0.60.4 → 0.61.2
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 +53 -39
- package/dist/index.d.ts +53 -39
- package/dist/index.mjs +63 -15
- package/package.json +1 -1
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 |
|
|
62
|
-
declare function normalizeCSSValues(obj:
|
|
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
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
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> = (
|
|
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
|
|
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,
|
|
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 |
|
|
62
|
-
declare function normalizeCSSValues(obj:
|
|
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
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
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> = (
|
|
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
|
|
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,
|
|
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.
|
|
605
|
+
const version = "0.61.2";
|
|
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,48 @@ class UnoGenerator {
|
|
|
973
979
|
const match = unprefixed.match(matcher);
|
|
974
980
|
if (!match)
|
|
975
981
|
continue;
|
|
976
|
-
|
|
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((
|
|
984
|
-
if (isString(
|
|
985
|
-
return [i,
|
|
986
|
-
|
|
987
|
-
|
|
1001
|
+
return entries.map((css) => {
|
|
1002
|
+
if (isString(css))
|
|
1003
|
+
return [i, css, meta];
|
|
1004
|
+
let variants = variantHandlers;
|
|
1005
|
+
for (const entry of css) {
|
|
1006
|
+
if (entry[0] === symbols.variants) {
|
|
1007
|
+
variants = [
|
|
1008
|
+
...toArray(entry[1]),
|
|
1009
|
+
...variants
|
|
1010
|
+
];
|
|
1011
|
+
} else if (entry[0] === symbols.parent) {
|
|
1012
|
+
variants = [
|
|
1013
|
+
{ parent: entry[1] },
|
|
1014
|
+
...variants
|
|
1015
|
+
];
|
|
1016
|
+
} else if (entry[0] === symbols.selector) {
|
|
1017
|
+
variants = [
|
|
1018
|
+
{ selector: entry[1] },
|
|
1019
|
+
...variants
|
|
1020
|
+
];
|
|
1021
|
+
}
|
|
1022
|
+
}
|
|
1023
|
+
return [i, raw, css, meta, variants];
|
|
988
1024
|
});
|
|
989
1025
|
}
|
|
990
1026
|
}
|
|
@@ -994,7 +1030,14 @@ class UnoGenerator {
|
|
|
994
1030
|
return;
|
|
995
1031
|
if (isRawUtil(parsed))
|
|
996
1032
|
return [parsed[0], void 0, parsed[1], void 0, parsed[2], this.config.details ? context : void 0, void 0];
|
|
997
|
-
const {
|
|
1033
|
+
const {
|
|
1034
|
+
selector,
|
|
1035
|
+
entries,
|
|
1036
|
+
parent,
|
|
1037
|
+
layer: variantLayer,
|
|
1038
|
+
sort: variantSort,
|
|
1039
|
+
noMerge
|
|
1040
|
+
} = this.applyVariants(parsed);
|
|
998
1041
|
const body = entriesToCss(entries);
|
|
999
1042
|
if (!body)
|
|
1000
1043
|
return;
|
|
@@ -1042,8 +1085,13 @@ class UnoGenerator {
|
|
|
1042
1085
|
}
|
|
1043
1086
|
}
|
|
1044
1087
|
}
|
|
1045
|
-
if (
|
|
1046
|
-
result =
|
|
1088
|
+
if (result) {
|
|
1089
|
+
result = toArray(result).map((s) => {
|
|
1090
|
+
if (isString(s))
|
|
1091
|
+
return expandVariantGroup(s.trim()).split(/\s+/g);
|
|
1092
|
+
return s;
|
|
1093
|
+
}).flat();
|
|
1094
|
+
}
|
|
1047
1095
|
if (!result) {
|
|
1048
1096
|
const [raw, inputWithoutVariant] = isString(input) ? await this.matchVariants(input) : input;
|
|
1049
1097
|
if (raw !== inputWithoutVariant) {
|
|
@@ -1096,8 +1144,8 @@ class UnoGenerator {
|
|
|
1096
1144
|
[e2.filter(([, noMerge]) => !noMerge).map(([entries, , sort]) => [entries, sort]), false]
|
|
1097
1145
|
];
|
|
1098
1146
|
return merges.map(([e3, noMerge]) => [
|
|
1099
|
-
...stringify(false, noMerge, e3.filter(([entries]) => entries.some((entry) => entry[0] ===
|
|
1100
|
-
...stringify(true, noMerge, e3.filter(([entries]) => entries.every((entry) => entry[0] !==
|
|
1147
|
+
...stringify(false, noMerge, e3.filter(([entries]) => entries.some((entry) => entry[0] === symbols.shortcutsNoMerge))),
|
|
1148
|
+
...stringify(true, noMerge, e3.filter(([entries]) => entries.every((entry) => entry[0] !== symbols.shortcutsNoMerge)))
|
|
1101
1149
|
]);
|
|
1102
1150
|
}).flat(2).filter(Boolean)
|
|
1103
1151
|
));
|
|
@@ -1136,4 +1184,4 @@ function defaultVariantHandler(input, next) {
|
|
|
1136
1184
|
return next(input);
|
|
1137
1185
|
}
|
|
1138
1186
|
|
|
1139
|
-
export { BetterMap,
|
|
1187
|
+
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 };
|