@unocss/preset-attributify 66.5.12 → 66.6.0

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