fumadocs-core 15.8.4 → 16.0.0
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/breadcrumb.d.ts +1 -1
- package/dist/breadcrumb.js +1 -1
- package/dist/{builder-5BHIAfCi.d.ts → builder-feW_xVjc.d.ts} +12 -99
- package/dist/{chunk-2IYQ7QMS.js → chunk-IZPLHEX4.js} +22 -6
- package/dist/{chunk-HN2NUUD2.js → chunk-XN2LKXFZ.js} +16 -27
- package/dist/{chunk-LMRZFODA.js → chunk-XZSI7AHE.js} +0 -16
- package/dist/content/github.js +39 -3
- package/dist/content/toc.d.ts +1 -0
- package/dist/content/toc.js +16 -3
- package/dist/{definitions-Q95-psoo.d.ts → definitions-BRsJlZ6m.d.ts} +1 -10
- package/dist/hide-if-empty.js +5 -4
- package/dist/highlight/client.d.ts +2 -13
- package/dist/highlight/client.js +2 -7
- package/dist/highlight/index.d.ts +13 -7
- package/dist/highlight/index.js +3 -1
- package/dist/i18n/index.js +5 -3
- package/dist/mdx-plugins/index.d.ts +6 -6
- package/dist/mdx-plugins/index.js +7 -10
- package/dist/{orama-cloud-74FM25SB.js → orama-cloud-WEGQE5A6.js} +8 -5
- package/dist/page-tree/index.d.ts +3 -3
- package/dist/page-tree/index.js +1 -1
- package/dist/search/algolia.d.ts +0 -6
- package/dist/search/algolia.js +1 -1
- package/dist/search/client.d.ts +4 -24
- package/dist/search/client.js +11 -18
- package/dist/search/orama-cloud.d.ts +3 -3
- package/dist/search/orama-cloud.js +16 -9
- package/dist/search/server.d.ts +2 -10
- package/dist/search/server.js +7 -12
- package/dist/source/index.d.ts +35 -5
- package/dist/source/index.js +15 -78
- package/dist/source/plugins/lucide-icons.d.ts +2 -2
- package/dist/toc.d.ts +4 -3
- package/dist/toc.js +1 -1
- package/dist/utils/use-media-query.js +19 -3
- package/package.json +19 -29
- package/dist/chunk-CX7IQ5Z6.js +0 -21
- package/dist/chunk-EP5LHGDZ.js +0 -22
- package/dist/chunk-HSBNG7QC.js +0 -42
- package/dist/chunk-HUTQC33E.js +0 -8
- package/dist/i18n/legacy.d.ts +0 -15
- package/dist/i18n/legacy.js +0 -19
- package/dist/server/index.d.ts +0 -66
- package/dist/server/index.js +0 -84
- package/dist/sidebar.d.ts +0 -33
- package/dist/sidebar.js +0 -79
package/dist/breadcrumb.d.ts
CHANGED
package/dist/breadcrumb.js
CHANGED
|
@@ -1,64 +1,7 @@
|
|
|
1
|
-
import { I as Item, F as Folder, S as Separator
|
|
1
|
+
import { R as Root, I as Item, F as Folder, S as Separator } from './definitions-BRsJlZ6m.js';
|
|
2
2
|
import { I18nConfig } from './i18n/index.js';
|
|
3
3
|
import { ReactNode } from 'react';
|
|
4
4
|
|
|
5
|
-
interface FileInfo {
|
|
6
|
-
/**
|
|
7
|
-
* File path without extension
|
|
8
|
-
*
|
|
9
|
-
* @deprecated obtain it with `join(dirname, name)`
|
|
10
|
-
*/
|
|
11
|
-
flattenedPath: string;
|
|
12
|
-
/**
|
|
13
|
-
* path of file (unparsed)
|
|
14
|
-
*/
|
|
15
|
-
path: string;
|
|
16
|
-
/**
|
|
17
|
-
* File name without extension
|
|
18
|
-
*/
|
|
19
|
-
name: string;
|
|
20
|
-
/**
|
|
21
|
-
* file extension from the last `.`, like `.md`
|
|
22
|
-
*
|
|
23
|
-
* empty string if no file extension
|
|
24
|
-
*/
|
|
25
|
-
ext: string;
|
|
26
|
-
dirname: string;
|
|
27
|
-
}
|
|
28
|
-
declare function basename(path: string, ext?: string): string;
|
|
29
|
-
declare function extname(path: string): string;
|
|
30
|
-
declare function dirname(path: string): string;
|
|
31
|
-
declare function parseFilePath(path: string): FileInfo;
|
|
32
|
-
/**
|
|
33
|
-
* Split path into segments, trailing/leading slashes are removed
|
|
34
|
-
*/
|
|
35
|
-
declare function splitPath(path: string): string[];
|
|
36
|
-
/**
|
|
37
|
-
* Resolve paths, slashes within the path will be ignored
|
|
38
|
-
* @param paths - Paths to join
|
|
39
|
-
* @example
|
|
40
|
-
* ```
|
|
41
|
-
* ['a','b'] // 'a/b'
|
|
42
|
-
* ['/a'] // 'a'
|
|
43
|
-
* ['a', '/b'] // 'a/b'
|
|
44
|
-
* ['a', '../b/c'] // 'b/c'
|
|
45
|
-
* ```
|
|
46
|
-
*/
|
|
47
|
-
declare function joinPath(...paths: string[]): string;
|
|
48
|
-
declare function slash(path: string): string;
|
|
49
|
-
|
|
50
|
-
type path_FileInfo = FileInfo;
|
|
51
|
-
declare const path_basename: typeof basename;
|
|
52
|
-
declare const path_dirname: typeof dirname;
|
|
53
|
-
declare const path_extname: typeof extname;
|
|
54
|
-
declare const path_joinPath: typeof joinPath;
|
|
55
|
-
declare const path_parseFilePath: typeof parseFilePath;
|
|
56
|
-
declare const path_slash: typeof slash;
|
|
57
|
-
declare const path_splitPath: typeof splitPath;
|
|
58
|
-
declare namespace path {
|
|
59
|
-
export { type path_FileInfo as FileInfo, path_basename as basename, path_dirname as dirname, path_extname as extname, path_joinPath as joinPath, path_parseFilePath as parseFilePath, path_slash as slash, path_splitPath as splitPath };
|
|
60
|
-
}
|
|
61
|
-
|
|
62
5
|
interface LoaderPlugin<Page extends PageData = PageData, Meta extends MetaData = MetaData> {
|
|
63
6
|
name?: string;
|
|
64
7
|
/**
|
|
@@ -84,36 +27,6 @@ interface LoaderPlugin<Page extends PageData = PageData, Meta extends MetaData =
|
|
|
84
27
|
}
|
|
85
28
|
declare function buildPlugins(plugins: (LoaderPlugin | LoaderPlugin[] | undefined)[]): LoaderPlugin[];
|
|
86
29
|
|
|
87
|
-
type TransformContentStorage = (context: {
|
|
88
|
-
storage: ContentStorage;
|
|
89
|
-
}) => void;
|
|
90
|
-
interface LegacyLoaderOptions {
|
|
91
|
-
/**
|
|
92
|
-
* We recommend you to use `plugins` instead
|
|
93
|
-
*/
|
|
94
|
-
transformers?: TransformContentStorage[];
|
|
95
|
-
}
|
|
96
|
-
interface LegacyPageTreeOptions<Page extends PageData = PageData, Meta extends MetaData = MetaData> {
|
|
97
|
-
/**
|
|
98
|
-
* @deprecated use `plugins` instead
|
|
99
|
-
*/
|
|
100
|
-
attachFile?: (node: Item, file?: PageFile<Page>) => Item;
|
|
101
|
-
/**
|
|
102
|
-
* @deprecated use `plugins` instead
|
|
103
|
-
*/
|
|
104
|
-
attachFolder?: (node: Folder, folder: {
|
|
105
|
-
children: (PageFile<Page> | MetaFile<Meta>)[];
|
|
106
|
-
}, meta?: MetaFile<Meta>) => Folder;
|
|
107
|
-
/**
|
|
108
|
-
* @deprecated use `plugins` instead
|
|
109
|
-
*/
|
|
110
|
-
attachSeparator?: (node: Separator) => Separator;
|
|
111
|
-
/**
|
|
112
|
-
* We recommend you to use `plugins` instead
|
|
113
|
-
*/
|
|
114
|
-
transformers?: PageTreeTransformer<Page, Meta>[];
|
|
115
|
-
}
|
|
116
|
-
|
|
117
30
|
type IconResolver = (icon: string | undefined) => ReactNode;
|
|
118
31
|
|
|
119
32
|
interface LoaderConfig {
|
|
@@ -124,17 +37,19 @@ interface SourceConfig {
|
|
|
124
37
|
pageData: PageData;
|
|
125
38
|
metaData: MetaData;
|
|
126
39
|
}
|
|
127
|
-
interface LoaderOptions<S extends SourceConfig = SourceConfig, I18n extends I18nConfig | undefined = I18nConfig | undefined>
|
|
40
|
+
interface LoaderOptions<S extends SourceConfig = SourceConfig, I18n extends I18nConfig | undefined = I18nConfig | undefined> {
|
|
128
41
|
baseUrl: string;
|
|
129
42
|
i18n?: I18n;
|
|
130
43
|
url?: UrlFn;
|
|
131
44
|
/**
|
|
132
45
|
* Additional options for page tree builder
|
|
133
46
|
*/
|
|
134
|
-
pageTree?: PageTreeOptions
|
|
47
|
+
pageTree?: PageTreeOptions<S['pageData'], S['metaData']>;
|
|
135
48
|
plugins?: (LoaderPlugin<S['pageData'], S['metaData']> | LoaderPlugin<S['pageData'], S['metaData']>[] | undefined)[];
|
|
136
49
|
icon?: IconResolver;
|
|
137
|
-
slugs?: (info:
|
|
50
|
+
slugs?: (info: {
|
|
51
|
+
path: string;
|
|
52
|
+
}) => string[];
|
|
138
53
|
}
|
|
139
54
|
interface ResolvedLoaderConfig {
|
|
140
55
|
source: Source;
|
|
@@ -147,12 +62,6 @@ interface Source<Config extends SourceConfig = SourceConfig> {
|
|
|
147
62
|
files: VirtualFile<Config>[];
|
|
148
63
|
}
|
|
149
64
|
interface SharedFileInfo {
|
|
150
|
-
/**
|
|
151
|
-
* Virtualized file path (parsed)
|
|
152
|
-
*
|
|
153
|
-
* @deprecated Use `path` instead.
|
|
154
|
-
*/
|
|
155
|
-
file: FileInfo;
|
|
156
65
|
/**
|
|
157
66
|
* Virtualized file path (relative to content directory)
|
|
158
67
|
*
|
|
@@ -359,7 +268,7 @@ interface PageTreeTransformer<Page extends PageData = PageData, Meta extends Met
|
|
|
359
268
|
separator?: (this: PageTreeBuilderContext<Page, Meta>, node: Separator) => Separator;
|
|
360
269
|
root?: (this: PageTreeBuilderContext<Page, Meta>, node: Root) => Root;
|
|
361
270
|
}
|
|
362
|
-
interface PageTreeOptions {
|
|
271
|
+
interface PageTreeOptions<Page extends PageData = PageData, Meta extends MetaData = MetaData> {
|
|
363
272
|
id?: string;
|
|
364
273
|
/**
|
|
365
274
|
* Remove references to the file path of original nodes (`$ref`)
|
|
@@ -373,6 +282,10 @@ interface PageTreeOptions {
|
|
|
373
282
|
* @defaultValue true
|
|
374
283
|
*/
|
|
375
284
|
generateFallback?: boolean;
|
|
285
|
+
/**
|
|
286
|
+
* Additional page tree transformers to apply
|
|
287
|
+
*/
|
|
288
|
+
transformers?: PageTreeTransformer<Page, Meta>[];
|
|
376
289
|
}
|
|
377
290
|
interface PageTreeBuilder {
|
|
378
291
|
build: (storage: ContentStorage, options?: PageTreeOptions) => Root;
|
|
@@ -380,4 +293,4 @@ interface PageTreeBuilder {
|
|
|
380
293
|
}
|
|
381
294
|
declare function createPageTreeBuilder(getUrl: UrlFn, plugins?: LoaderPlugin[]): PageTreeBuilder;
|
|
382
295
|
|
|
383
|
-
export { type ContentStorage as C,
|
|
296
|
+
export { type ContentStorage as C, FileSystem as F, type InferPageType as I, type LoaderPlugin as L, type MetaFile as M, type PageTreeTransformer as P, type ResolvedLoaderConfig as R, type SourceConfig as S, type UrlFn as U, type VirtualPage as V, type _ConfigUnion_ as _, type PageTreeBuilder as a, type PageTreeBuilderContext as b, createPageTreeBuilder as c, type PageTreeOptions as d, type PageFile as e, type LoaderConfig as f, type LoaderOptions as g, type Source as h, type Page as i, type Meta as j, type LoaderOutput as k, createGetUrl as l, loader as m, multiple as n, map as o, type MetaData as p, type PageData as q, type VirtualMeta as r, type VirtualFile as s, type InferMetaType as t, buildPlugins as u };
|
|
@@ -36,12 +36,28 @@ function getPageTreeRoots(pageTree) {
|
|
|
36
36
|
if (!("type" in pageTree)) result.push(pageTree);
|
|
37
37
|
return result;
|
|
38
38
|
}
|
|
39
|
-
function getPageTreePeers(
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
(
|
|
44
|
-
|
|
39
|
+
function getPageTreePeers(treeOrTrees, url) {
|
|
40
|
+
if ("children" in treeOrTrees) {
|
|
41
|
+
const tree = treeOrTrees;
|
|
42
|
+
const parent = findParentFromTree(tree, url);
|
|
43
|
+
if (!parent) return [];
|
|
44
|
+
return parent.children.filter(
|
|
45
|
+
(item) => item.type === "page" && item.url !== url
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
const trees = treeOrTrees;
|
|
49
|
+
for (const lang in trees) {
|
|
50
|
+
const rootTree = trees[lang];
|
|
51
|
+
if (rootTree) {
|
|
52
|
+
const parent = findParentFromTree(rootTree, url);
|
|
53
|
+
if (parent) {
|
|
54
|
+
return parent.children.filter(
|
|
55
|
+
(item) => item.type === "page" && item.url !== url
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return [];
|
|
45
61
|
}
|
|
46
62
|
function findParentFromTree(node, url) {
|
|
47
63
|
if ("index" in node && node.index?.url === url) {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
// src/highlight/shiki.ts
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
toJsxRuntime
|
|
4
|
+
} from "hast-util-to-jsx-runtime";
|
|
3
5
|
import { Fragment } from "react";
|
|
4
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
7
|
var defaultThemes = {
|
|
@@ -12,7 +14,7 @@ async function highlightHast(code, options) {
|
|
|
12
14
|
lang: initialLang,
|
|
13
15
|
fallbackLanguage,
|
|
14
16
|
components: _,
|
|
15
|
-
engine = "
|
|
17
|
+
engine = "js",
|
|
16
18
|
...rest
|
|
17
19
|
} = options;
|
|
18
20
|
let lang = initialLang;
|
|
@@ -27,24 +29,10 @@ async function highlightHast(code, options) {
|
|
|
27
29
|
};
|
|
28
30
|
themesToLoad = Object.values(themes.themes).filter((v) => v !== void 0);
|
|
29
31
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
themes: themesToLoad
|
|
35
|
-
});
|
|
36
|
-
} else {
|
|
37
|
-
highlighter = await getHighlighter("custom", {
|
|
38
|
-
engine,
|
|
39
|
-
langs: [],
|
|
40
|
-
themes: themesToLoad
|
|
41
|
-
});
|
|
42
|
-
if (process.env.NODE_ENV === "development") {
|
|
43
|
-
console.warn(
|
|
44
|
-
"[Fumadocs `highlight()`] Avoid passing `engine` directly. For custom engines, use `shiki` directly instead."
|
|
45
|
-
);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
32
|
+
const highlighter = await getHighlighter(engine, {
|
|
33
|
+
langs: [],
|
|
34
|
+
themes: themesToLoad
|
|
35
|
+
});
|
|
48
36
|
try {
|
|
49
37
|
await highlighter.loadLanguage(lang);
|
|
50
38
|
} catch {
|
|
@@ -58,13 +46,13 @@ async function highlightHast(code, options) {
|
|
|
58
46
|
defaultColor: "themes" in themes ? false : void 0
|
|
59
47
|
});
|
|
60
48
|
}
|
|
61
|
-
function
|
|
49
|
+
function hastToJsx(hast, options) {
|
|
62
50
|
return toJsxRuntime(hast, {
|
|
63
51
|
jsx,
|
|
64
52
|
jsxs,
|
|
65
53
|
development: false,
|
|
66
|
-
|
|
67
|
-
|
|
54
|
+
Fragment,
|
|
55
|
+
...options
|
|
68
56
|
});
|
|
69
57
|
}
|
|
70
58
|
async function getHighlighter(engineType, options) {
|
|
@@ -76,12 +64,10 @@ async function getHighlighter(engineType, options) {
|
|
|
76
64
|
engine = import("shiki/engine/javascript").then(
|
|
77
65
|
(res) => res.createJavaScriptRegexEngine()
|
|
78
66
|
);
|
|
79
|
-
} else
|
|
67
|
+
} else {
|
|
80
68
|
engine = import("shiki/engine/oniguruma").then(
|
|
81
69
|
(res) => res.createOnigurumaEngine(import("shiki/wasm"))
|
|
82
70
|
);
|
|
83
|
-
} else {
|
|
84
|
-
engine = options.engine;
|
|
85
71
|
}
|
|
86
72
|
highlighter = createHighlighter({
|
|
87
73
|
...options,
|
|
@@ -101,12 +87,15 @@ async function getHighlighter(engineType, options) {
|
|
|
101
87
|
});
|
|
102
88
|
}
|
|
103
89
|
async function highlight(code, options) {
|
|
104
|
-
return
|
|
90
|
+
return hastToJsx(await highlightHast(code, options), {
|
|
91
|
+
components: options.components
|
|
92
|
+
});
|
|
105
93
|
}
|
|
106
94
|
|
|
107
95
|
export {
|
|
108
96
|
defaultThemes,
|
|
109
97
|
highlightHast,
|
|
98
|
+
hastToJsx,
|
|
110
99
|
getHighlighter,
|
|
111
100
|
highlight
|
|
112
101
|
};
|
|
@@ -9,7 +9,6 @@ __export(path_exports, {
|
|
|
9
9
|
dirname: () => dirname,
|
|
10
10
|
extname: () => extname,
|
|
11
11
|
joinPath: () => joinPath,
|
|
12
|
-
parseFilePath: () => parseFilePath,
|
|
13
12
|
slash: () => slash,
|
|
14
13
|
splitPath: () => splitPath
|
|
15
14
|
});
|
|
@@ -30,20 +29,6 @@ function extname(path) {
|
|
|
30
29
|
function dirname(path) {
|
|
31
30
|
return path.split("/").slice(0, -1).join("/");
|
|
32
31
|
}
|
|
33
|
-
function parseFilePath(path) {
|
|
34
|
-
const ext = extname(path);
|
|
35
|
-
const name = basename(path, ext);
|
|
36
|
-
const dir = dirname(path);
|
|
37
|
-
return {
|
|
38
|
-
dirname: dir,
|
|
39
|
-
name,
|
|
40
|
-
ext,
|
|
41
|
-
path,
|
|
42
|
-
get flattenedPath() {
|
|
43
|
-
return [dir, name].filter((p) => p.length > 0).join("/");
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
32
|
function splitPath(path) {
|
|
48
33
|
return path.split("/").filter((p) => p.length > 0);
|
|
49
34
|
}
|
|
@@ -75,7 +60,6 @@ export {
|
|
|
75
60
|
basename,
|
|
76
61
|
extname,
|
|
77
62
|
dirname,
|
|
78
|
-
parseFilePath,
|
|
79
63
|
splitPath,
|
|
80
64
|
joinPath,
|
|
81
65
|
slash,
|
package/dist/content/github.js
CHANGED
|
@@ -1,7 +1,43 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getGithubLastEdit
|
|
3
|
-
} from "../chunk-HSBNG7QC.js";
|
|
4
1
|
import "../chunk-U67V476Y.js";
|
|
2
|
+
|
|
3
|
+
// src/content/github.ts
|
|
4
|
+
async function getGithubLastEdit({
|
|
5
|
+
repo,
|
|
6
|
+
token,
|
|
7
|
+
owner,
|
|
8
|
+
path,
|
|
9
|
+
sha,
|
|
10
|
+
options = {},
|
|
11
|
+
params: customParams = {}
|
|
12
|
+
}) {
|
|
13
|
+
const headers = new Headers(options.headers);
|
|
14
|
+
const params = new URLSearchParams();
|
|
15
|
+
params.set("path", path);
|
|
16
|
+
params.set("page", "1");
|
|
17
|
+
params.set("per_page", "1");
|
|
18
|
+
if (sha) params.set("sha", sha);
|
|
19
|
+
for (const [key, value] of Object.entries(customParams)) {
|
|
20
|
+
params.set(key, value);
|
|
21
|
+
}
|
|
22
|
+
if (token) {
|
|
23
|
+
headers.append("authorization", token);
|
|
24
|
+
}
|
|
25
|
+
const res = await fetch(
|
|
26
|
+
`https://api.github.com/repos/${owner}/${repo}/commits?${params.toString()}`,
|
|
27
|
+
{
|
|
28
|
+
cache: "force-cache",
|
|
29
|
+
...options,
|
|
30
|
+
headers
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
if (!res.ok)
|
|
34
|
+
throw new Error(
|
|
35
|
+
`Failed to fetch last edit time from Git ${await res.text()}`
|
|
36
|
+
);
|
|
37
|
+
const data = await res.json();
|
|
38
|
+
if (data.length === 0) return null;
|
|
39
|
+
return new Date(data[0].commit.committer.date);
|
|
40
|
+
}
|
|
5
41
|
export {
|
|
6
42
|
getGithubLastEdit
|
|
7
43
|
};
|
package/dist/content/toc.d.ts
CHANGED
package/dist/content/toc.js
CHANGED
|
@@ -1,8 +1,21 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-QMATWJ5F.js";
|
|
2
|
+
remarkHeading
|
|
3
|
+
} from "../chunk-QMATWJ5F.js";
|
|
5
4
|
import "../chunk-U67V476Y.js";
|
|
5
|
+
|
|
6
|
+
// src/content/toc.ts
|
|
7
|
+
import { remark } from "remark";
|
|
8
|
+
function getTableOfContents(content, remarkPlugins) {
|
|
9
|
+
if (remarkPlugins) {
|
|
10
|
+
return remark().use(remarkPlugins).use(remarkHeading).process(content).then((result2) => {
|
|
11
|
+
if ("toc" in result2.data) return result2.data.toc;
|
|
12
|
+
return [];
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
const result = remark().use(remarkHeading).processSync(content);
|
|
16
|
+
if ("toc" in result.data) return result.data.toc;
|
|
17
|
+
return [];
|
|
18
|
+
}
|
|
6
19
|
export {
|
|
7
20
|
getTableOfContents
|
|
8
21
|
};
|
|
@@ -49,13 +49,4 @@ interface Folder {
|
|
|
49
49
|
children: Node[];
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
type
|
|
53
|
-
type definitions_Item = Item;
|
|
54
|
-
type definitions_Node = Node;
|
|
55
|
-
type definitions_Root = Root;
|
|
56
|
-
type definitions_Separator = Separator;
|
|
57
|
-
declare namespace definitions {
|
|
58
|
-
export type { definitions_Folder as Folder, definitions_Item as Item, definitions_Node as Node, definitions_Root as Root, definitions_Separator as Separator };
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export { type Folder as F, type Item as I, type Node as N, type Root as R, type Separator as S, definitions as d };
|
|
52
|
+
export type { Folder as F, Item as I, Node as N, Root as R, Separator as S };
|
package/dist/hide-if-empty.js
CHANGED
|
@@ -52,9 +52,9 @@ function HideIfEmpty({
|
|
|
52
52
|
}, [id]);
|
|
53
53
|
const init = (id2) => {
|
|
54
54
|
const element = getElement(id2);
|
|
55
|
-
if (element)
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
if (element) {
|
|
56
|
+
element.hidden = isEmpty(element);
|
|
57
|
+
}
|
|
58
58
|
};
|
|
59
59
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
60
60
|
/* @__PURE__ */ jsx(
|
|
@@ -65,9 +65,10 @@ function HideIfEmpty({
|
|
|
65
65
|
hidden: empty ?? false
|
|
66
66
|
}
|
|
67
67
|
),
|
|
68
|
-
|
|
68
|
+
/* @__PURE__ */ jsx(
|
|
69
69
|
"script",
|
|
70
70
|
{
|
|
71
|
+
suppressHydrationWarning: true,
|
|
71
72
|
nonce,
|
|
72
73
|
dangerouslySetInnerHTML: {
|
|
73
74
|
__html: `{${getElement};${isEmpty};(${init})("${id}")}`
|
|
@@ -1,21 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DependencyList, ReactNode } from 'react';
|
|
2
2
|
import { HighlightOptions } from './index.js';
|
|
3
3
|
import 'shiki';
|
|
4
4
|
import 'shiki/themes';
|
|
5
5
|
import 'hast-util-to-jsx-runtime';
|
|
6
6
|
import 'hast';
|
|
7
7
|
|
|
8
|
-
declare function useShiki(code: string, options: HighlightOptions
|
|
9
|
-
/**
|
|
10
|
-
* @deprecated no longer pre-rendered using scripts.
|
|
11
|
-
*/
|
|
12
|
-
withPrerenderScript?: boolean;
|
|
13
|
-
/**
|
|
14
|
-
* Displayed before highlighter is loaded.
|
|
15
|
-
*
|
|
16
|
-
* @deprecated use React `Suspense` fallback instead.
|
|
17
|
-
*/
|
|
18
|
-
loading?: ReactNode;
|
|
19
|
-
}, deps?: DependencyList): ReactNode;
|
|
8
|
+
declare function useShiki(code: string, options: HighlightOptions, deps?: DependencyList): ReactNode;
|
|
20
9
|
|
|
21
10
|
export { useShiki };
|
package/dist/highlight/client.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
3
|
highlight
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-XN2LKXFZ.js";
|
|
5
5
|
import "../chunk-U67V476Y.js";
|
|
6
6
|
|
|
7
7
|
// src/highlight/client.tsx
|
|
@@ -17,12 +17,7 @@ function useShiki(code, options, deps) {
|
|
|
17
17
|
const state = deps ? JSON.stringify(deps) : `${options.lang}:${code}`;
|
|
18
18
|
return `${id}:${state}`;
|
|
19
19
|
}, [code, deps, id, options.lang]);
|
|
20
|
-
return use(
|
|
21
|
-
promises[key] ??= highlight(code, {
|
|
22
|
-
...options,
|
|
23
|
-
engine: options.engine ?? "js"
|
|
24
|
-
})
|
|
25
|
-
);
|
|
20
|
+
return use(promises[key] ??= highlight(code, options));
|
|
26
21
|
}
|
|
27
22
|
export {
|
|
28
23
|
useShiki
|
|
@@ -1,24 +1,30 @@
|
|
|
1
|
-
import { CodeToHastOptionsCommon, BundledLanguage, CodeOptionsMeta,
|
|
1
|
+
import { CodeToHastOptionsCommon, BundledLanguage, CodeOptionsMeta, CodeOptionsThemes, BundledHighlighterOptions, Highlighter } from 'shiki';
|
|
2
2
|
import { BundledTheme } from 'shiki/themes';
|
|
3
|
-
import { Components } from 'hast-util-to-jsx-runtime';
|
|
3
|
+
import { Components, Options } from 'hast-util-to-jsx-runtime';
|
|
4
4
|
import { ReactNode } from 'react';
|
|
5
5
|
import { Root } from 'hast';
|
|
6
6
|
|
|
7
7
|
type HighlightOptionsCommon = CodeToHastOptionsCommon<BundledLanguage> & CodeOptionsMeta & {
|
|
8
|
-
|
|
8
|
+
/**
|
|
9
|
+
* The Regex Engine for Shiki
|
|
10
|
+
*
|
|
11
|
+
* @defaultValue 'js'
|
|
12
|
+
*/
|
|
13
|
+
engine?: 'js' | 'oniguruma';
|
|
9
14
|
components?: Partial<Components>;
|
|
10
15
|
fallbackLanguage?: BundledLanguage;
|
|
11
16
|
};
|
|
12
17
|
type HighlightOptionsThemes = CodeOptionsThemes<BundledTheme>;
|
|
13
18
|
type HighlightOptions = HighlightOptionsCommon & (HighlightOptionsThemes | Record<never, never>);
|
|
14
19
|
declare function highlightHast(code: string, options: HighlightOptions): Promise<Root>;
|
|
20
|
+
declare function hastToJsx(hast: Root, options?: Partial<Options>): JSX.Element;
|
|
15
21
|
/**
|
|
16
|
-
* Get Shiki highlighter instance of Fumadocs (mostly for internal use,
|
|
22
|
+
* Get Shiki highlighter instance of Fumadocs (mostly for internal use, you should use Shiki directly over this).
|
|
17
23
|
*
|
|
18
|
-
* @param engineType -
|
|
24
|
+
* @param engineType - Shiki Regex engine to use.
|
|
19
25
|
* @param options - Shiki options.
|
|
20
26
|
*/
|
|
21
|
-
declare function getHighlighter(engineType: 'js' | 'oniguruma'
|
|
27
|
+
declare function getHighlighter(engineType: 'js' | 'oniguruma', options: Omit<BundledHighlighterOptions<BundledLanguage, BundledTheme>, 'engine'>): Promise<Highlighter>;
|
|
22
28
|
declare function highlight(code: string, options: HighlightOptions): Promise<ReactNode>;
|
|
23
29
|
|
|
24
|
-
export { type HighlightOptions, type HighlightOptionsCommon, type HighlightOptionsThemes, getHighlighter, highlight, highlightHast };
|
|
30
|
+
export { type HighlightOptions, type HighlightOptionsCommon, type HighlightOptionsThemes, getHighlighter, hastToJsx, highlight, highlightHast };
|
package/dist/highlight/index.js
CHANGED
package/dist/i18n/index.js
CHANGED
|
@@ -24,6 +24,12 @@ declare function transformerIcon(options?: IconOptions): ShikiTransformer;
|
|
|
24
24
|
|
|
25
25
|
declare const rehypeCodeDefaultOptions: RehypeCodeOptions;
|
|
26
26
|
type RehypeCodeOptions = RehypeShikiOptions & {
|
|
27
|
+
/**
|
|
28
|
+
* The regex engine to use.
|
|
29
|
+
*
|
|
30
|
+
* @defaultValue 'js'
|
|
31
|
+
*/
|
|
32
|
+
engine?: 'js' | 'oniguruma';
|
|
27
33
|
/**
|
|
28
34
|
* Filter meta string before processing
|
|
29
35
|
*/
|
|
@@ -38,12 +44,6 @@ type RehypeCodeOptions = RehypeShikiOptions & {
|
|
|
38
44
|
* @defaultValue true
|
|
39
45
|
*/
|
|
40
46
|
tab?: boolean;
|
|
41
|
-
/**
|
|
42
|
-
* Enable Shiki's experimental JS engine
|
|
43
|
-
*
|
|
44
|
-
* @defaultValue false
|
|
45
|
-
*/
|
|
46
|
-
experimentalJSEngine?: boolean;
|
|
47
47
|
};
|
|
48
48
|
/**
|
|
49
49
|
* Handle codeblocks
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
defaultThemes,
|
|
3
3
|
getHighlighter
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-XN2LKXFZ.js";
|
|
5
5
|
import {
|
|
6
6
|
flattenNode,
|
|
7
7
|
remarkHeading
|
|
@@ -254,7 +254,7 @@ var rehypeCodeDefaultOptions = {
|
|
|
254
254
|
themes: defaultThemes,
|
|
255
255
|
defaultColor: false,
|
|
256
256
|
defaultLanguage: "plaintext",
|
|
257
|
-
|
|
257
|
+
engine: "js",
|
|
258
258
|
transformers: [
|
|
259
259
|
transformerNotationHighlight({
|
|
260
260
|
matchAlgorithm: "v3"
|
|
@@ -310,14 +310,11 @@ function rehypeCode(_options = {}) {
|
|
|
310
310
|
if (options.tab !== false) {
|
|
311
311
|
transformers.push(transformerTab());
|
|
312
312
|
}
|
|
313
|
-
const highlighter = getHighlighter(
|
|
314
|
-
options
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
langAlias: options.langAlias
|
|
319
|
-
}
|
|
320
|
-
);
|
|
313
|
+
const highlighter = getHighlighter(options.engine ?? "js", {
|
|
314
|
+
themes: "themes" in options ? Object.values(options.themes).filter(Boolean) : [options.theme],
|
|
315
|
+
langs: options.langs ?? (options.lazy ? ["ts", "tsx"] : Object.keys(bundledLanguages)),
|
|
316
|
+
langAlias: options.langAlias
|
|
317
|
+
});
|
|
321
318
|
const transformer = highlighter.then(
|
|
322
319
|
(loaded) => rehypeShikiFromHighlighter(loaded, {
|
|
323
320
|
...options,
|