import type AtomAssetsParser from "./assetParsers/atom"; import type { IParsedBlockAsset } from "./assetParsers/block"; import type { IDumiDemoProps } from "./client/theme-api/DumiDemo"; import type { ILocalesConfig, IThemeConfig } from "./client/theme-api/types"; import type { IContentTab } from "./features/tabs"; import type { IThemeLoadResult } from "./features/theme/loader"; import type { IModify } from '@umijs/core'; import type { AssetsPackage, ExampleBlockAsset } from 'dumi-assets-types'; import type { Element } from 'hast'; import type { defineConfig as defineUmiConfig, IApi as IUmiApi } from 'umi'; type Subset = { [attr in keyof K]?: K[attr] extends Array ? K[attr] : K[attr] extends Function | undefined ? K[attr] : K[attr] extends object ? Subset : K[attr] extends object | null ? Subset | null : K[attr] extends object | null | undefined ? Subset | null | undefined : K[attr]; }; type NoStringIndex = { [K in keyof T as string extends K ? never : K]: T[K]; }; type IUmiConfig = Omit[0]>, 'resolve' | 'extraRemarkPlugins' | 'extraRehypePlugins' | 'themeConfig'>; interface IDumiExtendsConfig { resolve: { docDirs: (string | { type?: string; dir: string; })[]; atomDirs: { type: string; subType?: string; dir: string; }[]; codeBlockMode: 'active' | 'passive'; entryFile?: string; forceKebabCaseRouting: boolean; }; locales: ILocalesConfig; themeConfig: IThemeConfig; autoAlias?: boolean; /** * extra unified plugins */ extraRemarkPlugins?: (string | Function | [string | Function, object])[]; extraRehypePlugins?: (string | Function | [string | Function, object])[]; } export type IDumiConfig = Omit & IDumiExtendsConfig; export type IDumiUserConfig = Subset> & { locales?: Exclude[] | Omit, 'base'>[]; [key: string]: any; }; export declare abstract class IDumiTechStack { /** * tech stack name, such as 'react' */ abstract name: string; /** * transform code */ abstract isSupported(node: Element, lang: string): boolean; /** * transform for parse demo source to react component */ abstract transformCode(raw: string, opts: { type: 'external' | 'code-block'; fileAbsPath: string; }): string; /** * generator for return asset metadata */ abstract generateMetadata?(asset: ExampleBlockAsset, opts: { type: Parameters[1]['type']; mdAbsPath: string; fileAbsPath?: string; entryPointCode?: string; }): Promise | ExampleBlockAsset; /** * generator for return previewer props */ abstract generatePreviewerProps?(props: IDumiDemoProps['previewerProps'], opts: Parameters>[1]): Promise | IDumiDemoProps['previewerProps']; /** * generator for return file path of demo sources */ abstract generateSources?(sources: IParsedBlockAsset['sources'], opts: Parameters>[1]): Promise | IParsedBlockAsset['sources']; } export type IApi = IUmiApi & { config: IDumiConfig & { [key: string]: any; }; userConfig: IDumiUserConfig; service: IUmiApi['service'] & { themeData: IThemeLoadResult; atomParser: AtomAssetsParser; }; /** * register a new tech stack */ registerTechStack: (fn: () => IDumiTechStack) => void; /** * modify original theme data */ modifyTheme: IModify; /** * add content tab */ addContentTab: (fn: () => IContentTab) => void; /** * modify assets metadata */ modifyAssetsMetadata: IModify; /** * get assets metadata */ getAssetsMetadata?: () => Promise; }; export {};