fumadocs-core 15.0.9 → 15.0.11

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.
@@ -1,4 +1,5 @@
1
1
  import { S as SortedResult } from '../types-Ch8gnVgO.js';
2
+ import { Orama } from '@orama/orama';
2
3
  import { SearchOptions } from '@algolia/client-search';
3
4
  import { SearchIndex } from 'algoliasearch/lite';
4
5
  import { OramaClient, ClientSearchParams } from '@oramacloud/client';
@@ -15,6 +16,7 @@ interface StaticOptions {
15
16
  * Where to download exported search indexes (URL)
16
17
  */
17
18
  from?: string;
19
+ initOrama?: (locale?: string) => Promise<Orama<unknown, never, never, never>>;
18
20
  }
19
21
 
20
22
  interface AlgoliaOptions extends SearchOptions {
@@ -67,7 +67,7 @@ function useDocsSearch(client, locale, tag, delayMs = 100, allowEmpty = false, k
67
67
  const { searchDocs } = await import("../orama-cloud-HAZVD2ZO.js");
68
68
  return searchDocs(debouncedValue, tag, client);
69
69
  }
70
- const { createStaticClient } = await import("../static-KPGOHAZ2.js");
70
+ const { createStaticClient } = await import("../static-R3CYGT5R.js");
71
71
  if (!staticClient) staticClient = createStaticClient(client);
72
72
  return staticClient.search(debouncedValue, locale, tag);
73
73
  }
@@ -1,4 +1,4 @@
1
- import { TypedDocument, Orama, Language, create, SearchParams } from '@orama/orama';
1
+ import { TypedDocument, Orama, Language, RawData, create, SearchParams } from '@orama/orama';
2
2
  import { NextRequest } from 'next/server';
3
3
  import { S as StructuredData } from '../remark-structure-mP51W1AN.js';
4
4
  import { S as SortedResult } from '../types-Ch8gnVgO.js';
@@ -49,6 +49,15 @@ type Options = Omit<AdvancedOptions, 'language' | 'indexes'> & {
49
49
  };
50
50
  declare function createFromSource<S extends LoaderOutput<LoaderConfig>>(source: S, pageToIndexFn?: (page: InferPageType<S>) => AdvancedIndex, options?: Options): SearchAPI;
51
51
 
52
+ type SearchType = 'simple' | 'advanced';
53
+ type ExportedData = (RawData & {
54
+ type: SearchType;
55
+ }) | {
56
+ type: 'i18n';
57
+ data: Record<string, RawData & {
58
+ type: SearchType;
59
+ }>;
60
+ };
52
61
  interface SearchServer {
53
62
  search: (query: string, options?: {
54
63
  locale?: string;
@@ -59,7 +68,7 @@ interface SearchServer {
59
68
  *
60
69
  * You can reference the exported database to implement client-side search
61
70
  */
62
- export: () => Promise<unknown>;
71
+ export: () => Promise<ExportedData>;
63
72
  }
64
73
  interface SearchAPI extends SearchServer {
65
74
  GET: (request: NextRequest) => Promise<Response>;
@@ -91,7 +100,7 @@ interface AdvancedOptions extends SharedOptions {
91
100
  */
92
101
  search?: Partial<SearchParams<Orama<typeof advancedSchema>, AdvancedDocument>>;
93
102
  }
94
- declare function createSearchAPI<T extends 'simple' | 'advanced'>(type: T, options: T extends 'simple' ? SimpleOptions : AdvancedOptions): SearchAPI;
103
+ declare function createSearchAPI<T extends SearchType>(type: T, options: T extends 'simple' ? SimpleOptions : AdvancedOptions): SearchAPI;
95
104
  interface Index {
96
105
  title: string;
97
106
  description?: string;
@@ -117,4 +126,4 @@ interface AdvancedIndex {
117
126
  }
118
127
  declare function initAdvancedSearch(options: AdvancedOptions): SearchServer;
119
128
 
120
- export { type AdvancedIndex, type AdvancedOptions, type Dynamic, type Index, type SearchAPI, type SearchServer, type SimpleOptions, createFromSource, createI18nSearchAPI, createSearchAPI, initAdvancedSearch, initSimpleSearch };
129
+ export { type AdvancedIndex, type AdvancedOptions, type Dynamic, type ExportedData, type Index, type SearchAPI, type SearchServer, type SimpleOptions, createFromSource, createI18nSearchAPI, createSearchAPI, initAdvancedSearch, initSimpleSearch };
@@ -6,7 +6,9 @@ import "../chunk-DELA6Z2I.js";
6
6
  import "../chunk-MLKGABMK.js";
7
7
 
8
8
  // src/search/server.ts
9
- import { save } from "@orama/orama";
9
+ import {
10
+ save
11
+ } from "@orama/orama";
10
12
 
11
13
  // src/search/orama/create-endpoint.ts
12
14
  function createEndpoint(server) {
@@ -299,7 +301,7 @@ function initSimpleSearch(options) {
299
301
  async export() {
300
302
  return {
301
303
  type: "simple",
302
- ...save(await doc)
304
+ ...await save(await doc)
303
305
  };
304
306
  },
305
307
  async search(query) {
package/dist/sidebar.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
1
2
  import { ReactNode, ElementType, ComponentPropsWithoutRef, ReactElement } from 'react';
2
3
 
3
4
  interface SidebarProviderProps {
@@ -5,7 +6,7 @@ interface SidebarProviderProps {
5
6
  onOpenChange?: (v: boolean) => void;
6
7
  children: ReactNode;
7
8
  }
8
- declare function SidebarProvider(props: SidebarProviderProps): React.ReactElement;
9
+ declare function SidebarProvider(props: SidebarProviderProps): react_jsx_runtime.JSX.Element;
9
10
  type AsProps<T extends ElementType> = Omit<ComponentPropsWithoutRef<T>, 'as'> & {
10
11
  as?: T;
11
12
  };
package/dist/sidebar.js CHANGED
@@ -6,22 +6,29 @@ import {
6
6
  createContext,
7
7
  useContext,
8
8
  useEffect,
9
- useState
9
+ useState,
10
+ useMemo
10
11
  } from "react";
11
12
  import { RemoveScroll } from "react-remove-scroll";
12
13
  import { jsx } from "react/jsx-runtime";
13
- var SidebarContext = createContext(void 0);
14
+ var SidebarContext = createContext(null);
14
15
  function useSidebarContext() {
15
16
  const ctx = useContext(SidebarContext);
16
17
  if (!ctx) throw new Error("Missing sidebar provider");
17
18
  return ctx;
18
19
  }
19
20
  function SidebarProvider(props) {
20
- const [openInner, setOpenInner] = useState(false);
21
+ const [open, setOpen] = props.open === void 0 ? (
22
+ // eslint-disable-next-line react-hooks/rules-of-hooks
23
+ useState(false)
24
+ ) : [props.open, props.onOpenChange];
21
25
  return /* @__PURE__ */ jsx(
22
26
  SidebarContext.Provider,
23
27
  {
24
- value: [props.open ?? openInner, props.onOpenChange ?? setOpenInner],
28
+ value: useMemo(
29
+ () => ({ open, setOpen: setOpen ?? (() => void 0) }),
30
+ [open, setOpen]
31
+ ),
25
32
  children: props.children
26
33
  }
27
34
  );
@@ -30,7 +37,7 @@ function SidebarTrigger({
30
37
  as,
31
38
  ...props
32
39
  }) {
33
- const [open, setOpen] = useSidebarContext();
40
+ const { open, setOpen } = useSidebarContext();
34
41
  const As = as ?? "button";
35
42
  return /* @__PURE__ */ jsx(
36
43
  As,
@@ -49,7 +56,7 @@ function SidebarList({
49
56
  blockScrollingWidth,
50
57
  ...props
51
58
  }) {
52
- const [open] = useSidebarContext();
59
+ const { open } = useSidebarContext();
53
60
  const [isBlocking, setIsBlocking] = useState(false);
54
61
  useEffect(() => {
55
62
  if (!blockScrollingWidth) return;
@@ -6,12 +6,10 @@ import "./chunk-DELA6Z2I.js";
6
6
  import "./chunk-MLKGABMK.js";
7
7
 
8
8
  // src/search/client/static.ts
9
- import {
10
- create,
11
- load
12
- } from "@orama/orama";
9
+ import { create, load } from "@orama/orama";
13
10
  function createStaticClient({
14
- from = "/api/search"
11
+ from = "/api/search",
12
+ initOrama = (locale) => create({ schema: { _: "string" }, language: locale })
15
13
  }) {
16
14
  const dbs = /* @__PURE__ */ new Map();
17
15
  async function init() {
@@ -23,7 +21,7 @@ function createStaticClient({
23
21
  const data = await res.json();
24
22
  if (data.type === "i18n") {
25
23
  for (const [k, v] of Object.entries(data.data)) {
26
- const db = await create({ schema: { _: "string" } });
24
+ const db = await initOrama(k);
27
25
  await load(db, v);
28
26
  dbs.set(k, {
29
27
  type: v.type,
@@ -31,7 +29,7 @@ function createStaticClient({
31
29
  });
32
30
  }
33
31
  } else {
34
- const db = await create({ schema: { _: "string" } });
32
+ const db = await initOrama();
35
33
  await load(db, data);
36
34
  dbs.set("", {
37
35
  type: data.type,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fumadocs-core",
3
- "version": "15.0.9",
3
+ "version": "15.0.11",
4
4
  "description": "The library for building a documentation website in Next.js",
5
5
  "keywords": [
6
6
  "NextJs",
@@ -83,18 +83,18 @@
83
83
  "dependencies": {
84
84
  "@formatjs/intl-localematcher": "^0.6.0",
85
85
  "@orama/orama": "^2.1.1",
86
- "@shikijs/rehype": "^2.4.1",
87
- "@shikijs/transformers": "^2.4.1",
86
+ "@shikijs/rehype": "^3.0.0",
87
+ "@shikijs/transformers": "^3.0.0",
88
88
  "github-slugger": "^2.0.0",
89
- "hast-util-to-estree": "^3.1.1",
90
- "hast-util-to-jsx-runtime": "^2.3.2",
89
+ "hast-util-to-estree": "^3.1.2",
90
+ "hast-util-to-jsx-runtime": "^2.3.3",
91
91
  "image-size": "^1.2.0",
92
92
  "negotiator": "^1.0.0",
93
93
  "react-remove-scroll": "^2.6.3",
94
94
  "remark": "^15.0.0",
95
95
  "remark-gfm": "^4.0.1",
96
96
  "scroll-into-view-if-needed": "^3.1.0",
97
- "shiki": "^2.4.1",
97
+ "shiki": "^3.0.0",
98
98
  "unist-util-visit": "^5.0.0"
99
99
  },
100
100
  "devDependencies": {
@@ -107,8 +107,8 @@
107
107
  "@types/mdast": "^4.0.3",
108
108
  "@types/negotiator": "^0.6.3",
109
109
  "@types/node": "22.13.4",
110
- "@types/react": "^19.0.9",
111
- "@types/react-dom": "^19.0.3",
110
+ "@types/react": "^19.0.10",
111
+ "@types/react-dom": "^19.0.4",
112
112
  "algoliasearch": "4.24.0",
113
113
  "mdast-util-mdx-jsx": "^3.2.0",
114
114
  "mdast-util-mdxjs-esm": "^2.0.1",