| 1 | import { N as NamedUtilityValue, P as PluginUtils } from './resolve-config-BIFUA2FY.js';
|
|---|
| 2 | import './colors-b_6i0Oi7.js';
|
|---|
| 3 |
|
|---|
| 4 | /**
|
|---|
| 5 | * The source code for one or more nodes in the AST
|
|---|
| 6 | *
|
|---|
| 7 | * This generally corresponds to a stylesheet
|
|---|
| 8 | */
|
|---|
| 9 | interface Source {
|
|---|
| 10 | /**
|
|---|
| 11 | * The path to the file that contains the referenced source code
|
|---|
| 12 | *
|
|---|
| 13 | * If this references the *output* source code, this is `null`.
|
|---|
| 14 | */
|
|---|
| 15 | file: string | null;
|
|---|
| 16 | /**
|
|---|
| 17 | * The referenced source code
|
|---|
| 18 | */
|
|---|
| 19 | code: string;
|
|---|
| 20 | }
|
|---|
| 21 | /**
|
|---|
| 22 | * The file and offsets within it that this node covers
|
|---|
| 23 | *
|
|---|
| 24 | * This can represent either:
|
|---|
| 25 | * - A location in the original CSS which caused this node to be created
|
|---|
| 26 | * - A location in the output CSS where this node resides
|
|---|
| 27 | */
|
|---|
| 28 | type SourceLocation = [source: Source, start: number, end: number];
|
|---|
| 29 |
|
|---|
| 30 | type Config = UserConfig;
|
|---|
| 31 | type PluginFn = (api: PluginAPI) => void;
|
|---|
| 32 | type PluginWithConfig = {
|
|---|
| 33 | handler: PluginFn;
|
|---|
| 34 | config?: UserConfig;
|
|---|
| 35 | /** @internal */
|
|---|
| 36 | reference?: boolean;
|
|---|
| 37 | src?: SourceLocation | undefined;
|
|---|
| 38 | };
|
|---|
| 39 | type PluginWithOptions<T> = {
|
|---|
| 40 | (options?: T): PluginWithConfig;
|
|---|
| 41 | __isOptionsFunction: true;
|
|---|
| 42 | };
|
|---|
| 43 | type Plugin = PluginFn | PluginWithConfig | PluginWithOptions<any>;
|
|---|
| 44 | type PluginAPI = {
|
|---|
| 45 | addBase(base: CssInJs): void;
|
|---|
| 46 | addVariant(name: string, variant: string | string[] | CssInJs): void;
|
|---|
| 47 | matchVariant<T = string>(name: string, cb: (value: T | string, extra: {
|
|---|
| 48 | modifier: string | null;
|
|---|
| 49 | }) => string | string[], options?: {
|
|---|
| 50 | values?: Record<string, T>;
|
|---|
| 51 | sort?(a: {
|
|---|
| 52 | value: T | string;
|
|---|
| 53 | modifier: string | null;
|
|---|
| 54 | }, b: {
|
|---|
| 55 | value: T | string;
|
|---|
| 56 | modifier: string | null;
|
|---|
| 57 | }): number;
|
|---|
| 58 | }): void;
|
|---|
| 59 | addUtilities(utilities: Record<string, CssInJs | CssInJs[]> | Record<string, CssInJs | CssInJs[]>[], options?: {}): void;
|
|---|
| 60 | matchUtilities(utilities: Record<string, (value: string, extra: {
|
|---|
| 61 | modifier: string | null;
|
|---|
| 62 | }) => CssInJs | CssInJs[]>, options?: Partial<{
|
|---|
| 63 | type: string | string[];
|
|---|
| 64 | supportsNegativeValues: boolean;
|
|---|
| 65 | values: Record<string, string> & {
|
|---|
| 66 | __BARE_VALUE__?: (value: NamedUtilityValue) => string | undefined;
|
|---|
| 67 | };
|
|---|
| 68 | modifiers: 'any' | Record<string, string>;
|
|---|
| 69 | }>): void;
|
|---|
| 70 | addComponents(utilities: Record<string, CssInJs> | Record<string, CssInJs>[], options?: {}): void;
|
|---|
| 71 | matchComponents(utilities: Record<string, (value: string, extra: {
|
|---|
| 72 | modifier: string | null;
|
|---|
| 73 | }) => CssInJs>, options?: Partial<{
|
|---|
| 74 | type: string | string[];
|
|---|
| 75 | supportsNegativeValues: boolean;
|
|---|
| 76 | values: Record<string, string> & {
|
|---|
| 77 | __BARE_VALUE__?: (value: NamedUtilityValue) => string | undefined;
|
|---|
| 78 | };
|
|---|
| 79 | modifiers: 'any' | Record<string, string>;
|
|---|
| 80 | }>): void;
|
|---|
| 81 | theme(path: string, defaultValue?: any): any;
|
|---|
| 82 | config(path?: string, defaultValue?: any): any;
|
|---|
| 83 | prefix(className: string): string;
|
|---|
| 84 | };
|
|---|
| 85 | type CssInJs = {
|
|---|
| 86 | [key: string]: string | string[] | CssInJs | CssInJs[];
|
|---|
| 87 | };
|
|---|
| 88 |
|
|---|
| 89 | type ResolvableTo<T> = T | ((utils: PluginUtils) => T);
|
|---|
| 90 | type ThemeValue = ResolvableTo<Record<string, unknown>> | null | undefined;
|
|---|
| 91 | type ThemeConfig = Record<string, ThemeValue> & {
|
|---|
| 92 | extend?: Record<string, ThemeValue>;
|
|---|
| 93 | };
|
|---|
| 94 | type ContentFile = string | {
|
|---|
| 95 | raw: string;
|
|---|
| 96 | extension?: string;
|
|---|
| 97 | };
|
|---|
| 98 | type DarkModeStrategy = false | 'media' | 'class' | ['class', string] | 'selector' | ['selector', string] | ['variant', string | string[]];
|
|---|
| 99 | interface UserConfig {
|
|---|
| 100 | presets?: UserConfig[];
|
|---|
| 101 | theme?: ThemeConfig;
|
|---|
| 102 | plugins?: Plugin[];
|
|---|
| 103 | }
|
|---|
| 104 | interface UserConfig {
|
|---|
| 105 | content?: ContentFile[] | {
|
|---|
| 106 | relative?: boolean;
|
|---|
| 107 | files: ContentFile[];
|
|---|
| 108 | };
|
|---|
| 109 | }
|
|---|
| 110 | interface UserConfig {
|
|---|
| 111 | darkMode?: DarkModeStrategy;
|
|---|
| 112 | }
|
|---|
| 113 | interface UserConfig {
|
|---|
| 114 | prefix?: string;
|
|---|
| 115 | }
|
|---|
| 116 | interface UserConfig {
|
|---|
| 117 | blocklist?: string[];
|
|---|
| 118 | }
|
|---|
| 119 | interface UserConfig {
|
|---|
| 120 | important?: boolean | string;
|
|---|
| 121 | }
|
|---|
| 122 | interface UserConfig {
|
|---|
| 123 | future?: 'all' | Record<string, boolean>;
|
|---|
| 124 | }
|
|---|
| 125 | interface UserConfig {
|
|---|
| 126 | experimental?: 'all' | Record<string, boolean>;
|
|---|
| 127 | }
|
|---|
| 128 |
|
|---|
| 129 | declare function createPlugin(handler: PluginFn, config?: Partial<Config>): PluginWithConfig;
|
|---|
| 130 | declare namespace createPlugin {
|
|---|
| 131 | var withOptions: <T>(pluginFunction: (options?: T) => PluginFn, configFunction?: (options?: T) => Partial<Config>) => PluginWithOptions<T>;
|
|---|
| 132 | }
|
|---|
| 133 |
|
|---|
| 134 | export { createPlugin as default };
|
|---|