client.d.ts 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. export declare const globalField = "__VITE_THEME__";
  2. export declare const styleTagId = "__VITE_PLUGIN_THEME__";
  3. export declare const darkStyleTagId = "__VITE_PLUGIN_DARK_THEME__";
  4. export declare const linkID = "__VITE_PLUGIN_THEME-ANTD_DARK_THEME_LINK__";
  5. export interface Options {
  6. colorVariables: string[];
  7. wrapperCssSelector?: string;
  8. resolveSelector?: (selector: string) => string;
  9. fileName?: string;
  10. inline?: boolean;
  11. injectTo?: InjectTo;
  12. }
  13. export interface GlobalConfig {
  14. replaceStyleVariables: ({ colorVariables }: {
  15. colorVariables: string[];
  16. }) => void;
  17. colorVariables: string[];
  18. defaultOptions: Options;
  19. appended?: boolean;
  20. styleIdMap?: Map<string, string>;
  21. styleRenderQueueMap?: Map<string, string>;
  22. }
  23. export declare type InjectTo = 'head' | 'body' | 'body-prepend';
  24. declare global {
  25. interface Window {
  26. [globalField]: GlobalConfig;
  27. }
  28. }
  29. export declare let darkCssIsReady: boolean;
  30. export declare function addCssToQueue(id: string, styleString: string): void;
  31. export declare function replaceStyleVariables({ colorVariables, customCssHandler, }: {
  32. colorVariables: string[];
  33. customCssHandler?: (css: string) => string;
  34. }): Promise<void>;
  35. export declare function loadDarkThemeCss(): Promise<void>;
  36. export declare function replaceCssColors(css: string, colors: string[], customCssHandler?: (css: string) => string): Promise<string>;
  37. export declare function setGlobalOptions<T extends keyof GlobalConfig = any>(key: T, value: GlobalConfig[T]): void;
  38. export declare function getGlobalOptions<T extends keyof GlobalConfig = any>(key: T): GlobalConfig[T];
  39. export declare function getStyleDom(id: string): HTMLElement;
  40. export declare function appendCssToDom(styleDom: HTMLElement, cssText: string, appendTo?: InjectTo): Promise<void>;