@docubook/core 2.0.0-beta.0 → 2.0.0-beta.3
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/compile.d.ts +9 -0
- package/dist/extract.d.ts +22 -0
- package/dist/index.d.ts +10 -122
- package/dist/index.js +267 -444
- package/dist/index.js.map +1 -1
- package/dist/mdx-compiler/format-mdx-error.d.ts +4 -0
- package/dist/mdx-compiler/index.d.ts +15 -0
- package/dist/mdx-compiler/plugins/remove-dangerous-javascript-expressions.d.ts +2 -0
- package/dist/mdx-compiler/plugins/remove-imports-exports.d.ts +3 -0
- package/dist/mdx-compiler/plugins/remove-javascript-expressions.d.ts +6 -0
- package/dist/mdx-compiler/serialize.d.ts +5 -11
- package/dist/mdx-compiler/serialize.js +2 -7
- package/dist/mdx-compiler/types.d.ts +3 -0
- package/dist/plugins/handleCodeExpandable.d.ts +3 -0
- package/dist/plugins/handleCodeTitles.d.ts +2 -0
- package/dist/plugins/rehypeMermaid.d.ts +10 -0
- package/dist/plugins/remarkDirectiveToMdx.d.ts +23 -0
- package/dist/serialize-DEuXE4Xm.js +98 -0
- package/dist/serialize-DEuXE4Xm.js.map +1 -0
- package/dist/types.d.ts +5 -0
- package/dist/utils.d.ts +9 -12
- package/dist/utils.js +35 -16
- package/dist/utils.js.map +1 -1
- package/package.json +5 -5
- package/dist/chunk-HZJLRYAI.js +0 -45
- package/dist/chunk-HZJLRYAI.js.map +0 -1
- package/dist/chunk-J7CN2VUH.js +0 -188
- package/dist/chunk-J7CN2VUH.js.map +0 -1
- package/dist/mdx-compiler/serialize.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,463 +1,286 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
import
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
import
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
if (nextElement?.tagName === "pre") {
|
|
42
|
-
const titleNode = node.children?.[0];
|
|
43
|
-
if (titleNode?.type === "text") {
|
|
44
|
-
if (!nextElement.properties) {
|
|
45
|
-
nextElement.properties = {};
|
|
46
|
-
}
|
|
47
|
-
nextElement.properties["data-title"] = titleNode.value;
|
|
48
|
-
nextElement.codeTitle = titleNode.value;
|
|
49
|
-
toRemove.push({ parent, index });
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
for (let i = toRemove.length - 1; i >= 0; i--) {
|
|
54
|
-
const { parent, index } = toRemove[i];
|
|
55
|
-
parent.children.splice(index, 1);
|
|
56
|
-
}
|
|
1
|
+
import { cn as e, formatDate as t, formatDate2 as n, parseDate as r, stringToDate as i, toIsoDateOnly as a } from "./utils.js";
|
|
2
|
+
import { t as o } from "./serialize-DEuXE4Xm.js";
|
|
3
|
+
import { visit as s } from "unist-util-visit";
|
|
4
|
+
import c from "remark-gfm";
|
|
5
|
+
import l from "rehype-prism-plus";
|
|
6
|
+
import u from "rehype-autolink-headings";
|
|
7
|
+
import d from "rehype-slug";
|
|
8
|
+
import f from "rehype-code-titles";
|
|
9
|
+
import p from "remark-directive";
|
|
10
|
+
import m, { useEffect as h, useMemo as g, useState as _ } from "react";
|
|
11
|
+
import * as v from "react/jsx-runtime";
|
|
12
|
+
import * as y from "react/jsx-dev-runtime";
|
|
13
|
+
import * as b from "@mdx-js/react";
|
|
14
|
+
import x from "@11ty/gray-matter";
|
|
15
|
+
//#region src/plugins/handleCodeTitles.ts
|
|
16
|
+
var S = () => (e) => {
|
|
17
|
+
let t = [];
|
|
18
|
+
s(e, "element", (e, n, r) => {
|
|
19
|
+
if (!r || n === null || e.tagName !== "div" || !e.properties?.className?.includes("rehype-code-title")) return;
|
|
20
|
+
let i = null;
|
|
21
|
+
for (let e = n + 1; e < r.children.length; e++) {
|
|
22
|
+
let t = r.children[e];
|
|
23
|
+
if (t.type === "element") {
|
|
24
|
+
i = t;
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
if (i?.tagName === "pre") {
|
|
29
|
+
let a = e.children?.[0];
|
|
30
|
+
a?.type === "text" && (i.properties || (i.properties = {}), i.properties["data-title"] = a.value, i.codeTitle = a.value, t.push({
|
|
31
|
+
parent: r,
|
|
32
|
+
index: n
|
|
33
|
+
}));
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
for (let e = t.length - 1; e >= 0; e--) {
|
|
37
|
+
let { parent: n, index: r } = t[e];
|
|
38
|
+
n.children.splice(r, 1);
|
|
39
|
+
}
|
|
57
40
|
};
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
return out;
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region src/plugins/handleCodeExpandable.ts
|
|
43
|
+
function C(e) {
|
|
44
|
+
let t = "";
|
|
45
|
+
for (let n = 0; n < e.length; n++) {
|
|
46
|
+
let r = e[n];
|
|
47
|
+
if (r === "<" && e[n + 1] === "/") {
|
|
48
|
+
t += "\\u003C/", n++;
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
if (r === "`" || r === "$" || r === "{" || r === "}" || r === "\"" || r === "\\") {
|
|
52
|
+
t += `\\${r}`;
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
t += r;
|
|
56
|
+
}
|
|
57
|
+
return t;
|
|
77
58
|
}
|
|
78
|
-
function
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
if (normalized.endsWith("\n")) normalized = normalized.slice(0, -1);
|
|
82
|
-
if (normalized.length === 0) return 0;
|
|
83
|
-
return normalized.split("\n").length;
|
|
59
|
+
function w(e) {
|
|
60
|
+
let t = e.replace(/\r\n/g, "\n");
|
|
61
|
+
return t.startsWith("\n") && (t = t.slice(1)), t.endsWith("\n") && (t = t.slice(0, -1)), t.length === 0 ? 0 : t.split("\n").length;
|
|
84
62
|
}
|
|
85
|
-
var
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
const codeElement = node.children?.find((child) => {
|
|
126
|
-
const element = child;
|
|
127
|
-
return element.type === "element" && element.tagName === "code";
|
|
128
|
-
});
|
|
129
|
-
const codeClassName = codeElement?.properties?.className;
|
|
130
|
-
const codeClassList = Array.isArray(codeClassName) ? codeClassName : typeof codeClassName === "string" ? codeClassName.split(" ").filter(Boolean) : [];
|
|
131
|
-
const codeMeta = codeElement?.data && typeof codeElement.data === "object" && typeof codeElement.data["meta"] === "string" ? codeElement.data["meta"] : void 0;
|
|
132
|
-
const languageFromMeta = codeMeta?.match(/dbLang\(([^)]+)\)/)?.[1];
|
|
133
|
-
const titleFromMeta = codeMeta?.match(/dbTitle\(([^)]+)\)/)?.[1];
|
|
134
|
-
const languageFromProps = typeof codeElement?.properties?.["data-language"] === "string" ? codeElement.properties["data-language"] : void 0;
|
|
135
|
-
const titleFromProps = typeof codeElement?.properties?.["data-title"] === "string" ? codeElement.properties["data-title"] : void 0;
|
|
136
|
-
const languageFromCodeClass = codeClassList.find((item) => item.startsWith("language-"))?.replace("language-", "");
|
|
137
|
-
const existingPreLanguage = typeof node.properties?.["data-language"] === "string" ? node.properties["data-language"] : void 0;
|
|
138
|
-
const existingPreTitle = typeof node.properties?.["data-title"] === "string" ? node.properties["data-title"] : void 0;
|
|
139
|
-
const isExpandable = codeElement?.properties?.["data-expandable"] === "true" || codeClassList.includes("mdx-expandable-meta") || codeMeta?.includes("Expandable") === true;
|
|
140
|
-
const expandableLines = codeElement?.properties?.["data-expandable-lines"];
|
|
141
|
-
if (!isExpandable) return;
|
|
142
|
-
if (!node.properties) {
|
|
143
|
-
node.properties = {};
|
|
144
|
-
}
|
|
145
|
-
node.properties["data-expandable"] = "true";
|
|
146
|
-
if (typeof expandableLines === "string" || typeof expandableLines === "number") {
|
|
147
|
-
node.properties["data-expandable-lines"] = expandableLines.toString();
|
|
148
|
-
} else if (node.raw) {
|
|
149
|
-
node.properties["data-expandable-lines"] = countCodeLines(node.raw).toString();
|
|
150
|
-
}
|
|
151
|
-
const resolvedLanguage = languageFromProps || languageFromMeta || languageFromCodeClass || existingPreLanguage || node.language;
|
|
152
|
-
const resolvedTitle = titleFromProps || titleFromMeta || existingPreTitle || node.codeTitle;
|
|
153
|
-
if (resolvedLanguage) {
|
|
154
|
-
node.properties["data-language"] = resolvedLanguage;
|
|
155
|
-
}
|
|
156
|
-
if (resolvedTitle) {
|
|
157
|
-
node.properties["data-title"] = resolvedTitle;
|
|
158
|
-
}
|
|
159
|
-
const className = node.properties.className;
|
|
160
|
-
if (!className) {
|
|
161
|
-
node.properties.className = [];
|
|
162
|
-
}
|
|
163
|
-
if (Array.isArray(node.properties.className)) {
|
|
164
|
-
if (!node.properties.className.includes("mdx-expandable-code")) {
|
|
165
|
-
node.properties.className.push("mdx-expandable-code");
|
|
166
|
-
}
|
|
167
|
-
} else if (typeof className === "string") {
|
|
168
|
-
const hasMarker = className.split(" ").includes("mdx-expandable-code");
|
|
169
|
-
if (!hasMarker) {
|
|
170
|
-
node.properties.className = `${className} mdx-expandable-code`.trim().split(" ");
|
|
171
|
-
}
|
|
172
|
-
} else {
|
|
173
|
-
node.properties.className = ["mdx-expandable-code"];
|
|
174
|
-
}
|
|
175
|
-
if (codeElement?.properties) {
|
|
176
|
-
const cleanedCodeClassList = codeClassList.filter((item) => item !== "mdx-expandable-meta");
|
|
177
|
-
codeElement.properties.className = cleanedCodeClassList;
|
|
178
|
-
}
|
|
179
|
-
});
|
|
63
|
+
var T = () => (e) => {
|
|
64
|
+
s(e, "code", (e) => {
|
|
65
|
+
if (!e.meta) return;
|
|
66
|
+
let t = e.meta.includes("Expandable"), [n, r] = (e.lang ?? "").split(":"), i = n?.trim(), a = r?.trim();
|
|
67
|
+
if (!t) return;
|
|
68
|
+
let o = w(e.value);
|
|
69
|
+
e.data ||= {}, e.data.hProperties || (e.data.hProperties = {}), e.data.hProperties["data-expandable"] = "true", e.data.hProperties["data-expandable-lines"] = o.toString(), i && (e.data.hProperties["data-language"] = i), a && (e.data.hProperties["data-title"] = a);
|
|
70
|
+
let s = e.data.hProperties.className, c = Array.isArray(s) ? s : typeof s == "string" ? s.split(" ").filter(Boolean) : [];
|
|
71
|
+
c.includes("mdx-expandable-meta") || c.push("mdx-expandable-meta"), e.data.hProperties.className = c, i && !e.meta.includes("dbLang(") && (e.meta = `${e.meta} dbLang(${C(i)})`.trim()), a && !e.meta.includes("dbTitle(") && (e.meta = `${e.meta} dbTitle(${C(a)})`.trim());
|
|
72
|
+
});
|
|
73
|
+
}, E = () => (e) => {
|
|
74
|
+
s(e, "element", (e) => {
|
|
75
|
+
if (e.tagName !== "pre") return;
|
|
76
|
+
let t = e.children?.find((e) => {
|
|
77
|
+
let t = e;
|
|
78
|
+
return t.type === "element" && t.tagName === "code";
|
|
79
|
+
}), n = t?.properties?.className, r = Array.isArray(n) ? n : typeof n == "string" ? n.split(" ").filter(Boolean) : [], i = t?.data && typeof t.data == "object" && typeof t.data.meta == "string" ? t.data.meta : void 0, a = i?.match(/dbLang\(([^)]+)\)/)?.[1], o = i?.match(/dbTitle\(([^)]+)\)/)?.[1], s = typeof t?.properties?.["data-language"] == "string" ? t.properties["data-language"] : void 0, c = typeof t?.properties?.["data-title"] == "string" ? t.properties["data-title"] : void 0, l = r.find((e) => e.startsWith("language-"))?.replace("language-", ""), u = typeof e.properties?.["data-language"] == "string" ? e.properties["data-language"] : void 0, d = typeof e.properties?.["data-title"] == "string" ? e.properties["data-title"] : void 0, f = t?.properties?.["data-expandable"] === "true" || r.includes("mdx-expandable-meta") || i?.includes("Expandable") === !0, p = t?.properties?.["data-expandable-lines"];
|
|
80
|
+
if (!f) return;
|
|
81
|
+
e.properties ||= {}, e.properties["data-expandable"] = "true", typeof p == "string" || typeof p == "number" ? e.properties["data-expandable-lines"] = p.toString() : e.raw && (e.properties["data-expandable-lines"] = w(e.raw).toString());
|
|
82
|
+
let m = s || a || l || u || e.language, h = c || o || d || e.codeTitle;
|
|
83
|
+
m && (e.properties["data-language"] = m), h && (e.properties["data-title"] = h);
|
|
84
|
+
let g = e.properties.className;
|
|
85
|
+
if (g || (e.properties.className = []), Array.isArray(e.properties.className) ? e.properties.className.includes("mdx-expandable-code") || e.properties.className.push("mdx-expandable-code") : typeof g == "string" ? g.split(" ").includes("mdx-expandable-code") || (e.properties.className = `${g} mdx-expandable-code`.trim().split(" ")) : e.properties.className = ["mdx-expandable-code"], t?.properties) {
|
|
86
|
+
let e = r.filter((e) => e !== "mdx-expandable-meta");
|
|
87
|
+
t.properties.className = e;
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
}, D = () => (e) => {
|
|
91
|
+
s(e, "element", (e, t, n) => {
|
|
92
|
+
if (!n || t === null || e.tagName !== "pre") return;
|
|
93
|
+
let r = e.children?.find((e) => e.type === "element" && e.tagName === "code");
|
|
94
|
+
if (!r || !(Array.isArray(r.properties?.className) ? r.properties.className : typeof r.properties?.className == "string" ? r.properties.className.split(" ").filter(Boolean) : []).includes("language-mermaid")) return;
|
|
95
|
+
let i = r.children?.find((e) => e.type === "text")?.value ?? "";
|
|
96
|
+
n.children[t] = {
|
|
97
|
+
type: "element",
|
|
98
|
+
tagName: "Mermaid",
|
|
99
|
+
properties: { chart: i },
|
|
100
|
+
children: []
|
|
101
|
+
};
|
|
102
|
+
});
|
|
180
103
|
};
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
(child) => child.type === "element" && child.tagName === "code"
|
|
189
|
-
);
|
|
190
|
-
if (!codeEl) return;
|
|
191
|
-
const classList = Array.isArray(codeEl.properties?.className) ? codeEl.properties.className : typeof codeEl.properties?.className === "string" ? codeEl.properties.className.split(" ").filter(Boolean) : [];
|
|
192
|
-
if (!classList.includes("language-mermaid")) return;
|
|
193
|
-
const textNode = codeEl.children?.find((child) => child.type === "text");
|
|
194
|
-
const chart = textNode?.value ?? "";
|
|
195
|
-
parent.children[index] = {
|
|
196
|
-
type: "element",
|
|
197
|
-
tagName: "Mermaid",
|
|
198
|
-
properties: { chart },
|
|
199
|
-
children: []
|
|
200
|
-
};
|
|
201
|
-
});
|
|
202
|
-
};
|
|
203
|
-
|
|
204
|
-
// src/plugins/remarkDirectiveToMdx.ts
|
|
205
|
-
function remarkDirectiveToMdx() {
|
|
206
|
-
return (tree) => {
|
|
207
|
-
const root = tree;
|
|
208
|
-
root.children = root.children.map(transform);
|
|
209
|
-
return tree;
|
|
210
|
-
};
|
|
104
|
+
//#endregion
|
|
105
|
+
//#region src/plugins/remarkDirectiveToMdx.ts
|
|
106
|
+
function O() {
|
|
107
|
+
return (e) => {
|
|
108
|
+
let t = e;
|
|
109
|
+
return t.children = t.children.map(j), e;
|
|
110
|
+
};
|
|
211
111
|
}
|
|
212
|
-
var
|
|
213
|
-
function
|
|
214
|
-
|
|
112
|
+
var k = /* @__PURE__ */ new Set(["youtube"]);
|
|
113
|
+
function A(e) {
|
|
114
|
+
return e.type === "containerDirective" || e.type === "leafDirective" || e.type === "textDirective";
|
|
215
115
|
}
|
|
216
|
-
function
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
return node;
|
|
223
|
-
}
|
|
224
|
-
if (node.type === "textDirective") {
|
|
225
|
-
if (node.name === "tooltip") {
|
|
226
|
-
return inlineTooltip(node);
|
|
227
|
-
}
|
|
228
|
-
return literalDirective(node);
|
|
229
|
-
}
|
|
230
|
-
if (node.type === "leafDirective" && node.name === "tooltip") {
|
|
231
|
-
return literalDirective(node);
|
|
232
|
-
}
|
|
233
|
-
const children = node.type === "containerDirective" && !PURE_LEAVES.has(node.name) ? (node.children ?? []).map(transform) : [];
|
|
234
|
-
return directiveToElement(node, children);
|
|
116
|
+
function j(e) {
|
|
117
|
+
if (!A(e)) {
|
|
118
|
+
let t = e.children;
|
|
119
|
+
return Array.isArray(t) && (e.children = t.map(j)), e;
|
|
120
|
+
}
|
|
121
|
+
return e.type === "textDirective" ? e.name === "tooltip" ? P(e) : N(e) : e.type === "leafDirective" && e.name === "tooltip" ? N(e) : M(e, e.type === "containerDirective" && !k.has(e.name) ? (e.children ?? []).map(j) : []);
|
|
235
122
|
}
|
|
236
|
-
function
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
children
|
|
248
|
-
};
|
|
123
|
+
function M(e, t) {
|
|
124
|
+
return {
|
|
125
|
+
type: "mdxJsxFlowElement",
|
|
126
|
+
name: F(e.name),
|
|
127
|
+
attributes: Object.entries(e.attributes ?? {}).map(([e, t]) => ({
|
|
128
|
+
type: "mdxJsxAttribute",
|
|
129
|
+
name: e,
|
|
130
|
+
value: t === "" ? null : t
|
|
131
|
+
})),
|
|
132
|
+
children: t
|
|
133
|
+
};
|
|
249
134
|
}
|
|
250
|
-
function
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
135
|
+
function N(e) {
|
|
136
|
+
let t = ":" + e.name + (e.label ? `[${e.label}]` : ""), n = Object.entries(e.attributes ?? {}).map(([e, t]) => t === "" ? e : `${e}="${t}"`).join(" ");
|
|
137
|
+
return {
|
|
138
|
+
type: "text",
|
|
139
|
+
value: t + (n ? `{${n}}` : "")
|
|
140
|
+
};
|
|
254
141
|
}
|
|
255
|
-
function
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
142
|
+
function P(e) {
|
|
143
|
+
let t = (e.children ?? []).map((e) => e.value ?? "").join(""), n = e.attributes ?? {};
|
|
144
|
+
return {
|
|
145
|
+
type: "mdxJsxTextElement",
|
|
146
|
+
name: "Tooltip",
|
|
147
|
+
attributes: [{
|
|
148
|
+
type: "mdxJsxAttribute",
|
|
149
|
+
name: "text",
|
|
150
|
+
value: n.text || t || "?"
|
|
151
|
+
}, {
|
|
152
|
+
type: "mdxJsxAttribute",
|
|
153
|
+
name: "tip",
|
|
154
|
+
value: n.tip || t || ""
|
|
155
|
+
}],
|
|
156
|
+
children: []
|
|
157
|
+
};
|
|
263
158
|
}
|
|
264
|
-
function
|
|
265
|
-
|
|
159
|
+
function F(e) {
|
|
160
|
+
return e.split("-").map((e) => e.charAt(0).toUpperCase() + e.slice(1)).join("");
|
|
266
161
|
}
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
const fn = Reflect.construct(Function, keys.concat(`${compiledSource}`));
|
|
301
|
-
return fn.apply(fn, values).default;
|
|
302
|
-
}, [compiledSource, scope, frontmatter]);
|
|
303
|
-
if (!ready) {
|
|
304
|
-
return React.createElement("div", {
|
|
305
|
-
dangerouslySetInnerHTML: { __html: "" },
|
|
306
|
-
suppressHydrationWarning: true
|
|
307
|
-
});
|
|
308
|
-
}
|
|
309
|
-
const content = React.createElement(
|
|
310
|
-
mdx.MDXProvider,
|
|
311
|
-
{ components },
|
|
312
|
-
React.createElement(Content, null)
|
|
313
|
-
);
|
|
314
|
-
return lazy ? React.createElement("div", null, content) : content;
|
|
162
|
+
//#endregion
|
|
163
|
+
//#region src/mdx-compiler/index.ts
|
|
164
|
+
function I({ compiledSource: e, frontmatter: t, scope: n = {}, components: r = {}, lazy: i }) {
|
|
165
|
+
let [a, o] = _(!i || typeof window > "u");
|
|
166
|
+
h(() => {
|
|
167
|
+
if (!i) return;
|
|
168
|
+
let e = window.requestIdleCallback ? window.requestIdleCallback(() => o(!0), { timeout: 500 }) : setTimeout(() => o(!0), 1);
|
|
169
|
+
return () => {
|
|
170
|
+
window.cancelIdleCallback ? window.cancelIdleCallback(e) : clearTimeout(e);
|
|
171
|
+
};
|
|
172
|
+
}, [i]);
|
|
173
|
+
let s = g(() => {
|
|
174
|
+
let r = {
|
|
175
|
+
opts: {
|
|
176
|
+
...b,
|
|
177
|
+
...v,
|
|
178
|
+
...y
|
|
179
|
+
},
|
|
180
|
+
frontmatter: t,
|
|
181
|
+
...n
|
|
182
|
+
}, i = Object.keys(r), a = Object.values(r), o = Reflect.construct(Function, i.concat(`${e}`));
|
|
183
|
+
return o.apply(o, a).default;
|
|
184
|
+
}, [
|
|
185
|
+
e,
|
|
186
|
+
n,
|
|
187
|
+
t
|
|
188
|
+
]);
|
|
189
|
+
if (!a) return m.createElement("div", {
|
|
190
|
+
dangerouslySetInnerHTML: { __html: "" },
|
|
191
|
+
suppressHydrationWarning: !0
|
|
192
|
+
});
|
|
193
|
+
let c = m.createElement(b.MDXProvider, { components: r }, m.createElement(s, null));
|
|
194
|
+
return i ? m.createElement("div", null, c) : c;
|
|
315
195
|
}
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
var
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
if (element.properties && element.language && !element.properties["data-language"]) {
|
|
346
|
-
element.properties["data-language"] = element.language;
|
|
347
|
-
}
|
|
348
|
-
if (element.properties && element.codeTitle && !element.properties["data-title"]) {
|
|
349
|
-
element.properties["data-title"] = element.codeTitle;
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
});
|
|
353
|
-
return tree;
|
|
354
|
-
};
|
|
355
|
-
function createDefaultRehypePlugins() {
|
|
356
|
-
return [
|
|
357
|
-
preProcess,
|
|
358
|
-
rehypeMermaid,
|
|
359
|
-
// Transform ```mermaid before code transforms
|
|
360
|
-
rehypeCodeTitles,
|
|
361
|
-
handleCodeTitles,
|
|
362
|
-
handleCodeExpandable,
|
|
363
|
-
// Copy expandable metadata from <code> to <pre> before prism transforms nodes.
|
|
364
|
-
rehypePrism,
|
|
365
|
-
handleCodeExpandable,
|
|
366
|
-
// Re-apply expandable attrs after prism tokenization.
|
|
367
|
-
rehypeSlug,
|
|
368
|
-
rehypeAutolinkHeadings,
|
|
369
|
-
postProcess
|
|
370
|
-
];
|
|
196
|
+
//#endregion
|
|
197
|
+
//#region src/compile.ts
|
|
198
|
+
var L = () => (e) => (s(e, (e) => {
|
|
199
|
+
let t = e;
|
|
200
|
+
if (t?.type === "element" && t?.tagName === "pre" && t.children) {
|
|
201
|
+
let [e] = t.children;
|
|
202
|
+
if (e.tagName !== "code" || !e.children?.[0]) return;
|
|
203
|
+
let n = e.properties?.className, r = (Array.isArray(n) ? n : typeof n == "string" ? n.split(" ").filter(Boolean) : []).find((e) => e.startsWith("language-"));
|
|
204
|
+
r && (t.language = r.replace("language-", "").split(":")[0]);
|
|
205
|
+
let i = e.children[0];
|
|
206
|
+
i.type === "text" && i.value && (t.raw = i.value);
|
|
207
|
+
}
|
|
208
|
+
}), e), R = () => (e) => (s(e, "element", (e) => {
|
|
209
|
+
let t = e;
|
|
210
|
+
t?.type === "element" && t?.tagName === "pre" && (t.properties && t.raw && (t.properties.raw = t.raw), t.properties && t.language && !t.properties["data-language"] && (t.properties["data-language"] = t.language), t.properties && t.codeTitle && !t.properties["data-title"] && (t.properties["data-title"] = t.codeTitle));
|
|
211
|
+
}), e);
|
|
212
|
+
function z() {
|
|
213
|
+
return [
|
|
214
|
+
L,
|
|
215
|
+
D,
|
|
216
|
+
f,
|
|
217
|
+
S,
|
|
218
|
+
E,
|
|
219
|
+
l,
|
|
220
|
+
E,
|
|
221
|
+
d,
|
|
222
|
+
u,
|
|
223
|
+
R
|
|
224
|
+
];
|
|
371
225
|
}
|
|
372
|
-
function
|
|
373
|
-
|
|
226
|
+
function B() {
|
|
227
|
+
return [
|
|
228
|
+
c,
|
|
229
|
+
T,
|
|
230
|
+
p,
|
|
231
|
+
O
|
|
232
|
+
];
|
|
374
233
|
}
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
function sluggify(text) {
|
|
381
|
-
const normalized = text.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
|
|
382
|
-
const slug = normalized.toLowerCase().replace(/\s+/g, "-");
|
|
383
|
-
return slug.replace(/[^a-z0-9-]/g, "");
|
|
234
|
+
//#endregion
|
|
235
|
+
//#region src/extract.ts
|
|
236
|
+
var V = /^(````|```)(?!`)/, H = /^(#{2,4})\s+(.+)$/;
|
|
237
|
+
function U(e) {
|
|
238
|
+
return e.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase().replace(/\s+/g, "-").replace(/[^a-z0-9-]/g, "");
|
|
384
239
|
}
|
|
385
|
-
function
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
if (headingMatch) {
|
|
408
|
-
const headingLevel = headingMatch[1].length;
|
|
409
|
-
const headingText = headingMatch[2].trim().replace(/\s+#+\s*$/, "");
|
|
410
|
-
extractedHeadings.push({
|
|
411
|
-
level: headingLevel,
|
|
412
|
-
text: headingText,
|
|
413
|
-
href: `#${sluggify(headingText)}`
|
|
414
|
-
});
|
|
415
|
-
continue;
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
return extractedHeadings;
|
|
240
|
+
function W(e) {
|
|
241
|
+
let t = [], n = e.split(/\r?\n/), r = !1, i = 0;
|
|
242
|
+
for (let e of n) {
|
|
243
|
+
let n = e.trimStart(), a = V.exec(n);
|
|
244
|
+
if (a) {
|
|
245
|
+
let e = a[1];
|
|
246
|
+
r ? e.length === i && (r = !1) : (r = !0, i = e.length);
|
|
247
|
+
continue;
|
|
248
|
+
}
|
|
249
|
+
if (r) continue;
|
|
250
|
+
let o = H.exec(n);
|
|
251
|
+
if (o) {
|
|
252
|
+
let e = o[1].length, n = o[2].trim().replace(/\s+#+\s*$/, "");
|
|
253
|
+
t.push({
|
|
254
|
+
level: e,
|
|
255
|
+
text: n,
|
|
256
|
+
href: `#${U(n)}`
|
|
257
|
+
});
|
|
258
|
+
continue;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
return t;
|
|
419
262
|
}
|
|
420
|
-
function
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
263
|
+
function G(e) {
|
|
264
|
+
try {
|
|
265
|
+
return x(e).data;
|
|
266
|
+
} catch (e) {
|
|
267
|
+
let t = e instanceof Error ? e.message : String(e);
|
|
268
|
+
throw Error(`Failed to extract frontmatter: ${t}`, { cause: e });
|
|
269
|
+
}
|
|
427
270
|
}
|
|
428
|
-
function
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
271
|
+
function K(e, t) {
|
|
272
|
+
try {
|
|
273
|
+
let { data: n, content: r } = x(e);
|
|
274
|
+
return {
|
|
275
|
+
frontmatter: t ? t.parse(n) : n,
|
|
276
|
+
strippedContent: r
|
|
277
|
+
};
|
|
278
|
+
} catch (e) {
|
|
279
|
+
let t = e instanceof Error ? e.message : String(e);
|
|
280
|
+
throw Error(`Failed to extract frontmatter: ${t}`, { cause: e });
|
|
281
|
+
}
|
|
439
282
|
}
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
createDefaultRehypePlugins,
|
|
444
|
-
createDefaultRemarkPlugins,
|
|
445
|
-
extractFrontmatter,
|
|
446
|
-
extractFrontmatterWithContent,
|
|
447
|
-
extractTocsFromRawMdx,
|
|
448
|
-
formatDate,
|
|
449
|
-
formatDate2,
|
|
450
|
-
handleCodeExpandable,
|
|
451
|
-
handleCodeExpandableRemark,
|
|
452
|
-
handleCodeTitles,
|
|
453
|
-
parseDate,
|
|
454
|
-
postProcess,
|
|
455
|
-
preProcess,
|
|
456
|
-
rehypeMermaid,
|
|
457
|
-
remarkDirectiveToMdx,
|
|
458
|
-
serialize,
|
|
459
|
-
sluggify,
|
|
460
|
-
stringToDate,
|
|
461
|
-
toIsoDateOnly
|
|
462
|
-
};
|
|
283
|
+
//#endregion
|
|
284
|
+
export { I as MDXRemote, e as cn, z as createDefaultRehypePlugins, B as createDefaultRemarkPlugins, G as extractFrontmatter, K as extractFrontmatterWithContent, W as extractTocsFromRawMdx, t as formatDate, n as formatDate2, E as handleCodeExpandable, T as handleCodeExpandableRemark, S as handleCodeTitles, r as parseDate, R as postProcess, L as preProcess, D as rehypeMermaid, O as remarkDirectiveToMdx, o as serialize, U as sluggify, i as stringToDate, a as toIsoDateOnly };
|
|
285
|
+
|
|
463
286
|
//# sourceMappingURL=index.js.map
|