dumi 2.0.0-alpha.0 → 2.0.0-alpha.1
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/dist/assetParsers/block.d.ts +17 -0
- package/dist/assetParsers/block.js +130 -0
- package/dist/client/theme-api/DumiDemo.d.ts +10 -0
- package/dist/client/theme-api/DumiDemo.js +16 -0
- package/dist/client/theme-api/DumiDemoGrid.d.ts +6 -0
- package/dist/client/theme-api/DumiDemoGrid.js +14 -0
- package/dist/client/theme-api/context.d.ts +14 -0
- package/dist/client/{theme → theme-api}/context.js +2 -1
- package/dist/client/theme-api/index.d.ts +5 -0
- package/dist/client/theme-api/index.js +5 -0
- package/dist/client/theme-api/types.d.ts +20 -0
- package/dist/client/theme-api/types.js +1 -0
- package/dist/client/tsconfig.json +10 -0
- package/dist/features/compile.js +1 -0
- package/dist/features/locales.d.ts +3 -0
- package/dist/features/locales.js +85 -0
- package/dist/features/routes.js +13 -3
- package/dist/features/theme/index.js +8 -3
- package/dist/features/theme/loader.js +3 -3
- package/dist/loaders/markdown/index.js +13 -2
- package/dist/loaders/markdown/transformer/index.d.ts +14 -12
- package/dist/loaders/markdown/transformer/index.js +3 -1
- package/dist/loaders/markdown/transformer/rehypeDemo.js +129 -23
- package/dist/loaders/markdown/transformer/rehypeIsolation.js +1 -1
- package/dist/loaders/markdown/transformer/rehypeJsxify.js +1 -0
- package/dist/preset.js +2 -1
- package/dist/types.d.ts +8 -3
- package/package.json +21 -5
- package/theme-default/builtins/Previewer.d.ts +4 -0
- package/theme-default/builtins/Previewer.js +11 -0
- package/theme-default/locales/en-US.json +3 -0
- package/theme-default/locales/zh-CN.json +3 -0
- package/theme.d.ts +1 -0
- package/dist/client/theme/DumiDemo.d.ts +0 -4
- package/dist/client/theme/DumiDemo.js +0 -9
- package/dist/client/theme/context.d.ts +0 -5
- package/dist/client/theme/index.d.ts +0 -2
- package/dist/client/theme/index.js +0 -2
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ExampleBlockAsset } from 'dumi-assets-types';
|
|
2
|
+
export interface IParsedBlockAsset {
|
|
3
|
+
asset: ExampleBlockAsset;
|
|
4
|
+
sources: Record<string, string>;
|
|
5
|
+
frontmatter: ReturnType<typeof parseCodeFrontmatter>['frontmatter'];
|
|
6
|
+
}
|
|
7
|
+
declare function parseCodeFrontmatter(raw: string): {
|
|
8
|
+
code: string;
|
|
9
|
+
frontmatter: Record<string, any> | null;
|
|
10
|
+
};
|
|
11
|
+
declare function parseBlockAsset(opts: {
|
|
12
|
+
fileAbsPath: string;
|
|
13
|
+
id: string;
|
|
14
|
+
refAtomIds: string[];
|
|
15
|
+
entryPointCode?: string;
|
|
16
|
+
}): Promise<IParsedBlockAsset>;
|
|
17
|
+
export default parseBlockAsset;
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
+
|
|
22
|
+
// src/assetParsers/block.ts
|
|
23
|
+
var block_exports = {};
|
|
24
|
+
__export(block_exports, {
|
|
25
|
+
default: () => block_default
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(block_exports);
|
|
28
|
+
var import_esbuild = require("@umijs/bundler-utils/compiled/esbuild");
|
|
29
|
+
var import_fs = __toESM(require("fs"));
|
|
30
|
+
var import_js_yaml = __toESM(require("js-yaml"));
|
|
31
|
+
var import_path = __toESM(require("path"));
|
|
32
|
+
var import_plugin_utils = require("umi/plugin-utils");
|
|
33
|
+
function parseCodeFrontmatter(raw) {
|
|
34
|
+
const [, comment = "", code = ""] = raw.replace(/^\n\s*/, "").match(/^(\/\*\*[^]*?\n\s*\*\/)?(?:\s|\n)*([^]+)?$/);
|
|
35
|
+
const yamlComment = comment.replace(/^\/|\/$/g, "").replace(/(^|\n)\s*\*+/g, "$1");
|
|
36
|
+
let frontmatter = null;
|
|
37
|
+
try {
|
|
38
|
+
frontmatter = import_js_yaml.default.load(yamlComment);
|
|
39
|
+
} catch {
|
|
40
|
+
}
|
|
41
|
+
return { code: frontmatter ? code : raw, frontmatter };
|
|
42
|
+
}
|
|
43
|
+
async function parseBlockAsset(opts) {
|
|
44
|
+
const asset = {
|
|
45
|
+
type: "BLOCK",
|
|
46
|
+
id: opts.id,
|
|
47
|
+
refAtomIds: opts.refAtomIds,
|
|
48
|
+
dependencies: {}
|
|
49
|
+
};
|
|
50
|
+
const result = {
|
|
51
|
+
asset,
|
|
52
|
+
sources: {},
|
|
53
|
+
frontmatter: {}
|
|
54
|
+
};
|
|
55
|
+
await (0, import_esbuild.build)({
|
|
56
|
+
write: false,
|
|
57
|
+
bundle: true,
|
|
58
|
+
logLevel: "silent",
|
|
59
|
+
format: "esm",
|
|
60
|
+
target: "esnext",
|
|
61
|
+
entryPoints: [import_path.default.basename(opts.fileAbsPath)],
|
|
62
|
+
absWorkingDir: import_path.default.dirname(opts.fileAbsPath),
|
|
63
|
+
plugins: [
|
|
64
|
+
{
|
|
65
|
+
name: "plugin-dumi-collect-deps",
|
|
66
|
+
setup: (builder) => {
|
|
67
|
+
builder.onResolve({ filter: /.*/ }, (args) => {
|
|
68
|
+
if (args.kind !== "entry-point" && !args.path.startsWith(".")) {
|
|
69
|
+
const pkgJsonPath = import_plugin_utils.pkgUp.pkgUpSync({
|
|
70
|
+
cwd: require.resolve(args.path, { paths: [args.resolveDir] })
|
|
71
|
+
});
|
|
72
|
+
if (pkgJsonPath) {
|
|
73
|
+
asset.dependencies[args.path] = {
|
|
74
|
+
type: "NPM",
|
|
75
|
+
value: require(pkgJsonPath).version
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
return { path: args.path, external: true };
|
|
79
|
+
}
|
|
80
|
+
return {
|
|
81
|
+
path: import_path.default.join(args.resolveDir, args.path),
|
|
82
|
+
pluginData: { kind: args.kind, resolveDir: args.resolveDir }
|
|
83
|
+
};
|
|
84
|
+
});
|
|
85
|
+
builder.onLoad({ filter: /.*/ }, (args) => {
|
|
86
|
+
const ext = import_path.default.extname(args.path);
|
|
87
|
+
const isModule = [".js", ".jsx", ".ts", ".tsx"].includes(ext);
|
|
88
|
+
const isPlainText = [
|
|
89
|
+
".css",
|
|
90
|
+
".less",
|
|
91
|
+
".sass",
|
|
92
|
+
".scss",
|
|
93
|
+
".styl",
|
|
94
|
+
".json"
|
|
95
|
+
].includes(ext);
|
|
96
|
+
const isEntryPoint = args.pluginData.kind === "entry-point";
|
|
97
|
+
const filename = isEntryPoint ? `index${ext}` : (0, import_plugin_utils.winPath)(import_path.default.relative(import_path.default.dirname(opts.fileAbsPath), args.path));
|
|
98
|
+
if (isModule || isPlainText) {
|
|
99
|
+
asset.dependencies[filename] = {
|
|
100
|
+
type: "FILE",
|
|
101
|
+
value: opts.entryPointCode ?? import_fs.default.readFileSync(args.path, "utf-8")
|
|
102
|
+
};
|
|
103
|
+
if (isEntryPoint) {
|
|
104
|
+
const { code, frontmatter } = parseCodeFrontmatter(asset.dependencies[filename].value);
|
|
105
|
+
if (frontmatter) {
|
|
106
|
+
asset.dependencies[filename].value = code;
|
|
107
|
+
result.frontmatter = frontmatter;
|
|
108
|
+
["description", "title", "snapshot", "keywords"].forEach((key) => {
|
|
109
|
+
asset[key] = frontmatter == null ? void 0 : frontmatter[key];
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
if (!isEntryPoint || !opts.entryPointCode) {
|
|
114
|
+
result.sources[filename] = args.path;
|
|
115
|
+
}
|
|
116
|
+
return {
|
|
117
|
+
contents: isModule ? asset.dependencies[filename].value : "",
|
|
118
|
+
loader: isModule ? ext.slice(1) : "text"
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
]
|
|
125
|
+
});
|
|
126
|
+
return result;
|
|
127
|
+
}
|
|
128
|
+
var block_default = parseBlockAsset;
|
|
129
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
130
|
+
0 && (module.exports = {});
|
|
@@ -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,16 @@
|
|
|
1
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
+
|
|
3
|
+
import Previewer from 'dumi/theme/builtins/Previewer';
|
|
4
|
+
import React, { createElement, useContext } from 'react';
|
|
5
|
+
import { Context } from "./context";
|
|
6
|
+
export var DumiDemo = function DumiDemo(props) {
|
|
7
|
+
var _useContext = useContext(Context),
|
|
8
|
+
demos = _useContext.demos;
|
|
9
|
+
|
|
10
|
+
var _demos$props$demo$id = demos[props.demo.id],
|
|
11
|
+
component = _demos$props$demo$id.component,
|
|
12
|
+
asset = _demos$props$demo$id.asset;
|
|
13
|
+
return /*#__PURE__*/React.createElement(Previewer, _extends({
|
|
14
|
+
asset: asset
|
|
15
|
+
}, props.previewerProps), /*#__PURE__*/createElement(component));
|
|
16
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { DumiDemo } from "./DumiDemo";
|
|
3
|
+
export var DumiDemoGrid = function DumiDemoGrid(props) {
|
|
4
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
5
|
+
style: {
|
|
6
|
+
display: 'grid',
|
|
7
|
+
gridTemplateColumns: 'repeat(2, 1fr)'
|
|
8
|
+
}
|
|
9
|
+
}, props.items.map(function (item) {
|
|
10
|
+
return /*#__PURE__*/React.createElement("section", {
|
|
11
|
+
key: item.demo.id
|
|
12
|
+
}, /*#__PURE__*/React.createElement(DumiDemo, item));
|
|
13
|
+
}));
|
|
14
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type ComponentType } from 'react';
|
|
2
|
+
import type { IPreviewerProps } from './types';
|
|
3
|
+
export interface IThemeContext {
|
|
4
|
+
demos: Record<string, {
|
|
5
|
+
component: ComponentType;
|
|
6
|
+
asset: IPreviewerProps['asset'];
|
|
7
|
+
}>;
|
|
8
|
+
locales: {
|
|
9
|
+
id: string;
|
|
10
|
+
name: string;
|
|
11
|
+
base: string;
|
|
12
|
+
}[];
|
|
13
|
+
}
|
|
14
|
+
export declare const Context: import("react").Context<IThemeContext>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ExampleBlockAsset } from 'dumi-assets-types';
|
|
2
|
+
import type { 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
|
+
* asset metadata of current demo
|
|
14
|
+
*/
|
|
15
|
+
asset: ExampleBlockAsset;
|
|
16
|
+
/**
|
|
17
|
+
* react node of current demo
|
|
18
|
+
*/
|
|
19
|
+
children: ReactNode;
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/features/compile.js
CHANGED
|
@@ -41,6 +41,7 @@ var compile_default = (api) => {
|
|
|
41
41
|
builtins: api.service.themeData.builtins
|
|
42
42
|
});
|
|
43
43
|
memo.module.rule("dumi-demo").type("javascript/auto").test(/\..+$/).enforce("pre").resourceQuery(/techStack/).use("demo-loader").loader(require.resolve("../loaders/demo")).options({ techStacks, cwd: api.cwd });
|
|
44
|
+
memo.module.rule("dumi-raw").resourceQuery(/raw/).use("raw-loader").loader(require.resolve("raw-loader"));
|
|
44
45
|
if (api.env === "development") {
|
|
45
46
|
memo.plugin("fastRefresh").tap(([params]) => [
|
|
46
47
|
{
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/features/locales.ts
|
|
20
|
+
var locales_exports = {};
|
|
21
|
+
__export(locales_exports, {
|
|
22
|
+
default: () => locales_default
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(locales_exports);
|
|
25
|
+
var locales_default = (api) => {
|
|
26
|
+
api.describe({
|
|
27
|
+
config: {
|
|
28
|
+
default: [{ id: "zh-CN", name: "\u4E2D\u6587", base: "/" }],
|
|
29
|
+
schema: (Joi) => Joi.array().items(Joi.object({
|
|
30
|
+
id: Joi.string().regex(/^[a-z]{2}-[A-Z]{2}$/),
|
|
31
|
+
name: Joi.string(),
|
|
32
|
+
base: Joi.string().optional()
|
|
33
|
+
}))
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
api.register({
|
|
37
|
+
key: "modifyConfig",
|
|
38
|
+
stage: Infinity,
|
|
39
|
+
fn: (memo) => {
|
|
40
|
+
var _a;
|
|
41
|
+
(_a = memo.locales) == null ? void 0 : _a.forEach((locale, i) => {
|
|
42
|
+
locale.base ?? (locale.base = i ? `/${locale.id}` : "/");
|
|
43
|
+
});
|
|
44
|
+
return memo;
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
api.onGenerateFiles(() => {
|
|
48
|
+
api.writeTmpFile({
|
|
49
|
+
noPluginDir: true,
|
|
50
|
+
path: "dumi/locales/config.ts",
|
|
51
|
+
content: `export const locales = ${JSON.stringify(api.config.locales, null, 2)};
|
|
52
|
+
export const messages = ${JSON.stringify(api.service.themeData.locales, null, 2)};`
|
|
53
|
+
});
|
|
54
|
+
api.writeTmpFile({
|
|
55
|
+
noPluginDir: true,
|
|
56
|
+
path: "dumi/locales/runtime.tsx",
|
|
57
|
+
content: `
|
|
58
|
+
import { history } from 'umi';
|
|
59
|
+
import React, { useState, type ReactNode } from 'react';
|
|
60
|
+
import { RawIntlProvider, createIntl, createIntlCache } from 'react-intl';
|
|
61
|
+
import { locales, messages } from './config';
|
|
62
|
+
|
|
63
|
+
const cache = createIntlCache();
|
|
64
|
+
|
|
65
|
+
const LocalesContainer: FC<{ children: ReactNode }> = (props) => {
|
|
66
|
+
const [locale] = useState(() => {
|
|
67
|
+
const matched = locales.find((locale) => history.location.pathname.startsWith(locale.base));
|
|
68
|
+
|
|
69
|
+
return matched ? matched.id : locales[0].id;
|
|
70
|
+
});
|
|
71
|
+
const [intl] = useState(() => createIntl({ locale, messages: messages[locale] || {} }, cache))
|
|
72
|
+
|
|
73
|
+
return <RawIntlProvider value={intl}>{props.children}</RawIntlProvider>;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export function i18nProvider(container: Element) {
|
|
77
|
+
return React.createElement(LocalesContainer, null, container);
|
|
78
|
+
}
|
|
79
|
+
`
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
api.addRuntimePlugin(() => "@@/dumi/locales/runtime.tsx");
|
|
83
|
+
};
|
|
84
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
85
|
+
0 && (module.exports = {});
|
package/dist/features/routes.js
CHANGED
|
@@ -30,6 +30,14 @@ var import_path = __toESM(require("path"));
|
|
|
30
30
|
var import_pluralize = require("pluralize");
|
|
31
31
|
var import_plugin_utils = require("umi/plugin-utils");
|
|
32
32
|
var CTX_LAYOUT_ID = "dumi-context-layout";
|
|
33
|
+
function localizeUmiRoute(route, locales) {
|
|
34
|
+
const locale = locales.find((locale2) => route.path.endsWith(`/${locale2.id}`) && import_path.default.parse(route.file).name.endsWith(`.${locale2.id}`));
|
|
35
|
+
if (locale) {
|
|
36
|
+
const base = locale.base === "/" ? "" : locale.base;
|
|
37
|
+
route.path = `${base}${route.path.replace(new RegExp(`/${locale.id}$`), "").replace(/(index|README)$/, "")}`;
|
|
38
|
+
route.path = route.path !== "/" ? `/${route.path}` : route.path;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
33
41
|
var routes_default = (api) => {
|
|
34
42
|
api.describe({ key: "dumi:routes" });
|
|
35
43
|
api.modifyConfig((memo) => {
|
|
@@ -71,22 +79,24 @@ var routes_default = (api) => {
|
|
|
71
79
|
route.id = `${dir}/${key}`;
|
|
72
80
|
route.parentId = docLayoutId;
|
|
73
81
|
route.file = import_path.default.resolve(base, route.file);
|
|
82
|
+
localizeUmiRoute(route, api.config.locales);
|
|
74
83
|
routes[route.id] = route;
|
|
75
84
|
});
|
|
76
85
|
});
|
|
77
86
|
entityDirs.forEach(({ type, dir }) => {
|
|
78
87
|
const base = import_path.default.join(api.cwd, dir);
|
|
79
|
-
const entityFiles = import_plugin_utils.glob.sync("{*,*/index,*/README}.md", { cwd: base });
|
|
88
|
+
const entityFiles = import_plugin_utils.glob.sync("{*,*/index,*/index.*,*/README,*/README.*}.md", { cwd: base });
|
|
80
89
|
entityFiles.forEach((file) => {
|
|
81
|
-
const routePath = (0, import_plugin_utils.winPath)(import_path.default.join((0, import_pluralize.plural)(type), file)).replace(/(\/index|\/README)?\.md$/, "");
|
|
90
|
+
const routePath = (0, import_plugin_utils.winPath)(import_path.default.join((0, import_pluralize.plural)(type), file)).replace(/(\/index|\/README)?\.md$/, "").replace(/\./g, "/");
|
|
82
91
|
const routeId = `${dir}/${routePath}`;
|
|
83
92
|
routes[routeId] = {
|
|
84
93
|
id: routeId,
|
|
85
94
|
path: routePath,
|
|
86
|
-
absPath: routePath
|
|
95
|
+
absPath: `/${routePath}`,
|
|
87
96
|
parentId: docLayoutId,
|
|
88
97
|
file: import_path.default.resolve(base, file)
|
|
89
98
|
};
|
|
99
|
+
localizeUmiRoute(routes[routeId], api.config.locales);
|
|
90
100
|
});
|
|
91
101
|
});
|
|
92
102
|
return routes;
|
|
@@ -69,13 +69,17 @@ var theme_default = (api) => {
|
|
|
69
69
|
DumiDemo: {
|
|
70
70
|
specifier: "{ DumiDemo }",
|
|
71
71
|
source: "dumi/theme"
|
|
72
|
+
},
|
|
73
|
+
DumiDemoGrid: {
|
|
74
|
+
specifier: "{ DumiDemoGrid }",
|
|
75
|
+
source: "dumi/theme"
|
|
72
76
|
}
|
|
73
77
|
});
|
|
74
78
|
return memo;
|
|
75
79
|
}
|
|
76
80
|
});
|
|
77
81
|
api.modifyConfig((memo) => {
|
|
78
|
-
memo.alias["dumi/theme$"] = require.resolve("../../client/theme");
|
|
82
|
+
memo.alias["dumi/theme$"] = require.resolve("../../client/theme-api");
|
|
79
83
|
if (localThemeData) {
|
|
80
84
|
themeMapKeys.forEach((key) => {
|
|
81
85
|
Object.values(localThemeData[key] || {}).forEach((item) => {
|
|
@@ -87,7 +91,7 @@ var theme_default = (api) => {
|
|
|
87
91
|
memo.alias["dumi/theme-original"] = import_path.default.join(api.paths.absTmpPath, "dumi/theme");
|
|
88
92
|
memo.alias["dumi/theme-default"] = DEFAULT_THEME_PATH;
|
|
89
93
|
memo.extraBabelIncludes ?? (memo.extraBabelIncludes = []);
|
|
90
|
-
memo.extraBabelIncludes.push(import_path.default.resolve(__dirname, "../../client/theme"));
|
|
94
|
+
memo.extraBabelIncludes.push(import_path.default.resolve(__dirname, "../../client/theme-api"));
|
|
91
95
|
return memo;
|
|
92
96
|
});
|
|
93
97
|
api.modifyRoutes((routes) => {
|
|
@@ -128,12 +132,13 @@ export default {
|
|
|
128
132
|
content: `import { Context } from 'dumi/theme';
|
|
129
133
|
import { useOutlet } from 'umi';
|
|
130
134
|
import demos from '../demos';
|
|
135
|
+
import { locales } from '../locales/config';
|
|
131
136
|
|
|
132
137
|
export default function DumiContextWrapper() {
|
|
133
138
|
const outlet = useOutlet();
|
|
134
139
|
|
|
135
140
|
return (
|
|
136
|
-
<Context.Provider value={{ demos }}>{outlet}</Context.Provider>
|
|
141
|
+
<Context.Provider value={{ demos, locales }}>{outlet}</Context.Provider>
|
|
137
142
|
);
|
|
138
143
|
}`
|
|
139
144
|
});
|
|
@@ -39,7 +39,7 @@ function getComponentMapFromDir(globExp, dir) {
|
|
|
39
39
|
}
|
|
40
40
|
function getLocaleMapFromDir(globExp, dir) {
|
|
41
41
|
return import_plugin_utils.glob.sync(globExp, { cwd: dir }).reduce((ret, file) => {
|
|
42
|
-
const locale = file.replace(/\.json$/, "");
|
|
42
|
+
const locale = import_path.default.basename(file.replace(/\.json$/, ""));
|
|
43
43
|
ret[locale] = require(import_path.default.join(dir, file));
|
|
44
44
|
return ret;
|
|
45
45
|
}, {});
|
|
@@ -49,8 +49,8 @@ var loader_default = (dir) => {
|
|
|
49
49
|
name: import_path.default.basename(dir),
|
|
50
50
|
path: dir,
|
|
51
51
|
locales: getLocaleMapFromDir("locales/*.json", dir),
|
|
52
|
-
builtins: getComponentMapFromDir("builtins/{
|
|
53
|
-
slots: getComponentMapFromDir("slots/{
|
|
52
|
+
builtins: getComponentMapFromDir("builtins/{!(*.d),*/index}.{js,jsx,ts,tsx}", dir),
|
|
53
|
+
slots: getComponentMapFromDir("slots/{!(*.d),*/index}.{js,jsx,ts,tsx}", dir),
|
|
54
54
|
layouts: getComponentMapFromDir("layouts/{GlobalLayout,DocLayout,DemoLayout}{.,/index.}{js,jsx,ts,tsx}", dir)
|
|
55
55
|
};
|
|
56
56
|
};
|
|
@@ -40,9 +40,20 @@ function mdLoader(raw) {
|
|
|
40
40
|
|
|
41
41
|
export default {
|
|
42
42
|
{{#demos}}
|
|
43
|
-
'{{{id}}}': {
|
|
43
|
+
'{{{id}}}': {
|
|
44
|
+
component: {{{component}}},
|
|
45
|
+
asset: {{{renderAsset}}}
|
|
46
|
+
},
|
|
44
47
|
{{/demos}}
|
|
45
|
-
}`, {
|
|
48
|
+
}`, {
|
|
49
|
+
demos: ret.meta.demos,
|
|
50
|
+
renderAsset: function renderAsset() {
|
|
51
|
+
Object.keys(this.sources).forEach((file) => {
|
|
52
|
+
this.asset.dependencies[file].value = `{{{require('!!raw-loader!${this.sources[file]}?raw').default}}}`;
|
|
53
|
+
});
|
|
54
|
+
return JSON.stringify(this.asset, null, 2).replace(/"{{{|}}}"/g, "");
|
|
55
|
+
}
|
|
56
|
+
}));
|
|
46
57
|
} else {
|
|
47
58
|
cb(null, `${Object.values(opts.builtins).map((item) => `import ${item.specifier} from '${item.source}';`).join("\n")}
|
|
48
59
|
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import type { IParsedBlockAsset } from "../../../assetParsers/block";
|
|
1
2
|
import type { IDumiTechStack } from "../../../types";
|
|
3
|
+
import type { DataMap } from 'vfile';
|
|
2
4
|
declare module 'hast' {
|
|
3
5
|
interface Element {
|
|
4
6
|
JSXAttributes?: Array<{
|
|
@@ -11,6 +13,16 @@ declare module 'hast' {
|
|
|
11
13
|
}>;
|
|
12
14
|
}
|
|
13
15
|
}
|
|
16
|
+
declare module 'vfile' {
|
|
17
|
+
interface DataMap {
|
|
18
|
+
demos: {
|
|
19
|
+
id: string;
|
|
20
|
+
component: string;
|
|
21
|
+
asset: IParsedBlockAsset['asset'];
|
|
22
|
+
sources: IParsedBlockAsset['sources'];
|
|
23
|
+
}[];
|
|
24
|
+
}
|
|
25
|
+
}
|
|
14
26
|
export interface IMdTransformerOptions {
|
|
15
27
|
cwd: string;
|
|
16
28
|
fileAbsPath: string;
|
|
@@ -18,20 +30,10 @@ export interface IMdTransformerOptions {
|
|
|
18
30
|
}
|
|
19
31
|
export interface IMdTransformerResult {
|
|
20
32
|
content: string;
|
|
21
|
-
meta:
|
|
22
|
-
demos: {
|
|
23
|
-
id: string;
|
|
24
|
-
component: string;
|
|
25
|
-
}[];
|
|
26
|
-
};
|
|
33
|
+
meta: DataMap;
|
|
27
34
|
}
|
|
28
35
|
declare const _default: (raw: string, opts: IMdTransformerOptions) => Promise<{
|
|
29
36
|
content: string;
|
|
30
|
-
meta:
|
|
31
|
-
demos: {
|
|
32
|
-
id: string;
|
|
33
|
-
component: string;
|
|
34
|
-
}[];
|
|
35
|
-
};
|
|
37
|
+
meta: import("vfile").Data;
|
|
36
38
|
}>;
|
|
37
39
|
export default _default;
|
|
@@ -33,9 +33,11 @@ var import_rehypeStrip = __toESM(require("./rehypeStrip"));
|
|
|
33
33
|
var transformer_default = async (raw, opts) => {
|
|
34
34
|
const { unified } = await import("unified");
|
|
35
35
|
const { default: remarkParse } = await import("remark-parse");
|
|
36
|
+
const { default: remarkFrontmatter } = await import("remark-frontmatter");
|
|
37
|
+
const { default: remarkBreaks } = await import("remark-breaks");
|
|
36
38
|
const { default: remarkGfm } = await import("remark-gfm");
|
|
37
39
|
const { default: remarkRehype } = await import("remark-rehype");
|
|
38
|
-
const result = await unified().use(remarkParse).use(remarkGfm).use(remarkRehype, { allowDangerousHtml: true }).use(import_rehypeRaw.default).use(import_rehypeStrip.default).use(import_rehypeDemo.default, {
|
|
40
|
+
const result = await unified().use(remarkParse).use(remarkFrontmatter).use(remarkBreaks).use(remarkGfm).use(remarkRehype, { allowDangerousHtml: true }).use(import_rehypeRaw.default).use(import_rehypeStrip.default).use(import_rehypeDemo.default, {
|
|
39
41
|
techStacks: opts.techStacks,
|
|
40
42
|
cwd: opts.cwd,
|
|
41
43
|
fileAbsPath: opts.fileAbsPath
|
|
@@ -25,15 +25,20 @@ __export(rehypeDemo_exports, {
|
|
|
25
25
|
default: () => rehypeDemo
|
|
26
26
|
});
|
|
27
27
|
module.exports = __toCommonJS(rehypeDemo_exports);
|
|
28
|
+
var import_block = __toESM(require("../../../assetParsers/block"));
|
|
28
29
|
var import_utils = require("../../../utils");
|
|
29
30
|
var import_path = __toESM(require("path"));
|
|
30
31
|
var import_plugin_utils = require("umi/plugin-utils");
|
|
31
32
|
var visit;
|
|
32
33
|
var SKIP;
|
|
33
34
|
var toString;
|
|
35
|
+
var isElement;
|
|
36
|
+
var DEMO_NODE_CONTAINER = "$demo-container";
|
|
37
|
+
var DEMO_PROP_VALUE_KEY = "$demo-prop-value-key";
|
|
34
38
|
(async () => {
|
|
35
39
|
({ visit, SKIP } = await import("unist-util-visit"));
|
|
36
40
|
({ toString } = await import("mdast-util-to-string"));
|
|
41
|
+
({ isElement } = await import("hast-util-is-element"));
|
|
37
42
|
})();
|
|
38
43
|
function getCodeLang(node) {
|
|
39
44
|
var _a, _b;
|
|
@@ -49,42 +54,143 @@ function getCodeId(cwd, fileAbsPath, codeIndex, entityName) {
|
|
|
49
54
|
const prefix = entityName || (0, import_utils.getRoutePathFromFsPath)(import_path.default.relative(cwd, fileAbsPath)).replace(/\//g, "-");
|
|
50
55
|
return [prefix, "demo", String(codeIndex)].filter(Boolean).join("-");
|
|
51
56
|
}
|
|
57
|
+
function tryMarkDemoNode(node, opts) {
|
|
58
|
+
var _a, _b;
|
|
59
|
+
let isDemoNode = Boolean((_a = node.data) == null ? void 0 : _a.techStack);
|
|
60
|
+
if (!isDemoNode) {
|
|
61
|
+
const lang = getCodeLang(node);
|
|
62
|
+
const techStack = lang && opts.techStacks.find((ts) => ts.isSupported(node, lang));
|
|
63
|
+
if (techStack) {
|
|
64
|
+
isDemoNode = true;
|
|
65
|
+
node.data ?? (node.data = {});
|
|
66
|
+
node.data.techStack = techStack;
|
|
67
|
+
node.data.lang = lang;
|
|
68
|
+
node.data.type = typeof ((_b = node.properties) == null ? void 0 : _b.src) === "string" ? "external" : "code-block";
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return isDemoNode;
|
|
72
|
+
}
|
|
52
73
|
function rehypeDemo(opts) {
|
|
53
|
-
return (tree, vFile) => {
|
|
74
|
+
return async (tree, vFile) => {
|
|
75
|
+
const deferrers = [];
|
|
76
|
+
const replaceNodes = [];
|
|
54
77
|
let index = 0;
|
|
55
|
-
const demos = [];
|
|
56
78
|
visit(tree, "element", (node) => {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
79
|
+
if (isElement(node, "pre") && node.children.length === 1 && isElement(node.children[0], "code") && tryMarkDemoNode(node.children[0], opts)) {
|
|
80
|
+
node.tagName = "p";
|
|
81
|
+
node.data ?? (node.data = {});
|
|
82
|
+
node.data[DEMO_NODE_CONTAINER] = true;
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
visit(tree, "element", (node, nodeIndex, parent) => {
|
|
86
|
+
if (isElement(node, "p")) {
|
|
87
|
+
for (let childIndex = 0; childIndex < node.children.length; childIndex += 1) {
|
|
88
|
+
let child = node.children[childIndex];
|
|
89
|
+
if (isElement(child, "code") && tryMarkDemoNode(child, opts)) {
|
|
90
|
+
const isFirstChild = childIndex === 0;
|
|
91
|
+
let nextChildIndex = childIndex + 1;
|
|
92
|
+
let nextChild = node.children[nextChildIndex];
|
|
93
|
+
let splitFrom = childIndex;
|
|
94
|
+
if (isFirstChild) {
|
|
95
|
+
node.data ?? (node.data = {});
|
|
96
|
+
node.data[DEMO_NODE_CONTAINER] = true;
|
|
97
|
+
while (nextChild && (isElement(nextChild, "code") && tryMarkDemoNode(nextChild, opts) || isElement(nextChild, "br"))) {
|
|
98
|
+
splitFrom += 1;
|
|
99
|
+
nextChildIndex = splitFrom + 1;
|
|
100
|
+
nextChild = node.children[nextChildIndex];
|
|
101
|
+
}
|
|
102
|
+
if (!nextChild)
|
|
103
|
+
return SKIP;
|
|
104
|
+
}
|
|
105
|
+
const splitChildren = node.children.splice(splitFrom);
|
|
106
|
+
parent.children.splice(nodeIndex + 1, 0, {
|
|
107
|
+
type: "element",
|
|
108
|
+
tagName: "p",
|
|
109
|
+
children: splitChildren
|
|
70
110
|
});
|
|
71
|
-
|
|
72
|
-
|
|
111
|
+
return SKIP;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
visit(tree, "element", (node) => {
|
|
117
|
+
var _a;
|
|
118
|
+
if (isElement(node, "p") && ((_a = node.data) == null ? void 0 : _a[DEMO_NODE_CONTAINER])) {
|
|
119
|
+
const demosPropData = [];
|
|
120
|
+
node.children.forEach((codeNode) => {
|
|
121
|
+
if (isElement(codeNode, "code")) {
|
|
122
|
+
const codeType = codeNode.data.type;
|
|
123
|
+
const techStack = codeNode.data.techStack;
|
|
124
|
+
const codeId = getCodeId(opts.cwd, opts.fileAbsPath, index++);
|
|
125
|
+
const codeValue = toString(codeNode.children).trim();
|
|
126
|
+
const parseOpts = {
|
|
73
127
|
id: codeId,
|
|
74
|
-
|
|
128
|
+
refAtomIds: [],
|
|
129
|
+
fileAbsPath: "",
|
|
130
|
+
entryPointCode: codeType === "external" ? void 0 : codeValue
|
|
131
|
+
};
|
|
132
|
+
const previewerProps = {};
|
|
133
|
+
let component = "";
|
|
134
|
+
if (codeNode.data.type === "external") {
|
|
135
|
+
parseOpts.fileAbsPath = import_path.default.resolve(import_path.default.dirname(opts.fileAbsPath), codeNode.properties.src);
|
|
136
|
+
component = `React.lazy(() => import('${(0, import_plugin_utils.winPath)(parseOpts.fileAbsPath)}?techStack=${techStack.name}'))`;
|
|
137
|
+
} else {
|
|
138
|
+
parseOpts.fileAbsPath = opts.fileAbsPath.replace(".md", ".tsx");
|
|
139
|
+
component = techStack.transformCode(codeValue, {
|
|
75
140
|
type: "code-block",
|
|
76
141
|
fileAbsPath: opts.fileAbsPath
|
|
77
|
-
})
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
deferrers.push((0, import_block.default)(parseOpts).then(async ({ asset, sources, frontmatter }) => {
|
|
145
|
+
const { src, className, title, description, ...restAttrs } = codeNode.properties || {};
|
|
146
|
+
if (description) {
|
|
147
|
+
asset.description = String(description);
|
|
148
|
+
}
|
|
149
|
+
if (codeType === "external" && codeValue) {
|
|
150
|
+
asset.title = codeValue;
|
|
151
|
+
}
|
|
152
|
+
Object.assign(previewerProps, frontmatter, restAttrs);
|
|
153
|
+
return {
|
|
154
|
+
id: asset.id,
|
|
155
|
+
component,
|
|
156
|
+
asset: techStack.generateMetadata ? await techStack.generateMetadata(asset) : asset,
|
|
157
|
+
sources
|
|
158
|
+
};
|
|
159
|
+
}));
|
|
160
|
+
demosPropData.push({
|
|
161
|
+
demo: { id: codeId },
|
|
162
|
+
previewerProps
|
|
78
163
|
});
|
|
79
164
|
}
|
|
165
|
+
});
|
|
166
|
+
replaceNodes.push(node);
|
|
167
|
+
node.children = [];
|
|
168
|
+
if (demosPropData.length === 1) {
|
|
80
169
|
node.tagName = "DumiDemo";
|
|
81
|
-
node.
|
|
82
|
-
node.
|
|
83
|
-
|
|
170
|
+
node.data[DEMO_PROP_VALUE_KEY] = demosPropData[0];
|
|
171
|
+
node.JSXAttributes = [{ type: "JSXSpreadAttribute", argument: "" }];
|
|
172
|
+
} else {
|
|
173
|
+
node.tagName = "DumiDemoGrid";
|
|
174
|
+
node.data[DEMO_PROP_VALUE_KEY] = demosPropData;
|
|
175
|
+
node.JSXAttributes = [
|
|
176
|
+
{ type: "JSXAttribute", name: "items", value: "" }
|
|
177
|
+
];
|
|
84
178
|
}
|
|
179
|
+
return SKIP;
|
|
85
180
|
}
|
|
86
181
|
});
|
|
87
|
-
|
|
182
|
+
await Promise.all(deferrers).then((demos) => {
|
|
183
|
+
vFile.data.demos = demos;
|
|
184
|
+
replaceNodes.forEach((node) => {
|
|
185
|
+
const value = JSON.stringify(node.data[DEMO_PROP_VALUE_KEY]);
|
|
186
|
+
if (node.JSXAttributes[0].type === "JSXAttribute") {
|
|
187
|
+
node.JSXAttributes[0].value = value;
|
|
188
|
+
} else {
|
|
189
|
+
node.JSXAttributes[0].argument = value;
|
|
190
|
+
}
|
|
191
|
+
delete node.data[DEMO_PROP_VALUE_KEY];
|
|
192
|
+
});
|
|
193
|
+
});
|
|
88
194
|
};
|
|
89
195
|
}
|
|
90
196
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -30,7 +30,7 @@ var visit;
|
|
|
30
30
|
({ visit } = await import("unist-util-visit"));
|
|
31
31
|
})();
|
|
32
32
|
function isDemoNode(node) {
|
|
33
|
-
return node.tagName
|
|
33
|
+
return ["DumiDemo", "DumiDemoGrid"].includes(node.tagName);
|
|
34
34
|
}
|
|
35
35
|
function rehypeIsolation() {
|
|
36
36
|
return (tree) => {
|
|
@@ -51,6 +51,7 @@ function rehypeJsxify() {
|
|
|
51
51
|
visitUnist(ast, "element", (node) => {
|
|
52
52
|
var _a;
|
|
53
53
|
(_a = node.JSXAttributes) == null ? void 0 : _a.forEach((attr, i) => {
|
|
54
|
+
node.properties ?? (node.properties = {});
|
|
54
55
|
if (attr.type === "JSXAttribute") {
|
|
55
56
|
node.properties[`${JSX_PROP_PREFIX}${attr.name}`] = attr.value;
|
|
56
57
|
} else if (attr.type === "JSXSpreadAttribute") {
|
package/dist/preset.js
CHANGED
|
@@ -33,7 +33,8 @@ var preset_default = (api) => {
|
|
|
33
33
|
require.resolve("./features/configPlugins"),
|
|
34
34
|
require.resolve("./features/compile"),
|
|
35
35
|
require.resolve("./features/routes"),
|
|
36
|
-
require.resolve("./features/theme")
|
|
36
|
+
require.resolve("./features/theme"),
|
|
37
|
+
require.resolve("./features/locales")
|
|
37
38
|
]
|
|
38
39
|
};
|
|
39
40
|
};
|
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { IThemeLoadResult } from "./features/theme/loader";
|
|
2
2
|
import type { IModify } from '@umijs/core';
|
|
3
|
+
import type { ExampleBlockAsset } from 'dumi-assets-types';
|
|
3
4
|
import type { Element } from 'hast';
|
|
4
5
|
import type { IApi as IUmiApi } from 'umi';
|
|
5
6
|
declare type IUmiConfig = IUmiApi['config'];
|
|
@@ -11,6 +12,11 @@ export interface IDumiConfig extends IUmiConfig {
|
|
|
11
12
|
dir: string;
|
|
12
13
|
}[];
|
|
13
14
|
};
|
|
15
|
+
locales: {
|
|
16
|
+
id: string;
|
|
17
|
+
name: string;
|
|
18
|
+
base?: string;
|
|
19
|
+
}[];
|
|
14
20
|
}
|
|
15
21
|
export declare abstract class IDumiTechStack {
|
|
16
22
|
/**
|
|
@@ -29,10 +35,9 @@ export declare abstract class IDumiTechStack {
|
|
|
29
35
|
fileAbsPath: string;
|
|
30
36
|
}): string;
|
|
31
37
|
/**
|
|
32
|
-
* generator for return
|
|
33
|
-
* TODO: real assets meta data types
|
|
38
|
+
* generator for return asset metadata
|
|
34
39
|
*/
|
|
35
|
-
abstract generateMetadata?():
|
|
40
|
+
abstract generateMetadata?(asset: ExampleBlockAsset): Promise<ExampleBlockAsset> | ExampleBlockAsset;
|
|
36
41
|
/**
|
|
37
42
|
* generator for return previewer props
|
|
38
43
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dumi",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.1",
|
|
4
4
|
"description": "Framework for developing UI components",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"license": "MIT",
|
|
@@ -12,7 +12,9 @@
|
|
|
12
12
|
"files": [
|
|
13
13
|
"bin",
|
|
14
14
|
"dist",
|
|
15
|
-
"compiled"
|
|
15
|
+
"compiled",
|
|
16
|
+
"theme-default",
|
|
17
|
+
"theme.d.ts"
|
|
16
18
|
],
|
|
17
19
|
"scripts": {
|
|
18
20
|
"build": "father build",
|
|
@@ -51,25 +53,34 @@
|
|
|
51
53
|
"@types/hast": "^2.3.4",
|
|
52
54
|
"@umijs/bundler-utils": "^4.0.9",
|
|
53
55
|
"@umijs/core": "^4.0.9",
|
|
56
|
+
"dumi-assets-types": "2.0.0-alpha.0",
|
|
54
57
|
"estree-util-to-js": "^1.1.0",
|
|
55
58
|
"estree-util-visit": "^1.2.0",
|
|
59
|
+
"hast-util-is-element": "^2.1.2",
|
|
56
60
|
"hast-util-raw": "^7.2.2",
|
|
57
61
|
"hast-util-to-estree": "^2.1.0",
|
|
62
|
+
"js-yaml": "^4.1.0",
|
|
58
63
|
"mdast-util-to-string": "^3.1.0",
|
|
59
64
|
"pluralize": "^8.0.0",
|
|
65
|
+
"raw-loader": "^4.0.2",
|
|
66
|
+
"react-intl": "^6.1.1",
|
|
67
|
+
"remark-breaks": "^3.0.2",
|
|
68
|
+
"remark-frontmatter": "^4.0.1",
|
|
60
69
|
"remark-gfm": "^3.0.1",
|
|
61
70
|
"remark-parse": "^10.0.1",
|
|
62
71
|
"remark-rehype": "^10.1.0",
|
|
63
72
|
"umi": "^4.0.9",
|
|
64
73
|
"unified": "^10.1.2",
|
|
65
74
|
"unist-util-visit": "^4.1.0",
|
|
66
|
-
"v8-compile-cache": "2.3.0"
|
|
75
|
+
"v8-compile-cache": "2.3.0",
|
|
76
|
+
"vfile": "^5.3.4"
|
|
67
77
|
},
|
|
68
78
|
"devDependencies": {
|
|
69
79
|
"@commitlint/cli": "^17.0.3",
|
|
70
80
|
"@commitlint/config-conventional": "^17.0.3",
|
|
71
81
|
"@jest/types": "^27.0.0",
|
|
72
82
|
"@types/jest": "^27.0.0",
|
|
83
|
+
"@types/js-yaml": "^4.0.5",
|
|
73
84
|
"@types/node": "^18.6.3",
|
|
74
85
|
"@types/pluralize": "^0.0.29",
|
|
75
86
|
"@types/react": "^18.0.16",
|
|
@@ -77,7 +88,7 @@
|
|
|
77
88
|
"@umijs/test": "^4.0.9",
|
|
78
89
|
"cross-env": "^7.0.3",
|
|
79
90
|
"eslint": "^8.20.0",
|
|
80
|
-
"father": "^4.0.
|
|
91
|
+
"father": "^4.0.3",
|
|
81
92
|
"husky": "^8.0.1",
|
|
82
93
|
"jest": "^27.0.0",
|
|
83
94
|
"lint-staged": "^13.0.3",
|
|
@@ -86,7 +97,12 @@
|
|
|
86
97
|
"prettier-plugin-packagejson": "^2.2.18",
|
|
87
98
|
"react": "^18.2.0",
|
|
88
99
|
"stylelint": "^14.9.1",
|
|
89
|
-
"ts-node": "^10.0.0"
|
|
100
|
+
"ts-node": "^10.0.0",
|
|
101
|
+
"typescript": "~4.7.4"
|
|
102
|
+
},
|
|
103
|
+
"peerDependencies": {
|
|
104
|
+
"react": ">=16.8",
|
|
105
|
+
"react-dom": ">=16.8"
|
|
90
106
|
},
|
|
91
107
|
"packageManager": "pnpm@7.3.0",
|
|
92
108
|
"publishConfig": {
|
package/theme.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './dist/client/theme-api';
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { createElement, useContext } from 'react';
|
|
2
|
-
import { Context } from "./context";
|
|
3
|
-
export var DumiDemo = function DumiDemo(props) {
|
|
4
|
-
var _useContext = useContext(Context),
|
|
5
|
-
demos = _useContext.demos;
|
|
6
|
-
|
|
7
|
-
var component = demos[props.id];
|
|
8
|
-
return /*#__PURE__*/createElement(component);
|
|
9
|
-
};
|