dumi 2.2.1 → 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 +18 -23
- package/dist/client/theme-api/openStackBlitz.js +6 -14
- 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 +2 -2
- package/dist/client/theme-api/utils.js +33 -47
- package/dist/client/typings.d.ts +0 -5
- 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 +20 -9
- 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 +133 -38
- 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 +2 -1
- package/dist/loaders/markdown/transformer/index.js +34 -17
- 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.js +16 -5
- 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 +11 -9
- 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
|
@@ -1,111 +1,97 @@
|
|
|
1
1
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
-
|
|
3
2
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
4
|
-
|
|
5
3
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
6
|
-
|
|
7
4
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
8
|
-
|
|
9
|
-
function
|
|
10
|
-
|
|
11
|
-
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
12
|
-
|
|
5
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
6
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
13
7
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
14
|
-
|
|
15
8
|
import { useAppData, useIntl, useSiteData } from 'dumi';
|
|
16
9
|
import { useCallback, useEffect, useLayoutEffect, useState } from 'react';
|
|
17
10
|
import { useLocale } from "./useLocale";
|
|
11
|
+
|
|
18
12
|
/**
|
|
19
13
|
* private instance, do not use it in your code
|
|
20
14
|
*/
|
|
21
|
-
|
|
22
15
|
export var pluginManager;
|
|
23
16
|
export var setPluginManager = function setPluginManager(pm) {
|
|
24
17
|
pluginManager = pm;
|
|
25
18
|
};
|
|
26
19
|
export var useLocaleDocRoutes = function useLocaleDocRoutes() {
|
|
27
20
|
var intl = useIntl();
|
|
28
|
-
|
|
29
21
|
var _useAppData = useAppData(),
|
|
30
|
-
|
|
31
|
-
|
|
22
|
+
routes = _useAppData.routes;
|
|
32
23
|
var _useSiteData = useSiteData(),
|
|
33
|
-
|
|
34
|
-
|
|
24
|
+
locales = _useSiteData.locales;
|
|
35
25
|
var _useState = useState(function () {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
26
|
+
var reversedLocales = locales.slice().reverse();
|
|
27
|
+
return Object.values(routes).reduce(function (ret, route) {
|
|
28
|
+
var matched = reversedLocales.find(function (locale) {
|
|
29
|
+
return 'suffix' in locale ?
|
|
30
|
+
// suffix mode
|
|
31
|
+
route.path.endsWith(locale.suffix) :
|
|
32
|
+
// base mode
|
|
33
|
+
route.path.startsWith(locale.base.slice(1));
|
|
34
|
+
});
|
|
35
|
+
if (route.parentId === 'DocLayout' && matched.id === intl.locale) {
|
|
36
|
+
ret[route.id] = route;
|
|
37
|
+
}
|
|
38
|
+
return ret;
|
|
39
|
+
}, {});
|
|
40
|
+
}),
|
|
41
|
+
_useState2 = _slicedToArray(_useState, 1),
|
|
42
|
+
localeDocRoutes = _useState2[0];
|
|
54
43
|
return localeDocRoutes;
|
|
55
44
|
};
|
|
45
|
+
|
|
56
46
|
/**
|
|
57
47
|
* 在 react 18 中需要新的 render 方式,这个函数用来处理不同的 jsx 模式。
|
|
58
48
|
* @param version react version
|
|
59
49
|
* @returns code string
|
|
60
50
|
*/
|
|
61
|
-
|
|
62
51
|
export var genReactRenderCode = function genReactRenderCode(version) {
|
|
63
52
|
var annotation = "/**\n * This is an auto-generated demo by dumi\n * if you think it is not working as expected,\n * please report the issue at\n * https://github.com/umijs/dumi/issues\n */";
|
|
64
|
-
|
|
65
53
|
if (version.startsWith('18.') || version === 'latest') {
|
|
66
54
|
return "".concat(annotation, "\n\nimport React from 'react';\nimport { createRoot } from \"react-dom/client\";\nimport App from \"./App\";\n\nconst rootElement = document.getElementById(\"root\");\nconst root = createRoot(rootElement);\n\nroot.render(<App />);");
|
|
67
55
|
}
|
|
68
|
-
|
|
69
56
|
return "".concat(annotation, "\n\nimport React from 'react';\nimport ReactDOM from 'react-dom';\nimport App from './App';\n\nReactDOM.render(\n <App />,\n document.getElementById('root'),\n);");
|
|
70
57
|
};
|
|
71
58
|
export var useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;
|
|
59
|
+
|
|
72
60
|
/**
|
|
73
61
|
* common comparer for sidebar/nav items
|
|
74
62
|
*/
|
|
75
|
-
|
|
76
63
|
export var useRouteDataComparer = function useRouteDataComparer() {
|
|
77
64
|
var locale = useLocale();
|
|
78
65
|
return useCallback(function (a, b) {
|
|
79
|
-
return (
|
|
80
|
-
|
|
81
|
-
'
|
|
82
|
-
|
|
66
|
+
return (
|
|
67
|
+
// smaller before larger for all
|
|
68
|
+
('order' in a && 'order' in b ? a.order - b.order : 0) || (
|
|
69
|
+
// shallower before deeper for sidebar item
|
|
70
|
+
'link' in a && 'link' in b ? a.link.split('/').length - b.link.split('/').length : 0) || (
|
|
71
|
+
// shallower before deeper for sidebar leaf
|
|
72
|
+
'path' in a && 'path' in b ? a.path.split('/').length - b.path.split('/').length : 0) || (
|
|
73
|
+
// fallback to compare title (put non-title item at the end)
|
|
83
74
|
a.title ? a.title.localeCompare(b.title || '', locale.id) : -1)
|
|
84
75
|
);
|
|
85
76
|
}, []);
|
|
86
77
|
};
|
|
78
|
+
|
|
87
79
|
/**
|
|
88
80
|
* common util for pick meta to sort sidebar/nav items
|
|
89
81
|
*/
|
|
90
|
-
|
|
91
82
|
export var pickRouteSortMeta = function pickRouteSortMeta(original, field, fm) {
|
|
92
83
|
var _sub$order;
|
|
93
|
-
|
|
94
84
|
var sub = field === 'nav.second' ? _typeof(fm.nav) === 'object' ? fm.nav.second : {} : fm[field];
|
|
95
|
-
|
|
96
85
|
switch (_typeof(sub)) {
|
|
97
86
|
case 'object':
|
|
98
87
|
original.title = sub.title || original.title;
|
|
99
88
|
original.order = (_sub$order = sub.order) !== null && _sub$order !== void 0 ? _sub$order : original.order;
|
|
100
89
|
break;
|
|
101
|
-
|
|
102
90
|
case 'string':
|
|
103
91
|
original.title = sub || original.title;
|
|
104
92
|
break;
|
|
105
|
-
|
|
106
93
|
default:
|
|
107
94
|
}
|
|
108
|
-
|
|
109
95
|
return original;
|
|
110
96
|
};
|
|
111
97
|
export function getLocaleNav(nav, locale) {
|
package/dist/client/typings.d.ts
CHANGED
package/dist/features/assets.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/assets.ts
|
|
@@ -65,7 +72,10 @@ var assets_default = (api) => {
|
|
|
65
72
|
name: "getAssetsMetadata",
|
|
66
73
|
async fn() {
|
|
67
74
|
await compileDeferrer;
|
|
68
|
-
const { components } = api.service.atomParser ? await api.service.atomParser.parse() :
|
|
75
|
+
const { components } = api.service.atomParser ? await api.service.atomParser.parse() : (
|
|
76
|
+
// allow generate assets.json without atoms when parser is not available
|
|
77
|
+
{ components: {} }
|
|
78
|
+
);
|
|
69
79
|
return await api.applyPlugins({
|
|
70
80
|
key: "modifyAssetsMetadata",
|
|
71
81
|
initialValue: {
|
|
@@ -77,7 +87,12 @@ var assets_default = (api) => {
|
|
|
77
87
|
homepage: api.pkg.homepage,
|
|
78
88
|
repository: api.pkg.repository,
|
|
79
89
|
assets: {
|
|
80
|
-
atoms: Object.values(components).map(
|
|
90
|
+
atoms: Object.values(components).map(
|
|
91
|
+
(atom) => (
|
|
92
|
+
// assign extra meta data from md frontmatter
|
|
93
|
+
Object.assign(atom, atomsMeta[atom.id] || {})
|
|
94
|
+
)
|
|
95
|
+
),
|
|
81
96
|
examples: import_plugin_utils.lodash.uniqBy(examples, "id")
|
|
82
97
|
}
|
|
83
98
|
}
|
|
@@ -86,7 +101,11 @@ var assets_default = (api) => {
|
|
|
86
101
|
});
|
|
87
102
|
api.onBuildComplete(async () => {
|
|
88
103
|
const assets = await api.getAssetsMetadata();
|
|
89
|
-
import_fs.default.writeFileSync(
|
|
104
|
+
import_fs.default.writeFileSync(
|
|
105
|
+
import_path.default.join(api.cwd, "assets.json"),
|
|
106
|
+
JSON.stringify(assets, null, 2),
|
|
107
|
+
"utf-8"
|
|
108
|
+
);
|
|
90
109
|
});
|
|
91
110
|
};
|
|
92
111
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -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/autoAlias.ts
|
|
@@ -65,5 +72,3 @@ var autoAlias_default = (api) => {
|
|
|
65
72
|
return memo;
|
|
66
73
|
});
|
|
67
74
|
};
|
|
68
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
69
|
-
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/compile/index.ts
|
|
@@ -36,7 +43,9 @@ var compile_default = (api) => {
|
|
|
36
43
|
});
|
|
37
44
|
api.modifyConfig((memo) => {
|
|
38
45
|
if (memo.babelLoaderCustomize) {
|
|
39
|
-
api.logger.warn(
|
|
46
|
+
api.logger.warn(
|
|
47
|
+
"Config `babelLoaderCustomize` will be override by dumi, please report issue if you need it."
|
|
48
|
+
);
|
|
40
49
|
}
|
|
41
50
|
memo.babelLoaderCustomize = require.resolve("./babelLoaderCustomize");
|
|
42
51
|
return memo;
|
|
@@ -56,17 +65,21 @@ var compile_default = (api) => {
|
|
|
56
65
|
extraRemarkPlugins: api.config.extraRemarkPlugins,
|
|
57
66
|
extraRehypePlugins: api.config.extraRehypePlugins,
|
|
58
67
|
routes: api.appData.routes,
|
|
68
|
+
locales: api.config.locales,
|
|
59
69
|
pkg: api.pkg
|
|
60
70
|
};
|
|
61
71
|
memo.module.rule("dumi-md").type("javascript/auto").test(/\.md$/).oneOf("md-meta").resourceQuery(/meta$/).use("babel-loader").loader(babelInUmi.loader).options(babelInUmi.options).end().use("md-meta-loader").loader(loaderPath).options({
|
|
62
72
|
...loaderBaseOpts,
|
|
63
73
|
mode: "meta",
|
|
64
74
|
onResolveDemos(demos) {
|
|
65
|
-
const assets = demos.reduce(
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
75
|
+
const assets = demos.reduce(
|
|
76
|
+
(ret, demo) => {
|
|
77
|
+
if ("asset" in demo)
|
|
78
|
+
ret.push(demo.asset);
|
|
79
|
+
return ret;
|
|
80
|
+
},
|
|
81
|
+
[]
|
|
82
|
+
);
|
|
70
83
|
(0, import_assets.addExampleAssets)(assets);
|
|
71
84
|
},
|
|
72
85
|
onResolveAtomMeta: import_assets.addAtomMeta
|
|
@@ -88,5 +101,3 @@ var compile_default = (api) => {
|
|
|
88
101
|
return memo;
|
|
89
102
|
});
|
|
90
103
|
};
|
|
91
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
92
|
-
0 && (module.exports = {});
|
|
@@ -32,9 +32,10 @@ var configPlugins_default = (api) => {
|
|
|
32
32
|
forceKebabCaseRouting: true
|
|
33
33
|
},
|
|
34
34
|
themeConfig: {
|
|
35
|
-
footer: `Copyright
|
|
35
|
+
footer: `Copyright © ${(/* @__PURE__ */ new Date()).getFullYear()} | Powered by <a href="https://d.umijs.org" target="_blank" rel="noreferrer">dumi</a>`,
|
|
36
36
|
prefersColor: { default: "light", switch: true },
|
|
37
|
-
nprogress: true
|
|
37
|
+
nprogress: true,
|
|
38
|
+
lastUpdated: true
|
|
38
39
|
}
|
|
39
40
|
};
|
|
40
41
|
const schemas = (0, import_schema.getSchemas)();
|
|
@@ -54,5 +55,3 @@ var configPlugins_default = (api) => {
|
|
|
54
55
|
]);
|
|
55
56
|
}
|
|
56
57
|
};
|
|
57
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
58
|
-
0 && (module.exports = {});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { IApi } from 'umi';
|
|
2
|
-
|
|
2
|
+
type JoiRoot = Parameters<NonNullable<NonNullable<Parameters<IApi['describe']>[0]['config']>['schema']>>[0];
|
|
3
3
|
export declare function getSchemas(): Record<string, (Joi: JoiRoot) => any>;
|
|
4
4
|
export {};
|
|
@@ -23,13 +23,30 @@ __export(schema_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(schema_exports);
|
|
25
25
|
function getUnifiedPluginSchema(Joi) {
|
|
26
|
-
return Joi.array().items(
|
|
26
|
+
return Joi.array().items(
|
|
27
|
+
Joi.alternatives(
|
|
28
|
+
Joi.string(),
|
|
29
|
+
Joi.func(),
|
|
30
|
+
Joi.array().items(Joi.alternatives(Joi.string(), Joi.func()), Joi.object()).length(2)
|
|
31
|
+
)
|
|
32
|
+
).optional();
|
|
27
33
|
}
|
|
28
34
|
function getSchemas() {
|
|
29
35
|
return {
|
|
30
36
|
resolve: (Joi) => Joi.object({
|
|
31
|
-
docDirs: Joi.array().items(
|
|
32
|
-
|
|
37
|
+
docDirs: Joi.array().items(
|
|
38
|
+
Joi.alternatives(
|
|
39
|
+
Joi.string(),
|
|
40
|
+
Joi.object({ dir: Joi.string(), type: Joi.string().optional() })
|
|
41
|
+
)
|
|
42
|
+
).optional(),
|
|
43
|
+
atomDirs: Joi.array().items(
|
|
44
|
+
Joi.object({
|
|
45
|
+
type: Joi.string(),
|
|
46
|
+
subType: Joi.string().optional(),
|
|
47
|
+
dir: Joi.string()
|
|
48
|
+
})
|
|
49
|
+
).optional(),
|
|
33
50
|
codeBlockMode: Joi.string().valid("active", "passive").optional(),
|
|
34
51
|
entryFile: Joi.string().optional(),
|
|
35
52
|
forceKebabCaseRouting: Joi.bool().optional()
|
|
@@ -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/derivative.ts
|
|
@@ -32,7 +39,13 @@ var import_fs = __toESM(require("fs"));
|
|
|
32
39
|
var import_path = __toESM(require("path"));
|
|
33
40
|
var import_plugin_utils = require("umi/plugin-utils");
|
|
34
41
|
function isMFSUAvailable(api) {
|
|
35
|
-
return
|
|
42
|
+
return (
|
|
43
|
+
// maybe not working on windows
|
|
44
|
+
process.platform !== "win32" && // allow user to disable mfsu
|
|
45
|
+
api.userConfig.mfsu !== false && // mfsu will interrupt 2-level esm for strip-ansi with unknown reason
|
|
46
|
+
// ref: https://github.com/umijs/dumi/issues/1587
|
|
47
|
+
api.pkg.type !== "module"
|
|
48
|
+
);
|
|
36
49
|
}
|
|
37
50
|
function safeExcludeInMFSU(api, excludes) {
|
|
38
51
|
if (isMFSUAvailable(api)) {
|
|
@@ -68,38 +81,63 @@ var derivative_default = (api) => {
|
|
|
68
81
|
(0, import_assert.default)(!api.config[key], `${key} is not supported yet!`);
|
|
69
82
|
});
|
|
70
83
|
if (typeof api.config.mfsu === "object") {
|
|
71
|
-
(0, import_assert.default)(
|
|
72
|
-
|
|
84
|
+
(0, import_assert.default)(
|
|
85
|
+
api.config.mfsu.strategy !== "eager",
|
|
86
|
+
"MFSU eager mode is not supported yet!"
|
|
87
|
+
);
|
|
88
|
+
(0, import_assert.default)(
|
|
89
|
+
api.config.mfsu.esbuild !== true,
|
|
90
|
+
"MFSU esbuild bundler is not supported yet!"
|
|
91
|
+
);
|
|
73
92
|
}
|
|
74
|
-
(0, import_assert.default)(
|
|
75
|
-
|
|
93
|
+
(0, import_assert.default)(
|
|
94
|
+
!api.config.ssr || api.config.ssr.builder === "webpack",
|
|
95
|
+
"Only `webpack` builder is supported in SSR mode!"
|
|
96
|
+
);
|
|
97
|
+
(0, import_assert.default)(
|
|
98
|
+
((_a = api.config.cssLoader) == null ? void 0 : _a.modules) === void 0 && api.config.cssLoaderModules === void 0,
|
|
99
|
+
"CSS Modules is not supported! Because it is not suitable for UI library development, please use normal CSS, Less, etc. instead."
|
|
100
|
+
);
|
|
76
101
|
if (api.userConfig.history && api.userConfig.history.type === "hash") {
|
|
77
|
-
import_plugin_utils.logger.warn(
|
|
102
|
+
import_plugin_utils.logger.warn(
|
|
103
|
+
"Hash history is temporarily incompatible, it is recommended to use browser history for now."
|
|
104
|
+
);
|
|
78
105
|
}
|
|
79
106
|
const { themeConfig } = api.config;
|
|
80
107
|
if (themeConfig == null ? void 0 : themeConfig.nav) {
|
|
81
108
|
const hasOrder = !!JSON.stringify(themeConfig.nav).includes('"order":');
|
|
82
109
|
if (hasOrder) {
|
|
83
|
-
import_plugin_utils.logger.warn(
|
|
110
|
+
import_plugin_utils.logger.warn(
|
|
111
|
+
`\`order\` is deprecated in \`themeConfig.nav\`, you can order them directly in config`
|
|
112
|
+
);
|
|
84
113
|
}
|
|
85
114
|
}
|
|
86
115
|
try {
|
|
87
116
|
const tsconfig = require(import_path.default.join(api.cwd, "tsconfig.json"));
|
|
88
117
|
const expected = [".dumi/**/*"];
|
|
89
118
|
if ((_c = (_b = api.service.configManager) == null ? void 0 : _b.mainConfigFile) == null ? void 0 : _c.endsWith(".ts")) {
|
|
90
|
-
expected.push(
|
|
119
|
+
expected.push(
|
|
120
|
+
(0, import_plugin_utils.winPath)(
|
|
121
|
+
import_path.default.relative(api.cwd, api.service.configManager.mainConfigFile)
|
|
122
|
+
)
|
|
123
|
+
);
|
|
91
124
|
}
|
|
92
125
|
if (!expected.every((f) => {
|
|
93
126
|
var _a2;
|
|
94
127
|
return (_a2 = tsconfig.include) == null ? void 0 : _a2.includes(f);
|
|
95
128
|
})) {
|
|
96
|
-
import_plugin_utils.logger.warn(
|
|
129
|
+
import_plugin_utils.logger.warn(
|
|
130
|
+
`Please append ${expected.map((e) => `\`${e}\``).join(
|
|
131
|
+
" & "
|
|
132
|
+
)} into \`include\` option of \`tsconfig.json\`, to make sure the types exported by framework works.`
|
|
133
|
+
);
|
|
97
134
|
}
|
|
98
135
|
} catch {
|
|
99
136
|
}
|
|
100
137
|
});
|
|
101
138
|
safeExcludeInMFSU(api, [
|
|
102
139
|
new RegExp("dumi/dist/client"),
|
|
140
|
+
// for useSiteSearch api
|
|
103
141
|
new RegExp("compiled/_internal/searchWorker")
|
|
104
142
|
]);
|
|
105
143
|
api.modifyDefaultConfig((memo) => {
|
|
@@ -131,7 +169,9 @@ var derivative_default = (api) => {
|
|
|
131
169
|
if ((_a = api.userConfig.alias) == null ? void 0 : _a["@"]) {
|
|
132
170
|
memo.alias["@"] = api.userConfig.alias["@"];
|
|
133
171
|
} else {
|
|
134
|
-
memo.alias["@"] = (0, import_plugin_utils.winPath)(
|
|
172
|
+
memo.alias["@"] = (0, import_plugin_utils.winPath)(
|
|
173
|
+
[import_path.default.join(api.cwd, "src"), api.cwd].find(import_fs.default.existsSync)
|
|
174
|
+
);
|
|
135
175
|
}
|
|
136
176
|
return memo;
|
|
137
177
|
});
|
|
@@ -141,6 +181,7 @@ var derivative_default = (api) => {
|
|
|
141
181
|
});
|
|
142
182
|
api.register({
|
|
143
183
|
key: "onGenerateFiles",
|
|
184
|
+
// make sure after umi generate files
|
|
144
185
|
stage: Infinity,
|
|
145
186
|
fn() {
|
|
146
187
|
import_constants.USELESS_TMP_FILES.forEach((file) => {
|
|
@@ -150,7 +191,9 @@ var derivative_default = (api) => {
|
|
|
150
191
|
});
|
|
151
192
|
api.registerPlugins([require.resolve("../../compiled/@umijs/plugins")]);
|
|
152
193
|
[
|
|
194
|
+
// skip prepare plugin since umi@4.0.48, because it is not compatible with dumi currently
|
|
153
195
|
"prepare",
|
|
196
|
+
// skip routeProps plugin since umi@4.0.53, because dumi support conventional route props by default
|
|
154
197
|
"routeProps"
|
|
155
198
|
].forEach((plugin) => {
|
|
156
199
|
if (api.isPluginEnable(plugin))
|
|
@@ -25,6 +25,8 @@ module.exports = __toCommonJS(exportStatic_exports);
|
|
|
25
25
|
var import_constants = require("../constants");
|
|
26
26
|
var import_assets = require("./assets");
|
|
27
27
|
var NO_PRERENDER_ROUTES = [
|
|
28
|
+
// disable prerender for demo render page, because umi-hd doesn't support ssr
|
|
29
|
+
// ref: https://github.com/umijs/dumi/pull/1451
|
|
28
30
|
"demo-render"
|
|
29
31
|
];
|
|
30
32
|
var exportStatic_default = (api) => {
|
|
@@ -33,6 +35,7 @@ var exportStatic_default = (api) => {
|
|
|
33
35
|
enableBy: ({ env }) => env === "production" && api.isPluginEnable("exportStatic")
|
|
34
36
|
});
|
|
35
37
|
api.modifyRoutes({
|
|
38
|
+
// make sure be the last
|
|
36
39
|
stage: Infinity,
|
|
37
40
|
fn(memo) {
|
|
38
41
|
NO_PRERENDER_ROUTES.forEach((id) => {
|
|
@@ -43,15 +46,18 @@ var exportStatic_default = (api) => {
|
|
|
43
46
|
}
|
|
44
47
|
});
|
|
45
48
|
api.modifyExportHTMLFiles({
|
|
49
|
+
// make sure before umi exportStatic
|
|
46
50
|
before: "exportStatic",
|
|
47
51
|
fn(memo) {
|
|
48
52
|
const routePrefix = `${import_constants.SP_ROUTE_PREFIX}demos`;
|
|
49
53
|
const examples = (0, import_assets.getExampleAssets)();
|
|
50
|
-
api.appData.exportHtmlData.push(
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
54
|
+
api.appData.exportHtmlData.push(
|
|
55
|
+
...examples.map(({ id }) => ({
|
|
56
|
+
route: { path: `/${routePrefix}/${id}` },
|
|
57
|
+
file: `${routePrefix}/${id}/index.html`,
|
|
58
|
+
prerender: false
|
|
59
|
+
}))
|
|
60
|
+
);
|
|
55
61
|
return memo;
|
|
56
62
|
}
|
|
57
63
|
});
|
|
@@ -75,5 +81,3 @@ export function modifyClientRenderOpts(memo: any) {
|
|
|
75
81
|
return [`@@/dumi/exportStaticRuntimePlugin.ts`];
|
|
76
82
|
});
|
|
77
83
|
};
|
|
78
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
79
|
-
0 && (module.exports = {});
|
package/dist/features/exports.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/exports.ts
|
|
@@ -41,5 +48,3 @@ export * from '${(0, import_plugin_utils.winPath)(require.resolve("../client/the
|
|
|
41
48
|
});
|
|
42
49
|
});
|
|
43
50
|
};
|
|
44
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
45
|
-
0 && (module.exports = {});
|
|
@@ -101,11 +101,13 @@ export const getSketchJSON = ${api.config.html2sketch ? `async (
|
|
|
101
101
|
`
|
|
102
102
|
});
|
|
103
103
|
});
|
|
104
|
-
api.addEntryImports(
|
|
104
|
+
api.addEntryImports(
|
|
105
|
+
() => api.config.html2sketch ? { source: "@@/plugin-html2sketch/msgExecutor" } : []
|
|
106
|
+
);
|
|
105
107
|
api.addHTMLHeadScripts(() => {
|
|
106
|
-
return api.config.html2sketch ? [api.config.html2sketch.scriptUrl || SCRIPT_URL] : [];
|
|
108
|
+
return api.config.html2sketch ? [{ src: api.config.html2sketch.scriptUrl || SCRIPT_URL, async: true }] : [];
|
|
107
109
|
});
|
|
108
|
-
api.addRuntimePluginKey(
|
|
110
|
+
api.addRuntimePluginKey(
|
|
111
|
+
() => api.config.html2sketch ? [RUNTIME_CONFIG] : []
|
|
112
|
+
);
|
|
109
113
|
};
|
|
110
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
111
|
-
0 && (module.exports = {});
|