@hanzo/docs-core 16.2.5
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/LICENSE +21 -0
- package/README.md +5 -0
- package/dist/algolia-IZEDLPHE.js +58 -0
- package/dist/breadcrumb.d.ts +46 -0
- package/dist/breadcrumb.js +81 -0
- package/dist/chunk-5PMI7QDD.js +220 -0
- package/dist/chunk-ADBHPKXG.js +78 -0
- package/dist/chunk-APKPSBSB.js +74 -0
- package/dist/chunk-CH7YHH7V.js +222 -0
- package/dist/chunk-EFVXL2PP.js +144 -0
- package/dist/chunk-EMWGTXSW.js +19 -0
- package/dist/chunk-FAEPKD7U.js +20 -0
- package/dist/chunk-FUUVPEA5.js +29 -0
- package/dist/chunk-GINBKBVQ.js +12 -0
- package/dist/chunk-GLRQBLGN.js +59 -0
- package/dist/chunk-JUF4WZ6G.js +117 -0
- package/dist/chunk-K4WNLOVQ.js +75 -0
- package/dist/chunk-L4JKQWCM.js +131 -0
- package/dist/chunk-MA6O2UUE.js +50 -0
- package/dist/chunk-ONG4RVCR.js +8 -0
- package/dist/chunk-OTD7MV33.js +53 -0
- package/dist/chunk-PFNP6PEB.js +11 -0
- package/dist/chunk-QJRXMG4S.js +275 -0
- package/dist/chunk-SH7BNTG7.js +38 -0
- package/dist/chunk-TWIDBWFG.js +84 -0
- package/dist/chunk-U67V476Y.js +35 -0
- package/dist/chunk-VLSDGCJE.js +47 -0
- package/dist/chunk-W6WTLKRA.js +73 -0
- package/dist/chunk-X2HFD5QJ.js +275 -0
- package/dist/chunk-XJ6ZQNEX.js +91 -0
- package/dist/chunk-XN2LKXFZ.js +101 -0
- package/dist/chunk-XOFXGHS4.js +93 -0
- package/dist/chunk-XZSI7AHE.js +67 -0
- package/dist/chunk-YVVDKJ2H.js +34 -0
- package/dist/chunk-ZMWYLUDP.js +21 -0
- package/dist/content/github.d.ts +40 -0
- package/dist/content/github.js +44 -0
- package/dist/content/index.d.ts +16 -0
- package/dist/content/index.js +30 -0
- package/dist/content/mdx/preset-bundler.d.ts +31 -0
- package/dist/content/mdx/preset-bundler.js +72 -0
- package/dist/content/mdx/preset-runtime.d.ts +31 -0
- package/dist/content/mdx/preset-runtime.js +71 -0
- package/dist/content/toc.d.ts +21 -0
- package/dist/content/toc.js +22 -0
- package/dist/definitions-pJ7PybYY.d.ts +60 -0
- package/dist/dynamic-link.d.ts +12 -0
- package/dist/dynamic-link.js +32 -0
- package/dist/fetch-IBTWQCJR.js +22 -0
- package/dist/framework/index.d.ts +41 -0
- package/dist/framework/index.js +18 -0
- package/dist/framework/next.d.ts +12 -0
- package/dist/framework/next.js +31 -0
- package/dist/framework/react-router.d.ts +12 -0
- package/dist/framework/react-router.js +59 -0
- package/dist/framework/tanstack.d.ts +15 -0
- package/dist/framework/tanstack.js +72 -0
- package/dist/framework/waku.d.ts +12 -0
- package/dist/framework/waku.js +63 -0
- package/dist/highlight/client.d.ts +15 -0
- package/dist/highlight/client.js +18 -0
- package/dist/highlight/index.d.ts +30 -0
- package/dist/highlight/index.js +13 -0
- package/dist/i18n/index.d.ts +39 -0
- package/dist/i18n/index.js +9 -0
- package/dist/i18n/middleware.d.ts +34 -0
- package/dist/i18n/middleware.js +76 -0
- package/dist/link.d.ts +18 -0
- package/dist/link.js +9 -0
- package/dist/loader-BvlPPJX0.d.ts +321 -0
- package/dist/mdx-plugins/codeblock-utils.d.ts +29 -0
- package/dist/mdx-plugins/codeblock-utils.js +9 -0
- package/dist/mdx-plugins/index.d.ts +20 -0
- package/dist/mdx-plugins/index.js +73 -0
- package/dist/mdx-plugins/rehype-code.d.ts +55 -0
- package/dist/mdx-plugins/rehype-code.js +15 -0
- package/dist/mdx-plugins/rehype-toc.d.ts +14 -0
- package/dist/mdx-plugins/rehype-toc.js +7 -0
- package/dist/mdx-plugins/remark-admonition.d.ts +20 -0
- package/dist/mdx-plugins/remark-admonition.js +8 -0
- package/dist/mdx-plugins/remark-code-tab.d.ts +30 -0
- package/dist/mdx-plugins/remark-code-tab.js +8 -0
- package/dist/mdx-plugins/remark-directive-admonition.d.ts +27 -0
- package/dist/mdx-plugins/remark-directive-admonition.js +7 -0
- package/dist/mdx-plugins/remark-gfm.d.ts +1 -0
- package/dist/mdx-plugins/remark-gfm.js +7 -0
- package/dist/mdx-plugins/remark-heading.d.ts +31 -0
- package/dist/mdx-plugins/remark-heading.js +8 -0
- package/dist/mdx-plugins/remark-image.d.ts +57 -0
- package/dist/mdx-plugins/remark-image.js +7 -0
- package/dist/mdx-plugins/remark-mdx-files.d.ts +40 -0
- package/dist/mdx-plugins/remark-mdx-files.js +7 -0
- package/dist/mdx-plugins/remark-mdx-mermaid.d.ts +15 -0
- package/dist/mdx-plugins/remark-mdx-mermaid.js +7 -0
- package/dist/mdx-plugins/remark-npm.d.ts +31 -0
- package/dist/mdx-plugins/remark-npm.js +8 -0
- package/dist/mdx-plugins/remark-steps.d.ts +23 -0
- package/dist/mdx-plugins/remark-steps.js +7 -0
- package/dist/mdx-plugins/remark-structure.d.ts +71 -0
- package/dist/mdx-plugins/remark-structure.js +12 -0
- package/dist/mixedbread-RAHDVXGJ.js +118 -0
- package/dist/negotiation/index.d.ts +19 -0
- package/dist/negotiation/index.js +11 -0
- package/dist/orama-cloud-UZAPMPFV.js +93 -0
- package/dist/page-tree/index.d.ts +33 -0
- package/dist/page-tree/index.js +17 -0
- package/dist/search/algolia.d.ts +69 -0
- package/dist/search/algolia.js +71 -0
- package/dist/search/client.d.ts +140 -0
- package/dist/search/client.js +99 -0
- package/dist/search/index.d.ts +26 -0
- package/dist/search/index.js +7 -0
- package/dist/search/orama-cloud.d.ts +79 -0
- package/dist/search/orama-cloud.js +60 -0
- package/dist/search/server.d.ts +136 -0
- package/dist/search/server.js +400 -0
- package/dist/source/client/index.d.ts +16 -0
- package/dist/source/client/index.js +41 -0
- package/dist/source/index.d.ts +42 -0
- package/dist/source/index.js +776 -0
- package/dist/source/plugins/lucide-icons.d.ts +14 -0
- package/dist/source/plugins/lucide-icons.js +23 -0
- package/dist/source/schema.d.ts +26 -0
- package/dist/source/schema.js +25 -0
- package/dist/static-A2YJ5TXV.js +62 -0
- package/dist/toc.d.ts +43 -0
- package/dist/toc.js +151 -0
- package/dist/util-bZU2QeJ2.d.ts +6 -0
- package/dist/utils/use-effect-event.d.ts +9 -0
- package/dist/utils/use-effect-event.js +16 -0
- package/dist/utils/use-media-query.d.ts +3 -0
- package/dist/utils/use-media-query.js +23 -0
- package/dist/utils/use-on-change.d.ts +8 -0
- package/dist/utils/use-on-change.js +7 -0
- package/package.json +222 -0
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import {
|
|
2
|
+
generateCodeBlockTabs,
|
|
3
|
+
parseCodeBlockAttributes
|
|
4
|
+
} from "./chunk-TWIDBWFG.js";
|
|
5
|
+
|
|
6
|
+
// src/mdx-plugins/remark-code-tab.ts
|
|
7
|
+
import { visit } from "unist-util-visit";
|
|
8
|
+
var Tabs = {
|
|
9
|
+
convert(processor, nodes, withMdx = false, withParent = true) {
|
|
10
|
+
const tabs = Array.from(processTabValue(nodes).entries());
|
|
11
|
+
if (!withMdx) {
|
|
12
|
+
const children2 = tabs.map(([name, codes]) => {
|
|
13
|
+
return {
|
|
14
|
+
type: "mdxJsxFlowElement",
|
|
15
|
+
name: "Tab",
|
|
16
|
+
attributes: [
|
|
17
|
+
{
|
|
18
|
+
type: "mdxJsxAttribute",
|
|
19
|
+
name: "value",
|
|
20
|
+
value: name
|
|
21
|
+
}
|
|
22
|
+
],
|
|
23
|
+
children: codes
|
|
24
|
+
};
|
|
25
|
+
});
|
|
26
|
+
if (!withParent) return createFragment(children2);
|
|
27
|
+
return {
|
|
28
|
+
type: "mdxJsxFlowElement",
|
|
29
|
+
name: "Tabs",
|
|
30
|
+
attributes: [
|
|
31
|
+
{
|
|
32
|
+
type: "mdxJsxAttribute",
|
|
33
|
+
name: "items",
|
|
34
|
+
value: {
|
|
35
|
+
type: "mdxJsxAttributeValueExpression",
|
|
36
|
+
value: tabs.map(([name]) => name).join(", "),
|
|
37
|
+
data: {
|
|
38
|
+
estree: {
|
|
39
|
+
type: "Program",
|
|
40
|
+
sourceType: "module",
|
|
41
|
+
comments: [],
|
|
42
|
+
body: [
|
|
43
|
+
{
|
|
44
|
+
type: "ExpressionStatement",
|
|
45
|
+
expression: {
|
|
46
|
+
type: "ArrayExpression",
|
|
47
|
+
elements: tabs.map(([name]) => ({
|
|
48
|
+
type: "Literal",
|
|
49
|
+
value: name
|
|
50
|
+
}))
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
]
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
],
|
|
59
|
+
children: children2
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
const children = [
|
|
63
|
+
{
|
|
64
|
+
type: "mdxJsxFlowElement",
|
|
65
|
+
name: "TabsList",
|
|
66
|
+
attributes: [],
|
|
67
|
+
children: tabs.map(([name]) => ({
|
|
68
|
+
type: "mdxJsxFlowElement",
|
|
69
|
+
name: "TabsTrigger",
|
|
70
|
+
attributes: [
|
|
71
|
+
{
|
|
72
|
+
type: "mdxJsxAttribute",
|
|
73
|
+
name: "value",
|
|
74
|
+
value: name
|
|
75
|
+
}
|
|
76
|
+
],
|
|
77
|
+
children: [mdxToAst(processor, name)]
|
|
78
|
+
}))
|
|
79
|
+
},
|
|
80
|
+
...tabs.map(
|
|
81
|
+
([name, codes]) => ({
|
|
82
|
+
type: "mdxJsxFlowElement",
|
|
83
|
+
name: "TabsContent",
|
|
84
|
+
attributes: [
|
|
85
|
+
{
|
|
86
|
+
type: "mdxJsxAttribute",
|
|
87
|
+
name: "value",
|
|
88
|
+
value: name
|
|
89
|
+
}
|
|
90
|
+
],
|
|
91
|
+
children: codes
|
|
92
|
+
})
|
|
93
|
+
)
|
|
94
|
+
];
|
|
95
|
+
if (!withParent) return createFragment(children);
|
|
96
|
+
return {
|
|
97
|
+
type: "mdxJsxFlowElement",
|
|
98
|
+
name: "Tabs",
|
|
99
|
+
attributes: [
|
|
100
|
+
{
|
|
101
|
+
type: "mdxJsxAttribute",
|
|
102
|
+
name: "defaultValue",
|
|
103
|
+
value: tabs[0][0]
|
|
104
|
+
}
|
|
105
|
+
],
|
|
106
|
+
children
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
var CodeBlockTabs = {
|
|
111
|
+
convert(processor, nodes, withMdx = false, withParent = true) {
|
|
112
|
+
const tabs = Array.from(processTabValue(nodes).entries());
|
|
113
|
+
const node = generateCodeBlockTabs({
|
|
114
|
+
defaultValue: tabs[0][0],
|
|
115
|
+
triggers: tabs.map(([name]) => ({
|
|
116
|
+
value: name,
|
|
117
|
+
children: [
|
|
118
|
+
withMdx ? mdxToAst(processor, name) : {
|
|
119
|
+
type: "text",
|
|
120
|
+
value: name
|
|
121
|
+
}
|
|
122
|
+
]
|
|
123
|
+
})),
|
|
124
|
+
tabs: tabs.map(([name, codes]) => ({
|
|
125
|
+
value: name,
|
|
126
|
+
children: codes
|
|
127
|
+
}))
|
|
128
|
+
});
|
|
129
|
+
if (!withParent) return createFragment(node.children);
|
|
130
|
+
return node;
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
var Types = {
|
|
134
|
+
CodeBlockTabs,
|
|
135
|
+
Tabs
|
|
136
|
+
};
|
|
137
|
+
function remarkCodeTab(options = {}) {
|
|
138
|
+
const { parseMdx = false, Tabs: Tabs2 = "CodeBlockTabs" } = options;
|
|
139
|
+
return (tree) => {
|
|
140
|
+
const ignored = /* @__PURE__ */ new WeakSet();
|
|
141
|
+
visit(tree, (node) => {
|
|
142
|
+
if (!("children" in node) || ignored.has(node)) return "skip";
|
|
143
|
+
let localTabs = Tabs2;
|
|
144
|
+
let localParseMdx = parseMdx;
|
|
145
|
+
let withParent = true;
|
|
146
|
+
if (node.type === "mdxJsxFlowElement" && node.name && node.name in Types) {
|
|
147
|
+
withParent = false;
|
|
148
|
+
localTabs = node.name;
|
|
149
|
+
if (node.name === "Tabs" && localParseMdx) {
|
|
150
|
+
localParseMdx = node.attributes.every(
|
|
151
|
+
(attribute) => attribute.type !== "mdxJsxAttribute" || attribute.name !== "items"
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
let start = -1;
|
|
156
|
+
let end = 0;
|
|
157
|
+
const close = () => {
|
|
158
|
+
if (start === -1 || start === end) return;
|
|
159
|
+
const replacement = Types[localTabs].convert(
|
|
160
|
+
this,
|
|
161
|
+
node.children.slice(start, end),
|
|
162
|
+
localParseMdx,
|
|
163
|
+
withParent
|
|
164
|
+
);
|
|
165
|
+
ignored.add(replacement);
|
|
166
|
+
node.children.splice(start, end - start, replacement);
|
|
167
|
+
end = start;
|
|
168
|
+
start = -1;
|
|
169
|
+
};
|
|
170
|
+
for (; end < node.children.length; end++) {
|
|
171
|
+
const child = node.children[end];
|
|
172
|
+
if (child.type !== "code" || !child.meta) {
|
|
173
|
+
close();
|
|
174
|
+
continue;
|
|
175
|
+
}
|
|
176
|
+
const meta = parseCodeBlockAttributes(child.meta, ["tab"]);
|
|
177
|
+
if (!meta.attributes.tab) {
|
|
178
|
+
close();
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
181
|
+
if (start === -1) start = end;
|
|
182
|
+
child.meta = meta.rest;
|
|
183
|
+
child.data ??= {};
|
|
184
|
+
child.data.tab = meta.attributes.tab;
|
|
185
|
+
}
|
|
186
|
+
close();
|
|
187
|
+
});
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
function processTabValue(nodes) {
|
|
191
|
+
const out = /* @__PURE__ */ new Map();
|
|
192
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
193
|
+
const node = nodes[i];
|
|
194
|
+
const name = node.data?.tab ?? `Tab ${i + 1}`;
|
|
195
|
+
const li = out.get(name) ?? [];
|
|
196
|
+
li.push(node);
|
|
197
|
+
out.set(name, li);
|
|
198
|
+
}
|
|
199
|
+
return out;
|
|
200
|
+
}
|
|
201
|
+
function mdxToAst(processor, name) {
|
|
202
|
+
const node = processor.parse(name);
|
|
203
|
+
if (node.type === "root") {
|
|
204
|
+
node.children = node.children.flatMap((child) => {
|
|
205
|
+
if (child.type === "paragraph") return child.children;
|
|
206
|
+
return child;
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
return node;
|
|
210
|
+
}
|
|
211
|
+
function createFragment(children) {
|
|
212
|
+
return {
|
|
213
|
+
type: "mdxJsxFlowElement",
|
|
214
|
+
name: null,
|
|
215
|
+
attributes: [],
|
|
216
|
+
children
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
export {
|
|
221
|
+
remarkCodeTab
|
|
222
|
+
};
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
// src/mdx-plugins/rehype-toc.ts
|
|
2
|
+
import { toEstree } from "hast-util-to-estree";
|
|
3
|
+
|
|
4
|
+
// src/mdx-plugins/hast-utils.ts
|
|
5
|
+
function visit(node, tagNames, handler) {
|
|
6
|
+
if (node.type === "element" && tagNames.includes(node.tagName)) {
|
|
7
|
+
const result = handler(node);
|
|
8
|
+
if (result === "skip") return;
|
|
9
|
+
}
|
|
10
|
+
if ("children" in node)
|
|
11
|
+
node.children.forEach((n) => {
|
|
12
|
+
visit(n, tagNames, handler);
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// src/mdx-plugins/rehype-toc.ts
|
|
17
|
+
var TocOnlyTag = "[toc]";
|
|
18
|
+
var NoTocTag = "[!toc]";
|
|
19
|
+
function rehypeToc({ exportToc = true } = {}) {
|
|
20
|
+
return (tree) => {
|
|
21
|
+
const output = [];
|
|
22
|
+
visit(tree, ["h1", "h2", "h3", "h4", "h5", "h6"], (element) => {
|
|
23
|
+
const id = element.properties.id;
|
|
24
|
+
if (typeof id !== "string") return "skip";
|
|
25
|
+
let isTocOnly = false;
|
|
26
|
+
const last = element.children.at(-1);
|
|
27
|
+
if (last?.type === "text" && last.value.endsWith(TocOnlyTag)) {
|
|
28
|
+
isTocOnly = true;
|
|
29
|
+
last.value = last.value.substring(0, last.value.length - TocOnlyTag.length).trimEnd();
|
|
30
|
+
} else if (last?.type === "text" && last.value.endsWith(NoTocTag)) {
|
|
31
|
+
last.value = last.value.substring(0, last.value.length - NoTocTag.length).trimEnd();
|
|
32
|
+
return "skip";
|
|
33
|
+
}
|
|
34
|
+
const estree = toEstree(element, {
|
|
35
|
+
elementAttributeNameCase: "react",
|
|
36
|
+
stylePropertyNameCase: "dom"
|
|
37
|
+
});
|
|
38
|
+
if (estree.body[0].type === "ExpressionStatement")
|
|
39
|
+
output.push({
|
|
40
|
+
title: estree.body[0].expression,
|
|
41
|
+
depth: Number(element.tagName.slice(1)),
|
|
42
|
+
url: `#${id}`
|
|
43
|
+
});
|
|
44
|
+
if (isTocOnly) {
|
|
45
|
+
Object.assign(element, {
|
|
46
|
+
type: "comment",
|
|
47
|
+
value: ""
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
return "skip";
|
|
51
|
+
});
|
|
52
|
+
const declaration = {
|
|
53
|
+
type: "VariableDeclaration",
|
|
54
|
+
kind: "const",
|
|
55
|
+
declarations: [
|
|
56
|
+
{
|
|
57
|
+
type: "VariableDeclarator",
|
|
58
|
+
id: {
|
|
59
|
+
type: "Identifier",
|
|
60
|
+
name: "toc"
|
|
61
|
+
},
|
|
62
|
+
init: {
|
|
63
|
+
type: "ArrayExpression",
|
|
64
|
+
elements: output.map((item) => ({
|
|
65
|
+
type: "ObjectExpression",
|
|
66
|
+
properties: [
|
|
67
|
+
{
|
|
68
|
+
type: "Property",
|
|
69
|
+
method: false,
|
|
70
|
+
shorthand: false,
|
|
71
|
+
computed: false,
|
|
72
|
+
key: {
|
|
73
|
+
type: "Identifier",
|
|
74
|
+
name: "depth"
|
|
75
|
+
},
|
|
76
|
+
value: {
|
|
77
|
+
type: "Literal",
|
|
78
|
+
value: item.depth
|
|
79
|
+
},
|
|
80
|
+
kind: "init"
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
type: "Property",
|
|
84
|
+
method: false,
|
|
85
|
+
shorthand: false,
|
|
86
|
+
computed: false,
|
|
87
|
+
key: {
|
|
88
|
+
type: "Identifier",
|
|
89
|
+
name: "url"
|
|
90
|
+
},
|
|
91
|
+
value: {
|
|
92
|
+
type: "Literal",
|
|
93
|
+
value: item.url
|
|
94
|
+
},
|
|
95
|
+
kind: "init"
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
type: "Property",
|
|
99
|
+
method: false,
|
|
100
|
+
shorthand: false,
|
|
101
|
+
computed: false,
|
|
102
|
+
key: {
|
|
103
|
+
type: "Identifier",
|
|
104
|
+
name: "title"
|
|
105
|
+
},
|
|
106
|
+
value: {
|
|
107
|
+
type: "JSXFragment",
|
|
108
|
+
openingFragment: { type: "JSXOpeningFragment" },
|
|
109
|
+
closingFragment: { type: "JSXClosingFragment" },
|
|
110
|
+
children: item.title.children
|
|
111
|
+
},
|
|
112
|
+
kind: "init"
|
|
113
|
+
}
|
|
114
|
+
]
|
|
115
|
+
}))
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
]
|
|
119
|
+
};
|
|
120
|
+
tree.children.push({
|
|
121
|
+
type: "mdxjsEsm",
|
|
122
|
+
value: "",
|
|
123
|
+
data: {
|
|
124
|
+
estree: {
|
|
125
|
+
type: "Program",
|
|
126
|
+
body: [
|
|
127
|
+
exportToc ? {
|
|
128
|
+
type: "ExportNamedDeclaration",
|
|
129
|
+
declaration,
|
|
130
|
+
attributes: [],
|
|
131
|
+
specifiers: []
|
|
132
|
+
} : declaration
|
|
133
|
+
],
|
|
134
|
+
sourceType: "module",
|
|
135
|
+
comments: []
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export {
|
|
143
|
+
rehypeToc
|
|
144
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// src/utils/use-on-change.ts
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
function isDifferent(a, b) {
|
|
4
|
+
if (Array.isArray(a) && Array.isArray(b)) {
|
|
5
|
+
return b.length !== a.length || a.some((v, i) => isDifferent(v, b[i]));
|
|
6
|
+
}
|
|
7
|
+
return a !== b;
|
|
8
|
+
}
|
|
9
|
+
function useOnChange(value, onChange, isUpdated = isDifferent) {
|
|
10
|
+
const [prev, setPrev] = useState(value);
|
|
11
|
+
if (isUpdated(prev, value)) {
|
|
12
|
+
onChange(value, prev);
|
|
13
|
+
setPrev(value);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export {
|
|
18
|
+
useOnChange
|
|
19
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// src/source/plugins/icon.ts
|
|
2
|
+
function iconPlugin(resolveIcon) {
|
|
3
|
+
function replaceIcon(node) {
|
|
4
|
+
if (node.icon === void 0 || typeof node.icon === "string")
|
|
5
|
+
node.icon = resolveIcon(node.icon);
|
|
6
|
+
return node;
|
|
7
|
+
}
|
|
8
|
+
return {
|
|
9
|
+
name: "fumadocs:icon",
|
|
10
|
+
transformPageTree: {
|
|
11
|
+
file: replaceIcon,
|
|
12
|
+
folder: replaceIcon,
|
|
13
|
+
separator: replaceIcon
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export {
|
|
19
|
+
iconPlugin
|
|
20
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// src/mdx-plugins/remark-mdx-mermaid.ts
|
|
2
|
+
import { visit } from "unist-util-visit";
|
|
3
|
+
function toMDX(code) {
|
|
4
|
+
return {
|
|
5
|
+
type: "mdxJsxFlowElement",
|
|
6
|
+
name: "Mermaid",
|
|
7
|
+
attributes: [
|
|
8
|
+
{
|
|
9
|
+
type: "mdxJsxAttribute",
|
|
10
|
+
name: "chart",
|
|
11
|
+
value: code.trim()
|
|
12
|
+
}
|
|
13
|
+
],
|
|
14
|
+
children: []
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function remarkMdxMermaid(options = {}) {
|
|
18
|
+
const { lang = "mermaid" } = options;
|
|
19
|
+
return (tree) => {
|
|
20
|
+
visit(tree, "code", (node) => {
|
|
21
|
+
if (node.lang !== lang || !node.value) return;
|
|
22
|
+
Object.assign(node, toMDX(node.value));
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export {
|
|
28
|
+
remarkMdxMermaid
|
|
29
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// src/content/mdx/util.ts
|
|
2
|
+
async function resolvePlugins(def, options = []) {
|
|
3
|
+
const list = (await Promise.all(def(Array.isArray(options) ? options : []))).filter((v) => v !== false);
|
|
4
|
+
if (typeof options === "function") {
|
|
5
|
+
return Promise.all(options(list));
|
|
6
|
+
}
|
|
7
|
+
return list;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export {
|
|
11
|
+
resolvePlugins
|
|
12
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import {
|
|
2
|
+
generateCodeBlockTabs
|
|
3
|
+
} from "./chunk-TWIDBWFG.js";
|
|
4
|
+
|
|
5
|
+
// src/mdx-plugins/remark-npm.ts
|
|
6
|
+
import { visit } from "unist-util-visit";
|
|
7
|
+
import convert from "npm-to-yarn";
|
|
8
|
+
var aliases = ["npm", "package-install"];
|
|
9
|
+
function remarkNpm({
|
|
10
|
+
persist = false,
|
|
11
|
+
packageManagers = [
|
|
12
|
+
{ command: (cmd) => convert(cmd, "npm"), name: "npm" },
|
|
13
|
+
{ command: (cmd) => convert(cmd, "pnpm"), name: "pnpm" },
|
|
14
|
+
{ command: (cmd) => convert(cmd, "yarn"), name: "yarn" },
|
|
15
|
+
{ command: (cmd) => convert(cmd, "bun"), name: "bun" }
|
|
16
|
+
]
|
|
17
|
+
} = {}) {
|
|
18
|
+
return (tree) => {
|
|
19
|
+
visit(tree, "code", (node) => {
|
|
20
|
+
if (!node.lang || !aliases.includes(node.lang)) return;
|
|
21
|
+
let code = node.value;
|
|
22
|
+
if (node.lang === "package-install" && !code.startsWith("npm") && !code.startsWith("npx")) {
|
|
23
|
+
code = `npm install ${code}`;
|
|
24
|
+
}
|
|
25
|
+
const options = {
|
|
26
|
+
persist,
|
|
27
|
+
tabs: [],
|
|
28
|
+
triggers: []
|
|
29
|
+
};
|
|
30
|
+
for (const manager of packageManagers) {
|
|
31
|
+
const value = manager.value ?? manager.name;
|
|
32
|
+
const command = manager.command(code);
|
|
33
|
+
if (!command || command.length === 0) continue;
|
|
34
|
+
options.defaultValue ??= value;
|
|
35
|
+
options.triggers.push({
|
|
36
|
+
value,
|
|
37
|
+
children: [{ type: "text", value: manager.name }]
|
|
38
|
+
});
|
|
39
|
+
options.tabs.push({
|
|
40
|
+
value,
|
|
41
|
+
children: [
|
|
42
|
+
{
|
|
43
|
+
type: "code",
|
|
44
|
+
lang: "bash",
|
|
45
|
+
meta: node.meta,
|
|
46
|
+
value: command
|
|
47
|
+
}
|
|
48
|
+
]
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
Object.assign(node, generateCodeBlockTabs(options));
|
|
52
|
+
return "skip";
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export {
|
|
58
|
+
remarkNpm
|
|
59
|
+
};
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import {
|
|
2
|
+
flattenNode,
|
|
3
|
+
toMdxExport
|
|
4
|
+
} from "./chunk-VLSDGCJE.js";
|
|
5
|
+
|
|
6
|
+
// src/mdx-plugins/remark-structure.ts
|
|
7
|
+
import Slugger from "github-slugger";
|
|
8
|
+
import { remark } from "remark";
|
|
9
|
+
import remarkGfm from "remark-gfm";
|
|
10
|
+
import { visit } from "unist-util-visit";
|
|
11
|
+
var remarkStructureDefaultOptions = {
|
|
12
|
+
types: [
|
|
13
|
+
"heading",
|
|
14
|
+
"paragraph",
|
|
15
|
+
"blockquote",
|
|
16
|
+
"tableCell",
|
|
17
|
+
"mdxJsxFlowElement"
|
|
18
|
+
],
|
|
19
|
+
allowedMdxAttributes: (node) => {
|
|
20
|
+
if (!node.name) return false;
|
|
21
|
+
return ["TypeTable", "Callout"].includes(node.name);
|
|
22
|
+
},
|
|
23
|
+
exportAs: false
|
|
24
|
+
};
|
|
25
|
+
function remarkStructure({
|
|
26
|
+
types = remarkStructureDefaultOptions.types,
|
|
27
|
+
allowedMdxAttributes = remarkStructureDefaultOptions.allowedMdxAttributes,
|
|
28
|
+
exportAs = remarkStructureDefaultOptions.exportAs
|
|
29
|
+
} = {}) {
|
|
30
|
+
const slugger = new Slugger();
|
|
31
|
+
if (Array.isArray(allowedMdxAttributes)) {
|
|
32
|
+
const arr = allowedMdxAttributes;
|
|
33
|
+
allowedMdxAttributes = (_node, attribute) => attribute.type === "mdxJsxAttribute" && arr.includes(attribute.name);
|
|
34
|
+
}
|
|
35
|
+
if (Array.isArray(types)) {
|
|
36
|
+
const arr = types;
|
|
37
|
+
types = (node) => arr.includes(node.type);
|
|
38
|
+
}
|
|
39
|
+
return (tree, file) => {
|
|
40
|
+
slugger.reset();
|
|
41
|
+
const data = { contents: [], headings: [] };
|
|
42
|
+
let lastHeading;
|
|
43
|
+
if (file.data.frontmatter) {
|
|
44
|
+
const frontmatter = file.data.frontmatter;
|
|
45
|
+
if (frontmatter._openapi?.structuredData) {
|
|
46
|
+
data.headings.push(...frontmatter._openapi.structuredData.headings);
|
|
47
|
+
data.contents.push(...frontmatter._openapi.structuredData.contents);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
visit(tree, (element) => {
|
|
51
|
+
if (element.type === "root" || !types(element)) return;
|
|
52
|
+
if (element.type === "heading") {
|
|
53
|
+
element.data ||= {};
|
|
54
|
+
element.data.hProperties ||= {};
|
|
55
|
+
const properties = element.data.hProperties;
|
|
56
|
+
const content2 = flattenNode(element).trim();
|
|
57
|
+
const id = properties.id ?? slugger.slug(content2);
|
|
58
|
+
data.headings.push({
|
|
59
|
+
id,
|
|
60
|
+
content: content2
|
|
61
|
+
});
|
|
62
|
+
lastHeading = id;
|
|
63
|
+
return "skip";
|
|
64
|
+
}
|
|
65
|
+
if (element.data?._string) {
|
|
66
|
+
for (const content2 of element.data._string) {
|
|
67
|
+
data.contents.push({
|
|
68
|
+
heading: lastHeading,
|
|
69
|
+
content: content2
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
return "skip";
|
|
73
|
+
}
|
|
74
|
+
if (element.type === "mdxJsxFlowElement" && element.name) {
|
|
75
|
+
data.contents.push(
|
|
76
|
+
...element.attributes.flatMap((attribute) => {
|
|
77
|
+
const value = typeof attribute.value === "string" ? attribute.value : attribute.value?.value;
|
|
78
|
+
if (!value || value.length === 0) return [];
|
|
79
|
+
if (allowedMdxAttributes && !allowedMdxAttributes(element, attribute))
|
|
80
|
+
return [];
|
|
81
|
+
return {
|
|
82
|
+
heading: lastHeading,
|
|
83
|
+
content: attribute.type === "mdxJsxAttribute" ? `${attribute.name}: ${value}` : value
|
|
84
|
+
};
|
|
85
|
+
})
|
|
86
|
+
);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
const content = flattenNode(element).trim();
|
|
90
|
+
if (content.length === 0) return;
|
|
91
|
+
data.contents.push({
|
|
92
|
+
heading: lastHeading,
|
|
93
|
+
content
|
|
94
|
+
});
|
|
95
|
+
return "skip";
|
|
96
|
+
});
|
|
97
|
+
file.data.structuredData = data;
|
|
98
|
+
if (exportAs) {
|
|
99
|
+
tree.children.unshift(
|
|
100
|
+
toMdxExport(
|
|
101
|
+
typeof exportAs === "string" ? exportAs : "structuredData",
|
|
102
|
+
data
|
|
103
|
+
)
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
function structure(content, remarkPlugins = [], options = {}) {
|
|
109
|
+
const result = remark().use(remarkGfm).use(remarkPlugins).use(remarkStructure, options).processSync(content);
|
|
110
|
+
return result.data.structuredData;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export {
|
|
114
|
+
remarkStructureDefaultOptions,
|
|
115
|
+
remarkStructure,
|
|
116
|
+
structure
|
|
117
|
+
};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// src/framework/index.tsx
|
|
2
|
+
import { createContext, use, useMemo } from "react";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
var notImplemented = () => {
|
|
5
|
+
throw new Error(
|
|
6
|
+
"You need to wrap your application inside `FrameworkProvider`."
|
|
7
|
+
);
|
|
8
|
+
};
|
|
9
|
+
var FrameworkContext = createContext({
|
|
10
|
+
useParams: notImplemented,
|
|
11
|
+
useRouter: notImplemented,
|
|
12
|
+
usePathname: notImplemented
|
|
13
|
+
});
|
|
14
|
+
function FrameworkProvider({
|
|
15
|
+
Link: Link2,
|
|
16
|
+
useRouter: useRouter2,
|
|
17
|
+
useParams: useParams2,
|
|
18
|
+
usePathname: usePathname2,
|
|
19
|
+
Image: Image2,
|
|
20
|
+
children
|
|
21
|
+
}) {
|
|
22
|
+
const framework = useMemo(
|
|
23
|
+
() => ({
|
|
24
|
+
usePathname: usePathname2,
|
|
25
|
+
useRouter: useRouter2,
|
|
26
|
+
Link: Link2,
|
|
27
|
+
Image: Image2,
|
|
28
|
+
useParams: useParams2
|
|
29
|
+
}),
|
|
30
|
+
[Link2, usePathname2, useRouter2, useParams2, Image2]
|
|
31
|
+
);
|
|
32
|
+
return /* @__PURE__ */ jsx(FrameworkContext, { value: framework, children });
|
|
33
|
+
}
|
|
34
|
+
function usePathname() {
|
|
35
|
+
return use(FrameworkContext).usePathname();
|
|
36
|
+
}
|
|
37
|
+
function useRouter() {
|
|
38
|
+
return use(FrameworkContext).useRouter();
|
|
39
|
+
}
|
|
40
|
+
function useParams() {
|
|
41
|
+
return use(FrameworkContext).useParams();
|
|
42
|
+
}
|
|
43
|
+
function Image(props) {
|
|
44
|
+
const { Image: Image2 } = use(FrameworkContext);
|
|
45
|
+
if (!Image2) {
|
|
46
|
+
const { src, alt, priority, ...rest } = props;
|
|
47
|
+
return /* @__PURE__ */ jsx(
|
|
48
|
+
"img",
|
|
49
|
+
{
|
|
50
|
+
alt,
|
|
51
|
+
src,
|
|
52
|
+
fetchPriority: priority ? "high" : "auto",
|
|
53
|
+
...rest
|
|
54
|
+
}
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
return /* @__PURE__ */ jsx(Image2, { ...props });
|
|
58
|
+
}
|
|
59
|
+
function Link(props) {
|
|
60
|
+
const { Link: Link2 } = use(FrameworkContext);
|
|
61
|
+
if (!Link2) {
|
|
62
|
+
const { href, prefetch: _, ...rest } = props;
|
|
63
|
+
return /* @__PURE__ */ jsx("a", { href, ...rest });
|
|
64
|
+
}
|
|
65
|
+
return /* @__PURE__ */ jsx(Link2, { ...props });
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export {
|
|
69
|
+
FrameworkProvider,
|
|
70
|
+
usePathname,
|
|
71
|
+
useRouter,
|
|
72
|
+
useParams,
|
|
73
|
+
Image,
|
|
74
|
+
Link
|
|
75
|
+
};
|