dumi 2.0.0-beta.6 → 2.0.0-beta.8
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/dist/client/theme-api/DumiDemo.js +1 -0
- package/dist/client/theme-api/DumiPage.js +24 -4
- package/dist/client/theme-api/context.d.ts +3 -0
- package/dist/client/theme-api/context.js +1 -0
- package/dist/client/theme-api/index.d.ts +2 -0
- package/dist/client/theme-api/index.js +3 -1
- package/dist/client/theme-api/types.d.ts +34 -3
- package/dist/client/theme-api/useRouteMeta.js +4 -3
- package/dist/client/theme-api/useSiteSearch.d.ts +23 -0
- package/dist/client/theme-api/useSiteSearch.js +331 -0
- package/dist/client/theme-api/useTabMeta.d.ts +4 -0
- package/dist/client/theme-api/useTabMeta.js +47 -0
- package/dist/constants.d.ts +9 -0
- package/dist/constants.js +11 -0
- package/dist/features/compile.js +6 -1
- package/dist/features/configPlugins/index.js +1 -1
- package/dist/features/configPlugins/schema.js +2 -1
- package/dist/features/exports.d.ts +5 -0
- package/dist/features/exports.js +23 -2
- package/dist/features/meta.js +43 -22
- package/dist/features/parser.js +9 -4
- package/dist/features/routes.js +9 -9
- package/dist/features/tabs.js +3 -3
- package/dist/features/theme/index.js +8 -2
- package/dist/loaders/markdown/index.d.ts +1 -1
- package/dist/loaders/markdown/index.js +69 -45
- package/dist/loaders/markdown/transformer/index.d.ts +9 -5
- package/dist/loaders/markdown/transformer/index.js +6 -6
- package/dist/loaders/markdown/transformer/rehypeDemo.js +13 -5
- package/dist/loaders/markdown/transformer/rehypeEnhancedTag.js +6 -1
- package/dist/loaders/markdown/transformer/rehypeImg.d.ts +6 -0
- package/dist/loaders/markdown/transformer/rehypeImg.js +57 -0
- package/dist/loaders/markdown/transformer/rehypeJsxify.js +17 -1
- package/dist/loaders/markdown/transformer/rehypeSlug.d.ts +2 -2
- package/dist/loaders/markdown/transformer/rehypeSlug.js +21 -57
- package/dist/loaders/markdown/transformer/rehypeText.d.ts +4 -0
- package/dist/loaders/markdown/transformer/rehypeText.js +110 -0
- package/dist/loaders/markdown/transformer/remarkEmbed.d.ts +4 -0
- package/dist/loaders/markdown/transformer/remarkEmbed.js +89 -0
- package/dist/loaders/page/index.js +1 -0
- package/dist/types.d.ts +8 -1
- package/dist/utils.d.ts +7 -0
- package/dist/utils.js +16 -0
- package/package.json +12 -11
- package/theme-default/builtins/Previewer/index.js +1 -0
- package/theme-default/layouts/DocLayout/index.js +3 -1
- package/theme-default/layouts/DocLayout/index.less +9 -4
- package/theme-default/locales/en-US.json +2 -1
- package/theme-default/locales/zh-CN.json +2 -1
- package/theme-default/slots/ContentTabs/index.d.ts +1 -1
- package/theme-default/slots/ContentTabs/index.js +1 -1
- package/theme-default/slots/Features/index.d.ts +4 -0
- package/theme-default/slots/Features/index.js +28 -0
- package/theme-default/slots/Features/index.less +49 -0
- package/theme-default/slots/Header/index.js +9 -2
- package/theme-default/slots/Header/index.less +18 -10
- package/theme-default/slots/Hero/index.d.ts +4 -0
- package/theme-default/slots/Hero/index.js +35 -0
- package/theme-default/slots/Hero/index.less +65 -0
- package/theme-default/slots/HeroTitle/index.d.ts +6 -0
- package/theme-default/slots/HeroTitle/index.js +10 -0
- package/theme-default/slots/HeroTitle/index.less +23 -0
- package/theme-default/slots/SearchBar/index.js +69 -9
- package/theme-default/slots/SearchBar/index.less +37 -4
- package/theme-default/slots/SearchResult/index.d.ts +9 -0
- package/theme-default/slots/SearchResult/index.js +168 -0
- package/theme-default/slots/SearchResult/index.less +119 -0
- package/dist/loaders/markdown/transformer/rehypeEmbed.d.ts +0 -12
- package/dist/loaders/markdown/transformer/rehypeEmbed.js +0 -87
|
@@ -0,0 +1,57 @@
|
|
|
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(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
+
|
|
22
|
+
// src/loaders/markdown/transformer/rehypeImg.ts
|
|
23
|
+
var rehypeImg_exports = {};
|
|
24
|
+
__export(rehypeImg_exports, {
|
|
25
|
+
default: () => rehypeImg
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(rehypeImg_exports);
|
|
28
|
+
var import_path = __toESM(require("path"));
|
|
29
|
+
var visit;
|
|
30
|
+
(async () => {
|
|
31
|
+
({ visit } = await import("unist-util-visit"));
|
|
32
|
+
})();
|
|
33
|
+
function isRelativeUrl(url) {
|
|
34
|
+
return !/^((blob:)?\w+:)?\/\//.test(url) && !import_path.default.isAbsolute(url);
|
|
35
|
+
}
|
|
36
|
+
function rehypeImg() {
|
|
37
|
+
return (tree) => {
|
|
38
|
+
visit(tree, "element", (node) => {
|
|
39
|
+
var _a;
|
|
40
|
+
if (node.tagName === "img" && typeof ((_a = node.properties) == null ? void 0 : _a.src) === "string") {
|
|
41
|
+
const src = node.properties.src.trim();
|
|
42
|
+
if (isRelativeUrl(src)) {
|
|
43
|
+
delete node.properties.src;
|
|
44
|
+
node.JSXAttributes = [
|
|
45
|
+
{
|
|
46
|
+
type: "JSXAttribute",
|
|
47
|
+
name: "src",
|
|
48
|
+
value: `require('${decodeURI(src)}')`
|
|
49
|
+
}
|
|
50
|
+
];
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
57
|
+
0 && (module.exports = {});
|
|
@@ -59,7 +59,23 @@ function rehypeJsxify() {
|
|
|
59
59
|
}
|
|
60
60
|
});
|
|
61
61
|
});
|
|
62
|
-
const esTree = toEstree(ast
|
|
62
|
+
const esTree = toEstree(ast, {
|
|
63
|
+
handlers: {
|
|
64
|
+
text: function text(node) {
|
|
65
|
+
var _a;
|
|
66
|
+
const value = String(node.value || "");
|
|
67
|
+
if (!value)
|
|
68
|
+
return null;
|
|
69
|
+
return {
|
|
70
|
+
type: "JSXExpressionContainer",
|
|
71
|
+
expression: ((_a = node.data) == null ? void 0 : _a.expression) || {
|
|
72
|
+
type: "Literal",
|
|
73
|
+
value
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
});
|
|
63
79
|
visitEstree(esTree, (node) => {
|
|
64
80
|
var _a, _b;
|
|
65
81
|
const isStubJSXAttr = node.type === "JSXAttribute" && "name" in node && String(node.name.name).startsWith(JSX_PROP_PREFIX);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { Root } from 'hast';
|
|
2
2
|
import type { Transformer } from 'unified';
|
|
3
|
-
|
|
4
|
-
export default function rehypeSlug(
|
|
3
|
+
export declare const HEADING_TAGS: string[];
|
|
4
|
+
export default function rehypeSlug(): Transformer<Root>;
|
|
@@ -22,84 +22,48 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
22
22
|
// src/loaders/markdown/transformer/rehypeSlug.ts
|
|
23
23
|
var rehypeSlug_exports = {};
|
|
24
24
|
__export(rehypeSlug_exports, {
|
|
25
|
+
HEADING_TAGS: () => HEADING_TAGS,
|
|
25
26
|
default: () => rehypeSlug
|
|
26
27
|
});
|
|
27
28
|
module.exports = __toCommonJS(rehypeSlug_exports);
|
|
28
|
-
var import_utils = require("../../../utils");
|
|
29
|
-
var import_fs = __toESM(require("fs"));
|
|
30
29
|
var import_github_slugger = __toESM(require("github-slugger"));
|
|
31
|
-
var import__ = __toESM(require("."));
|
|
32
30
|
var import_rehypeDemo = require("./rehypeDemo");
|
|
33
|
-
var import_rehypeEmbed = require("./rehypeEmbed");
|
|
34
31
|
var visit;
|
|
35
32
|
var toString;
|
|
36
|
-
var sharedSluggers = /* @__PURE__ */ new Map();
|
|
37
|
-
function getFileSlugger(fileAbsPath, parentAbsPath) {
|
|
38
|
-
if (parentAbsPath)
|
|
39
|
-
return sharedSluggers.get(parentAbsPath);
|
|
40
|
-
const slugger = new import_github_slugger.default();
|
|
41
|
-
sharedSluggers.set(fileAbsPath, slugger);
|
|
42
|
-
return slugger;
|
|
43
|
-
}
|
|
44
33
|
(async () => {
|
|
45
34
|
({ visit } = await import("unist-util-visit"));
|
|
46
35
|
({ toString } = await import("hast-util-to-string"));
|
|
47
36
|
})();
|
|
48
37
|
var HEADING_TAGS = ["h1", "h2", "h3", "h4", "h5", "h6"];
|
|
49
|
-
function rehypeSlug(
|
|
38
|
+
function rehypeSlug() {
|
|
50
39
|
return async (tree, vFile) => {
|
|
51
|
-
const
|
|
52
|
-
const slugger = getFileSlugger(pathWithRandom, opts.parentAbsPath);
|
|
53
|
-
const deferrers = [];
|
|
40
|
+
const slugger = new import_github_slugger.default();
|
|
54
41
|
vFile.data.toc = [];
|
|
55
42
|
visit(tree, "element", (node) => {
|
|
56
|
-
var _a, _b
|
|
43
|
+
var _a, _b;
|
|
57
44
|
if (HEADING_TAGS.includes(node.tagName)) {
|
|
58
45
|
const title = toString(node);
|
|
59
46
|
const depth = Number(node.tagName.slice(1));
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
const {
|
|
75
|
-
meta: { toc }
|
|
76
|
-
} = await (0, import__.default)(content, {
|
|
77
|
-
...opts,
|
|
78
|
-
parentAbsPath: opts.parentAbsPath || pathWithRandom
|
|
79
|
-
});
|
|
80
|
-
vFile.data.toc.push(...toc);
|
|
81
|
-
});
|
|
82
|
-
} else if ([import_rehypeDemo.DUMI_DEMO_TAG, import_rehypeDemo.DUMI_DEMO_GRID_TAG].includes(node.tagName) && ((_b = node.data) == null ? void 0 : _b[import_rehypeDemo.DEMO_PROP_VALUE_KEY])) {
|
|
83
|
-
const demos = [].concat((_c = node.data) == null ? void 0 : _c[import_rehypeDemo.DEMO_PROP_VALUE_KEY]);
|
|
84
|
-
deferrers.push(() => {
|
|
85
|
-
demos.forEach(({ demo, previewerProps }) => {
|
|
86
|
-
var _a2, _b2;
|
|
87
|
-
if (!demo.inline && previewerProps.title) {
|
|
88
|
-
vFile.data.toc.push({
|
|
89
|
-
id: slugger.slug(demo.id),
|
|
90
|
-
depth: ((_b2 = (_a2 = vFile.data.frontmatter) == null ? void 0 : _a2.demo) == null ? void 0 : _b2.tocDepth) || 3,
|
|
91
|
-
title: previewerProps.title
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
});
|
|
47
|
+
const id = slugger.slug(title);
|
|
48
|
+
node.properties.id = id;
|
|
49
|
+
vFile.data.toc.push({ id, depth, title });
|
|
50
|
+
} else if ([import_rehypeDemo.DUMI_DEMO_TAG, import_rehypeDemo.DUMI_DEMO_GRID_TAG].includes(node.tagName) && ((_a = node.data) == null ? void 0 : _a[import_rehypeDemo.DEMO_PROP_VALUE_KEY])) {
|
|
51
|
+
const demos = [].concat((_b = node.data) == null ? void 0 : _b[import_rehypeDemo.DEMO_PROP_VALUE_KEY]);
|
|
52
|
+
demos.forEach(({ demo, previewerProps }) => {
|
|
53
|
+
var _a2, _b2;
|
|
54
|
+
if (!demo.inline && previewerProps.title) {
|
|
55
|
+
vFile.data.toc.push({
|
|
56
|
+
id: slugger.slug(demo.id),
|
|
57
|
+
depth: ((_b2 = (_a2 = vFile.data.frontmatter) == null ? void 0 : _a2.demo) == null ? void 0 : _b2.tocDepth) || 3,
|
|
58
|
+
title: previewerProps.title
|
|
59
|
+
});
|
|
60
|
+
}
|
|
95
61
|
});
|
|
96
62
|
}
|
|
97
63
|
});
|
|
98
|
-
for (let deferrer of deferrers) {
|
|
99
|
-
await deferrer();
|
|
100
|
-
}
|
|
101
|
-
sharedSluggers.delete(pathWithRandom);
|
|
102
64
|
};
|
|
103
65
|
}
|
|
104
66
|
// Annotate the CommonJS export names for ESM import in node:
|
|
105
|
-
0 && (module.exports = {
|
|
67
|
+
0 && (module.exports = {
|
|
68
|
+
HEADING_TAGS
|
|
69
|
+
});
|
|
@@ -0,0 +1,110 @@
|
|
|
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(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
+
|
|
22
|
+
// src/loaders/markdown/transformer/rehypeText.ts
|
|
23
|
+
var rehypeText_exports = {};
|
|
24
|
+
__export(rehypeText_exports, {
|
|
25
|
+
CONTENT_TEXTS_OBJ_NAME: () => CONTENT_TEXTS_OBJ_NAME,
|
|
26
|
+
default: () => rehypeText
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(rehypeText_exports);
|
|
29
|
+
var import_rehypeSlug = require("./rehypeSlug");
|
|
30
|
+
var CONTENT_TEXTS_OBJ_NAME = "$$contentTexts";
|
|
31
|
+
var visit;
|
|
32
|
+
(async () => {
|
|
33
|
+
({ visitParents: visit } = await import("unist-util-visit-parents"));
|
|
34
|
+
})();
|
|
35
|
+
function findParagraphAncestor(ancestors) {
|
|
36
|
+
for (let i = ancestors.length - 1; i >= 0; i--) {
|
|
37
|
+
const node = ancestors[i];
|
|
38
|
+
if (node.type === "element" && node.tagName === "p" || node.type === "root") {
|
|
39
|
+
return node;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function findClosestTitle(ancestors, node) {
|
|
44
|
+
for (let i = ancestors.length - 1; i >= 0; i--) {
|
|
45
|
+
const parent = ancestors[i];
|
|
46
|
+
const current = ancestors[i + 1] || node;
|
|
47
|
+
for (let i2 = parent.children.indexOf(current) - 1; i2 >= 0; i2 -= 1) {
|
|
48
|
+
const child = parent.children[i2];
|
|
49
|
+
if (child.type === "element" && import_rehypeSlug.HEADING_TAGS.includes(child.tagName)) {
|
|
50
|
+
return child;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function rehypeText() {
|
|
56
|
+
return (tree, vFile) => {
|
|
57
|
+
let textId = 0;
|
|
58
|
+
let paraId = 0;
|
|
59
|
+
vFile.data.texts = [];
|
|
60
|
+
visit(tree, "text", (node, ancestors) => {
|
|
61
|
+
var _a, _b, _c;
|
|
62
|
+
const parent = ancestors[ancestors.length - 1];
|
|
63
|
+
if (parent.type !== "element" || !import_rehypeSlug.HEADING_TAGS.includes(parent.tagName)) {
|
|
64
|
+
const paraNode = findParagraphAncestor(ancestors);
|
|
65
|
+
const titleNode = paraNode.type === "element" && findClosestTitle(ancestors, paraNode);
|
|
66
|
+
let tocIndex = -1;
|
|
67
|
+
if (titleNode) {
|
|
68
|
+
tocIndex = vFile.data.toc.findIndex(({ id }) => {
|
|
69
|
+
var _a2;
|
|
70
|
+
return id === ((_a2 = titleNode.properties) == null ? void 0 : _a2.id);
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
paraNode.data ?? (paraNode.data = {});
|
|
74
|
+
(_a = paraNode.data).id ?? (_a.id = paraId++);
|
|
75
|
+
node.data = {
|
|
76
|
+
expression: {
|
|
77
|
+
type: "MemberExpression",
|
|
78
|
+
start: (_b = node.position) == null ? void 0 : _b.start,
|
|
79
|
+
end: (_c = node.position) == null ? void 0 : _c.end,
|
|
80
|
+
object: {
|
|
81
|
+
type: "MemberExpression",
|
|
82
|
+
computed: true,
|
|
83
|
+
object: {
|
|
84
|
+
type: "Identifier",
|
|
85
|
+
name: CONTENT_TEXTS_OBJ_NAME
|
|
86
|
+
},
|
|
87
|
+
property: {
|
|
88
|
+
type: "Literal",
|
|
89
|
+
value: textId++
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
property: {
|
|
93
|
+
type: "Identifier",
|
|
94
|
+
name: "value"
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
vFile.data.texts.push({
|
|
99
|
+
value: node.value,
|
|
100
|
+
paraId: paraNode.data.id,
|
|
101
|
+
...tocIndex > -1 ? { tocIndex } : {}
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
108
|
+
0 && (module.exports = {
|
|
109
|
+
CONTENT_TEXTS_OBJ_NAME
|
|
110
|
+
});
|
|
@@ -0,0 +1,89 @@
|
|
|
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(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
+
|
|
22
|
+
// src/loaders/markdown/transformer/remarkEmbed.ts
|
|
23
|
+
var remarkEmbed_exports = {};
|
|
24
|
+
__export(remarkEmbed_exports, {
|
|
25
|
+
default: () => remarkEmbed
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(remarkEmbed_exports);
|
|
28
|
+
var import_utils = require("../../../utils");
|
|
29
|
+
var import_fs = __toESM(require("fs"));
|
|
30
|
+
var import_path = __toESM(require("path"));
|
|
31
|
+
var import_plugin_utils = require("umi/plugin-utils");
|
|
32
|
+
var import_url = __toESM(require("url"));
|
|
33
|
+
var EMBED_OPEN_TAG = "<embed ";
|
|
34
|
+
var EMBED_CLOSE_TAG = "</embed>";
|
|
35
|
+
var unified;
|
|
36
|
+
var remarkParse;
|
|
37
|
+
var remarkFrontmatter;
|
|
38
|
+
var visit;
|
|
39
|
+
(async () => {
|
|
40
|
+
({ visit } = await import("unist-util-visit"));
|
|
41
|
+
({ unified } = await import("unified"));
|
|
42
|
+
({ default: remarkParse } = await import("remark-parse"));
|
|
43
|
+
({ default: remarkFrontmatter } = await import("remark-frontmatter"));
|
|
44
|
+
})();
|
|
45
|
+
function remarkRawAST() {
|
|
46
|
+
this.Compiler = function Compiler(ast) {
|
|
47
|
+
return ast;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function remarkEmbed(opts) {
|
|
51
|
+
return (tree, vFile) => {
|
|
52
|
+
visit(tree, "html", (node, i, parent) => {
|
|
53
|
+
var _a, _b;
|
|
54
|
+
if (node.value.startsWith(EMBED_OPEN_TAG)) {
|
|
55
|
+
let relatedNodeCount = 1;
|
|
56
|
+
const src = (_a = node.value.match(/src=("|')([^"']+)\1/)) == null ? void 0 : _a[2];
|
|
57
|
+
if (src) {
|
|
58
|
+
const parsed = import_url.default.parse(src);
|
|
59
|
+
const hash = decodeURIComponent(parsed.hash || "").replace("#", "");
|
|
60
|
+
const absPath = (0, import_plugin_utils.winPath)(import_path.default.resolve(import_path.default.parse(opts.fileAbsPath).dir, parsed.pathname));
|
|
61
|
+
let content = import_fs.default.readFileSync(absPath, "utf-8");
|
|
62
|
+
if (hash.startsWith("L")) {
|
|
63
|
+
content = (0, import_utils.getFileRangeLines)(content, hash);
|
|
64
|
+
} else if (hash.startsWith("RE-")) {
|
|
65
|
+
content = (0, import_utils.getFileContentByRegExp)(content, hash.slice(3), absPath);
|
|
66
|
+
}
|
|
67
|
+
const mdast = unified().use(remarkParse).use(remarkFrontmatter).use(remarkRawAST).processSync(content).result;
|
|
68
|
+
if (!node.value.endsWith(EMBED_CLOSE_TAG)) {
|
|
69
|
+
for (let j = i; j < parent.children.length; j++) {
|
|
70
|
+
const sibling = parent.children[j];
|
|
71
|
+
const isCloseTag = sibling.type === "html" && sibling.value === EMBED_CLOSE_TAG;
|
|
72
|
+
if (isCloseTag) {
|
|
73
|
+
relatedNodeCount += j - i;
|
|
74
|
+
break;
|
|
75
|
+
} else if (j === parent.children.length - 1) {
|
|
76
|
+
throw new Error(`Missing close tag for \`${node.value}\``);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
parent.children.splice(i, relatedNodeCount, ...mdast.children);
|
|
81
|
+
(_b = vFile.data).embeds ?? (_b.embeds = []);
|
|
82
|
+
vFile.data.embeds.push(absPath);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
89
|
+
0 && (module.exports = {});
|
|
@@ -35,6 +35,7 @@ function pageMetaLoader(raw) {
|
|
|
35
35
|
frontmatter.title ?? (frontmatter.title = import_plugin_utils.lodash.startCase(import_path.default.basename(pathWithoutIndex)));
|
|
36
36
|
return `export const frontmatter = ${JSON.stringify(frontmatter)};
|
|
37
37
|
export const toc = [];
|
|
38
|
+
export const texts = [];
|
|
38
39
|
export const demos = {};`;
|
|
39
40
|
}
|
|
40
41
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/types.d.ts
CHANGED
|
@@ -14,7 +14,14 @@ export interface IDumiConfig extends IUmiConfig {
|
|
|
14
14
|
type?: string;
|
|
15
15
|
dir: string;
|
|
16
16
|
})[];
|
|
17
|
-
|
|
17
|
+
/**
|
|
18
|
+
* @deprecated use `resolve.atomDirs` instead
|
|
19
|
+
*/
|
|
20
|
+
entityDirs?: {
|
|
21
|
+
type: string;
|
|
22
|
+
dir: string;
|
|
23
|
+
}[];
|
|
24
|
+
atomDirs: {
|
|
18
25
|
type: string;
|
|
19
26
|
dir: string;
|
|
20
27
|
}[];
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import Cache from 'file-system-cache';
|
|
1
2
|
/**
|
|
2
3
|
* get route path from file-system path
|
|
3
4
|
*/
|
|
@@ -20,3 +21,9 @@ export declare function parseCodeFrontmatter(raw: string): {
|
|
|
20
21
|
code: string;
|
|
21
22
|
frontmatter: Record<string, any> | null;
|
|
22
23
|
};
|
|
24
|
+
/**
|
|
25
|
+
* get file-system cache for specific namespace
|
|
26
|
+
*/
|
|
27
|
+
declare const caches: Record<string, ReturnType<typeof Cache>>;
|
|
28
|
+
export declare function getCache(ns: string): typeof caches['0'];
|
|
29
|
+
export {};
|
package/dist/utils.js
CHANGED
|
@@ -22,13 +22,16 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
22
22
|
// src/utils.ts
|
|
23
23
|
var utils_exports = {};
|
|
24
24
|
__export(utils_exports, {
|
|
25
|
+
getCache: () => getCache,
|
|
25
26
|
getFileContentByRegExp: () => getFileContentByRegExp,
|
|
26
27
|
getFileRangeLines: () => getFileRangeLines,
|
|
27
28
|
getRoutePathFromFsPath: () => getRoutePathFromFsPath,
|
|
28
29
|
parseCodeFrontmatter: () => parseCodeFrontmatter
|
|
29
30
|
});
|
|
30
31
|
module.exports = __toCommonJS(utils_exports);
|
|
32
|
+
var import_file_system_cache = __toESM(require("file-system-cache"));
|
|
31
33
|
var import_js_yaml = __toESM(require("js-yaml"));
|
|
34
|
+
var import_path = __toESM(require("path"));
|
|
32
35
|
var import_plugin_utils = require("umi/plugin-utils");
|
|
33
36
|
function getRoutePathFromFsPath(fsPath) {
|
|
34
37
|
return import_plugin_utils.lodash.kebabCase((0, import_plugin_utils.winPath)(fsPath).replace(/((\/|^)index(\.[a-zA-Z-]+)?)?\.\w+$/g, ""));
|
|
@@ -63,8 +66,21 @@ function parseCodeFrontmatter(raw) {
|
|
|
63
66
|
}
|
|
64
67
|
return { code: frontmatter ? code : raw, frontmatter };
|
|
65
68
|
}
|
|
69
|
+
var caches = {};
|
|
70
|
+
var CACHE_PATH = "node_modules/.cache/dumi";
|
|
71
|
+
function getCache(ns) {
|
|
72
|
+
if (process.env.DUMI_CACHE === "none") {
|
|
73
|
+
return { set() {
|
|
74
|
+
}, get() {
|
|
75
|
+
}, setSync() {
|
|
76
|
+
}, getSync() {
|
|
77
|
+
} };
|
|
78
|
+
}
|
|
79
|
+
return caches[ns] ?? (caches[ns] = (0, import_file_system_cache.default)({ basePath: import_path.default.join(CACHE_PATH, ns) }));
|
|
80
|
+
}
|
|
66
81
|
// Annotate the CommonJS export names for ESM import in node:
|
|
67
82
|
0 && (module.exports = {
|
|
83
|
+
getCache,
|
|
68
84
|
getFileContentByRegExp,
|
|
69
85
|
getFileRangeLines,
|
|
70
86
|
getRoutePathFromFsPath,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dumi",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.8",
|
|
4
4
|
"description": "Framework for developing UI components",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"license": "MIT",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"lint:es": "eslint \"{src,test}/**/*.{js,jsx,ts,tsx}\"",
|
|
28
28
|
"prepare": "npm run build && node ./bin/dumi.js setup",
|
|
29
29
|
"prepublishOnly": "npm run build",
|
|
30
|
-
"test": "
|
|
30
|
+
"test": "vitest"
|
|
31
31
|
},
|
|
32
32
|
"commitlint": {
|
|
33
33
|
"extends": [
|
|
@@ -57,18 +57,21 @@
|
|
|
57
57
|
"@swc/core": "^1.2.224",
|
|
58
58
|
"@types/hast": "^2.3.4",
|
|
59
59
|
"@types/mdast": "^3.0.10",
|
|
60
|
-
"@umijs/bundler-utils": "^4.0.
|
|
61
|
-
"@umijs/core": "^4.0.
|
|
60
|
+
"@umijs/bundler-utils": "^4.0.26",
|
|
61
|
+
"@umijs/core": "^4.0.26",
|
|
62
|
+
"deepmerge": "^4.2.2",
|
|
62
63
|
"dumi-afx-deps": "^1.0.0-alpha.1",
|
|
63
64
|
"dumi-assets-types": "2.0.0-alpha.0",
|
|
64
65
|
"estree-util-to-js": "^1.1.0",
|
|
65
66
|
"estree-util-visit": "^1.2.0",
|
|
67
|
+
"file-system-cache": "^2.0.0",
|
|
66
68
|
"github-slugger": "^1.4.0",
|
|
67
69
|
"hast-util-is-element": "^2.1.2",
|
|
68
70
|
"hast-util-raw": "^7.2.2",
|
|
69
71
|
"hast-util-to-estree": "^2.1.0",
|
|
70
72
|
"hast-util-to-string": "^2.0.0",
|
|
71
73
|
"heti": "^0.9.2",
|
|
74
|
+
"highlight-words-core": "^1.2.2",
|
|
72
75
|
"html-to-text": "^8.2.1",
|
|
73
76
|
"js-yaml": "^4.1.0",
|
|
74
77
|
"mdast-util-to-string": "^3.1.0",
|
|
@@ -88,9 +91,10 @@
|
|
|
88
91
|
"remark-parse": "^10.0.1",
|
|
89
92
|
"remark-rehype": "^10.1.0",
|
|
90
93
|
"sass": "^1.55.0",
|
|
91
|
-
"umi": "^4.0.
|
|
94
|
+
"umi": "^4.0.26",
|
|
92
95
|
"unified": "^10.1.2",
|
|
93
96
|
"unist-util-visit": "^4.1.0",
|
|
97
|
+
"unist-util-visit-parents": "^5.1.1",
|
|
94
98
|
"url": "^0.11.0",
|
|
95
99
|
"v8-compile-cache": "2.3.0",
|
|
96
100
|
"vfile": "^5.3.4"
|
|
@@ -98,9 +102,8 @@
|
|
|
98
102
|
"devDependencies": {
|
|
99
103
|
"@commitlint/cli": "^17.0.3",
|
|
100
104
|
"@commitlint/config-conventional": "^17.0.3",
|
|
101
|
-
"@jest/types": "^27.0.0",
|
|
102
105
|
"@types/github-slugger": "^1.3.0",
|
|
103
|
-
"@types/
|
|
106
|
+
"@types/highlight-words-core": "^1.2.1",
|
|
104
107
|
"@types/js-yaml": "^4.0.5",
|
|
105
108
|
"@types/node": "^18.6.3",
|
|
106
109
|
"@types/pluralize": "^0.0.29",
|
|
@@ -108,12 +111,9 @@
|
|
|
108
111
|
"@types/react-copy-to-clipboard": "^5.0.4",
|
|
109
112
|
"@types/react-helmet": "^6.1.5",
|
|
110
113
|
"@umijs/lint": "^4.0.22",
|
|
111
|
-
"@umijs/test": "^4.0.22",
|
|
112
|
-
"cross-env": "^7.0.3",
|
|
113
114
|
"eslint": "^8.20.0",
|
|
114
115
|
"father": "^4.0.7",
|
|
115
116
|
"husky": "^8.0.1",
|
|
116
|
-
"jest": "^27.0.0",
|
|
117
117
|
"lint-staged": "^13.0.3",
|
|
118
118
|
"prettier": "^2.7.1",
|
|
119
119
|
"prettier-plugin-organize-imports": "^3.0.0",
|
|
@@ -121,7 +121,8 @@
|
|
|
121
121
|
"react": "^18.2.0",
|
|
122
122
|
"stylelint": "^14.9.1",
|
|
123
123
|
"ts-node": "^10.0.0",
|
|
124
|
-
"typescript": "~4.7.4"
|
|
124
|
+
"typescript": "~4.7.4",
|
|
125
|
+
"vitest": "^0.24.3"
|
|
125
126
|
},
|
|
126
127
|
"peerDependencies": {
|
|
127
128
|
"react": ">=16.8",
|
|
@@ -75,6 +75,7 @@ var Previewer = function Previewer(props) {
|
|
|
75
75
|
var lang = ((_files$activeKey$0$ma = files[activeKey][0].match(/\.([^.]+)$/)) === null || _files$activeKey$0$ma === void 0 ? void 0 : _files$activeKey$0$ma[1]) || 'text';
|
|
76
76
|
var link = "#".concat(props.asset.id);
|
|
77
77
|
return /*#__PURE__*/React.createElement("div", {
|
|
78
|
+
id: props.asset.id,
|
|
78
79
|
className: "dumi-default-previewer",
|
|
79
80
|
"data-debug": props.debug,
|
|
80
81
|
"data-active": hash === link || undefined
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { useIntl, useOutlet, useRouteMeta } from 'dumi';
|
|
2
2
|
import Content from 'dumi/theme/slots/Content';
|
|
3
|
+
import Features from 'dumi/theme/slots/Features';
|
|
3
4
|
import Header from 'dumi/theme/slots/Header';
|
|
5
|
+
import Hero from 'dumi/theme/slots/Hero';
|
|
4
6
|
import Sidebar from 'dumi/theme/slots/Sidebar';
|
|
5
7
|
import React from 'react';
|
|
6
8
|
import Helmet from 'react-helmet';
|
|
@@ -32,7 +34,7 @@ var DocLayout = function DocLayout() {
|
|
|
32
34
|
}), fm.keywords && /*#__PURE__*/React.createElement("meta", {
|
|
33
35
|
property: "og:keywords",
|
|
34
36
|
content: fm.keywords.join(',')
|
|
35
|
-
})), /*#__PURE__*/React.createElement(Header, null), /*#__PURE__*/React.createElement("main", null, /*#__PURE__*/React.createElement(Sidebar, null), /*#__PURE__*/React.createElement(Content, null, outlet)));
|
|
37
|
+
})), /*#__PURE__*/React.createElement(Header, null), /*#__PURE__*/React.createElement(Hero, null), /*#__PURE__*/React.createElement(Features, null), /*#__PURE__*/React.createElement("main", null, /*#__PURE__*/React.createElement(Sidebar, null), /*#__PURE__*/React.createElement(Content, null, outlet)));
|
|
36
38
|
};
|
|
37
39
|
|
|
38
40
|
export default DocLayout;
|
|
@@ -7,12 +7,17 @@ body {
|
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
.@{prefix}-doc-layout {
|
|
10
|
-
max-width: @s-content-width;
|
|
11
|
-
margin: 0 auto;
|
|
12
|
-
padding: 0 24px;
|
|
13
|
-
|
|
14
10
|
> main {
|
|
15
11
|
display: flex;
|
|
16
12
|
align-items: flex-start;
|
|
13
|
+
margin: 0 auto;
|
|
14
|
+
padding: 0 24px;
|
|
15
|
+
max-width: @s-content-width;
|
|
16
|
+
box-sizing: border-box;
|
|
17
|
+
|
|
18
|
+
> section {
|
|
19
|
+
flex: 1;
|
|
20
|
+
max-width: 100%;
|
|
21
|
+
}
|
|
17
22
|
}
|
|
18
23
|
}
|
|
@@ -15,5 +15,6 @@
|
|
|
15
15
|
"api.component.required": "(required)",
|
|
16
16
|
"api.component.loading": "Properties definition is resolving, wait a moment...",
|
|
17
17
|
"api.component.not.found": "Properties definition not found for {id} component",
|
|
18
|
-
"content.tabs.default": "Doc"
|
|
18
|
+
"content.tabs.default": "Doc",
|
|
19
|
+
"search.not.found": "No content was found"
|
|
19
20
|
}
|
|
@@ -4,7 +4,7 @@ import './index.less';
|
|
|
4
4
|
declare type IContentTabs = ReturnType<typeof useRouteMeta>['tabs'];
|
|
5
5
|
export interface IContentTabsProps {
|
|
6
6
|
tabs: IContentTabs;
|
|
7
|
-
tabKey
|
|
7
|
+
tabKey: string | null;
|
|
8
8
|
onChange: (tab?: NonNullable<IContentTabs>[0]) => void;
|
|
9
9
|
}
|
|
10
10
|
declare const ContentTabs: FC<IContentTabsProps>;
|