1 | import type { BaseAtomAssetsParser as IAtomAssetsParser } from "./assetParsers/BaseParser";
|
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 { OnLoadArgs, OnLoadResult } from '@umijs/bundler-utils/compiled/esbuild';
|
8 | import type { IModify } from '@umijs/core';
|
9 | import type { AssetsPackage, ExampleBlockAsset } from 'dumi-assets-types';
|
10 | import type { Element } from 'hast';
|
11 | import type { IApi as IUmiApi, defineConfig as defineUmiConfig } from 'umi';
|
12 | type Subset<K> = {
|
13 | [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];
|
14 | };
|
15 | type NoStringIndex<T> = {
|
16 | [K in keyof T as string extends K ? never : K]: T[K];
|
17 | };
|
18 | type IUmiConfig = Omit<NoStringIndex<Parameters<typeof defineUmiConfig>[0]>, 'resolve' | 'extraRemarkPlugins' | 'extraRehypePlugins' | 'themeConfig'>;
|
19 | interface IDumiExtendsConfig {
|
20 | resolve: {
|
21 | docDirs: (string | {
|
22 | type?: string;
|
23 | dir: string;
|
24 | })[];
|
25 | atomDirs: {
|
26 | type: string;
|
27 | subType?: string;
|
28 | dir: string;
|
29 | }[];
|
30 | codeBlockMode: 'active' | 'passive';
|
31 | entryFile?: string;
|
32 | forceKebabCaseRouting: boolean;
|
33 | };
|
34 | locales: ILocalesConfig;
|
35 | themeConfig: IThemeConfig;
|
36 | autoAlias?: boolean;
|
37 | |
38 |
|
39 |
|
40 | extraRemarkPlugins?: (string | Function | [string | Function, object])[];
|
41 | extraRehypePlugins?: (string | Function | [string | Function, object])[];
|
42 | }
|
43 | export type IDumiConfig = Omit<IUmiConfig, 'locales'> & IDumiExtendsConfig;
|
44 | export type IDumiUserConfig = Subset<Omit<IDumiConfig, 'locales'>> & {
|
45 | locales?: Exclude<IDumiConfig['locales'][0], {
|
46 | base: string;
|
47 | }>[] | Omit<Exclude<IDumiConfig['locales'][0], {
|
48 | suffix: string;
|
49 | }>, 'base'>[];
|
50 | [key: string]: any;
|
51 | };
|
52 | export interface IDumiTechStackOnBlockLoadResult {
|
53 | content: string;
|
54 | type: Required<OnLoadResult>['loader'];
|
55 | }
|
56 | export type IDumiTechStackOnBlockLoadArgs = OnLoadArgs & {
|
57 | entryPointCode: string;
|
58 | filename: string;
|
59 | };
|
60 | export interface IDumiTechStackRuntimeOpts {
|
61 | |
62 |
|
63 |
|
64 |
|
65 | preflightPath?: string;
|
66 | |
67 |
|
68 |
|
69 |
|
70 | rendererPath?: string;
|
71 | |
72 |
|
73 |
|
74 | compilePath?: string;
|
75 | |
76 |
|
77 |
|
78 | pluginPath?: string;
|
79 | }
|
80 | export declare abstract class IDumiTechStack {
|
81 | |
82 |
|
83 |
|
84 | abstract name: string;
|
85 | |
86 |
|
87 |
|
88 | abstract runtimeOpts?: IDumiTechStackRuntimeOpts;
|
89 | |
90 |
|
91 |
|
92 |
|
93 |
|
94 | abstract isSupported(node: Element, lang: string): boolean;
|
95 | |
96 |
|
97 |
|
98 | abstract transformCode(raw: string, opts: {
|
99 | type: 'external' | 'code-block';
|
100 | fileAbsPath: string;
|
101 | }): string;
|
102 | |
103 |
|
104 |
|
105 | abstract generateMetadata?(asset: ExampleBlockAsset, opts: {
|
106 | type: Parameters<IDumiTechStack['transformCode']>[1]['type'];
|
107 | mdAbsPath: string;
|
108 | fileAbsPath?: string;
|
109 | entryPointCode?: string;
|
110 | }): Promise<ExampleBlockAsset> | ExampleBlockAsset;
|
111 | |
112 |
|
113 |
|
114 | abstract generatePreviewerProps?(props: IDumiDemoProps['previewerProps'], opts: Parameters<NonNullable<IDumiTechStack['generateMetadata']>>[1]): Promise<IDumiDemoProps['previewerProps']> | IDumiDemoProps['previewerProps'];
|
115 | |
116 |
|
117 |
|
118 | abstract generateSources?(source: IParsedBlockAsset['resolveMap'], opts: Parameters<NonNullable<IDumiTechStack['generateMetadata']>>[1]): Promise<IParsedBlockAsset['resolveMap']> | IParsedBlockAsset['resolveMap'];
|
119 | |
120 |
|
121 |
|
122 |
|
123 |
|
124 |
|
125 |
|
126 |
|
127 | abstract onBlockLoad?(args: IDumiTechStackOnBlockLoadArgs): IDumiTechStackOnBlockLoadResult | null;
|
128 | }
|
129 | export type IApi = IUmiApi & {
|
130 | config: IDumiConfig & {
|
131 | [key: string]: any;
|
132 | };
|
133 | userConfig: IDumiUserConfig;
|
134 | service: IUmiApi['service'] & {
|
135 | themeData: IThemeLoadResult;
|
136 | atomParser: IAtomAssetsParser;
|
137 | };
|
138 | |
139 |
|
140 |
|
141 | registerTechStack: (fn: () => IDumiTechStack) => void;
|
142 | |
143 |
|
144 |
|
145 | modifyTheme: IModify<IThemeLoadResult, null>;
|
146 | |
147 |
|
148 |
|
149 | addContentTab: (fn: () => IContentTab) => void;
|
150 | |
151 |
|
152 |
|
153 | modifyAssetsMetadata: IModify<AssetsPackage, null>;
|
154 | |
155 |
|
156 |
|
157 | getAssetsMetadata?: () => Promise<AssetsPackage>;
|
158 | };
|
159 | export {};
|