dumi 2.0.0-rc.7 → 2.0.0-rc.9
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/client/theme-api/DumiDemo.js +22 -2
- package/dist/client/theme-api/types.d.ts +4 -0
- package/dist/features/routes.js +18 -17
- package/dist/features/sitemap.d.ts +3 -0
- package/dist/features/sitemap.js +64 -0
- package/dist/loaders/markdown/index.js +1 -1
- package/dist/loaders/markdown/transformer/rehypeDemo.js +2 -1
- package/dist/loaders/markdown/transformer/rehypeSlug.js +2 -1
- package/dist/preset.js +2 -1
- package/package.json +8 -6
- package/theme-default/builtins/Container/index.less +32 -8
|
@@ -2,8 +2,24 @@ function _extends() { _extends = Object.assign ? Object.assign.bind() : function
|
|
|
2
2
|
|
|
3
3
|
import { SP_ROUTE_PREFIX } from "../../constants";
|
|
4
4
|
import { useSiteData } from 'dumi';
|
|
5
|
+
import Container from "dumi/theme/builtins/Container";
|
|
5
6
|
import Previewer from "dumi/theme/builtins/Previewer";
|
|
6
7
|
import React, { createElement } from 'react';
|
|
8
|
+
import { ErrorBoundary } from 'react-error-boundary';
|
|
9
|
+
|
|
10
|
+
var DemoErrorBoundary = function DemoErrorBoundary(props) {
|
|
11
|
+
return /*#__PURE__*/React.createElement(ErrorBoundary, {
|
|
12
|
+
fallbackRender: function fallbackRender(_ref) {
|
|
13
|
+
var error = _ref.error;
|
|
14
|
+
return /*#__PURE__*/React.createElement(Container, {
|
|
15
|
+
type: "error"
|
|
16
|
+
}, /*#__PURE__*/React.createElement("p", null, /*#__PURE__*/React.createElement("strong", null, error.message || 'This demo has been crashed.')), error.stack && /*#__PURE__*/React.createElement("p", null, /*#__PURE__*/React.createElement("details", {
|
|
17
|
+
open: true
|
|
18
|
+
}, /*#__PURE__*/React.createElement("summary", null, "Error stack"), /*#__PURE__*/React.createElement("pre", null, error.stack))));
|
|
19
|
+
}
|
|
20
|
+
}, props.children);
|
|
21
|
+
};
|
|
22
|
+
|
|
7
23
|
export var DumiDemo = function DumiDemo(props) {
|
|
8
24
|
var _useSiteData = useSiteData(),
|
|
9
25
|
demos = _useSiteData.demos;
|
|
@@ -11,10 +27,14 @@ export var DumiDemo = function DumiDemo(props) {
|
|
|
11
27
|
var _demos$props$demo$id = demos[props.demo.id],
|
|
12
28
|
component = _demos$props$demo$id.component,
|
|
13
29
|
asset = _demos$props$demo$id.asset;
|
|
14
|
-
|
|
30
|
+
|
|
31
|
+
if (props.demo.inline) {
|
|
32
|
+
return /*#__PURE__*/React.createElement(DemoErrorBoundary, null, /*#__PURE__*/createElement(component));
|
|
33
|
+
}
|
|
34
|
+
|
|
15
35
|
return /*#__PURE__*/React.createElement(Previewer, _extends({
|
|
16
36
|
asset: asset,
|
|
17
37
|
demoUrl: // allow user override demoUrl by frontmatter
|
|
18
38
|
props.previewerProps.demoUrl || "/".concat(SP_ROUTE_PREFIX, "demos/").concat(props.demo.id)
|
|
19
|
-
}, props.previewerProps), props.previewerProps.iframe ? null : /*#__PURE__*/createElement(component));
|
|
39
|
+
}, props.previewerProps), props.previewerProps.iframe ? null : /*#__PURE__*/React.createElement(DemoErrorBoundary, null, /*#__PURE__*/createElement(component)));
|
|
20
40
|
};
|
package/dist/features/routes.js
CHANGED
|
@@ -44,10 +44,10 @@ function localizeUmiRoute(route, locales) {
|
|
|
44
44
|
route.absPath = route.path !== "/" ? `/${route.path}` : route.path;
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
-
function flatRoute(route) {
|
|
48
|
-
if (route.parentId !==
|
|
49
|
-
route.parentId =
|
|
50
|
-
route.path = route.path === "*" ? route.path
|
|
47
|
+
function flatRoute(route, docLayoutId) {
|
|
48
|
+
if (route.parentId !== docLayoutId) {
|
|
49
|
+
route.parentId = docLayoutId;
|
|
50
|
+
route.path = route.path === "*" ? route.path : route.absPath.slice(1);
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
function getClientPageFile(file, cwd) {
|
|
@@ -121,8 +121,6 @@ var routes_default = (api) => {
|
|
|
121
121
|
}
|
|
122
122
|
Object.entries(pages).forEach(([, route]) => {
|
|
123
123
|
route.file = (0, import_plugin_utils.winPath)(import_path.default.resolve(api.config.conventionRoutes.base, route.file));
|
|
124
|
-
flatRoute(route);
|
|
125
|
-
localizeUmiRoute(route, api.config.locales);
|
|
126
124
|
routes[route.id] = route;
|
|
127
125
|
});
|
|
128
126
|
docDirs.map(normalizeDocDir).forEach(({ type, dir }) => {
|
|
@@ -133,14 +131,12 @@ var routes_default = (api) => {
|
|
|
133
131
|
});
|
|
134
132
|
Object.entries(dirRoutes).forEach(([key, route]) => {
|
|
135
133
|
route.id = `${dir}/${key}`;
|
|
136
|
-
flatRoute(route);
|
|
137
134
|
if (type) {
|
|
138
135
|
const pluralType = (0, import_pluralize.plural)(type);
|
|
139
136
|
route.path = `${pluralType}/${route.path}`.replace(/\/+$/, "/");
|
|
140
137
|
route.absPath = `/${route.path}`;
|
|
141
138
|
}
|
|
142
139
|
route.file = (0, import_plugin_utils.winPath)(import_path.default.resolve(base, route.file));
|
|
143
|
-
localizeUmiRoute(route, api.config.locales);
|
|
144
140
|
routes[route.id] = route;
|
|
145
141
|
});
|
|
146
142
|
});
|
|
@@ -148,8 +144,9 @@ var routes_default = (api) => {
|
|
|
148
144
|
const base = import_path.default.join(api.cwd, dir);
|
|
149
145
|
const atomFiles = import_plugin_utils.glob.sync("{*,*/index,*/index.*,*/README,*/README.*}.md", { cwd: base });
|
|
150
146
|
atomFiles.forEach((file) => {
|
|
151
|
-
const
|
|
152
|
-
const
|
|
147
|
+
const routeFile = (0, import_plugin_utils.winPath)(import_path.default.join((0, import_pluralize.plural)(type), file));
|
|
148
|
+
const routePath = routeFile.replace(/(\/index|\/README)?\.md$/, "").replace(/\./g, "/");
|
|
149
|
+
const routeId = (0, import_utils.createRouteId)(routeFile);
|
|
153
150
|
routes[routeId] = {
|
|
154
151
|
id: routeId,
|
|
155
152
|
path: routePath,
|
|
@@ -157,9 +154,19 @@ var routes_default = (api) => {
|
|
|
157
154
|
parentId: docLayoutId,
|
|
158
155
|
file: (0, import_plugin_utils.winPath)(import_path.default.resolve(base, file))
|
|
159
156
|
};
|
|
160
|
-
localizeUmiRoute(routes[routeId], api.config.locales);
|
|
161
157
|
});
|
|
162
158
|
});
|
|
159
|
+
Object.values(routes).forEach((route) => {
|
|
160
|
+
if (route.path !== encodeURI(route.path)) {
|
|
161
|
+
throw new Error(`Invalid route path: ${route.path}, please rename it with only alphanumeric, dash and slash.
|
|
162
|
+
at ${route.file}`);
|
|
163
|
+
} else if (!route.isLayout) {
|
|
164
|
+
flatRoute(route, docLayoutId);
|
|
165
|
+
localizeUmiRoute(route, api.config.locales);
|
|
166
|
+
route.path = route.path.toLowerCase();
|
|
167
|
+
route.absPath = route.absPath.toLowerCase();
|
|
168
|
+
}
|
|
169
|
+
});
|
|
163
170
|
if (Object.values(pages).every((route) => route.path !== "*")) {
|
|
164
171
|
routes["404"] = {
|
|
165
172
|
id: "404",
|
|
@@ -176,12 +183,6 @@ var routes_default = (api) => {
|
|
|
176
183
|
parentId: demoLayoutId,
|
|
177
184
|
file: getClientPageFile("client/pages/Demo", api.cwd)
|
|
178
185
|
};
|
|
179
|
-
Object.values(routes).forEach((route) => {
|
|
180
|
-
if (route.path !== encodeURI(route.path)) {
|
|
181
|
-
throw new Error(`Invalid route path: ${route.path}, please rename it with only alphanumeric, dash and slash.
|
|
182
|
-
at ${route.file}`);
|
|
183
|
-
}
|
|
184
|
-
});
|
|
185
186
|
return routes;
|
|
186
187
|
});
|
|
187
188
|
api.addLayouts(() => {
|
|
@@ -0,0 +1,64 @@
|
|
|
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/sitemap.ts
|
|
23
|
+
var sitemap_exports = {};
|
|
24
|
+
__export(sitemap_exports, {
|
|
25
|
+
default: () => sitemap_default
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(sitemap_exports);
|
|
28
|
+
var import_fs = __toESM(require("fs"));
|
|
29
|
+
var import_path = __toESM(require("path"));
|
|
30
|
+
var import_sitemap = require("sitemap");
|
|
31
|
+
var sitemap_default = (api) => {
|
|
32
|
+
api.describe({
|
|
33
|
+
key: "sitemap",
|
|
34
|
+
config: {
|
|
35
|
+
schema(joi) {
|
|
36
|
+
return joi.object({
|
|
37
|
+
hostname: joi.string().required(),
|
|
38
|
+
exclude: joi.array().items(joi.string())
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
enableBy: ({ userConfig, env }) => userConfig.sitemap && env === "production"
|
|
43
|
+
});
|
|
44
|
+
api.onBuildComplete(async () => {
|
|
45
|
+
const smis = new import_sitemap.SitemapStream({
|
|
46
|
+
hostname: api.config.sitemap.hostname,
|
|
47
|
+
xmlns: { video: false, image: false, news: false, xhtml: false }
|
|
48
|
+
});
|
|
49
|
+
const exclude = ["/404"].concat(api.config.sitemap.exclude);
|
|
50
|
+
const writeStream = import_fs.default.createWriteStream(import_path.default.join(api.paths.absOutputPath, "sitemap.xml"));
|
|
51
|
+
smis.pipe(writeStream);
|
|
52
|
+
Object.values(api.appData.routes).forEach((route) => {
|
|
53
|
+
if (!exclude.includes(route.path) && ![":", "*"].some((char) => route.path.includes(char))) {
|
|
54
|
+
smis.write({ url: route.path });
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
smis.end();
|
|
58
|
+
await new Promise((resolve) => {
|
|
59
|
+
writeStream.on("close", resolve);
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
64
|
+
0 && (module.exports = {});
|
|
@@ -121,7 +121,7 @@ function mdLoader(content) {
|
|
|
121
121
|
} else if (cacheKey in deferrer) {
|
|
122
122
|
deferrer[cacheKey].then((res) => {
|
|
123
123
|
cb(null, emit.call(this, opts, res));
|
|
124
|
-
});
|
|
124
|
+
}).catch(cb);
|
|
125
125
|
return;
|
|
126
126
|
}
|
|
127
127
|
deferrer[cacheKey] = (0, import_transformer.default)(content, {
|
|
@@ -139,9 +139,10 @@ function rehypeDemo(opts) {
|
|
|
139
139
|
const previewerProps = {};
|
|
140
140
|
let component = "";
|
|
141
141
|
if (codeType === "external") {
|
|
142
|
+
const chunkName = [vFile.data.frontmatter.atomId, "demos"].filter(Boolean).join("__");
|
|
142
143
|
parseOpts.fileAbsPath = codeNode.properties.src;
|
|
143
144
|
parseOpts.id = getCodeId(opts.cwd, opts.fileAbsPath, import_path.default.parse(parseOpts.fileAbsPath).name, vFile.data.frontmatter.atomId);
|
|
144
|
-
component = `React.lazy(() => import('${(0, import_plugin_utils.winPath)(parseOpts.fileAbsPath)}?techStack=${techStack.name}'))`;
|
|
145
|
+
component = `React.lazy(() => import( /* webpackChunkName: "${chunkName}" */ '${(0, import_plugin_utils.winPath)(parseOpts.fileAbsPath)}?techStack=${techStack.name}'))`;
|
|
145
146
|
codeNode.properties.title = codeValue || void 0;
|
|
146
147
|
(_a2 = codeNode.properties).filename ?? (_a2.filename = (0, import_plugin_utils.winPath)(import_path.default.relative(opts.cwd, parseOpts.fileAbsPath)));
|
|
147
148
|
} else {
|
|
@@ -59,7 +59,8 @@ function rehypeSlug() {
|
|
|
59
59
|
vFile.data.toc.push({
|
|
60
60
|
id: slugger.slug(demo.id),
|
|
61
61
|
depth: ((_b2 = (_a2 = vFile.data.frontmatter) == null ? void 0 : _a2.demo) == null ? void 0 : _b2.tocDepth) || 3,
|
|
62
|
-
title: previewerProps.title
|
|
62
|
+
title: previewerProps.title,
|
|
63
|
+
...previewerProps.debug ? { _debug_demo: true } : {}
|
|
63
64
|
});
|
|
64
65
|
}
|
|
65
66
|
});
|
package/dist/preset.js
CHANGED
|
@@ -56,7 +56,8 @@ var preset_default = (api) => {
|
|
|
56
56
|
require.resolve("./features/locales"),
|
|
57
57
|
require.resolve("./features/parser"),
|
|
58
58
|
require.resolve("./features/assets"),
|
|
59
|
-
require.resolve("./features/exportStatic")
|
|
59
|
+
require.resolve("./features/exportStatic"),
|
|
60
|
+
require.resolve("./features/sitemap")
|
|
60
61
|
]
|
|
61
62
|
};
|
|
62
63
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dumi",
|
|
3
|
-
"version": "2.0.0-rc.
|
|
3
|
+
"version": "2.0.0-rc.9",
|
|
4
4
|
"description": "Framework for developing UI components",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"license": "MIT",
|
|
@@ -57,8 +57,8 @@
|
|
|
57
57
|
"@swc/core": "^1.2.224",
|
|
58
58
|
"@types/hast": "^2.3.4",
|
|
59
59
|
"@types/mdast": "^3.0.10",
|
|
60
|
-
"@umijs/bundler-utils": "
|
|
61
|
-
"@umijs/core": "
|
|
60
|
+
"@umijs/bundler-utils": "4.0.0-canary.20221114.1",
|
|
61
|
+
"@umijs/core": "4.0.0-canary.20221114.1",
|
|
62
62
|
"codesandbox": "^2.2.3",
|
|
63
63
|
"deepmerge": "^4.2.2",
|
|
64
64
|
"dumi-afx-deps": "^1.0.0-alpha.1",
|
|
@@ -84,6 +84,7 @@
|
|
|
84
84
|
"raw-loader": "^4.0.2",
|
|
85
85
|
"rc-tabs": "12.1.0-alpha.1",
|
|
86
86
|
"react-copy-to-clipboard": "^5.1.0",
|
|
87
|
+
"react-error-boundary": "^3.1.4",
|
|
87
88
|
"react-helmet": "^6.1.0",
|
|
88
89
|
"react-intl": "^6.1.1",
|
|
89
90
|
"rehype-autolink-headings": "^6.1.1",
|
|
@@ -96,7 +97,8 @@
|
|
|
96
97
|
"remark-parse": "^10.0.1",
|
|
97
98
|
"remark-rehype": "^10.1.0",
|
|
98
99
|
"sass": "^1.55.0",
|
|
99
|
-
"
|
|
100
|
+
"sitemap": "^7.1.1",
|
|
101
|
+
"umi": "4.0.0-canary.20221114.1",
|
|
100
102
|
"unified": "^10.1.2",
|
|
101
103
|
"unist-util-visit": "^4.1.0",
|
|
102
104
|
"unist-util-visit-parents": "^5.1.1",
|
|
@@ -116,8 +118,8 @@
|
|
|
116
118
|
"@types/react": "^18.0.16",
|
|
117
119
|
"@types/react-copy-to-clipboard": "^5.0.4",
|
|
118
120
|
"@types/react-helmet": "^6.1.5",
|
|
119
|
-
"@umijs/lint": "
|
|
120
|
-
"@umijs/plugins": "
|
|
121
|
+
"@umijs/lint": "4.0.0-canary.20221114.1",
|
|
122
|
+
"@umijs/plugins": "4.0.0-canary.20221114.1",
|
|
121
123
|
"eslint": "^8.20.0",
|
|
122
124
|
"father": "^4.1.0",
|
|
123
125
|
"husky": "^8.0.1",
|
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
@import (reference) '../../styles/variables.less';
|
|
2
2
|
|
|
3
|
-
.@{prefix}-container {
|
|
4
|
-
margin: 24px 0 32px;
|
|
3
|
+
.@{prefix}-container.markdown {
|
|
5
4
|
padding: 18px 16px 18px 44px;
|
|
6
5
|
border-radius: 4px;
|
|
7
6
|
|
|
7
|
+
&:not(:first-child) {
|
|
8
|
+
margin-top: 24px;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
&:not(:last-child) {
|
|
12
|
+
margin-top: 32px;
|
|
13
|
+
}
|
|
14
|
+
|
|
8
15
|
> svg {
|
|
9
16
|
float: left;
|
|
10
17
|
fill: currentcolor;
|
|
@@ -13,9 +20,10 @@
|
|
|
13
20
|
}
|
|
14
21
|
|
|
15
22
|
> h4 {
|
|
16
|
-
|
|
23
|
+
clear: none;
|
|
24
|
+
margin: 0;
|
|
17
25
|
font-size: 15px;
|
|
18
|
-
line-height:
|
|
26
|
+
line-height: 17px;
|
|
19
27
|
}
|
|
20
28
|
|
|
21
29
|
> p {
|
|
@@ -27,9 +35,13 @@
|
|
|
27
35
|
&[data-type='info'] {
|
|
28
36
|
@color: darken(desaturate(@c-primary, 45%), 10%);
|
|
29
37
|
|
|
30
|
-
color: @color;
|
|
31
38
|
background: lighten(@c-primary, 42%);
|
|
32
39
|
|
|
40
|
+
> h4,
|
|
41
|
+
> svg {
|
|
42
|
+
color: @color;
|
|
43
|
+
}
|
|
44
|
+
|
|
33
45
|
> p {
|
|
34
46
|
color: desaturate(@color, 20%);
|
|
35
47
|
}
|
|
@@ -38,9 +50,13 @@
|
|
|
38
50
|
&[data-type='warning'] {
|
|
39
51
|
@color: darken(desaturate(@c-warning, 20%), 2%);
|
|
40
52
|
|
|
41
|
-
color: @color;
|
|
42
53
|
background: lighten(@c-warning, 51%);
|
|
43
54
|
|
|
55
|
+
> h4,
|
|
56
|
+
> svg {
|
|
57
|
+
color: @color;
|
|
58
|
+
}
|
|
59
|
+
|
|
44
60
|
> p {
|
|
45
61
|
color: desaturate(@color, 24%);
|
|
46
62
|
}
|
|
@@ -49,9 +65,13 @@
|
|
|
49
65
|
&[data-type='success'] {
|
|
50
66
|
@color: darken(desaturate(@c-success, 5%), 1%);
|
|
51
67
|
|
|
52
|
-
color: @color;
|
|
53
68
|
background: lighten(@c-success, 59%);
|
|
54
69
|
|
|
70
|
+
> h4,
|
|
71
|
+
> svg {
|
|
72
|
+
color: @color;
|
|
73
|
+
}
|
|
74
|
+
|
|
55
75
|
> p {
|
|
56
76
|
color: desaturate(@color, 22%);
|
|
57
77
|
}
|
|
@@ -60,9 +80,13 @@
|
|
|
60
80
|
&[data-type='error'] {
|
|
61
81
|
@color: darken(desaturate(@c-error, 20%), 1%);
|
|
62
82
|
|
|
63
|
-
color: @color;
|
|
64
83
|
background: lighten(@c-error, 51%);
|
|
65
84
|
|
|
85
|
+
> h4,
|
|
86
|
+
> svg {
|
|
87
|
+
color: @color;
|
|
88
|
+
}
|
|
89
|
+
|
|
66
90
|
> p {
|
|
67
91
|
color: desaturate(@color, 25%);
|
|
68
92
|
}
|