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
@@ -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/loaders/markdown/transformer/rehypeStrip.ts
@@ -40,5 +47,3 @@ function rehypeStrip() {
40
47
  });
41
48
  };
42
49
  }
43
- // Annotate the CommonJS export names for ESM import in node:
44
- 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/loaders/markdown/transformer/rehypeText.ts
@@ -66,10 +73,12 @@ function rehypeText() {
66
73
  const titleNode = paraNode.type === "element" && findClosestTitle(ancestors, paraNode);
67
74
  let tocIndex = -1;
68
75
  if (titleNode) {
69
- tocIndex = vFile.data.toc.findIndex(({ id }) => {
70
- var _a2;
71
- return id === ((_a2 = titleNode.properties) == null ? void 0 : _a2.id);
72
- });
76
+ tocIndex = vFile.data.toc.findIndex(
77
+ ({ id }) => {
78
+ var _a2;
79
+ return id === ((_a2 = titleNode.properties) == null ? void 0 : _a2.id);
80
+ }
81
+ );
73
82
  }
74
83
  paraNode.data ?? (paraNode.data = {});
75
84
  (_a = paraNode.data).id ?? (_a.id = paraId++);
@@ -0,0 +1,3 @@
1
+ import type { IMdTransformerOptions } from "./index";
2
+ import type { Root } from 'mdast';
3
+ export default function remarkBreaks(opts: Pick<IMdTransformerOptions, 'fileAbsPath'>): (tree: Root) => void;
@@ -0,0 +1,65 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
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
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/loaders/markdown/transformer/remarkBreaks.ts
30
+ var remarkBreaks_exports = {};
31
+ __export(remarkBreaks_exports, {
32
+ default: () => remarkBreaks
33
+ });
34
+ module.exports = __toCommonJS(remarkBreaks_exports);
35
+ var import_plugin_utils = require("umi/plugin-utils");
36
+ var findAndReplace;
37
+ (async () => {
38
+ ({ findAndReplace } = await import("mdast-util-find-and-replace"));
39
+ })();
40
+ var warningLock = /* @__PURE__ */ new Map();
41
+ function logDeprecationWarning(fileAbsPath) {
42
+ if (warningLock.get(fileAbsPath))
43
+ return;
44
+ warningLock.set(fileAbsPath, true);
45
+ import_plugin_utils.logger.warn(
46
+ "Detected that you are using soft breaks, dumi will transform them into spaces after the declaration",
47
+ "version greater than or equal to `2.2.0`, however, they are still being transformed as line breaks now, please",
48
+ "migrate them to hard breaks before upgrading the declaration version for dumi.\n",
49
+ import_plugin_utils.chalk.grey(` at ${fileAbsPath}
50
+ `),
51
+ import_plugin_utils.chalk.grey(" see also: https://github.com/umijs/dumi/issues/1683\n")
52
+ );
53
+ }
54
+ function remarkBreaks(opts) {
55
+ const replace = (_, match) => {
56
+ if (match.input === "\n" || match.input === "\r" || match.input === "\r\n") {
57
+ return false;
58
+ }
59
+ logDeprecationWarning(opts.fileAbsPath);
60
+ return { type: "break" };
61
+ };
62
+ return (tree) => {
63
+ findAndReplace(tree, /\r?\n|\r/g, replace);
64
+ };
65
+ }
@@ -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/loaders/markdown/transformer/remarkContainer.ts
@@ -33,25 +40,33 @@ var VALID_CONTAINER_TYPES = ["info", "warning", "success", "error"];
33
40
  })();
34
41
  function remarkContainer() {
35
42
  const data = this.data();
36
- const micromarkExtensions = data.micromarkExtensions.find(({ flow, text }) => flow && "58" in flow && text && "58" in text);
43
+ const micromarkExtensions = data.micromarkExtensions.find(
44
+ ({ flow, text }) => flow && "58" in flow && text && "58" in text
45
+ );
37
46
  delete micromarkExtensions.text;
38
47
  micromarkExtensions.flow["58"].splice(1, 1);
39
48
  return (tree) => {
40
49
  visit(tree, (node, i, parent) => {
41
50
  if (node.type === "containerDirective" && VALID_CONTAINER_TYPES.includes(node.name)) {
42
- const attrs = Object.entries(node.attributes || {}).reduce((ret, [name, value]) => `${ret} ${value ? `${name}="${value}"` : name}`, "");
43
- parent.children.splice(i, 1, {
44
- type: "html",
45
- value: `<Container type="${node.name}"${attrs}>`,
46
- position: node.position
47
- }, ...(node.children || []).concat({
48
- type: "html",
49
- value: "</Container>"
50
- }));
51
+ const attrs = Object.entries(node.attributes || {}).reduce(
52
+ (ret, [name, value]) => `${ret} ${value ? `${name}="${value}"` : name}`,
53
+ ""
54
+ );
55
+ parent.children.splice(
56
+ i,
57
+ 1,
58
+ {
59
+ type: "html",
60
+ value: `<Container type="${node.name}"${attrs}>`,
61
+ position: node.position
62
+ },
63
+ ...(node.children || []).concat({
64
+ type: "html",
65
+ value: "</Container>"
66
+ })
67
+ );
51
68
  return SKIP;
52
69
  }
53
70
  });
54
71
  };
55
72
  }
56
- // Annotate the CommonJS export names for ESM import in node:
57
- 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/loaders/markdown/transformer/remarkEmbed.ts
@@ -54,29 +61,39 @@ function remarkReplaceSrc(opts) {
54
61
  return (0, import_plugin_utils.winPath)(import_path.default.relative(import_path.default.dirname(parentAbsPath), absPath)).replace(/^([^.])/, "./$1");
55
62
  }
56
63
  return (ast) => {
57
- visit(ast, ["html", "image", "link"], (node) => {
58
- switch (node.type) {
59
- case "html":
60
- if (/^<(code|img|a)[^>]+(src|href)=('|")\.\.?\//.test(node.value)) {
61
- node.value = node.value.replace(/(src|href)=("|')([^]+?)\2/, (_, tag, quote, value) => `${tag}=${quote}${getEmbedRltPath(value)}${quote}`);
62
- }
63
- break;
64
- case "image":
65
- case "link":
66
- if (/^\.\.?\//.test(node.url)) {
67
- node.url = getEmbedRltPath(node.url);
68
- }
69
- break;
70
- default:
64
+ visit(
65
+ ast,
66
+ ["html", "image", "link"],
67
+ (node) => {
68
+ switch (node.type) {
69
+ case "html":
70
+ if (/^<(code|img|a)[^>]+(src|href)=('|")\.\.?\//.test(node.value)) {
71
+ node.value = node.value.replace(
72
+ /(src|href)=("|')([^]+?)\2/,
73
+ (_, tag, quote, value) => `${tag}=${quote}${getEmbedRltPath(value)}${quote}`
74
+ );
75
+ }
76
+ break;
77
+ case "image":
78
+ case "link":
79
+ if (/^\.\.?\//.test(node.url)) {
80
+ node.url = getEmbedRltPath(node.url);
81
+ }
82
+ break;
83
+ default:
84
+ }
71
85
  }
72
- });
86
+ );
73
87
  };
74
88
  }
75
89
  function remarkRawAST() {
76
90
  this.Compiler = function Compiler(ast) {
77
91
  visit(ast, "yaml", (node, ancestors) => {
78
92
  const parent = ancestors[ancestors.length - 1];
79
- ancestors[ancestors.length - 1].children.splice(parent.children.indexOf(node), 1);
93
+ ancestors[ancestors.length - 1].children.splice(
94
+ parent.children.indexOf(node),
95
+ 1
96
+ );
80
97
  });
81
98
  return ast;
82
99
  };
@@ -99,7 +116,10 @@ function remarkEmbed(opts) {
99
116
  if (src) {
100
117
  const parsed = import_url.default.parse(src);
101
118
  const hash = decodeURIComponent(parsed.hash || "").replace("#", "");
102
- const absPath = resolver(import_path.default.dirname(opts.fileAbsPath), parsed.pathname);
119
+ const absPath = resolver(
120
+ import_path.default.dirname(opts.fileAbsPath),
121
+ parsed.pathname
122
+ );
103
123
  let content = import_fs.default.readFileSync(absPath, "utf-8");
104
124
  if (hash.startsWith("L")) {
105
125
  content = (0, import_utils.getFileRangeLines)(content, hash);
@@ -142,12 +162,14 @@ function remarkEmbed(opts) {
142
162
  children: after
143
163
  });
144
164
  }
145
- grandParent.children.splice(grandParent.children.indexOf(parent), 1, ...newParentNodes);
165
+ grandParent.children.splice(
166
+ grandParent.children.indexOf(parent),
167
+ 1,
168
+ ...newParentNodes
169
+ );
146
170
  vFile.data.embeds.push(...[absPath].concat(embeds));
147
171
  }
148
172
  }
149
173
  });
150
174
  };
151
175
  }
152
- // Annotate the CommonJS export names for ESM import in node:
153
- 0 && (module.exports = {});
@@ -1,6 +1,8 @@
1
1
  import type { Root } from 'mdast';
2
2
  import type { Transformer } from 'unified';
3
3
  import type { IMdTransformerOptions } from '.';
4
- declare type IRemarkMetaOpts = Pick<IMdTransformerOptions, 'cwd' | 'fileAbsPath' | 'resolve'>;
4
+ type IRemarkMetaOpts = Pick<IMdTransformerOptions, 'cwd' | 'fileAbsPath' | 'resolve'> & {
5
+ fileLocaleLessPath: string;
6
+ };
5
7
  export default function remarkMeta(opts: IRemarkMetaOpts): Transformer<Root>;
6
8
  export {};
@@ -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/loaders/markdown/transformer/remarkMeta.ts
@@ -26,6 +33,7 @@ __export(remarkMeta_exports, {
26
33
  });
27
34
  module.exports = __toCommonJS(remarkMeta_exports);
28
35
  var import_tabs = require("../../../features/tabs");
36
+ var import_child_process = require("child_process");
29
37
  var import_fs = __toESM(require("fs"));
30
38
  var import_js_yaml = __toESM(require("js-yaml"));
31
39
  var import_path = __toESM(require("path"));
@@ -37,13 +45,16 @@ var toString;
37
45
  ({ toString } = await import("mdast-util-to-string"));
38
46
  })();
39
47
  function getGuessAtomId(opts) {
40
- const parsed = import_path.default.parse(opts.fileAbsPath);
41
- const clearFileName = parsed.name.replace(/(?:\.$tab-[^.]+)?(?:\.[^.]+)?(\.[^.]+)$/, "$1");
48
+ const parsed = import_path.default.parse(opts.fileLocaleLessPath);
49
+ const clearFileName = (0, import_tabs.getHostForTabRouteFile)(parsed.name);
42
50
  const atomFile = [".tsx", ".jsx"].map((ext) => import_path.default.join(parsed.dir, `${clearFileName}${ext}`)).find(import_fs.default.existsSync);
43
51
  if (atomFile) {
44
52
  const atomAbsDir = opts.resolve.atomDirs.map(({ dir }) => import_path.default.resolve(opts.cwd, dir)).sort((a, b) => b.split("/").length - a.split("/").length).find((dir) => atomFile.startsWith(dir));
45
53
  if (atomAbsDir) {
46
- return (0, import_plugin_utils.winPath)(import_path.default.relative(atomAbsDir, atomFile)).replace(/((^|\/)index)?\.\w+$/, "");
54
+ return (0, import_plugin_utils.winPath)(import_path.default.relative(atomAbsDir, atomFile)).replace(
55
+ /((^|\/)index)?\.\w+$/,
56
+ ""
57
+ );
47
58
  }
48
59
  }
49
60
  }
@@ -56,6 +67,18 @@ function remarkMeta(opts) {
56
67
  filename: (0, import_plugin_utils.winPath)(import_path.default.relative(opts.cwd, opts.fileAbsPath)),
57
68
  ...guessAtomId && { atomId: guessAtomId }
58
69
  };
70
+ try {
71
+ vFile.data.frontmatter.lastUpdated = parseInt(
72
+ (0, import_child_process.execSync)(`git log -1 --format=%at ${opts.fileAbsPath}`, {
73
+ stdio: "pipe"
74
+ }).toString(),
75
+ 10
76
+ ) * 1e3;
77
+ } catch {
78
+ }
79
+ if (Number.isNaN(vFile.data.frontmatter.lastUpdated)) {
80
+ vFile.data.frontmatter.lastUpdated = +/* @__PURE__ */ new Date();
81
+ }
59
82
  visit(tree, "yaml", (node) => {
60
83
  try {
61
84
  Object.assign(vFile.data.frontmatter, import_js_yaml.default.load(node.value));
@@ -63,6 +86,7 @@ function remarkMeta(opts) {
63
86
  }
64
87
  });
65
88
  const titleReaders = [
89
+ // use first heading as title
66
90
  () => {
67
91
  visit(tree, "heading", (node) => {
68
92
  if (node.depth === 1) {
@@ -70,12 +94,20 @@ function remarkMeta(opts) {
70
94
  }
71
95
  });
72
96
  },
97
+ // use filename as title
73
98
  () => {
74
99
  if ((0, import_tabs.isTabRouteFile)(opts.fileAbsPath)) {
75
- vFile.data.frontmatter.title = import_plugin_utils.lodash.startCase((0, import_tabs.getTabKeyFromFile)(opts.fileAbsPath));
100
+ vFile.data.frontmatter.title = import_plugin_utils.lodash.startCase(
101
+ (0, import_tabs.getTabKeyFromFile)(opts.fileAbsPath)
102
+ );
76
103
  } else {
77
- const pathWithoutIndex = opts.fileAbsPath.replace(/(\/index([^/]+)?)?\.md$/, "");
78
- vFile.data.frontmatter.title = import_plugin_utils.lodash.startCase(import_path.default.basename(pathWithoutIndex));
104
+ const pathWithoutIndex = opts.fileAbsPath.replace(
105
+ /(\/index([^/]+)?)?\.md$/,
106
+ ""
107
+ );
108
+ vFile.data.frontmatter.title = import_plugin_utils.lodash.startCase(
109
+ import_path.default.basename(pathWithoutIndex)
110
+ );
79
111
  }
80
112
  }
81
113
  ];
@@ -84,5 +116,3 @@ function remarkMeta(opts) {
84
116
  }
85
117
  };
86
118
  }
87
- // Annotate the CommonJS export names for ESM import in node:
88
- 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/loaders/page/index.ts
@@ -29,7 +36,10 @@ var import_utils = require("../../utils");
29
36
  var import_path = __toESM(require("path"));
30
37
  var import_plugin_utils = require("umi/plugin-utils");
31
38
  function pageMetaLoader(raw) {
32
- const pathWithoutIndex = (0, import_plugin_utils.winPath)(this.resourcePath).replace(/(\/index([^/]+)?)?\.(j|t)sx?$/, "");
39
+ const pathWithoutIndex = (0, import_plugin_utils.winPath)(this.resourcePath).replace(
40
+ /(\/index([^/]+)?)?\.(j|t)sx?$/,
41
+ ""
42
+ );
33
43
  let { frontmatter } = (0, import_utils.parseCodeFrontmatter)(raw);
34
44
  frontmatter || (frontmatter = {});
35
45
  frontmatter.title ?? (frontmatter.title = import_plugin_utils.lodash.startCase(import_path.default.basename(pathWithoutIndex)));
@@ -38,5 +48,3 @@ export const toc = [];
38
48
  export const texts = [];
39
49
  export const demos = {};`;
40
50
  }
41
- // Annotate the CommonJS export names for ESM import in node:
42
- 0 && (module.exports = {});
@@ -29,5 +29,3 @@ function preRawLoader(raw) {
29
29
  }
30
30
  return raw;
31
31
  }
32
- // Annotate the CommonJS export names for ESM import in node:
33
- 0 && (module.exports = {});
package/dist/preset.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(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/preset.ts
@@ -49,5 +56,3 @@ var preset_default = (api) => {
49
56
  ]
50
57
  };
51
58
  };
52
- // Annotate the CommonJS export names for ESM import in node:
53
- 0 && (module.exports = {});
@@ -33,5 +33,3 @@ var registerMethods_default = (api) => {
33
33
  api.registerMethod({ name });
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/service/dev.ts
@@ -29,7 +29,9 @@ function printHelp() {
29
29
  import_plugin_utils.logger.fatal("A complete log of this run can be found in:");
30
30
  import_plugin_utils.logger.fatal(loggerPath);
31
31
  }
32
- import_plugin_utils.logger.fatal("Consider reporting a GitHub issue on https://github.com/umijs/dumi/issues");
32
+ import_plugin_utils.logger.fatal(
33
+ "Consider reporting a GitHub issue on https://github.com/umijs/dumi/issues"
34
+ );
33
35
  }
34
36
  // Annotate the CommonJS export names for ESM import in node:
35
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/techStacks/react.ts
@@ -65,5 +72,3 @@ ${code}
65
72
  return raw;
66
73
  }
67
74
  };
68
- // Annotate the CommonJS export names for ESM import in node:
69
- 0 && (module.exports = {});
package/dist/types.d.ts CHANGED
@@ -8,13 +8,13 @@ import type { IModify } from '@umijs/core';
8
8
  import type { AssetsPackage, ExampleBlockAsset } from 'dumi-assets-types';
9
9
  import type { Element } from 'hast';
10
10
  import type { defineConfig as defineUmiConfig, IApi as IUmiApi } from 'umi';
11
- declare type Subset<K> = {
11
+ type Subset<K> = {
12
12
  [attr in keyof K]?: K[attr] extends Array<any> ? K[attr] : K[attr] extends Function | undefined ? K[attr] : K[attr] extends object ? Subset<K[attr]> : K[attr] extends object | null ? Subset<K[attr]> | null : K[attr] extends object | null | undefined ? Subset<K[attr]> | null | undefined : K[attr];
13
13
  };
14
- declare type NoStringIndex<T> = {
14
+ type NoStringIndex<T> = {
15
15
  [K in keyof T as string extends K ? never : K]: T[K];
16
16
  };
17
- declare type IUmiConfig = Omit<NoStringIndex<Parameters<typeof defineUmiConfig>[0]>, 'resolve' | 'extraRemarkPlugins' | 'extraRehypePlugins' | 'themeConfig'>;
17
+ type IUmiConfig = Omit<NoStringIndex<Parameters<typeof defineUmiConfig>[0]>, 'resolve' | 'extraRemarkPlugins' | 'extraRehypePlugins' | 'themeConfig'>;
18
18
  interface IDumiExtendsConfig {
19
19
  resolve: {
20
20
  docDirs: (string | {
@@ -39,8 +39,8 @@ interface IDumiExtendsConfig {
39
39
  extraRemarkPlugins?: (string | Function | [string | Function, object])[];
40
40
  extraRehypePlugins?: (string | Function | [string | Function, object])[];
41
41
  }
42
- export declare type IDumiConfig = IUmiConfig & IDumiExtendsConfig;
43
- export declare type IDumiUserConfig = Subset<Omit<IDumiConfig, 'locales'>> & {
42
+ export type IDumiConfig = Omit<IUmiConfig, 'locales'> & IDumiExtendsConfig;
43
+ export type IDumiUserConfig = Subset<Omit<IDumiConfig, 'locales'>> & {
44
44
  locales?: Exclude<IDumiConfig['locales'][0], {
45
45
  base: string;
46
46
  }>[] | Omit<Exclude<IDumiConfig['locales'][0], {
@@ -82,7 +82,7 @@ export declare abstract class IDumiTechStack {
82
82
  */
83
83
  abstract generateSources?(sources: IParsedBlockAsset['sources'], opts: Parameters<NonNullable<IDumiTechStack['generateMetadata']>>[1]): Promise<IParsedBlockAsset['sources']> | IParsedBlockAsset['sources'];
84
84
  }
85
- export declare type IApi = IUmiApi & {
85
+ export type IApi = IUmiApi & {
86
86
  config: IDumiConfig & {
87
87
  [key: string]: any;
88
88
  };
package/dist/utils.d.ts CHANGED
@@ -2,7 +2,7 @@ import Cache from 'file-system-cache';
2
2
  /**
3
3
  * get route path from file-system path
4
4
  */
5
- export declare function getRoutePathFromFsPath(fsPath: string): string;
5
+ export declare function getFileIdFromFsPath(fsPath: string): string;
6
6
  /**
7
7
  * get range lines of markdown file
8
8
  */
package/dist/utils.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(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/utils.ts
@@ -24,9 +31,9 @@ var utils_exports = {};
24
31
  __export(utils_exports, {
25
32
  getCache: () => getCache,
26
33
  getFileContentByRegExp: () => getFileContentByRegExp,
34
+ getFileIdFromFsPath: () => getFileIdFromFsPath,
27
35
  getFileRangeLines: () => getFileRangeLines,
28
36
  getProjectRoot: () => getProjectRoot,
29
- getRoutePathFromFsPath: () => getRoutePathFromFsPath,
30
37
  parseCodeFrontmatter: () => parseCodeFrontmatter,
31
38
  tryFatherBuildConfigs: () => tryFatherBuildConfigs
32
39
  });
@@ -36,8 +43,8 @@ var import_fs = __toESM(require("fs"));
36
43
  var import_js_yaml = __toESM(require("js-yaml"));
37
44
  var import_path = __toESM(require("path"));
38
45
  var import_plugin_utils = require("umi/plugin-utils");
39
- function getRoutePathFromFsPath(fsPath) {
40
- return import_plugin_utils.lodash.kebabCase((0, import_plugin_utils.winPath)(fsPath).replace(/((\/|^)index(\.[a-zA-Z-]+)?)?\.\w+$/g, ""));
46
+ function getFileIdFromFsPath(fsPath) {
47
+ return import_plugin_utils.lodash.kebabCase((0, import_plugin_utils.winPath)(fsPath).replace(/((\/|^)index)?\.\w+$/g, ""));
41
48
  }
42
49
  var getFileRangeLines = (content2, range) => {
43
50
  const [, start, end] = (range == null ? void 0 : range.match(/^L(\d+)(?:-L(\d+))?$/)) || [];
@@ -111,7 +118,9 @@ function getProjectRoot(cwd) {
111
118
  if (!rootCwd)
112
119
  break;
113
120
  const pkgPath = import_path.default.join(rootCwd, "package.json");
114
- if (import_fs.default.existsSync(pkgPath) && (["pnpm-workspace.yaml", "lerna.json"].some((f) => import_fs.default.existsSync(import_path.default.join(rootCwd, f))) || require(pkgPath).workspace)) {
121
+ if (import_fs.default.existsSync(pkgPath) && (["pnpm-workspace.yaml", "lerna.json"].some(
122
+ (f) => import_fs.default.existsSync(import_path.default.join(rootCwd, f))
123
+ ) || require(pkgPath).workspace)) {
115
124
  return (0, import_plugin_utils.winPath)(rootCwd);
116
125
  }
117
126
  }
@@ -121,9 +130,9 @@ function getProjectRoot(cwd) {
121
130
  0 && (module.exports = {
122
131
  getCache,
123
132
  getFileContentByRegExp,
133
+ getFileIdFromFsPath,
124
134
  getFileRangeLines,
125
135
  getProjectRoot,
126
- getRoutePathFromFsPath,
127
136
  parseCodeFrontmatter,
128
137
  tryFatherBuildConfigs
129
138
  });