fumadocs-core 16.7.15 → 16.7.16
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/content/mdx/preset-bundler.d.ts +1 -1
- package/dist/content/mdx/preset-runtime.d.ts +1 -1
- package/dist/i18n/middleware.js +9 -34
- package/dist/mdx-plugins/index.d.ts +2 -2
- package/dist/mdx-plugins/index.js +1 -1
- package/dist/mdx-plugins/rehype-code.core.d.ts +1 -1
- package/dist/mdx-plugins/rehype-code.core.js +1 -1
- package/dist/mdx-plugins/rehype-code.d.ts +2 -2
- package/dist/mdx-plugins/rehype-code.js +1 -1
- package/dist/{rehype-code-DJKXLHtp.d.ts → rehype-code-RQFGrMHT.d.ts} +1 -1
- package/dist/{rehype-code.core-Cg1anr4H.d.ts → rehype-code.core-AKfLRGV3.d.ts} +9 -3
- package/dist/{rehype-code.core-Ckq2nRUU.js → rehype-code.core-n_TXY2L8.js} +51 -47
- package/package.json +8 -8
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as RehypeCodeOptions } from "../../rehype-code-
|
|
1
|
+
import { t as RehypeCodeOptions } from "../../rehype-code-RQFGrMHT.js";
|
|
2
2
|
import { t as RemarkImageOptions } from "../../remark-image-CSTFtaeg.js";
|
|
3
3
|
import { r as StructureOptions } from "../../remark-structure-BxbC5Buc.js";
|
|
4
4
|
import { t as RemarkHeadingOptions } from "../../remark-heading-DJvYcq64.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as RehypeCodeOptions } from "../../rehype-code-
|
|
1
|
+
import { t as RehypeCodeOptions } from "../../rehype-code-RQFGrMHT.js";
|
|
2
2
|
import { t as RemarkImageOptions } from "../../remark-image-CSTFtaeg.js";
|
|
3
3
|
import { r as StructureOptions } from "../../remark-structure-BxbC5Buc.js";
|
|
4
4
|
import { t as RemarkHeadingOptions } from "../../remark-heading-DJvYcq64.js";
|
package/dist/i18n/middleware.js
CHANGED
|
@@ -1,15 +1,6 @@
|
|
|
1
1
|
import { t as getNegotiator } from "../negotiation-BdxTpPs1.js";
|
|
2
2
|
import { NextResponse } from "next/server.js";
|
|
3
|
-
//#region ../../node_modules/.pnpm/@formatjs+
|
|
4
|
-
/**
|
|
5
|
-
* http://ecma-international.org/ecma-402/7.0/index.html#sec-canonicalizelocalelist
|
|
6
|
-
* @param locales
|
|
7
|
-
*/
|
|
8
|
-
function CanonicalizeLocaleList(locales) {
|
|
9
|
-
return Intl.getCanonicalLocales(locales);
|
|
10
|
-
}
|
|
11
|
-
//#endregion
|
|
12
|
-
//#region ../../node_modules/.pnpm/@formatjs+fast-memoize@3.1.1/node_modules/@formatjs/fast-memoize/index.js
|
|
3
|
+
//#region ../../node_modules/.pnpm/@formatjs+fast-memoize@3.1.2/node_modules/@formatjs/fast-memoize/index.js
|
|
13
4
|
function memoize(fn, options) {
|
|
14
5
|
const cache = options && options.cache ? options.cache : cacheDefault;
|
|
15
6
|
const serializer = options && options.serializer ? options.serializer : serializerDefault;
|
|
@@ -51,7 +42,6 @@ const serializerDefault = function() {
|
|
|
51
42
|
return JSON.stringify(arguments);
|
|
52
43
|
};
|
|
53
44
|
var ObjectWithoutPrototypeCache = class {
|
|
54
|
-
cache;
|
|
55
45
|
constructor() {
|
|
56
46
|
this.cache = Object.create(null);
|
|
57
47
|
}
|
|
@@ -66,7 +56,14 @@ const cacheDefault = { create: function create() {
|
|
|
66
56
|
return new ObjectWithoutPrototypeCache();
|
|
67
57
|
} };
|
|
68
58
|
//#endregion
|
|
69
|
-
//#region ../../node_modules/.pnpm/@formatjs+intl-localematcher@0.8.
|
|
59
|
+
//#region ../../node_modules/.pnpm/@formatjs+intl-localematcher@0.8.3/node_modules/@formatjs/intl-localematcher/index.js
|
|
60
|
+
/**
|
|
61
|
+
* http://ecma-international.org/ecma-402/7.0/index.html#sec-canonicalizelocalelist
|
|
62
|
+
* @param locales
|
|
63
|
+
*/
|
|
64
|
+
function CanonicalizeLocaleList(locales) {
|
|
65
|
+
return Intl.getCanonicalLocales(locales);
|
|
66
|
+
}
|
|
70
67
|
const data = { supplemental: { languageMatching: { "written-new": [
|
|
71
68
|
{ paradigmLocales: { _locales: "en en_GB es es_419 pt_BR pt_PT" } },
|
|
72
69
|
{ $enUS: { _value: "AS+CA+GU+MH+MP+PH+PR+UM+US+VI" } },
|
|
@@ -1913,8 +1910,6 @@ const data = { supplemental: { languageMatching: { "written-new": [
|
|
|
1913
1910
|
_distance: "4"
|
|
1914
1911
|
} }
|
|
1915
1912
|
] } } };
|
|
1916
|
-
//#endregion
|
|
1917
|
-
//#region ../../node_modules/.pnpm/@formatjs+intl-localematcher@0.8.2/node_modules/@formatjs/intl-localematcher/abstract/regions.generated.js
|
|
1918
1913
|
const regions = {
|
|
1919
1914
|
"001": [
|
|
1920
1915
|
"001",
|
|
@@ -3248,8 +3243,6 @@ const regions = {
|
|
|
3248
3243
|
"ZW"
|
|
3249
3244
|
]
|
|
3250
3245
|
};
|
|
3251
|
-
//#endregion
|
|
3252
|
-
//#region ../../node_modules/.pnpm/@formatjs+intl-localematcher@0.8.2/node_modules/@formatjs/intl-localematcher/abstract/utils.js
|
|
3253
3246
|
const UNICODE_EXTENSION_SEQUENCE_REGEX = /-u(?:-[0-9a-z]{2,8})+/gi;
|
|
3254
3247
|
/**
|
|
3255
3248
|
* Asserts that a condition is true, throwing an error if it is not.
|
|
@@ -3538,8 +3531,6 @@ function findBestMatch(requestedLocales, supportedLocales, threshold = DEFAULT_M
|
|
|
3538
3531
|
}
|
|
3539
3532
|
return result;
|
|
3540
3533
|
}
|
|
3541
|
-
//#endregion
|
|
3542
|
-
//#region ../../node_modules/.pnpm/@formatjs+intl-localematcher@0.8.2/node_modules/@formatjs/intl-localematcher/abstract/BestFitMatcher.js
|
|
3543
3534
|
/**
|
|
3544
3535
|
* https://tc39.es/ecma402/#sec-bestfitmatcher
|
|
3545
3536
|
* @param availableLocales
|
|
@@ -3567,20 +3558,14 @@ function BestFitMatcher(availableLocales, requestedLocales, getDefaultLocale) {
|
|
|
3567
3558
|
extension
|
|
3568
3559
|
};
|
|
3569
3560
|
}
|
|
3570
|
-
//#endregion
|
|
3571
|
-
//#region ../../node_modules/.pnpm/@formatjs+intl-localematcher@0.8.2/node_modules/@formatjs/intl-localematcher/abstract/CanonicalizeUValue.js
|
|
3572
3561
|
function CanonicalizeUValue(ukey, uvalue) {
|
|
3573
3562
|
let lowerValue = uvalue.toLowerCase();
|
|
3574
3563
|
invariant(ukey !== void 0, `ukey must be defined`);
|
|
3575
3564
|
return lowerValue;
|
|
3576
3565
|
}
|
|
3577
|
-
//#endregion
|
|
3578
|
-
//#region ../../node_modules/.pnpm/@formatjs+intl-localematcher@0.8.2/node_modules/@formatjs/intl-localematcher/abstract/CanonicalizeUnicodeLocaleId.js
|
|
3579
3566
|
function CanonicalizeUnicodeLocaleId(locale) {
|
|
3580
3567
|
return Intl.getCanonicalLocales(locale)[0];
|
|
3581
3568
|
}
|
|
3582
|
-
//#endregion
|
|
3583
|
-
//#region ../../node_modules/.pnpm/@formatjs+intl-localematcher@0.8.2/node_modules/@formatjs/intl-localematcher/abstract/InsertUnicodeExtensionAndCanonicalize.js
|
|
3584
3569
|
function InsertUnicodeExtensionAndCanonicalize(locale, attributes, keywords) {
|
|
3585
3570
|
invariant(locale.indexOf("-u-") === -1, "Expected locale to not have a Unicode locale extension");
|
|
3586
3571
|
let extension = "-u";
|
|
@@ -3601,8 +3586,6 @@ function InsertUnicodeExtensionAndCanonicalize(locale, attributes, keywords) {
|
|
|
3601
3586
|
}
|
|
3602
3587
|
return CanonicalizeUnicodeLocaleId(newLocale);
|
|
3603
3588
|
}
|
|
3604
|
-
//#endregion
|
|
3605
|
-
//#region ../../node_modules/.pnpm/@formatjs+intl-localematcher@0.8.2/node_modules/@formatjs/intl-localematcher/abstract/BestAvailableLocale.js
|
|
3606
3589
|
const availableLocalesSetCache = /* @__PURE__ */ new WeakMap();
|
|
3607
3590
|
/**
|
|
3608
3591
|
* https://tc39.es/ecma402/#sec-bestavailablelocale
|
|
@@ -3624,8 +3607,6 @@ function BestAvailableLocale(availableLocales, locale) {
|
|
|
3624
3607
|
candidate = candidate.slice(0, pos);
|
|
3625
3608
|
}
|
|
3626
3609
|
}
|
|
3627
|
-
//#endregion
|
|
3628
|
-
//#region ../../node_modules/.pnpm/@formatjs+intl-localematcher@0.8.2/node_modules/@formatjs/intl-localematcher/abstract/LookupMatcher.js
|
|
3629
3610
|
/**
|
|
3630
3611
|
* https://tc39.es/ecma402/#sec-lookupmatcher
|
|
3631
3612
|
* @param availableLocales
|
|
@@ -3646,8 +3627,6 @@ function LookupMatcher(availableLocales, requestedLocales, getDefaultLocale) {
|
|
|
3646
3627
|
result.locale = getDefaultLocale();
|
|
3647
3628
|
return result;
|
|
3648
3629
|
}
|
|
3649
|
-
//#endregion
|
|
3650
|
-
//#region ../../node_modules/.pnpm/@formatjs+intl-localematcher@0.8.2/node_modules/@formatjs/intl-localematcher/abstract/UnicodeExtensionComponents.js
|
|
3651
3630
|
function UnicodeExtensionComponents(extension) {
|
|
3652
3631
|
invariant(extension === extension.toLowerCase(), "Expected extension to be lowercase");
|
|
3653
3632
|
invariant(extension.slice(0, 3) === "-u-", "Expected extension to be a Unicode locale extension");
|
|
@@ -3683,8 +3662,6 @@ function UnicodeExtensionComponents(extension) {
|
|
|
3683
3662
|
keywords
|
|
3684
3663
|
};
|
|
3685
3664
|
}
|
|
3686
|
-
//#endregion
|
|
3687
|
-
//#region ../../node_modules/.pnpm/@formatjs+intl-localematcher@0.8.2/node_modules/@formatjs/intl-localematcher/abstract/ResolveLocale.js
|
|
3688
3665
|
/**
|
|
3689
3666
|
* https://tc39.es/ecma402/#sec-resolvelocale
|
|
3690
3667
|
*/
|
|
@@ -3756,8 +3733,6 @@ function ResolveLocale(availableLocales, requestedLocales, options, relevantExte
|
|
|
3756
3733
|
result.locale = foundLocale;
|
|
3757
3734
|
return result;
|
|
3758
3735
|
}
|
|
3759
|
-
//#endregion
|
|
3760
|
-
//#region ../../node_modules/.pnpm/@formatjs+intl-localematcher@0.8.2/node_modules/@formatjs/intl-localematcher/index.js
|
|
3761
3736
|
function match(requestedLocales, availableLocales, defaultLocale, opts) {
|
|
3762
3737
|
return ResolveLocale(availableLocales, CanonicalizeLocaleList(requestedLocales), { localeMatcher: opts?.algorithm || "best fit" }, [], {}, () => defaultLocale).locale;
|
|
3763
3738
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { n as remarkGfm, t as RemarkGfmOptions } from "../remark-gfm-D9aa2ppr.js";
|
|
2
|
-
import { a as CodeBlockIcon, i as transformerTab, o as transformerIcon } from "../rehype-code.core-
|
|
3
|
-
import { n as rehypeCode, r as rehypeCodeDefaultOptions, t as RehypeCodeOptions } from "../rehype-code-
|
|
2
|
+
import { a as CodeBlockIcon, i as transformerTab, o as transformerIcon } from "../rehype-code.core-AKfLRGV3.js";
|
|
3
|
+
import { n as rehypeCode, r as rehypeCodeDefaultOptions, t as RehypeCodeOptions } from "../rehype-code-RQFGrMHT.js";
|
|
4
4
|
import { n as remarkImage, t as RemarkImageOptions } from "../remark-image-CSTFtaeg.js";
|
|
5
5
|
import { a as defaultStringifier, c as structure, i as StructuredData, n as StringifyOptions, o as remarkStructure, r as StructureOptions, s as remarkStructureDefaultOptions, t as Stringifier } from "../remark-structure-BxbC5Buc.js";
|
|
6
6
|
import { n as remarkHeading, t as RemarkHeadingOptions } from "../remark-heading-DJvYcq64.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { remarkHeading } from "./remark-heading.js";
|
|
2
2
|
import { generateCodeBlockTabs, parseCodeBlockAttributes } from "./codeblock-utils.js";
|
|
3
3
|
import { remarkGfm } from "./remark-gfm.js";
|
|
4
|
-
import { i as transformerIcon, r as transformerTab } from "../rehype-code.core-
|
|
4
|
+
import { i as transformerIcon, r as transformerTab } from "../rehype-code.core-n_TXY2L8.js";
|
|
5
5
|
import { rehypeCode, rehypeCodeDefaultOptions } from "./rehype-code.js";
|
|
6
6
|
import { remarkImage } from "./remark-image.js";
|
|
7
7
|
import { defaultStringifier, remarkStructure, remarkStructureDefaultOptions, structure } from "./remark-structure.js";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as CodeBlockIcon, i as transformerTab, n as createRehypeCode, o as transformerIcon, r as rehypeCodeDefaultOptions, t as RehypeCodeOptionsCommon } from "../rehype-code.core-
|
|
1
|
+
import { a as CodeBlockIcon, i as transformerTab, n as createRehypeCode, o as transformerIcon, r as rehypeCodeDefaultOptions, t as RehypeCodeOptionsCommon } from "../rehype-code.core-AKfLRGV3.js";
|
|
2
2
|
export { CodeBlockIcon, RehypeCodeOptionsCommon, createRehypeCode, rehypeCodeDefaultOptions, transformerIcon, transformerTab };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as transformerIcon, n as rehypeCodeDefaultOptions, r as transformerTab, t as createRehypeCode } from "../rehype-code.core-
|
|
1
|
+
import { i as transformerIcon, n as rehypeCodeDefaultOptions, r as transformerTab, t as createRehypeCode } from "../rehype-code.core-n_TXY2L8.js";
|
|
2
2
|
export { createRehypeCode, rehypeCodeDefaultOptions, transformerIcon, transformerTab };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as CodeBlockIcon, i as transformerTab, o as transformerIcon } from "../rehype-code.core-
|
|
2
|
-
import { n as rehypeCode, r as rehypeCodeDefaultOptions, t as RehypeCodeOptions } from "../rehype-code-
|
|
1
|
+
import { a as CodeBlockIcon, i as transformerTab, o as transformerIcon } from "../rehype-code.core-AKfLRGV3.js";
|
|
2
|
+
import { n as rehypeCode, r as rehypeCodeDefaultOptions, t as RehypeCodeOptions } from "../rehype-code-RQFGrMHT.js";
|
|
3
3
|
export { CodeBlockIcon, RehypeCodeOptions, rehypeCode, rehypeCodeDefaultOptions, transformerIcon, transformerTab };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defaultShikiFactory, wasmShikiFactory } from "../highlight/shiki/full.js";
|
|
2
|
-
import { i as transformerIcon, n as rehypeCodeDefaultOptions$1, r as transformerTab, t as createRehypeCode } from "../rehype-code.core-
|
|
2
|
+
import { i as transformerIcon, n as rehypeCodeDefaultOptions$1, r as transformerTab, t as createRehypeCode } from "../rehype-code.core-n_TXY2L8.js";
|
|
3
3
|
//#region src/mdx-plugins/rehype-code.ts
|
|
4
4
|
const rehypeCodeDefaultOptions = {
|
|
5
5
|
engine: "js",
|
|
@@ -74,6 +74,14 @@ interface RehypeShikiExtraOptions {
|
|
|
74
74
|
onError?: (error: unknown) => void;
|
|
75
75
|
}
|
|
76
76
|
type RehypeShikiCoreOptions = CodeOptionsThemes<BuiltinTheme> & TransformerOptions & CodeOptionsMeta & RehypeShikiExtraOptions & Omit<CodeToHastOptionsCommon, 'lang'>;
|
|
77
|
+
declare module 'shiki' {
|
|
78
|
+
interface ShikiTransformerContextMeta {
|
|
79
|
+
/** [Fumadocs: rehype-code] run async tasks after process */
|
|
80
|
+
_fd_postprocess?: ((ctx: {
|
|
81
|
+
highlighter: HighlighterCore;
|
|
82
|
+
}) => Promise<void>)[];
|
|
83
|
+
}
|
|
84
|
+
}
|
|
77
85
|
//#endregion
|
|
78
86
|
//#region src/mdx-plugins/transformer-icon.d.ts
|
|
79
87
|
type CodeBlockIcon = {
|
|
@@ -94,9 +102,7 @@ declare function transformerIcon(options?: IconOptions): ShikiTransformer;
|
|
|
94
102
|
declare function rehypeCodeDefaultOptions(): RehypeCodeOptionsCommon;
|
|
95
103
|
type RehypeCodeOptionsCommon = RehypeShikiCoreOptions & {
|
|
96
104
|
/**
|
|
97
|
-
* Language names to include.
|
|
98
|
-
*
|
|
99
|
-
* @default Object.keys(bundledLanguages)
|
|
105
|
+
* Language names to include & preload.
|
|
100
106
|
*/
|
|
101
107
|
langs?: Array<LanguageInput | BuiltinLanguage>;
|
|
102
108
|
/**
|
|
@@ -11,7 +11,7 @@ const InlineCodeParsers = { "tailing-curly-colon": (_tree, node) => {
|
|
|
11
11
|
const match = raw.match(RE_TAILING_CURLY_COLON);
|
|
12
12
|
if (!match) return;
|
|
13
13
|
return {
|
|
14
|
-
|
|
14
|
+
structure: "inline",
|
|
15
15
|
code: match[1] ?? raw,
|
|
16
16
|
lang: match.at(2)
|
|
17
17
|
};
|
|
@@ -23,7 +23,7 @@ const PreParser = (_tree, node) => {
|
|
|
23
23
|
const classes = head.properties.className;
|
|
24
24
|
const languageClass = Array.isArray(classes) ? classes.find((d) => typeof d === "string" && d.startsWith(languagePrefix)) : void 0;
|
|
25
25
|
return {
|
|
26
|
-
|
|
26
|
+
structure: "classic",
|
|
27
27
|
lang: typeof languageClass === "string" ? languageClass.slice(9) : void 0,
|
|
28
28
|
code: flattenNodeHast(head),
|
|
29
29
|
meta: head.data?.meta ?? head.properties.metastring?.toString() ?? ""
|
|
@@ -32,58 +32,58 @@ const PreParser = (_tree, node) => {
|
|
|
32
32
|
//#endregion
|
|
33
33
|
//#region src/mdx-plugins/rehype-code/shiki.ts
|
|
34
34
|
function rehypeShikiFromHighlighter(highlighter, options) {
|
|
35
|
-
const { addLanguageClass = false, parseMetaString, filterMetaString, cache, defaultLanguage, fallbackLanguage, onError, stripEndNewline = true, inline = false, lazy =
|
|
36
|
-
function
|
|
35
|
+
const { addLanguageClass = false, parseMetaString, filterMetaString, cache, defaultLanguage, fallbackLanguage, onError, stripEndNewline = true, inline = false, lazy = true, ...rest } = options;
|
|
36
|
+
function isLanguageLoaded(lang) {
|
|
37
|
+
return isSpecialLang(lang) || highlighter.getLoadedLanguages().includes(lang);
|
|
38
|
+
}
|
|
39
|
+
async function onNode(tree, node, parsed) {
|
|
40
|
+
let { meta: metaString = "", lang = defaultLanguage, code } = parsed;
|
|
41
|
+
if (!lang) return;
|
|
42
|
+
if (!isLanguageLoaded(lang)) {
|
|
43
|
+
if (lazy && lang in highlighter.getBundledLanguages()) await highlighter.loadLanguage(lang);
|
|
44
|
+
else if (fallbackLanguage) {
|
|
45
|
+
lang = fallbackLanguage;
|
|
46
|
+
if (!isLanguageLoaded(fallbackLanguage)) await highlighter.loadLanguage(fallbackLanguage);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
37
49
|
if (filterMetaString) metaString = filterMetaString(metaString);
|
|
38
50
|
const cacheKey = `${lang}:${metaString}:${code}`;
|
|
39
51
|
const cachedValue = cache?.get(cacheKey);
|
|
40
52
|
if (cachedValue) return cachedValue;
|
|
53
|
+
const transformers = rest.transformers ? [...rest.transformers] : [];
|
|
54
|
+
let _fd_postprocess;
|
|
55
|
+
transformers.push({
|
|
56
|
+
enforce: "post",
|
|
57
|
+
root() {
|
|
58
|
+
_fd_postprocess = this.meta._fd_postprocess;
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
if (addLanguageClass) transformers.push(transformerAddLanguage(lang));
|
|
41
62
|
const codeOptions = {
|
|
42
63
|
...rest,
|
|
43
64
|
lang,
|
|
65
|
+
structure: parsed.structure,
|
|
66
|
+
transformers,
|
|
44
67
|
meta: {
|
|
45
68
|
...rest.meta,
|
|
46
69
|
__raw: metaString,
|
|
47
70
|
...parseMetaString?.(metaString, node, tree)
|
|
48
71
|
}
|
|
49
72
|
};
|
|
50
|
-
if (addLanguageClass) codeOptions.transformers = [...codeOptions.transformers ?? [], {
|
|
51
|
-
name: "rehype-shiki:code-language-class",
|
|
52
|
-
code(node) {
|
|
53
|
-
this.addClassToHast(node, `language-${lang}`);
|
|
54
|
-
return node;
|
|
55
|
-
}
|
|
56
|
-
}];
|
|
57
73
|
if (stripEndNewline && code.endsWith("\n")) code = code.slice(0, -1);
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
} catch (error) {
|
|
63
|
-
if (onError) onError(error);
|
|
64
|
-
else throw error;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
function isLanguageLoaded(lang) {
|
|
68
|
-
return isSpecialLang(lang) || highlighter.getLoadedLanguages().includes(lang);
|
|
69
|
-
}
|
|
70
|
-
async function onNode(tree, node, parsed) {
|
|
71
|
-
let lang = parsed.lang ?? defaultLanguage;
|
|
72
|
-
if (!lang) return;
|
|
73
|
-
if (!isLanguageLoaded(lang)) {
|
|
74
|
-
if (lazy && lang in highlighter.getBundledLanguages()) await highlighter.loadLanguage(lang);
|
|
75
|
-
else if (fallbackLanguage) {
|
|
76
|
-
lang = fallbackLanguage;
|
|
77
|
-
if (!isLanguageLoaded(fallbackLanguage)) await highlighter.loadLanguage(fallbackLanguage);
|
|
78
|
-
}
|
|
74
|
+
const fragment = highlighter.codeToHast(code, codeOptions);
|
|
75
|
+
if (_fd_postprocess && _fd_postprocess.length > 0) {
|
|
76
|
+
const ctx = { highlighter };
|
|
77
|
+
await Promise.all(_fd_postprocess.map((v) => v(ctx)));
|
|
79
78
|
}
|
|
80
|
-
|
|
81
|
-
if (
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
79
|
+
cache?.set(cacheKey, fragment);
|
|
80
|
+
if (parsed.structure === "classic") return fragment;
|
|
81
|
+
return {
|
|
82
|
+
type: "element",
|
|
83
|
+
tagName: "code",
|
|
84
|
+
properties: { class: "shiki" },
|
|
85
|
+
children: fragment.children
|
|
86
|
+
};
|
|
87
87
|
}
|
|
88
88
|
return async (tree) => {
|
|
89
89
|
const queue = [];
|
|
@@ -92,6 +92,7 @@ function rehypeShikiFromHighlighter(highlighter, options) {
|
|
|
92
92
|
if (!parent || index == null) return;
|
|
93
93
|
if (node.tagName === "pre") parsed = PreParser(tree, node);
|
|
94
94
|
else if (node.tagName === "code" && inline) parsed = InlineCodeParsers[inline](tree, node);
|
|
95
|
+
else return;
|
|
95
96
|
if (!parsed) return "skip";
|
|
96
97
|
queue.push(onNode(tree, node, parsed).then((fragment) => {
|
|
97
98
|
if (fragment) parent.children[index] = fragment;
|
|
@@ -104,6 +105,15 @@ function rehypeShikiFromHighlighter(highlighter, options) {
|
|
|
104
105
|
if (queue.length > 0) await Promise.all(queue);
|
|
105
106
|
};
|
|
106
107
|
}
|
|
108
|
+
function transformerAddLanguage(lang) {
|
|
109
|
+
return {
|
|
110
|
+
name: "rehype-shiki:code-language-class",
|
|
111
|
+
code(node) {
|
|
112
|
+
this.addClassToHast(node, `language-${lang}`);
|
|
113
|
+
return node;
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
}
|
|
107
117
|
//#endregion
|
|
108
118
|
//#region src/mdx-plugins/transformer-icon.ts
|
|
109
119
|
const defaultShortcuts = {
|
|
@@ -252,7 +262,6 @@ function transformerIcon(options = {}) {
|
|
|
252
262
|
//#region src/mdx-plugins/rehype-code.core.ts
|
|
253
263
|
function rehypeCodeDefaultOptions() {
|
|
254
264
|
return {
|
|
255
|
-
lazy: true,
|
|
256
265
|
...defaultThemes,
|
|
257
266
|
defaultLanguage: "plaintext",
|
|
258
267
|
transformers: [
|
|
@@ -292,13 +301,8 @@ function createRehypeCode(highlighterFactory) {
|
|
|
292
301
|
const transformers = options.transformers ? [...options.transformers] : [];
|
|
293
302
|
if (options.icon !== false) transformers.push(transformerIcon(options.icon));
|
|
294
303
|
if (options.tab !== false) transformers.push(transformerTab());
|
|
295
|
-
const
|
|
296
|
-
|
|
297
|
-
"jsx",
|
|
298
|
-
"ts",
|
|
299
|
-
"tsx"
|
|
300
|
-
] : Object.keys(highlighter.getBundledLanguages()));
|
|
301
|
-
await Promise.all([highlighter.loadTheme(...getRequiredThemes(options)), highlighter.loadLanguage(...langs)]);
|
|
304
|
+
const lazy = options.lazy ?? true;
|
|
305
|
+
await Promise.all([highlighter.loadTheme(...getRequiredThemes(options)), !lazy && highlighter.loadLanguage(...options.langs ?? Object.keys(highlighter.getBundledLanguages()))]);
|
|
302
306
|
return rehypeShikiFromHighlighter(highlighter, {
|
|
303
307
|
...options,
|
|
304
308
|
transformers
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fumadocs-core",
|
|
3
|
-
"version": "16.7.
|
|
3
|
+
"version": "16.7.16",
|
|
4
4
|
"description": "The React.js library for building a documentation website",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Docs",
|
|
@@ -110,12 +110,12 @@
|
|
|
110
110
|
"vfile": "^6.0.3"
|
|
111
111
|
},
|
|
112
112
|
"devDependencies": {
|
|
113
|
-
"@formatjs/intl-localematcher": "^0.8.
|
|
113
|
+
"@formatjs/intl-localematcher": "^0.8.3",
|
|
114
114
|
"@mdx-js/mdx": "^3.1.1",
|
|
115
115
|
"@mixedbread/sdk": "^0.61.0",
|
|
116
116
|
"@orama/core": "^1.2.19",
|
|
117
117
|
"@oramacloud/client": "^2.1.4",
|
|
118
|
-
"@tanstack/react-router": "1.168.
|
|
118
|
+
"@tanstack/react-router": "1.168.22",
|
|
119
119
|
"@types/estree-jsx": "^1.0.5",
|
|
120
120
|
"@types/hast": "^3.0.4",
|
|
121
121
|
"@types/mdast": "^4.0.4",
|
|
@@ -123,7 +123,7 @@
|
|
|
123
123
|
"@types/node": "25.6.0",
|
|
124
124
|
"@types/react": "^19.2.14",
|
|
125
125
|
"@types/react-dom": "^19.2.3",
|
|
126
|
-
"algoliasearch": "5.50.
|
|
126
|
+
"algoliasearch": "5.50.2",
|
|
127
127
|
"flexsearch": "^0.8.212",
|
|
128
128
|
"image-size": "^2.0.2",
|
|
129
129
|
"lucide-react": "^1.8.0",
|
|
@@ -131,11 +131,11 @@
|
|
|
131
131
|
"next": "16.2.3",
|
|
132
132
|
"npm-to-yarn": "^3.0.1",
|
|
133
133
|
"path-to-regexp": "^8.4.2",
|
|
134
|
-
"react-router": "^7.14.
|
|
134
|
+
"react-router": "^7.14.1",
|
|
135
135
|
"remark-directive": "^4.0.0",
|
|
136
136
|
"remark-mdx": "^3.1.1",
|
|
137
137
|
"remove-markdown": "^0.6.3",
|
|
138
|
-
"tsdown": "0.21.
|
|
138
|
+
"tsdown": "0.21.8",
|
|
139
139
|
"typescript": "^6.0.2",
|
|
140
140
|
"waku": "1.0.0-alpha.7",
|
|
141
141
|
"zod": "^4.3.6",
|
|
@@ -218,8 +218,8 @@
|
|
|
218
218
|
}
|
|
219
219
|
},
|
|
220
220
|
"inlinedDependencies": {
|
|
221
|
-
"@formatjs/fast-memoize": "3.1.
|
|
222
|
-
"@formatjs/intl-localematcher": "0.8.
|
|
221
|
+
"@formatjs/fast-memoize": "3.1.2",
|
|
222
|
+
"@formatjs/intl-localematcher": "0.8.3",
|
|
223
223
|
"image-size": "2.0.2",
|
|
224
224
|
"negotiator": "1.0.0",
|
|
225
225
|
"npm-to-yarn": "3.0.1",
|