dumi 2.2.1-alpha.0 → 2.2.2
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/compiled/crates/swc_plugin_react_demo.wasm +0 -0
- package/dist/assetParsers/atom.js +15 -5
- package/dist/assetParsers/block.js +27 -9
- package/dist/cli.js +8 -1
- package/dist/client/pages/Demo/index.js +3 -8
- package/dist/client/theme-api/AtomRenderer.d.ts +2 -2
- package/dist/client/theme-api/AtomRenderer.js +19 -35
- package/dist/client/theme-api/DumiDemo.js +8 -13
- package/dist/client/theme-api/DumiDemoGrid.js +12 -26
- package/dist/client/theme-api/DumiPage.js +16 -34
- package/dist/client/theme-api/openCodeSandbox.js +28 -26
- package/dist/client/theme-api/openStackBlitz.js +15 -16
- package/dist/client/theme-api/types.d.ts +15 -12
- package/dist/client/theme-api/useAtomAssets.js +1 -2
- package/dist/client/theme-api/useLocale.js +10 -19
- package/dist/client/theme-api/useNavData.js +78 -103
- package/dist/client/theme-api/usePrefersColor.d.ts +2 -2
- package/dist/client/theme-api/usePrefersColor.js +39 -66
- package/dist/client/theme-api/useRouteMeta.js +9 -23
- package/dist/client/theme-api/useSidebarData.js +124 -158
- package/dist/client/theme-api/useSiteSearch/index.d.ts +1 -1
- package/dist/client/theme-api/useSiteSearch/index.js +24 -38
- package/dist/client/theme-api/useTabMeta.js +8 -19
- package/dist/client/theme-api/utils.d.ts +6 -0
- package/dist/client/theme-api/utils.js +40 -46
- package/dist/client/typings.d.ts +0 -5
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +3 -0
- package/dist/features/assets.js +23 -4
- package/dist/features/autoAlias.js +8 -3
- package/dist/features/compile/babelLoaderCustomize.js +0 -2
- package/dist/features/compile/index.js +22 -10
- package/dist/features/configPlugins/index.js +3 -4
- package/dist/features/configPlugins/schema.d.ts +1 -1
- package/dist/features/configPlugins/schema.js +20 -3
- package/dist/features/derivative.js +54 -11
- package/dist/features/exportStatic.js +11 -7
- package/dist/features/exports.js +8 -3
- package/dist/features/html2sketch.js +7 -5
- package/dist/features/locales.js +53 -17
- package/dist/features/meta.js +23 -10
- package/dist/features/parser.js +17 -5
- package/dist/features/routes.js +63 -24
- package/dist/features/sideEffects/docSideEffectsWebpackPlugin.js +27 -16
- package/dist/features/sideEffects/index.js +13 -4
- package/dist/features/sitemap.js +17 -5
- package/dist/features/tabs.js +23 -11
- package/dist/features/theme/index.js +152 -39
- package/dist/features/theme/loader.js +23 -7
- package/dist/index.js +10 -2
- package/dist/loaders/demo/index.js +3 -3
- package/dist/loaders/markdown/index.d.ts +1 -1
- package/dist/loaders/markdown/index.js +36 -24
- package/dist/loaders/markdown/transformer/index.d.ts +4 -2
- package/dist/loaders/markdown/transformer/index.js +48 -19
- package/dist/loaders/markdown/transformer/rehypeDemo.d.ts +3 -1
- package/dist/loaders/markdown/transformer/rehypeDemo.js +125 -68
- package/dist/loaders/markdown/transformer/rehypeDesc.js +8 -3
- package/dist/loaders/markdown/transformer/rehypeEnhancedTag.js +8 -3
- package/dist/loaders/markdown/transformer/rehypeHighlightLine.js +8 -3
- package/dist/loaders/markdown/transformer/rehypeImg.js +8 -3
- package/dist/loaders/markdown/transformer/rehypeIsolation.js +36 -21
- package/dist/loaders/markdown/transformer/rehypeJsxify.js +8 -3
- package/dist/loaders/markdown/transformer/rehypeLink.d.ts +1 -1
- package/dist/loaders/markdown/transformer/rehypeLink.js +24 -9
- package/dist/loaders/markdown/transformer/rehypeRaw.d.ts +1 -1
- package/dist/loaders/markdown/transformer/rehypeRaw.js +20 -6
- package/dist/loaders/markdown/transformer/rehypeSlug.js +16 -3
- package/dist/loaders/markdown/transformer/rehypeStrip.js +8 -3
- package/dist/loaders/markdown/transformer/rehypeText.js +14 -5
- package/dist/loaders/markdown/transformer/remarkBreaks.d.ts +3 -0
- package/dist/loaders/markdown/transformer/remarkBreaks.js +65 -0
- package/dist/loaders/markdown/transformer/remarkContainer.js +28 -13
- package/dist/loaders/markdown/transformer/remarkEmbed.js +43 -21
- package/dist/loaders/markdown/transformer/remarkMeta.d.ts +3 -1
- package/dist/loaders/markdown/transformer/remarkMeta.js +39 -9
- package/dist/loaders/page/index.js +12 -4
- package/dist/loaders/pre-raw/index.js +0 -2
- package/dist/preset.js +8 -3
- package/dist/registerMethods.js +0 -2
- package/dist/service/dev.js +8 -1
- package/dist/service/printHelp.js +3 -1
- package/dist/techStacks/react.js +8 -3
- package/dist/types.d.ts +6 -6
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +15 -6
- package/package.json +12 -10
- package/theme-default/builtins/API/index.js +15 -36
- package/theme-default/builtins/Badge/index.js +0 -3
- package/theme-default/builtins/Container/index.js +6 -15
- package/theme-default/builtins/Previewer/index.js +1 -8
- package/theme-default/builtins/SourceCode/index.js +15 -27
- package/theme-default/builtins/Table/index.js +10 -25
- package/theme-default/builtins/Tree/index.js +13 -44
- package/theme-default/layouts/DocLayout/index.js +14 -27
- package/theme-default/locales/en-US.json +4 -0
- package/theme-default/locales/zh-CN.json +4 -0
- package/theme-default/slots/ColorSwitch/index.js +7 -22
- package/theme-default/slots/Content/index.js +5 -7
- package/theme-default/slots/Content/index.less +16 -1
- package/theme-default/slots/ContentFooter/index.d.ts +4 -0
- package/theme-default/slots/ContentFooter/index.js +93 -0
- package/theme-default/slots/ContentFooter/index.less +163 -0
- package/theme-default/slots/ContentTabs/index.d.ts +1 -1
- package/theme-default/slots/ContentTabs/index.js +5 -5
- package/theme-default/slots/Features/index.js +6 -11
- package/theme-default/slots/Footer/index.js +1 -4
- package/theme-default/slots/Header/index.js +7 -18
- package/theme-default/slots/HeaderExtra/index.js +0 -2
- package/theme-default/slots/Hero/index.js +2 -6
- package/theme-default/slots/HeroTitle/index.js +0 -2
- package/theme-default/slots/LangSwitch/index.js +23 -35
- package/theme-default/slots/Logo/index.js +1 -4
- package/theme-default/slots/Navbar/index.js +14 -29
- package/theme-default/slots/NavbarExtra/index.js +0 -2
- package/theme-default/slots/NotFound/index.js +0 -2
- package/theme-default/slots/PreviewerActions/index.js +13 -35
- package/theme-default/slots/PreviewerActionsExtra/index.js +0 -2
- package/theme-default/slots/RtlSwitch/index.js +6 -20
- package/theme-default/slots/RtlSwitch/index.less +5 -0
- package/theme-default/slots/SearchBar/Input.d.ts +1 -1
- package/theme-default/slots/SearchBar/Input.js +6 -5
- package/theme-default/slots/SearchBar/Mask.d.ts +1 -1
- package/theme-default/slots/SearchBar/Mask.js +0 -1
- package/theme-default/slots/SearchBar/index.js +20 -41
- package/theme-default/slots/SearchResult/index.d.ts +1 -1
- package/theme-default/slots/SearchResult/index.js +13 -36
- package/theme-default/slots/Sidebar/index.js +1 -4
- package/theme-default/slots/SocialIcon/index.d.ts +2 -2
- package/theme-default/slots/SocialIcon/index.js +1 -3
- package/theme-default/slots/Toc/index.js +12 -28
package/dist/features/locales.js
CHANGED
|
@@ -16,7 +16,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
20
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
28
|
|
|
22
29
|
// src/features/locales.ts
|
|
@@ -34,19 +41,29 @@ var locales_default = (api) => {
|
|
|
34
41
|
default: [
|
|
35
42
|
{
|
|
36
43
|
id: "zh-CN",
|
|
37
|
-
name: "
|
|
44
|
+
name: "中文",
|
|
45
|
+
// only apply default base for non-suffix mode
|
|
38
46
|
...((_a = api.userConfig.locales) == null ? void 0 : _a[0]) && "suffix" in api.userConfig.locales[0] ? {} : { base: "/" }
|
|
39
47
|
}
|
|
40
48
|
],
|
|
41
49
|
schema: (Joi) => {
|
|
42
50
|
const basicOpts = { id: Joi.string(), name: Joi.string() };
|
|
43
|
-
return Joi.alternatives(
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
51
|
+
return Joi.alternatives(
|
|
52
|
+
// base mode
|
|
53
|
+
Joi.array().items(
|
|
54
|
+
Joi.object({
|
|
55
|
+
...basicOpts,
|
|
56
|
+
base: Joi.string().optional()
|
|
57
|
+
})
|
|
58
|
+
),
|
|
59
|
+
// suffix mode
|
|
60
|
+
Joi.array().items(
|
|
61
|
+
Joi.object({
|
|
62
|
+
...basicOpts,
|
|
63
|
+
suffix: Joi.string().allow("")
|
|
64
|
+
})
|
|
65
|
+
)
|
|
66
|
+
);
|
|
50
67
|
}
|
|
51
68
|
}
|
|
52
69
|
});
|
|
@@ -54,7 +71,10 @@ var locales_default = (api) => {
|
|
|
54
71
|
if (api.config.locales) {
|
|
55
72
|
api.config.locales.slice(1).forEach((locale) => {
|
|
56
73
|
if ("base" in locale && locale.base === "/") {
|
|
57
|
-
assert(
|
|
74
|
+
assert(
|
|
75
|
+
false,
|
|
76
|
+
`Only the first locale item is allowed to set base: '/', you can move ${locale.id} to the front as default locale. See more: See https://d.umijs.org/config#locales`
|
|
77
|
+
);
|
|
58
78
|
}
|
|
59
79
|
});
|
|
60
80
|
}
|
|
@@ -76,8 +96,16 @@ var locales_default = (api) => {
|
|
|
76
96
|
api.writeTmpFile({
|
|
77
97
|
noPluginDir: true,
|
|
78
98
|
path: "dumi/locales/config.ts",
|
|
79
|
-
content: `export const locales = ${JSON.stringify(
|
|
80
|
-
|
|
99
|
+
content: `export const locales = ${JSON.stringify(
|
|
100
|
+
api.config.locales,
|
|
101
|
+
null,
|
|
102
|
+
2
|
|
103
|
+
)};
|
|
104
|
+
export const messages = ${JSON.stringify(
|
|
105
|
+
api.service.themeData.locales,
|
|
106
|
+
null,
|
|
107
|
+
2
|
|
108
|
+
)};`
|
|
81
109
|
});
|
|
82
110
|
api.writeTmpFile({
|
|
83
111
|
noPluginDir: true,
|
|
@@ -85,8 +113,12 @@ export const messages = ${JSON.stringify(api.service.themeData.locales, null, 2)
|
|
|
85
113
|
content: `
|
|
86
114
|
import { history } from 'dumi';
|
|
87
115
|
import React, { useState, useLayoutEffect, useCallback, type ReactNode } from 'react';
|
|
88
|
-
import { RawIntlProvider, createIntl, createIntlCache } from '${(0, import_plugin_utils.winPath)(
|
|
89
|
-
|
|
116
|
+
import { RawIntlProvider, createIntl, createIntlCache } from '${(0, import_plugin_utils.winPath)(
|
|
117
|
+
import_path.default.dirname(require.resolve("react-intl/package"))
|
|
118
|
+
)}';
|
|
119
|
+
import { useIsomorphicLayoutEffect } from '${(0, import_plugin_utils.winPath)(
|
|
120
|
+
require.resolve("../client/theme-api/utils")
|
|
121
|
+
)}'
|
|
90
122
|
import { locales, messages } from './config';
|
|
91
123
|
|
|
92
124
|
const cache = createIntlCache();
|
|
@@ -102,8 +134,14 @@ const LocalesContainer: FC<{ children: ReactNode }> = (props) => {
|
|
|
102
134
|
.startsWith("${api.config.base.replace(/\/$/, "")}" + locale.base)
|
|
103
135
|
));
|
|
104
136
|
const locale = matched ? matched.id : locales[0].id;
|
|
137
|
+
const localeMessages = messages[locale] || {};
|
|
105
138
|
|
|
106
|
-
|
|
139
|
+
// append internal message, for use intl as string template util
|
|
140
|
+
localeMessages['$internal.edit.link'] = ${JSON.stringify(
|
|
141
|
+
api.config.themeConfig.editLink
|
|
142
|
+
)};
|
|
143
|
+
|
|
144
|
+
return createIntl({ locale, messages: localeMessages }, cache);
|
|
107
145
|
}, []);
|
|
108
146
|
const [intl, setIntl] = useState(() => getIntl());
|
|
109
147
|
|
|
@@ -124,5 +162,3 @@ export function i18nProvider(container: Element) {
|
|
|
124
162
|
});
|
|
125
163
|
api.addRuntimePlugin(() => "@@/dumi/locales/runtime.tsx");
|
|
126
164
|
};
|
|
127
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
128
|
-
0 && (module.exports = {});
|
package/dist/features/meta.js
CHANGED
|
@@ -16,7 +16,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
20
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
28
|
|
|
22
29
|
// src/features/meta.ts
|
|
@@ -36,6 +43,7 @@ var meta_default = (api) => {
|
|
|
36
43
|
const metaFiles = [];
|
|
37
44
|
api.register({
|
|
38
45
|
key: "modifyRoutes",
|
|
46
|
+
// make sure it is called last
|
|
39
47
|
stage: Infinity,
|
|
40
48
|
fn: (routes) => {
|
|
41
49
|
metaFiles.length = 0;
|
|
@@ -60,7 +68,8 @@ var meta_default = (api) => {
|
|
|
60
68
|
api.writeTmpFile({
|
|
61
69
|
noPluginDir: true,
|
|
62
70
|
path: "dumi/meta/index.ts",
|
|
63
|
-
content: import_plugin_utils.Mustache.render(
|
|
71
|
+
content: import_plugin_utils.Mustache.render(
|
|
72
|
+
`{{#metaFiles}}
|
|
64
73
|
import { demos as dm{{{index}}}, frontmatter as fm{{{index}}}, toc as toc{{{index}}}, texts as txt{{{index}}} } from '{{{file}}}?type=meta';
|
|
65
74
|
{{/metaFiles}}
|
|
66
75
|
|
|
@@ -95,19 +104,23 @@ export const demos = Object.entries(filesMeta).reduce((acc, [id, meta]) => {
|
|
|
95
104
|
|
|
96
105
|
return acc;
|
|
97
106
|
}, {});
|
|
98
|
-
`,
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
107
|
+
`,
|
|
108
|
+
{
|
|
109
|
+
metaFiles: await api.applyPlugins({
|
|
110
|
+
type: api.ApplyPluginsType.modify,
|
|
111
|
+
key: "dumi.modifyMetaFiles",
|
|
112
|
+
initialValue: metaFiles
|
|
113
|
+
})
|
|
114
|
+
}
|
|
115
|
+
)
|
|
105
116
|
});
|
|
106
117
|
api.writeTmpFile({
|
|
107
118
|
noPluginDir: true,
|
|
108
119
|
path: "dumi/meta/runtime.ts",
|
|
109
120
|
content: `import { filesMeta, tabs } from '.';
|
|
110
|
-
import deepmerge from '${(0, import_plugin_utils.winPath)(
|
|
121
|
+
import deepmerge from '${(0, import_plugin_utils.winPath)(
|
|
122
|
+
import_path.default.dirname(require.resolve("deepmerge/package"))
|
|
123
|
+
)}';
|
|
111
124
|
export const patchRoutes = ({ routes }) => {
|
|
112
125
|
Object.values(routes).forEach((route) => {
|
|
113
126
|
if (filesMeta[route.id]) {
|
package/dist/features/parser.js
CHANGED
|
@@ -16,7 +16,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
20
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
28
|
|
|
22
29
|
// src/features/parser.ts
|
|
@@ -33,7 +40,11 @@ var parser_default = (api) => {
|
|
|
33
40
|
api.writeTmpFile({
|
|
34
41
|
noPluginDir: true,
|
|
35
42
|
path: import_meta.ATOMS_META_PATH,
|
|
36
|
-
content: `export const components = ${JSON.stringify(
|
|
43
|
+
content: `export const components = ${JSON.stringify(
|
|
44
|
+
data.components,
|
|
45
|
+
null,
|
|
46
|
+
2
|
|
47
|
+
)};`
|
|
37
48
|
});
|
|
38
49
|
};
|
|
39
50
|
api.describe({
|
|
@@ -49,7 +60,10 @@ var parser_default = (api) => {
|
|
|
49
60
|
});
|
|
50
61
|
api.modifyDefaultConfig((memo) => {
|
|
51
62
|
var _a;
|
|
52
|
-
(0, import_assert.default)(
|
|
63
|
+
(0, import_assert.default)(
|
|
64
|
+
(_a = api.userConfig.resolve) == null ? void 0 : _a.entryFile,
|
|
65
|
+
"`resolve.entryFile` must be configured when `apiParser` enable"
|
|
66
|
+
);
|
|
53
67
|
return memo;
|
|
54
68
|
});
|
|
55
69
|
api.onCheckPkgJSON(async () => {
|
|
@@ -96,5 +110,3 @@ var parser_default = (api) => {
|
|
|
96
110
|
return memo;
|
|
97
111
|
});
|
|
98
112
|
};
|
|
99
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
100
|
-
0 && (module.exports = {});
|
package/dist/features/routes.js
CHANGED
|
@@ -16,7 +16,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
20
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
28
|
|
|
22
29
|
// src/features/routes.ts
|
|
@@ -46,12 +53,17 @@ function kebabCaseRoutePath(routePath) {
|
|
|
46
53
|
return routePath.replace(/(.)?([A-Z][^A-Z/])/g, replacer).replace(/(.)?([A-Z]+)/g, replacer);
|
|
47
54
|
}
|
|
48
55
|
function localizeUmiRoute(route, locales, forceKebabCase) {
|
|
49
|
-
const locale = locales.find(
|
|
56
|
+
const locale = locales.find(
|
|
57
|
+
(locale2) => route.path.endsWith(`/${locale2.id}`) && // avoid locale id conflict with folder/file name
|
|
58
|
+
import_path.default.parse(route.file).name.endsWith(`.${locale2.id}`)
|
|
59
|
+
);
|
|
50
60
|
const format = forceKebabCase ? kebabCaseRoutePath : (str) => str;
|
|
51
61
|
if (locale) {
|
|
52
62
|
const base = !("base" in locale) || locale.base === "/" ? "" : locale.base.replace(/^(\/)(.+)$/, "$2$1");
|
|
53
63
|
const suffix = "suffix" in locale ? locale.suffix : "";
|
|
54
|
-
route.path = `${base}${format(
|
|
64
|
+
route.path = `${base}${format(
|
|
65
|
+
route.path.replace(new RegExp(`/${locale.id}$`), "").replace(/((^|\/)(index|README))$/, "")
|
|
66
|
+
)}${suffix}`;
|
|
55
67
|
route.absPath = route.path !== "/" ? `/${route.path}` : route.path;
|
|
56
68
|
} else {
|
|
57
69
|
route.path = format(route.path);
|
|
@@ -61,7 +73,11 @@ function localizeUmiRoute(route, locales, forceKebabCase) {
|
|
|
61
73
|
function flatRoute(route, docLayoutId) {
|
|
62
74
|
if (route.parentId !== docLayoutId) {
|
|
63
75
|
route.parentId = docLayoutId;
|
|
64
|
-
route.path = route.path === "*" ?
|
|
76
|
+
route.path = route.path === "*" ? (
|
|
77
|
+
// FIXME: compatible with wrong conventional 404 absPath, wait for umi fix
|
|
78
|
+
// from: https://github.com/umijs/umi/blob/9e8f143229d6f5d8547e951c23cbb2c66cbfd190/packages/preset-umi/src/features/404/404.ts#L8
|
|
79
|
+
route.path
|
|
80
|
+
) : route.absPath.slice(1);
|
|
65
81
|
}
|
|
66
82
|
}
|
|
67
83
|
function getAliasLayoutFile({
|
|
@@ -90,25 +106,36 @@ var routes_default = (api) => {
|
|
|
90
106
|
memo.resolve[key] = [];
|
|
91
107
|
});
|
|
92
108
|
}
|
|
93
|
-
memo.alias[ALIAS_THEME_TMP] = (0, import_plugin_utils.winPath)(
|
|
94
|
-
|
|
95
|
-
|
|
109
|
+
memo.alias[ALIAS_THEME_TMP] = (0, import_plugin_utils.winPath)(
|
|
110
|
+
import_path.default.join(api.paths.absTmpPath, "dumi/theme")
|
|
111
|
+
);
|
|
112
|
+
memo.alias[ALIAS_LAYOUTS_LOCAL] = (0, import_plugin_utils.winPath)(
|
|
113
|
+
import_path.default.join(api.cwd, import_constants.LOCAL_THEME_DIR, "layouts")
|
|
114
|
+
);
|
|
115
|
+
memo.alias[ALIAS_INTERNAL_PAGES] = (0, import_plugin_utils.winPath)(
|
|
116
|
+
import_path.default.join(__dirname, "../client/pages")
|
|
117
|
+
);
|
|
96
118
|
return memo;
|
|
97
119
|
});
|
|
98
120
|
api.modifyRoutes((oRoutes) => {
|
|
99
121
|
const pages = {};
|
|
100
|
-
const routes = Object.values(oRoutes).reduce(
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
122
|
+
const routes = Object.values(oRoutes).reduce(
|
|
123
|
+
(ret, route) => {
|
|
124
|
+
if (route.isLayout) {
|
|
125
|
+
ret[route.id] = route;
|
|
126
|
+
} else {
|
|
127
|
+
pages[route.id] = route;
|
|
128
|
+
}
|
|
129
|
+
return ret;
|
|
130
|
+
},
|
|
131
|
+
{}
|
|
132
|
+
);
|
|
108
133
|
const { DocLayout, DemoLayout } = api.service.themeData.layouts;
|
|
109
134
|
const { docDirs, atomDirs } = api.config.resolve;
|
|
110
135
|
const layoutRouteValues = Object.values(routes);
|
|
111
|
-
const lastLayoutId = layoutRouteValues.find(
|
|
136
|
+
const lastLayoutId = layoutRouteValues.find(
|
|
137
|
+
({ id }) => layoutRouteValues.every(({ parentId }) => id !== parentId)
|
|
138
|
+
).id;
|
|
112
139
|
let docLayoutId = lastLayoutId;
|
|
113
140
|
let demoLayoutId = lastLayoutId;
|
|
114
141
|
if (DocLayout) {
|
|
@@ -116,6 +143,9 @@ var routes_default = (api) => {
|
|
|
116
143
|
routes[DocLayout.specifier] = {
|
|
117
144
|
id: DocLayout.specifier,
|
|
118
145
|
path: "/",
|
|
146
|
+
// why not use DocLayout.source?
|
|
147
|
+
// because umi will generate chunk name from file path
|
|
148
|
+
// but source may too long in pnpm/monorepo project
|
|
119
149
|
file: getAliasLayoutFile(DocLayout),
|
|
120
150
|
parentId: lastLayoutId,
|
|
121
151
|
absPath: "/",
|
|
@@ -157,7 +187,10 @@ var routes_default = (api) => {
|
|
|
157
187
|
});
|
|
158
188
|
atomDirs.forEach(({ type, subType = "", dir }) => {
|
|
159
189
|
const base = import_path.default.join(api.cwd, dir);
|
|
160
|
-
const atomFiles = import_plugin_utils.glob.sync(
|
|
190
|
+
const atomFiles = import_plugin_utils.glob.sync(
|
|
191
|
+
"{*,*/index,*/index.*,*/README,*/README.*}.md",
|
|
192
|
+
{ cwd: base }
|
|
193
|
+
);
|
|
161
194
|
atomFiles.forEach((file) => {
|
|
162
195
|
const routeFile = (0, import_plugin_utils.winPath)(import_path.default.join((0, import_pluralize.plural)(type), subType, file));
|
|
163
196
|
const routePath = routeFile.replace(/(\/index|\/README)?\.md$/, "").replace(/\./g, "/");
|
|
@@ -174,11 +207,17 @@ var routes_default = (api) => {
|
|
|
174
207
|
});
|
|
175
208
|
Object.values(routes).forEach((route) => {
|
|
176
209
|
if (route.path !== encodeURI(route.path)) {
|
|
177
|
-
throw new Error(
|
|
178
|
-
|
|
210
|
+
throw new Error(
|
|
211
|
+
`Invalid route path: ${route.path}, please rename it with only alphanumeric, dash and slash.
|
|
212
|
+
at ${route.file}`
|
|
213
|
+
);
|
|
179
214
|
} else if (!route.isLayout) {
|
|
180
215
|
flatRoute(route, docLayoutId);
|
|
181
|
-
localizeUmiRoute(
|
|
216
|
+
localizeUmiRoute(
|
|
217
|
+
route,
|
|
218
|
+
api.config.locales,
|
|
219
|
+
api.config.resolve.forceKebabCaseRouting
|
|
220
|
+
);
|
|
182
221
|
}
|
|
183
222
|
});
|
|
184
223
|
if (Object.values(pages).every((route) => route.path !== "*")) {
|
|
@@ -215,7 +254,8 @@ var routes_default = (api) => {
|
|
|
215
254
|
}
|
|
216
255
|
return layouts;
|
|
217
256
|
});
|
|
218
|
-
api.addEntryCodeAhead(
|
|
257
|
+
api.addEntryCodeAhead(
|
|
258
|
+
() => `
|
|
219
259
|
// always remove trailing slash from location.pathname
|
|
220
260
|
if (
|
|
221
261
|
typeof history !== 'undefined' &&
|
|
@@ -228,7 +268,6 @@ if (
|
|
|
228
268
|
location.pathname.slice(0, -1) + location.search + location.hash,
|
|
229
269
|
);
|
|
230
270
|
}
|
|
231
|
-
`
|
|
271
|
+
`
|
|
272
|
+
);
|
|
232
273
|
};
|
|
233
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
234
|
-
0 && (module.exports = {});
|
|
@@ -16,7 +16,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
20
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
28
|
|
|
22
29
|
// src/features/sideEffects/docSideEffectsWebpackPlugin.ts
|
|
@@ -31,20 +38,24 @@ var docSideEffectsWebpackPlugin = class {
|
|
|
31
38
|
this.opts = opts;
|
|
32
39
|
}
|
|
33
40
|
apply(compiler) {
|
|
34
|
-
compiler.hooks.normalModuleFactory.tap(
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
41
|
+
compiler.hooks.normalModuleFactory.tap(
|
|
42
|
+
this.constructor.name,
|
|
43
|
+
(normalModuleFactory) => {
|
|
44
|
+
normalModuleFactory.hooks.afterResolve.tap(
|
|
45
|
+
this.constructor.name,
|
|
46
|
+
(data) => {
|
|
47
|
+
var _a;
|
|
48
|
+
const createData = data.createData || data;
|
|
49
|
+
const resourceResolveData = createData.resourceResolveData;
|
|
50
|
+
const sideEffectsFlag = (_a = resourceResolveData == null ? void 0 : resourceResolveData.descriptionFileData) == null ? void 0 : _a.sideEffects;
|
|
51
|
+
if (resourceResolveData && (sideEffectsFlag === false || Array.isArray(sideEffectsFlag)) && import_path.default.normalize(resourceResolveData.descriptionFilePath) === this.opts.pkgPath) {
|
|
52
|
+
const list = new Set(sideEffectsFlag || []);
|
|
53
|
+
this.opts.sideEffects.forEach((item) => list.add(item));
|
|
54
|
+
resourceResolveData.descriptionFileData.sideEffects = Array.from(list);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
);
|
|
47
60
|
}
|
|
48
61
|
};
|
|
49
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
50
|
-
0 && (module.exports = {});
|
|
@@ -16,7 +16,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
20
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
28
|
|
|
22
29
|
// src/features/sideEffects/index.ts
|
|
@@ -34,7 +41,11 @@ var sideEffects_default = (api) => {
|
|
|
34
41
|
memo.plugin("docSideEffects").use(import_docSideEffectsWebpackPlugin.default, [
|
|
35
42
|
{
|
|
36
43
|
sideEffects: [
|
|
37
|
-
|
|
44
|
+
// such as .dumi/tmp-production/**
|
|
45
|
+
(0, import_plugin_utils.winPath)(
|
|
46
|
+
import_path.default.relative(api.cwd, import_path.default.join(api.paths.absTmpPath, "**"))
|
|
47
|
+
),
|
|
48
|
+
// .dumi local theme
|
|
38
49
|
".dumi/theme/**"
|
|
39
50
|
],
|
|
40
51
|
pkgPath: import_path.default.join(api.cwd, "package.json")
|
|
@@ -43,5 +54,3 @@ var sideEffects_default = (api) => {
|
|
|
43
54
|
return memo;
|
|
44
55
|
});
|
|
45
56
|
};
|
|
46
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
47
|
-
0 && (module.exports = {});
|
package/dist/features/sitemap.js
CHANGED
|
@@ -16,7 +16,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
20
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
28
|
|
|
22
29
|
// src/features/sitemap.ts
|
|
@@ -47,10 +54,17 @@ var sitemap_default = (api) => {
|
|
|
47
54
|
xmlns: { video: false, image: false, news: false, xhtml: false }
|
|
48
55
|
});
|
|
49
56
|
const exclude = ["/404"].concat(api.config.sitemap.exclude || []);
|
|
50
|
-
const writeStream = import_fs.default.createWriteStream(
|
|
57
|
+
const writeStream = import_fs.default.createWriteStream(
|
|
58
|
+
import_path.default.join(api.paths.absOutputPath, "sitemap.xml")
|
|
59
|
+
);
|
|
51
60
|
smis.pipe(writeStream);
|
|
52
61
|
Object.values(api.appData.routes).forEach((route) => {
|
|
53
|
-
if (
|
|
62
|
+
if (
|
|
63
|
+
// ignore specific paths
|
|
64
|
+
!exclude.includes(route.path) && // ignore dynamic route, such as /~demos/:uuid
|
|
65
|
+
![":", "*"].some((char) => route.path.includes(char)) && // ignore duplicate URLs
|
|
66
|
+
!route.isLayout
|
|
67
|
+
) {
|
|
54
68
|
smis.write({ url: route.path });
|
|
55
69
|
}
|
|
56
70
|
});
|
|
@@ -60,5 +74,3 @@ var sitemap_default = (api) => {
|
|
|
60
74
|
});
|
|
61
75
|
});
|
|
62
76
|
};
|
|
63
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
64
|
-
0 && (module.exports = {});
|
package/dist/features/tabs.js
CHANGED
|
@@ -16,7 +16,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
20
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
28
|
|
|
22
29
|
// src/features/tabs.ts
|
|
@@ -86,14 +93,16 @@ var tabs_default = (api) => {
|
|
|
86
93
|
});
|
|
87
94
|
}
|
|
88
95
|
});
|
|
89
|
-
tabs.push(
|
|
90
|
-
index
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
96
|
+
tabs.push(
|
|
97
|
+
...tabsFromPlugins.map((tab, index) => ({
|
|
98
|
+
index: tabs.length + index,
|
|
99
|
+
key: tab.key,
|
|
100
|
+
id: tab.id,
|
|
101
|
+
title: tab.title || import_plugin_utils.lodash.startCase(import_path.default.parse(tab.component).name),
|
|
102
|
+
titleIntlId: tab.titleIntlId,
|
|
103
|
+
file: tab.component
|
|
104
|
+
}))
|
|
105
|
+
);
|
|
97
106
|
return routes;
|
|
98
107
|
});
|
|
99
108
|
api.register({
|
|
@@ -121,7 +130,8 @@ var tabs_default = (api) => {
|
|
|
121
130
|
api.writeTmpFile({
|
|
122
131
|
noPluginDir: true,
|
|
123
132
|
path: import_meta.TABS_META_PATH,
|
|
124
|
-
content: import_plugin_utils.Mustache.render(
|
|
133
|
+
content: import_plugin_utils.Mustache.render(
|
|
134
|
+
`{{#tabs}}
|
|
125
135
|
import * as tab{{{index}}} from '{{{file}}}';
|
|
126
136
|
{{/tabs}}
|
|
127
137
|
|
|
@@ -130,7 +140,9 @@ export const tabs = {
|
|
|
130
140
|
'{{{id}}}': { key: '{{{key}}}', title: '{{{title}}}', titleIntlId: '{{{titleIntlId}}}', components: tab{{{index}}} },
|
|
131
141
|
{{/tabs}}
|
|
132
142
|
}
|
|
133
|
-
`,
|
|
143
|
+
`,
|
|
144
|
+
{ tabs }
|
|
145
|
+
)
|
|
134
146
|
});
|
|
135
147
|
});
|
|
136
148
|
};
|