dumi 2.1.2 → 2.1.3
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/atom.js +2 -1
- package/dist/client/theme-api/types.d.ts +9 -4
- package/dist/features/derivative.js +6 -3
- package/dist/features/meta.js +12 -6
- package/dist/features/routes.js +5 -1
- package/package.json +1 -1
- package/theme-default/slots/ColorSwitch/index.js +9 -14
- package/theme-default/slots/PreviewerActions/index.js +1 -1
|
@@ -48,7 +48,8 @@ var AtomAssetsParser = class {
|
|
|
48
48
|
async parse() {
|
|
49
49
|
if (!this.parseDeferrer || this.unresolvedFiles.length) {
|
|
50
50
|
this.parseDeferrer = (async () => {
|
|
51
|
-
|
|
51
|
+
this.unresolvedFiles.splice(0);
|
|
52
|
+
await this.parser.patch([]);
|
|
52
53
|
const resolver = new import_parser.SchemaResolver(await this.parser.parse());
|
|
53
54
|
const result = {
|
|
54
55
|
components: {},
|
|
@@ -21,6 +21,10 @@ export interface IPreviewerProps {
|
|
|
21
21
|
* debug mark (will only render in dev by default)
|
|
22
22
|
*/
|
|
23
23
|
debug?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* display the source code or not by default
|
|
26
|
+
*/
|
|
27
|
+
defaultShowCode?: boolean;
|
|
24
28
|
/**
|
|
25
29
|
* url for render current demo in a single page
|
|
26
30
|
*/
|
|
@@ -85,6 +89,7 @@ export interface IRouteMeta {
|
|
|
85
89
|
};
|
|
86
90
|
atomId?: string;
|
|
87
91
|
filename?: string;
|
|
92
|
+
debug?: boolean;
|
|
88
93
|
[key: string]: any;
|
|
89
94
|
};
|
|
90
95
|
toc: {
|
|
@@ -138,15 +143,15 @@ export declare type ILocalesConfig = ILocale[];
|
|
|
138
143
|
export interface INavItem {
|
|
139
144
|
title: string;
|
|
140
145
|
link: string;
|
|
141
|
-
order
|
|
146
|
+
order?: number;
|
|
142
147
|
activePath?: string;
|
|
143
148
|
[key: string]: any;
|
|
144
149
|
}
|
|
145
150
|
export interface ISidebarItem {
|
|
146
151
|
title: string;
|
|
147
152
|
link: string;
|
|
148
|
-
order
|
|
149
|
-
frontmatter
|
|
153
|
+
order?: number;
|
|
154
|
+
frontmatter?: IRouteMeta['frontmatter'];
|
|
150
155
|
[key: string]: any;
|
|
151
156
|
}
|
|
152
157
|
export interface ISidebarGroup {
|
|
@@ -163,7 +168,7 @@ export interface IThemeConfig {
|
|
|
163
168
|
children?: INavItem[];
|
|
164
169
|
})[]>;
|
|
165
170
|
sidebar?: Record<string, ISidebarGroup[]>;
|
|
166
|
-
footer?: string;
|
|
171
|
+
footer?: string | false;
|
|
167
172
|
prefersColor: {
|
|
168
173
|
default: 'light' | 'dark' | 'auto';
|
|
169
174
|
switch: boolean;
|
|
@@ -47,7 +47,7 @@ function safeExcludeInMFSU(api, excludes) {
|
|
|
47
47
|
var derivative_default = (api) => {
|
|
48
48
|
api.describe({ key: "dumi:derivative" });
|
|
49
49
|
api.onCheck(() => {
|
|
50
|
-
var _a, _b;
|
|
50
|
+
var _a, _b, _c;
|
|
51
51
|
(0, import_assert.default)(!api.config.mpa, "MPA mode is not supported in dumi!");
|
|
52
52
|
(0, import_assert.default)(!api.config.vite, "Vite mode is not supported yet!");
|
|
53
53
|
if (typeof api.config.mfsu === "object") {
|
|
@@ -61,12 +61,15 @@ var derivative_default = (api) => {
|
|
|
61
61
|
}
|
|
62
62
|
try {
|
|
63
63
|
const tsconfig = require(import_path.default.join(api.cwd, "tsconfig.json"));
|
|
64
|
-
const expected = [".dumi/**/*"
|
|
64
|
+
const expected = [".dumi/**/*"];
|
|
65
|
+
if ((_c = api.service.configManager) == null ? void 0 : _c.mainConfigFile) {
|
|
66
|
+
expected.push((0, import_plugin_utils.winPath)(import_path.default.relative(api.cwd, api.service.configManager.mainConfigFile)));
|
|
67
|
+
}
|
|
65
68
|
if (!expected.every((f) => {
|
|
66
69
|
var _a2;
|
|
67
70
|
return (_a2 = tsconfig.include) == null ? void 0 : _a2.includes(f);
|
|
68
71
|
})) {
|
|
69
|
-
import_plugin_utils.logger.warn(
|
|
72
|
+
import_plugin_utils.logger.warn(`Please append ${expected.map((e) => `\`${e}\``).join(" & ")} into \`include\` option of \`tsconfig.json\`, to make sure \`defineConfig\` works.`);
|
|
70
73
|
}
|
|
71
74
|
} catch {
|
|
72
75
|
}
|
package/dist/features/meta.js
CHANGED
|
@@ -111,13 +111,19 @@ import deepmerge from '${(0, import_plugin_utils.winPath)(import_path.default.di
|
|
|
111
111
|
export const patchRoutes = ({ routes }) => {
|
|
112
112
|
Object.values(routes).forEach((route) => {
|
|
113
113
|
if (filesMeta[route.id]) {
|
|
114
|
-
|
|
114
|
+
if (process.env.NODE_ENV === 'production' && (route.meta?.frontmatter?.debug || filesMeta[route.id].frontmatter.debug)) {
|
|
115
|
+
// hide route in production which set hide frontmatter
|
|
116
|
+
delete routes[route.id];
|
|
117
|
+
} else {
|
|
118
|
+
// merge meta to route object
|
|
119
|
+
route.meta = deepmerge(route.meta, filesMeta[route.id]);
|
|
115
120
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
+
// apply real tab data from id
|
|
122
|
+
route.meta.tabs = route.meta.tabs?.map(id => ({
|
|
123
|
+
...tabs[id],
|
|
124
|
+
meta: filesMeta[id],
|
|
125
|
+
}));
|
|
126
|
+
}
|
|
121
127
|
}
|
|
122
128
|
});
|
|
123
129
|
}
|
package/dist/features/routes.js
CHANGED
|
@@ -36,7 +36,11 @@ function normalizeDocDir(docDir) {
|
|
|
36
36
|
return typeof docDir === "object" ? docDir : { dir: docDir };
|
|
37
37
|
}
|
|
38
38
|
function kebabCaseRoutePath(routePath) {
|
|
39
|
-
|
|
39
|
+
const replacer = (_, s1, s2, i) => {
|
|
40
|
+
const symbol = ["", "/"].includes(s1) || !i ? "" : "-";
|
|
41
|
+
return `${s1 || ""}${symbol}${s2.toLowerCase()}`;
|
|
42
|
+
};
|
|
43
|
+
return routePath.replace(/(.)?([A-Z][^A-Z/])/g, replacer).replace(/(.)?([A-Z]+)/g, replacer);
|
|
40
44
|
}
|
|
41
45
|
function localizeUmiRoute(route, locales) {
|
|
42
46
|
const locale = locales.find((locale2) => route.path.endsWith(`/${locale2.id}`) && import_path.default.parse(route.file).name.endsWith(`.${locale2.id}`));
|
package/package.json
CHANGED
|
@@ -10,7 +10,7 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
|
|
|
10
10
|
|
|
11
11
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
12
12
|
|
|
13
|
-
import {
|
|
13
|
+
import { useIntl, usePrefersColor, useSiteData } from 'dumi';
|
|
14
14
|
import React from 'react';
|
|
15
15
|
import "./index.less";
|
|
16
16
|
|
|
@@ -68,19 +68,14 @@ var ColorSwitch = function ColorSwitch() {
|
|
|
68
68
|
return setPrefersColor(ev.target.value);
|
|
69
69
|
},
|
|
70
70
|
value: prefersColor
|
|
71
|
-
},
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
})), /*#__PURE__*/React.createElement("option", {
|
|
80
|
-
value: "auto"
|
|
81
|
-
}, /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
82
|
-
id: "header.color.mode.auto"
|
|
83
|
-
}))));
|
|
71
|
+
}, ['light', 'dark', 'auto'].map(function (c) {
|
|
72
|
+
return /*#__PURE__*/React.createElement("option", {
|
|
73
|
+
value: c,
|
|
74
|
+
key: c
|
|
75
|
+
}, intl.formatMessage({
|
|
76
|
+
id: "header.color.mode.".concat(c)
|
|
77
|
+
}));
|
|
78
|
+
})));
|
|
84
79
|
};
|
|
85
80
|
|
|
86
81
|
export default ColorSwitch;
|
|
@@ -97,7 +97,7 @@ var PreviewerActions = function PreviewerActions(props) {
|
|
|
97
97
|
"data-dumi-tooltip": intl.formatMessage({
|
|
98
98
|
id: 'previewer.actions.separate'
|
|
99
99
|
})
|
|
100
|
-
}, /*#__PURE__*/React.createElement(IconExternalLink, null)), /*#__PURE__*/React.createElement(PreviewerActionsExtra, props), !
|
|
100
|
+
}, /*#__PURE__*/React.createElement(IconExternalLink, null)), /*#__PURE__*/React.createElement(PreviewerActionsExtra, props), !props.forceShowCode && /*#__PURE__*/React.createElement("button", {
|
|
101
101
|
className: "dumi-default-previewer-action-btn",
|
|
102
102
|
type: "button",
|
|
103
103
|
onClick: function onClick() {
|