fumadocs-core 16.17.7 → 16.17.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{algolia-nI8K-5gY.d.ts → algolia-NG5vCx7r.d.ts} +2 -2
- package/dist/breadcrumb.d.ts +1 -1
- package/dist/{build-index-Bxu0jldy.js → build-index-a5ygCRBZ.js} +1 -1
- package/dist/{client-aul0_BWr.d.ts → client-BAj2KxA7.d.ts} +3 -3
- package/dist/content/md/frontmatter.d.ts +2 -1
- package/dist/content/md.d.ts +2 -2
- package/dist/content/md.js +6 -13
- package/dist/content/mdx/preset-bundler.d.ts +2 -2
- package/dist/content/mdx/preset-runtime.d.ts +2 -2
- package/dist/{definitions-BZlqdyOx.d.ts → definitions-CFOhwE1k.d.ts} +2 -4
- package/dist/{dynamic-1an9p9Sx.js → dynamic-CymQi8F2.js} +1 -1
- package/dist/framework/astro.d.ts +2 -1
- package/dist/framework/index.d.ts +2 -1
- package/dist/hast-to-jsx-CgR__kSX.d.ts +21 -0
- package/dist/highlight/client.d.ts +1 -1
- package/dist/highlight/client.js +1 -1
- package/dist/highlight/highlights.d.ts +25 -0
- package/dist/highlight/highlights.js +219 -0
- package/dist/highlight/index.d.ts +2 -30
- package/dist/highlight/index.js +3 -9
- package/dist/highlight/shiki/full.d.ts +1 -1
- package/dist/highlight/shiki/full.js +1 -1
- package/dist/highlight/shiki/index.d.ts +2 -2
- package/dist/highlight/shiki/index.js +1 -27
- package/dist/highlight/shiki/react.d.ts +3 -3
- package/dist/highlight/shiki/react.js +8 -19
- package/dist/i18n/middleware.d.ts +2 -1
- package/dist/{index-DNn03jFO.d.ts → index-B-0R0VbS.d.ts} +2 -2
- package/dist/index-Bf_V9OZJ.d.ts +51 -0
- package/dist/index-Cr-WMmZN.d.ts +17 -0
- package/dist/{index-B0I6yRlw.d.ts → index-DNo8LS3A.d.ts} +5 -5
- package/dist/{index-DUWMH-uy.d.ts → index-E8Qh_yQs.d.ts} +2 -5
- package/dist/index-m7W5wflM.d.ts +32 -0
- package/dist/mcp.d.ts +3 -3
- package/dist/mdx-plugins/index.d.ts +6 -5
- package/dist/mdx-plugins/index.js +3 -2
- package/dist/mdx-plugins/rehype-code.core.d.ts +2 -2
- package/dist/mdx-plugins/rehype-code.core.js +2 -2
- package/dist/mdx-plugins/rehype-code.d.ts +2 -2
- package/dist/mdx-plugins/rehype-code.js +1 -1
- package/dist/mdx-plugins/rehype-toc.d.ts +1 -1
- package/dist/mdx-plugins/remark-gfm.js +1 -2
- package/dist/mdx-plugins/remark-image.js +35 -4
- package/dist/mdx-plugins/remark-include.d.ts +2 -0
- package/dist/mdx-plugins/remark-include.js +210 -0
- package/dist/mdx-plugins/remark-llms.js +36 -21
- package/dist/mdx-plugins/remark-llms.runtime.d.ts +1 -1
- package/dist/mdx-plugins/stringifier.d.ts +10 -2
- package/dist/mdx-plugins/stringifier.js +4 -2
- package/dist/{meilisearch-ZjsML7Pr.d.ts → meilisearch-Cy3VXUZn.d.ts} +2 -2
- package/dist/{mixedbread-y5oWDuHL.d.ts → mixedbread-2VnWtXx5.d.ts} +2 -2
- package/dist/negotiation/index.js +1 -1
- package/dist/page-tree/index.d.ts +2 -2
- package/dist/page-tree/index.js +1 -2
- package/dist/{path-m9Srg2Jq.js → path-UUoiuLiY.js} +1 -1
- package/dist/{rehype-code-CGahijs1.d.ts → rehype-code-BVf0Uz2w.d.ts} +1 -1
- package/dist/{rehype-code.core-COgx9A69.d.ts → rehype-code.core-4GV1oJiD.d.ts} +50 -35
- package/dist/{rehype-code.core-BwH0Kyry.js → rehype-code.core-CI2UNT3P.js} +190 -159
- package/dist/{rehype-toc-K51AGb5U.d.ts → rehype-toc-BXIfcuF8.d.ts} +1 -1
- package/dist/remark-include-BUSAq2rM.d.ts +30 -0
- package/dist/{rolldown-runtime-EAsCxrDo.js → rolldown-runtime-CgOhrHTk.js} +1 -1
- package/dist/search/algolia.d.ts +1 -1
- package/dist/search/algolia.js +1 -1
- package/dist/search/client/algolia.d.ts +1 -1
- package/dist/search/client/docs-search.d.ts +1 -1
- package/dist/search/client/fetch.d.ts +1 -1
- package/dist/search/client/flexsearch-static.d.ts +1 -1
- package/dist/search/client/meilisearch.d.ts +1 -1
- package/dist/search/client/mixedbread.d.ts +2 -2
- package/dist/search/client/orama-cloud-legacy.d.ts +1 -1
- package/dist/search/client/orama-cloud.d.ts +1 -1
- package/dist/search/client/orama-static.d.ts +1 -1
- package/dist/search/client.d.ts +1 -1
- package/dist/search/flexsearch.d.ts +5 -4
- package/dist/search/flexsearch.js +1 -1
- package/dist/search/meilisearch.d.ts +1 -1
- package/dist/search/meilisearch.js +1 -1
- package/dist/search/mixedbread.d.ts +2 -2
- package/dist/search/orama-cloud-legacy.d.ts +1 -1
- package/dist/search/orama-cloud.d.ts +3 -3
- package/dist/search/orama-cloud.js +1 -1
- package/dist/search/server.d.ts +1 -1
- package/dist/search/server.js +1 -1
- package/dist/{server-DgLf5q-v.d.ts → server-BhSRJDWc.d.ts} +2 -2
- package/dist/shiki-DzWiTQMz.js +114 -0
- package/dist/source/client/index.d.ts +1 -1
- package/dist/source/dynamic.d.ts +1 -1
- package/dist/source/dynamic.js +1 -2
- package/dist/source/index.d.ts +1 -1
- package/dist/source/index.js +2 -2
- package/dist/source/llms.d.ts +1 -1
- package/dist/source/plugins/lucide-icons.d.ts +1 -1
- package/dist/source/plugins/slugs.d.ts +1 -1
- package/dist/source/plugins/slugs.js +1 -1
- package/dist/source/plugins/status-badges.d.ts +2 -2
- package/dist/types-D1vp9AYr.d.ts +5 -0
- package/dist/utils/hast-to-jsx.d.ts +2 -0
- package/dist/utils/hast-to-jsx.js +367 -0
- package/package.json +21 -13
- package/dist/index-B-xgXq2T.d.ts +0 -23
- package/dist/index-BMEUQz-F.d.ts +0 -21
- package/dist/types-D89QoQR-.d.ts +0 -4
- package/dist/utils-Cgs-6U-z.js +0 -39
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as Awaitable } from "./types-
|
|
1
|
+
import { t as Awaitable } from "./types-D1vp9AYr.js";
|
|
2
2
|
import { n as StructuredData } from "./remark-structure-C4hp7I5L.js";
|
|
3
|
-
import { S as LoaderOutput, b as LoaderConfig } from "./index-
|
|
3
|
+
import { S as LoaderOutput, b as LoaderConfig } from "./index-DNo8LS3A.js";
|
|
4
4
|
import { Algoliasearch } from "algoliasearch";
|
|
5
5
|
//#region src/search/algolia.d.ts
|
|
6
6
|
interface DocumentRecord {
|
package/dist/breadcrumb.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as Root,
|
|
1
|
+
import { i as Root, r as Node, t as Folder } from "./definitions-CFOhwE1k.js";
|
|
2
2
|
import { ReactNode } from "react";
|
|
3
3
|
//#region src/breadcrumb.d.ts
|
|
4
4
|
export interface BreadcrumbItem {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { t as Awaitable } from "./types-
|
|
1
|
+
import { t as Awaitable } from "./types-D1vp9AYr.js";
|
|
2
2
|
import { r as SortedResult } from "./index-BbTxYEFm.js";
|
|
3
|
-
import { t as BaseIndex } from "./algolia-
|
|
4
|
-
import "./mixedbread-
|
|
3
|
+
import { t as BaseIndex } from "./algolia-NG5vCx7r.js";
|
|
4
|
+
import "./mixedbread-2VnWtXx5.js";
|
|
5
5
|
import { DependencyList } from "react";
|
|
6
6
|
import { AnyZBSearch, SearchParams } from "zbsearch";
|
|
7
7
|
import { Root } from "hast";
|
package/dist/content/md.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { t as Components } from "../hast-to-jsx-CgR__kSX.js";
|
|
1
2
|
import { FC } from "react";
|
|
2
3
|
import { Options } from "remark-rehype";
|
|
3
4
|
import { Compatible } from "vfile";
|
|
4
|
-
import { Components } from "hast-util-to-jsx-runtime";
|
|
5
5
|
import { PluggableList } from "unified";
|
|
6
6
|
//#region src/content/md.d.ts
|
|
7
7
|
export interface MarkdownRendererOptions {
|
|
@@ -15,7 +15,7 @@ export interface MarkdownRenderer {
|
|
|
15
15
|
}
|
|
16
16
|
export interface MarkdownProps {
|
|
17
17
|
async?: boolean;
|
|
18
|
-
components?: Components
|
|
18
|
+
components?: Partial<Components>;
|
|
19
19
|
children: Compatible;
|
|
20
20
|
}
|
|
21
21
|
export declare function createMarkdownRenderer({ rehypePlugins, remarkPlugins, remarkRehypeOptions }?: MarkdownRendererOptions): MarkdownRenderer;
|
package/dist/content/md.js
CHANGED
|
@@ -1,21 +1,12 @@
|
|
|
1
|
+
import { toJsx } from "../utils/hast-to-jsx.js";
|
|
1
2
|
import { use, useMemo } from "react";
|
|
2
|
-
import * as JsxRuntime from "react/jsx-runtime";
|
|
3
3
|
import { remark } from "remark";
|
|
4
4
|
import remarkRehype from "remark-rehype";
|
|
5
5
|
import { VFile } from "vfile";
|
|
6
|
-
import { toJsxRuntime } from "hast-util-to-jsx-runtime";
|
|
7
6
|
//#region src/content/md.ts
|
|
8
7
|
function createMarkdownRenderer({ rehypePlugins = [], remarkPlugins = [], remarkRehypeOptions } = {}) {
|
|
9
8
|
const processor = remark().use(remarkPlugins).use(remarkRehype, remarkRehypeOptions).use(rehypePlugins);
|
|
10
9
|
const promises = {};
|
|
11
|
-
function render(tree, file, props) {
|
|
12
|
-
return toJsxRuntime(tree, {
|
|
13
|
-
development: false,
|
|
14
|
-
filePath: file.path,
|
|
15
|
-
components: props.components,
|
|
16
|
-
...JsxRuntime
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
10
|
function parse(file) {
|
|
20
11
|
return processor.parse(file);
|
|
21
12
|
}
|
|
@@ -26,13 +17,15 @@ function createMarkdownRenderer({ rehypePlugins = [], remarkPlugins = [], remark
|
|
|
26
17
|
const id = `${file.path}:${file.value}`;
|
|
27
18
|
if (async) {
|
|
28
19
|
promises[id] ??= processor.run(parse(file), file);
|
|
29
|
-
|
|
20
|
+
const out = use(promises[id]);
|
|
21
|
+
return toJsx(out, { components: props.components });
|
|
30
22
|
}
|
|
31
|
-
|
|
23
|
+
const v = useMemo(() => processor.runSync(parse(file), file), [id]);
|
|
24
|
+
return toJsx(v, { components: props.components });
|
|
32
25
|
},
|
|
33
26
|
async MarkdownServer(props) {
|
|
34
27
|
const file = new VFile(props.children);
|
|
35
|
-
return
|
|
28
|
+
return toJsx(await processor.run(parse(file), file), { components: props.components });
|
|
36
29
|
}
|
|
37
30
|
};
|
|
38
31
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { t as RehypeCodeOptions } from "../../rehype-code-
|
|
1
|
+
import { t as RehypeCodeOptions } from "../../rehype-code-BVf0Uz2w.js";
|
|
2
2
|
import { t as RemarkImageOptions } from "../../remark-image-BI2S9LOb.js";
|
|
3
3
|
import { t as StructureOptions } from "../../remark-structure-C4hp7I5L.js";
|
|
4
4
|
import { t as RemarkHeadingOptions } from "../../remark-heading-DEIzTkU5.js";
|
|
5
5
|
import { t as RemarkCodeTabOptions } from "../../remark-code-tab-DE_4bdnu.js";
|
|
6
6
|
import { t as RemarkNpmOptions } from "../../remark-npm-BbpvkJaT.js";
|
|
7
|
-
import
|
|
7
|
+
import "../../index-Cr-WMmZN.js";
|
|
8
8
|
import { t as ResolvePlugins } from "../../util-BDsqOxh3.js";
|
|
9
9
|
import { Pluggable } from "unified";
|
|
10
10
|
import { ProcessorOptions } from "@mdx-js/mdx";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { t as RehypeCodeOptions } from "../../rehype-code-
|
|
1
|
+
import { t as RehypeCodeOptions } from "../../rehype-code-BVf0Uz2w.js";
|
|
2
2
|
import { t as RemarkImageOptions } from "../../remark-image-BI2S9LOb.js";
|
|
3
3
|
import { t as StructureOptions } from "../../remark-structure-C4hp7I5L.js";
|
|
4
4
|
import { t as RemarkHeadingOptions } from "../../remark-heading-DEIzTkU5.js";
|
|
5
5
|
import { t as RemarkCodeTabOptions } from "../../remark-code-tab-DE_4bdnu.js";
|
|
6
6
|
import { t as RemarkNpmOptions } from "../../remark-npm-BbpvkJaT.js";
|
|
7
|
-
import
|
|
7
|
+
import "../../index-Cr-WMmZN.js";
|
|
8
8
|
import { t as ResolvePlugins } from "../../util-BDsqOxh3.js";
|
|
9
9
|
import { ProcessorOptions } from "@mdx-js/mdx";
|
|
10
10
|
//#region src/content/mdx/preset-runtime.d.ts
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { ReactNode } from "react";
|
|
2
|
-
|
|
3
|
-
export { Folder, Item, Node, Root, Separator };
|
|
4
|
-
}
|
|
2
|
+
//#region src/page-tree/definitions.d.ts
|
|
5
3
|
interface ID {
|
|
6
4
|
/**
|
|
7
5
|
* ID for the node, unique in all page trees (even across different locales)
|
|
@@ -71,4 +69,4 @@ interface Folder extends ID {
|
|
|
71
69
|
children: Node[];
|
|
72
70
|
}
|
|
73
71
|
//#endregion
|
|
74
|
-
export { Separator as a, Root as i, Item as n,
|
|
72
|
+
export { Separator as a, Root as i, Item as n, Node as r, Folder as t };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { r as normalizeUrl } from "./url-BVHvi3_K.js";
|
|
2
2
|
import { l as visit } from "./utils-DEVq3cEC.js";
|
|
3
3
|
import { t as isEqualShallow } from "./is-equal-LdLqRs0o.js";
|
|
4
|
-
import { a as normalize, i as joinPath, n as dirname, r as extname, t as basename } from "./path-
|
|
4
|
+
import { a as normalize, i as joinPath, n as dirname, r as extname, t as basename } from "./path-UUoiuLiY.js";
|
|
5
5
|
import { slugsPlugin } from "./source/plugins/slugs.js";
|
|
6
6
|
import { t as iconPlugin } from "./icon-BILaoXeg.js";
|
|
7
7
|
import { cache } from "react";
|
|
@@ -17,4 +17,5 @@ export interface AstroProviderProps {
|
|
|
17
17
|
* You can pass `navigate` from `astro:transitions/client` to preserve client navigation.
|
|
18
18
|
*/
|
|
19
19
|
export declare function AstroProvider({ children, pathname, params, navigate, Link, Image }: AstroProviderProps): import("react").JSX.Element;
|
|
20
|
-
//#endregion
|
|
20
|
+
//#endregion
|
|
21
|
+
export {};
|
|
@@ -36,4 +36,5 @@ export declare function useRouter(): Router;
|
|
|
36
36
|
export declare function useParams(): Record<string, string | string[]>;
|
|
37
37
|
export declare function Image(props: ImageProps): import("react").JSX.Element;
|
|
38
38
|
export declare function Link(props: LinkProps): import("react").JSX.Element;
|
|
39
|
-
//#endregion
|
|
39
|
+
//#endregion
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ComponentType, JSX, ReactNode } from "react";
|
|
2
|
+
import { Nodes } from "hast";
|
|
3
|
+
import { Expression, Program } from "estree-jsx";
|
|
4
|
+
//#region src/utils/hast-to-jsx.d.ts
|
|
5
|
+
type Components = { [Tag in keyof JSX.IntrinsicElements]: ComponentType<JSX.IntrinsicElements[Tag]> | keyof JSX.IntrinsicElements; };
|
|
6
|
+
/** Turns the ESTree of MDX nodes into values. */
|
|
7
|
+
interface Evaluator {
|
|
8
|
+
evaluateExpression: (expression: Expression) => unknown;
|
|
9
|
+
evaluateProgram: (program: Program) => unknown;
|
|
10
|
+
}
|
|
11
|
+
interface ToJsxOptions {
|
|
12
|
+
components?: Partial<Components>;
|
|
13
|
+
/** Required by MDX expressions, ESM, and JSX elements with expressions or capitalized names. */
|
|
14
|
+
evaluator?: Evaluator;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Convert hast, with MDX nodes, into React elements like `toJsxRuntime()` from `hast-util-to-jsx-runtime`, but faster.
|
|
18
|
+
*/
|
|
19
|
+
declare function toJsx(tree: Nodes, { components, evaluator }?: ToJsxOptions): ReactNode;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { toJsx as i, Evaluator as n, ToJsxOptions as r, Components as t };
|
package/dist/highlight/client.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
2
|
+
import { i as applyDefaultThemes } from "../shiki-DzWiTQMz.js";
|
|
3
3
|
import { useShiki as useShiki$1 } from "./shiki/react.js";
|
|
4
4
|
import { defaultShikiFactory } from "./shiki/full.js";
|
|
5
5
|
//#region src/highlight/client.ts
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { i as Highlighter } from "../index-Bf_V9OZJ.js";
|
|
2
|
+
import { Theme } from "@pierre/highlights";
|
|
3
|
+
import { ShikiTransformer } from "shiki";
|
|
4
|
+
//#region src/highlight/highlights.d.ts
|
|
5
|
+
export interface HighlightsOptions {
|
|
6
|
+
/**
|
|
7
|
+
* Themes from `@pierre/highlights/themes`, like `{ light: githubLight, dark: githubDark }`.
|
|
8
|
+
*
|
|
9
|
+
* @defaultValue GitHub Light and GitHub Dark
|
|
10
|
+
*/
|
|
11
|
+
themes?: Record<string, Theme>;
|
|
12
|
+
/**
|
|
13
|
+
* Shiki transformers, run on the tokens of Highlights as a compatibility layer.
|
|
14
|
+
*/
|
|
15
|
+
shikiTransformers?: ShikiTransformer[];
|
|
16
|
+
}
|
|
17
|
+
export interface HighlightsHighlighter extends Highlighter {
|
|
18
|
+
/** Create a highlighter with `options` in place of its own, like other Shiki transformers. */
|
|
19
|
+
override: (options: HighlightsOptions) => HighlightsHighlighter;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* A highlighter using `@pierre/highlights`, its languages are built in.
|
|
23
|
+
*/
|
|
24
|
+
export declare function createHighlights(highlightsOptions?: HighlightsOptions): HighlightsHighlighter;
|
|
25
|
+
//#endregion
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import { codeToTokens, isSupportedLanguage } from "@pierre/highlights";
|
|
2
|
+
import githubLight from "@pierre/highlights/themes/github-light";
|
|
3
|
+
import githubDark from "@pierre/highlights/themes/github-dark";
|
|
4
|
+
//#region src/highlight/highlights.ts
|
|
5
|
+
/**
|
|
6
|
+
* A highlighter using `@pierre/highlights`, its languages are built in.
|
|
7
|
+
*/
|
|
8
|
+
function createHighlights(highlightsOptions = {}) {
|
|
9
|
+
const { themes = {
|
|
10
|
+
light: githubLight,
|
|
11
|
+
dark: githubDark
|
|
12
|
+
}, shikiTransformers = [] } = highlightsOptions;
|
|
13
|
+
const themeIds = {};
|
|
14
|
+
for (const [key, theme] of Object.entries(themes)) themeIds[key] = theme.name.toLowerCase().replaceAll(" ", "-");
|
|
15
|
+
const themeName = `shiki-themes ${Object.values(themeIds).join(" ")}`;
|
|
16
|
+
function tokenize(code, lang) {
|
|
17
|
+
return {
|
|
18
|
+
...codeToTokens(code, {
|
|
19
|
+
lang: isSupportedLanguage(lang) ? lang : "text",
|
|
20
|
+
themes,
|
|
21
|
+
defaultColor: false,
|
|
22
|
+
cssVariablePrefix: "--shiki-"
|
|
23
|
+
}),
|
|
24
|
+
themeName
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function render(code, options) {
|
|
28
|
+
const transformers = (options.transformers ?? []).toSorted((a, b) => order(a) - order(b));
|
|
29
|
+
const context = {
|
|
30
|
+
meta: {},
|
|
31
|
+
options,
|
|
32
|
+
codeToHast: render,
|
|
33
|
+
codeToTokens: (code, { lang = "text" }) => tokenize(code, lang)
|
|
34
|
+
};
|
|
35
|
+
for (const transformer of transformers) code = transformer.preprocess?.call(context, code, options) || code;
|
|
36
|
+
const result = tokenize(code, options.lang);
|
|
37
|
+
let tokens = mergeWhitespaces(result.tokens);
|
|
38
|
+
const source = {
|
|
39
|
+
...context,
|
|
40
|
+
source: code
|
|
41
|
+
};
|
|
42
|
+
for (const transformer of transformers) tokens = transformer.tokens?.call(source, tokens) || tokens;
|
|
43
|
+
return tokensToHast(tokens, {
|
|
44
|
+
...result,
|
|
45
|
+
...options
|
|
46
|
+
}, transformers, source);
|
|
47
|
+
}
|
|
48
|
+
function getCodeOptions(codeOptions) {
|
|
49
|
+
return {
|
|
50
|
+
...codeOptions,
|
|
51
|
+
themes: themeIds,
|
|
52
|
+
defaultColor: false,
|
|
53
|
+
transformers: shikiTransformers
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
codeToHast: (code, codeOptions) => render(code, getCodeOptions(codeOptions)),
|
|
58
|
+
override: (options) => createHighlights({
|
|
59
|
+
...highlightsOptions,
|
|
60
|
+
...options
|
|
61
|
+
})
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
function order(transformer) {
|
|
65
|
+
if (transformer.enforce === "pre") return -1;
|
|
66
|
+
if (transformer.enforce === "post") return 1;
|
|
67
|
+
return 0;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* White space tokens join the next token, like the default `mergeWhitespaces` of Shiki: its transformers
|
|
71
|
+
* expect it, the notations find comment-only lines as lines of one token.
|
|
72
|
+
*/
|
|
73
|
+
function mergeWhitespaces(lines) {
|
|
74
|
+
const out = [];
|
|
75
|
+
for (const line of lines) {
|
|
76
|
+
const merged = [];
|
|
77
|
+
let carry = "";
|
|
78
|
+
let offset = 0;
|
|
79
|
+
for (let i = 0; i < line.length; i++) {
|
|
80
|
+
const token = line[i];
|
|
81
|
+
const mergeable = ((token.fontStyle ?? 0) & 12) === 0;
|
|
82
|
+
if (mergeable && i < line.length - 1 && /^\s+$/.test(token.content)) {
|
|
83
|
+
if (!carry) offset = token.offset;
|
|
84
|
+
carry += token.content;
|
|
85
|
+
} else if (!carry) merged.push(token);
|
|
86
|
+
else if (mergeable) {
|
|
87
|
+
merged.push({
|
|
88
|
+
...token,
|
|
89
|
+
offset,
|
|
90
|
+
content: carry + token.content
|
|
91
|
+
});
|
|
92
|
+
carry = "";
|
|
93
|
+
} else {
|
|
94
|
+
merged.push({
|
|
95
|
+
content: carry,
|
|
96
|
+
offset
|
|
97
|
+
}, token);
|
|
98
|
+
carry = "";
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
out.push(merged);
|
|
102
|
+
}
|
|
103
|
+
return out;
|
|
104
|
+
}
|
|
105
|
+
function getTokenStyle(token) {
|
|
106
|
+
let style = "";
|
|
107
|
+
for (const key in token.htmlStyle) style += `${style ? ";" : ""}${key}:${token.htmlStyle[key]}`;
|
|
108
|
+
return style;
|
|
109
|
+
}
|
|
110
|
+
function addClassToHast(node, className) {
|
|
111
|
+
if (!className) return node;
|
|
112
|
+
const current = node.properties.class;
|
|
113
|
+
const classes = Array.isArray(current) ? current : typeof current === "string" ? current.split(/\s+/) : [];
|
|
114
|
+
for (const name of Array.isArray(className) ? className : className.split(/\s+/)) if (name && !classes.includes(name)) classes.push(name);
|
|
115
|
+
node.properties.class = classes;
|
|
116
|
+
return node;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Render Shiki tokens into Shiki's hast structure, with transformers applied.
|
|
120
|
+
*/
|
|
121
|
+
function tokensToHast(tokens, options, transformers, source) {
|
|
122
|
+
const { structure = "classic" } = options;
|
|
123
|
+
const properties = {
|
|
124
|
+
class: `shiki ${options.themeName ?? ""}`,
|
|
125
|
+
style: options.rootStyle || `background-color:${options.bg};color:${options.fg}`,
|
|
126
|
+
tabindex: "0"
|
|
127
|
+
};
|
|
128
|
+
for (const [key, value] of Object.entries(options.meta ?? {})) if (!key.startsWith("_")) properties[key] = value;
|
|
129
|
+
const lines = [];
|
|
130
|
+
let root = {
|
|
131
|
+
type: "root",
|
|
132
|
+
children: []
|
|
133
|
+
};
|
|
134
|
+
let pre = {
|
|
135
|
+
type: "element",
|
|
136
|
+
tagName: "pre",
|
|
137
|
+
properties,
|
|
138
|
+
children: []
|
|
139
|
+
};
|
|
140
|
+
let code = {
|
|
141
|
+
type: "element",
|
|
142
|
+
tagName: "code",
|
|
143
|
+
properties: {},
|
|
144
|
+
children: []
|
|
145
|
+
};
|
|
146
|
+
const context = {
|
|
147
|
+
...source,
|
|
148
|
+
structure,
|
|
149
|
+
addClassToHast,
|
|
150
|
+
get tokens() {
|
|
151
|
+
return tokens;
|
|
152
|
+
},
|
|
153
|
+
get root() {
|
|
154
|
+
return root;
|
|
155
|
+
},
|
|
156
|
+
get pre() {
|
|
157
|
+
return pre;
|
|
158
|
+
},
|
|
159
|
+
get code() {
|
|
160
|
+
return code;
|
|
161
|
+
},
|
|
162
|
+
get lines() {
|
|
163
|
+
return lines;
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
for (let i = 0; i < tokens.length; i++) {
|
|
167
|
+
let line = {
|
|
168
|
+
type: "element",
|
|
169
|
+
tagName: "span",
|
|
170
|
+
properties: { class: "line" },
|
|
171
|
+
children: []
|
|
172
|
+
};
|
|
173
|
+
let col = 0;
|
|
174
|
+
for (const token of tokens[i]) {
|
|
175
|
+
let span = {
|
|
176
|
+
type: "element",
|
|
177
|
+
tagName: "span",
|
|
178
|
+
properties: { ...token.htmlAttrs },
|
|
179
|
+
children: [{
|
|
180
|
+
type: "text",
|
|
181
|
+
value: token.content
|
|
182
|
+
}]
|
|
183
|
+
};
|
|
184
|
+
const style = getTokenStyle(token);
|
|
185
|
+
if (style) span.properties.style = style;
|
|
186
|
+
for (const transformer of transformers) span = transformer.span?.call(context, span, i + 1, col, line, token) || span;
|
|
187
|
+
line.children.push(span);
|
|
188
|
+
col += token.content.length;
|
|
189
|
+
}
|
|
190
|
+
if (structure === "classic") for (const transformer of transformers) line = transformer.line?.call(context, line, i + 1) || line;
|
|
191
|
+
lines.push(line);
|
|
192
|
+
}
|
|
193
|
+
for (let i = 0; i < lines.length; i++) {
|
|
194
|
+
if (i > 0 && structure === "classic") code.children.push({
|
|
195
|
+
type: "text",
|
|
196
|
+
value: "\n"
|
|
197
|
+
});
|
|
198
|
+
code.children.push(lines[i]);
|
|
199
|
+
}
|
|
200
|
+
for (const transformer of transformers) code = transformer.code?.call(context, code) || code;
|
|
201
|
+
if (structure === "classic") {
|
|
202
|
+
pre.children.push(code);
|
|
203
|
+
for (const transformer of transformers) pre = transformer.pre?.call(context, pre) || pre;
|
|
204
|
+
root.children.push(pre);
|
|
205
|
+
} else for (let i = 0; i < code.children.length; i++) {
|
|
206
|
+
const line = code.children[i];
|
|
207
|
+
if (i > 0) root.children.push({
|
|
208
|
+
type: "element",
|
|
209
|
+
tagName: "br",
|
|
210
|
+
properties: {},
|
|
211
|
+
children: []
|
|
212
|
+
});
|
|
213
|
+
if (line.type === "element") root.children.push(...line.children);
|
|
214
|
+
}
|
|
215
|
+
for (const transformer of transformers) root = transformer.root?.call(context, root) || root;
|
|
216
|
+
return root;
|
|
217
|
+
}
|
|
218
|
+
//#endregion
|
|
219
|
+
export { createHighlights };
|
|
@@ -1,30 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { Root } from "hast";
|
|
4
|
-
import { BundledLanguage, BundledTheme, CodeOptionsMeta, CodeOptionsThemes, CodeToHastOptionsCommon, LanguageRegistration, ThemeRegistrationAny } from "shiki";
|
|
5
|
-
//#region src/highlight/index.d.ts
|
|
6
|
-
export type HighlightOptions = HighlightHastOptions & {
|
|
7
|
-
components?: Partial<Components>;
|
|
8
|
-
};
|
|
9
|
-
export type HighlightHastOptions = CodeToHastOptionsCommon<BundledLanguage> & CodeOptionsMeta & {
|
|
10
|
-
fallbackLanguage?: BundledLanguage | (string & {});
|
|
11
|
-
/**
|
|
12
|
-
* The Regex Engine for Shiki
|
|
13
|
-
*
|
|
14
|
-
* @defaultValue 'js'
|
|
15
|
-
*/
|
|
16
|
-
engine?: 'js' | 'oniguruma';
|
|
17
|
-
} & (CodeOptionsThemes<BundledTheme> | Record<never, never>);
|
|
18
|
-
export declare function highlightHast(code: string, options: HighlightHastOptions): Promise<Root>;
|
|
19
|
-
/**
|
|
20
|
-
* Get Shiki highlighter instance of Fumadocs (mostly for internal use, you should use Shiki directly over this).
|
|
21
|
-
*
|
|
22
|
-
* @param engineType - Shiki Regex engine to use.
|
|
23
|
-
* @param options - Shiki options.
|
|
24
|
-
*/
|
|
25
|
-
export declare function getHighlighter(engineType: 'js' | 'oniguruma', options?: {
|
|
26
|
-
langs?: (BundledLanguage | LanguageRegistration)[];
|
|
27
|
-
themes?: (BundledTheme | ThemeRegistrationAny)[];
|
|
28
|
-
}): Promise<import("shiki").HighlighterCore>;
|
|
29
|
-
export declare function highlight(code: string, options: HighlightOptions): Promise<ReactNode>;
|
|
30
|
-
//#endregion
|
|
1
|
+
import { a as getHighlighter, i as Highlighter, n as HighlightHastOptions, o as highlight, r as HighlightOptions, s as highlightHast, t as HighlightCodeOptions } from "../index-Bf_V9OZJ.js";
|
|
2
|
+
export { HighlightCodeOptions, HighlightHastOptions, HighlightOptions, Highlighter, getHighlighter, highlight, highlightHast };
|
package/dist/highlight/index.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { toJsx } from "../utils/hast-to-jsx.js";
|
|
2
|
+
import { i as applyDefaultThemes, o as loadMissingLanguage, r as highlightHast$1, s as loadMissingTheme } from "../shiki-DzWiTQMz.js";
|
|
3
3
|
import { defaultShikiFactory, wasmShikiFactory } from "./shiki/full.js";
|
|
4
|
-
import * as JsxRuntime from "react/jsx-runtime";
|
|
5
|
-
import { toJsxRuntime } from "hast-util-to-jsx-runtime";
|
|
6
4
|
//#region src/highlight/index.ts
|
|
7
5
|
async function highlightHast(code, options) {
|
|
8
6
|
const instance = await ((options.engine ?? "js") === "js" ? defaultShikiFactory : wasmShikiFactory).getOrInit();
|
|
@@ -20,11 +18,7 @@ async function getHighlighter(engineType, options = {}) {
|
|
|
20
18
|
return instance;
|
|
21
19
|
}
|
|
22
20
|
async function highlight(code, options) {
|
|
23
|
-
return
|
|
24
|
-
...JsxRuntime,
|
|
25
|
-
development: false,
|
|
26
|
-
components: options.components
|
|
27
|
-
});
|
|
21
|
+
return toJsx(await highlightHast(code, options), { components: options.components });
|
|
28
22
|
}
|
|
29
23
|
//#endregion
|
|
30
24
|
export { getHighlighter, highlight, highlightHast };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as ShikiFactory } from "../../index-
|
|
1
|
+
import { n as ShikiFactory } from "../../index-m7W5wflM.js";
|
|
2
2
|
//#region src/highlight/shiki/full.d.ts
|
|
3
3
|
export declare const defaultShikiFactory: ShikiFactory;
|
|
4
4
|
/** factory using the WASM powered Regex engine */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createShikiFactory } from "
|
|
1
|
+
import { t as createShikiFactory } from "../../shiki-DzWiTQMz.js";
|
|
2
2
|
//#region src/highlight/shiki/full.ts
|
|
3
3
|
const defaultShikiFactory = createShikiFactory({ async init(options) {
|
|
4
4
|
const { createHighlighter, createJavaScriptRegexEngine } = await import("shiki");
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as
|
|
2
|
-
export { HighlightHastOptions, ShikiFactory, createShikiFactory, highlightHast };
|
|
1
|
+
import { a as createShikiFactory, i as ShikiHighlighterOptions, n as ShikiFactory, o as createShikiHighlighter, r as ShikiHighlighter, s as highlightHast, t as HighlightHastOptions } from "../../index-m7W5wflM.js";
|
|
2
|
+
export { HighlightHastOptions, ShikiFactory, ShikiHighlighter, ShikiHighlighterOptions, createShikiFactory, createShikiHighlighter, highlightHast };
|
|
@@ -1,27 +1 @@
|
|
|
1
|
-
|
|
2
|
-
//#region src/highlight/shiki/index.ts
|
|
3
|
-
function createShikiFactory(config) {
|
|
4
|
-
let instance;
|
|
5
|
-
return {
|
|
6
|
-
init(options) {
|
|
7
|
-
const created = config.init(options);
|
|
8
|
-
if (created instanceof Promise) created.catch(() => {
|
|
9
|
-
if (instance === created) instance = void 0;
|
|
10
|
-
});
|
|
11
|
-
return instance = created;
|
|
12
|
-
},
|
|
13
|
-
getOrInit() {
|
|
14
|
-
return instance ?? this.init();
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
async function highlightHast(highlighter, code, options) {
|
|
19
|
-
const { fallbackLanguage = "text", ...resolved } = options;
|
|
20
|
-
const { isSpecialLang } = await import("shiki/core");
|
|
21
|
-
const loaded = highlighter.getLoadedLanguages();
|
|
22
|
-
if (!isSpecialLang(resolved.lang) && !(resolved.lang in highlighter.getBundledLanguages()) && !loaded.includes(resolved.lang)) resolved.lang = fallbackLanguage;
|
|
23
|
-
await Promise.all([loadMissingTheme(highlighter, getRequiredThemes(resolved)), !isSpecialLang(resolved.lang) && !loaded.includes(resolved.lang) && highlighter.loadLanguage(resolved.lang)]);
|
|
24
|
-
return highlighter.codeToHast(code, resolved);
|
|
25
|
-
}
|
|
26
|
-
//#endregion
|
|
27
|
-
export { createShikiFactory, highlightHast };
|
|
1
|
+
export { t as createShikiFactory, n as createShikiHighlighter, r as highlightHast } from "../../shiki-DzWiTQMz.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { t as
|
|
2
|
-
import { t as
|
|
1
|
+
import { t as Components } from "../../hast-to-jsx-CgR__kSX.js";
|
|
2
|
+
import { t as Awaitable } from "../../types-D1vp9AYr.js";
|
|
3
|
+
import { t as HighlightHastOptions } from "../../index-m7W5wflM.js";
|
|
3
4
|
import { DependencyList, ReactNode } from "react";
|
|
4
|
-
import { Components } from "hast-util-to-jsx-runtime";
|
|
5
5
|
import { HighlighterCore } from "shiki";
|
|
6
6
|
//#region src/highlight/shiki/react.d.ts
|
|
7
7
|
export type UseShikiOptions = HighlightHastOptions & {
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
2
|
+
import { toJsx } from "../../utils/hast-to-jsx.js";
|
|
3
|
+
import { r as highlightHast } from "../../shiki-DzWiTQMz.js";
|
|
3
4
|
import { use, useEffect, useMemo, useRef, useState } from "react";
|
|
4
|
-
import * as JsxRuntime from "react/jsx-runtime";
|
|
5
|
-
import { toJsxRuntime } from "hast-util-to-jsx-runtime";
|
|
6
5
|
//#region src/highlight/shiki/react.ts
|
|
7
6
|
const promises = {};
|
|
7
|
+
async function render(highlighter, code, options) {
|
|
8
|
+
const instance = typeof highlighter === "function" ? await highlighter() : highlighter;
|
|
9
|
+
return toJsx(await highlightHast(instance, code, options), { components: options.components });
|
|
10
|
+
}
|
|
8
11
|
/**
|
|
9
12
|
* get highlighted results (uncached), use `useEffect` instead of React 19 APIs.
|
|
10
13
|
*/
|
|
@@ -12,14 +15,7 @@ function useShikiDynamic(highlighter, code, options, deps) {
|
|
|
12
15
|
const [node, setNode] = useState(options.defaultValue);
|
|
13
16
|
const lastTask = useRef(null);
|
|
14
17
|
useEffect(() => {
|
|
15
|
-
|
|
16
|
-
const instance = typeof highlighter === "function" ? await highlighter() : highlighter;
|
|
17
|
-
return toJsxRuntime(await highlightHast(instance, code, options), {
|
|
18
|
-
...JsxRuntime,
|
|
19
|
-
components: options.components
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
const promise = task();
|
|
18
|
+
const promise = render(highlighter, code, options);
|
|
23
19
|
lastTask.current = promise;
|
|
24
20
|
promise.then((res) => {
|
|
25
21
|
if (lastTask.current === promise) setNode(res);
|
|
@@ -37,14 +33,7 @@ function useShikiDynamic(highlighter, code, options, deps) {
|
|
|
37
33
|
*/
|
|
38
34
|
function useShiki(highlighter, code, options, deps = [options.lang, code]) {
|
|
39
35
|
const key = useMemo(() => JSON.stringify(deps), [deps]);
|
|
40
|
-
|
|
41
|
-
const instance = typeof highlighter === "function" ? await highlighter() : highlighter;
|
|
42
|
-
return toJsxRuntime(await highlightHast(instance, code, options), {
|
|
43
|
-
...JsxRuntime,
|
|
44
|
-
components: options.components
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
return use(promises[key] ??= run());
|
|
36
|
+
return use(promises[key] ??= render(highlighter, code, options));
|
|
48
37
|
}
|
|
49
38
|
//#endregion
|
|
50
39
|
export { useShiki, useShikiDynamic };
|
|
@@ -30,4 +30,5 @@ export interface URLFormatter {
|
|
|
30
30
|
}
|
|
31
31
|
export declare const DefaultFormatter: URLFormatter;
|
|
32
32
|
export declare function createI18nMiddleware({ languages, defaultLanguage, format, cookieName, hideLocale }: MiddlewareOptions): NextProxy;
|
|
33
|
-
//#endregion
|
|
33
|
+
//#endregion
|
|
34
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i as Root } from "./definitions-
|
|
2
|
-
import
|
|
1
|
+
import { i as Root } from "./definitions-CFOhwE1k.js";
|
|
2
|
+
import "./index-E8Qh_yQs.js";
|
|
3
3
|
//#region src/source/client/index.d.ts
|
|
4
4
|
interface SerializedPageTree {
|
|
5
5
|
$fumadocs_loader: 'page-tree';
|