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.
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 +22 -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 +12 -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 +9 -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 +67 -0
  97. package/dumi-types.d.ts +115 -0
  98. package/index.d.ts +64 -5
  99. package/package.json +4 -1
  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 +20 -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,55 @@
1
+ import type { AtomComponentAsset, AtomFunctionAsset } from 'dumi-assets-types';
2
+ import { chokidar } from 'umi/plugin-utils';
3
+ export interface IPatchFile {
4
+ event: 'add' | 'addDir' | 'change' | 'unlink' | 'unlinkDir';
5
+ fileName: string;
6
+ }
7
+ export interface IAtomAssetsParserResult {
8
+ components: Record<string, AtomComponentAsset>;
9
+ functions: Record<string, AtomFunctionAsset>;
10
+ }
11
+ /**
12
+ * The parsing and extraction of language metadata should be implemented separately
13
+ */
14
+ export interface ILanguageMetaParser {
15
+ patch(file: IPatchFile): void;
16
+ parse(): Promise<IAtomAssetsParserResult>;
17
+ destroy(): Promise<void>;
18
+ }
19
+ export interface IHandleWatcherArgs {
20
+ patch: ILanguageMetaParser['patch'];
21
+ parse: () => void;
22
+ watchArgs: {
23
+ paths: string | string[];
24
+ options: chokidar.WatchOptions;
25
+ };
26
+ }
27
+ export interface IBaseAtomAssetsParserParams<T> {
28
+ entryFile: string;
29
+ resolveDir: string;
30
+ parser: T;
31
+ handleWatcher?: (watcher: chokidar.FSWatcher, params: IHandleWatcherArgs) => chokidar.FSWatcher;
32
+ watchOptions?: chokidar.WatchOptions;
33
+ }
34
+ export declare class BaseAtomAssetsParser<T extends ILanguageMetaParser = ILanguageMetaParser> {
35
+ private watchArgs;
36
+ private watcher;
37
+ private handleWatcher?;
38
+ private entryDir;
39
+ private resolveDir;
40
+ private readonly parser;
41
+ private isParsing;
42
+ private parseDeferrer;
43
+ private cbs;
44
+ constructor(opts: IBaseAtomAssetsParserParams<T>);
45
+ parse(): Promise<IAtomAssetsParserResult>;
46
+ watch(cb: (data: IAtomAssetsParserResult) => void): void;
47
+ unwatch(cb: (data: IAtomAssetsParserResult) => void): void;
48
+ patchWatchArgs(handler: (args: BaseAtomAssetsParser<T>['watchArgs']) => BaseAtomAssetsParser<T>['watchArgs']): void;
49
+ getWatchArgs(): {
50
+ paths: string | string[];
51
+ options: chokidar.WatchOptions;
52
+ };
53
+ destroyWorker(): Promise<void>;
54
+ }
55
+ export type IAtomAssetsParser = InstanceType<typeof BaseAtomAssetsParser>;
@@ -0,0 +1,21 @@
1
+ import { BaseAtomAssetsParser, IAtomAssetsParserResult, ILanguageMetaParser, IPatchFile } from './BaseParser';
2
+ interface ParserParams {
3
+ entryFile: string;
4
+ resolveDir: string;
5
+ resolveFilter?: ReactMetaParser['resolveFilter'];
6
+ unpkgHost?: string;
7
+ parseOptions?: object;
8
+ }
9
+ declare class ReactMetaParser implements ILanguageMetaParser {
10
+ private parser;
11
+ private resolveFilter;
12
+ private unresolvedFiles;
13
+ constructor(opts: ParserParams);
14
+ parse(): Promise<IAtomAssetsParserResult>;
15
+ destroy(): Promise<void>;
16
+ patch(file: IPatchFile): void;
17
+ }
18
+ declare class ReactAtomAssetsParser extends BaseAtomAssetsParser<ReactMetaParser> {
19
+ constructor(opts: ParserParams);
20
+ }
21
+ export default ReactAtomAssetsParser;
@@ -0,0 +1,25 @@
1
+ import { parseCodeFrontmatter } from "../utils";
2
+ import type { ExampleBlockAsset } from 'dumi-assets-types';
3
+ import type { sync } from 'enhanced-resolve';
4
+ import { IDumiTechStack } from '../types';
5
+ export interface IParsedBlockAsset {
6
+ asset: ExampleBlockAsset;
7
+ /**
8
+ * resolveMap: {
9
+ * '@/constants': '/path/to/constants.ts',
10
+ * 'antd/es/button': '/path/to/antd/es/button/index.jsx',
11
+ * }
12
+ */
13
+ resolveMap: Record<string, string>;
14
+ frontmatter: ReturnType<typeof parseCodeFrontmatter>['frontmatter'];
15
+ }
16
+ declare function parseBlockAsset(opts: {
17
+ fileAbsPath: string;
18
+ fileLocale?: string;
19
+ id: string;
20
+ refAtomIds: string[];
21
+ entryPointCode?: string;
22
+ resolver: typeof sync;
23
+ techStack: IDumiTechStack;
24
+ }): Promise<IParsedBlockAsset>;
25
+ export default parseBlockAsset;
@@ -0,0 +1,79 @@
1
+ import { BaseAtomAssetsParser, IBaseAtomAssetsParserParams, ILanguageMetaParser } from './BaseParser';
2
+ /**
3
+ * Only expose these methods to avoid all properties being proxied
4
+ * @param ClassConstructor The Class to be processed
5
+ * @param publicMethods accessible Class methods
6
+ * @returns processed Class
7
+ */
8
+ export declare function createExposedClass<T extends {
9
+ new (...args: ConstructorParameters<T>): InstanceType<T>;
10
+ }>(ClassConstructor: T, publicMethods?: string[]): {
11
+ new (...params: ConstructorParameters<T>): {};
12
+ };
13
+ /**
14
+ * Create Class that can execute across threads
15
+ * @param filename Child thread running script path
16
+ * @param ClassConstructor Class that require remote execution
17
+ * @param opts
18
+ * @returns Remote Class, all its methods are asynchronous
19
+ */
20
+ export declare function createRemoteClass<T extends {
21
+ new (...args: ConstructorParameters<T>): InstanceType<T>;
22
+ }>(filename: string, ClassConstructor: T, opts?: {
23
+ destroyMethod: string;
24
+ publicMethods?: string[];
25
+ }): T;
26
+ interface ICreateApiParserOptions<S, C> {
27
+ /**
28
+ * The full file name (absolute path) of the file where `parseWorker` is located
29
+ */
30
+ filename: string;
31
+ /**
32
+ * Parsing class working in worker_thead
33
+ */
34
+ worker: S;
35
+ /**
36
+ * Main thread side work, mainly to detect file changes
37
+ */
38
+ parseOptions?: C;
39
+ }
40
+ export interface IBaseApiParserOptions {
41
+ entryFile: string;
42
+ resolveDir: string;
43
+ }
44
+ /**
45
+ * Can be used to override apiParser
46
+ * @param options
47
+ * @returns A function that returns a Parser instance
48
+ * @example
49
+ * ```ts
50
+ * interface ParserOptions extends BaseApiParserOptions {
51
+ * // other props...
52
+ * }
53
+ * const Parser = createApiParser({
54
+ * filename: __filename,
55
+ * worker: (class {
56
+ * constructor(opts: ParserOptions) {}
57
+ * patch () {}
58
+ * async parse () {
59
+ * return {
60
+ * components: {},
61
+ * functions: {}
62
+ * };
63
+ * }
64
+ * async destroy () {}
65
+ * }),
66
+ * parserOptions: {
67
+ * handleWatcher(watcher, { parse, patch }) {
68
+ * return watcher.on('all', (ev, file) => {
69
+ * // You can perform patch and parse operations based on file changes.
70
+ * // patch will transfer the corresponding file to the parseWorker,
71
+ * // and parse will instruct the parseWorker to parse according to updated files.
72
+ * });
73
+ * },
74
+ * },
75
+ * });
76
+ * ```
77
+ */
78
+ export declare function createApiParser<P extends new (...args: ConstructorParameters<P>) => InstanceType<P> & ILanguageMetaParser>(options: ICreateApiParserOptions<P, Partial<IBaseAtomAssetsParserParams<P>>>): (...args: ConstructorParameters<P>) => BaseAtomAssetsParser<ILanguageMetaParser>;
79
+ export {};
package/dist/cli.d.ts ADDED
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import type { IDemoCompileFn } from '../theme-api/types';
2
+ declare const compile: IDemoCompileFn;
3
+ export default compile;
@@ -0,0 +1 @@
1
+ export { default } from 'dumi/theme/slots/NotFound';
@@ -0,0 +1,4 @@
1
+ import { type FC } from 'react';
2
+ import './index.less';
3
+ declare const DemoRenderPage: FC;
4
+ export default DemoRenderPage;
@@ -0,0 +1 @@
1
+ export { default } from 'dumi/theme/slots/Loading';
@@ -0,0 +1,13 @@
1
+ import { AtomAsset, ExamplePresetAsset } from 'dumi-assets-types';
2
+ import type { TypeMap } from 'dumi-assets-types/typings/atom/props/types';
3
+ import { type FC } from 'react';
4
+ interface IAtomRendererProps {
5
+ type: AtomAsset['type'];
6
+ value: ExamplePresetAsset['value'];
7
+ processor?: typeof builtInProcessor;
8
+ }
9
+ type Entity = TypeMap['element'] | TypeMap['function'] | TypeMap['dom'];
10
+ type Exports = Record<string, any>;
11
+ declare function builtInProcessor(entity: Entity, entryExports: Exports): any;
12
+ export declare const AtomRenderer: FC<IAtomRendererProps>;
13
+ export {};
@@ -0,0 +1,5 @@
1
+ import { type FC, type ReactNode } from 'react';
2
+ declare const DemoErrorBoundary: FC<{
3
+ children: ReactNode;
4
+ }>;
5
+ export default DemoErrorBoundary;
@@ -0,0 +1,10 @@
1
+ import { type FC } from 'react';
2
+ import type { IPreviewerProps } from '../types';
3
+ export interface IDumiDemoProps {
4
+ demo: {
5
+ id: string;
6
+ inline?: boolean;
7
+ };
8
+ previewerProps: Omit<IPreviewerProps, 'asset' | 'children'>;
9
+ }
10
+ export declare const DumiDemo: FC<IDumiDemoProps>;
@@ -0,0 +1,7 @@
1
+ import { ReactNode, type FC } from 'react';
2
+ import type { IDumiDemoProps } from './DumiDemo';
3
+ export interface IDumiDemoGridProps {
4
+ items: IDumiDemoProps[];
5
+ demoRender?: (item: IDumiDemoProps) => ReactNode;
6
+ }
7
+ export declare const DumiDemoGrid: FC<IDumiDemoGridProps>;
@@ -0,0 +1,4 @@
1
+ import { type FC, type ReactNode } from 'react';
2
+ export declare const DumiPage: FC<{
3
+ children: ReactNode;
4
+ }>;
@@ -0,0 +1,22 @@
1
+ /// <reference types="react" />
2
+ import type { PICKED_PKG_FIELDS } from "../../constants";
3
+ import type { AtomComponentAsset } from 'dumi-assets-types';
4
+ import type { IDemoData, ILocalesConfig, IThemeConfig } from './types';
5
+ export interface ISiteContext {
6
+ pkg: Partial<Record<keyof typeof PICKED_PKG_FIELDS, any>>;
7
+ historyType: 'browser' | 'hash' | 'memory';
8
+ entryExports: Record<string, any>;
9
+ demos: Record<string, IDemoData>;
10
+ components: Record<string, AtomComponentAsset>;
11
+ locales: ILocalesConfig;
12
+ themeConfig: IThemeConfig;
13
+ hostname?: string;
14
+ loading: boolean;
15
+ setLoading: (status: boolean) => void;
16
+ /**
17
+ * private field, do not use it in your code
18
+ */
19
+ _2_level_nav_available: boolean;
20
+ }
21
+ export declare const SiteContext: import("react").Context<ISiteContext>;
22
+ export declare const useSiteData: () => ISiteContext;
@@ -0,0 +1,18 @@
1
+ export { FormattedDate, FormattedDateParts, FormattedDisplayName, FormattedList, FormattedMessage, FormattedNumber, FormattedNumberParts, FormattedPlural, FormattedRelativeTime, FormattedTime, FormattedTimeParts, IntlContext, IntlProvider, RawIntlProvider, createIntlCache, defineMessages, injectIntl, useIntl, } from 'react-intl';
2
+ export { AtomRenderer } from './AtomRenderer';
3
+ export { DumiDemo } from './DumiDemo';
4
+ export { DumiDemoGrid } from './DumiDemoGrid';
5
+ export { DumiPage } from './DumiPage';
6
+ export { useSiteData } from './context';
7
+ export { openCodeSandbox } from './openCodeSandbox';
8
+ export { openStackBlitz } from './openStackBlitz';
9
+ export type { IDemoCancelableFn, IPreviewerProps } from './types';
10
+ export { useAtomAssets } from './useAtomAssets';
11
+ export { useLiveDemo } from './useLiveDemo';
12
+ export { useLocale } from './useLocale';
13
+ export { useNavData } from './useNavData';
14
+ export { usePrefersColor } from './usePrefersColor';
15
+ export { useMatchedRoute, useRouteMeta } from './useRouteMeta';
16
+ export { useFullSidebarData, useSidebarData } from './useSidebarData';
17
+ export { useSiteSearch } from './useSiteSearch';
18
+ export { useTabMeta } from './useTabMeta';
@@ -0,0 +1,10 @@
1
+ import { type IPreviewerProps } from 'dumi';
2
+ /**
3
+ * use CodeSandbox.io
4
+ * @param data previewer opts
5
+ * @param opts the api that CodeSandbox calls when creating the demo
6
+ * @note return a open function for open demo on codesandbox.io
7
+ */
8
+ export declare const openCodeSandbox: (data: IPreviewerProps, opts?: {
9
+ api?: string;
10
+ }) => void;
@@ -0,0 +1,2 @@
1
+ import { type IPreviewerProps } from 'dumi';
2
+ export declare const openStackBlitz: (data: IPreviewerProps) => void;
@@ -0,0 +1,258 @@
1
+ import type { ExampleBlockAsset } from 'dumi-assets-types';
2
+ import type { ComponentType as ReactComponentType, ReactNode } from 'react';
3
+ export interface IPreviewerProps {
4
+ /**
5
+ * title of current demo
6
+ */
7
+ title?: string;
8
+ /**
9
+ * description of current demo
10
+ */
11
+ description?: string;
12
+ /**
13
+ * filename of current demo
14
+ */
15
+ filename?: string;
16
+ /**
17
+ * use iframe to render demo
18
+ */
19
+ iframe?: boolean | number;
20
+ /**
21
+ * debug mark (will only render in dev by default)
22
+ */
23
+ debug?: boolean;
24
+ /**
25
+ * display the source code or not by default
26
+ */
27
+ defaultShowCode?: boolean;
28
+ /**
29
+ * url for render current demo in a single page
30
+ */
31
+ demoUrl: string;
32
+ /**
33
+ * disable demo content padding
34
+ */
35
+ compact?: boolean;
36
+ /**
37
+ * add transform property for handle absolute/fixed position element
38
+ */
39
+ transform?: boolean;
40
+ /**
41
+ * background color for demo content
42
+ */
43
+ background?: string;
44
+ /**
45
+ * asset metadata of current demo
46
+ */
47
+ asset: ExampleBlockAsset;
48
+ /**
49
+ * react node of current demo
50
+ */
51
+ children: ReactNode;
52
+ /**
53
+ * private field, do not use it in your code
54
+ */
55
+ _live_in_iframe?: boolean;
56
+ [key: string]: any;
57
+ }
58
+ export interface IRouteMeta {
59
+ frontmatter: {
60
+ title: string;
61
+ description?: string;
62
+ keywords?: string[];
63
+ nav?: string | {
64
+ title?: string;
65
+ order?: number;
66
+ second?: Omit<IRouteMeta['frontmatter']['nav'], 'second'>;
67
+ };
68
+ group?: string | {
69
+ title?: string;
70
+ order?: number;
71
+ };
72
+ order?: number;
73
+ hero?: {
74
+ title?: string;
75
+ description?: string;
76
+ background?: string;
77
+ actions?: {
78
+ text: string;
79
+ link: string;
80
+ }[];
81
+ [key: string]: any;
82
+ };
83
+ features?: {
84
+ emoji?: string;
85
+ title?: string;
86
+ link?: string;
87
+ description?: string;
88
+ [key: string]: any;
89
+ }[];
90
+ toc?: boolean | 'content' | 'menu';
91
+ demo?: {
92
+ cols?: number;
93
+ tocDepth?: number;
94
+ };
95
+ atomId?: string;
96
+ filename?: string;
97
+ lastUpdated?: number;
98
+ debug?: boolean;
99
+ /**
100
+ * Control the display of the sidebar menu.
101
+ * @default true
102
+ */
103
+ sidebar?: boolean;
104
+ [key: string]: any;
105
+ };
106
+ toc: {
107
+ id: string;
108
+ depth: number;
109
+ title: string;
110
+ /**
111
+ * private field, do not use it in your code
112
+ */
113
+ _debug_demo?: boolean;
114
+ }[];
115
+ texts: {
116
+ type?: 'content';
117
+ value: string;
118
+ /**
119
+ * paragraph index
120
+ */
121
+ paraId: number;
122
+ /**
123
+ * title index in toc
124
+ */
125
+ tocIndex?: number;
126
+ }[];
127
+ tabs?: {
128
+ key: string;
129
+ title?: string;
130
+ titleIntlId?: string;
131
+ components: {
132
+ default: ReactComponentType;
133
+ Extra: ReactComponentType;
134
+ Action: ReactComponentType;
135
+ };
136
+ meta: {
137
+ frontmatter: Omit<IRouteMeta['frontmatter'], 'description' | 'keywords' | 'nav' | 'group' | 'hero' | 'features'>;
138
+ toc: IRouteMeta['toc'];
139
+ texts: IRouteMeta['texts'];
140
+ [key: string]: any;
141
+ };
142
+ }[];
143
+ /**
144
+ * private field, do not use it in your code
145
+ */
146
+ _atom_route?: boolean;
147
+ }
148
+ type IBasicLocale = {
149
+ id: string;
150
+ name: string;
151
+ };
152
+ export type ILocale = (IBasicLocale & {
153
+ base: string;
154
+ }) | (IBasicLocale & {
155
+ suffix: string;
156
+ });
157
+ export type ILocalesConfig = ILocale[];
158
+ export interface INavItem {
159
+ title: string;
160
+ link?: string;
161
+ order?: number;
162
+ activePath?: string;
163
+ [key: string]: any;
164
+ }
165
+ export interface ISidebarItem {
166
+ title: string;
167
+ link: string;
168
+ order?: number;
169
+ frontmatter?: IRouteMeta['frontmatter'];
170
+ [key: string]: any;
171
+ }
172
+ export interface ISidebarGroup {
173
+ title?: string;
174
+ children: ISidebarItem[];
175
+ [key: string]: any;
176
+ }
177
+ export type SocialTypes = 'github' | 'weibo' | 'twitter' | 'x' | 'gitlab' | 'facebook' | 'zhihu' | 'yuque' | 'linkedin';
178
+ export type INavItems = (INavItem & {
179
+ children?: INavItem[];
180
+ })[];
181
+ export type INav = INavItems | Record<string, INavItems>;
182
+ type IUserNavItem = Pick<INavItem, 'title' | 'link' | 'activePath'>;
183
+ export type IUserNavMode = 'override' | 'append' | 'prepend';
184
+ export type IUserNavItems = (IUserNavItem & {
185
+ children?: IUserNavItem[];
186
+ })[];
187
+ export type IUserNavValue = IUserNavItems | Record<string, IUserNavItems>;
188
+ export type NavWithMode<T extends IUserNavValue> = {
189
+ /**
190
+ * 扩展导航的模式
191
+ * @description
192
+ * - 'override': 用 value 中配置的导航直接覆盖约定路由的导航
193
+ * - 'append': 将 value 中配置的导航追加到约定路由导航后面
194
+ * - 'prepend': 将 value 中配置的导航添加到约定路由导航前面
195
+ */
196
+ mode: IUserNavMode;
197
+ value: T;
198
+ };
199
+ export interface IThemeConfig {
200
+ name?: string;
201
+ logo?: string | false;
202
+ nav?: IUserNavValue | NavWithMode<IUserNavValue>;
203
+ sidebar?: Record<string, ISidebarGroup[]>;
204
+ footer?: string | false;
205
+ showLineNum?: boolean;
206
+ prefersColor: {
207
+ default: 'light' | 'dark' | 'auto';
208
+ switch: boolean;
209
+ };
210
+ nprogress?: boolean;
211
+ socialLinks?: {
212
+ [key in SocialTypes]?: string;
213
+ };
214
+ editLink?: boolean | string;
215
+ sourceLink?: boolean | string;
216
+ lastUpdated?: boolean;
217
+ [key: string]: any;
218
+ }
219
+ export type IRoutesById = Record<string, {
220
+ path?: string;
221
+ parentId?: string;
222
+ meta?: IRouteMeta;
223
+ id: string;
224
+ redirect?: string;
225
+ [key: string]: any;
226
+ }>;
227
+ export type AgnosticComponentModule = {
228
+ default?: any;
229
+ [key: string]: any;
230
+ };
231
+ export type AgnosticComponentType = Promise<AgnosticComponentModule> | AgnosticComponentModule;
232
+ export type IDemoCompileFn = (code: string, opts: {
233
+ filename: string;
234
+ }) => Promise<string>;
235
+ export type IDemoCancelableFn = (canvas: HTMLElement, component: AgnosticComponentModule) => (() => void) | Promise<() => void>;
236
+ export type IDemoPreflightFn = (component: AgnosticComponentModule) => Promise<void>;
237
+ export type IDemoData = {
238
+ component: ReactComponentType | AgnosticComponentType;
239
+ asset: IPreviewerProps['asset'];
240
+ routeId: string;
241
+ context?: Record<string, unknown>;
242
+ renderOpts?: {
243
+ /**
244
+ * provide a runtime compile function for compile demo code for live preview
245
+ */
246
+ compile?: IDemoCompileFn;
247
+ /**
248
+ * Component rendering function, used to manage the creation and unmount of components
249
+ */
250
+ renderer?: IDemoCancelableFn;
251
+ /**
252
+ * Used to detect initialization errors of components in advance
253
+ * (if there is an error, the component will not be mounted)
254
+ */
255
+ preflight?: IDemoPreflightFn;
256
+ };
257
+ };
258
+ export {};
@@ -0,0 +1,4 @@
1
+ import { AtomComponentAsset } from 'dumi-assets-types';
2
+ export declare const useAtomAssets: () => {
3
+ components: Record<string, AtomComponentAsset>;
4
+ };
@@ -0,0 +1,10 @@
1
+ import { type ReactNode, type RefObject } from 'react';
2
+ export declare const useLiveDemo: (id: string, opts?: {
3
+ containerRef?: RefObject<HTMLElement>;
4
+ iframe?: boolean;
5
+ }) => {
6
+ node: ReactNode;
7
+ loading: boolean;
8
+ error: Error | null;
9
+ setSource: (source: Record<string, string>) => Promise<void>;
10
+ };
@@ -0,0 +1,2 @@
1
+ import type { ILocale } from './types';
2
+ export declare const useLocale: () => ILocale;
@@ -0,0 +1,5 @@
1
+ import type { INavItems } from './types';
2
+ /**
3
+ * hook for get nav data
4
+ */
5
+ export declare const useNavData: () => INavItems;
@@ -0,0 +1,7 @@
1
+ export type IColorValue = 'light' | 'dark';
2
+ export type IPrefersColorValue = IColorValue | 'auto';
3
+ /**
4
+ * hook for get/set prefers-color-schema, use to control color mode for theme package
5
+ * @see https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme
6
+ */
7
+ export declare const usePrefersColor: () => [IColorValue, IPrefersColorValue, (val: IPrefersColorValue) => void];
@@ -0,0 +1,12 @@
1
+ /// <reference types="react" />
2
+ import type { AgnosticComponentType, IDemoData } from './types';
3
+ export interface UseRendererOptions {
4
+ id: string;
5
+ component?: AgnosticComponentType;
6
+ renderOpts: IDemoData['renderOpts'];
7
+ onResolved?: () => void;
8
+ }
9
+ export declare const useRenderer: ({ id, component, renderOpts, onResolved, }: UseRendererOptions) => {
10
+ canvasRef: import("react").RefObject<HTMLDivElement>;
11
+ setComponent: import("react").Dispatch<import("react").SetStateAction<AgnosticComponentType | null>>;
12
+ };
@@ -0,0 +1,17 @@
1
+ import type { IRouteMeta } from './types';
2
+ /**
3
+ * hook for get matched route
4
+ * @internal internal use. Do not use in your production code.
5
+ */
6
+ export declare const useMatchedRoute: () => {
7
+ [key: string]: any;
8
+ path?: string | undefined;
9
+ parentId?: string | undefined;
10
+ meta?: IRouteMeta | undefined;
11
+ id: string;
12
+ redirect?: string | undefined;
13
+ };
14
+ /**
15
+ * hook for get matched route meta
16
+ */
17
+ export declare const useRouteMeta: () => IRouteMeta;
@@ -0,0 +1,29 @@
1
+ import type { ILocalesConfig, IRouteMeta, ISidebarGroup } from './types';
2
+ export declare const getLocaleClearPath: (routePath: string, locale: ILocalesConfig[0]) => string;
3
+ /**
4
+ * get parent path from route path
5
+ */
6
+ export declare function getRouteParentPath(path: string, { meta, is2LevelNav, locale, }: {
7
+ meta?: IRouteMeta;
8
+ is2LevelNav: boolean;
9
+ locale: ILocalesConfig[0];
10
+ }): string;
11
+ /**
12
+ * hook for get sidebar data for all nav
13
+ */
14
+ export declare const useFullSidebarData: () => Record<string, ISidebarGroup[]>;
15
+ interface ITreeSidebarLeaf {
16
+ path: string;
17
+ title: string;
18
+ order: number;
19
+ children: (ITreeSidebarLeaf | ISidebarGroup)[];
20
+ }
21
+ /**
22
+ * hook for get full sidebar data in tree structure
23
+ */
24
+ export declare const useTreeSidebarData: () => ITreeSidebarLeaf[];
25
+ /**
26
+ * hook for get sidebar data for current nav
27
+ */
28
+ export declare const useSidebarData: () => ISidebarGroup[];
29
+ export {};