fumadocs-core 15.0.14 → 15.0.15

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.
@@ -4,6 +4,13 @@ function isDifferent(a, b) {
4
4
  if (Array.isArray(a) && Array.isArray(b)) {
5
5
  return b.length !== a.length || a.some((v, i) => isDifferent(v, b[i]));
6
6
  }
7
+ if (typeof a === "object" && a && typeof b === "object" && b) {
8
+ const aKeys = Object.keys(a);
9
+ const bKeys = Object.keys(b);
10
+ return aKeys.length !== bKeys.length || aKeys.some(
11
+ (key) => isDifferent(a[key], b[key])
12
+ );
13
+ }
7
14
  return a !== b;
8
15
  }
9
16
  function useOnChange(value, onChange, isUpdated = isDifferent) {
@@ -1,16 +1,20 @@
1
1
  import "./chunk-MLKGABMK.js";
2
2
 
3
3
  // src/search/client/fetch.ts
4
+ var cache = /* @__PURE__ */ new Map();
4
5
  async function fetchDocs(query, locale, tag, options) {
5
6
  const params = new URLSearchParams();
6
7
  params.set("query", query);
7
8
  if (locale) params.set("locale", locale);
8
9
  if (tag) params.set("tag", tag);
9
- const res = await fetch(
10
- `${options.api ?? "/api/search"}?${params.toString()}`
11
- );
10
+ const key = `${options.api ?? "/api/search"}?${params}`;
11
+ const cached = cache.get(key);
12
+ if (cached) return cached;
13
+ const res = await fetch(key);
12
14
  if (!res.ok) throw new Error(await res.text());
13
- return await res.json();
15
+ const result = await res.json();
16
+ cache.set(key, result);
17
+ return result;
14
18
  }
15
19
  export {
16
20
  fetchDocs
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  useOnChange
3
- } from "../chunk-EMWGTXSW.js";
3
+ } from "../chunk-ORHEEQVY.js";
4
4
  import "../chunk-MLKGABMK.js";
5
5
 
6
6
  // src/search/client.ts
7
- import { useMemo, useRef as useRef2, useState as useState2 } from "react";
7
+ import { useRef as useRef2, useState as useState2 } from "react";
8
8
 
9
9
  // src/utils/use-debounce.ts
10
10
  import { useRef, useState } from "react";
@@ -23,7 +23,6 @@ function useDebounce(value, delayMs = 1e3) {
23
23
  }
24
24
 
25
25
  // src/search/client.ts
26
- var cache = /* @__PURE__ */ new Map();
27
26
  var staticClient;
28
27
  function useDocsSearch(client, locale, tag, delayMs = 100, allowEmpty = false, key) {
29
28
  const [search, setSearch] = useState2("");
@@ -32,21 +31,11 @@ function useDocsSearch(client, locale, tag, delayMs = 100, allowEmpty = false, k
32
31
  const [isLoading, setIsLoading] = useState2(false);
33
32
  const debouncedValue = useDebounce(search, delayMs);
34
33
  const onStart = useRef2(void 0);
35
- const cacheKey = useMemo(() => {
36
- return key ?? JSON.stringify([client.type, debouncedValue, locale, tag]);
37
- }, [client.type, debouncedValue, locale, tag, key]);
38
- useOnChange(cacheKey, () => {
39
- const cached = cache.get(cacheKey);
34
+ useOnChange(key ?? [client, debouncedValue, locale, tag], () => {
40
35
  if (onStart.current) {
41
36
  onStart.current();
42
37
  onStart.current = void 0;
43
38
  }
44
- if (cached) {
45
- setIsLoading(false);
46
- setError(void 0);
47
- setResults(cached);
48
- return;
49
- }
50
39
  setIsLoading(true);
51
40
  let interrupt = false;
52
41
  onStart.current = () => {
@@ -55,7 +44,7 @@ function useDocsSearch(client, locale, tag, delayMs = 100, allowEmpty = false, k
55
44
  async function run() {
56
45
  if (debouncedValue.length === 0 && !allowEmpty) return "empty";
57
46
  if (client.type === "fetch") {
58
- const { fetchDocs } = await import("../fetch-4K7QOPFM.js");
47
+ const { fetchDocs } = await import("../fetch-W5EHIBOE.js");
59
48
  return fetchDocs(debouncedValue, locale, tag, client);
60
49
  }
61
50
  if (client.type === "algolia") {
@@ -72,7 +61,6 @@ function useDocsSearch(client, locale, tag, delayMs = 100, allowEmpty = false, k
72
61
  return staticClient.search(debouncedValue, locale, tag);
73
62
  }
74
63
  void run().then((res) => {
75
- cache.set(cacheKey, res);
76
64
  if (interrupt) return;
77
65
  setError(void 0);
78
66
  setResults(res);
package/dist/toc.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import {
3
3
  useOnChange
4
- } from "./chunk-EMWGTXSW.js";
4
+ } from "./chunk-ORHEEQVY.js";
5
5
  import "./chunk-MLKGABMK.js";
6
6
 
7
7
  // src/toc.tsx
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  useOnChange
3
- } from "../chunk-EMWGTXSW.js";
3
+ } from "../chunk-ORHEEQVY.js";
4
4
  import "../chunk-MLKGABMK.js";
5
5
  export {
6
6
  useOnChange
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fumadocs-core",
3
- "version": "15.0.14",
3
+ "version": "15.0.15",
4
4
  "description": "The library for building a documentation website in Next.js",
5
5
  "keywords": [
6
6
  "NextJs",
@@ -108,7 +108,6 @@
108
108
  "devDependencies": {
109
109
  "@algolia/client-search": "4.24.0",
110
110
  "@mdx-js/mdx": "^3.1.0",
111
- "@orama/tokenizers": "^3.1.1",
112
111
  "@oramacloud/client": "^2.1.4",
113
112
  "@types/estree-jsx": "^1.0.5",
114
113
  "@types/hast": "^3.0.4",
@@ -130,7 +129,6 @@
130
129
  "tsconfig": "0.0.0"
131
130
  },
132
131
  "peerDependencies": {
133
- "@orama/tokenizers": "2.x.x",
134
132
  "@oramacloud/client": "1.x.x || 2.x.x",
135
133
  "algoliasearch": "4.24.0",
136
134
  "next": "14.x.x || 15.x.x",
@@ -138,9 +136,6 @@
138
136
  "react-dom": "18.x.x || 19.x.x"
139
137
  },
140
138
  "peerDependenciesMeta": {
141
- "@orama/tokenizers": {
142
- "optional": true
143
- },
144
139
  "@oramacloud/client": {
145
140
  "optional": true
146
141
  },