dumi 2.4.29 → 2.4.31

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.
Files changed (140) hide show
  1. package/compiled/crates/swc_plugin_react_demo.wasm +0 -0
  2. package/dist/assetParsers/BaseParser.d.ts +55 -0
  3. package/dist/assetParsers/atom.d.ts +21 -0
  4. package/dist/assetParsers/block.d.ts +25 -0
  5. package/dist/assetParsers/utils.d.ts +79 -0
  6. package/dist/cli.d.ts +1 -0
  7. package/dist/client/misc/reactDemoCompiler.d.ts +3 -0
  8. package/dist/client/pages/404.d.ts +1 -0
  9. package/dist/client/pages/Demo/index.d.ts +4 -0
  10. package/dist/client/pages/Loading.d.ts +1 -0
  11. package/dist/client/theme-api/AtomRenderer.d.ts +13 -0
  12. package/dist/client/theme-api/DumiDemo/DemoErrorBoundary.d.ts +5 -0
  13. package/dist/client/theme-api/DumiDemo/index.d.ts +10 -0
  14. package/dist/client/theme-api/DumiDemoGrid.d.ts +7 -0
  15. package/dist/client/theme-api/DumiPage.d.ts +4 -0
  16. package/dist/client/theme-api/context.d.ts +21 -0
  17. package/dist/client/theme-api/index.d.ts +18 -0
  18. package/dist/client/theme-api/openCodeSandbox.d.ts +10 -0
  19. package/dist/client/theme-api/openStackBlitz.d.ts +2 -0
  20. package/dist/client/theme-api/types.d.ts +258 -0
  21. package/dist/client/theme-api/useAtomAssets.d.ts +4 -0
  22. package/dist/client/theme-api/useLiveDemo.d.ts +10 -0
  23. package/dist/client/theme-api/useLocale.d.ts +2 -0
  24. package/dist/client/theme-api/useNavData.d.ts +5 -0
  25. package/dist/client/theme-api/usePrefersColor.d.ts +7 -0
  26. package/dist/client/theme-api/useRenderer.d.ts +11 -0
  27. package/dist/client/theme-api/useRouteMeta.d.ts +17 -0
  28. package/dist/client/theme-api/useSidebarData.d.ts +29 -0
  29. package/dist/client/theme-api/useSiteSearch/index.d.ts +24 -0
  30. package/dist/client/theme-api/useSiteSearch/useSearchData.d.ts +12 -0
  31. package/dist/client/theme-api/useTabMeta.d.ts +4 -0
  32. package/dist/client/theme-api/utils.d.ts +31 -0
  33. package/dist/constants.d.ts +23 -0
  34. package/dist/features/assets.d.ts +20 -0
  35. package/dist/features/assets.js +2 -1
  36. package/dist/features/autoAlias.d.ts +3 -0
  37. package/dist/features/compile/babelLoaderCustomize.d.ts +4 -0
  38. package/dist/features/compile/index.d.ts +4 -0
  39. package/dist/features/compile/makoHooks.d.ts +8 -0
  40. package/dist/features/compile/utils.d.ts +2 -0
  41. package/dist/features/compile/utoopackLoaders.d.ts +8 -0
  42. package/dist/features/configPlugins/index.d.ts +3 -0
  43. package/dist/features/configPlugins/schema.d.ts +4 -0
  44. package/dist/features/derivative.d.ts +11 -0
  45. package/dist/features/exportStatic.d.ts +3 -0
  46. package/dist/features/exports.d.ts +3 -0
  47. package/dist/features/html2sketch.d.ts +3 -0
  48. package/dist/features/locales.d.ts +3 -0
  49. package/dist/features/meta.d.ts +5 -0
  50. package/dist/features/parser.d.ts +3 -0
  51. package/dist/features/routes.d.ts +3 -0
  52. package/dist/features/sideEffects/docSideEffectsWebpackPlugin.d.ts +14 -0
  53. package/dist/features/sideEffects/index.d.ts +7 -0
  54. package/dist/features/sitemap.d.ts +3 -0
  55. package/dist/features/sitemap.js +5 -2
  56. package/dist/features/tabs.d.ts +17 -0
  57. package/dist/features/tabs.js +7 -4
  58. package/dist/features/theme/index.d.ts +3 -0
  59. package/dist/features/theme/index.js +6 -4
  60. package/dist/features/theme/loader.d.ts +55 -0
  61. package/dist/index.d.ts +6 -0
  62. package/dist/loaders/demo/index.d.ts +6 -0
  63. package/dist/loaders/markdown/index.d.ts +27 -0
  64. package/dist/loaders/markdown/transformer/index.d.ts +69 -0
  65. package/dist/loaders/markdown/transformer/rehypeDemo.d.ts +15 -0
  66. package/dist/loaders/markdown/transformer/rehypeDesc.d.ts +6 -0
  67. package/dist/loaders/markdown/transformer/rehypeEnhancedTag.d.ts +3 -0
  68. package/dist/loaders/markdown/transformer/rehypeHighlightLine.d.ts +4 -0
  69. package/dist/loaders/markdown/transformer/rehypeImg.d.ts +6 -0
  70. package/dist/loaders/markdown/transformer/rehypeIsolation.d.ts +7 -0
  71. package/dist/loaders/markdown/transformer/rehypeJsxify.d.ts +2 -0
  72. package/dist/loaders/markdown/transformer/rehypeLink.d.ts +6 -0
  73. package/dist/loaders/markdown/transformer/rehypeRaw.d.ts +6 -0
  74. package/dist/loaders/markdown/transformer/rehypeSlug.d.ts +4 -0
  75. package/dist/loaders/markdown/transformer/rehypeStrip.d.ts +3 -0
  76. package/dist/loaders/markdown/transformer/rehypeText.d.ts +4 -0
  77. package/dist/loaders/markdown/transformer/remarkBreaks.d.ts +3 -0
  78. package/dist/loaders/markdown/transformer/remarkContainer.d.ts +3 -0
  79. package/dist/loaders/markdown/transformer/remarkEmbed.d.ts +4 -0
  80. package/dist/loaders/markdown/transformer/remarkMeta.d.ts +8 -0
  81. package/dist/loaders/null/index.d.ts +2 -0
  82. package/dist/loaders/page/index.d.ts +1 -0
  83. package/dist/loaders/post-raw/index.d.ts +4 -0
  84. package/dist/loaders/pre-raw/index.d.ts +4 -0
  85. package/dist/preset.d.ts +5 -0
  86. package/dist/registerMethods.d.ts +3 -0
  87. package/dist/service/cli.d.ts +5 -0
  88. package/dist/service/constants.d.ts +4 -0
  89. package/dist/service/dev.d.ts +1 -0
  90. package/dist/service/forkedDev.d.ts +1 -0
  91. package/dist/service/printHelp.d.ts +1 -0
  92. package/dist/service/service.d.ts +13 -0
  93. package/dist/techStacks/react.d.ts +7 -0
  94. package/dist/techStacks/utils.d.ts +40 -0
  95. package/dist/types.d.ts +159 -0
  96. package/dist/utils.d.ts +66 -0
  97. package/dumi-types.d.ts +115 -0
  98. package/index.d.ts +64 -5
  99. package/package.json +12 -8
  100. package/theme-api.d.ts +319 -0
  101. package/theme-default/builtins/API/index.d.ts +7 -0
  102. package/theme-default/builtins/Badge/index.d.ts +7 -0
  103. package/theme-default/builtins/CodeGroup/index.d.ts +3 -0
  104. package/theme-default/builtins/Container/index.d.ts +8 -0
  105. package/theme-default/builtins/Previewer/index.d.ts +5 -0
  106. package/theme-default/builtins/SourceCode/index.d.ts +14 -0
  107. package/theme-default/builtins/Table/index.d.ts +6 -0
  108. package/theme-default/builtins/Tree/index.d.ts +5 -0
  109. package/theme-default/builtins/Tree/index.js +11 -11
  110. package/theme-default/layouts/DocLayout/index.d.ts +4 -0
  111. package/theme-default/slots/ColorSwitch/index.d.ts +4 -0
  112. package/theme-default/slots/Content/index.d.ts +7 -0
  113. package/theme-default/slots/ContentFooter/index.d.ts +4 -0
  114. package/theme-default/slots/ContentTabs/index.d.ts +11 -0
  115. package/theme-default/slots/Features/index.d.ts +4 -0
  116. package/theme-default/slots/Footer/index.d.ts +4 -0
  117. package/theme-default/slots/Header/index.d.ts +4 -0
  118. package/theme-default/slots/Header/index.js +5 -2
  119. package/theme-default/slots/HeaderExtra/index.d.ts +3 -0
  120. package/theme-default/slots/Hero/index.d.ts +4 -0
  121. package/theme-default/slots/HeroTitle/index.d.ts +6 -0
  122. package/theme-default/slots/LangSwitch/index.d.ts +4 -0
  123. package/theme-default/slots/Loading/index.d.ts +5 -0
  124. package/theme-default/slots/Logo/index.d.ts +4 -0
  125. package/theme-default/slots/Navbar/index.d.ts +4 -0
  126. package/theme-default/slots/NavbarExtra/index.d.ts +3 -0
  127. package/theme-default/slots/NotFound/index.d.ts +4 -0
  128. package/theme-default/slots/PreviewerActions/index.d.ts +27 -0
  129. package/theme-default/slots/PreviewerActionsExtra/index.d.ts +4 -0
  130. package/theme-default/slots/RtlSwitch/index.d.ts +4 -0
  131. package/theme-default/slots/SearchBar/Input.d.ts +6 -0
  132. package/theme-default/slots/SearchBar/Mask.d.ts +9 -0
  133. package/theme-default/slots/SearchBar/index.d.ts +6 -0
  134. package/theme-default/slots/SearchResult/index.d.ts +10 -0
  135. package/theme-default/slots/Sidebar/index.d.ts +4 -0
  136. package/theme-default/slots/SocialIcon/index.d.ts +15 -0
  137. package/theme-default/slots/SourceCodeEditor/index.d.ts +19 -0
  138. package/theme-default/slots/Tabs/index.d.ts +6 -0
  139. package/theme-default/slots/Toc/index.d.ts +4 -0
  140. package/theme-modules.d.ts +62 -0
@@ -0,0 +1,4 @@
1
+ import type { Root } from 'mdast';
2
+ import type { Transformer } from 'unified';
3
+ import type { IMdTransformerOptions } from '.';
4
+ export default function remarkEmbed(opts: Pick<IMdTransformerOptions, 'fileAbsPath' | 'alias'>): Transformer<Root>;
@@ -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,2 @@
1
+ export default function loader(): string;
2
+ export declare function pitch(): string;
@@ -0,0 +1 @@
1
+ export default function pageMetaLoader(this: any, raw: string): string;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * loader for mako dumi-raw watch-parent
3
+ */
4
+ export default function postRawLoader(this: any, raw: string): string;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * loader for discard frontmatter from code file content
3
+ */
4
+ export default function preRawLoader(this: any, raw: string): string;
@@ -0,0 +1,5 @@
1
+ import type { IApi } from './types';
2
+ declare const _default: (api: IApi) => {
3
+ plugins: string[];
4
+ };
5
+ export default _default;
@@ -0,0 +1,3 @@
1
+ import type { IApi } from './types';
2
+ declare const _default: (api: IApi) => void;
3
+ export default _default;
@@ -0,0 +1,5 @@
1
+ interface IOpts {
2
+ presets?: string[];
3
+ }
4
+ export declare function run(opts?: IOpts): Promise<void>;
5
+ export {};
@@ -0,0 +1,4 @@
1
+ export declare const MIN_NODE_VERSION = 14;
2
+ export declare const DEV_COMMAND = "dev";
3
+ export declare const DEFAULT_CONFIG_FILES: string[];
4
+ export declare const FRAMEWORK_NAME = "dumi";
@@ -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;
@@ -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 {};
@@ -0,0 +1,66 @@
1
+ import type { Range, RangeOptions } from '@umijs/utils/compiled/semver';
2
+ import Cache from 'file-system-cache';
3
+ import type { RunLoaderOption as InternalRunLoaderOption, RunLoaderResult } from '../compiled/loader-runner';
4
+ export type * from '../compiled/loader-runner';
5
+ export { getContext } from '../compiled/loader-runner';
6
+ /**
7
+ * get route path from file-system path
8
+ */
9
+ export declare function getFileIdFromFsPath(fsPath: string): string;
10
+ /**
11
+ * get range lines of markdown file
12
+ */
13
+ export declare const getFileRangeLines: (content: string, range: string) => string;
14
+ /**
15
+ * get file content by regular expression
16
+ * @param content source file content
17
+ * @param regexp regular expression string
18
+ * @param filePath source file path
19
+ */
20
+ export declare const getFileContentByRegExp: (content: string, regexp: string, filePath: string) => string;
21
+ /**
22
+ * parse frontmatter from code string,
23
+ * also supports html/xml comments
24
+ */
25
+ export declare function parseCodeFrontmatter(raw: string): {
26
+ code: string;
27
+ frontmatter: Record<string, any> | null;
28
+ };
29
+ declare const caches: Record<string, ReturnType<typeof Cache>>;
30
+ export declare function _setFSCacheDir(dir: string): void;
31
+ export declare function getCache(ns: string): (typeof caches)['0'];
32
+ /**
33
+ * try to get father config
34
+ */
35
+ export declare function tryFatherBuildConfigs(cwd: string): Promise<any[]>;
36
+ /**
37
+ * get root dir for monorepo project
38
+ */
39
+ export declare function getProjectRoot(cwd: string): string;
40
+ /**
41
+ *
42
+ * transform component into webpack chunkName
43
+ * @export
44
+ * @param {string} component component path
45
+ * @param {string} [cwdPath] current root path
46
+ * @return {*} {string}
47
+ */
48
+ export declare function componentToChunkName(component: string, cwdPath?: string): string;
49
+ export declare function generateMetaChunkName(path: string, cwd: string, locales?: string[]): string;
50
+ /**
51
+ * generate hash for string
52
+ */
53
+ export declare function getContentHash(content: string, length?: number): string;
54
+ export type RunLoaderOption = Partial<InternalRunLoaderOption>;
55
+ export declare function runLoaders(options: RunLoaderOption): Promise<RunLoaderResult>;
56
+ export declare function runLoaders(options: RunLoaderOption, callback: undefined): Promise<RunLoaderResult>;
57
+ export declare function runLoaders(options: RunLoaderOption, callback: (err: NodeJS.ErrnoException | null, result: RunLoaderResult) => any): void;
58
+ /**
59
+ * check if version is in range
60
+ */
61
+ export declare function isVersionInRange(version: string, range: string | Range, options?: RangeOptions): boolean;
62
+ /**
63
+ * normalize module specifier for generated import/export statements
64
+ * keep package/bare specifiers unchanged and normalize path separators
65
+ */
66
+ export declare function toImportSpecifier(source: string): string;
@@ -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
- export * from '@@/dumi/exports';
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 * from './dist';
9
- // override umi exported defineConfig
10
- export { defineConfig } from './dist';
11
- export { IApi } from './dist/types';
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.29",
3
+ "version": "2.4.31",
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",
@@ -65,9 +68,9 @@
65
68
  "@swc/core": "1.9.2",
66
69
  "@types/hast": "^2.3.5",
67
70
  "@types/mdast": "^3.0.12",
68
- "@umijs/bundler-utils": "^4.6.61",
69
- "@umijs/core": "^4.6.61",
70
- "@umijs/utils": "^4.6.61",
71
+ "@umijs/bundler-utils": "^4.6.65",
72
+ "@umijs/core": "^4.6.65",
73
+ "@umijs/utils": "^4.6.65",
71
74
  "animated-scroll-to": "^2.3.0",
72
75
  "classnames": "2.3.2",
73
76
  "codesandbox-import-utils": "^2.2.3",
@@ -119,7 +122,7 @@
119
122
  "sass": "^1.64.1",
120
123
  "sitemap": "^7.1.1",
121
124
  "sucrase": "^3.34.0",
122
- "umi": "^4.6.61",
125
+ "umi": "^4.6.65",
123
126
  "unified": "^10.1.2",
124
127
  "unist-util-visit": "^4.1.2",
125
128
  "unist-util-visit-parents": "^5.1.3",
@@ -142,12 +145,13 @@
142
145
  "@types/react": "^18.2.17",
143
146
  "@types/react-copy-to-clipboard": "^5.0.4",
144
147
  "@types/react-dom": "^18.2.7",
145
- "@umijs/lint": "^4.6.61",
146
- "@umijs/plugins": "4.6.61",
148
+ "@typescript/native-preview": "7.0.0-dev.20260609.1",
149
+ "@umijs/lint": "^4.6.65",
150
+ "@umijs/plugins": "4.6.65",
147
151
  "eslint": "^8.46.0",
148
152
  "esno": "^4.7.0",
149
153
  "fast-glob": "^3.3.1",
150
- "father": "^4.6.21",
154
+ "father": "^4.6.23",
151
155
  "git-repo-info": "^2.1.1",
152
156
  "highlight-words-core": "^1.2.2",
153
157
  "husky": "^8.0.3",