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
|
@@ -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/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(
|
|
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(
|
|
70
|
-
|
|
71
|
-
|
|
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++);
|
|
@@ -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/loaders/markdown/transformer/remarkBreaks.ts
|
|
@@ -35,8 +42,14 @@ function logDeprecationWarning(fileAbsPath) {
|
|
|
35
42
|
if (warningLock.get(fileAbsPath))
|
|
36
43
|
return;
|
|
37
44
|
warningLock.set(fileAbsPath, true);
|
|
38
|
-
import_plugin_utils.logger.warn(
|
|
39
|
-
|
|
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
|
+
);
|
|
40
53
|
}
|
|
41
54
|
function remarkBreaks(opts) {
|
|
42
55
|
const replace = (_, match) => {
|
|
@@ -50,5 +63,3 @@ function remarkBreaks(opts) {
|
|
|
50
63
|
findAndReplace(tree, /\r?\n|\r/g, replace);
|
|
51
64
|
};
|
|
52
65
|
}
|
|
53
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
54
|
-
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/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(
|
|
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(
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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(
|
|
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(
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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(
|
|
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(
|
|
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(
|
|
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
|
-
|
|
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(
|
|
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.
|
|
41
|
-
const clearFileName = parsed.name
|
|
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(
|
|
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(
|
|
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(
|
|
78
|
-
|
|
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(
|
|
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(
|
|
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 = {});
|
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(
|
|
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 = {});
|
package/dist/registerMethods.js
CHANGED
package/dist/service/dev.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/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(
|
|
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 = {
|
package/dist/techStacks/react.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/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
|
-
|
|
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
|
-
|
|
14
|
+
type NoStringIndex<T> = {
|
|
15
15
|
[K in keyof T as string extends K ? never : K]: T[K];
|
|
16
16
|
};
|
|
17
|
-
|
|
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
|
|
43
|
-
export
|
|
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
|
|
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
|
|
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(
|
|
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
|
|
40
|
-
return import_plugin_utils.lodash.kebabCase((0, import_plugin_utils.winPath)(fsPath).replace(/((\/|^)index
|
|
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(
|
|
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
|
});
|