fumadocs-core 15.8.2 → 15.8.4

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.
Files changed (48) hide show
  1. package/dist/{algolia-Z232AL35.js → algolia-IZEDLPHE.js} +1 -1
  2. package/dist/breadcrumb.js +4 -4
  3. package/dist/builder-5BHIAfCi.d.ts +383 -0
  4. package/dist/{chunk-DDDU7USP.js → chunk-FAEPKD7U.js} +1 -0
  5. package/dist/{chunk-Z5V4JSQY.js → chunk-LMRZFODA.js} +16 -1
  6. package/dist/{chunk-JSBRDJBE.js → chunk-U67V476Y.js} +5 -0
  7. package/dist/content/github.js +1 -1
  8. package/dist/content/index.js +1 -1
  9. package/dist/content/toc.js +1 -1
  10. package/dist/dynamic-link.js +1 -1
  11. package/dist/{fetch-C3XV44E6.js → fetch-2XFMBLBA.js} +1 -1
  12. package/dist/framework/index.js +1 -1
  13. package/dist/framework/next.js +1 -1
  14. package/dist/framework/react-router.js +1 -1
  15. package/dist/framework/tanstack.js +1 -1
  16. package/dist/framework/waku.js +1 -1
  17. package/dist/hide-if-empty.js +1 -1
  18. package/dist/highlight/client.js +1 -1
  19. package/dist/highlight/index.js +1 -1
  20. package/dist/i18n/index.js +1 -1
  21. package/dist/i18n/legacy.js +1 -1
  22. package/dist/i18n/middleware.js +1 -1
  23. package/dist/link.js +1 -1
  24. package/dist/mdx-plugins/index.js +1 -1
  25. package/dist/{mixedbread-AG5AAOKO.js → mixedbread-RAHDVXGJ.js} +1 -1
  26. package/dist/negotiation/index.js +1 -1
  27. package/dist/{orama-cloud-GMFFJOIB.js → orama-cloud-74FM25SB.js} +1 -1
  28. package/dist/page-tree/index.js +1 -1
  29. package/dist/search/algolia.js +1 -1
  30. package/dist/search/client.js +6 -6
  31. package/dist/search/index.js +1 -1
  32. package/dist/search/orama-cloud.js +1 -1
  33. package/dist/search/server.d.ts +1 -1
  34. package/dist/search/server.js +5 -5
  35. package/dist/server/index.d.ts +1 -1
  36. package/dist/server/index.js +4 -4
  37. package/dist/sidebar.js +1 -1
  38. package/dist/source/index.d.ts +6 -331
  39. package/dist/source/index.js +200 -150
  40. package/dist/source/plugins/lucide-icons.d.ts +1 -1
  41. package/dist/source/plugins/lucide-icons.js +2 -2
  42. package/dist/{static-UVSWNGTY.js → static-A2YJ5TXV.js} +1 -1
  43. package/dist/toc.js +1 -1
  44. package/dist/utils/use-effect-event.d.ts +4 -3
  45. package/dist/utils/use-effect-event.js +9 -6
  46. package/dist/utils/use-media-query.js +1 -1
  47. package/dist/utils/use-on-change.js +1 -1
  48. package/package.json +12 -12
@@ -1,4 +1,4 @@
1
- import "../chunk-JSBRDJBE.js";
1
+ import "../chunk-U67V476Y.js";
2
2
 
3
3
  // src/search/algolia.ts
4
4
  async function sync(client, options) {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  useOnChange
3
3
  } from "../chunk-EMWGTXSW.js";
4
- import "../chunk-JSBRDJBE.js";
4
+ import "../chunk-U67V476Y.js";
5
5
 
6
6
  // src/search/client.ts
7
7
  import { useRef as useRef2, useState as useState2 } from "react";
@@ -65,23 +65,23 @@ function useDocsSearch(clientOptions, _locale, _tag, _delayMs = 100, _allowEmpty
65
65
  async function run() {
66
66
  if (debouncedValue.length === 0 && !allowEmpty) return "empty";
67
67
  if (client.type === "fetch") {
68
- const { fetchDocs } = await import("../fetch-C3XV44E6.js");
68
+ const { fetchDocs } = await import("../fetch-2XFMBLBA.js");
69
69
  return fetchDocs(debouncedValue, client);
70
70
  }
71
71
  if (client.type === "algolia") {
72
- const { searchDocs } = await import("../algolia-Z232AL35.js");
72
+ const { searchDocs } = await import("../algolia-IZEDLPHE.js");
73
73
  return searchDocs(debouncedValue, client);
74
74
  }
75
75
  if (client.type === "orama-cloud") {
76
- const { searchDocs } = await import("../orama-cloud-GMFFJOIB.js");
76
+ const { searchDocs } = await import("../orama-cloud-74FM25SB.js");
77
77
  return searchDocs(debouncedValue, client);
78
78
  }
79
79
  if (client.type === "static") {
80
- const { search: search2 } = await import("../static-UVSWNGTY.js");
80
+ const { search: search2 } = await import("../static-A2YJ5TXV.js");
81
81
  return search2(debouncedValue, client);
82
82
  }
83
83
  if (client.type === "mixedbread") {
84
- const { search: search2 } = await import("../mixedbread-AG5AAOKO.js");
84
+ const { search: search2 } = await import("../mixedbread-RAHDVXGJ.js");
85
85
  return search2(debouncedValue, client);
86
86
  }
87
87
  throw new Error("unknown search client");
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  createContentHighlighter
3
3
  } from "../chunk-OTD7MV33.js";
4
- import "../chunk-JSBRDJBE.js";
4
+ import "../chunk-U67V476Y.js";
5
5
  export {
6
6
  createContentHighlighter
7
7
  };
@@ -1,4 +1,4 @@
1
- import "../chunk-JSBRDJBE.js";
1
+ import "../chunk-U67V476Y.js";
2
2
 
3
3
  // src/search/orama-cloud.ts
4
4
  async function sync(cloudManager, options) {
@@ -3,7 +3,7 @@ import { S as StructuredData } from '../remark-structure-DkCXCzpD.js';
3
3
  import { SortedResult } from './index.js';
4
4
  export { HighlightedText, ReactSortedResult, createContentHighlighter } from './index.js';
5
5
  import { I18nConfig } from '../i18n/index.js';
6
- import { LoaderOutput, LoaderConfig, InferPageType } from '../source/index.js';
6
+ import { L as LoaderOutput, a as LoaderConfig, I as InferPageType } from '../builder-5BHIAfCi.js';
7
7
  import 'mdast';
8
8
  import 'unified';
9
9
  import 'mdast-util-mdx-jsx';
@@ -3,17 +3,17 @@ import {
3
3
  searchSimple
4
4
  } from "../chunk-XOFXGHS4.js";
5
5
  import "../chunk-ZMWYLUDP.js";
6
- import {
7
- basename,
8
- extname
9
- } from "../chunk-Z5V4JSQY.js";
10
6
  import {
11
7
  createContentHighlighter
12
8
  } from "../chunk-OTD7MV33.js";
9
+ import {
10
+ basename,
11
+ extname
12
+ } from "../chunk-LMRZFODA.js";
13
13
  import {
14
14
  findPath
15
15
  } from "../chunk-2IYQ7QMS.js";
16
- import "../chunk-JSBRDJBE.js";
16
+ import "../chunk-U67V476Y.js";
17
17
 
18
18
  // src/search/server.ts
19
19
  import {
@@ -1,7 +1,7 @@
1
1
  export { GetGithubLastCommitOptions, getGithubLastEdit } from '../content/github.js';
2
2
  import { Metadata } from 'next';
3
3
  import { NextRequest } from 'next/server';
4
- import { LoaderOutput, LoaderConfig, InferPageType } from '../source/index.js';
4
+ import { L as LoaderOutput, a as LoaderConfig, I as InferPageType } from '../builder-5BHIAfCi.js';
5
5
  export { getTableOfContents } from '../content/toc.js';
6
6
  export { TOCItemType, TableOfContents } from '../toc.js';
7
7
  export { SortedResult } from '../search/index.js';
@@ -1,6 +1,3 @@
1
- import {
2
- getGithubLastEdit
3
- } from "../chunk-HSBNG7QC.js";
4
1
  import {
5
2
  getTableOfContents
6
3
  } from "../chunk-CX7IQ5Z6.js";
@@ -12,7 +9,10 @@ import {
12
9
  getPageTreePeers,
13
10
  getPageTreeRoots
14
11
  } from "../chunk-2IYQ7QMS.js";
15
- import "../chunk-JSBRDJBE.js";
12
+ import {
13
+ getGithubLastEdit
14
+ } from "../chunk-HSBNG7QC.js";
15
+ import "../chunk-U67V476Y.js";
16
16
 
17
17
  // src/server/metadata.ts
18
18
  function createMetadataImage(options) {
package/dist/sidebar.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  useMediaQuery
4
4
  } from "./chunk-EP5LHGDZ.js";
5
- import "./chunk-JSBRDJBE.js";
5
+ import "./chunk-U67V476Y.js";
6
6
 
7
7
  // src/sidebar.tsx
8
8
  import {
@@ -1,337 +1,12 @@
1
- import { I as Item, F as Folder, S as Separator, R as Root } from '../definitions-Q95-psoo.js';
2
- import { I18nConfig } from '../i18n/index.js';
3
- import { ReactNode } from 'react';
1
+ import { F as FileInfo } from '../builder-5BHIAfCi.js';
2
+ export { C as ContentStorage, f as FileSystem, v as InferMetaType, I as InferPageType, a as LoaderConfig, i as LoaderOptions, L as LoaderOutput, w as LoaderPlugin, l as Meta, r as MetaData, M as MetaFile, k as Page, s as PageData, g as PageFile, b as PageTreeBuilder, d as PageTreeBuilderContext, e as PageTreeOptions, P as PageTreeTransformer, p as PathUtils, R as ResolvedLoaderConfig, j as Source, S as SourceConfig, T as Transformer, U as UrlFn, u as VirtualFile, t as VirtualMeta, V as VirtualPage, _ as _ConfigUnion_, x as buildPlugins, m as createGetUrl, c as createPageTreeBuilder, n as loader, q as map, o as multiple, h as parseFilePath } from '../builder-5BHIAfCi.js';
3
+ import '../definitions-Q95-psoo.js';
4
+ import 'react';
5
+ import '../i18n/index.js';
4
6
 
5
- interface FileInfo {
6
- /**
7
- * File path without extension
8
- *
9
- * @deprecated obtain it with `join(dirname, name)`
10
- */
11
- flattenedPath: string;
12
- /**
13
- * path of file (unparsed)
14
- */
15
- path: string;
16
- /**
17
- * File name without extension
18
- */
19
- name: string;
20
- /**
21
- * file extension from the last `.`, like `.md`
22
- *
23
- * empty string if no file extension
24
- */
25
- ext: string;
26
- dirname: string;
27
- }
28
- interface FolderInfo {
29
- /**
30
- * Original path of folder
31
- */
32
- path: string;
33
- /**
34
- * folder name
35
- */
36
- name: string;
37
- dirname: string;
38
- }
39
- declare function parseFilePath(path: string): FileInfo;
40
-
41
- type LoaderPlugins<Page extends PageData, Meta extends MetaData> = LoaderPlugin<Page, Meta>[];
42
- interface LoaderPlugin<Page extends PageData = PageData, Meta extends MetaData = MetaData> {
43
- /**
44
- * transform the storage after loading
45
- */
46
- transformStorage?: (context: {
47
- storage: ContentStorage<Page, Meta>;
48
- }) => void;
49
- /**
50
- * transform the generated page tree
51
- */
52
- transformPageTree?: PageTreeTransformer<Page, Meta>;
53
- }
54
- declare function buildPlugins<Page extends PageData, Meta extends MetaData>(plugins: LoaderPlugins<Page, Meta>): LoaderPlugin<Page, Meta>[];
55
-
56
- interface LegacyLoaderOptions {
57
- /**
58
- * We recommend you to use `plugins` instead
59
- */
60
- transformers?: Transformer[];
61
- }
62
- interface LegacyPageTreeOptions<Page extends PageData, Meta extends MetaData> {
63
- /**
64
- * @deprecated use `plugins` instead
65
- */
66
- attachFile?: (node: Item, file?: PageFile<Page>) => Item;
67
- /**
68
- * @deprecated use `plugins` instead
69
- */
70
- attachFolder?: (node: Folder, folder: {
71
- children: (PageFile<Page> | MetaFile<Meta>)[];
72
- }, meta?: MetaFile<Meta>) => Folder;
73
- /**
74
- * @deprecated use `plugins` instead
75
- */
76
- attachSeparator?: (node: Separator) => Separator;
77
- /**
78
- * We recommend you to use `plugins` instead
79
- */
80
- transformers?: PageTreeTransformer<Page, Meta>[];
81
- }
82
-
83
- type IconResolver = (icon: string | undefined) => ReactNode;
84
-
85
- interface LoaderConfig {
86
- source: SourceConfig;
87
- i18n: I18nConfig | undefined;
88
- }
89
- interface SourceConfig {
90
- pageData: PageData;
91
- metaData: MetaData;
92
- }
93
- type LoaderOptions<Config extends SourceConfig = SourceConfig, I18n extends I18nConfig | undefined = I18nConfig | undefined> = BaseLoaderOptions<NoInfer<Config>> & {
94
- source: Source<Config> | Source<Config>[];
95
- /**
96
- * Configure i18n
97
- */
98
- i18n?: I18n;
99
- };
100
- interface BaseLoaderOptions<Config extends SourceConfig> extends LegacyLoaderOptions {
101
- baseUrl: string;
102
- icon?: IconResolver;
103
- slugs?: (info: FileInfo) => string[];
104
- url?: UrlFn;
105
- /**
106
- * Additional options for page tree builder
107
- */
108
- pageTree?: Partial<BaseOptions> & LegacyPageTreeOptions<Config['pageData'], Config['metaData']>;
109
- plugins?: LoaderPlugins<Config['pageData'], Config['metaData']>;
110
- }
111
- interface Source<Config extends SourceConfig> {
112
- /**
113
- * @internal
114
- */
115
- _config?: Config;
116
- files: VirtualFile[] | (() => VirtualFile[]);
117
- }
118
- interface SharedFileInfo {
119
- /**
120
- * Virtualized file path (parsed)
121
- *
122
- * @deprecated Use `path` instead.
123
- */
124
- file: FileInfo;
125
- /**
126
- * Virtualized file path (relative to content directory)
127
- *
128
- * @example `docs/page.mdx`
129
- */
130
- path: string;
131
- /**
132
- * Absolute path of the file
133
- */
134
- absolutePath: string;
135
- }
136
- interface VirtualFile {
137
- /**
138
- * Virtualized path (relative to content directory)
139
- *
140
- * @example `docs/page.mdx`
141
- */
142
- path: string;
143
- /**
144
- * Absolute path of the file
145
- */
146
- absolutePath?: string;
147
- type: 'page' | 'meta';
148
- /**
149
- * Specified Slugs for page
150
- */
151
- slugs?: string[];
152
- data: unknown;
153
- }
154
- interface Page<Data = PageData> extends SharedFileInfo {
155
- slugs: string[];
156
- url: string;
157
- data: Data;
158
- locale?: string | undefined;
159
- }
160
- interface Meta<Data = MetaData> extends SharedFileInfo {
161
- data: Data;
162
- }
163
- interface LanguageEntry<Data = PageData> {
164
- language: string;
165
- pages: Page<Data>[];
166
- }
167
- interface LoaderOutput<Config extends LoaderConfig> {
168
- pageTree: Config['i18n'] extends I18nConfig ? Record<string, Root> : Root;
169
- getPageTree: (locale?: string) => Root;
170
- getPageByHref: (href: string, options?: {
171
- language?: string;
172
- /**
173
- * resolve relative file paths in `href` from specified dirname, must be a virtual path.
174
- */
175
- dir?: string;
176
- }) => {
177
- page: Page<Config['source']['pageData']>;
178
- hash?: string;
179
- } | undefined;
180
- /**
181
- * @internal
182
- */
183
- _i18n?: I18nConfig;
184
- /**
185
- * Get a list of pages from specified language
186
- *
187
- * @param language - If empty, list pages from all languages.
188
- */
189
- getPages: (language?: string) => Page<Config['source']['pageData']>[];
190
- /**
191
- * get each language and its pages, empty if i18n is not enabled.
192
- */
193
- getLanguages: () => LanguageEntry<Config['source']['pageData']>[];
194
- /**
195
- * Get page with slugs
196
- *
197
- * @param language - If empty, the default language will be used
198
- */
199
- getPage: (slugs: string[] | undefined, language?: string) => Page<Config['source']['pageData']> | undefined;
200
- getNodePage: (node: Item, language?: string) => Page<Config['source']['pageData']> | undefined;
201
- getNodeMeta: (node: Folder, language?: string) => Meta<Config['source']['metaData']> | undefined;
202
- /**
203
- * generate static params for Next.js SSG
204
- *
205
- * @param slug - customise parameter name for slugs
206
- * @param lang - customise parameter name for lang
207
- */
208
- generateParams: <TSlug extends string = 'slug', TLang extends string = 'lang'>(slug?: TSlug, lang?: TLang) => (Record<TSlug, string[]> & Record<TLang, string>)[];
209
- }
210
- declare function createGetUrl(baseUrl: string, i18n?: I18nConfig): UrlFn;
211
- declare function loader<Config extends SourceConfig, I18n extends I18nConfig | undefined = undefined>(options: LoaderOptions<Config, I18n>): LoaderOutput<{
212
- source: Config;
213
- i18n: I18n;
214
- }>;
215
7
  /**
216
8
  * Convert file path into slugs, also encode non-ASCII characters, so they can work in pathname
217
9
  */
218
10
  declare function getSlugs(file: string | FileInfo): string[];
219
11
 
220
- interface MetaData {
221
- icon?: string | undefined;
222
- title?: string | undefined;
223
- root?: boolean | undefined;
224
- pages?: string[] | undefined;
225
- defaultOpen?: boolean | undefined;
226
- description?: string | undefined;
227
- }
228
- interface PageData {
229
- icon?: string | undefined;
230
- title?: string;
231
- description?: string | undefined;
232
- }
233
- type InferPageType<Utils extends LoaderOutput<any>> = Utils extends LoaderOutput<infer Config> ? Page<Config['source']['pageData']> : never;
234
- type InferMetaType<Utils extends LoaderOutput<any>> = Utils extends LoaderOutput<infer Config> ? Meta<Config['source']['metaData']> : never;
235
- /**
236
- * @internal
237
- */
238
- type UrlFn = (slugs: string[], locale?: string) => string;
239
-
240
- /**
241
- * In memory file system.
242
- */
243
- declare class FileSystem<File> {
244
- files: Map<string, File>;
245
- folders: Map<string, string[]>;
246
- constructor(inherit?: FileSystem<File>);
247
- read(path: string): File | undefined;
248
- /**
249
- * get the direct children of folder (in virtual file path)
250
- */
251
- readDir(path: string): string[] | undefined;
252
- write(path: string, file: File): void;
253
- delete(path: string): boolean;
254
- deleteDir(path: string): boolean;
255
- getFiles(): string[];
256
- makeDir(path: string): void;
257
- }
258
-
259
- interface LoadOptions {
260
- buildFile: (file: VirtualFile) => MetaFile | PageFile;
261
- plugins?: LoaderPlugin[];
262
- }
263
- type ContentStorage<Page extends PageData = PageData, Meta extends MetaData = MetaData> = FileSystem<MetaFile<Meta> | PageFile<Page>>;
264
- interface MetaFile<Data extends MetaData = MetaData> {
265
- path: string;
266
- absolutePath: string;
267
- format: 'meta';
268
- data: Data;
269
- }
270
- interface PageFile<Data extends PageData = PageData> {
271
- path: string;
272
- absolutePath: string;
273
- format: 'page';
274
- slugs: string[];
275
- data: Data;
276
- }
277
- type Transformer = (context: {
278
- storage: ContentStorage;
279
- }) => void;
280
- /**
281
- * @returns a map of locale and its content storage.
282
- *
283
- * in the storage, locale codes are removed from file paths, hence the same file will have same file paths in every storage.
284
- */
285
- declare function loadFiles(files: VirtualFile[], options: LoadOptions, i18n: I18nConfig): Record<string, ContentStorage>;
286
-
287
- interface PageTreeBuilderContext<Page extends PageData = PageData, Meta extends MetaData = MetaData> {
288
- /**
289
- * @internal resolve paths without extensions
290
- */
291
- resolveName: (name: string, format: 'meta' | 'page') => string;
292
- options: BaseOptions;
293
- transformers: PageTreeTransformer<Page, Meta>[];
294
- builder: PageTreeBuilder;
295
- storage: ContentStorage<Page, Meta>;
296
- getUrl: UrlFn;
297
- storages?: Record<string, ContentStorage<Page, Meta>>;
298
- locale?: string;
299
- visitedPaths: Set<string>;
300
- }
301
- interface PageTreeTransformer<Page extends PageData = PageData, Meta extends MetaData = MetaData> {
302
- name?: string;
303
- file?: (this: PageTreeBuilderContext<Page, Meta>, node: Item, filePath?: string) => Item;
304
- folder?: (this: PageTreeBuilderContext<Page, Meta>, node: Folder, folderPath: string, metaPath?: string) => Folder;
305
- separator?: (this: PageTreeBuilderContext<Page, Meta>, node: Separator) => Separator;
306
- root?: (this: PageTreeBuilderContext<Page, Meta>, node: Root) => Root;
307
- }
308
- interface BaseOptions {
309
- id?: string;
310
- /**
311
- * Remove references to the file path of original nodes (`$ref`)
312
- *
313
- * @defaultValue false
314
- */
315
- noRef?: boolean;
316
- plugins?: LoaderPlugin[];
317
- /**
318
- * generate fallback page tree
319
- *
320
- * @defaultValue true
321
- */
322
- generateFallback?: boolean;
323
- }
324
- interface PageTreeBuilder {
325
- build: (options: BaseOptions & {
326
- storage: ContentStorage;
327
- }) => Root;
328
- /**
329
- * Build page tree and fallback to the default language if the localized page doesn't exist
330
- */
331
- buildI18n: (options: BaseOptions & {
332
- storages: Record<string, ContentStorage>;
333
- }) => Record<string, Root>;
334
- }
335
- declare function createPageTreeBuilder(getUrl: UrlFn): PageTreeBuilder;
336
-
337
- export { type BaseOptions, type ContentStorage, type FileInfo, FileSystem, type FolderInfo, type InferMetaType, type InferPageType, type LanguageEntry, type LoadOptions, type LoaderConfig, type LoaderOptions, type LoaderOutput, type LoaderPlugin, type LoaderPlugins, type Meta, type MetaData, type MetaFile, type Page, type PageData, type PageFile, type PageTreeBuilder, type PageTreeBuilderContext, type PageTreeTransformer, type Source, type SourceConfig, type Transformer, type UrlFn, type VirtualFile, buildPlugins, createGetUrl, createPageTreeBuilder, getSlugs, loadFiles, loader, parseFilePath };
12
+ export { FileInfo, getSlugs };