fumadocs-core 15.6.6 → 15.6.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.
@@ -0,0 +1,8 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { ReactNode } from 'react';
3
+
4
+ declare function WakuProvider({ children }: {
5
+ children: ReactNode;
6
+ }): react_jsx_runtime.JSX.Element;
7
+
8
+ export { WakuProvider };
@@ -0,0 +1,51 @@
1
+ "use client";
2
+ import {
3
+ FrameworkProvider
4
+ } from "../chunk-BBP7MIO4.js";
5
+ import "../chunk-JSBRDJBE.js";
6
+
7
+ // src/framework/waku.tsx
8
+ import { useMemo } from "react";
9
+ import { Link as WakuLink, useRouter } from "waku";
10
+ import { jsx } from "react/jsx-runtime";
11
+ var framework = {
12
+ usePathname() {
13
+ const { path } = useRouter();
14
+ return path;
15
+ },
16
+ useParams() {
17
+ const { query } = useRouter();
18
+ return useMemo(() => {
19
+ const params = new URLSearchParams(query);
20
+ return Object.fromEntries(
21
+ Array.from(params.entries()).map(([key, value]) => [
22
+ key,
23
+ Array.isArray(value) ? value[0] : value
24
+ ])
25
+ );
26
+ }, [query]);
27
+ },
28
+ useRouter() {
29
+ const router = useRouter();
30
+ return useMemo(
31
+ () => ({
32
+ push(url) {
33
+ void router.push(url);
34
+ },
35
+ refresh() {
36
+ void router.push(router.path);
37
+ }
38
+ }),
39
+ [router]
40
+ );
41
+ },
42
+ Link({ href, prefetch: _prefetch, ...props }) {
43
+ return /* @__PURE__ */ jsx(WakuLink, { to: href, ...props, children: props.children });
44
+ }
45
+ };
46
+ function WakuProvider({ children }) {
47
+ return /* @__PURE__ */ jsx(FrameworkProvider, { ...framework, children });
48
+ }
49
+ export {
50
+ WakuProvider
51
+ };
@@ -1,14 +1,18 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { ReactNode } from 'react';
2
+ import { ReactNode, HTMLAttributes, FC } from 'react';
3
3
 
4
+ declare function HideIfEmptyProvider({ nonce, children, }: {
5
+ nonce?: string;
6
+ children: ReactNode;
7
+ }): react_jsx_runtime.JSX.Element;
4
8
  /**
5
9
  * The built-in CSS `:empty` selector cannot detect if the children is hidden, classes such as `md:hidden` causes it to fail.
6
10
  * This component is an enhancement to `empty:hidden` to fix the issue described above.
7
11
  *
8
12
  * This can be expensive, please avoid this whenever possible.
9
13
  */
10
- declare function HideIfEmpty({ children }: {
11
- children: ReactNode;
14
+ declare function HideIfEmpty<Props extends HTMLAttributes<HTMLElement>>({ as: Comp, ...props }: Props & {
15
+ as: FC<Props>;
12
16
  }): react_jsx_runtime.JSX.Element;
13
17
 
14
- export { HideIfEmpty };
18
+ export { HideIfEmpty, HideIfEmptyProvider };
@@ -2,9 +2,28 @@
2
2
  import "./chunk-JSBRDJBE.js";
3
3
 
4
4
  // src/hide-if-empty.tsx
5
- import React from "react";
5
+ import {
6
+ createContext,
7
+ useContext,
8
+ useEffect,
9
+ useId,
10
+ useMemo,
11
+ useState
12
+ } from "react";
6
13
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
7
- var isEmpty = (node) => {
14
+ var Context = createContext({
15
+ nonce: void 0
16
+ });
17
+ function HideIfEmptyProvider({
18
+ nonce,
19
+ children
20
+ }) {
21
+ return /* @__PURE__ */ jsx(Context.Provider, { value: useMemo(() => ({ nonce }), [nonce]), children });
22
+ }
23
+ function getElement(id) {
24
+ return document.querySelector(`[data-fd-if-empty="${id}"]`);
25
+ }
26
+ function isEmpty(node) {
8
27
  for (let i = 0; i < node.childNodes.length; i++) {
9
28
  const child = node.childNodes.item(i);
10
29
  if (child.nodeType === Node.TEXT_NODE || child.nodeType === Node.ELEMENT_NODE && window.getComputedStyle(child).display !== "none") {
@@ -12,53 +31,52 @@ var isEmpty = (node) => {
12
31
  }
13
32
  }
14
33
  return true;
15
- };
16
- function HideIfEmpty({ children }) {
17
- const id = React.useId();
18
- const [empty, setEmpty] = React.useState();
19
- React.useEffect(() => {
20
- const element = document.querySelector(
21
- `[data-fdid="${id}"]`
22
- );
23
- if (!element) return;
24
- const onUpdate = () => {
25
- setEmpty(isEmpty(element));
26
- };
27
- const observer = new ResizeObserver(onUpdate);
28
- observer.observe(element);
29
- onUpdate();
30
- return () => {
31
- observer.disconnect();
34
+ }
35
+ function HideIfEmpty({
36
+ as: Comp,
37
+ ...props
38
+ }) {
39
+ const id = useId();
40
+ const { nonce } = useContext(Context);
41
+ const [empty, setEmpty] = useState(() => {
42
+ const element = typeof window !== "undefined" ? getElement(id) : null;
43
+ if (element) return isEmpty(element);
44
+ });
45
+ useEffect(() => {
46
+ const handleResize = () => {
47
+ const element = getElement(id);
48
+ if (element) setEmpty(isEmpty(element));
32
49
  };
50
+ window.addEventListener("resize", handleResize);
51
+ return () => window.removeEventListener("resize", handleResize);
33
52
  }, [id]);
34
- let child;
35
- if (React.isValidElement(children)) {
36
- child = React.cloneElement(children, {
37
- ...children.props,
38
- "data-fdid": id,
39
- "data-empty": empty,
40
- suppressHydrationWarning: true
41
- });
42
- } else {
43
- child = React.Children.count(children) > 1 ? React.Children.only(null) : null;
44
- }
53
+ const init = (id2) => {
54
+ const element = getElement(id2);
55
+ if (element) element.hidden = isEmpty(element);
56
+ const script = document.currentScript;
57
+ if (script) script.parentNode?.removeChild(script);
58
+ };
45
59
  return /* @__PURE__ */ jsxs(Fragment, { children: [
46
- child,
60
+ /* @__PURE__ */ jsx(
61
+ Comp,
62
+ {
63
+ ...props,
64
+ "data-fd-if-empty": id,
65
+ hidden: empty ?? false
66
+ }
67
+ ),
47
68
  empty === void 0 && /* @__PURE__ */ jsx(
48
69
  "script",
49
70
  {
50
- suppressHydrationWarning: true,
71
+ nonce,
51
72
  dangerouslySetInnerHTML: {
52
- __html: `{
53
- const element = document.querySelector('[data-fdid="${id}"]')
54
- if (element) {
55
- element.setAttribute('data-empty', String((${isEmpty.toString()})(element)))
56
- }}`
73
+ __html: `{${getElement};${isEmpty};(${init})("${id}")}`
57
74
  }
58
75
  }
59
76
  )
60
77
  ] });
61
78
  }
62
79
  export {
63
- HideIfEmpty
80
+ HideIfEmpty,
81
+ HideIfEmptyProvider
64
82
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fumadocs-core",
3
- "version": "15.6.6",
3
+ "version": "15.6.8",
4
4
  "description": "The library for building a documentation website in Next.js",
5
5
  "keywords": [
6
6
  "NextJs",
@@ -87,8 +87,8 @@
87
87
  "dependencies": {
88
88
  "@formatjs/intl-localematcher": "^0.6.1",
89
89
  "@orama/orama": "^3.1.11",
90
- "@shikijs/rehype": "^3.8.1",
91
- "@shikijs/transformers": "^3.8.1",
90
+ "@shikijs/rehype": "^3.9.1",
91
+ "@shikijs/transformers": "^3.9.1",
92
92
  "github-slugger": "^2.0.0",
93
93
  "hast-util-to-estree": "^3.1.3",
94
94
  "hast-util-to-jsx-runtime": "^2.3.6",
@@ -100,42 +100,46 @@
100
100
  "remark-gfm": "^4.0.1",
101
101
  "remark-rehype": "^11.1.2",
102
102
  "scroll-into-view-if-needed": "^3.1.0",
103
- "shiki": "^3.8.1",
103
+ "shiki": "^3.9.1",
104
104
  "unist-util-visit": "^5.0.0"
105
105
  },
106
106
  "devDependencies": {
107
107
  "@mdx-js/mdx": "^3.1.0",
108
108
  "@mixedbread/sdk": "^0.19.0",
109
109
  "@oramacloud/client": "^2.1.4",
110
- "@tanstack/react-router": "^1.129.0",
110
+ "@tanstack/react-router": "^1.130.12",
111
111
  "@types/estree-jsx": "^1.0.5",
112
112
  "@types/hast": "^3.0.4",
113
113
  "@types/mdast": "^4.0.3",
114
114
  "@types/negotiator": "^0.6.4",
115
115
  "@types/node": "24.1.0",
116
- "@types/react": "^19.1.8",
117
- "@types/react-dom": "^19.1.6",
118
- "algoliasearch": "5.34.1",
116
+ "@types/react": "^19.1.9",
117
+ "@types/react-dom": "^19.1.7",
118
+ "algoliasearch": "5.35.0",
119
119
  "mdast-util-mdx-jsx": "^3.2.0",
120
120
  "mdast-util-mdxjs-esm": "^2.0.1",
121
- "next": "^15.4.4",
121
+ "next": "^15.4.5",
122
122
  "react-router": "^7.7.1",
123
123
  "remark-mdx": "^3.1.0",
124
124
  "remove-markdown": "^0.6.2",
125
- "typescript": "^5.8.3",
125
+ "typescript": "^5.9.2",
126
126
  "unified": "^11.0.5",
127
127
  "vfile": "^6.0.3",
128
+ "waku": "^0.23.7",
128
129
  "eslint-config-custom": "0.0.0",
129
130
  "tsconfig": "0.0.0"
130
131
  },
131
132
  "peerDependencies": {
132
133
  "@mixedbread/sdk": "^0.19.0",
133
134
  "@oramacloud/client": "1.x.x || 2.x.x",
135
+ "@tanstack/react-router": "1.x.x",
134
136
  "@types/react": "*",
135
137
  "algoliasearch": "5.x.x",
136
138
  "next": "14.x.x || 15.x.x",
137
139
  "react": "18.x.x || 19.x.x",
138
- "react-dom": "18.x.x || 19.x.x"
140
+ "react-dom": "18.x.x || 19.x.x",
141
+ "react-router": "7.x.x",
142
+ "waku": "^0.23.0"
139
143
  },
140
144
  "peerDependenciesMeta": {
141
145
  "@mixedbread/sdk": {
@@ -158,6 +162,15 @@
158
162
  },
159
163
  "react-dom": {
160
164
  "optional": true
165
+ },
166
+ "waku": {
167
+ "optional": true
168
+ },
169
+ "@tanstack/react-router": {
170
+ "optional": true
171
+ },
172
+ "react-router": {
173
+ "optional": true
161
174
  }
162
175
  },
163
176
  "publishConfig": {