@unocss/core 66.5.10-beta.1 → 66.5.11
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 +860 -885
- package/dist/index.mjs +1117 -1214
- package/package.json +5 -6
- package/dist/index.d.ts +0 -1137
package/dist/index.d.mts
CHANGED
|
@@ -1,77 +1,79 @@
|
|
|
1
|
-
import MagicString from
|
|
2
|
-
import { LoadConfigResult } from
|
|
1
|
+
import MagicString from "magic-string";
|
|
2
|
+
import { LoadConfigResult } from "unconfig";
|
|
3
3
|
|
|
4
|
+
//#region src/utils/basic.d.ts
|
|
4
5
|
declare function toArray<T>(value?: T | T[]): T[];
|
|
5
6
|
declare function uniq<T>(value: T[]): T[];
|
|
6
7
|
declare function uniqueBy<T>(array: readonly T[], equalFn: (a: T, b: T) => boolean): T[];
|
|
7
8
|
declare function isString(s: any): s is string;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
9
|
+
//#endregion
|
|
10
|
+
//#region src/utils/countable-set.d.ts
|
|
11
|
+
declare class CountableSet<K$1> extends Set<K$1> {
|
|
12
|
+
_map: Map<K$1, number>;
|
|
13
|
+
constructor(values?: Iterable<K$1>);
|
|
14
|
+
add(key: K$1): this;
|
|
15
|
+
delete(key: K$1): boolean;
|
|
16
|
+
clear(): void;
|
|
17
|
+
getCount(key: K$1): number;
|
|
18
|
+
setCount(key: K$1, count: number): this;
|
|
17
19
|
}
|
|
18
20
|
declare function isCountableSet<T = string>(value: any): value is CountableSet<T>;
|
|
19
|
-
|
|
21
|
+
//#endregion
|
|
22
|
+
//#region src/utils/escape.d.ts
|
|
20
23
|
declare function escapeRegExp(string: string): string;
|
|
21
24
|
/**
|
|
22
25
|
* CSS Selector Escape
|
|
23
26
|
*/
|
|
24
27
|
declare function escapeSelector(str: string): string;
|
|
25
28
|
declare const e: typeof escapeSelector;
|
|
26
|
-
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region src/utils/events.d.ts
|
|
27
31
|
type EventsMap = Record<string, any>;
|
|
28
32
|
interface DefaultEvents extends EventsMap {
|
|
29
|
-
|
|
33
|
+
[event: string]: (...args: any) => void;
|
|
30
34
|
}
|
|
31
35
|
interface Unsubscribe {
|
|
32
|
-
|
|
36
|
+
(): void;
|
|
33
37
|
}
|
|
34
38
|
declare class Emitter<Events extends EventsMap = DefaultEvents> {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
*/
|
|
74
|
-
emit<K extends keyof Events>(this: this, event: K, ...args: Parameters<Events[K]>): void;
|
|
39
|
+
/**
|
|
40
|
+
* Event names in keys and arrays with listeners in values.
|
|
41
|
+
*
|
|
42
|
+
* ```js
|
|
43
|
+
* emitter1.events = emitter2.events
|
|
44
|
+
* emitter2.events = { }
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
events: Partial<{ [E in keyof Events]: Events[E][] }>;
|
|
48
|
+
/**
|
|
49
|
+
* Add a listener for a given event.
|
|
50
|
+
*
|
|
51
|
+
* ```js
|
|
52
|
+
* const unbind = ee.on('tick', (tickType, tickDuration) => {
|
|
53
|
+
* count += 1
|
|
54
|
+
* })
|
|
55
|
+
*
|
|
56
|
+
* disable () {
|
|
57
|
+
* unbind()
|
|
58
|
+
* }
|
|
59
|
+
* ```
|
|
60
|
+
*
|
|
61
|
+
* @param event The event name.
|
|
62
|
+
* @param cb The listener function.
|
|
63
|
+
* @returns Unbind listener from event.
|
|
64
|
+
*/
|
|
65
|
+
on<K$1 extends keyof Events>(this: this, event: K$1, cb: Events[K$1]): Unsubscribe;
|
|
66
|
+
/**
|
|
67
|
+
* Calls each of the listeners registered for a given event.
|
|
68
|
+
*
|
|
69
|
+
* ```js
|
|
70
|
+
* ee.emit('tick', tickType, tickDuration)
|
|
71
|
+
* ```
|
|
72
|
+
*
|
|
73
|
+
* @param event The event name.
|
|
74
|
+
* @param args The arguments for listeners.
|
|
75
|
+
*/
|
|
76
|
+
emit<K$1 extends keyof Events>(this: this, event: K$1, ...args: Parameters<Events[K$1]>): void;
|
|
75
77
|
}
|
|
76
78
|
/**
|
|
77
79
|
* Create event emitter.
|
|
@@ -93,7 +95,8 @@ declare class Emitter<Events extends EventsMap = DefaultEvents> {
|
|
|
93
95
|
* ```
|
|
94
96
|
*/
|
|
95
97
|
declare function createNanoEvents<Events extends EventsMap = DefaultEvents>(): Emitter<Events>;
|
|
96
|
-
|
|
98
|
+
//#endregion
|
|
99
|
+
//#region src/utils/helpers.d.ts
|
|
97
100
|
declare const attributifyRE: RegExp;
|
|
98
101
|
declare const cssIdRE: RegExp;
|
|
99
102
|
declare const validateFilterRE: RegExp;
|
|
@@ -103,25 +106,28 @@ declare function normalizeVariant(variant: Variant<any>): VariantObject<any>;
|
|
|
103
106
|
declare function isRawUtil(util: ParsedUtil | RawUtil | StringifiedUtil): util is RawUtil;
|
|
104
107
|
declare function notNull<T>(value: T | null | undefined): value is T;
|
|
105
108
|
declare function noop(): void;
|
|
106
|
-
|
|
109
|
+
//#endregion
|
|
110
|
+
//#region src/utils/layer.d.ts
|
|
107
111
|
declare function withLayer<T extends object>(layer: string, rules: Rule<T>[]): Rule<T>[];
|
|
108
|
-
|
|
112
|
+
//#endregion
|
|
113
|
+
//#region src/utils/map.d.ts
|
|
109
114
|
declare class TwoKeyMap<K1, K2, V> {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
115
|
+
_map: Map<K1, Map<K2, V>>;
|
|
116
|
+
get(key1: K1, key2: K2): V | undefined;
|
|
117
|
+
getFallback(key1: K1, key2: K2, fallback: V): V;
|
|
118
|
+
set(key1: K1, key2: K2, value: V): this;
|
|
119
|
+
has(key1: K1, key2: K2): boolean | undefined;
|
|
120
|
+
delete(key1: K1, key2: K2): boolean;
|
|
121
|
+
deleteTop(key1: K1): boolean;
|
|
122
|
+
map<T>(fn: (v: V, k1: K1, k2: K2) => T): T[];
|
|
118
123
|
}
|
|
119
|
-
declare class BetterMap<K, V> extends Map<K, V> {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
124
|
+
declare class BetterMap<K$1, V> extends Map<K$1, V> {
|
|
125
|
+
getFallback(key: K$1, fallback: V): V;
|
|
126
|
+
map<R>(mapFn: (value: V, key: K$1) => R): R[];
|
|
127
|
+
flatMap<R extends readonly unknown[]>(mapFn: (value: V, key: K$1) => R): R[number][];
|
|
123
128
|
}
|
|
124
|
-
|
|
129
|
+
//#endregion
|
|
130
|
+
//#region src/utils/object.d.ts
|
|
125
131
|
declare function normalizeCSSEntries(obj: string | CSSEntriesInput | CSSObjectInput): string | CSSEntries;
|
|
126
132
|
declare function normalizeCSSValues(obj: CSSValueInput | string | (CSSValueInput | string)[]): (string | CSSEntries)[];
|
|
127
133
|
declare function clearIdenticalEntries(entry: CSSEntries): CSSEntries;
|
|
@@ -135,82 +141,82 @@ declare function mergeDeep<T>(original: T, patch: DeepPartial<T>, mergeArray?: b
|
|
|
135
141
|
declare function clone<T>(val: T): T;
|
|
136
142
|
declare function isStaticRule(rule: Rule<any>): rule is StaticRule;
|
|
137
143
|
declare function isStaticShortcut(sc: Shortcut<any>): sc is StaticShortcut;
|
|
138
|
-
|
|
144
|
+
//#endregion
|
|
145
|
+
//#region src/utils/variant-group.d.ts
|
|
139
146
|
declare function makeRegexClassGroup(separators?: string[]): RegExp;
|
|
140
147
|
interface VariantGroup {
|
|
141
|
-
|
|
142
|
-
|
|
148
|
+
length: number;
|
|
149
|
+
items: HighlightAnnotation[];
|
|
143
150
|
}
|
|
144
151
|
declare function parseVariantGroup(str: string | MagicString, separators?: string[], depth?: number): {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
152
|
+
prefixes: string[];
|
|
153
|
+
hasChanged: boolean;
|
|
154
|
+
groupsByOffset: Map<number, VariantGroup>;
|
|
155
|
+
readonly expanded: string;
|
|
149
156
|
};
|
|
150
157
|
declare function collapseVariantGroup(str: string, prefixes: string[]): string;
|
|
151
158
|
declare function expandVariantGroup(str: string, separators?: string[], depth?: number): string;
|
|
152
159
|
declare function expandVariantGroup(str: MagicString, separators?: string[], depth?: number): MagicString;
|
|
153
|
-
|
|
160
|
+
//#endregion
|
|
161
|
+
//#region src/utils/warn.d.ts
|
|
154
162
|
declare function warnOnce(msg: string): void;
|
|
155
|
-
|
|
163
|
+
//#endregion
|
|
164
|
+
//#region src/generator.d.ts
|
|
156
165
|
declare const symbols: ControlSymbols;
|
|
157
166
|
declare class UnoGeneratorInternal<Theme extends object = object> {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
167
|
+
userConfig: UserConfig<Theme>;
|
|
168
|
+
defaults: UserConfigDefaults<Theme>;
|
|
169
|
+
readonly version: string;
|
|
170
|
+
readonly events: Emitter<{
|
|
171
|
+
config: (config: ResolvedConfig<Theme>) => void;
|
|
172
|
+
}>;
|
|
173
|
+
config: ResolvedConfig<Theme>;
|
|
174
|
+
cache: Map<string, StringifiedUtil<Theme>[] | null>;
|
|
175
|
+
blocked: Set<string>;
|
|
176
|
+
parentOrders: Map<string, number>;
|
|
177
|
+
activatedRules: Set<Rule<Theme>>;
|
|
178
|
+
protected constructor(userConfig?: UserConfig<Theme>, defaults?: UserConfigDefaults<Theme>);
|
|
179
|
+
static create<Theme extends object = object>(userConfig?: UserConfig<Theme>, defaults?: UserConfigDefaults<Theme>): Promise<UnoGeneratorInternal<Theme>>;
|
|
180
|
+
setConfig(userConfig?: UserConfig<Theme>, defaults?: UserConfigDefaults<Theme>): Promise<void>;
|
|
181
|
+
applyExtractors(code: string, id?: string, extracted?: Set<string>): Promise<Set<string>>;
|
|
182
|
+
applyExtractors(code: string, id?: string, extracted?: CountableSet<string>): Promise<CountableSet<string>>;
|
|
183
|
+
makeContext(raw: string, applied: VariantMatchedResult<Theme>): RuleContext<Theme>;
|
|
184
|
+
parseToken(raw: string, alias?: string): Promise<StringifiedUtil<Theme>[] | undefined | null>;
|
|
185
|
+
generate(input: string | Set<string> | CountableSet<string> | string[], options?: GenerateOptions<false>): Promise<GenerateResult<Set<string>>>;
|
|
186
|
+
generate(input: string | Set<string> | CountableSet<string> | string[], options?: GenerateOptions<true>): Promise<GenerateResult<Map<string, ExtendedTokenInfo<Theme>>>>;
|
|
187
|
+
matchVariants(raw: string, current?: string): Promise<readonly VariantMatchedResult<Theme>[]>;
|
|
188
|
+
private applyVariants;
|
|
189
|
+
constructCustomCSS(context: Readonly<RuleContext<Theme>>, body: CSSObject | CSSEntries, overrideSelector?: string): string;
|
|
190
|
+
parseUtil(input: string | VariantMatchedResult<Theme>, context: RuleContext<Theme>, internal?: boolean, shortcutPrefix?: string | string[] | undefined): Promise<(ParsedUtil | RawUtil)[] | undefined>;
|
|
191
|
+
private resolveCSSResult;
|
|
192
|
+
stringifyUtil(parsed?: ParsedUtil | RawUtil, context?: RuleContext<Theme>): StringifiedUtil<Theme>[] | undefined;
|
|
193
|
+
expandShortcut(input: string, context: RuleContext<Theme>, depth?: number): Promise<[(string | ShortcutInlineValue)[], RuleMeta | undefined] | undefined>;
|
|
194
|
+
stringifyShortcuts(parent: VariantMatchedResult<Theme>, context: RuleContext<Theme>, expanded: (string | ShortcutInlineValue)[], meta?: RuleMeta): Promise<StringifiedUtil<Theme>[] | undefined>;
|
|
195
|
+
isBlocked(raw: string): boolean;
|
|
196
|
+
getBlocked(raw: string): [BlocklistValue, BlocklistMeta | undefined] | undefined;
|
|
188
197
|
}
|
|
189
198
|
declare class UnoGenerator<Theme extends object = object> extends UnoGeneratorInternal<Theme> {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
199
|
+
/**
|
|
200
|
+
* @deprecated `new UnoGenerator` is deprecated, please use `createGenerator()` instead
|
|
201
|
+
*/
|
|
202
|
+
constructor(userConfig?: UserConfig<Theme>, defaults?: UserConfigDefaults<Theme>);
|
|
194
203
|
}
|
|
195
204
|
declare function createGenerator<Theme extends object = object>(config?: UserConfig<Theme>, defaults?: UserConfigDefaults<Theme>): Promise<UnoGenerator<Theme>>;
|
|
196
205
|
declare const regexScopePlaceholder: RegExp;
|
|
197
206
|
declare function hasScopePlaceholder(css: string): boolean;
|
|
198
207
|
declare function toEscapedSelector(raw: string): string;
|
|
199
|
-
|
|
208
|
+
//#endregion
|
|
209
|
+
//#region src/types.d.ts
|
|
200
210
|
type Awaitable<T> = T | Promise<T>;
|
|
201
211
|
type Arrayable<T> = T | T[];
|
|
202
212
|
type ToArray<T> = T extends (infer U)[] ? U[] : T[];
|
|
203
213
|
type ArgumentType<T> = T extends ((...args: infer A) => any) ? A : never;
|
|
204
214
|
type Shift<T> = T extends [_: any, ...args: infer A] ? A : never;
|
|
205
215
|
type RestArgs<T> = Shift<ArgumentType<T>>;
|
|
206
|
-
type DeepPartial<T> = {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
type
|
|
210
|
-
[K in keyof T]: T[K];
|
|
211
|
-
};
|
|
212
|
-
type PartialByKeys<T, K extends keyof T = keyof T> = FlatObjectTuple<Partial<Pick<T, Extract<keyof T, K>>> & Omit<T, K>>;
|
|
213
|
-
type RequiredByKey<T, K extends keyof T = keyof T> = FlatObjectTuple<Required<Pick<T, Extract<keyof T, K>>> & Omit<T, K>>;
|
|
216
|
+
type DeepPartial<T> = { [P in keyof T]?: DeepPartial<T[P]> };
|
|
217
|
+
type FlatObjectTuple<T> = { [K in keyof T]: T[K] };
|
|
218
|
+
type PartialByKeys<T, K$1 extends keyof T = keyof T> = FlatObjectTuple<Partial<Pick<T, Extract<keyof T, K$1>>> & Omit<T, K$1>>;
|
|
219
|
+
type RequiredByKey<T, K$1 extends keyof T = keyof T> = FlatObjectTuple<Required<Pick<T, Extract<keyof T, K$1>>> & Omit<T, K$1>>;
|
|
214
220
|
type CSSObject = Record<string, string | number | undefined>;
|
|
215
221
|
/**
|
|
216
222
|
* [property, value, operators?]
|
|
@@ -224,52 +230,52 @@ type CSSEntriesInput = (CSSEntry | ControlSymbolsEntry)[];
|
|
|
224
230
|
type CSSValueInput = CSSObjectInput | CSSEntriesInput | CSSValue;
|
|
225
231
|
type PresetOptions = Record<string, any>;
|
|
226
232
|
interface RuleContext<Theme extends object = object> {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
233
|
+
/**
|
|
234
|
+
* Unprocessed selector from user input.
|
|
235
|
+
* Useful for generating CSS rule.
|
|
236
|
+
*/
|
|
237
|
+
rawSelector: string;
|
|
238
|
+
/**
|
|
239
|
+
* Current selector for rule matching
|
|
240
|
+
*/
|
|
241
|
+
currentSelector: string;
|
|
242
|
+
/**
|
|
243
|
+
* UnoCSS generator instance
|
|
244
|
+
*/
|
|
245
|
+
generator: UnoGenerator<Theme>;
|
|
246
|
+
/**
|
|
247
|
+
* Symbols for special handling
|
|
248
|
+
*/
|
|
249
|
+
symbols: ControlSymbols;
|
|
250
|
+
/**
|
|
251
|
+
* The theme object
|
|
252
|
+
*/
|
|
253
|
+
theme: Theme;
|
|
254
|
+
/**
|
|
255
|
+
* Matched variants handlers for this rule.
|
|
256
|
+
*/
|
|
257
|
+
variantHandlers: VariantHandler[];
|
|
258
|
+
/**
|
|
259
|
+
* The result of variant matching.
|
|
260
|
+
*/
|
|
261
|
+
variantMatch: VariantMatchedResult<Theme>;
|
|
262
|
+
/**
|
|
263
|
+
* Construct a custom CSS rule.
|
|
264
|
+
* Variants and selector escaping will be handled automatically.
|
|
265
|
+
*/
|
|
266
|
+
constructCSS: (body: CSSEntries | CSSObject, overrideSelector?: string) => string;
|
|
267
|
+
/**
|
|
268
|
+
* Available only when `details` option is enabled.
|
|
269
|
+
*/
|
|
270
|
+
rules?: Rule<Theme>[];
|
|
271
|
+
/**
|
|
272
|
+
* Available only when `details` option is enabled.
|
|
273
|
+
*/
|
|
274
|
+
shortcuts?: Shortcut<Theme>[];
|
|
275
|
+
/**
|
|
276
|
+
* Available only when `details` option is enabled.
|
|
277
|
+
*/
|
|
278
|
+
variants?: Variant<Theme>[];
|
|
273
279
|
}
|
|
274
280
|
declare const SymbolShortcutsNoMerge: unique symbol;
|
|
275
281
|
declare const SymbolNoMerge: unique symbol;
|
|
@@ -280,143 +286,139 @@ declare const SymbolLayer: unique symbol;
|
|
|
280
286
|
declare const SymbolSort: unique symbol;
|
|
281
287
|
declare const SymbolBody: unique symbol;
|
|
282
288
|
interface ControlSymbols {
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
289
|
+
/**
|
|
290
|
+
* Prevent merging in shortcuts
|
|
291
|
+
*/
|
|
292
|
+
shortcutsNoMerge: typeof SymbolShortcutsNoMerge;
|
|
293
|
+
/**
|
|
294
|
+
* Prevent merging in rules
|
|
295
|
+
*/
|
|
296
|
+
noMerge: typeof SymbolNoMerge;
|
|
297
|
+
/**
|
|
298
|
+
* Additional variants applied to this rule
|
|
299
|
+
*/
|
|
300
|
+
variants: typeof SymbolVariants;
|
|
301
|
+
/**
|
|
302
|
+
* Parent selector (`@media`, `@supports`, etc.)
|
|
303
|
+
*/
|
|
304
|
+
parent: typeof SymbolParent;
|
|
305
|
+
/**
|
|
306
|
+
* Selector modifier
|
|
307
|
+
*/
|
|
308
|
+
selector: typeof SymbolSelector;
|
|
309
|
+
/**
|
|
310
|
+
* Layer modifier
|
|
311
|
+
*/
|
|
312
|
+
layer: typeof SymbolLayer;
|
|
313
|
+
/**
|
|
314
|
+
* Sort modifier
|
|
315
|
+
*/
|
|
316
|
+
sort: typeof SymbolSort;
|
|
317
|
+
/**
|
|
318
|
+
* Custom css body modifier
|
|
319
|
+
*/
|
|
320
|
+
body: typeof SymbolBody;
|
|
315
321
|
}
|
|
316
322
|
interface ControlSymbolsValue {
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
323
|
+
[SymbolShortcutsNoMerge]: true;
|
|
324
|
+
[SymbolNoMerge]: true;
|
|
325
|
+
[SymbolVariants]: VariantHandler[] | ((handlers: VariantHandler[]) => VariantHandler[]);
|
|
326
|
+
[SymbolParent]: string;
|
|
327
|
+
[SymbolSelector]: (selector: string) => string;
|
|
328
|
+
[SymbolLayer]: string;
|
|
329
|
+
[SymbolSort]: number;
|
|
330
|
+
[SymbolBody]: string;
|
|
325
331
|
}
|
|
326
|
-
type ObjectToEntry<T> = {
|
|
327
|
-
[K in keyof T]: [K, T[K]];
|
|
328
|
-
}[keyof T];
|
|
332
|
+
type ObjectToEntry<T> = { [K in keyof T]: [K, T[K]] }[keyof T];
|
|
329
333
|
type ControlSymbolsEntry = ObjectToEntry<ControlSymbolsValue>;
|
|
330
334
|
interface VariantContext<Theme extends object = object> {
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
335
|
+
/**
|
|
336
|
+
* Unprocessed selector from user input.
|
|
337
|
+
*/
|
|
338
|
+
rawSelector: string;
|
|
339
|
+
/**
|
|
340
|
+
* UnoCSS generator instance
|
|
341
|
+
*/
|
|
342
|
+
generator: UnoGenerator<Theme>;
|
|
343
|
+
/**
|
|
344
|
+
* The theme object
|
|
345
|
+
*/
|
|
346
|
+
theme: Theme;
|
|
343
347
|
}
|
|
344
348
|
interface ExtractorContext {
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
349
|
+
readonly original: string;
|
|
350
|
+
code: string;
|
|
351
|
+
id?: string;
|
|
352
|
+
extracted: Set<string> | CountableSet<string>;
|
|
353
|
+
envMode?: 'dev' | 'build';
|
|
350
354
|
}
|
|
351
355
|
interface BaseContext<Theme extends object = object> {
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
}
|
|
361
|
-
interface PreflightContext<Theme extends object = object> extends BaseContext<Theme> {
|
|
362
|
-
}
|
|
363
|
-
interface SafeListContext<Theme extends object = object> extends BaseContext<Theme> {
|
|
356
|
+
/**
|
|
357
|
+
* UnoCSS generator instance
|
|
358
|
+
*/
|
|
359
|
+
generator: UnoGenerator<Theme>;
|
|
360
|
+
/**
|
|
361
|
+
* The theme object
|
|
362
|
+
*/
|
|
363
|
+
theme: Theme;
|
|
364
364
|
}
|
|
365
|
+
interface PreflightContext<Theme extends object = object> extends BaseContext<Theme> {}
|
|
366
|
+
interface SafeListContext<Theme extends object = object> extends BaseContext<Theme> {}
|
|
365
367
|
interface Extractor {
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
368
|
+
name: string;
|
|
369
|
+
order?: number;
|
|
370
|
+
/**
|
|
371
|
+
* Extract the code and return a list of selectors.
|
|
372
|
+
*
|
|
373
|
+
* Return `undefined` to skip this extractor.
|
|
374
|
+
*/
|
|
375
|
+
extract?: (ctx: ExtractorContext) => Awaitable<Set<string> | CountableSet<string> | string[] | undefined | void>;
|
|
374
376
|
}
|
|
375
377
|
interface RuleMeta {
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
378
|
+
/**
|
|
379
|
+
* The layer name of this rule.
|
|
380
|
+
* @default 'default'
|
|
381
|
+
*/
|
|
382
|
+
layer?: string;
|
|
383
|
+
/**
|
|
384
|
+
* Option to not merge this selector even if the body are the same.
|
|
385
|
+
* @default false
|
|
386
|
+
*/
|
|
387
|
+
noMerge?: boolean;
|
|
388
|
+
/**
|
|
389
|
+
* Fine tune sort
|
|
390
|
+
*/
|
|
391
|
+
sort?: number;
|
|
392
|
+
/**
|
|
393
|
+
* Templates to provide autocomplete suggestions
|
|
394
|
+
*/
|
|
395
|
+
autocomplete?: Arrayable<AutoCompleteTemplate>;
|
|
396
|
+
/**
|
|
397
|
+
* Matching prefix before this util
|
|
398
|
+
*/
|
|
399
|
+
prefix?: string | string[];
|
|
400
|
+
/**
|
|
401
|
+
* Internal rules will only be matched for shortcuts but not the user code.
|
|
402
|
+
* @default false
|
|
403
|
+
*/
|
|
404
|
+
internal?: boolean;
|
|
405
|
+
/**
|
|
406
|
+
* Store the hash of the rule boy
|
|
407
|
+
*
|
|
408
|
+
* @internal
|
|
409
|
+
* @private
|
|
410
|
+
*/
|
|
411
|
+
__hash?: string;
|
|
412
|
+
/**
|
|
413
|
+
* Internal index of the rulelist
|
|
414
|
+
* @internal
|
|
415
|
+
* @private
|
|
416
|
+
*/
|
|
417
|
+
__index?: number;
|
|
418
|
+
/**
|
|
419
|
+
* Custom metadata
|
|
420
|
+
*/
|
|
421
|
+
custom?: Record<string, any>;
|
|
420
422
|
}
|
|
421
423
|
type CSSValue = CSSObject | CSSEntries;
|
|
422
424
|
type CSSValues = CSSValue | CSSValue[];
|
|
@@ -431,675 +433,647 @@ type DynamicShortcut<Theme extends object = object> = [RegExp, DynamicShortcutMa
|
|
|
431
433
|
type UserShortcuts<Theme extends object = object> = StaticShortcutMap | (StaticShortcut | DynamicShortcut<Theme> | StaticShortcutMap)[];
|
|
432
434
|
type Shortcut<Theme extends object = object> = StaticShortcut | DynamicShortcut<Theme>;
|
|
433
435
|
interface ShortcutInlineValue {
|
|
434
|
-
|
|
435
|
-
|
|
436
|
+
handles: VariantHandler[];
|
|
437
|
+
value: ShortcutValue;
|
|
436
438
|
}
|
|
437
439
|
type ShortcutValue = string | CSSValue;
|
|
438
440
|
type FilterPattern = ReadonlyArray<string | RegExp> | string | RegExp | null;
|
|
439
441
|
interface Preflight<Theme extends object = object> {
|
|
440
|
-
|
|
441
|
-
|
|
442
|
+
getCSS: (context: PreflightContext<Theme>) => Promise<string | undefined> | string | undefined;
|
|
443
|
+
layer?: string;
|
|
442
444
|
}
|
|
443
445
|
interface BlocklistMeta {
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
446
|
+
/**
|
|
447
|
+
* Custom message to show why this selector is blocked.
|
|
448
|
+
*/
|
|
449
|
+
message?: string | ((selector: string) => string);
|
|
448
450
|
}
|
|
449
451
|
type BlocklistValue = string | RegExp | ((selector: string) => boolean | null | undefined);
|
|
450
452
|
type BlocklistRule = BlocklistValue | [BlocklistValue, BlocklistMeta];
|
|
451
453
|
interface VariantHandlerContext {
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
454
|
+
/**
|
|
455
|
+
* Rewrite the output selector. Often be used to append parents.
|
|
456
|
+
*/
|
|
457
|
+
prefix: string;
|
|
458
|
+
/**
|
|
459
|
+
* Rewrite the output selector. Often be used to append pseudo classes.
|
|
460
|
+
*/
|
|
461
|
+
selector: string;
|
|
462
|
+
/**
|
|
463
|
+
* Rewrite the output selector. Often be used to append pseudo elements.
|
|
464
|
+
*/
|
|
465
|
+
pseudo: string;
|
|
466
|
+
/**
|
|
467
|
+
* Rewrite the output css body. The input come in [key,value][] pairs.
|
|
468
|
+
*/
|
|
469
|
+
entries: CSSEntries;
|
|
470
|
+
/**
|
|
471
|
+
* Provide a parent selector(e.g. media query) to the output css.
|
|
472
|
+
*/
|
|
473
|
+
parent?: string;
|
|
474
|
+
/**
|
|
475
|
+
* Provide order to the `parent` parent selector within layer.
|
|
476
|
+
*/
|
|
477
|
+
parentOrder?: number;
|
|
478
|
+
/**
|
|
479
|
+
* Override layer to the output css.
|
|
480
|
+
*/
|
|
481
|
+
layer?: string;
|
|
482
|
+
/**
|
|
483
|
+
* Order in which the variant is sorted within single rule.
|
|
484
|
+
*/
|
|
485
|
+
sort?: number;
|
|
486
|
+
/**
|
|
487
|
+
* Option to not merge the resulting entries even if the body are the same.
|
|
488
|
+
* @default false
|
|
489
|
+
*/
|
|
490
|
+
noMerge?: boolean;
|
|
489
491
|
}
|
|
490
492
|
interface VariantHandler {
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
493
|
+
/**
|
|
494
|
+
* Callback to process the handler.
|
|
495
|
+
*/
|
|
496
|
+
handle?: (input: VariantHandlerContext, next: (input: VariantHandlerContext) => VariantHandlerContext) => VariantHandlerContext;
|
|
497
|
+
/**
|
|
498
|
+
* The result rewritten selector for the next round of matching
|
|
499
|
+
*/
|
|
500
|
+
matcher?: string;
|
|
501
|
+
/**
|
|
502
|
+
* Order in which the variant is applied to selector.
|
|
503
|
+
*/
|
|
504
|
+
order?: number;
|
|
505
|
+
/**
|
|
506
|
+
* Rewrite the output selector. Often be used to append pseudo classes or parents.
|
|
507
|
+
*/
|
|
508
|
+
selector?: (input: string, body: CSSEntries) => string | undefined;
|
|
509
|
+
/**
|
|
510
|
+
* Rewrite the output css body. The input come in [key,value][] pairs.
|
|
511
|
+
*/
|
|
512
|
+
body?: (body: CSSEntries) => CSSEntries | undefined;
|
|
513
|
+
/**
|
|
514
|
+
* Provide a parent selector(e.g. media query) to the output css.
|
|
515
|
+
*/
|
|
516
|
+
parent?: string | [string, number] | undefined;
|
|
517
|
+
/**
|
|
518
|
+
* Order in which the variant is sorted within single rule.
|
|
519
|
+
*/
|
|
520
|
+
sort?: number;
|
|
521
|
+
/**
|
|
522
|
+
* Override layer to the output css.
|
|
523
|
+
*/
|
|
524
|
+
layer?: string | undefined;
|
|
523
525
|
}
|
|
524
526
|
type VariantFunction<Theme extends object = object> = (matcher: string, context: Readonly<VariantContext<Theme>>) => Awaitable<string | VariantHandler | VariantHandler[] | undefined>;
|
|
525
527
|
interface VariantObject<Theme extends object = object> {
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
528
|
+
/**
|
|
529
|
+
* The name of the variant.
|
|
530
|
+
*/
|
|
531
|
+
name?: string;
|
|
532
|
+
/**
|
|
533
|
+
* The entry function to match and rewrite the selector for further processing.
|
|
534
|
+
*/
|
|
535
|
+
match: VariantFunction<Theme>;
|
|
536
|
+
/**
|
|
537
|
+
* Sort for when the match is applied.
|
|
538
|
+
*/
|
|
539
|
+
order?: number;
|
|
540
|
+
/**
|
|
541
|
+
* Allows this variant to be used more than once in matching a single rule
|
|
542
|
+
*
|
|
543
|
+
* @default false
|
|
544
|
+
*/
|
|
545
|
+
multiPass?: boolean;
|
|
546
|
+
/**
|
|
547
|
+
* Custom function for auto complete
|
|
548
|
+
*/
|
|
549
|
+
autocomplete?: Arrayable<AutoCompleteFunction | AutoCompleteTemplate>;
|
|
548
550
|
}
|
|
549
551
|
type Variant<Theme extends object = object> = VariantFunction<Theme> | VariantObject<Theme>;
|
|
550
552
|
type Preprocessor = (matcher: string) => string | undefined;
|
|
551
|
-
type Postprocessor = (util: UtilObject) => void;
|
|
553
|
+
type Postprocessor = (util: UtilObject) => void | UtilObject | (UtilObject | null | undefined)[];
|
|
552
554
|
type ThemeExtender<Theme extends object = object> = (theme: Theme, config: Readonly<ResolvedConfig<Theme>>) => Theme | void;
|
|
553
555
|
interface ConfigBase<Theme extends object = object> {
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
556
|
+
/**
|
|
557
|
+
* Rules to generate CSS utilities.
|
|
558
|
+
*
|
|
559
|
+
* Later entries have higher priority.
|
|
560
|
+
*/
|
|
561
|
+
rules?: Rule<Theme>[];
|
|
562
|
+
/**
|
|
563
|
+
* Variant separator
|
|
564
|
+
*
|
|
565
|
+
* @default [':', '-']
|
|
566
|
+
*/
|
|
567
|
+
separators?: Arrayable<string>;
|
|
568
|
+
/**
|
|
569
|
+
* Variants that preprocess the selectors,
|
|
570
|
+
* having the ability to rewrite the CSS object.
|
|
571
|
+
*/
|
|
572
|
+
variants?: Variant<Theme>[];
|
|
573
|
+
/**
|
|
574
|
+
* Similar to Windi CSS's shortcuts,
|
|
575
|
+
* allows you have create new utilities by combining existing ones.
|
|
576
|
+
*
|
|
577
|
+
* Later entries have higher priority.
|
|
578
|
+
*/
|
|
579
|
+
shortcuts?: UserShortcuts<Theme>;
|
|
580
|
+
/**
|
|
581
|
+
* Rules to exclude the selectors for your design system (to narrow down the possibilities).
|
|
582
|
+
* Combining `warnExcluded` options it can also help you identify wrong usages.
|
|
583
|
+
*/
|
|
584
|
+
blocklist?: BlocklistRule[];
|
|
585
|
+
/**
|
|
586
|
+
* Utilities that always been included
|
|
587
|
+
*/
|
|
588
|
+
safelist?: (string | ((context: SafeListContext<Theme>) => Arrayable<string>))[];
|
|
589
|
+
/**
|
|
590
|
+
* Extractors to handle the source file and outputs possible classes/selectors
|
|
591
|
+
* Can be language-aware.
|
|
592
|
+
*/
|
|
593
|
+
extractors?: Extractor[];
|
|
594
|
+
/**
|
|
595
|
+
* Default extractor that are always applied.
|
|
596
|
+
* By default it split the source code by whitespace and quotes.
|
|
597
|
+
*
|
|
598
|
+
* It maybe be replaced by preset or user config,
|
|
599
|
+
* only one default extractor can be presented,
|
|
600
|
+
* later one will override the previous one.
|
|
601
|
+
*
|
|
602
|
+
* Pass `null` or `false` to disable the default extractor.
|
|
603
|
+
*
|
|
604
|
+
* @see https://github.com/unocss/unocss/blob/main/packages-engine/core/src/extractors/split.ts
|
|
605
|
+
* @default import('@unocss/core').defaultExtractor
|
|
606
|
+
*/
|
|
607
|
+
extractorDefault?: Extractor | null | false;
|
|
608
|
+
/**
|
|
609
|
+
* Raw CSS injections.
|
|
610
|
+
*/
|
|
611
|
+
preflights?: Preflight<Theme>[];
|
|
612
|
+
/**
|
|
613
|
+
* Theme object for shared configuration between rules
|
|
614
|
+
*/
|
|
615
|
+
theme?: Theme;
|
|
616
|
+
/**
|
|
617
|
+
* Layer orders. Default to 0.
|
|
618
|
+
*/
|
|
619
|
+
layers?: Record<string, number>;
|
|
620
|
+
/**
|
|
621
|
+
* Output the internal layers as CSS Cascade Layers.
|
|
622
|
+
*/
|
|
623
|
+
outputToCssLayers?: boolean | OutputCssLayersOptions;
|
|
624
|
+
/**
|
|
625
|
+
* Custom function to sort layers.
|
|
626
|
+
*/
|
|
627
|
+
sortLayers?: (layers: string[]) => string[];
|
|
628
|
+
/**
|
|
629
|
+
* Preprocess the incoming utilities, return falsy value to exclude
|
|
630
|
+
*/
|
|
631
|
+
preprocess?: Arrayable<Preprocessor>;
|
|
632
|
+
/**
|
|
633
|
+
* Postprocess the generate utils object
|
|
634
|
+
*/
|
|
635
|
+
postprocess?: Arrayable<Postprocessor>;
|
|
636
|
+
/**
|
|
637
|
+
* Custom functions mutate the theme object.
|
|
638
|
+
*
|
|
639
|
+
* It's also possible to return a new theme object to completely replace the original one.
|
|
640
|
+
*/
|
|
641
|
+
extendTheme?: Arrayable<ThemeExtender<Theme>>;
|
|
642
|
+
/**
|
|
643
|
+
* Presets
|
|
644
|
+
*/
|
|
645
|
+
presets?: (PresetOrFactoryAwaitable<Theme> | PresetOrFactoryAwaitable<Theme>[])[];
|
|
646
|
+
/**
|
|
647
|
+
* Additional options for auto complete
|
|
648
|
+
*/
|
|
649
|
+
autocomplete?: {
|
|
650
|
+
/**
|
|
651
|
+
* Custom functions / templates to provide autocomplete suggestions
|
|
652
|
+
*/
|
|
653
|
+
templates?: Arrayable<AutoCompleteFunction | AutoCompleteTemplate>;
|
|
654
|
+
/**
|
|
655
|
+
* Custom extractors to pickup possible classes and
|
|
656
|
+
* transform class-name style suggestions to the correct format
|
|
657
|
+
*/
|
|
658
|
+
extractors?: Arrayable<AutoCompleteExtractor>;
|
|
659
|
+
/**
|
|
660
|
+
* Custom shorthands to provide autocomplete suggestions.
|
|
661
|
+
* if values is an array, it will be joined with `|` and wrapped with `()`
|
|
662
|
+
*/
|
|
663
|
+
shorthands?: Record<string, string | string[]>;
|
|
664
|
+
};
|
|
665
|
+
/**
|
|
666
|
+
* Hook to modify the resolved config.
|
|
667
|
+
*
|
|
668
|
+
* First presets runs first and the user config
|
|
669
|
+
*/
|
|
670
|
+
configResolved?: (config: ResolvedConfig<Theme>) => void;
|
|
671
|
+
/**
|
|
672
|
+
* Expose internal details for debugging / inspecting
|
|
673
|
+
*
|
|
674
|
+
* Added `rules`, `shortcuts`, `variants` to the context and expose the context object in `StringifiedUtil`
|
|
675
|
+
*
|
|
676
|
+
* You don't usually need to set this.
|
|
677
|
+
*
|
|
678
|
+
* @default `true` when `envMode` is `dev`, otherwise `false`
|
|
679
|
+
*/
|
|
680
|
+
details?: boolean;
|
|
681
|
+
/**
|
|
682
|
+
* Options for sources to be extracted as utilities usages.
|
|
683
|
+
*
|
|
684
|
+
*/
|
|
685
|
+
content?: ContentOptions;
|
|
686
|
+
/**
|
|
687
|
+
* Custom transformers to the source code.
|
|
688
|
+
*/
|
|
689
|
+
transformers?: SourceCodeTransformer[];
|
|
688
690
|
}
|
|
689
691
|
interface OutputCssLayersOptions {
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
692
|
+
/**
|
|
693
|
+
* Specify the css layer that the internal layer should be output to.
|
|
694
|
+
*
|
|
695
|
+
* Return `null` to specify that the layer should not be output to any css layer.
|
|
696
|
+
*/
|
|
697
|
+
cssLayerName?: (internalLayer: string) => string | undefined | null;
|
|
696
698
|
}
|
|
697
699
|
type AutoCompleteTemplate = string;
|
|
698
700
|
type AutoCompleteFunction = (input: string) => Awaitable<string[]>;
|
|
699
701
|
interface AutoCompleteExtractorContext {
|
|
700
|
-
|
|
701
|
-
|
|
702
|
+
content: string;
|
|
703
|
+
cursor: number;
|
|
702
704
|
}
|
|
703
705
|
interface Replacement {
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
706
|
+
/**
|
|
707
|
+
* The range of the original text
|
|
708
|
+
*/
|
|
709
|
+
start: number;
|
|
710
|
+
end: number;
|
|
711
|
+
/**
|
|
712
|
+
* The text used to replace
|
|
713
|
+
*/
|
|
714
|
+
replacement: string;
|
|
713
715
|
}
|
|
714
716
|
interface SuggestResult {
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
717
|
+
/**
|
|
718
|
+
* The generated suggestions
|
|
719
|
+
*
|
|
720
|
+
* `[original, formatted]`
|
|
721
|
+
*/
|
|
722
|
+
suggestions: [string, string][];
|
|
723
|
+
/**
|
|
724
|
+
* The function to convert the selected suggestion back.
|
|
725
|
+
* Needs to pass in the original one.
|
|
726
|
+
*/
|
|
727
|
+
resolveReplacement: (suggestion: string) => Replacement;
|
|
726
728
|
}
|
|
727
729
|
interface AutoCompleteExtractorResult {
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
730
|
+
/**
|
|
731
|
+
* The extracted string
|
|
732
|
+
*/
|
|
733
|
+
extracted: string;
|
|
734
|
+
/**
|
|
735
|
+
* The function to convert the selected suggestion back
|
|
736
|
+
*/
|
|
737
|
+
resolveReplacement: (suggestion: string) => Replacement;
|
|
738
|
+
/**
|
|
739
|
+
* The function to format suggestions
|
|
740
|
+
*/
|
|
741
|
+
transformSuggestions?: (suggestions: string[]) => string[];
|
|
740
742
|
}
|
|
741
743
|
interface AutoCompleteExtractor {
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
744
|
+
name: string;
|
|
745
|
+
extract: (context: AutoCompleteExtractorContext) => Awaitable<AutoCompleteExtractorResult | null>;
|
|
746
|
+
order?: number;
|
|
745
747
|
}
|
|
746
748
|
interface Preset<Theme extends object = object> extends ConfigBase<Theme> {
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
749
|
+
name: string;
|
|
750
|
+
/**
|
|
751
|
+
* Enforce the preset to be applied before or after other presets
|
|
752
|
+
*/
|
|
753
|
+
enforce?: 'pre' | 'post';
|
|
754
|
+
/**
|
|
755
|
+
* Preset options for other tools like IDE to consume
|
|
756
|
+
*/
|
|
757
|
+
options?: PresetOptions;
|
|
758
|
+
/**
|
|
759
|
+
* Apply prefix to all utilities and shortcuts
|
|
760
|
+
*/
|
|
761
|
+
prefix?: string | string[];
|
|
762
|
+
/**
|
|
763
|
+
* Apply layer to all utilities and shortcuts
|
|
764
|
+
*/
|
|
765
|
+
layer?: string;
|
|
766
|
+
/**
|
|
767
|
+
* Custom API endpoint for cross-preset communication
|
|
768
|
+
*/
|
|
769
|
+
api?: any;
|
|
770
|
+
/**
|
|
771
|
+
* Custom metadata for the preset
|
|
772
|
+
*/
|
|
773
|
+
meta?: Record<string, any>;
|
|
772
774
|
}
|
|
773
|
-
type PresetFactory<Theme extends object = object, PresetOptions extends object | undefined = undefined> = (options?: PresetOptions) => Preset<Theme>;
|
|
774
|
-
type PresetFactoryAwaitable<Theme extends object = object, PresetOptions extends object | undefined = undefined> = (options?: PresetOptions) => Awaitable<Preset<Theme>>;
|
|
775
|
+
type PresetFactory<Theme extends object = object, PresetOptions$1 extends object | undefined = undefined> = (options?: PresetOptions$1) => Preset<Theme>;
|
|
776
|
+
type PresetFactoryAwaitable<Theme extends object = object, PresetOptions$1 extends object | undefined = undefined> = (options?: PresetOptions$1) => Awaitable<Preset<Theme>>;
|
|
775
777
|
type PresetOrFactory<Theme extends object = object> = Preset<Theme> | PresetFactory<Theme, any>;
|
|
776
778
|
type PresetOrFactoryAwaitable<Theme extends object = object> = PresetOrFactory<Theme> | Promise<Preset<Theme>> | PresetFactoryAwaitable<Theme>;
|
|
777
779
|
interface GeneratorOptions {
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
780
|
+
/**
|
|
781
|
+
* Merge utilities with the exact same body to save the file size
|
|
782
|
+
*
|
|
783
|
+
* @default true
|
|
784
|
+
*/
|
|
785
|
+
mergeSelectors?: boolean;
|
|
786
|
+
/**
|
|
787
|
+
* Emit warning when matched selectors are presented in blocklist
|
|
788
|
+
*
|
|
789
|
+
* @default true
|
|
790
|
+
*/
|
|
791
|
+
warn?: boolean;
|
|
790
792
|
}
|
|
791
793
|
interface UserOnlyOptions<Theme extends object = object> {
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
794
|
+
/**
|
|
795
|
+
* The theme object, will be merged with the theme provides by presets
|
|
796
|
+
*/
|
|
797
|
+
theme?: Theme;
|
|
798
|
+
/**
|
|
799
|
+
* Layout name of shortcuts
|
|
800
|
+
*
|
|
801
|
+
* @default 'shortcuts'
|
|
802
|
+
*/
|
|
803
|
+
shortcutsLayer?: string;
|
|
804
|
+
/**
|
|
805
|
+
* Environment mode
|
|
806
|
+
*
|
|
807
|
+
* @default 'build'
|
|
808
|
+
*/
|
|
809
|
+
envMode?: 'dev' | 'build';
|
|
810
|
+
/**
|
|
811
|
+
* legacy.renderModernChunks need to be consistent with @vitejs/plugin-legacy
|
|
812
|
+
*/
|
|
813
|
+
legacy?: {
|
|
814
|
+
renderModernChunks: boolean;
|
|
815
|
+
};
|
|
816
|
+
/**
|
|
817
|
+
* Custom prefix for virtual modules
|
|
818
|
+
*
|
|
819
|
+
* @default '__uno'
|
|
820
|
+
*/
|
|
821
|
+
virtualModulePrefix?: string;
|
|
820
822
|
}
|
|
821
823
|
/**
|
|
822
824
|
* For unocss-cli config
|
|
823
825
|
*/
|
|
824
826
|
interface CliOptions {
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
827
|
+
cli?: {
|
|
828
|
+
entry?: Arrayable<CliEntryItem>;
|
|
829
|
+
};
|
|
828
830
|
}
|
|
829
831
|
interface UnocssPluginContext<Config extends UserConfig = UserConfig> {
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
832
|
+
/**
|
|
833
|
+
* Singleton promise for config loading
|
|
834
|
+
*/
|
|
835
|
+
ready: Promise<LoadConfigResult<Config>>;
|
|
836
|
+
/**
|
|
837
|
+
* The UnoCSS generator instance. Should be used after `ready` resolved.
|
|
838
|
+
*/
|
|
839
|
+
uno: UnoGenerator;
|
|
840
|
+
/**
|
|
841
|
+
* All tokens scanned
|
|
842
|
+
*/
|
|
843
|
+
tokens: Set<string>;
|
|
844
|
+
/**
|
|
845
|
+
* Map for all module's raw content
|
|
846
|
+
*/
|
|
847
|
+
modules: BetterMap<string, string>;
|
|
848
|
+
/**
|
|
849
|
+
* Module IDs that been affected by UnoCSS
|
|
850
|
+
*/
|
|
851
|
+
affectedModules: Set<string>;
|
|
852
|
+
/**
|
|
853
|
+
* Pending promises
|
|
854
|
+
*/
|
|
855
|
+
tasks: Promise<any>[];
|
|
856
|
+
/**
|
|
857
|
+
* Await all pending tasks
|
|
858
|
+
*/
|
|
859
|
+
flushTasks: () => Promise<any>;
|
|
860
|
+
filter: (code: string, id: string) => boolean;
|
|
861
|
+
extract: (code: string, id?: string) => Promise<void>;
|
|
862
|
+
reloadConfig: () => Promise<LoadConfigResult<Config>>;
|
|
863
|
+
getConfig: () => Promise<Config>;
|
|
864
|
+
onReload: (fn: () => void) => void;
|
|
865
|
+
invalidate: () => void;
|
|
866
|
+
onInvalidate: (fn: () => void) => void;
|
|
867
|
+
root: string;
|
|
868
|
+
updateRoot: (root: string) => Promise<LoadConfigResult<Config>>;
|
|
869
|
+
getConfigFileList: () => string[];
|
|
870
|
+
/**
|
|
871
|
+
* Get regexes to match virtual module ids
|
|
872
|
+
*/
|
|
873
|
+
getVMPRegexes: () => Promise<{
|
|
874
|
+
prefix: string;
|
|
875
|
+
RESOLVED_ID_WITH_QUERY_RE: RegExp;
|
|
876
|
+
RESOLVED_ID_RE: RegExp;
|
|
877
|
+
}>;
|
|
876
878
|
}
|
|
877
879
|
interface SourceMap {
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
880
|
+
file?: string;
|
|
881
|
+
mappings?: string;
|
|
882
|
+
names?: string[];
|
|
883
|
+
sources?: string[];
|
|
884
|
+
sourcesContent?: string[];
|
|
885
|
+
version?: number;
|
|
884
886
|
}
|
|
885
887
|
interface HighlightAnnotation {
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
888
|
+
offset: number;
|
|
889
|
+
length: number;
|
|
890
|
+
className: string;
|
|
889
891
|
}
|
|
890
892
|
type SourceCodeTransformerEnforce = 'pre' | 'post' | 'default';
|
|
891
893
|
interface SourceCodeTransformer {
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
894
|
+
name: string;
|
|
895
|
+
/**
|
|
896
|
+
* The order of transformer
|
|
897
|
+
*/
|
|
898
|
+
enforce?: SourceCodeTransformerEnforce;
|
|
899
|
+
/**
|
|
900
|
+
* Custom id filter, if not provided, the extraction filter will be applied
|
|
901
|
+
*/
|
|
902
|
+
idFilter?: (id: string) => boolean;
|
|
903
|
+
/**
|
|
904
|
+
* The transform function
|
|
905
|
+
*/
|
|
906
|
+
transform: (code: MagicString, id: string, ctx: UnocssPluginContext) => Awaitable<{
|
|
907
|
+
highlightAnnotations?: HighlightAnnotation[];
|
|
908
|
+
} | void>;
|
|
907
909
|
}
|
|
908
910
|
interface ContentOptions {
|
|
909
|
-
|
|
910
|
-
|
|
911
|
+
/**
|
|
912
|
+
* Glob patterns to extract from the file system, in addition to other content sources.
|
|
913
|
+
*
|
|
914
|
+
* In dev mode, the files will be watched and trigger HMR.
|
|
915
|
+
*
|
|
916
|
+
* @default []
|
|
917
|
+
*/
|
|
918
|
+
filesystem?: string[];
|
|
919
|
+
/**
|
|
920
|
+
* Inline text to be extracted
|
|
921
|
+
*/
|
|
922
|
+
inline?: (string | {
|
|
923
|
+
code: string;
|
|
924
|
+
id?: string;
|
|
925
|
+
} | (() => Awaitable<string | {
|
|
926
|
+
code: string;
|
|
927
|
+
id?: string;
|
|
928
|
+
}>))[];
|
|
929
|
+
/**
|
|
930
|
+
* Filters to determine whether to extract certain modules from the build tools' transformation pipeline.
|
|
931
|
+
*
|
|
932
|
+
* Currently only works for Vite and Webpack integration.
|
|
933
|
+
*
|
|
934
|
+
* Set `false` to disable.
|
|
935
|
+
*/
|
|
936
|
+
pipeline?: false | {
|
|
937
|
+
/**
|
|
938
|
+
* Patterns that filter the files being extracted.
|
|
939
|
+
* Supports regular expressions and `picomatch` glob patterns.
|
|
911
940
|
*
|
|
912
|
-
*
|
|
941
|
+
* By default, `.ts` and `.js` files are NOT extracted.
|
|
913
942
|
*
|
|
914
|
-
* @
|
|
943
|
+
* @see https://www.npmjs.com/package/picomatch
|
|
944
|
+
* @default [/\.(vue|svelte|[jt]sx|vine.ts|mdx?|astro|elm|php|phtml|marko|html)($|\?)/]
|
|
915
945
|
*/
|
|
916
|
-
|
|
946
|
+
include?: FilterPattern;
|
|
917
947
|
/**
|
|
918
|
-
*
|
|
919
|
-
|
|
920
|
-
inline?: (string | {
|
|
921
|
-
code: string;
|
|
922
|
-
id?: string;
|
|
923
|
-
} | (() => Awaitable<string | {
|
|
924
|
-
code: string;
|
|
925
|
-
id?: string;
|
|
926
|
-
}>))[];
|
|
927
|
-
/**
|
|
928
|
-
* Filters to determine whether to extract certain modules from the build tools' transformation pipeline.
|
|
948
|
+
* Patterns that filter the files NOT being extracted.
|
|
949
|
+
* Supports regular expressions and `picomatch` glob patterns.
|
|
929
950
|
*
|
|
930
|
-
*
|
|
951
|
+
* By default, `node_modules` and `dist` are also extracted.
|
|
931
952
|
*
|
|
932
|
-
*
|
|
953
|
+
* @see https://www.npmjs.com/package/picomatch
|
|
954
|
+
* @default [/\.(css|postcss|sass|scss|less|stylus|styl)($|\?)/]
|
|
933
955
|
*/
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
* Patterns that filter the files being extracted.
|
|
937
|
-
* Supports regular expressions and `picomatch` glob patterns.
|
|
938
|
-
*
|
|
939
|
-
* By default, `.ts` and `.js` files are NOT extracted.
|
|
940
|
-
*
|
|
941
|
-
* @see https://www.npmjs.com/package/picomatch
|
|
942
|
-
* @default [/\.(vue|svelte|[jt]sx|vine.ts|mdx?|astro|elm|php|phtml|marko|html)($|\?)/]
|
|
943
|
-
*/
|
|
944
|
-
include?: FilterPattern;
|
|
945
|
-
/**
|
|
946
|
-
* Patterns that filter the files NOT being extracted.
|
|
947
|
-
* Supports regular expressions and `picomatch` glob patterns.
|
|
948
|
-
*
|
|
949
|
-
* By default, `node_modules` and `dist` are also extracted.
|
|
950
|
-
*
|
|
951
|
-
* @see https://www.npmjs.com/package/picomatch
|
|
952
|
-
* @default [/\.(css|postcss|sass|scss|less|stylus|styl)($|\?)/]
|
|
953
|
-
*/
|
|
954
|
-
exclude?: FilterPattern;
|
|
955
|
-
};
|
|
956
|
+
exclude?: FilterPattern;
|
|
957
|
+
};
|
|
956
958
|
}
|
|
957
959
|
/**
|
|
958
960
|
* For other modules to aggregate the options
|
|
959
961
|
*/
|
|
960
962
|
interface PluginOptions {
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
}
|
|
987
|
-
interface UserConfig<Theme extends object = object> extends ConfigBase<Theme>, UserOnlyOptions<Theme>, GeneratorOptions, PluginOptions, CliOptions {
|
|
988
|
-
}
|
|
989
|
-
interface UserConfigDefaults<Theme extends object = object> extends ConfigBase<Theme>, UserOnlyOptions<Theme> {
|
|
963
|
+
/**
|
|
964
|
+
* Load from configs files
|
|
965
|
+
*
|
|
966
|
+
* set `false` to disable
|
|
967
|
+
*/
|
|
968
|
+
configFile?: string | false;
|
|
969
|
+
/**
|
|
970
|
+
* List of files that will also trigger config reloads
|
|
971
|
+
*/
|
|
972
|
+
configDeps?: string[];
|
|
973
|
+
/**
|
|
974
|
+
* Custom transformers to the source code
|
|
975
|
+
*/
|
|
976
|
+
transformers?: SourceCodeTransformer[];
|
|
977
|
+
/**
|
|
978
|
+
* Options for sources to be extracted as utilities usages
|
|
979
|
+
*
|
|
980
|
+
* Supported sources:
|
|
981
|
+
* - `filesystem` - extract from file system
|
|
982
|
+
* - `inline` - extract from plain inline text
|
|
983
|
+
* - `pipeline` - extract from build tools' transformation pipeline, such as Vite and Webpack
|
|
984
|
+
*
|
|
985
|
+
* The usage extracted from each source will be **merged** together.
|
|
986
|
+
*/
|
|
987
|
+
content?: ContentOptions;
|
|
990
988
|
}
|
|
989
|
+
interface UserConfig<Theme extends object = object> extends ConfigBase<Theme>, UserOnlyOptions<Theme>, GeneratorOptions, PluginOptions, CliOptions {}
|
|
990
|
+
interface UserConfigDefaults<Theme extends object = object> extends ConfigBase<Theme>, UserOnlyOptions<Theme> {}
|
|
991
991
|
interface ResolvedConfig<Theme extends object = object> extends Omit<RequiredByKey<UserConfig<Theme>, 'mergeSelectors' | 'theme' | 'rules' | 'variants' | 'layers' | 'extractors' | 'blocklist' | 'safelist' | 'preflights' | 'sortLayers'>, 'rules' | 'shortcuts' | 'autocomplete' | 'presets'> {
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
992
|
+
presets: Preset<Theme>[];
|
|
993
|
+
shortcuts: Shortcut<Theme>[];
|
|
994
|
+
variants: VariantObject<Theme>[];
|
|
995
|
+
preprocess: Preprocessor[];
|
|
996
|
+
postprocess: Postprocessor[];
|
|
997
|
+
rulesSize: number;
|
|
998
|
+
rules: readonly Rule<Theme>[];
|
|
999
|
+
rulesDynamic: readonly DynamicRule<Theme>[];
|
|
1000
|
+
rulesStaticMap: Record<string, StaticRule | undefined>;
|
|
1001
|
+
autocomplete: {
|
|
1002
|
+
templates: (AutoCompleteFunction | AutoCompleteTemplate)[];
|
|
1003
|
+
extractors: AutoCompleteExtractor[];
|
|
1004
|
+
shorthands: Record<string, string>;
|
|
1005
|
+
};
|
|
1006
|
+
separators: string[];
|
|
1007
1007
|
}
|
|
1008
1008
|
interface GenerateResult<T = Set<string>> {
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1009
|
+
css: string;
|
|
1010
|
+
layers: string[];
|
|
1011
|
+
getLayer: (name?: string) => string | undefined;
|
|
1012
|
+
getLayers: (includes?: string[], excludes?: string[]) => string;
|
|
1013
|
+
setLayer: (layer: string, callback: (content: string) => Promise<string>) => Promise<string>;
|
|
1014
|
+
matched: T;
|
|
1015
1015
|
}
|
|
1016
|
-
type VariantMatchedResult<Theme extends object = object> = [
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
];
|
|
1022
|
-
type ParsedUtil = readonly [
|
|
1023
|
-
index: number,
|
|
1024
|
-
raw: string,
|
|
1025
|
-
entries: CSSEntries,
|
|
1026
|
-
meta: RuleMeta | undefined,
|
|
1027
|
-
variantHandlers: VariantHandler[]
|
|
1028
|
-
];
|
|
1029
|
-
type RawUtil = readonly [
|
|
1030
|
-
index: number,
|
|
1031
|
-
rawCSS: string,
|
|
1032
|
-
meta: RuleMeta | undefined
|
|
1033
|
-
];
|
|
1034
|
-
type StringifiedUtil<Theme extends object = object> = readonly [
|
|
1035
|
-
index: number,
|
|
1036
|
-
selector: string | undefined,
|
|
1037
|
-
body: string,
|
|
1038
|
-
parent: string | undefined,
|
|
1039
|
-
meta: RuleMeta | undefined,
|
|
1040
|
-
context: RuleContext<Theme> | undefined,
|
|
1041
|
-
noMerge: boolean | undefined
|
|
1042
|
-
];
|
|
1043
|
-
type PreparedRule = readonly [
|
|
1044
|
-
selector: [string, number][],
|
|
1045
|
-
body: string,
|
|
1046
|
-
noMerge: boolean
|
|
1047
|
-
];
|
|
1016
|
+
type VariantMatchedResult<Theme extends object = object> = [raw: string, current: string, variantHandlers: VariantHandler[], variants: Set<Variant<Theme>>];
|
|
1017
|
+
type ParsedUtil = readonly [index: number, raw: string, entries: CSSEntries, meta: RuleMeta | undefined, variantHandlers: VariantHandler[]];
|
|
1018
|
+
type RawUtil = readonly [index: number, rawCSS: string, meta: RuleMeta | undefined];
|
|
1019
|
+
type StringifiedUtil<Theme extends object = object> = readonly [index: number, selector: string | undefined, body: string, parent: string | undefined, meta: RuleMeta | undefined, context: RuleContext<Theme> | undefined, noMerge: boolean | undefined];
|
|
1020
|
+
type PreparedRule = readonly [selector: [string, number][], body: string, noMerge: boolean];
|
|
1048
1021
|
interface CliEntryItem {
|
|
1049
|
-
|
|
1050
|
-
|
|
1022
|
+
patterns: string[];
|
|
1023
|
+
outFile: string;
|
|
1051
1024
|
}
|
|
1052
1025
|
interface UtilObject {
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1026
|
+
selector: string;
|
|
1027
|
+
entries: CSSEntries;
|
|
1028
|
+
parent: string | undefined;
|
|
1029
|
+
layer: string | undefined;
|
|
1030
|
+
sort: number | undefined;
|
|
1031
|
+
noMerge: boolean | undefined;
|
|
1059
1032
|
}
|
|
1060
1033
|
/**
|
|
1061
1034
|
* Returned from `uno.generate()` when `extendedInfo` option is enabled.
|
|
1062
1035
|
*/
|
|
1063
1036
|
interface ExtendedTokenInfo<Theme extends object = object> {
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1037
|
+
/**
|
|
1038
|
+
* Stringified util data
|
|
1039
|
+
*/
|
|
1040
|
+
data: StringifiedUtil<Theme>[];
|
|
1041
|
+
/**
|
|
1042
|
+
* Return -1 if the data structure is not countable
|
|
1043
|
+
*/
|
|
1044
|
+
count: number;
|
|
1072
1045
|
}
|
|
1073
1046
|
interface GenerateOptions<T extends boolean> {
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1047
|
+
/**
|
|
1048
|
+
* Filepath of the file being processed.
|
|
1049
|
+
*/
|
|
1050
|
+
id?: string;
|
|
1051
|
+
/**
|
|
1052
|
+
* Generate preflights (if defined)
|
|
1053
|
+
*
|
|
1054
|
+
* @default true
|
|
1055
|
+
*/
|
|
1056
|
+
preflights?: boolean;
|
|
1057
|
+
/**
|
|
1058
|
+
* Includes safelist
|
|
1059
|
+
*/
|
|
1060
|
+
safelist?: boolean;
|
|
1061
|
+
/**
|
|
1062
|
+
* Generate minified CSS
|
|
1063
|
+
* @default false
|
|
1064
|
+
*/
|
|
1065
|
+
minify?: boolean;
|
|
1066
|
+
/**
|
|
1067
|
+
* @experimental
|
|
1068
|
+
*/
|
|
1069
|
+
scope?: string;
|
|
1070
|
+
/**
|
|
1071
|
+
* If return extended "matched" with payload and count
|
|
1072
|
+
*/
|
|
1073
|
+
extendedInfo?: T;
|
|
1101
1074
|
}
|
|
1102
|
-
|
|
1075
|
+
//#endregion
|
|
1076
|
+
//#region src/config.d.ts
|
|
1103
1077
|
declare function resolveShortcuts<Theme extends object = object>(shortcuts: UserShortcuts<Theme>): Shortcut<Theme>[];
|
|
1104
1078
|
/**
|
|
1105
1079
|
* Resolve a single preset, nested presets are ignored
|
|
@@ -1117,21 +1091,22 @@ declare function mergeConfigs<Theme extends object = object>(configs: UserConfig
|
|
|
1117
1091
|
declare function definePreset<Options extends object | undefined = undefined, Theme extends object = object>(preset: PresetFactory<Theme, Options>): PresetFactory<Theme, Options>;
|
|
1118
1092
|
declare function definePreset<Options extends object | undefined = undefined, Theme extends object = object>(preset: PresetFactoryAwaitable<Theme, Options>): PresetFactoryAwaitable<Theme, Options>;
|
|
1119
1093
|
declare function definePreset<Theme extends object = object>(preset: Preset<Theme>): Preset<Theme>;
|
|
1120
|
-
|
|
1094
|
+
//#endregion
|
|
1095
|
+
//#region src/constants.d.ts
|
|
1121
1096
|
declare const LAYER_DEFAULT = "default";
|
|
1122
1097
|
declare const LAYER_PREFLIGHTS = "preflights";
|
|
1123
1098
|
declare const LAYER_SHORTCUTS = "shortcuts";
|
|
1124
1099
|
declare const LAYER_IMPORTS = "imports";
|
|
1125
1100
|
declare const DEFAULT_LAYERS: {
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1101
|
+
imports: number;
|
|
1102
|
+
preflights: number;
|
|
1103
|
+
shortcuts: number;
|
|
1104
|
+
default: number;
|
|
1130
1105
|
};
|
|
1131
|
-
|
|
1106
|
+
//#endregion
|
|
1107
|
+
//#region src/extractors/split.d.ts
|
|
1132
1108
|
declare const defaultSplitRE: RegExp;
|
|
1133
1109
|
declare const splitWithVariantGroupRE: RegExp;
|
|
1134
1110
|
declare const extractorSplit: Extractor;
|
|
1135
|
-
|
|
1136
|
-
export { BetterMap, CountableSet, DEFAULT_LAYERS, Emitter, LAYER_DEFAULT, LAYER_IMPORTS, LAYER_PREFLIGHTS, LAYER_SHORTCUTS, TwoKeyMap, UnoGenerator, VirtualKey, attributifyRE, clearIdenticalEntries, clone, collapseVariantGroup, createGenerator, createNanoEvents, cssIdRE, defaultSplitRE, definePreset, e, entriesToCss, escapeRegExp, escapeSelector, expandVariantGroup, extractorSplit as extractorDefault, extractorSplit, hasScopePlaceholder, isAttributifySelector, isCountableSet, isObject, isRawUtil, isStaticRule, isStaticShortcut, isString, isValidSelector, makeRegexClassGroup, mergeConfigs, mergeDeep, noop, normalizeCSSEntries, normalizeCSSValues, normalizeVariant, notNull, parseVariantGroup, regexScopePlaceholder, resolveConfig, resolvePreset, resolvePresets, resolveShortcuts, splitWithVariantGroupRE, symbols, toArray, toEscapedSelector, uniq, uniqueBy, validateFilterRE, warnOnce, withLayer };
|
|
1137
|
-
export type { ArgumentType, Arrayable, AutoCompleteExtractor, AutoCompleteExtractorContext, AutoCompleteExtractorResult, AutoCompleteFunction, AutoCompleteTemplate, Awaitable, BaseContext, BlocklistMeta, BlocklistRule, BlocklistValue, CSSEntries, CSSEntriesInput, CSSEntry, CSSObject, CSSObjectInput, CSSValue, CSSValueInput, CSSValues, CliEntryItem, CliOptions, ConfigBase, ContentOptions, ControlSymbols, ControlSymbolsEntry, ControlSymbolsValue, DeepPartial, DynamicMatcher, DynamicRule, DynamicShortcut, DynamicShortcutMatcher, ExtendedTokenInfo, Extractor, ExtractorContext, FilterPattern, FlatObjectTuple, GenerateOptions, GenerateResult, GeneratorOptions, HighlightAnnotation, ObjectToEntry, OutputCssLayersOptions, ParsedUtil, PartialByKeys, PluginOptions, Postprocessor, Preflight, PreflightContext, PreparedRule, Preprocessor, Preset, PresetFactory, PresetFactoryAwaitable, PresetOptions, PresetOrFactory, PresetOrFactoryAwaitable, RawUtil, Replacement, RequiredByKey, ResolvedConfig, RestArgs, Rule, RuleContext, RuleMeta, SafeListContext, Shift, Shortcut, ShortcutInlineValue, ShortcutValue, SourceCodeTransformer, SourceCodeTransformerEnforce, SourceMap, StaticRule, StaticShortcut, StaticShortcutMap, StringifiedUtil, SuggestResult, ThemeExtender, ToArray, UnocssPluginContext, Unsubscribe, UserConfig, UserConfigDefaults, UserOnlyOptions, UserShortcuts, UtilObject, Variant, VariantContext, VariantFunction, VariantHandler, VariantHandlerContext, VariantMatchedResult, VariantObject };
|
|
1111
|
+
//#endregion
|
|
1112
|
+
export { ArgumentType, Arrayable, AutoCompleteExtractor, AutoCompleteExtractorContext, AutoCompleteExtractorResult, AutoCompleteFunction, AutoCompleteTemplate, Awaitable, BaseContext, BetterMap, BlocklistMeta, BlocklistRule, BlocklistValue, CSSEntries, CSSEntriesInput, CSSEntry, CSSObject, CSSObjectInput, CSSValue, CSSValueInput, CSSValues, CliEntryItem, CliOptions, ConfigBase, ContentOptions, ControlSymbols, ControlSymbolsEntry, ControlSymbolsValue, CountableSet, DEFAULT_LAYERS, DeepPartial, DynamicMatcher, DynamicRule, DynamicShortcut, DynamicShortcutMatcher, Emitter, ExtendedTokenInfo, Extractor, ExtractorContext, FilterPattern, FlatObjectTuple, GenerateOptions, GenerateResult, GeneratorOptions, HighlightAnnotation, LAYER_DEFAULT, LAYER_IMPORTS, LAYER_PREFLIGHTS, LAYER_SHORTCUTS, ObjectToEntry, OutputCssLayersOptions, ParsedUtil, PartialByKeys, PluginOptions, Postprocessor, Preflight, PreflightContext, PreparedRule, Preprocessor, Preset, PresetFactory, PresetFactoryAwaitable, PresetOptions, PresetOrFactory, PresetOrFactoryAwaitable, RawUtil, Replacement, RequiredByKey, ResolvedConfig, RestArgs, Rule, RuleContext, RuleMeta, SafeListContext, Shift, Shortcut, ShortcutInlineValue, ShortcutValue, SourceCodeTransformer, SourceCodeTransformerEnforce, SourceMap, StaticRule, StaticShortcut, StaticShortcutMap, StringifiedUtil, SuggestResult, ThemeExtender, ToArray, TwoKeyMap, UnoGenerator, UnocssPluginContext, Unsubscribe, UserConfig, UserConfigDefaults, UserOnlyOptions, UserShortcuts, UtilObject, Variant, VariantContext, VariantFunction, VariantHandler, VariantHandlerContext, VariantMatchedResult, VariantObject, VirtualKey, attributifyRE, clearIdenticalEntries, clone, collapseVariantGroup, createGenerator, createNanoEvents, cssIdRE, defaultSplitRE, definePreset, e, entriesToCss, escapeRegExp, escapeSelector, expandVariantGroup, extractorSplit as extractorDefault, extractorSplit, hasScopePlaceholder, isAttributifySelector, isCountableSet, isObject, isRawUtil, isStaticRule, isStaticShortcut, isString, isValidSelector, makeRegexClassGroup, mergeConfigs, mergeDeep, noop, normalizeCSSEntries, normalizeCSSValues, normalizeVariant, notNull, parseVariantGroup, regexScopePlaceholder, resolveConfig, resolvePreset, resolvePresets, resolveShortcuts, splitWithVariantGroupRE, symbols, toArray, toEscapedSelector, uniq, uniqueBy, validateFilterRE, warnOnce, withLayer };
|