@vezham/docs-core 1.0.1
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/advanced-Ct13khZr.js +79 -0
- package/dist/algolia-C0E5qQhM.d.ts +66 -0
- package/dist/breadcrumb.d.ts +46 -0
- package/dist/breadcrumb.js +59 -0
- package/dist/build-doc-4OvfjVN2.js +85 -0
- package/dist/client-kQ39Ub0-.d.ts +247 -0
- package/dist/codeblock-utils-CyP8qsYv.d.ts +29 -0
- package/dist/content/github.d.ts +41 -0
- package/dist/content/github.js +28 -0
- package/dist/content/md/frontmatter.d.ts +15 -0
- package/dist/content/md/frontmatter.js +24 -0
- package/dist/content/md.d.ts +24 -0
- package/dist/content/md.js +43 -0
- package/dist/content/mdx/preset-bundler.d.ts +29 -0
- package/dist/content/mdx/preset-bundler.js +39 -0
- package/dist/content/mdx/preset-runtime.d.ts +26 -0
- package/dist/content/mdx/preset-runtime.js +36 -0
- package/dist/content/toc.d.ts +19 -0
- package/dist/content/toc.js +14 -0
- package/dist/definitions-CFOhwE1k.d.ts +72 -0
- package/dist/dynamic-CTsodhTH.js +905 -0
- package/dist/dynamic-link.d.ts +12 -0
- package/dist/dynamic-link.js +31 -0
- package/dist/endpoint-MyoBU5IC.js +28 -0
- package/dist/framework/astro.d.ts +21 -0
- package/dist/framework/astro.js +52 -0
- package/dist/framework/index.d.ts +40 -0
- package/dist/framework/index.js +66 -0
- package/dist/framework/next.d.ts +10 -0
- package/dist/framework/next.js +19 -0
- package/dist/framework/react-router.d.ts +10 -0
- package/dist/framework/react-router.js +43 -0
- package/dist/framework/tanstack.d.ts +13 -0
- package/dist/framework/tanstack.js +54 -0
- package/dist/framework/waku.d.ts +10 -0
- package/dist/framework/waku.js +46 -0
- package/dist/highlight/client.d.ts +11 -0
- package/dist/highlight/client.js +15 -0
- package/dist/highlight/index.d.ts +31 -0
- package/dist/highlight/index.js +30 -0
- package/dist/highlight/shiki/full.d.ts +7 -0
- package/dist/highlight/shiki/full.js +23 -0
- package/dist/highlight/shiki/index.d.ts +2 -0
- package/dist/highlight/shiki/index.js +27 -0
- package/dist/highlight/shiki/react.d.ts +23 -0
- package/dist/highlight/shiki/react.js +50 -0
- package/dist/i18n/index.d.ts +2 -0
- package/dist/i18n/index.js +63 -0
- package/dist/i18n/middleware.d.ts +34 -0
- package/dist/i18n/middleware.js +3855 -0
- package/dist/icon-BILaoXeg.js +17 -0
- package/dist/index-B-0R0VbS.d.ts +18 -0
- package/dist/index-BM36H-xw.d.ts +36 -0
- package/dist/index-BMEUQz-F.d.ts +21 -0
- package/dist/index-DAYtLGbx.d.ts +16 -0
- package/dist/index-DIwKCYOz.d.ts +513 -0
- package/dist/index-DydiXvgS.d.ts +90 -0
- package/dist/index-E8Qh_yQs.d.ts +49 -0
- package/dist/is-equal-LdLqRs0o.js +8 -0
- package/dist/link.d.ts +17 -0
- package/dist/link.js +23 -0
- package/dist/mdx-plugins/codeblock-utils.d.ts +2 -0
- package/dist/mdx-plugins/codeblock-utils.js +68 -0
- package/dist/mdx-plugins/index.d.ts +20 -0
- package/dist/mdx-plugins/index.js +18 -0
- package/dist/mdx-plugins/rehype-code.core.d.ts +3 -0
- package/dist/mdx-plugins/rehype-code.core.js +3 -0
- package/dist/mdx-plugins/rehype-code.d.ts +4 -0
- package/dist/mdx-plugins/rehype-code.js +24 -0
- package/dist/mdx-plugins/rehype-toc.d.ts +2 -0
- package/dist/mdx-plugins/rehype-toc.js +139 -0
- package/dist/mdx-plugins/remark-admonition.d.ts +2 -0
- package/dist/mdx-plugins/remark-admonition.js +71 -0
- package/dist/mdx-plugins/remark-block-id.d.ts +37 -0
- package/dist/mdx-plugins/remark-block-id.js +41 -0
- package/dist/mdx-plugins/remark-code-tab.d.ts +2 -0
- package/dist/mdx-plugins/remark-code-tab.js +190 -0
- package/dist/mdx-plugins/remark-directive-admonition.d.ts +2 -0
- package/dist/mdx-plugins/remark-directive-admonition.js +57 -0
- package/dist/mdx-plugins/remark-feedback-block.d.ts +2 -0
- package/dist/mdx-plugins/remark-feedback-block.js +54 -0
- package/dist/mdx-plugins/remark-gfm.d.ts +2 -0
- package/dist/mdx-plugins/remark-gfm.js +2 -0
- package/dist/mdx-plugins/remark-heading.d.ts +2 -0
- package/dist/mdx-plugins/remark-heading.js +46 -0
- package/dist/mdx-plugins/remark-image.d.ts +2 -0
- package/dist/mdx-plugins/remark-image.js +167 -0
- package/dist/mdx-plugins/remark-llms.d.ts +2 -0
- package/dist/mdx-plugins/remark-llms.js +338 -0
- package/dist/mdx-plugins/remark-llms.runtime.d.ts +10 -0
- package/dist/mdx-plugins/remark-llms.runtime.js +24 -0
- package/dist/mdx-plugins/remark-mdx-files.d.ts +2 -0
- package/dist/mdx-plugins/remark-mdx-files.js +182 -0
- package/dist/mdx-plugins/remark-mdx-mermaid.d.ts +2 -0
- package/dist/mdx-plugins/remark-mdx-mermaid.js +28 -0
- package/dist/mdx-plugins/remark-npm.d.ts +2 -0
- package/dist/mdx-plugins/remark-npm.js +76 -0
- package/dist/mdx-plugins/remark-steps.d.ts +2 -0
- package/dist/mdx-plugins/remark-steps.js +93 -0
- package/dist/mdx-plugins/remark-structure.d.ts +2 -0
- package/dist/mdx-plugins/remark-structure.js +118 -0
- package/dist/mdx-plugins/stringifier.d.ts +2 -0
- package/dist/mdx-plugins/stringifier.js +91 -0
- package/dist/mdx-plugins/transformer-icon.d.ts +2 -0
- package/dist/mdx-plugins/transformer-icon.js +145 -0
- package/dist/negotiation/index.d.ts +17 -0
- package/dist/negotiation/index.js +378 -0
- package/dist/page-tree/index.d.ts +3 -0
- package/dist/page-tree/index.js +2 -0
- package/dist/path-1H5VzYiT.js +75 -0
- package/dist/rehype-code-D-RFJb9W.d.ts +14 -0
- package/dist/rehype-code.core-BUwNuchP.js +548 -0
- package/dist/rehype-code.core-BjH1uHWj.d.ts +115 -0
- package/dist/rehype-toc-K51AGb5U.d.ts +43 -0
- package/dist/remark-admonition-BwTcmI_S.d.ts +20 -0
- package/dist/remark-code-tab-DE_4bdnu.d.ts +34 -0
- package/dist/remark-directive-admonition-BLiJ5l43.d.ts +27 -0
- package/dist/remark-feedback-block-BxtINXN-.d.ts +45 -0
- package/dist/remark-gfm-DpVfAX1x.d.ts +2 -0
- package/dist/remark-heading-DEIzTkU5.d.ts +33 -0
- package/dist/remark-image-BI2S9LOb.d.ts +57 -0
- package/dist/remark-llms-bD3WvU2V.d.ts +73 -0
- package/dist/remark-mdx-files-Buvxc-sa.d.ts +54 -0
- package/dist/remark-mdx-mermaid-C1bCHHc6.d.ts +15 -0
- package/dist/remark-npm-BbpvkJaT.d.ts +31 -0
- package/dist/remark-steps-DqVEo0iq.d.ts +23 -0
- package/dist/remark-structure-CnHwvNZr.d.ts +87 -0
- package/dist/remove-markdown-DfKNMl9w.js +40 -0
- package/dist/remove-undefined-CzMSKybq.js +24 -0
- package/dist/rolldown-runtime-DC62tzP2.js +33 -0
- package/dist/search/algolia.d.ts +2 -0
- package/dist/search/algolia.js +75 -0
- package/dist/search/client/algolia.d.ts +2 -0
- package/dist/search/client/algolia.js +53 -0
- package/dist/search/client/fetch.d.ts +2 -0
- package/dist/search/client/fetch.js +28 -0
- package/dist/search/client/flexsearch-static.d.ts +2 -0
- package/dist/search/client/flexsearch-static.js +42 -0
- package/dist/search/client/mixedbread.d.ts +2 -0
- package/dist/search/client/mixedbread.js +65 -0
- package/dist/search/client/orama-cloud-legacy.d.ts +2 -0
- package/dist/search/client/orama-cloud-legacy.js +84 -0
- package/dist/search/client/orama-cloud.d.ts +2 -0
- package/dist/search/client/orama-cloud.js +86 -0
- package/dist/search/client/orama-static.d.ts +2 -0
- package/dist/search/client/orama-static.js +75 -0
- package/dist/search/client.d.ts +2 -0
- package/dist/search/client.js +97 -0
- package/dist/search/flexsearch.d.ts +56 -0
- package/dist/search/flexsearch.js +128 -0
- package/dist/search/index.d.ts +2 -0
- package/dist/search/index.js +74 -0
- package/dist/search/mixedbread.d.ts +49 -0
- package/dist/search/mixedbread.js +77 -0
- package/dist/search/orama-cloud-legacy.d.ts +75 -0
- package/dist/search/orama-cloud-legacy.js +48 -0
- package/dist/search/orama-cloud.d.ts +75 -0
- package/dist/search/orama-cloud.js +50 -0
- package/dist/search/server.d.ts +2 -0
- package/dist/search/server.js +237 -0
- package/dist/server-CCqACwlF.d.ts +165 -0
- package/dist/server.browser.d.ts +13 -0
- package/dist/server.browser.js +22 -0
- package/dist/server.d.ts +42 -0
- package/dist/server.js +398 -0
- package/dist/source/client/index.d.ts +2 -0
- package/dist/source/client/index.js +37 -0
- package/dist/source/dynamic.d.ts +2 -0
- package/dist/source/dynamic.js +2 -0
- package/dist/source/index.d.ts +2 -0
- package/dist/source/index.js +5 -0
- package/dist/source/llms.d.ts +2 -0
- package/dist/source/llms.js +74 -0
- package/dist/source/plugins/lucide-icons.d.ts +11 -0
- package/dist/source/plugins/lucide-icons.js +21 -0
- package/dist/source/plugins/slugs.d.ts +2 -0
- package/dist/source/plugins/slugs.js +75 -0
- package/dist/source/plugins/status-badges.d.ts +50 -0
- package/dist/source/plugins/status-badges.js +52 -0
- package/dist/source/schema.d.ts +30 -0
- package/dist/source/schema.js +28 -0
- package/dist/stringifier-B_QUcUyo.d.ts +63 -0
- package/dist/toc-CtW5lwA1.d.ts +64 -0
- package/dist/toc.d.ts +2 -0
- package/dist/toc.js +245 -0
- package/dist/transformer-icon-DlrneIS3.d.ts +17 -0
- package/dist/types-D89QoQR-.d.ts +4 -0
- package/dist/url-BVHvi3_K.js +29 -0
- package/dist/util-BDsqOxh3.d.ts +6 -0
- package/dist/util-DjBr9b3w.js +8 -0
- package/dist/utils/use-media-query.d.ts +4 -0
- package/dist/utils/use-media-query.js +20 -0
- package/dist/utils/use-on-change.d.ts +9 -0
- package/dist/utils/use-on-change.js +17 -0
- package/dist/utils-Bvy3V-fv.js +59 -0
- package/dist/utils-Cgs-6U-z.js +39 -0
- package/dist/utils-DEVq3cEC.js +151 -0
- package/dist/utils-Yx0IL9eW.js +48 -0
- package/package.json +251 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { createContentHighlighter } from "./search/index.js";
|
|
2
|
+
import Search from "flexsearch";
|
|
3
|
+
//#region src/search/flexsearch/utils.ts
|
|
4
|
+
async function search(index, query, tag, limit = 60) {
|
|
5
|
+
const arr = await index.searchAsync(query, {
|
|
6
|
+
index: "content",
|
|
7
|
+
limit,
|
|
8
|
+
tag: tag ? { tags: tag } : void 0
|
|
9
|
+
});
|
|
10
|
+
const out = [];
|
|
11
|
+
if (arr.length === 0) return out;
|
|
12
|
+
const results = arr[0].result;
|
|
13
|
+
const highlighter = createContentHighlighter(query);
|
|
14
|
+
const grouped = /* @__PURE__ */ new Map();
|
|
15
|
+
for (const id of results) {
|
|
16
|
+
const doc = index.get(id);
|
|
17
|
+
if (!doc) continue;
|
|
18
|
+
let list = grouped.get(doc.page_id);
|
|
19
|
+
if (!list) {
|
|
20
|
+
list = [];
|
|
21
|
+
grouped.set(doc.page_id, list);
|
|
22
|
+
}
|
|
23
|
+
if (doc.type !== "page") list.push(doc);
|
|
24
|
+
}
|
|
25
|
+
for (const [page_id, items] of grouped) {
|
|
26
|
+
const page = index.get(page_id);
|
|
27
|
+
if (!page) continue;
|
|
28
|
+
out.push({
|
|
29
|
+
id: page_id,
|
|
30
|
+
type: "page",
|
|
31
|
+
content: highlighter.highlightMarkdown(page.content),
|
|
32
|
+
breadcrumbs: page.breadcrumbs,
|
|
33
|
+
url: page.url
|
|
34
|
+
});
|
|
35
|
+
for (const item of items) out.push({
|
|
36
|
+
id: item.id,
|
|
37
|
+
content: highlighter.highlightMarkdown(item.content),
|
|
38
|
+
breadcrumbs: item.breadcrumbs,
|
|
39
|
+
type: item.type,
|
|
40
|
+
url: item.url
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
return out;
|
|
44
|
+
}
|
|
45
|
+
function createDocument(options) {
|
|
46
|
+
return new Search.Document({
|
|
47
|
+
tokenize: "full",
|
|
48
|
+
...options,
|
|
49
|
+
document: {
|
|
50
|
+
id: "id",
|
|
51
|
+
index: ["content"],
|
|
52
|
+
tag: ["tags"],
|
|
53
|
+
store: true,
|
|
54
|
+
...options?.document
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
//#endregion
|
|
59
|
+
export { search as n, createDocument as t };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
//#region src/highlight/utils.ts
|
|
2
|
+
async function loadMissingTheme(highlighter, themes) {
|
|
3
|
+
const bundled = highlighter.getBundledThemes();
|
|
4
|
+
const loaded = highlighter.getLoadedThemes();
|
|
5
|
+
const missingThemes = themes.filter((theme) => {
|
|
6
|
+
if (typeof theme === "string") return theme in bundled && !loaded.includes(theme);
|
|
7
|
+
return theme.name === void 0 || !loaded.includes(theme.name);
|
|
8
|
+
});
|
|
9
|
+
if (missingThemes.length > 0) await highlighter.loadTheme(...missingThemes);
|
|
10
|
+
}
|
|
11
|
+
async function loadMissingLanguage(highlighter, langs) {
|
|
12
|
+
const bundled = highlighter.getBundledLanguages();
|
|
13
|
+
const loaded = highlighter.getLoadedLanguages();
|
|
14
|
+
const missingLangs = langs.filter((lang) => {
|
|
15
|
+
if (typeof lang === "string") return lang in bundled && !loaded.includes(lang);
|
|
16
|
+
return !loaded.includes(lang.name);
|
|
17
|
+
});
|
|
18
|
+
if (missingLangs.length > 0) await highlighter.loadLanguage(...missingLangs);
|
|
19
|
+
}
|
|
20
|
+
function getRequiredThemes(options) {
|
|
21
|
+
if ("theme" in options) return [options.theme];
|
|
22
|
+
else return Object.values(options.themes).filter((v) => v !== void 0);
|
|
23
|
+
}
|
|
24
|
+
function applyDefaultThemes(options, defaultValue = defaultThemes) {
|
|
25
|
+
if (!("theme" in options) && !("themes" in options)) return {
|
|
26
|
+
...defaultValue,
|
|
27
|
+
...options
|
|
28
|
+
};
|
|
29
|
+
else return options;
|
|
30
|
+
}
|
|
31
|
+
const defaultThemes = {
|
|
32
|
+
themes: {
|
|
33
|
+
light: "github-light",
|
|
34
|
+
dark: "github-dark"
|
|
35
|
+
},
|
|
36
|
+
defaultColor: false
|
|
37
|
+
};
|
|
38
|
+
//#endregion
|
|
39
|
+
export { loadMissingTheme as a, loadMissingLanguage as i, defaultThemes as n, getRequiredThemes as r, applyDefaultThemes as t };
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
//#region src/page-tree/utils.ts
|
|
2
|
+
/**
|
|
3
|
+
* Flatten tree to an array of page nodes
|
|
4
|
+
*/
|
|
5
|
+
function flattenTree(nodes) {
|
|
6
|
+
const out = [];
|
|
7
|
+
for (const node of nodes) if (node.type === "folder") {
|
|
8
|
+
if (node.index) out.push(node.index);
|
|
9
|
+
out.push(...flattenTree(node.children));
|
|
10
|
+
} else if (node.type === "page") out.push(node);
|
|
11
|
+
return out;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Get neighbours of a page, useful for implementing "previous & next" buttons
|
|
15
|
+
*/
|
|
16
|
+
function findNeighbour(tree, url, options) {
|
|
17
|
+
const { separateRoot = true } = options ?? {};
|
|
18
|
+
const roots = separateRoot ? getPageTreeRoots(tree) : [tree];
|
|
19
|
+
if (tree.fallback) roots.push(tree.fallback);
|
|
20
|
+
for (const root of roots) {
|
|
21
|
+
const list = flattenTree(root.children);
|
|
22
|
+
const idx = list.findIndex((item) => item.url === url);
|
|
23
|
+
if (idx === -1) continue;
|
|
24
|
+
return {
|
|
25
|
+
previous: list[idx - 1],
|
|
26
|
+
next: list[idx + 1]
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
return {};
|
|
30
|
+
}
|
|
31
|
+
function getPageTreeRoots(pageTree) {
|
|
32
|
+
const result = pageTree.children.flatMap((child) => {
|
|
33
|
+
if (child.type !== "folder") return [];
|
|
34
|
+
const roots = getPageTreeRoots(child);
|
|
35
|
+
if (child.root) roots.push(child);
|
|
36
|
+
return roots;
|
|
37
|
+
});
|
|
38
|
+
if (!pageTree.type || pageTree.type === "root") result.push(pageTree);
|
|
39
|
+
return result;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Get other **page** nodes that lives under the same parent.
|
|
43
|
+
*
|
|
44
|
+
* note: folders & its index nodes are not considered, use `findSiblings()` for more control.
|
|
45
|
+
*/
|
|
46
|
+
function getPageTreePeers(treeOrTrees, url) {
|
|
47
|
+
return findSiblings(treeOrTrees, url).filter((item) => item.type === "page");
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Get other tree nodes that lives under the same parent.
|
|
51
|
+
*/
|
|
52
|
+
function findSiblings(treeOrTrees, url) {
|
|
53
|
+
if ("children" in treeOrTrees) {
|
|
54
|
+
const parent = findParent(treeOrTrees, url);
|
|
55
|
+
if (!parent) return [];
|
|
56
|
+
return parent.children.filter((item) => item.type !== "page" || item.url !== url);
|
|
57
|
+
}
|
|
58
|
+
for (const lang in treeOrTrees) {
|
|
59
|
+
const result = findSiblings(treeOrTrees[lang], url);
|
|
60
|
+
if (result.length > 0) return result;
|
|
61
|
+
}
|
|
62
|
+
return [];
|
|
63
|
+
}
|
|
64
|
+
function findParent(from, url) {
|
|
65
|
+
let result;
|
|
66
|
+
visit(from, (node, parent) => {
|
|
67
|
+
if (node.type === "page" && node.url === url) {
|
|
68
|
+
result = parent;
|
|
69
|
+
return "break";
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
return result;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Search the path of a node in the tree matched by the matcher.
|
|
76
|
+
*
|
|
77
|
+
* @returns The path to the target node (from starting root), or null if the page doesn't exist
|
|
78
|
+
*/
|
|
79
|
+
function findPath(nodes, matcher, options = {}) {
|
|
80
|
+
const { includeSeparator = true } = options;
|
|
81
|
+
function run(nodes) {
|
|
82
|
+
let separator;
|
|
83
|
+
for (const node of nodes) {
|
|
84
|
+
if (matcher(node)) {
|
|
85
|
+
const items = [];
|
|
86
|
+
if (separator) items.push(separator);
|
|
87
|
+
items.push(node);
|
|
88
|
+
return items;
|
|
89
|
+
}
|
|
90
|
+
if (node.type === "separator" && includeSeparator) {
|
|
91
|
+
separator = node;
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
if (node.type === "folder") {
|
|
95
|
+
const items = node.index && matcher(node.index) ? [node.index] : run(node.children);
|
|
96
|
+
if (items) {
|
|
97
|
+
items.unshift(node);
|
|
98
|
+
if (separator) items.unshift(separator);
|
|
99
|
+
return items;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return run(nodes) ?? null;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Find the structural projection of `page` (under the root folder `from`) in `to`:
|
|
108
|
+
* the page at the same file path relative to the root folder.
|
|
109
|
+
*/
|
|
110
|
+
function findProjection(from, to, page) {
|
|
111
|
+
const prefix = from.$ref && `${from.$ref.folder}/`;
|
|
112
|
+
if (!prefix || !to.$ref || !page.$ref?.startsWith(prefix)) return;
|
|
113
|
+
const target = `${to.$ref.folder}/${page.$ref.slice(prefix.length)}`;
|
|
114
|
+
let result;
|
|
115
|
+
visit(to, (node) => {
|
|
116
|
+
if (node.type === "page" && node.$ref === target) {
|
|
117
|
+
result = node;
|
|
118
|
+
return "break";
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
return result;
|
|
122
|
+
}
|
|
123
|
+
const VisitBreak = Symbol("VisitBreak");
|
|
124
|
+
/**
|
|
125
|
+
* Perform a depth-first search on page tree visiting every node.
|
|
126
|
+
*
|
|
127
|
+
* @param root - the root of page tree to visit.
|
|
128
|
+
* @param visitor - function to receive nodes, return `skip` to skip the children of current node, `break` to stop the search entirely.
|
|
129
|
+
*/
|
|
130
|
+
function visit(root, visitor) {
|
|
131
|
+
function onNode(node, parent) {
|
|
132
|
+
const result = visitor(node, parent);
|
|
133
|
+
switch (result) {
|
|
134
|
+
case "skip": return node;
|
|
135
|
+
case "break": throw VisitBreak;
|
|
136
|
+
default: if (result) node = result;
|
|
137
|
+
}
|
|
138
|
+
if ("index" in node && node.index) node.index = onNode(node.index, node);
|
|
139
|
+
if ("fallback" in node && node.fallback) node.fallback = onNode(node.fallback, node);
|
|
140
|
+
if ("children" in node) for (let i = 0; i < node.children.length; i++) node.children[i] = onNode(node.children[i], node);
|
|
141
|
+
return node;
|
|
142
|
+
}
|
|
143
|
+
try {
|
|
144
|
+
return onNode(root);
|
|
145
|
+
} catch (e) {
|
|
146
|
+
if (e === VisitBreak) return root;
|
|
147
|
+
throw e;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
//#endregion
|
|
151
|
+
export { findSiblings as a, getPageTreeRoots as c, findProjection as i, visit as l, findParent as n, flattenTree as o, findPath as r, getPageTreePeers as s, findNeighbour as t };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { valueToEstree } from "estree-util-value-to-estree";
|
|
2
|
+
//#region src/mdx-plugins/utils.ts
|
|
3
|
+
function flattenNode(node) {
|
|
4
|
+
if ("children" in node) return node.children.map(flattenNode).join("");
|
|
5
|
+
if ("value" in node && typeof node.value === "string") return node.value;
|
|
6
|
+
return "";
|
|
7
|
+
}
|
|
8
|
+
function flattenNodeHast(node) {
|
|
9
|
+
if ("children" in node) return node.children.map(flattenNodeHast).join("");
|
|
10
|
+
return "value" in node && typeof node.value === "string" ? node.value : "";
|
|
11
|
+
}
|
|
12
|
+
function toMdxExport(name, value) {
|
|
13
|
+
return toMdxExportRaw(name, valueToEstree(value));
|
|
14
|
+
}
|
|
15
|
+
function toMdxExportRaw(name, expression) {
|
|
16
|
+
return {
|
|
17
|
+
type: "mdxjsEsm",
|
|
18
|
+
value: "",
|
|
19
|
+
data: { estree: {
|
|
20
|
+
type: "Program",
|
|
21
|
+
sourceType: "module",
|
|
22
|
+
body: [{
|
|
23
|
+
type: "ExportNamedDeclaration",
|
|
24
|
+
attributes: [],
|
|
25
|
+
specifiers: [],
|
|
26
|
+
declaration: {
|
|
27
|
+
type: "VariableDeclaration",
|
|
28
|
+
kind: "let",
|
|
29
|
+
declarations: [{
|
|
30
|
+
type: "VariableDeclarator",
|
|
31
|
+
id: {
|
|
32
|
+
type: "Identifier",
|
|
33
|
+
name
|
|
34
|
+
},
|
|
35
|
+
init: expression
|
|
36
|
+
}]
|
|
37
|
+
}
|
|
38
|
+
}]
|
|
39
|
+
} }
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function handleTag(value, tag) {
|
|
43
|
+
const idx = value.indexOf(tag);
|
|
44
|
+
if (idx !== -1) return value.slice(0, idx).trimEnd() + value.slice(idx + tag.length);
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
//#endregion
|
|
48
|
+
export { toMdxExportRaw as a, toMdxExport as i, flattenNodeHast as n, handleTag as r, flattenNode as t };
|
package/package.json
ADDED
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vezham/docs-core",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "The React.js library for building a documentation website",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"Docs",
|
|
7
|
+
"Fumadocs"
|
|
8
|
+
],
|
|
9
|
+
"homepage": "https://vezham.com",
|
|
10
|
+
"bugs": {
|
|
11
|
+
"url": "https://github.com/vezham/fumadocs/issues"
|
|
12
|
+
},
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"author": "Fuma Nama",
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "https://github.com/vezham/fumadocs",
|
|
18
|
+
"directory": "packages/core"
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"dist"
|
|
22
|
+
],
|
|
23
|
+
"type": "module",
|
|
24
|
+
"exports": {
|
|
25
|
+
"./breadcrumb": "./dist/breadcrumb.js",
|
|
26
|
+
"./content/github": "./dist/content/github.js",
|
|
27
|
+
"./content/md": "./dist/content/md.js",
|
|
28
|
+
"./content/md/frontmatter": "./dist/content/md/frontmatter.js",
|
|
29
|
+
"./content/mdx/preset-bundler": "./dist/content/mdx/preset-bundler.js",
|
|
30
|
+
"./content/mdx/preset-runtime": "./dist/content/mdx/preset-runtime.js",
|
|
31
|
+
"./content/toc": "./dist/content/toc.js",
|
|
32
|
+
"./dynamic-link": "./dist/dynamic-link.js",
|
|
33
|
+
"./framework": "./dist/framework/index.js",
|
|
34
|
+
"./framework/astro": "./dist/framework/astro.js",
|
|
35
|
+
"./framework/next": "./dist/framework/next.js",
|
|
36
|
+
"./framework/react-router": "./dist/framework/react-router.js",
|
|
37
|
+
"./framework/tanstack": "./dist/framework/tanstack.js",
|
|
38
|
+
"./framework/waku": "./dist/framework/waku.js",
|
|
39
|
+
"./highlight": "./dist/highlight/index.js",
|
|
40
|
+
"./highlight/client": "./dist/highlight/client.js",
|
|
41
|
+
"./highlight/shiki": "./dist/highlight/shiki/index.js",
|
|
42
|
+
"./highlight/shiki/full": "./dist/highlight/shiki/full.js",
|
|
43
|
+
"./highlight/shiki/react": "./dist/highlight/shiki/react.js",
|
|
44
|
+
"./i18n": "./dist/i18n/index.js",
|
|
45
|
+
"./i18n/middleware": "./dist/i18n/middleware.js",
|
|
46
|
+
"./link": "./dist/link.js",
|
|
47
|
+
"./mdx-plugins": "./dist/mdx-plugins/index.js",
|
|
48
|
+
"./mdx-plugins/codeblock-utils": "./dist/mdx-plugins/codeblock-utils.js",
|
|
49
|
+
"./mdx-plugins/rehype-code": "./dist/mdx-plugins/rehype-code.js",
|
|
50
|
+
"./mdx-plugins/rehype-code.core": "./dist/mdx-plugins/rehype-code.core.js",
|
|
51
|
+
"./mdx-plugins/rehype-toc": "./dist/mdx-plugins/rehype-toc.js",
|
|
52
|
+
"./mdx-plugins/remark-admonition": "./dist/mdx-plugins/remark-admonition.js",
|
|
53
|
+
"./mdx-plugins/remark-block-id": "./dist/mdx-plugins/remark-block-id.js",
|
|
54
|
+
"./mdx-plugins/remark-code-tab": "./dist/mdx-plugins/remark-code-tab.js",
|
|
55
|
+
"./mdx-plugins/remark-directive-admonition": "./dist/mdx-plugins/remark-directive-admonition.js",
|
|
56
|
+
"./mdx-plugins/remark-feedback-block": "./dist/mdx-plugins/remark-feedback-block.js",
|
|
57
|
+
"./mdx-plugins/remark-gfm": "./dist/mdx-plugins/remark-gfm.js",
|
|
58
|
+
"./mdx-plugins/remark-heading": "./dist/mdx-plugins/remark-heading.js",
|
|
59
|
+
"./mdx-plugins/remark-image": "./dist/mdx-plugins/remark-image.js",
|
|
60
|
+
"./mdx-plugins/remark-llms": "./dist/mdx-plugins/remark-llms.js",
|
|
61
|
+
"./mdx-plugins/remark-llms.runtime": "./dist/mdx-plugins/remark-llms.runtime.js",
|
|
62
|
+
"./mdx-plugins/remark-mdx-files": "./dist/mdx-plugins/remark-mdx-files.js",
|
|
63
|
+
"./mdx-plugins/remark-mdx-mermaid": "./dist/mdx-plugins/remark-mdx-mermaid.js",
|
|
64
|
+
"./mdx-plugins/remark-npm": "./dist/mdx-plugins/remark-npm.js",
|
|
65
|
+
"./mdx-plugins/remark-steps": "./dist/mdx-plugins/remark-steps.js",
|
|
66
|
+
"./mdx-plugins/remark-structure": "./dist/mdx-plugins/remark-structure.js",
|
|
67
|
+
"./mdx-plugins/stringifier": "./dist/mdx-plugins/stringifier.js",
|
|
68
|
+
"./mdx-plugins/transformer-icon": "./dist/mdx-plugins/transformer-icon.js",
|
|
69
|
+
"./negotiation": "./dist/negotiation/index.js",
|
|
70
|
+
"./page-tree": "./dist/page-tree/index.js",
|
|
71
|
+
"./search": "./dist/search/index.js",
|
|
72
|
+
"./search/algolia": "./dist/search/algolia.js",
|
|
73
|
+
"./search/client": "./dist/search/client.js",
|
|
74
|
+
"./search/client/algolia": "./dist/search/client/algolia.js",
|
|
75
|
+
"./search/client/fetch": "./dist/search/client/fetch.js",
|
|
76
|
+
"./search/client/flexsearch-static": "./dist/search/client/flexsearch-static.js",
|
|
77
|
+
"./search/client/mixedbread": "./dist/search/client/mixedbread.js",
|
|
78
|
+
"./search/client/orama-cloud": "./dist/search/client/orama-cloud.js",
|
|
79
|
+
"./search/client/orama-cloud-legacy": "./dist/search/client/orama-cloud-legacy.js",
|
|
80
|
+
"./search/client/orama-static": "./dist/search/client/orama-static.js",
|
|
81
|
+
"./search/flexsearch": "./dist/search/flexsearch.js",
|
|
82
|
+
"./search/mixedbread": "./dist/search/mixedbread.js",
|
|
83
|
+
"./search/orama-cloud": "./dist/search/orama-cloud.js",
|
|
84
|
+
"./search/orama-cloud-legacy": "./dist/search/orama-cloud-legacy.js",
|
|
85
|
+
"./search/server": "./dist/search/server.js",
|
|
86
|
+
"./server": {
|
|
87
|
+
"browser": "./dist/server.browser.js",
|
|
88
|
+
"import": "./dist/server.js"
|
|
89
|
+
},
|
|
90
|
+
"./server.browser": "./dist/server.browser.js",
|
|
91
|
+
"./source": "./dist/source/index.js",
|
|
92
|
+
"./source/client": "./dist/source/client/index.js",
|
|
93
|
+
"./source/dynamic": "./dist/source/dynamic.js",
|
|
94
|
+
"./source/llms": "./dist/source/llms.js",
|
|
95
|
+
"./source/plugins/lucide-icons": "./dist/source/plugins/lucide-icons.js",
|
|
96
|
+
"./source/plugins/slugs": "./dist/source/plugins/slugs.js",
|
|
97
|
+
"./source/plugins/status-badges": "./dist/source/plugins/status-badges.js",
|
|
98
|
+
"./source/schema": "./dist/source/schema.js",
|
|
99
|
+
"./toc": "./dist/toc.js",
|
|
100
|
+
"./utils/use-media-query": "./dist/utils/use-media-query.js",
|
|
101
|
+
"./utils/use-on-change": "./dist/utils/use-on-change.js",
|
|
102
|
+
"./package.json": "./package.json",
|
|
103
|
+
"./source/*": {
|
|
104
|
+
"types": "./dist/source/plugins/*.d.ts",
|
|
105
|
+
"import": "./dist/source/plugins/*.js"
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
"publishConfig": {
|
|
109
|
+
"access": "public"
|
|
110
|
+
},
|
|
111
|
+
"dependencies": {
|
|
112
|
+
"estree-util-value-to-estree": "^3.5.0",
|
|
113
|
+
"github-slugger": "^2.0.0",
|
|
114
|
+
"hast-util-to-estree": "^3.1.3",
|
|
115
|
+
"hast-util-to-jsx-runtime": "^2.3.6",
|
|
116
|
+
"mdast-util-mdx": "^3.0.0",
|
|
117
|
+
"mdast-util-to-markdown": "^2.1.2",
|
|
118
|
+
"npm-to-yarn": "3.2.0",
|
|
119
|
+
"remark": "^15.0.1",
|
|
120
|
+
"remark-gfm": "^4.0.1",
|
|
121
|
+
"remark-rehype": "^11.1.2",
|
|
122
|
+
"scroll-into-view-if-needed": "^3.1.0",
|
|
123
|
+
"shiki": "^4.4.3",
|
|
124
|
+
"tinyglobby": "^0.2.17",
|
|
125
|
+
"unified": "^11.0.5",
|
|
126
|
+
"unist-util-visit": "^5.1.0",
|
|
127
|
+
"vfile": "^6.0.3",
|
|
128
|
+
"yaml": "^2.9.0",
|
|
129
|
+
"zbsearch": "^4.0.0",
|
|
130
|
+
"@fumari/image-size": "^0.1.0"
|
|
131
|
+
},
|
|
132
|
+
"devDependencies": {
|
|
133
|
+
"@formatjs/intl-localematcher": "^0.8.13",
|
|
134
|
+
"@mdx-js/mdx": "^3.1.1",
|
|
135
|
+
"@mixedbread/sdk": "0.77.0",
|
|
136
|
+
"@orama/core": "^1.2.19",
|
|
137
|
+
"@oramacloud/client": "^2.1.4",
|
|
138
|
+
"@shikijs/transformers": "^4.4.3",
|
|
139
|
+
"@tanstack/react-router": "1.170.32",
|
|
140
|
+
"@types/estree-jsx": "^1.0.5",
|
|
141
|
+
"@types/hast": "^3.0.5",
|
|
142
|
+
"@types/mdast": "^4.0.4",
|
|
143
|
+
"@types/node": "26.3.0",
|
|
144
|
+
"@types/react": "^19.2.18",
|
|
145
|
+
"@types/react-dom": "^19.2.5",
|
|
146
|
+
"algoliasearch": "5.57.0",
|
|
147
|
+
"flexsearch": "^0.8.212",
|
|
148
|
+
"lucide-react": "^1.34.0",
|
|
149
|
+
"next": "16.3.3",
|
|
150
|
+
"path-to-regexp": "^8.4.2",
|
|
151
|
+
"react-router": "^8.3.0",
|
|
152
|
+
"remark-directive": "^4.0.0",
|
|
153
|
+
"remark-mdx": "^3.1.1",
|
|
154
|
+
"remove-markdown": "^0.6.4",
|
|
155
|
+
"tsdown": "0.22.14",
|
|
156
|
+
"typescript": "^6.0.3",
|
|
157
|
+
"waku": "1.0.0-rc.0",
|
|
158
|
+
"zod": "4.4.3",
|
|
159
|
+
"tsconfig": "0.0.0"
|
|
160
|
+
},
|
|
161
|
+
"peerDependencies": {
|
|
162
|
+
"@mdx-js/mdx": "*",
|
|
163
|
+
"@mixedbread/sdk": "0.x.x",
|
|
164
|
+
"@orama/core": "1.x.x",
|
|
165
|
+
"@oramacloud/client": "2.x.x",
|
|
166
|
+
"@tanstack/react-router": "1.x.x",
|
|
167
|
+
"@types/estree-jsx": "*",
|
|
168
|
+
"@types/hast": "*",
|
|
169
|
+
"@types/mdast": "*",
|
|
170
|
+
"@types/react": "*",
|
|
171
|
+
"algoliasearch": "5.x.x",
|
|
172
|
+
"flexsearch": "*",
|
|
173
|
+
"lucide-react": "*",
|
|
174
|
+
"next": "16.x.x",
|
|
175
|
+
"react": "^19.2.0",
|
|
176
|
+
"react-dom": "^19.2.0",
|
|
177
|
+
"react-router": "7.x.x || 8.x.x",
|
|
178
|
+
"waku": "*",
|
|
179
|
+
"zod": "4.x.x"
|
|
180
|
+
},
|
|
181
|
+
"peerDependenciesMeta": {
|
|
182
|
+
"flexsearch": {
|
|
183
|
+
"optional": true
|
|
184
|
+
},
|
|
185
|
+
"@mdx-js/mdx": {
|
|
186
|
+
"optional": true
|
|
187
|
+
},
|
|
188
|
+
"@types/estree-jsx": {
|
|
189
|
+
"optional": true
|
|
190
|
+
},
|
|
191
|
+
"@types/hast": {
|
|
192
|
+
"optional": true
|
|
193
|
+
},
|
|
194
|
+
"@types/mdast": {
|
|
195
|
+
"optional": true
|
|
196
|
+
},
|
|
197
|
+
"@mixedbread/sdk": {
|
|
198
|
+
"optional": true
|
|
199
|
+
},
|
|
200
|
+
"@types/react": {
|
|
201
|
+
"optional": true
|
|
202
|
+
},
|
|
203
|
+
"@orama/core": {
|
|
204
|
+
"optional": true
|
|
205
|
+
},
|
|
206
|
+
"@oramacloud/client": {
|
|
207
|
+
"optional": true
|
|
208
|
+
},
|
|
209
|
+
"algoliasearch": {
|
|
210
|
+
"optional": true
|
|
211
|
+
},
|
|
212
|
+
"next": {
|
|
213
|
+
"optional": true
|
|
214
|
+
},
|
|
215
|
+
"react": {
|
|
216
|
+
"optional": true
|
|
217
|
+
},
|
|
218
|
+
"react-dom": {
|
|
219
|
+
"optional": true
|
|
220
|
+
},
|
|
221
|
+
"react-router": {
|
|
222
|
+
"optional": true
|
|
223
|
+
},
|
|
224
|
+
"waku": {
|
|
225
|
+
"optional": true
|
|
226
|
+
},
|
|
227
|
+
"@tanstack/react-router": {
|
|
228
|
+
"optional": true
|
|
229
|
+
},
|
|
230
|
+
"lucide-react": {
|
|
231
|
+
"optional": true
|
|
232
|
+
},
|
|
233
|
+
"zod": {
|
|
234
|
+
"optional": true
|
|
235
|
+
}
|
|
236
|
+
},
|
|
237
|
+
"inlinedDependencies": {
|
|
238
|
+
"@formatjs/fast-memoize": "3.1.7",
|
|
239
|
+
"@formatjs/intl-localematcher": "0.8.13",
|
|
240
|
+
"@shikijs/transformers": "4.4.3",
|
|
241
|
+
"path-to-regexp": "8.4.2",
|
|
242
|
+
"remove-markdown": "0.6.4"
|
|
243
|
+
},
|
|
244
|
+
"scripts": {
|
|
245
|
+
"build": "tsdown",
|
|
246
|
+
"clean": "rimraf dist",
|
|
247
|
+
"dev": "tsdown --watch --clean false",
|
|
248
|
+
"lint": "oxlint .",
|
|
249
|
+
"types:check": "tsc --noEmit"
|
|
250
|
+
}
|
|
251
|
+
}
|