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.
Files changed (131) hide show
  1. package/compiled/crates/swc_plugin_react_demo.wasm +0 -0
  2. package/dist/assetParsers/atom.js +15 -5
  3. package/dist/assetParsers/block.js +27 -9
  4. package/dist/cli.js +8 -1
  5. package/dist/client/pages/Demo/index.js +3 -8
  6. package/dist/client/theme-api/AtomRenderer.d.ts +2 -2
  7. package/dist/client/theme-api/AtomRenderer.js +19 -35
  8. package/dist/client/theme-api/DumiDemo.js +8 -13
  9. package/dist/client/theme-api/DumiDemoGrid.js +12 -26
  10. package/dist/client/theme-api/DumiPage.js +16 -34
  11. package/dist/client/theme-api/openCodeSandbox.js +28 -26
  12. package/dist/client/theme-api/openStackBlitz.js +15 -16
  13. package/dist/client/theme-api/types.d.ts +15 -12
  14. package/dist/client/theme-api/useAtomAssets.js +1 -2
  15. package/dist/client/theme-api/useLocale.js +10 -19
  16. package/dist/client/theme-api/useNavData.js +78 -103
  17. package/dist/client/theme-api/usePrefersColor.d.ts +2 -2
  18. package/dist/client/theme-api/usePrefersColor.js +39 -66
  19. package/dist/client/theme-api/useRouteMeta.js +9 -23
  20. package/dist/client/theme-api/useSidebarData.js +124 -158
  21. package/dist/client/theme-api/useSiteSearch/index.d.ts +1 -1
  22. package/dist/client/theme-api/useSiteSearch/index.js +24 -38
  23. package/dist/client/theme-api/useTabMeta.js +8 -19
  24. package/dist/client/theme-api/utils.d.ts +6 -0
  25. package/dist/client/theme-api/utils.js +40 -46
  26. package/dist/client/typings.d.ts +0 -5
  27. package/dist/constants.d.ts +1 -0
  28. package/dist/constants.js +3 -0
  29. package/dist/features/assets.js +23 -4
  30. package/dist/features/autoAlias.js +8 -3
  31. package/dist/features/compile/babelLoaderCustomize.js +0 -2
  32. package/dist/features/compile/index.js +22 -10
  33. package/dist/features/configPlugins/index.js +3 -4
  34. package/dist/features/configPlugins/schema.d.ts +1 -1
  35. package/dist/features/configPlugins/schema.js +20 -3
  36. package/dist/features/derivative.js +54 -11
  37. package/dist/features/exportStatic.js +11 -7
  38. package/dist/features/exports.js +8 -3
  39. package/dist/features/html2sketch.js +7 -5
  40. package/dist/features/locales.js +53 -17
  41. package/dist/features/meta.js +23 -10
  42. package/dist/features/parser.js +17 -5
  43. package/dist/features/routes.js +63 -24
  44. package/dist/features/sideEffects/docSideEffectsWebpackPlugin.js +27 -16
  45. package/dist/features/sideEffects/index.js +13 -4
  46. package/dist/features/sitemap.js +17 -5
  47. package/dist/features/tabs.js +23 -11
  48. package/dist/features/theme/index.js +152 -39
  49. package/dist/features/theme/loader.js +23 -7
  50. package/dist/index.js +10 -2
  51. package/dist/loaders/demo/index.js +3 -3
  52. package/dist/loaders/markdown/index.d.ts +1 -1
  53. package/dist/loaders/markdown/index.js +36 -24
  54. package/dist/loaders/markdown/transformer/index.d.ts +4 -2
  55. package/dist/loaders/markdown/transformer/index.js +48 -19
  56. package/dist/loaders/markdown/transformer/rehypeDemo.d.ts +3 -1
  57. package/dist/loaders/markdown/transformer/rehypeDemo.js +125 -68
  58. package/dist/loaders/markdown/transformer/rehypeDesc.js +8 -3
  59. package/dist/loaders/markdown/transformer/rehypeEnhancedTag.js +8 -3
  60. package/dist/loaders/markdown/transformer/rehypeHighlightLine.js +8 -3
  61. package/dist/loaders/markdown/transformer/rehypeImg.js +8 -3
  62. package/dist/loaders/markdown/transformer/rehypeIsolation.js +36 -21
  63. package/dist/loaders/markdown/transformer/rehypeJsxify.js +8 -3
  64. package/dist/loaders/markdown/transformer/rehypeLink.d.ts +1 -1
  65. package/dist/loaders/markdown/transformer/rehypeLink.js +24 -9
  66. package/dist/loaders/markdown/transformer/rehypeRaw.d.ts +1 -1
  67. package/dist/loaders/markdown/transformer/rehypeRaw.js +20 -6
  68. package/dist/loaders/markdown/transformer/rehypeSlug.js +16 -3
  69. package/dist/loaders/markdown/transformer/rehypeStrip.js +8 -3
  70. package/dist/loaders/markdown/transformer/rehypeText.js +14 -5
  71. package/dist/loaders/markdown/transformer/remarkBreaks.d.ts +3 -0
  72. package/dist/loaders/markdown/transformer/remarkBreaks.js +65 -0
  73. package/dist/loaders/markdown/transformer/remarkContainer.js +28 -13
  74. package/dist/loaders/markdown/transformer/remarkEmbed.js +43 -21
  75. package/dist/loaders/markdown/transformer/remarkMeta.d.ts +3 -1
  76. package/dist/loaders/markdown/transformer/remarkMeta.js +39 -9
  77. package/dist/loaders/page/index.js +12 -4
  78. package/dist/loaders/pre-raw/index.js +0 -2
  79. package/dist/preset.js +8 -3
  80. package/dist/registerMethods.js +0 -2
  81. package/dist/service/dev.js +8 -1
  82. package/dist/service/printHelp.js +3 -1
  83. package/dist/techStacks/react.js +8 -3
  84. package/dist/types.d.ts +6 -6
  85. package/dist/utils.d.ts +1 -1
  86. package/dist/utils.js +15 -6
  87. package/package.json +12 -10
  88. package/theme-default/builtins/API/index.js +15 -36
  89. package/theme-default/builtins/Badge/index.js +0 -3
  90. package/theme-default/builtins/Container/index.js +6 -15
  91. package/theme-default/builtins/Previewer/index.js +1 -8
  92. package/theme-default/builtins/SourceCode/index.js +15 -27
  93. package/theme-default/builtins/Table/index.js +10 -25
  94. package/theme-default/builtins/Tree/index.js +13 -44
  95. package/theme-default/layouts/DocLayout/index.js +14 -27
  96. package/theme-default/locales/en-US.json +4 -0
  97. package/theme-default/locales/zh-CN.json +4 -0
  98. package/theme-default/slots/ColorSwitch/index.js +7 -22
  99. package/theme-default/slots/Content/index.js +5 -7
  100. package/theme-default/slots/Content/index.less +16 -1
  101. package/theme-default/slots/ContentFooter/index.d.ts +4 -0
  102. package/theme-default/slots/ContentFooter/index.js +93 -0
  103. package/theme-default/slots/ContentFooter/index.less +163 -0
  104. package/theme-default/slots/ContentTabs/index.d.ts +1 -1
  105. package/theme-default/slots/ContentTabs/index.js +5 -5
  106. package/theme-default/slots/Features/index.js +6 -11
  107. package/theme-default/slots/Footer/index.js +1 -4
  108. package/theme-default/slots/Header/index.js +7 -18
  109. package/theme-default/slots/HeaderExtra/index.js +0 -2
  110. package/theme-default/slots/Hero/index.js +2 -6
  111. package/theme-default/slots/HeroTitle/index.js +0 -2
  112. package/theme-default/slots/LangSwitch/index.js +23 -35
  113. package/theme-default/slots/Logo/index.js +1 -4
  114. package/theme-default/slots/Navbar/index.js +14 -29
  115. package/theme-default/slots/NavbarExtra/index.js +0 -2
  116. package/theme-default/slots/NotFound/index.js +0 -2
  117. package/theme-default/slots/PreviewerActions/index.js +13 -35
  118. package/theme-default/slots/PreviewerActionsExtra/index.js +0 -2
  119. package/theme-default/slots/RtlSwitch/index.js +6 -20
  120. package/theme-default/slots/RtlSwitch/index.less +5 -0
  121. package/theme-default/slots/SearchBar/Input.d.ts +1 -1
  122. package/theme-default/slots/SearchBar/Input.js +6 -5
  123. package/theme-default/slots/SearchBar/Mask.d.ts +1 -1
  124. package/theme-default/slots/SearchBar/Mask.js +0 -1
  125. package/theme-default/slots/SearchBar/index.js +20 -41
  126. package/theme-default/slots/SearchResult/index.d.ts +1 -1
  127. package/theme-default/slots/SearchResult/index.js +13 -36
  128. package/theme-default/slots/Sidebar/index.js +1 -4
  129. package/theme-default/slots/SocialIcon/index.d.ts +2 -2
  130. package/theme-default/slots/SocialIcon/index.js +1 -3
  131. package/theme-default/slots/Toc/index.js +12 -28
@@ -1,103 +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 _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; }
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
+
12
+ /**
13
+ * private instance, do not use it in your code
14
+ */
15
+ export var pluginManager;
16
+ export var setPluginManager = function setPluginManager(pm) {
17
+ pluginManager = pm;
18
+ };
18
19
  export var useLocaleDocRoutes = function useLocaleDocRoutes() {
19
20
  var intl = useIntl();
20
-
21
21
  var _useAppData = useAppData(),
22
- routes = _useAppData.routes;
23
-
22
+ routes = _useAppData.routes;
24
23
  var _useSiteData = useSiteData(),
25
- locales = _useSiteData.locales;
26
-
24
+ locales = _useSiteData.locales;
27
25
  var _useState = useState(function () {
28
- var reversedLocales = locales.slice().reverse();
29
- return Object.values(routes).reduce(function (ret, route) {
30
- var matched = reversedLocales.find(function (locale) {
31
- return 'suffix' in locale ? // suffix mode
32
- route.path.endsWith(locale.suffix) : // base mode
33
- route.path.startsWith(locale.base.slice(1));
34
- });
35
-
36
- if (route.parentId === 'DocLayout' && matched.id === intl.locale) {
37
- ret[route.id] = route;
38
- }
39
-
40
- return ret;
41
- }, {});
42
- }),
43
- _useState2 = _slicedToArray(_useState, 1),
44
- localeDocRoutes = _useState2[0];
45
-
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];
46
43
  return localeDocRoutes;
47
44
  };
45
+
48
46
  /**
49
47
  * 在 react 18 中需要新的 render 方式,这个函数用来处理不同的 jsx 模式。
50
48
  * @param version react version
51
49
  * @returns code string
52
50
  */
53
-
54
51
  export var genReactRenderCode = function genReactRenderCode(version) {
55
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 */";
56
-
57
53
  if (version.startsWith('18.') || version === 'latest') {
58
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 />);");
59
55
  }
60
-
61
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);");
62
57
  };
63
58
  export var useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;
59
+
64
60
  /**
65
61
  * common comparer for sidebar/nav items
66
62
  */
67
-
68
63
  export var useRouteDataComparer = function useRouteDataComparer() {
69
64
  var locale = useLocale();
70
65
  return useCallback(function (a, b) {
71
- return (// smaller before larger for all
72
- ('order' in a && 'order' in b ? a.order - b.order : 0) || ( // shallower before deeper for sidebar item
73
- 'link' in a && 'link' in b ? a.link.split('/').length - b.link.split('/').length : 0) || ( // shallower before deeper for sidebar leaf
74
- 'path' in a && 'path' in b ? a.path.split('/').length - b.path.split('/').length : 0) || ( // fallback to compare title (put non-title item at the end)
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)
75
74
  a.title ? a.title.localeCompare(b.title || '', locale.id) : -1)
76
75
  );
77
76
  }, []);
78
77
  };
78
+
79
79
  /**
80
80
  * common util for pick meta to sort sidebar/nav items
81
81
  */
82
-
83
82
  export var pickRouteSortMeta = function pickRouteSortMeta(original, field, fm) {
84
83
  var _sub$order;
85
-
86
84
  var sub = field === 'nav.second' ? _typeof(fm.nav) === 'object' ? fm.nav.second : {} : fm[field];
87
-
88
85
  switch (_typeof(sub)) {
89
86
  case 'object':
90
87
  original.title = sub.title || original.title;
91
88
  original.order = (_sub$order = sub.order) !== null && _sub$order !== void 0 ? _sub$order : original.order;
92
89
  break;
93
-
94
90
  case 'string':
95
91
  original.title = sub || original.title;
96
92
  break;
97
-
98
93
  default:
99
94
  }
100
-
101
95
  return original;
102
96
  };
103
97
  export function getLocaleNav(nav, locale) {
@@ -1,8 +1,3 @@
1
- declare module '*.less' {
2
- const classes: CSSModuleClasses;
3
- export default classes;
4
- }
5
-
6
1
  declare module '*.svg' {
7
2
  import * as React from 'react';
8
3
  export const ReactComponent: React.FunctionComponent<
@@ -16,3 +16,4 @@ export declare const PICKED_PKG_FIELDS: {
16
16
  };
17
17
  export declare const USELESS_TMP_FILES: string[];
18
18
  export declare const VERSION_2_LEVEL_NAV = "^2.2.0";
19
+ export declare const VERSION_2_DEPRECATE_SOFT_BREAKS = "^2.2.0";
package/dist/constants.js CHANGED
@@ -28,6 +28,7 @@ __export(constants_exports, {
28
28
  SP_ROUTE_PREFIX: () => SP_ROUTE_PREFIX,
29
29
  THEME_PREFIX: () => THEME_PREFIX,
30
30
  USELESS_TMP_FILES: () => USELESS_TMP_FILES,
31
+ VERSION_2_DEPRECATE_SOFT_BREAKS: () => VERSION_2_DEPRECATE_SOFT_BREAKS,
31
32
  VERSION_2_LEVEL_NAV: () => VERSION_2_LEVEL_NAV
32
33
  });
33
34
  module.exports = __toCommonJS(constants_exports);
@@ -49,6 +50,7 @@ var PICKED_PKG_FIELDS = {
49
50
  };
50
51
  var USELESS_TMP_FILES = ["tsconfig.json", "typings.d.ts"];
51
52
  var VERSION_2_LEVEL_NAV = "^2.2.0";
53
+ var VERSION_2_DEPRECATE_SOFT_BREAKS = "^2.2.0";
52
54
  // Annotate the CommonJS export names for ESM import in node:
53
55
  0 && (module.exports = {
54
56
  LOCAL_DUMI_DIR,
@@ -60,5 +62,6 @@ var VERSION_2_LEVEL_NAV = "^2.2.0";
60
62
  SP_ROUTE_PREFIX,
61
63
  THEME_PREFIX,
62
64
  USELESS_TMP_FILES,
65
+ VERSION_2_DEPRECATE_SOFT_BREAKS,
63
66
  VERSION_2_LEVEL_NAV
64
67
  });
@@ -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(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
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() : { components: {} };
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((atom) => Object.assign(atom, atomsMeta[atom.id] || {})),
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(import_path.default.join(api.cwd, "assets.json"), JSON.stringify(assets, null, 2), "utf-8");
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(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
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 = {});
@@ -33,5 +33,3 @@ function babelLoaderCustomize() {
33
33
  }
34
34
  };
35
35
  }
36
- // Annotate the CommonJS export names for ESM import in node:
37
- 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(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
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("Config `babelLoaderCustomize` will be override by dumi, please report issue if you need it.");
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;
@@ -55,17 +64,22 @@ var compile_default = (api) => {
55
64
  resolve: api.config.resolve,
56
65
  extraRemarkPlugins: api.config.extraRemarkPlugins,
57
66
  extraRehypePlugins: api.config.extraRehypePlugins,
58
- routes: api.appData.routes
67
+ routes: api.appData.routes,
68
+ locales: api.config.locales,
69
+ pkg: api.pkg
59
70
  };
60
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({
61
72
  ...loaderBaseOpts,
62
73
  mode: "meta",
63
74
  onResolveDemos(demos) {
64
- const assets = demos.reduce((ret, demo) => {
65
- if ("asset" in demo)
66
- ret.push(demo.asset);
67
- return ret;
68
- }, []);
75
+ const assets = demos.reduce(
76
+ (ret, demo) => {
77
+ if ("asset" in demo)
78
+ ret.push(demo.asset);
79
+ return ret;
80
+ },
81
+ []
82
+ );
69
83
  (0, import_assets.addExampleAssets)(assets);
70
84
  },
71
85
  onResolveAtomMeta: import_assets.addAtomMeta
@@ -87,5 +101,3 @@ var compile_default = (api) => {
87
101
  return memo;
88
102
  });
89
103
  };
90
- // Annotate the CommonJS export names for ESM import in node:
91
- 0 && (module.exports = {});
@@ -32,9 +32,10 @@ var configPlugins_default = (api) => {
32
32
  forceKebabCaseRouting: true
33
33
  },
34
34
  themeConfig: {
35
- footer: `Copyright \xA9 ${new Date().getFullYear()} | Powered by <a href="https://d.umijs.org" target="_blank" rel="noreferrer">dumi</a>`,
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
- declare type JoiRoot = Parameters<NonNullable<NonNullable<Parameters<IApi['describe']>[0]['config']>['schema']>>[0];
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(Joi.alternatives(Joi.string(), Joi.func(), Joi.array().items(Joi.alternatives(Joi.string(), Joi.func()), Joi.object()).length(2))).optional();
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(Joi.alternatives(Joi.string(), Joi.object({ dir: Joi.string(), type: Joi.string().optional() }))).optional(),
32
- atomDirs: Joi.array().items(Joi.object({ type: Joi.string(), dir: Joi.string() })).optional(),
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(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
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 process.platform !== "win32" && api.userConfig.mfsu !== false && api.pkg.type !== "module";
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)(api.config.mfsu.strategy !== "eager", "MFSU eager mode is not supported yet!");
72
- (0, import_assert.default)(api.config.mfsu.esbuild !== true, "MFSU esbuild bundler is not supported yet!");
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)(!api.config.ssr || api.config.ssr.builder === "webpack", "Only `webpack` builder is supported in SSR mode!");
75
- (0, import_assert.default)(((_a = api.config.cssLoader) == null ? void 0 : _a.modules) === void 0 && api.config.cssLoaderModules === void 0, "CSS Modules is not supported! Because it is not suitable for UI library development, please use normal CSS, Less, etc. instead.");
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("Hash history is temporarily incompatible, it is recommended to use browser history for now.");
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(`\`order\` is deprecated in \`themeConfig.nav\`, you can order them directly in config`);
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((0, import_plugin_utils.winPath)(import_path.default.relative(api.cwd, api.service.configManager.mainConfigFile)));
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(`Please append ${expected.map((e) => `\`${e}\``).join(" & ")} into \`include\` option of \`tsconfig.json\`, to make sure the types exported by framework works.`);
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)([import_path.default.join(api.cwd, "src"), api.cwd].find(import_fs.default.existsSync));
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(...examples.map(({ id }) => ({
51
- route: { path: `/${routePrefix}/${id}` },
52
- file: `${routePrefix}/${id}/index.html`,
53
- prerender: false
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 = {});
@@ -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(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
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(() => api.config.html2sketch ? { source: "@@/plugin-html2sketch/msgExecutor" } : []);
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(() => api.config.html2sketch ? [RUNTIME_CONFIG] : []);
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 = {});