dumi 2.4.29 → 2.4.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/compiled/crates/swc_plugin_react_demo.wasm +0 -0
- package/dist/assetParsers/BaseParser.d.ts +55 -0
- package/dist/assetParsers/atom.d.ts +21 -0
- package/dist/assetParsers/block.d.ts +25 -0
- package/dist/assetParsers/utils.d.ts +79 -0
- package/dist/cli.d.ts +1 -0
- package/dist/client/misc/reactDemoCompiler.d.ts +3 -0
- package/dist/client/pages/404.d.ts +1 -0
- package/dist/client/pages/Demo/index.d.ts +4 -0
- package/dist/client/pages/Loading.d.ts +1 -0
- package/dist/client/theme-api/AtomRenderer.d.ts +13 -0
- package/dist/client/theme-api/DumiDemo/DemoErrorBoundary.d.ts +5 -0
- package/dist/client/theme-api/DumiDemo/index.d.ts +10 -0
- package/dist/client/theme-api/DumiDemoGrid.d.ts +7 -0
- package/dist/client/theme-api/DumiPage.d.ts +4 -0
- package/dist/client/theme-api/context.d.ts +22 -0
- package/dist/client/theme-api/index.d.ts +18 -0
- package/dist/client/theme-api/openCodeSandbox.d.ts +10 -0
- package/dist/client/theme-api/openStackBlitz.d.ts +2 -0
- package/dist/client/theme-api/types.d.ts +258 -0
- package/dist/client/theme-api/useAtomAssets.d.ts +4 -0
- package/dist/client/theme-api/useLiveDemo.d.ts +10 -0
- package/dist/client/theme-api/useLocale.d.ts +2 -0
- package/dist/client/theme-api/useNavData.d.ts +5 -0
- package/dist/client/theme-api/usePrefersColor.d.ts +7 -0
- package/dist/client/theme-api/useRenderer.d.ts +12 -0
- package/dist/client/theme-api/useRouteMeta.d.ts +17 -0
- package/dist/client/theme-api/useSidebarData.d.ts +29 -0
- package/dist/client/theme-api/useSiteSearch/index.d.ts +24 -0
- package/dist/client/theme-api/useSiteSearch/useSearchData.d.ts +12 -0
- package/dist/client/theme-api/useTabMeta.d.ts +4 -0
- package/dist/client/theme-api/utils.d.ts +31 -0
- package/dist/constants.d.ts +23 -0
- package/dist/features/assets.d.ts +20 -0
- package/dist/features/assets.js +2 -1
- package/dist/features/autoAlias.d.ts +3 -0
- package/dist/features/compile/babelLoaderCustomize.d.ts +4 -0
- package/dist/features/compile/index.d.ts +4 -0
- package/dist/features/compile/makoHooks.d.ts +9 -0
- package/dist/features/compile/utils.d.ts +2 -0
- package/dist/features/compile/utoopackLoaders.d.ts +8 -0
- package/dist/features/configPlugins/index.d.ts +3 -0
- package/dist/features/configPlugins/schema.d.ts +4 -0
- package/dist/features/derivative.d.ts +11 -0
- package/dist/features/exportStatic.d.ts +3 -0
- package/dist/features/exports.d.ts +3 -0
- package/dist/features/html2sketch.d.ts +3 -0
- package/dist/features/locales.d.ts +3 -0
- package/dist/features/meta.d.ts +5 -0
- package/dist/features/parser.d.ts +3 -0
- package/dist/features/routes.d.ts +3 -0
- package/dist/features/sideEffects/docSideEffectsWebpackPlugin.d.ts +14 -0
- package/dist/features/sideEffects/index.d.ts +7 -0
- package/dist/features/sitemap.d.ts +3 -0
- package/dist/features/sitemap.js +5 -2
- package/dist/features/tabs.d.ts +17 -0
- package/dist/features/tabs.js +7 -4
- package/dist/features/theme/index.d.ts +3 -0
- package/dist/features/theme/index.js +6 -4
- package/dist/features/theme/loader.d.ts +55 -0
- package/dist/index.d.ts +6 -0
- package/dist/loaders/demo/index.d.ts +6 -0
- package/dist/loaders/markdown/index.d.ts +27 -0
- package/dist/loaders/markdown/transformer/index.d.ts +69 -0
- package/dist/loaders/markdown/transformer/rehypeDemo.d.ts +15 -0
- package/dist/loaders/markdown/transformer/rehypeDesc.d.ts +6 -0
- package/dist/loaders/markdown/transformer/rehypeEnhancedTag.d.ts +3 -0
- package/dist/loaders/markdown/transformer/rehypeHighlightLine.d.ts +4 -0
- package/dist/loaders/markdown/transformer/rehypeImg.d.ts +6 -0
- package/dist/loaders/markdown/transformer/rehypeIsolation.d.ts +7 -0
- package/dist/loaders/markdown/transformer/rehypeJsxify.d.ts +2 -0
- package/dist/loaders/markdown/transformer/rehypeLink.d.ts +6 -0
- package/dist/loaders/markdown/transformer/rehypeRaw.d.ts +6 -0
- package/dist/loaders/markdown/transformer/rehypeSlug.d.ts +4 -0
- package/dist/loaders/markdown/transformer/rehypeStrip.d.ts +3 -0
- package/dist/loaders/markdown/transformer/rehypeText.d.ts +4 -0
- package/dist/loaders/markdown/transformer/remarkBreaks.d.ts +3 -0
- package/dist/loaders/markdown/transformer/remarkContainer.d.ts +3 -0
- package/dist/loaders/markdown/transformer/remarkEmbed.d.ts +4 -0
- package/dist/loaders/markdown/transformer/remarkMeta.d.ts +8 -0
- package/dist/loaders/null/index.d.ts +2 -0
- package/dist/loaders/page/index.d.ts +1 -0
- package/dist/loaders/post-raw/index.d.ts +4 -0
- package/dist/loaders/pre-raw/index.d.ts +4 -0
- package/dist/preset.d.ts +5 -0
- package/dist/registerMethods.d.ts +3 -0
- package/dist/service/cli.d.ts +5 -0
- package/dist/service/constants.d.ts +4 -0
- package/dist/service/dev.d.ts +1 -0
- package/dist/service/forkedDev.d.ts +1 -0
- package/dist/service/printHelp.d.ts +1 -0
- package/dist/service/service.d.ts +13 -0
- package/dist/techStacks/react.d.ts +7 -0
- package/dist/techStacks/utils.d.ts +40 -0
- package/dist/types.d.ts +159 -0
- package/dist/utils.d.ts +67 -0
- package/dumi-types.d.ts +115 -0
- package/index.d.ts +64 -5
- package/package.json +4 -1
- package/theme-api.d.ts +319 -0
- package/theme-default/builtins/API/index.d.ts +7 -0
- package/theme-default/builtins/Badge/index.d.ts +7 -0
- package/theme-default/builtins/CodeGroup/index.d.ts +3 -0
- package/theme-default/builtins/Container/index.d.ts +8 -0
- package/theme-default/builtins/Previewer/index.d.ts +5 -0
- package/theme-default/builtins/SourceCode/index.d.ts +14 -0
- package/theme-default/builtins/Table/index.d.ts +6 -0
- package/theme-default/builtins/Tree/index.d.ts +5 -0
- package/theme-default/builtins/Tree/index.js +11 -11
- package/theme-default/layouts/DocLayout/index.d.ts +4 -0
- package/theme-default/slots/ColorSwitch/index.d.ts +4 -0
- package/theme-default/slots/Content/index.d.ts +7 -0
- package/theme-default/slots/ContentFooter/index.d.ts +4 -0
- package/theme-default/slots/ContentTabs/index.d.ts +11 -0
- package/theme-default/slots/Features/index.d.ts +4 -0
- package/theme-default/slots/Footer/index.d.ts +4 -0
- package/theme-default/slots/Header/index.d.ts +4 -0
- package/theme-default/slots/Header/index.js +5 -2
- package/theme-default/slots/HeaderExtra/index.d.ts +3 -0
- package/theme-default/slots/Hero/index.d.ts +4 -0
- package/theme-default/slots/HeroTitle/index.d.ts +6 -0
- package/theme-default/slots/LangSwitch/index.d.ts +4 -0
- package/theme-default/slots/Loading/index.d.ts +5 -0
- package/theme-default/slots/Logo/index.d.ts +4 -0
- package/theme-default/slots/Navbar/index.d.ts +4 -0
- package/theme-default/slots/NavbarExtra/index.d.ts +3 -0
- package/theme-default/slots/NotFound/index.d.ts +4 -0
- package/theme-default/slots/PreviewerActions/index.d.ts +27 -0
- package/theme-default/slots/PreviewerActionsExtra/index.d.ts +4 -0
- package/theme-default/slots/RtlSwitch/index.d.ts +4 -0
- package/theme-default/slots/SearchBar/Input.d.ts +6 -0
- package/theme-default/slots/SearchBar/Mask.d.ts +9 -0
- package/theme-default/slots/SearchBar/index.d.ts +6 -0
- package/theme-default/slots/SearchResult/index.d.ts +10 -0
- package/theme-default/slots/Sidebar/index.d.ts +4 -0
- package/theme-default/slots/SocialIcon/index.d.ts +15 -0
- package/theme-default/slots/SourceCodeEditor/index.d.ts +20 -0
- package/theme-default/slots/Tabs/index.d.ts +6 -0
- package/theme-default/slots/Toc/index.d.ts +4 -0
- package/theme-modules.d.ts +62 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Root } from 'mdast';
|
|
2
|
+
import type { Transformer } from 'unified';
|
|
3
|
+
import type { IMdTransformerOptions } from '.';
|
|
4
|
+
type IRemarkMetaOpts = Pick<IMdTransformerOptions, 'cwd' | 'fileAbsPath' | 'resolve'> & {
|
|
5
|
+
fileLocaleLessPath: string;
|
|
6
|
+
};
|
|
7
|
+
export default function remarkMeta(opts: IRemarkMetaOpts): Transformer<Root>;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function pageMetaLoader(this: any, raw: string): string;
|
package/dist/preset.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function dev(): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function printHelp(): void;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Service } from 'umi';
|
|
2
|
+
export declare class DumiService extends Service {
|
|
3
|
+
constructor();
|
|
4
|
+
getPaths(): Promise<{
|
|
5
|
+
cwd: string;
|
|
6
|
+
absSrcPath: string;
|
|
7
|
+
absPagesPath: string;
|
|
8
|
+
absApiRoutesPath: string;
|
|
9
|
+
absTmpPath: string;
|
|
10
|
+
absNodeModulesPath: string;
|
|
11
|
+
absOutputPath: string;
|
|
12
|
+
}>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { IDumiTechStack } from "../types";
|
|
2
|
+
export default class ReactTechStack implements IDumiTechStack {
|
|
3
|
+
name: string;
|
|
4
|
+
runtimeOpts?: IDumiTechStack['runtimeOpts'];
|
|
5
|
+
isSupported(...[, lang]: Parameters<IDumiTechStack['isSupported']>): boolean;
|
|
6
|
+
transformCode(...[raw, opts]: Parameters<IDumiTechStack['transformCode']>): string;
|
|
7
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { ParserConfig } from '@swc/core';
|
|
2
|
+
import { IDumiTechStack } from '../types';
|
|
3
|
+
export { IDumiTechStack, IDumiTechStackOnBlockLoadArgs, IDumiTechStackOnBlockLoadResult, IDumiTechStackRuntimeOpts, } from '../types';
|
|
4
|
+
/**
|
|
5
|
+
* for frameworks like vue , we need to extract the JS fragments in their scripts
|
|
6
|
+
* @param htmlLike HTML, vue and other html-like files are available
|
|
7
|
+
* @returns js/ts code
|
|
8
|
+
*/
|
|
9
|
+
export declare function extractScript(htmlLike: string): string;
|
|
10
|
+
export interface IWrapDemoWithFnOptions {
|
|
11
|
+
filename: string;
|
|
12
|
+
parserConfig: ParserConfig;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Use swc to convert es module into async function.
|
|
16
|
+
* More transform process detail, refer to:
|
|
17
|
+
* https://github.com/umijs/dumi/blob/master/crates/swc_plugin_react_demo/src/lib.rs#L126
|
|
18
|
+
*/
|
|
19
|
+
export declare function wrapDemoWithFn(code: string, opts: IWrapDemoWithFnOptions): string;
|
|
20
|
+
export type IDefineTechStackOptions = IDumiTechStack;
|
|
21
|
+
/**
|
|
22
|
+
* Define a tech stack
|
|
23
|
+
* @param options techstack options
|
|
24
|
+
* @returns function that returns {@link IDumiTechStack}, can be used to register a techstack
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* const ReactTechStack = defineTechStack({
|
|
28
|
+
* name: 'jsx',
|
|
29
|
+
* isSupported(_, lang) {
|
|
30
|
+
* return ['jsx', 'tsx'].includes(lang);
|
|
31
|
+
* },
|
|
32
|
+
* transformCode() {
|
|
33
|
+
* // ...
|
|
34
|
+
* return '';
|
|
35
|
+
* },
|
|
36
|
+
* });
|
|
37
|
+
*
|
|
38
|
+
* api.registerTechStack(() => ReactTechStack);
|
|
39
|
+
*/
|
|
40
|
+
export declare function defineTechStack(options: IDefineTechStackOptions): IDumiTechStack;
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
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
|
+
* extra unified plugins
|
|
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
|
+
* Component detection function path,
|
|
63
|
+
* used to detect errors that occur from application creation to component mounting.
|
|
64
|
+
*/
|
|
65
|
+
preflightPath?: string;
|
|
66
|
+
/**
|
|
67
|
+
* path of the cancelable{@link IDemoCancelableFn} function
|
|
68
|
+
* that manipulate(mount/unmount) third-party framework component
|
|
69
|
+
*/
|
|
70
|
+
rendererPath?: string;
|
|
71
|
+
/**
|
|
72
|
+
* path to runtime compile function module
|
|
73
|
+
*/
|
|
74
|
+
compilePath?: string;
|
|
75
|
+
/**
|
|
76
|
+
* path to runtime plugin for this tech stack
|
|
77
|
+
*/
|
|
78
|
+
pluginPath?: string;
|
|
79
|
+
}
|
|
80
|
+
export declare abstract class IDumiTechStack {
|
|
81
|
+
/**
|
|
82
|
+
* tech stack name, such as 'react'
|
|
83
|
+
*/
|
|
84
|
+
abstract name: string;
|
|
85
|
+
/**
|
|
86
|
+
* runtime options
|
|
87
|
+
*/
|
|
88
|
+
abstract runtimeOpts?: IDumiTechStackRuntimeOpts;
|
|
89
|
+
/**
|
|
90
|
+
* Is the lang supported by the current tech stack?
|
|
91
|
+
* @param lang
|
|
92
|
+
* @param node hast Element https://github.com/syntax-tree/hast?tab=readme-ov-file#element
|
|
93
|
+
*/
|
|
94
|
+
abstract isSupported(node: Element, lang: string): boolean;
|
|
95
|
+
/**
|
|
96
|
+
* transform for parse demo source to expression/function/class
|
|
97
|
+
*/
|
|
98
|
+
abstract transformCode(raw: string, opts: {
|
|
99
|
+
type: 'external' | 'code-block';
|
|
100
|
+
fileAbsPath: string;
|
|
101
|
+
}): string;
|
|
102
|
+
/**
|
|
103
|
+
* generator for return asset metadata
|
|
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
|
+
* generator for return previewer props
|
|
113
|
+
*/
|
|
114
|
+
abstract generatePreviewerProps?(props: IDumiDemoProps['previewerProps'], opts: Parameters<NonNullable<IDumiTechStack['generateMetadata']>>[1]): Promise<IDumiDemoProps['previewerProps']> | IDumiDemoProps['previewerProps'];
|
|
115
|
+
/**
|
|
116
|
+
* generator for return file path of demo source
|
|
117
|
+
*/
|
|
118
|
+
abstract generateSources?(source: IParsedBlockAsset['resolveMap'], opts: Parameters<NonNullable<IDumiTechStack['generateMetadata']>>[1]): Promise<IParsedBlockAsset['resolveMap']> | IParsedBlockAsset['resolveMap'];
|
|
119
|
+
/**
|
|
120
|
+
* Use current function as onLoad CallBack(https://esbuild.github.io/plugins/#on-load)
|
|
121
|
+
* @description
|
|
122
|
+
* Why use this method?
|
|
123
|
+
* By default, dumi can only support the parsing of js/ts related code blocks,
|
|
124
|
+
* but many front-end frameworks have custom extensions,
|
|
125
|
+
* so this method is provided to facilitate developers to convert codes.
|
|
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
|
+
* register a new tech stack
|
|
140
|
+
*/
|
|
141
|
+
registerTechStack: (fn: () => IDumiTechStack) => void;
|
|
142
|
+
/**
|
|
143
|
+
* modify original theme data
|
|
144
|
+
*/
|
|
145
|
+
modifyTheme: IModify<IThemeLoadResult, null>;
|
|
146
|
+
/**
|
|
147
|
+
* add content tab
|
|
148
|
+
*/
|
|
149
|
+
addContentTab: (fn: () => IContentTab) => void;
|
|
150
|
+
/**
|
|
151
|
+
* modify assets metadata
|
|
152
|
+
*/
|
|
153
|
+
modifyAssetsMetadata: IModify<AssetsPackage, null>;
|
|
154
|
+
/**
|
|
155
|
+
* get assets metadata
|
|
156
|
+
*/
|
|
157
|
+
getAssetsMetadata?: () => Promise<AssetsPackage>;
|
|
158
|
+
};
|
|
159
|
+
export {};
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import type { Range, RangeOptions } from '@umijs/utils/compiled/semver';
|
|
3
|
+
import Cache from 'file-system-cache';
|
|
4
|
+
import type { RunLoaderOption as InternalRunLoaderOption, RunLoaderResult } from '../compiled/loader-runner';
|
|
5
|
+
export type * from '../compiled/loader-runner';
|
|
6
|
+
export { getContext } from '../compiled/loader-runner';
|
|
7
|
+
/**
|
|
8
|
+
* get route path from file-system path
|
|
9
|
+
*/
|
|
10
|
+
export declare function getFileIdFromFsPath(fsPath: string): string;
|
|
11
|
+
/**
|
|
12
|
+
* get range lines of markdown file
|
|
13
|
+
*/
|
|
14
|
+
export declare const getFileRangeLines: (content: string, range: string) => string;
|
|
15
|
+
/**
|
|
16
|
+
* get file content by regular expression
|
|
17
|
+
* @param content source file content
|
|
18
|
+
* @param regexp regular expression string
|
|
19
|
+
* @param filePath source file path
|
|
20
|
+
*/
|
|
21
|
+
export declare const getFileContentByRegExp: (content: string, regexp: string, filePath: string) => string;
|
|
22
|
+
/**
|
|
23
|
+
* parse frontmatter from code string,
|
|
24
|
+
* also supports html/xml comments
|
|
25
|
+
*/
|
|
26
|
+
export declare function parseCodeFrontmatter(raw: string): {
|
|
27
|
+
code: string;
|
|
28
|
+
frontmatter: Record<string, any> | null;
|
|
29
|
+
};
|
|
30
|
+
declare const caches: Record<string, ReturnType<typeof Cache>>;
|
|
31
|
+
export declare function _setFSCacheDir(dir: string): void;
|
|
32
|
+
export declare function getCache(ns: string): (typeof caches)['0'];
|
|
33
|
+
/**
|
|
34
|
+
* try to get father config
|
|
35
|
+
*/
|
|
36
|
+
export declare function tryFatherBuildConfigs(cwd: string): Promise<any[]>;
|
|
37
|
+
/**
|
|
38
|
+
* get root dir for monorepo project
|
|
39
|
+
*/
|
|
40
|
+
export declare function getProjectRoot(cwd: string): string;
|
|
41
|
+
/**
|
|
42
|
+
*
|
|
43
|
+
* transform component into webpack chunkName
|
|
44
|
+
* @export
|
|
45
|
+
* @param {string} component component path
|
|
46
|
+
* @param {string} [cwdPath] current root path
|
|
47
|
+
* @return {*} {string}
|
|
48
|
+
*/
|
|
49
|
+
export declare function componentToChunkName(component: string, cwdPath?: string): string;
|
|
50
|
+
export declare function generateMetaChunkName(path: string, cwd: string, locales?: string[]): string;
|
|
51
|
+
/**
|
|
52
|
+
* generate hash for string
|
|
53
|
+
*/
|
|
54
|
+
export declare function getContentHash(content: string, length?: number): string;
|
|
55
|
+
export type RunLoaderOption = Partial<InternalRunLoaderOption>;
|
|
56
|
+
export declare function runLoaders(options: RunLoaderOption): Promise<RunLoaderResult>;
|
|
57
|
+
export declare function runLoaders(options: RunLoaderOption, callback: undefined): Promise<RunLoaderResult>;
|
|
58
|
+
export declare function runLoaders(options: RunLoaderOption, callback: (err: NodeJS.ErrnoException | null, result: RunLoaderResult) => any): void;
|
|
59
|
+
/**
|
|
60
|
+
* check if version is in range
|
|
61
|
+
*/
|
|
62
|
+
export declare function isVersionInRange(version: string, range: string | Range, options?: RangeOptions): boolean;
|
|
63
|
+
/**
|
|
64
|
+
* normalize module specifier for generated import/export statements
|
|
65
|
+
* keep package/bare specifiers unchanged and normalize path separators
|
|
66
|
+
*/
|
|
67
|
+
export declare function toImportSpecifier(source: string): string;
|
package/dumi-types.d.ts
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
OnLoadArgs,
|
|
3
|
+
OnLoadResult,
|
|
4
|
+
} from '@umijs/bundler-utils/compiled/esbuild';
|
|
5
|
+
import type { IModify } from '@umijs/core';
|
|
6
|
+
import type { AssetsPackage, ExampleBlockAsset } from 'dumi-assets-types';
|
|
7
|
+
import type { Element } from 'hast';
|
|
8
|
+
import type { IApi as IUmiApi, defineConfig as defineUmiConfig } from 'umi';
|
|
9
|
+
import type { IDumiDemoProps, ILocalesConfig, IThemeConfig } from './theme-api';
|
|
10
|
+
|
|
11
|
+
type Subset<K> = {
|
|
12
|
+
[attr in keyof K]?: K[attr] extends Array<any>
|
|
13
|
+
? K[attr]
|
|
14
|
+
: K[attr] extends (...args: any[]) => any | undefined
|
|
15
|
+
? K[attr]
|
|
16
|
+
: K[attr] extends object
|
|
17
|
+
? Subset<K[attr]>
|
|
18
|
+
: K[attr] extends object | null
|
|
19
|
+
? Subset<K[attr]> | null
|
|
20
|
+
: K[attr] extends object | null | undefined
|
|
21
|
+
? Subset<K[attr]> | null | undefined
|
|
22
|
+
: K[attr];
|
|
23
|
+
};
|
|
24
|
+
type NoStringIndex<T> = {
|
|
25
|
+
[K in keyof T as string extends K ? never : K]: T[K];
|
|
26
|
+
};
|
|
27
|
+
type IUmiConfig = Omit<
|
|
28
|
+
NoStringIndex<Parameters<typeof defineUmiConfig>[0]>,
|
|
29
|
+
'resolve' | 'extraRemarkPlugins' | 'extraRehypePlugins' | 'themeConfig'
|
|
30
|
+
>;
|
|
31
|
+
type UnifiedPluginConfig =
|
|
32
|
+
| string
|
|
33
|
+
| ((...args: any[]) => any)
|
|
34
|
+
| [string | ((...args: any[]) => any), object];
|
|
35
|
+
|
|
36
|
+
export interface IDumiExtendsConfig {
|
|
37
|
+
resolve: {
|
|
38
|
+
docDirs: (string | { type?: string; dir: string })[];
|
|
39
|
+
atomDirs: { type: string; subType?: string; dir: string }[];
|
|
40
|
+
codeBlockMode: 'active' | 'passive';
|
|
41
|
+
entryFile?: string;
|
|
42
|
+
forceKebabCaseRouting: boolean;
|
|
43
|
+
};
|
|
44
|
+
locales: ILocalesConfig;
|
|
45
|
+
themeConfig: IThemeConfig;
|
|
46
|
+
autoAlias?: boolean;
|
|
47
|
+
extraRemarkPlugins?: UnifiedPluginConfig[];
|
|
48
|
+
extraRehypePlugins?: UnifiedPluginConfig[];
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export type IDumiConfig = Omit<IUmiConfig, 'locales'> & IDumiExtendsConfig;
|
|
52
|
+
export type IDumiUserConfig = Subset<Omit<IDumiConfig, 'locales'>> & {
|
|
53
|
+
locales?:
|
|
54
|
+
| Exclude<IDumiConfig['locales'][0], { base: string }>[]
|
|
55
|
+
| Omit<Exclude<IDumiConfig['locales'][0], { suffix: string }>, 'base'>[];
|
|
56
|
+
[key: string]: any;
|
|
57
|
+
};
|
|
58
|
+
export interface IDumiTechStackOnBlockLoadResult {
|
|
59
|
+
content: string;
|
|
60
|
+
type: Required<OnLoadResult>['loader'];
|
|
61
|
+
}
|
|
62
|
+
export type IDumiTechStackOnBlockLoadArgs = OnLoadArgs & {
|
|
63
|
+
entryPointCode: string;
|
|
64
|
+
filename: string;
|
|
65
|
+
};
|
|
66
|
+
export interface IDumiTechStackRuntimeOpts {
|
|
67
|
+
preflightPath?: string;
|
|
68
|
+
rendererPath?: string;
|
|
69
|
+
compilePath?: string;
|
|
70
|
+
pluginPath?: string;
|
|
71
|
+
}
|
|
72
|
+
export abstract class IDumiTechStack {
|
|
73
|
+
abstract name: string;
|
|
74
|
+
abstract runtimeOpts?: IDumiTechStackRuntimeOpts;
|
|
75
|
+
abstract isSupported(node: Element, lang: string): boolean;
|
|
76
|
+
abstract transformCode(
|
|
77
|
+
raw: string,
|
|
78
|
+
opts: { type: 'external' | 'code-block'; fileAbsPath: string },
|
|
79
|
+
): string;
|
|
80
|
+
abstract generateMetadata?(
|
|
81
|
+
asset: ExampleBlockAsset,
|
|
82
|
+
opts: {
|
|
83
|
+
type: Parameters<IDumiTechStack['transformCode']>[1]['type'];
|
|
84
|
+
mdAbsPath: string;
|
|
85
|
+
fileAbsPath?: string;
|
|
86
|
+
entryPointCode?: string;
|
|
87
|
+
},
|
|
88
|
+
): Promise<ExampleBlockAsset> | ExampleBlockAsset;
|
|
89
|
+
abstract generatePreviewerProps?(
|
|
90
|
+
props: IDumiDemoProps['previewerProps'],
|
|
91
|
+
opts: Parameters<NonNullable<IDumiTechStack['generateMetadata']>>[1],
|
|
92
|
+
):
|
|
93
|
+
| Promise<IDumiDemoProps['previewerProps']>
|
|
94
|
+
| IDumiDemoProps['previewerProps'];
|
|
95
|
+
abstract generateSources?(
|
|
96
|
+
source: Record<string, string>,
|
|
97
|
+
opts: Parameters<NonNullable<IDumiTechStack['generateMetadata']>>[1],
|
|
98
|
+
): Promise<Record<string, string>> | Record<string, string>;
|
|
99
|
+
abstract onBlockLoad?(
|
|
100
|
+
args: IDumiTechStackOnBlockLoadArgs,
|
|
101
|
+
): IDumiTechStackOnBlockLoadResult | null;
|
|
102
|
+
}
|
|
103
|
+
export type IApi = IUmiApi & {
|
|
104
|
+
config: IDumiConfig & { [key: string]: any };
|
|
105
|
+
userConfig: IDumiUserConfig;
|
|
106
|
+
service: IUmiApi['service'] & {
|
|
107
|
+
themeData: any;
|
|
108
|
+
atomParser: any;
|
|
109
|
+
};
|
|
110
|
+
registerTechStack: (fn: () => IDumiTechStack) => void;
|
|
111
|
+
modifyTheme: IModify<any, null>;
|
|
112
|
+
addContentTab: (fn: () => any) => void;
|
|
113
|
+
modifyAssetsMetadata: IModify<AssetsPackage, null>;
|
|
114
|
+
getAssetsMetadata?: () => Promise<AssetsPackage>;
|
|
115
|
+
};
|
package/index.d.ts
CHANGED
|
@@ -1,11 +1,70 @@
|
|
|
1
|
-
|
|
1
|
+
import type { IRouteMeta, IRoutesById } from './theme-api';
|
|
2
|
+
|
|
2
3
|
export { Root as HastRoot } from 'hast';
|
|
3
4
|
export * from 'umi';
|
|
4
5
|
export {
|
|
5
6
|
Plugin as UnifiedPlugin,
|
|
6
7
|
Transformer as UnifiedTransformer,
|
|
7
8
|
} from 'unified';
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
export type {
|
|
10
|
+
IApi,
|
|
11
|
+
IDumiConfig,
|
|
12
|
+
IDumiTechStack,
|
|
13
|
+
IDumiTechStackOnBlockLoadArgs,
|
|
14
|
+
IDumiTechStackOnBlockLoadResult,
|
|
15
|
+
IDumiTechStackRuntimeOpts,
|
|
16
|
+
IDumiUserConfig,
|
|
17
|
+
} from './dumi-types';
|
|
18
|
+
export * from './theme-api';
|
|
19
|
+
|
|
20
|
+
export declare enum ApplyPluginsType {
|
|
21
|
+
add = 'add',
|
|
22
|
+
modify = 'modify',
|
|
23
|
+
event = 'event',
|
|
24
|
+
compose = 'compose',
|
|
25
|
+
}
|
|
26
|
+
export declare class PluginManager {
|
|
27
|
+
static create(opts: Record<string, any>): PluginManager;
|
|
28
|
+
applyPlugins(opts: Record<string, any>): any;
|
|
29
|
+
[key: string]: any;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export declare const getSketchJSON: (
|
|
33
|
+
element: Element,
|
|
34
|
+
opts: Record<string, any>,
|
|
35
|
+
) => Promise<Record<string, any>>;
|
|
36
|
+
export declare const history: {
|
|
37
|
+
location: Location;
|
|
38
|
+
push(to: string | Record<string, any>): void;
|
|
39
|
+
replace(to: string | Record<string, any>): void;
|
|
40
|
+
listen(listener: (...args: any[]) => void): () => void;
|
|
41
|
+
[key: string]: any;
|
|
42
|
+
};
|
|
43
|
+
export declare const Helmet: any;
|
|
44
|
+
export declare const Link: any;
|
|
45
|
+
export declare const NavLink: any;
|
|
46
|
+
export declare const matchRoutes: (...args: any[]) => any;
|
|
47
|
+
export declare const useAppData: () => {
|
|
48
|
+
clientRoutes: any[];
|
|
49
|
+
routes: IRoutesById;
|
|
50
|
+
[key: string]: any;
|
|
51
|
+
};
|
|
52
|
+
export declare const useLocation: () => Location & Record<string, any>;
|
|
53
|
+
export declare const useOutlet: () => any;
|
|
54
|
+
export declare const useParams: () => Record<string, string | undefined>;
|
|
55
|
+
export declare const useRouteData: () => {
|
|
56
|
+
route: { path?: string; meta?: IRouteMeta; [key: string]: any };
|
|
57
|
+
[key: string]: any;
|
|
58
|
+
};
|
|
59
|
+
export declare const useSearchParams: () => [
|
|
60
|
+
URLSearchParams,
|
|
61
|
+
(...args: any[]) => void,
|
|
62
|
+
];
|
|
63
|
+
|
|
64
|
+
export declare let unistUtilVisit: typeof import('unist-util-visit');
|
|
65
|
+
export declare const getProjectRoot: (cwd: string) => string;
|
|
66
|
+
export declare const defineConfig: <
|
|
67
|
+
T extends import('./dumi-types').IDumiUserConfig,
|
|
68
|
+
>(
|
|
69
|
+
config: T,
|
|
70
|
+
) => T;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dumi",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.30",
|
|
4
4
|
"description": "📖 Documentation Generator of React Component",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"generator",
|
|
@@ -30,7 +30,10 @@
|
|
|
30
30
|
"dist",
|
|
31
31
|
"compiled",
|
|
32
32
|
"theme-default",
|
|
33
|
+
"dumi-types.d.ts",
|
|
33
34
|
"index.d.ts",
|
|
35
|
+
"theme-api.d.ts",
|
|
36
|
+
"theme-modules.d.ts",
|
|
34
37
|
"plugin-utils.js",
|
|
35
38
|
"plugin-utils.d.ts",
|
|
36
39
|
"tech-stack-utils.js",
|