dumi 1.1.45 → 2.0.0-alpha.0
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/README.md +9 -167
- package/bin/dumi.js +3 -1
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +30 -0
- package/dist/client/theme/DumiDemo.d.ts +4 -0
- package/dist/client/theme/DumiDemo.js +9 -0
- package/dist/client/theme/context.d.ts +5 -0
- package/dist/client/theme/context.js +4 -0
- package/dist/client/theme/index.d.ts +2 -0
- package/dist/client/theme/index.js +2 -0
- package/dist/constants.d.ts +2 -0
- package/dist/constants.js +32 -0
- package/dist/features/compile.d.ts +3 -0
- package/dist/features/compile.js +56 -0
- package/dist/features/configPlugins/index.d.ts +3 -0
- package/dist/features/configPlugins/index.js +51 -0
- package/dist/features/configPlugins/schema.d.ts +4 -0
- package/dist/features/configPlugins/schema.js +36 -0
- package/dist/features/routes.d.ts +3 -0
- package/dist/features/routes.js +112 -0
- package/dist/features/theme/index.d.ts +3 -0
- package/dist/features/theme/index.js +143 -0
- package/dist/features/theme/loader.d.ts +51 -0
- package/dist/features/theme/loader.js +58 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +27 -0
- package/dist/loaders/demo/index.d.ts +6 -0
- package/dist/loaders/demo/index.js +35 -0
- package/dist/loaders/markdown/index.d.ts +12 -0
- package/dist/loaders/markdown/index.js +60 -0
- package/dist/loaders/markdown/transformer/index.d.ts +37 -0
- package/dist/loaders/markdown/transformer/index.js +49 -0
- package/dist/loaders/markdown/transformer/rehypeDemo.d.ts +6 -0
- package/dist/loaders/markdown/transformer/rehypeDemo.js +91 -0
- package/dist/loaders/markdown/transformer/rehypeIsolation.d.ts +3 -0
- package/dist/loaders/markdown/transformer/rehypeIsolation.js +60 -0
- package/dist/loaders/markdown/transformer/rehypeJsxify.d.ts +2 -0
- package/dist/loaders/markdown/transformer/rehypeJsxify.js +92 -0
- package/dist/loaders/markdown/transformer/rehypeRaw.d.ts +3 -0
- package/dist/loaders/markdown/transformer/rehypeRaw.js +58 -0
- package/dist/loaders/markdown/transformer/rehypeStrip.d.ts +3 -0
- package/dist/loaders/markdown/transformer/rehypeStrip.js +44 -0
- package/dist/preset.d.ts +5 -0
- package/dist/preset.js +41 -0
- package/dist/registerMethods.d.ts +3 -0
- package/dist/registerMethods.js +32 -0
- package/dist/techStacks/react.d.ts +6 -0
- package/dist/techStacks/react.js +79 -0
- package/dist/types.d.ts +56 -0
- package/dist/types.js +30 -0
- package/dist/utils.d.ts +4 -0
- package/dist/utils.js +32 -0
- package/package.json +89 -23
- package/index.d.ts +0 -1
- package/index.js +0 -3
- package/lib/index.js +0 -32
- package/theme.d.ts +0 -2
package/README.md
CHANGED
|
@@ -1,178 +1,20 @@
|
|
|
1
1
|
# dumi
|
|
2
2
|
|
|
3
|
-
[](https://github.com/actions-cool/issues-helper)
|
|
3
|
+
[](https://npmjs.org/package/dumi) [](https://npmjs.org/package/dumi)
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
The development version for dumi 2, if you are looking for dumi 1, please switch to the [1.x branch](https://github.com/umijs/dumi/tree/1.x).
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
### Features
|
|
11
|
-
|
|
12
|
-
- 📦 Out of the box, focus on component development and documentation
|
|
13
|
-
- 📋 Rich Markdown extensions, more than just rendering component demo
|
|
14
|
-
- 🏷 Automatically generate component API based on TypeScript type definition
|
|
15
|
-
- 🎨 Easily customize the theme, and create your own Markdown components
|
|
16
|
-
- 📱 Support mobile component library development, built-in mobile HD rendering solution
|
|
17
|
-
- 📡 One-line command digitizes component assets and connects them with downstream productivity tools
|
|
18
|
-
|
|
19
|
-
## Usage & Guide
|
|
20
|
-
|
|
21
|
-
To view more online examples and docs, please visit [dumi official site](https://d.umijs.org).
|
|
22
|
-
|
|
23
|
-
## Development
|
|
7
|
+
## Install
|
|
24
8
|
|
|
25
9
|
```bash
|
|
26
|
-
$
|
|
27
|
-
$ yarn watch
|
|
28
|
-
$ yarn dev
|
|
10
|
+
$ pnpm install
|
|
29
11
|
```
|
|
30
12
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
<tr>
|
|
36
|
-
<td width="160" align="center">
|
|
37
|
-
<a target="_blank" href="https://ahooks.js.org/">
|
|
38
|
-
<img src="https://ahooks.js.org/logo.svg" />
|
|
39
|
-
<br />
|
|
40
|
-
<strong>ahooks</strong>
|
|
41
|
-
</a>
|
|
42
|
-
</td>
|
|
43
|
-
<td width="160" align="center">
|
|
44
|
-
<a target="_blank" href="https://alitajs.com/">
|
|
45
|
-
<img src="https://user-images.githubusercontent.com/11746742/104428726-c2c90300-55bf-11eb-9b84-d52a86050b9a.png" width="42" />
|
|
46
|
-
<br />
|
|
47
|
-
<strong>alitajs</strong>
|
|
48
|
-
</a>
|
|
49
|
-
</td>
|
|
50
|
-
<td width="160" align="center">
|
|
51
|
-
<a target="_blank" href="https://boyuai.github.io/antd-country-phone-input/">
|
|
52
|
-
<img src="https://staticcdn.boyuai.com/user-assets/6074/vF5on4266Geu54q8dM7mEU/Lark20200122-235918.svg" width="42" />
|
|
53
|
-
<br />
|
|
54
|
-
<strong>antd-cpi</strong>
|
|
55
|
-
</a>
|
|
56
|
-
</td>
|
|
57
|
-
<td width="160" align="center">
|
|
58
|
-
<a target="_blank" href="https://github.com/H5-Dooring/dooringx">
|
|
59
|
-
<img src="https://img-blog.csdnimg.cn/img_convert/520863a38a93d960862f92c805bc97cc.png" />
|
|
60
|
-
<br />
|
|
61
|
-
<strong>Dooringx</strong>
|
|
62
|
-
</a>
|
|
63
|
-
</td>
|
|
64
|
-
<td width="160" align="center">
|
|
65
|
-
<a target="_blank" href="https://v2.formilyjs.org/">
|
|
66
|
-
<img src="https://img.alicdn.com/imgextra/i2/O1CN01Kq3OHU1fph6LGqjIz_!!6000000004056-55-tps-1141-150.svg" />
|
|
67
|
-
<br />
|
|
68
|
-
<strong>Formily</strong>
|
|
69
|
-
</a>
|
|
70
|
-
</td>
|
|
71
|
-
</tr>
|
|
72
|
-
<tr>
|
|
73
|
-
<td width="160" align="center">
|
|
74
|
-
<a target="_blank" href="https://ggeditor.com">
|
|
75
|
-
<img src="https://img.alicdn.com/tfs/TB1FFA1CFP7gK0jSZFjXXc5aXXa-214-200.png" width="42" />
|
|
76
|
-
<br />
|
|
77
|
-
<strong>GGEditor</strong>
|
|
78
|
-
</a>
|
|
79
|
-
</td>
|
|
80
|
-
<td width="160" align="center">
|
|
81
|
-
<a target="_blank" href="https://graphin.antv.vision/">
|
|
82
|
-
<img src="https://gw.alipayobjects.com/zos/antfincdn/0b4HzOcEJY/Graphin.svg" width="42" />
|
|
83
|
-
<br />
|
|
84
|
-
<strong>Graphin</strong>
|
|
85
|
-
</a>
|
|
86
|
-
</td>
|
|
87
|
-
<td width="160" align="center">
|
|
88
|
-
<a target="_blank" href="https://actions-cool.github.io/issues-helper/">
|
|
89
|
-
<img src="https://avatars1.githubusercontent.com/u/73879334?s=200&v=4" width="42" />
|
|
90
|
-
<br />
|
|
91
|
-
<strong>issues-helper</strong>
|
|
92
|
-
</a>
|
|
93
|
-
</td>
|
|
94
|
-
<td width="160" align="center">
|
|
95
|
-
<a target="_blank" href="https://lightproxy.org">
|
|
96
|
-
<img src="https://user-images.githubusercontent.com/5436704/81533849-83e00f00-9399-11ea-943d-ac5fd4653906.png" width="42" />
|
|
97
|
-
<br />
|
|
98
|
-
<strong>LightProxy</strong>
|
|
99
|
-
</a>
|
|
100
|
-
</td>
|
|
101
|
-
<td width="160" align="center">
|
|
102
|
-
<a target="_blank" href="https://pinyin.js.org/">
|
|
103
|
-
<img src="https://gw.alipayobjects.com/mdn/rms_f6322a/afts/img/A*bGz9QbNudekAAAAAAAAAAAAAARQnAQ" width="42" />
|
|
104
|
-
<br />
|
|
105
|
-
<strong>pīnyīn</strong>
|
|
106
|
-
</a>
|
|
107
|
-
</td>
|
|
108
|
-
</tr>
|
|
109
|
-
<tr>
|
|
110
|
-
<td width="160" align="center">
|
|
111
|
-
<a target="_blank" href="https://procomponents.ant.design/">
|
|
112
|
-
<img src="https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg" width="42" />
|
|
113
|
-
<br />
|
|
114
|
-
<strong>Pro Components</strong>
|
|
115
|
-
</a>
|
|
116
|
-
</td>
|
|
117
|
-
<td width="160" align="center">
|
|
118
|
-
<a target="_blank" href="https://qiankun.umijs.org/">
|
|
119
|
-
<img src="https://gw.alipayobjects.com/zos/bmw-prod/8a74c1d3-16f3-4719-be63-15e467a68a24/km0cv8vn_w500_h500.png" width="42" />
|
|
120
|
-
<br />
|
|
121
|
-
<strong>qiankun</strong>
|
|
122
|
-
</a>
|
|
123
|
-
</td>
|
|
124
|
-
<td width="160" align="center">
|
|
125
|
-
<a target="_blank" href="https://github.com/react-component">
|
|
126
|
-
<img src="https://avatars3.githubusercontent.com/u/9441414?s=200&v=4" width="42" />
|
|
127
|
-
<br />
|
|
128
|
-
<strong>react-component</strong>
|
|
129
|
-
</a>
|
|
130
|
-
</td>
|
|
131
|
-
<td width="160" align="center">
|
|
132
|
-
<a target="_blank" href="https://remaxjs.org">
|
|
133
|
-
<img src="https://gw.alipayobjects.com/mdn/rms_b5fcc5/afts/img/A*1NHAQYduQiQAAAAAAAAAAABkARQnAQ" width="42" />
|
|
134
|
-
<br />
|
|
135
|
-
<strong>Remax</strong>
|
|
136
|
-
</a>
|
|
137
|
-
</td>
|
|
138
|
-
<td width="160" align="center">
|
|
139
|
-
<a target="_blank" href="https://umijs.org">
|
|
140
|
-
<img src="https://gw.alipayobjects.com/zos/bmw-prod/598d14af-4f1c-497d-b579-5ac42cd4dd1f/k7bjua9c_w132_h130.png" width="42" />
|
|
141
|
-
<br />
|
|
142
|
-
<strong>UmiJS</strong>
|
|
143
|
-
</a>
|
|
144
|
-
</td>
|
|
145
|
-
</tr>
|
|
146
|
-
<tr>
|
|
147
|
-
<td width="160" align="center">
|
|
148
|
-
<a target="_blank" href="https://x-render.gitee.io/">
|
|
149
|
-
<img src="https://img.alicdn.com/tfs/TB17UtINiLaK1RjSZFxXXamPFXa-606-643.png" width="42" />
|
|
150
|
-
<br />
|
|
151
|
-
<strong>XRender</strong>
|
|
152
|
-
</a>
|
|
153
|
-
</td>
|
|
154
|
-
<td width="160" align="center">
|
|
155
|
-
</td>
|
|
156
|
-
<td width="160" align="center">
|
|
157
|
-
</td>
|
|
158
|
-
<td width="160" align="center">
|
|
159
|
-
</td>
|
|
160
|
-
<td width="160" align="center">
|
|
161
|
-
</td>
|
|
162
|
-
</tr>
|
|
163
|
-
</table>
|
|
164
|
-
|
|
165
|
-
### README Badge
|
|
166
|
-
|
|
167
|
-
Using dumi ? Add a README badge to show it off: [](https://github.com/umijs/dumi)
|
|
168
|
-
|
|
169
|
-
```
|
|
170
|
-
[](https://github.com/umijs/dumi)
|
|
13
|
+
```bash
|
|
14
|
+
$ npm run dev
|
|
15
|
+
$ npm run build
|
|
171
16
|
```
|
|
172
17
|
|
|
173
|
-
##
|
|
18
|
+
## LICENSE
|
|
174
19
|
|
|
175
|
-
|
|
176
|
-
<img data-type="dingtalk" src="https://gw.alipayobjects.com/zos/bmw-prod/ce3439e7-3bf9-4031-b823-6473439ec9e6/kxkiis4c_w1004_h1346.jpeg" width="300" />
|
|
177
|
-
<img data-type="wechat" src="https://gw.alipayobjects.com/zos/bmw-prod/c18bc2a5-719a-48ca-b225-c79ef88bfb43/k7m10ymd_w1004_h1346.jpeg" width="300" />
|
|
178
|
-
</div>
|
|
20
|
+
MIT
|
package/bin/dumi.js
CHANGED
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
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 __copyProps = (to, from, except, desc) => {
|
|
8
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
9
|
+
for (let key of __getOwnPropNames(from))
|
|
10
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
11
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
12
|
+
}
|
|
13
|
+
return to;
|
|
14
|
+
};
|
|
15
|
+
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));
|
|
16
|
+
|
|
17
|
+
// src/cli.ts
|
|
18
|
+
var import_umi = require("umi");
|
|
19
|
+
var import_plugin_utils = require("umi/plugin-utils");
|
|
20
|
+
(async () => {
|
|
21
|
+
try {
|
|
22
|
+
import_plugin_utils.logger.info(import_plugin_utils.chalk.cyan.bold(`dumi v${require("../package").version}`));
|
|
23
|
+
await (0, import_umi.run)({
|
|
24
|
+
presets: [require.resolve("./preset")]
|
|
25
|
+
});
|
|
26
|
+
} catch (e) {
|
|
27
|
+
console.error(e);
|
|
28
|
+
process.exit(1);
|
|
29
|
+
}
|
|
30
|
+
})();
|
|
@@ -0,0 +1,9 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
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/constants.ts
|
|
20
|
+
var constants_exports = {};
|
|
21
|
+
__export(constants_exports, {
|
|
22
|
+
LOCAL_THEME_DIR: () => LOCAL_THEME_DIR,
|
|
23
|
+
THEME_PREFIX: () => THEME_PREFIX
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(constants_exports);
|
|
26
|
+
var LOCAL_THEME_DIR = ".dumi/theme";
|
|
27
|
+
var THEME_PREFIX = "dumi-theme-";
|
|
28
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
29
|
+
0 && (module.exports = {
|
|
30
|
+
LOCAL_THEME_DIR,
|
|
31
|
+
THEME_PREFIX
|
|
32
|
+
});
|
|
@@ -0,0 +1,56 @@
|
|
|
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/features/compile.ts
|
|
23
|
+
var compile_exports = {};
|
|
24
|
+
__export(compile_exports, {
|
|
25
|
+
default: () => compile_default
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(compile_exports);
|
|
28
|
+
var import_react = __toESM(require("../techStacks/react"));
|
|
29
|
+
var compile_default = (api) => {
|
|
30
|
+
api.registerTechStack(() => new import_react.default());
|
|
31
|
+
api.chainWebpack(async (memo) => {
|
|
32
|
+
const loaderPath = require.resolve("../loaders/markdown");
|
|
33
|
+
const babelInUmi = memo.module.rule("src").use("babel-loader").entries();
|
|
34
|
+
const techStacks = await api.applyPlugins({
|
|
35
|
+
key: "registerTechStack",
|
|
36
|
+
type: api.ApplyPluginsType.add
|
|
37
|
+
});
|
|
38
|
+
memo.module.rule("dumi-md").type("javascript/auto").test(/\.md$/).oneOf("demo-index").resourceQuery(/meta\.demos/).use("demo-index-loader").loader(loaderPath).options({ techStacks, cwd: api.cwd, mode: "demos" }).end().end().oneOf("md").use("babel-loader").loader(babelInUmi.loader).options(babelInUmi.options).end().use("md-loader").loader(loaderPath).options({
|
|
39
|
+
techStacks,
|
|
40
|
+
cwd: api.cwd,
|
|
41
|
+
builtins: api.service.themeData.builtins
|
|
42
|
+
});
|
|
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
|
+
if (api.env === "development") {
|
|
45
|
+
memo.plugin("fastRefresh").tap(([params]) => [
|
|
46
|
+
{
|
|
47
|
+
...params,
|
|
48
|
+
include: /\.([cm]js|[jt]sx?|flow|md)$/i
|
|
49
|
+
}
|
|
50
|
+
]);
|
|
51
|
+
}
|
|
52
|
+
return memo;
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
56
|
+
0 && (module.exports = {});
|
|
@@ -0,0 +1,51 @@
|
|
|
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/configPlugins/index.ts
|
|
20
|
+
var configPlugins_exports = {};
|
|
21
|
+
__export(configPlugins_exports, {
|
|
22
|
+
default: () => configPlugins_default
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(configPlugins_exports);
|
|
25
|
+
var import_schema = require("./schema");
|
|
26
|
+
var configPlugins_default = (api) => {
|
|
27
|
+
const configDefaults = {
|
|
28
|
+
resolve: {
|
|
29
|
+
docDirs: ["docs"],
|
|
30
|
+
entityDirs: [{ type: "component", dir: "src" }]
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
const schemas = (0, import_schema.getSchemas)();
|
|
34
|
+
for (const key of Object.keys(schemas)) {
|
|
35
|
+
const config = {
|
|
36
|
+
schema: schemas[key] || ((joi) => joi.any())
|
|
37
|
+
};
|
|
38
|
+
if (key in configDefaults) {
|
|
39
|
+
config.default = configDefaults[key];
|
|
40
|
+
}
|
|
41
|
+
api.registerPlugins([
|
|
42
|
+
{
|
|
43
|
+
id: `virtual: config-${key}`,
|
|
44
|
+
key,
|
|
45
|
+
config
|
|
46
|
+
}
|
|
47
|
+
]);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
51
|
+
0 && (module.exports = {});
|
|
@@ -0,0 +1,36 @@
|
|
|
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/configPlugins/schema.ts
|
|
20
|
+
var schema_exports = {};
|
|
21
|
+
__export(schema_exports, {
|
|
22
|
+
getSchemas: () => getSchemas
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(schema_exports);
|
|
25
|
+
function getSchemas() {
|
|
26
|
+
return {
|
|
27
|
+
resolve: (Joi) => Joi.object({
|
|
28
|
+
docDirs: Joi.array().items(Joi.string()).optional(),
|
|
29
|
+
entityDirs: Joi.array().items(Joi.object({ type: Joi.string(), dir: Joi.string() })).optional()
|
|
30
|
+
}).optional()
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
34
|
+
0 && (module.exports = {
|
|
35
|
+
getSchemas
|
|
36
|
+
});
|
|
@@ -0,0 +1,112 @@
|
|
|
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/features/routes.ts
|
|
23
|
+
var routes_exports = {};
|
|
24
|
+
__export(routes_exports, {
|
|
25
|
+
default: () => routes_default
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(routes_exports);
|
|
28
|
+
var import_core = require("@umijs/core");
|
|
29
|
+
var import_path = __toESM(require("path"));
|
|
30
|
+
var import_pluralize = require("pluralize");
|
|
31
|
+
var import_plugin_utils = require("umi/plugin-utils");
|
|
32
|
+
var CTX_LAYOUT_ID = "dumi-context-layout";
|
|
33
|
+
var routes_default = (api) => {
|
|
34
|
+
api.describe({ key: "dumi:routes" });
|
|
35
|
+
api.modifyConfig((memo) => {
|
|
36
|
+
memo.conventionRoutes = {
|
|
37
|
+
base: import_path.default.join(__dirname, "dumi-disable-default-routes")
|
|
38
|
+
};
|
|
39
|
+
return memo;
|
|
40
|
+
});
|
|
41
|
+
api.modifyRoutes((oRoutes) => {
|
|
42
|
+
const routes = Object.values(oRoutes).reduce((ret, route) => {
|
|
43
|
+
if (route.isLayout) {
|
|
44
|
+
ret[route.id] = route;
|
|
45
|
+
}
|
|
46
|
+
return ret;
|
|
47
|
+
}, {});
|
|
48
|
+
const { DocLayout } = api.service.themeData.layouts;
|
|
49
|
+
const { docDirs, entityDirs } = api.config.resolve;
|
|
50
|
+
const layoutRouteValues = Object.values(routes);
|
|
51
|
+
const lastLayoutId = layoutRouteValues.find(({ id }) => layoutRouteValues.every(({ parentId }) => id !== parentId)).id;
|
|
52
|
+
let docLayoutId = lastLayoutId;
|
|
53
|
+
if (DocLayout) {
|
|
54
|
+
docLayoutId = DocLayout.specifier;
|
|
55
|
+
routes[DocLayout.specifier] = {
|
|
56
|
+
id: DocLayout.specifier,
|
|
57
|
+
path: "/",
|
|
58
|
+
file: DocLayout.source,
|
|
59
|
+
parentId: lastLayoutId,
|
|
60
|
+
absPath: "/",
|
|
61
|
+
isLayout: true
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
docDirs.forEach((dir) => {
|
|
65
|
+
const base = import_path.default.join(api.cwd, dir);
|
|
66
|
+
const dirRoutes = (0, import_core.getConventionRoutes)({
|
|
67
|
+
base,
|
|
68
|
+
exclude: [/.*(?<!md)$/]
|
|
69
|
+
});
|
|
70
|
+
Object.entries(dirRoutes).forEach(([key, route]) => {
|
|
71
|
+
route.id = `${dir}/${key}`;
|
|
72
|
+
route.parentId = docLayoutId;
|
|
73
|
+
route.file = import_path.default.resolve(base, route.file);
|
|
74
|
+
routes[route.id] = route;
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
entityDirs.forEach(({ type, dir }) => {
|
|
78
|
+
const base = import_path.default.join(api.cwd, dir);
|
|
79
|
+
const entityFiles = import_plugin_utils.glob.sync("{*,*/index,*/README}.md", { cwd: base });
|
|
80
|
+
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$/, "");
|
|
82
|
+
const routeId = `${dir}/${routePath}`;
|
|
83
|
+
routes[routeId] = {
|
|
84
|
+
id: routeId,
|
|
85
|
+
path: routePath,
|
|
86
|
+
absPath: routePath,
|
|
87
|
+
parentId: docLayoutId,
|
|
88
|
+
file: import_path.default.resolve(base, file)
|
|
89
|
+
};
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
return routes;
|
|
93
|
+
});
|
|
94
|
+
api.addLayouts(() => {
|
|
95
|
+
const layouts = [
|
|
96
|
+
{
|
|
97
|
+
id: CTX_LAYOUT_ID,
|
|
98
|
+
file: "@/.umi/dumi/theme/ContextWrapper.tsx"
|
|
99
|
+
}
|
|
100
|
+
];
|
|
101
|
+
const { GlobalLayout } = api.service.themeData.layouts;
|
|
102
|
+
if (GlobalLayout) {
|
|
103
|
+
layouts.unshift({
|
|
104
|
+
id: GlobalLayout.specifier,
|
|
105
|
+
file: GlobalLayout.source
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
return layouts;
|
|
109
|
+
});
|
|
110
|
+
};
|
|
111
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
112
|
+
0 && (module.exports = {});
|