1 | import type AtomAssetsParser from "./assetParsers/atom";
|
2 | import type { IParsedBlockAsset } from "./assetParsers/block";
|
3 | import type { IDumiDemoProps } from "./client/theme-api/DumiDemo";
|
4 | import type { ILocalesConfig, IThemeConfig } from "./client/theme-api/types";
|
5 | import type { IContentTab } from "./features/tabs";
|
6 | import type { IThemeLoadResult } from "./features/theme/loader";
|
7 | import type { IModify } from '@umijs/core';
|
8 | import type { AssetsPackage, ExampleBlockAsset } from 'dumi-assets-types';
|
9 | import type { Element } from 'hast';
|
10 | import type { defineConfig as defineUmiConfig, IApi as IUmiApi } from 'umi';
|
11 | type Subset<K> = {
|
12 | [attr in keyof K]?: K[attr] extends Array<any> ? K[attr] : K[attr] extends Function | undefined ? K[attr] : K[attr] extends object ? Subset<K[attr]> : K[attr] extends object | null ? Subset<K[attr]> | null : K[attr] extends object | null | undefined ? Subset<K[attr]> | null | undefined : K[attr];
|
13 | };
|
14 | type NoStringIndex<T> = {
|
15 | [K in keyof T as string extends K ? never : K]: T[K];
|
16 | };
|
17 | type IUmiConfig = Omit<NoStringIndex<Parameters<typeof defineUmiConfig>[0]>, 'resolve' | 'extraRemarkPlugins' | 'extraRehypePlugins' | 'themeConfig'>;
|
18 | interface IDumiExtendsConfig {
|
19 | resolve: {
|
20 | docDirs: (string | {
|
21 | type?: string;
|
22 | dir: string;
|
23 | })[];
|
24 | atomDirs: {
|
25 | type: string;
|
26 | subType?: string;
|
27 | dir: string;
|
28 | }[];
|
29 | codeBlockMode: 'active' | 'passive';
|
30 | entryFile?: string;
|
31 | forceKebabCaseRouting: boolean;
|
32 | };
|
33 | locales: ILocalesConfig;
|
34 | themeConfig: IThemeConfig;
|
35 | autoAlias?: boolean;
|
36 | |
37 |
|
38 |
|
39 | extraRemarkPlugins?: (string | Function | [string | Function, object])[];
|
40 | extraRehypePlugins?: (string | Function | [string | Function, object])[];
|
41 | }
|
42 | export type IDumiConfig = Omit<IUmiConfig, 'locales'> & IDumiExtendsConfig;
|
43 | export type IDumiUserConfig = Subset<Omit<IDumiConfig, 'locales'>> & {
|
44 | locales?: Exclude<IDumiConfig['locales'][0], {
|
45 | base: string;
|
46 | }>[] | Omit<Exclude<IDumiConfig['locales'][0], {
|
47 | suffix: string;
|
48 | }>, 'base'>[];
|
49 | [key: string]: any;
|
50 | };
|
51 | export declare abstract class IDumiTechStack {
|
52 | |
53 |
|
54 |
|
55 | abstract name: string;
|
56 | |
57 |
|
58 |
|
59 | abstract isSupported(node: Element, lang: string): boolean;
|
60 | |
61 |
|
62 |
|
63 | abstract transformCode(raw: string, opts: {
|
64 | type: 'external' | 'code-block';
|
65 | fileAbsPath: string;
|
66 | }): string;
|
67 | |
68 |
|
69 |
|
70 | abstract generateMetadata?(asset: ExampleBlockAsset, opts: {
|
71 | type: Parameters<IDumiTechStack['transformCode']>[1]['type'];
|
72 | mdAbsPath: string;
|
73 | fileAbsPath?: string;
|
74 | entryPointCode?: string;
|
75 | }): Promise<ExampleBlockAsset> | ExampleBlockAsset;
|
76 | |
77 |
|
78 |
|
79 | abstract generatePreviewerProps?(props: IDumiDemoProps['previewerProps'], opts: Parameters<NonNullable<IDumiTechStack['generateMetadata']>>[1]): Promise<IDumiDemoProps['previewerProps']> | IDumiDemoProps['previewerProps'];
|
80 | |
81 |
|
82 |
|
83 | abstract generateSources?(sources: IParsedBlockAsset['sources'], opts: Parameters<NonNullable<IDumiTechStack['generateMetadata']>>[1]): Promise<IParsedBlockAsset['sources']> | IParsedBlockAsset['sources'];
|
84 | }
|
85 | export type IApi = IUmiApi & {
|
86 | config: IDumiConfig & {
|
87 | [key: string]: any;
|
88 | };
|
89 | userConfig: IDumiUserConfig;
|
90 | service: IUmiApi['service'] & {
|
91 | themeData: IThemeLoadResult;
|
92 | atomParser: AtomAssetsParser;
|
93 | };
|
94 | |
95 |
|
96 |
|
97 | registerTechStack: (fn: () => IDumiTechStack) => void;
|
98 | |
99 |
|
100 |
|
101 | modifyTheme: IModify<IThemeLoadResult, null>;
|
102 | |
103 |
|
104 |
|
105 | addContentTab: (fn: () => IContentTab) => void;
|
106 | |
107 |
|
108 |
|
109 | modifyAssetsMetadata: IModify<AssetsPackage, null>;
|
110 | |
111 |
|
112 |
|
113 | getAssetsMetadata?: () => Promise<AssetsPackage>;
|
114 | };
|
115 | export {};
|