fumadocs-core 15.2.14 → 15.3.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/chunk-EP5LHGDZ.js +22 -0
- package/dist/{chunk-SRVMHXJD.js → chunk-KNWSJ4IF.js} +0 -15
- package/dist/highlight/client.js +1 -1
- package/dist/highlight/index.d.ts +2 -3
- package/dist/highlight/index.js +1 -3
- package/dist/mdx-plugins/index.d.ts +1 -1
- package/dist/mdx-plugins/index.js +21 -17
- package/dist/{remark-structure-FIjTA11P.d.ts → remark-structure-DVje0Sib.d.ts} +8 -2
- package/dist/search/algolia.d.ts +1 -1
- package/dist/search/client.d.ts +1 -1
- package/dist/search/orama-cloud.d.ts +1 -1
- package/dist/search/server.d.ts +1 -1
- package/dist/sidebar.js +7 -17
- package/dist/utils/use-media-query.d.ts +3 -0
- package/dist/utils/use-media-query.js +7 -0
- package/package.json +6 -6
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// src/utils/use-media-query.ts
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
function useMediaQuery(query, disabled = false) {
|
|
4
|
+
const [isMatch, setMatch] = useState(null);
|
|
5
|
+
useEffect(() => {
|
|
6
|
+
if (disabled) return;
|
|
7
|
+
const mediaQueryList = window.matchMedia(query);
|
|
8
|
+
const handleChange = () => {
|
|
9
|
+
setMatch(mediaQueryList.matches);
|
|
10
|
+
};
|
|
11
|
+
handleChange();
|
|
12
|
+
mediaQueryList.addEventListener("change", handleChange);
|
|
13
|
+
return () => {
|
|
14
|
+
mediaQueryList.removeEventListener("change", handleChange);
|
|
15
|
+
};
|
|
16
|
+
}, [disabled, query]);
|
|
17
|
+
return isMatch;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export {
|
|
21
|
+
useMediaQuery
|
|
22
|
+
};
|
|
@@ -2,19 +2,6 @@
|
|
|
2
2
|
import { toJsxRuntime } from "hast-util-to-jsx-runtime";
|
|
3
3
|
import { Fragment } from "react";
|
|
4
4
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
-
function createStyleTransformer() {
|
|
6
|
-
return {
|
|
7
|
-
name: "rehype-code:styles",
|
|
8
|
-
line(hast) {
|
|
9
|
-
if (hast.children.length === 0) {
|
|
10
|
-
hast.children.push({
|
|
11
|
-
type: "text",
|
|
12
|
-
value: " "
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
5
|
var defaultThemes = {
|
|
19
6
|
light: "github-light",
|
|
20
7
|
dark: "github-dark"
|
|
@@ -37,7 +24,6 @@ async function _highlight(code, options) {
|
|
|
37
24
|
lang,
|
|
38
25
|
...rest,
|
|
39
26
|
...themes,
|
|
40
|
-
transformers: [createStyleTransformer(), ...rest.transformers ?? []],
|
|
41
27
|
defaultColor: "themes" in themes ? false : void 0
|
|
42
28
|
});
|
|
43
29
|
}
|
|
@@ -88,7 +74,6 @@ async function highlight(code, options) {
|
|
|
88
74
|
}
|
|
89
75
|
|
|
90
76
|
export {
|
|
91
|
-
createStyleTransformer,
|
|
92
77
|
defaultThemes,
|
|
93
78
|
_highlight,
|
|
94
79
|
_renderHighlight,
|
package/dist/highlight/client.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { CodeToHastOptionsCommon, BundledLanguage, CodeOptionsMeta, Awaitable, RegexEngine, CodeOptionsThemes,
|
|
1
|
+
import { CodeToHastOptionsCommon, BundledLanguage, CodeOptionsMeta, Awaitable, RegexEngine, CodeOptionsThemes, BundledHighlighterOptions, Highlighter } from 'shiki';
|
|
2
2
|
import { BundledTheme } from 'shiki/themes';
|
|
3
3
|
import { Components } from 'hast-util-to-jsx-runtime';
|
|
4
4
|
import { ReactNode } from 'react';
|
|
5
5
|
|
|
6
|
-
declare function createStyleTransformer(): ShikiTransformer;
|
|
7
6
|
type HighlightOptionsCommon = CodeToHastOptionsCommon<BundledLanguage> & CodeOptionsMeta & {
|
|
8
7
|
engine?: Awaitable<RegexEngine>;
|
|
9
8
|
components?: Partial<Components>;
|
|
@@ -19,4 +18,4 @@ type HighlightOptions = HighlightOptionsCommon & (HighlightOptionsThemes | Recor
|
|
|
19
18
|
declare function getHighlighter(engineType: 'js' | 'oniguruma' | 'custom', options: BundledHighlighterOptions<BundledLanguage, BundledTheme>): Promise<Highlighter>;
|
|
20
19
|
declare function highlight(code: string, options: HighlightOptions): Promise<ReactNode>;
|
|
21
20
|
|
|
22
|
-
export { type HighlightOptions, type HighlightOptionsCommon, type HighlightOptionsThemes,
|
|
21
|
+
export { type HighlightOptions, type HighlightOptionsCommon, type HighlightOptionsThemes, getHighlighter, highlight };
|
package/dist/highlight/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import { RehypeShikiOptions } from '@shikijs/rehype';
|
|
|
4
4
|
import { Processor, Transformer } from 'unified';
|
|
5
5
|
import { ShikiTransformer } from 'shiki';
|
|
6
6
|
import { Root as Root$1 } from 'mdast';
|
|
7
|
-
export { a as StructureOptions, S as StructuredData, r as remarkStructure, s as structure } from '../remark-structure-
|
|
7
|
+
export { a as StructureOptions, S as StructuredData, r as remarkStructure, s as structure } from '../remark-structure-DVje0Sib.js';
|
|
8
8
|
export { R as RemarkHeadingOptions, r as remarkHeading } from '../remark-heading-BPCoYwjn.js';
|
|
9
9
|
import 'mdast-util-mdx-jsx';
|
|
10
10
|
|
|
@@ -7,10 +7,9 @@ import {
|
|
|
7
7
|
slash
|
|
8
8
|
} from "../chunk-XMCPKVJQ.js";
|
|
9
9
|
import {
|
|
10
|
-
createStyleTransformer,
|
|
11
10
|
defaultThemes,
|
|
12
11
|
getHighlighter
|
|
13
|
-
} from "../chunk-
|
|
12
|
+
} from "../chunk-KNWSJ4IF.js";
|
|
14
13
|
import "../chunk-MLKGABMK.js";
|
|
15
14
|
|
|
16
15
|
// src/mdx-plugins/index.ts
|
|
@@ -194,7 +193,6 @@ var rehypeCodeDefaultOptions = {
|
|
|
194
193
|
defaultLanguage: "plaintext",
|
|
195
194
|
experimentalJSEngine: false,
|
|
196
195
|
transformers: [
|
|
197
|
-
createStyleTransformer(),
|
|
198
196
|
transformerNotationHighlight({
|
|
199
197
|
matchAlgorithm: "v3"
|
|
200
198
|
}),
|
|
@@ -247,7 +245,7 @@ function rehypeCode(_options = {}) {
|
|
|
247
245
|
options.experimentalJSEngine ? "js" : "oniguruma",
|
|
248
246
|
{
|
|
249
247
|
themes: "themes" in options ? Object.values(options.themes).filter(Boolean) : [options.theme],
|
|
250
|
-
langs: options.langs ?? (options.lazy ? [] : Object.keys(bundledLanguages))
|
|
248
|
+
langs: options.langs ?? (options.lazy ? ["ts", "tsx"] : Object.keys(bundledLanguages))
|
|
251
249
|
}
|
|
252
250
|
);
|
|
253
251
|
const transformer = highlighter.then(
|
|
@@ -345,10 +343,12 @@ function remarkImage({
|
|
|
345
343
|
]
|
|
346
344
|
});
|
|
347
345
|
}).catch((e) => {
|
|
348
|
-
|
|
349
|
-
`[Remark Image] Failed obtain image size for ${url}
|
|
346
|
+
throw new Error(
|
|
347
|
+
`[Remark Image] Failed obtain image size for ${url} (public directory configured as ${publicDir})`,
|
|
348
|
+
{
|
|
349
|
+
cause: e
|
|
350
|
+
}
|
|
350
351
|
);
|
|
351
|
-
throw e;
|
|
352
352
|
});
|
|
353
353
|
promises.push(task);
|
|
354
354
|
} else if (!isExternal) {
|
|
@@ -432,8 +432,13 @@ async function getImageSize(src, dir) {
|
|
|
432
432
|
} else {
|
|
433
433
|
return imageSizeFromFile(isRelative ? path.join(dir, src) : src);
|
|
434
434
|
}
|
|
435
|
-
const
|
|
436
|
-
|
|
435
|
+
const res = await fetch(url);
|
|
436
|
+
if (!res.ok) {
|
|
437
|
+
throw new Error(
|
|
438
|
+
`[Remark Image] Failed to fetch ${url} (${res.status}): ${await res.text()}`
|
|
439
|
+
);
|
|
440
|
+
}
|
|
441
|
+
return imageSize(new Uint8Array(await res.arrayBuffer()));
|
|
437
442
|
}
|
|
438
443
|
|
|
439
444
|
// src/mdx-plugins/remark-structure.ts
|
|
@@ -450,7 +455,10 @@ function remarkStructure({
|
|
|
450
455
|
"tableCell",
|
|
451
456
|
"mdxJsxFlowElement"
|
|
452
457
|
],
|
|
453
|
-
allowedMdxAttributes = () =>
|
|
458
|
+
allowedMdxAttributes = (node) => {
|
|
459
|
+
if (!node.name) return false;
|
|
460
|
+
return ["TypeTable", "Callout"].includes(node.name);
|
|
461
|
+
}
|
|
454
462
|
} = {}) {
|
|
455
463
|
if (Array.isArray(allowedMdxAttributes)) {
|
|
456
464
|
const arr = allowedMdxAttributes;
|
|
@@ -498,18 +506,14 @@ function remarkStructure({
|
|
|
498
506
|
}
|
|
499
507
|
if (element.type === "mdxJsxFlowElement" && element.name) {
|
|
500
508
|
data.contents.push(
|
|
501
|
-
{
|
|
502
|
-
heading: lastHeading,
|
|
503
|
-
content: element.name
|
|
504
|
-
},
|
|
505
509
|
...element.attributes.flatMap((attribute) => {
|
|
506
|
-
const
|
|
507
|
-
if (!
|
|
510
|
+
const value = typeof attribute.value === "string" ? attribute.value : attribute.value?.value;
|
|
511
|
+
if (!value || value.length === 0) return [];
|
|
508
512
|
if (allowedMdxAttributes && !allowedMdxAttributes(element, attribute))
|
|
509
513
|
return [];
|
|
510
514
|
return {
|
|
511
515
|
heading: lastHeading,
|
|
512
|
-
content: attribute.type === "mdxJsxAttribute" ? `${attribute.name}: ${
|
|
516
|
+
content: attribute.type === "mdxJsxAttribute" ? `${attribute.name}: ${value}` : value
|
|
513
517
|
};
|
|
514
518
|
})
|
|
515
519
|
);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Nodes, Root } from 'mdast';
|
|
2
2
|
import { Transformer, PluggableList } from 'unified';
|
|
3
|
-
import { MdxJsxAttribute, MdxJsxExpressionAttribute } from 'mdast-util-mdx-jsx';
|
|
3
|
+
import { MdxJsxFlowElement, MdxJsxAttribute, MdxJsxExpressionAttribute } from 'mdast-util-mdx-jsx';
|
|
4
4
|
|
|
5
5
|
interface Heading {
|
|
6
6
|
id: string;
|
|
@@ -24,7 +24,13 @@ interface StructureOptions {
|
|
|
24
24
|
* @defaultValue ['heading', 'paragraph', 'blockquote', 'tableCell', 'mdxJsxFlowElement']
|
|
25
25
|
*/
|
|
26
26
|
types?: string[] | ((node: Nodes) => boolean);
|
|
27
|
-
|
|
27
|
+
/**
|
|
28
|
+
* A list of indexable MDX attributes, either:
|
|
29
|
+
*
|
|
30
|
+
* - an array of attribute names.
|
|
31
|
+
* - a function that determines if attribute should be indexed.
|
|
32
|
+
*/
|
|
33
|
+
allowedMdxAttributes?: string[] | ((node: MdxJsxFlowElement, attribute: MdxJsxAttribute | MdxJsxExpressionAttribute) => boolean);
|
|
28
34
|
}
|
|
29
35
|
declare module 'mdast' {
|
|
30
36
|
interface Data {
|
package/dist/search/algolia.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SearchClient, SearchIndex } from 'algoliasearch';
|
|
2
|
-
import { S as StructuredData } from '../remark-structure-
|
|
2
|
+
import { S as StructuredData } from '../remark-structure-DVje0Sib.js';
|
|
3
3
|
import 'mdast';
|
|
4
4
|
import 'unified';
|
|
5
5
|
import 'mdast-util-mdx-jsx';
|
package/dist/search/client.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { S as SortedResult } from '../types-Ch8gnVgO.js';
|
|
|
2
2
|
import { AnyOrama } from '@orama/orama';
|
|
3
3
|
import { SearchOptions } from '@algolia/client-search';
|
|
4
4
|
import { SearchIndex } from 'algoliasearch/lite';
|
|
5
|
-
import '../remark-structure-
|
|
5
|
+
import '../remark-structure-DVje0Sib.js';
|
|
6
6
|
import { OramaClient, ClientSearchParams } from '@oramacloud/client';
|
|
7
7
|
import 'mdast';
|
|
8
8
|
import 'unified';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CloudManager } from '@oramacloud/client';
|
|
2
|
-
import { S as StructuredData } from '../remark-structure-
|
|
2
|
+
import { S as StructuredData } from '../remark-structure-DVje0Sib.js';
|
|
3
3
|
import '../remark-heading-BPCoYwjn.js';
|
|
4
4
|
import 'mdast';
|
|
5
5
|
import 'unified';
|
package/dist/search/server.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TypedDocument, Orama, Language, RawData, create, SearchParams } from '@orama/orama';
|
|
2
|
-
import { S as StructuredData } from '../remark-structure-
|
|
2
|
+
import { S as StructuredData } from '../remark-structure-DVje0Sib.js';
|
|
3
3
|
import { S as SortedResult } from '../types-Ch8gnVgO.js';
|
|
4
4
|
import { I as I18nConfig } from '../config-Cm58P4fz.js';
|
|
5
5
|
import { LoaderOutput, LoaderConfig, InferPageType } from '../source/index.js';
|
package/dist/sidebar.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import {
|
|
3
|
+
useMediaQuery
|
|
4
|
+
} from "./chunk-EP5LHGDZ.js";
|
|
2
5
|
import "./chunk-MLKGABMK.js";
|
|
3
6
|
|
|
4
7
|
// src/sidebar.tsx
|
|
5
8
|
import {
|
|
6
9
|
createContext,
|
|
7
10
|
useContext,
|
|
8
|
-
|
|
9
|
-
useState
|
|
10
|
-
useMemo
|
|
11
|
+
useMemo,
|
|
12
|
+
useState
|
|
11
13
|
} from "react";
|
|
12
14
|
import { RemoveScroll } from "react-remove-scroll";
|
|
13
15
|
import { jsx } from "react/jsx-runtime";
|
|
@@ -58,25 +60,13 @@ function SidebarList({
|
|
|
58
60
|
...props
|
|
59
61
|
}) {
|
|
60
62
|
const { open } = useSidebarContext();
|
|
61
|
-
const
|
|
62
|
-
useEffect(() => {
|
|
63
|
-
if (!removeScrollOn) return;
|
|
64
|
-
const mediaQueryList = window.matchMedia(removeScrollOn);
|
|
65
|
-
const handleChange = () => {
|
|
66
|
-
setIsBlocking(mediaQueryList.matches);
|
|
67
|
-
};
|
|
68
|
-
handleChange();
|
|
69
|
-
mediaQueryList.addEventListener("change", handleChange);
|
|
70
|
-
return () => {
|
|
71
|
-
mediaQueryList.removeEventListener("change", handleChange);
|
|
72
|
-
};
|
|
73
|
-
}, [removeScrollOn]);
|
|
63
|
+
const isBlocking = useMediaQuery(removeScrollOn ?? "", !removeScrollOn) ?? false;
|
|
74
64
|
return /* @__PURE__ */ jsx(
|
|
75
65
|
RemoveScroll,
|
|
76
66
|
{
|
|
77
67
|
as: as ?? "aside",
|
|
78
68
|
"data-open": open,
|
|
79
|
-
enabled:
|
|
69
|
+
enabled: isBlocking && open,
|
|
80
70
|
...props,
|
|
81
71
|
children: props.children
|
|
82
72
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fumadocs-core",
|
|
3
|
-
"version": "15.
|
|
3
|
+
"version": "15.3.0",
|
|
4
4
|
"description": "The library for building a documentation website in Next.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"NextJs",
|
|
@@ -79,8 +79,8 @@
|
|
|
79
79
|
"dependencies": {
|
|
80
80
|
"@formatjs/intl-localematcher": "^0.6.1",
|
|
81
81
|
"@orama/orama": "^3.1.6",
|
|
82
|
-
"@shikijs/rehype": "^3.
|
|
83
|
-
"@shikijs/transformers": "^3.
|
|
82
|
+
"@shikijs/rehype": "^3.4.0",
|
|
83
|
+
"@shikijs/transformers": "^3.4.0",
|
|
84
84
|
"github-slugger": "^2.0.0",
|
|
85
85
|
"hast-util-to-estree": "^3.1.3",
|
|
86
86
|
"hast-util-to-jsx-runtime": "^2.3.6",
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
"remark": "^15.0.0",
|
|
91
91
|
"remark-gfm": "^4.0.1",
|
|
92
92
|
"scroll-into-view-if-needed": "^3.1.0",
|
|
93
|
-
"shiki": "^3.
|
|
93
|
+
"shiki": "^3.4.0",
|
|
94
94
|
"unist-util-visit": "^5.0.0"
|
|
95
95
|
},
|
|
96
96
|
"devDependencies": {
|
|
@@ -102,8 +102,8 @@
|
|
|
102
102
|
"@types/hast": "^3.0.4",
|
|
103
103
|
"@types/mdast": "^4.0.3",
|
|
104
104
|
"@types/negotiator": "^0.6.3",
|
|
105
|
-
"@types/node": "22.15.
|
|
106
|
-
"@types/react": "^19.1.
|
|
105
|
+
"@types/node": "22.15.12",
|
|
106
|
+
"@types/react": "^19.1.3",
|
|
107
107
|
"@types/react-dom": "^19.1.3",
|
|
108
108
|
"algoliasearch": "4.24.0",
|
|
109
109
|
"mdast-util-mdx-jsx": "^3.2.0",
|