fumadocs-core 15.0.7 → 15.0.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.
|
@@ -19,23 +19,21 @@ var defaultThemes = {
|
|
|
19
19
|
light: "github-light",
|
|
20
20
|
dark: "github-dark"
|
|
21
21
|
};
|
|
22
|
+
var defaultEngine;
|
|
22
23
|
async function _highlight(code, options) {
|
|
23
24
|
const { getSingletonHighlighter } = await import("shiki");
|
|
24
|
-
const { lang, components: _, engine
|
|
25
|
+
const { lang, components: _, engine, ...rest } = options;
|
|
25
26
|
let themes = { themes: defaultThemes };
|
|
26
27
|
if ("theme" in options && options.theme) {
|
|
27
28
|
themes = { theme: options.theme };
|
|
28
29
|
} else if ("themes" in options && options.themes) {
|
|
29
30
|
themes = { themes: options.themes };
|
|
30
31
|
}
|
|
31
|
-
let engine = defaultEngine;
|
|
32
|
-
if (!engine) {
|
|
33
|
-
const { createOnigurumaEngine } = await import("shiki/engine/oniguruma");
|
|
34
|
-
engine = await createOnigurumaEngine(await import("shiki/wasm"));
|
|
35
|
-
}
|
|
36
32
|
const highlighter = await getSingletonHighlighter({
|
|
37
33
|
langs: [lang],
|
|
38
|
-
engine
|
|
34
|
+
engine: engine ?? (defaultEngine ??= await import("shiki/engine/oniguruma").then(
|
|
35
|
+
(res) => res.createOnigurumaEngine(import("shiki/wasm"))
|
|
36
|
+
)),
|
|
39
37
|
themes: "theme" in themes ? [themes.theme] : Object.values(themes.themes).filter((v) => v !== void 0)
|
|
40
38
|
});
|
|
41
39
|
return highlighter.codeToHast(code, {
|
package/dist/server/index.js
CHANGED
package/dist/utils/use-shiki.js
CHANGED
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
_highlight,
|
|
4
4
|
_renderHighlight,
|
|
5
5
|
highlight
|
|
6
|
-
} from "../chunk-
|
|
6
|
+
} from "../chunk-SCQ5QN2V.js";
|
|
7
7
|
import "../chunk-MLKGABMK.js";
|
|
8
8
|
|
|
9
9
|
// src/utils/use-shiki.tsx
|
|
@@ -28,7 +28,6 @@ function getHighlightOptions(from) {
|
|
|
28
28
|
engine: jsEngine
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
|
-
var cache = /* @__PURE__ */ new Map();
|
|
32
31
|
function useShiki(code, {
|
|
33
32
|
defaultValue,
|
|
34
33
|
scriptKey,
|
|
@@ -45,13 +44,9 @@ function useShiki(code, {
|
|
|
45
44
|
});
|
|
46
45
|
const [rendered, setRendered] = useState(() => {
|
|
47
46
|
if (defaultValue) return defaultValue;
|
|
48
|
-
const cached = cache.get(key);
|
|
49
|
-
if (cached) return cached;
|
|
50
47
|
const hast = globalThis._use_shiki?.get(scriptKey);
|
|
51
48
|
if (hast) {
|
|
52
|
-
|
|
53
|
-
cache.set(key, node);
|
|
54
|
-
return node;
|
|
49
|
+
return _renderHighlight(hast, shikiOptions);
|
|
55
50
|
}
|
|
56
51
|
currentTask.current = void 0;
|
|
57
52
|
const Pre = options.components?.pre ?? "pre";
|
|
@@ -71,7 +66,6 @@ function useShiki(code, {
|
|
|
71
66
|
};
|
|
72
67
|
currentTask.current = task;
|
|
73
68
|
highlight(code, shikiOptions).then((result) => {
|
|
74
|
-
cache.set(key, result);
|
|
75
69
|
if (!task.aborted) setRendered(result);
|
|
76
70
|
});
|
|
77
71
|
}
|