@vezham/docs-core 1.0.1

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 (201) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +5 -0
  3. package/dist/advanced-Ct13khZr.js +79 -0
  4. package/dist/algolia-C0E5qQhM.d.ts +66 -0
  5. package/dist/breadcrumb.d.ts +46 -0
  6. package/dist/breadcrumb.js +59 -0
  7. package/dist/build-doc-4OvfjVN2.js +85 -0
  8. package/dist/client-kQ39Ub0-.d.ts +247 -0
  9. package/dist/codeblock-utils-CyP8qsYv.d.ts +29 -0
  10. package/dist/content/github.d.ts +41 -0
  11. package/dist/content/github.js +28 -0
  12. package/dist/content/md/frontmatter.d.ts +15 -0
  13. package/dist/content/md/frontmatter.js +24 -0
  14. package/dist/content/md.d.ts +24 -0
  15. package/dist/content/md.js +43 -0
  16. package/dist/content/mdx/preset-bundler.d.ts +29 -0
  17. package/dist/content/mdx/preset-bundler.js +39 -0
  18. package/dist/content/mdx/preset-runtime.d.ts +26 -0
  19. package/dist/content/mdx/preset-runtime.js +36 -0
  20. package/dist/content/toc.d.ts +19 -0
  21. package/dist/content/toc.js +14 -0
  22. package/dist/definitions-CFOhwE1k.d.ts +72 -0
  23. package/dist/dynamic-CTsodhTH.js +905 -0
  24. package/dist/dynamic-link.d.ts +12 -0
  25. package/dist/dynamic-link.js +31 -0
  26. package/dist/endpoint-MyoBU5IC.js +28 -0
  27. package/dist/framework/astro.d.ts +21 -0
  28. package/dist/framework/astro.js +52 -0
  29. package/dist/framework/index.d.ts +40 -0
  30. package/dist/framework/index.js +66 -0
  31. package/dist/framework/next.d.ts +10 -0
  32. package/dist/framework/next.js +19 -0
  33. package/dist/framework/react-router.d.ts +10 -0
  34. package/dist/framework/react-router.js +43 -0
  35. package/dist/framework/tanstack.d.ts +13 -0
  36. package/dist/framework/tanstack.js +54 -0
  37. package/dist/framework/waku.d.ts +10 -0
  38. package/dist/framework/waku.js +46 -0
  39. package/dist/highlight/client.d.ts +11 -0
  40. package/dist/highlight/client.js +15 -0
  41. package/dist/highlight/index.d.ts +31 -0
  42. package/dist/highlight/index.js +30 -0
  43. package/dist/highlight/shiki/full.d.ts +7 -0
  44. package/dist/highlight/shiki/full.js +23 -0
  45. package/dist/highlight/shiki/index.d.ts +2 -0
  46. package/dist/highlight/shiki/index.js +27 -0
  47. package/dist/highlight/shiki/react.d.ts +23 -0
  48. package/dist/highlight/shiki/react.js +50 -0
  49. package/dist/i18n/index.d.ts +2 -0
  50. package/dist/i18n/index.js +63 -0
  51. package/dist/i18n/middleware.d.ts +34 -0
  52. package/dist/i18n/middleware.js +3855 -0
  53. package/dist/icon-BILaoXeg.js +17 -0
  54. package/dist/index-B-0R0VbS.d.ts +18 -0
  55. package/dist/index-BM36H-xw.d.ts +36 -0
  56. package/dist/index-BMEUQz-F.d.ts +21 -0
  57. package/dist/index-DAYtLGbx.d.ts +16 -0
  58. package/dist/index-DIwKCYOz.d.ts +513 -0
  59. package/dist/index-DydiXvgS.d.ts +90 -0
  60. package/dist/index-E8Qh_yQs.d.ts +49 -0
  61. package/dist/is-equal-LdLqRs0o.js +8 -0
  62. package/dist/link.d.ts +17 -0
  63. package/dist/link.js +23 -0
  64. package/dist/mdx-plugins/codeblock-utils.d.ts +2 -0
  65. package/dist/mdx-plugins/codeblock-utils.js +68 -0
  66. package/dist/mdx-plugins/index.d.ts +20 -0
  67. package/dist/mdx-plugins/index.js +18 -0
  68. package/dist/mdx-plugins/rehype-code.core.d.ts +3 -0
  69. package/dist/mdx-plugins/rehype-code.core.js +3 -0
  70. package/dist/mdx-plugins/rehype-code.d.ts +4 -0
  71. package/dist/mdx-plugins/rehype-code.js +24 -0
  72. package/dist/mdx-plugins/rehype-toc.d.ts +2 -0
  73. package/dist/mdx-plugins/rehype-toc.js +139 -0
  74. package/dist/mdx-plugins/remark-admonition.d.ts +2 -0
  75. package/dist/mdx-plugins/remark-admonition.js +71 -0
  76. package/dist/mdx-plugins/remark-block-id.d.ts +37 -0
  77. package/dist/mdx-plugins/remark-block-id.js +41 -0
  78. package/dist/mdx-plugins/remark-code-tab.d.ts +2 -0
  79. package/dist/mdx-plugins/remark-code-tab.js +190 -0
  80. package/dist/mdx-plugins/remark-directive-admonition.d.ts +2 -0
  81. package/dist/mdx-plugins/remark-directive-admonition.js +57 -0
  82. package/dist/mdx-plugins/remark-feedback-block.d.ts +2 -0
  83. package/dist/mdx-plugins/remark-feedback-block.js +54 -0
  84. package/dist/mdx-plugins/remark-gfm.d.ts +2 -0
  85. package/dist/mdx-plugins/remark-gfm.js +2 -0
  86. package/dist/mdx-plugins/remark-heading.d.ts +2 -0
  87. package/dist/mdx-plugins/remark-heading.js +46 -0
  88. package/dist/mdx-plugins/remark-image.d.ts +2 -0
  89. package/dist/mdx-plugins/remark-image.js +167 -0
  90. package/dist/mdx-plugins/remark-llms.d.ts +2 -0
  91. package/dist/mdx-plugins/remark-llms.js +338 -0
  92. package/dist/mdx-plugins/remark-llms.runtime.d.ts +10 -0
  93. package/dist/mdx-plugins/remark-llms.runtime.js +24 -0
  94. package/dist/mdx-plugins/remark-mdx-files.d.ts +2 -0
  95. package/dist/mdx-plugins/remark-mdx-files.js +182 -0
  96. package/dist/mdx-plugins/remark-mdx-mermaid.d.ts +2 -0
  97. package/dist/mdx-plugins/remark-mdx-mermaid.js +28 -0
  98. package/dist/mdx-plugins/remark-npm.d.ts +2 -0
  99. package/dist/mdx-plugins/remark-npm.js +76 -0
  100. package/dist/mdx-plugins/remark-steps.d.ts +2 -0
  101. package/dist/mdx-plugins/remark-steps.js +93 -0
  102. package/dist/mdx-plugins/remark-structure.d.ts +2 -0
  103. package/dist/mdx-plugins/remark-structure.js +118 -0
  104. package/dist/mdx-plugins/stringifier.d.ts +2 -0
  105. package/dist/mdx-plugins/stringifier.js +91 -0
  106. package/dist/mdx-plugins/transformer-icon.d.ts +2 -0
  107. package/dist/mdx-plugins/transformer-icon.js +145 -0
  108. package/dist/negotiation/index.d.ts +17 -0
  109. package/dist/negotiation/index.js +378 -0
  110. package/dist/page-tree/index.d.ts +3 -0
  111. package/dist/page-tree/index.js +2 -0
  112. package/dist/path-1H5VzYiT.js +75 -0
  113. package/dist/rehype-code-D-RFJb9W.d.ts +14 -0
  114. package/dist/rehype-code.core-BUwNuchP.js +548 -0
  115. package/dist/rehype-code.core-BjH1uHWj.d.ts +115 -0
  116. package/dist/rehype-toc-K51AGb5U.d.ts +43 -0
  117. package/dist/remark-admonition-BwTcmI_S.d.ts +20 -0
  118. package/dist/remark-code-tab-DE_4bdnu.d.ts +34 -0
  119. package/dist/remark-directive-admonition-BLiJ5l43.d.ts +27 -0
  120. package/dist/remark-feedback-block-BxtINXN-.d.ts +45 -0
  121. package/dist/remark-gfm-DpVfAX1x.d.ts +2 -0
  122. package/dist/remark-heading-DEIzTkU5.d.ts +33 -0
  123. package/dist/remark-image-BI2S9LOb.d.ts +57 -0
  124. package/dist/remark-llms-bD3WvU2V.d.ts +73 -0
  125. package/dist/remark-mdx-files-Buvxc-sa.d.ts +54 -0
  126. package/dist/remark-mdx-mermaid-C1bCHHc6.d.ts +15 -0
  127. package/dist/remark-npm-BbpvkJaT.d.ts +31 -0
  128. package/dist/remark-steps-DqVEo0iq.d.ts +23 -0
  129. package/dist/remark-structure-CnHwvNZr.d.ts +87 -0
  130. package/dist/remove-markdown-DfKNMl9w.js +40 -0
  131. package/dist/remove-undefined-CzMSKybq.js +24 -0
  132. package/dist/rolldown-runtime-DC62tzP2.js +33 -0
  133. package/dist/search/algolia.d.ts +2 -0
  134. package/dist/search/algolia.js +75 -0
  135. package/dist/search/client/algolia.d.ts +2 -0
  136. package/dist/search/client/algolia.js +53 -0
  137. package/dist/search/client/fetch.d.ts +2 -0
  138. package/dist/search/client/fetch.js +28 -0
  139. package/dist/search/client/flexsearch-static.d.ts +2 -0
  140. package/dist/search/client/flexsearch-static.js +42 -0
  141. package/dist/search/client/mixedbread.d.ts +2 -0
  142. package/dist/search/client/mixedbread.js +65 -0
  143. package/dist/search/client/orama-cloud-legacy.d.ts +2 -0
  144. package/dist/search/client/orama-cloud-legacy.js +84 -0
  145. package/dist/search/client/orama-cloud.d.ts +2 -0
  146. package/dist/search/client/orama-cloud.js +86 -0
  147. package/dist/search/client/orama-static.d.ts +2 -0
  148. package/dist/search/client/orama-static.js +75 -0
  149. package/dist/search/client.d.ts +2 -0
  150. package/dist/search/client.js +97 -0
  151. package/dist/search/flexsearch.d.ts +56 -0
  152. package/dist/search/flexsearch.js +128 -0
  153. package/dist/search/index.d.ts +2 -0
  154. package/dist/search/index.js +74 -0
  155. package/dist/search/mixedbread.d.ts +49 -0
  156. package/dist/search/mixedbread.js +77 -0
  157. package/dist/search/orama-cloud-legacy.d.ts +75 -0
  158. package/dist/search/orama-cloud-legacy.js +48 -0
  159. package/dist/search/orama-cloud.d.ts +75 -0
  160. package/dist/search/orama-cloud.js +50 -0
  161. package/dist/search/server.d.ts +2 -0
  162. package/dist/search/server.js +237 -0
  163. package/dist/server-CCqACwlF.d.ts +165 -0
  164. package/dist/server.browser.d.ts +13 -0
  165. package/dist/server.browser.js +22 -0
  166. package/dist/server.d.ts +42 -0
  167. package/dist/server.js +398 -0
  168. package/dist/source/client/index.d.ts +2 -0
  169. package/dist/source/client/index.js +37 -0
  170. package/dist/source/dynamic.d.ts +2 -0
  171. package/dist/source/dynamic.js +2 -0
  172. package/dist/source/index.d.ts +2 -0
  173. package/dist/source/index.js +5 -0
  174. package/dist/source/llms.d.ts +2 -0
  175. package/dist/source/llms.js +74 -0
  176. package/dist/source/plugins/lucide-icons.d.ts +11 -0
  177. package/dist/source/plugins/lucide-icons.js +21 -0
  178. package/dist/source/plugins/slugs.d.ts +2 -0
  179. package/dist/source/plugins/slugs.js +75 -0
  180. package/dist/source/plugins/status-badges.d.ts +50 -0
  181. package/dist/source/plugins/status-badges.js +52 -0
  182. package/dist/source/schema.d.ts +30 -0
  183. package/dist/source/schema.js +28 -0
  184. package/dist/stringifier-B_QUcUyo.d.ts +63 -0
  185. package/dist/toc-CtW5lwA1.d.ts +64 -0
  186. package/dist/toc.d.ts +2 -0
  187. package/dist/toc.js +245 -0
  188. package/dist/transformer-icon-DlrneIS3.d.ts +17 -0
  189. package/dist/types-D89QoQR-.d.ts +4 -0
  190. package/dist/url-BVHvi3_K.js +29 -0
  191. package/dist/util-BDsqOxh3.d.ts +6 -0
  192. package/dist/util-DjBr9b3w.js +8 -0
  193. package/dist/utils/use-media-query.d.ts +4 -0
  194. package/dist/utils/use-media-query.js +20 -0
  195. package/dist/utils/use-on-change.d.ts +9 -0
  196. package/dist/utils/use-on-change.js +17 -0
  197. package/dist/utils-Bvy3V-fv.js +59 -0
  198. package/dist/utils-Cgs-6U-z.js +39 -0
  199. package/dist/utils-DEVq3cEC.js +151 -0
  200. package/dist/utils-Yx0IL9eW.js +48 -0
  201. package/package.json +251 -0
@@ -0,0 +1,17 @@
1
+ //#region src/source/plugins/icon.ts
2
+ function iconPlugin(resolveIcon) {
3
+ function replaceIcon(node) {
4
+ if (node.icon === void 0 || typeof node.icon === "string") node.icon = resolveIcon(node.icon);
5
+ return node;
6
+ }
7
+ return {
8
+ name: "fumadocs:icon",
9
+ transformPageTree: {
10
+ file: replaceIcon,
11
+ folder: replaceIcon,
12
+ separator: replaceIcon
13
+ }
14
+ };
15
+ }
16
+ //#endregion
17
+ export { iconPlugin as t };
@@ -0,0 +1,18 @@
1
+ import { i as Root } from "./definitions-CFOhwE1k.js";
2
+ import "./index-E8Qh_yQs.js";
3
+ //#region src/source/client/index.d.ts
4
+ interface SerializedPageTree {
5
+ $fumadocs_loader: 'page-tree';
6
+ data: object;
7
+ }
8
+ type Serialized<Data> = { [K in keyof Data]: Data[K] extends SerializedPageTree ? Root : Data[K]; };
9
+ declare function deserializePageTree(serialized: SerializedPageTree): Root;
10
+ /**
11
+ * Deserialize loader data that is serialized by the server-side Fumadocs `loader()`, supported:
12
+ * - Page Tree
13
+ *
14
+ * other unrelated properties are kept in the output.
15
+ */
16
+ declare function useFumadocsLoader<V>(serialized: V): Serialized<V>;
17
+ //#endregion
18
+ export { useFumadocsLoader as i, SerializedPageTree as n, deserializePageTree as r, Serialized as t };
@@ -0,0 +1,36 @@
1
+ import { ReactNode } from "react";
2
+ //#region src/search/index.d.ts
3
+ interface SortedResult<Content = string> {
4
+ id: string;
5
+ url: string;
6
+ type: 'page' | 'heading' | 'text';
7
+ content: Content;
8
+ /**
9
+ * breadcrumbs to be displayed on UI
10
+ */
11
+ breadcrumbs?: Content[];
12
+ /**
13
+ * @deprecated it is now included in `content` as Markdown using `<mark />`.
14
+ */
15
+ contentWithHighlights?: HighlightedText<Content>[];
16
+ }
17
+ type ReactSortedResult = SortedResult<ReactNode>;
18
+ interface HighlightedText<Content = string> {
19
+ type: 'text';
20
+ content: Content;
21
+ styles?: {
22
+ highlight?: boolean;
23
+ };
24
+ }
25
+ declare function createContentHighlighter(query: string | RegExp): {
26
+ /**
27
+ * @deprecated use `highlightMarkdown()` instead.
28
+ */
29
+ highlight(content: string): HighlightedText[];
30
+ /**
31
+ * @param content - Markdown, it assumes the content is already sanitized & safe, no escape is performed.
32
+ */
33
+ highlightMarkdown(content: string): string;
34
+ };
35
+ //#endregion
36
+ export { createContentHighlighter as i, ReactSortedResult as n, SortedResult as r, HighlightedText as t };
@@ -0,0 +1,21 @@
1
+ import { t as Awaitable } from "./types-D89QoQR-.js";
2
+ import { Root } from "hast";
3
+ import { BundledLanguage, BundledTheme, CodeOptionsMeta, CodeOptionsThemes, CodeToHastOptionsCommon, HighlighterCore } from "shiki";
4
+ //#region src/highlight/shiki/index.d.ts
5
+ interface InitOptions {
6
+ langAlias?: Record<string, string>;
7
+ }
8
+ /**
9
+ * A factory for Fumadocs to manage Shiki instances.
10
+ */
11
+ interface ShikiFactory {
12
+ init: (options?: InitOptions) => Awaitable<HighlighterCore>;
13
+ getOrInit: () => Awaitable<HighlighterCore>;
14
+ }
15
+ declare function createShikiFactory(config: Pick<ShikiFactory, 'init'>): ShikiFactory;
16
+ type HighlightHastOptions = CodeToHastOptionsCommon<BundledLanguage> & CodeOptionsMeta & CodeOptionsThemes<BundledTheme> & {
17
+ fallbackLanguage?: BundledLanguage | (string & {});
18
+ };
19
+ declare function highlightHast(highlighter: HighlighterCore, code: string, options: HighlightHastOptions): Promise<Root>;
20
+ //#endregion
21
+ export { highlightHast as i, ShikiFactory as n, createShikiFactory as r, HighlightHastOptions as t };
@@ -0,0 +1,16 @@
1
+ import "./remark-gfm-DpVfAX1x.js";
2
+ import "./rehype-code-D-RFJb9W.js";
3
+ import "./remark-image-BI2S9LOb.js";
4
+ import "./remark-structure-CnHwvNZr.js";
5
+ import "./remark-heading-DEIzTkU5.js";
6
+ import "./remark-admonition-BwTcmI_S.js";
7
+ import "./remark-directive-admonition-BLiJ5l43.js";
8
+ import "./rehype-toc-K51AGb5U.js";
9
+ import "./remark-code-tab-DE_4bdnu.js";
10
+ import "./remark-steps-DqVEo0iq.js";
11
+ import "./remark-npm-BbpvkJaT.js";
12
+ import "./codeblock-utils-CyP8qsYv.js";
13
+ import "./remark-mdx-files-Buvxc-sa.js";
14
+ import "./remark-mdx-mermaid-C1bCHHc6.js";
15
+ import "./remark-feedback-block-BxtINXN-.js";
16
+ import "./remark-llms-bD3WvU2V.js";
@@ -0,0 +1,513 @@
1
+ import { a as Separator, i as Root, n as Item, r as Node, t as Folder } from "./definitions-CFOhwE1k.js";
2
+ import { t as Awaitable } from "./types-D89QoQR-.js";
3
+ import { i as StructuredData } from "./remark-structure-CnHwvNZr.js";
4
+ import "./index-DAYtLGbx.js";
5
+ import { n as I18nConfig } from "./index-DydiXvgS.js";
6
+ import "./index-E8Qh_yQs.js";
7
+ import { n as SerializedPageTree } from "./index-B-0R0VbS.js";
8
+ import { ReactNode } from "react";
9
+ //#region src/source/storage/file-system.d.ts
10
+ /**
11
+ * In memory file system.
12
+ */
13
+ declare class FileSystem<File> {
14
+ files: Map<string, File>;
15
+ folders: Map<string, string[]>;
16
+ constructor(inherit?: FileSystem<File>);
17
+ read(path: string): File | undefined;
18
+ /**
19
+ * get the direct children of folder (in virtual file path)
20
+ */
21
+ readDir(path: string): string[] | undefined;
22
+ write(path: string, file: File): void;
23
+ /**
24
+ * Delete files at specified path.
25
+ *
26
+ * @param path - the target path.
27
+ * @param [recursive=false] - if set to `true`, it will also delete directories.
28
+ */
29
+ delete(path: string, recursive?: boolean): boolean;
30
+ getFiles(): string[];
31
+ makeDir(path: string): void;
32
+ }
33
+ //#endregion
34
+ //#region src/source/storage/content.d.ts
35
+ type ContentStorage<P extends ContentStoragePageFile = ContentStoragePageFile, M extends ContentStorageMetaFile = ContentStorageMetaFile> = FileSystem<P | M> & {
36
+ /** always `undefined`, for inferring types only */
37
+ $inferPage: P;
38
+ /** always `undefined`, for inferring types only */
39
+ $inferMeta: M;
40
+ };
41
+ /** @internal */
42
+ interface ContentStorageMetaFile<Type extends string | undefined = string | undefined, Data extends MetaData = MetaData> {
43
+ type: Type;
44
+ path: string;
45
+ absolutePath?: string;
46
+ format: 'meta';
47
+ data: Data;
48
+ }
49
+ /** @internal */
50
+ interface ContentStoragePageFile<Type extends string | undefined = string | undefined, Data extends PageData = PageData> {
51
+ type: Type;
52
+ path: string;
53
+ absolutePath?: string;
54
+ format: 'page';
55
+ slugs: string[];
56
+ data: Data;
57
+ }
58
+ //#endregion
59
+ //#region src/source/page-tree/builder.d.ts
60
+ interface PageTreeBuilderContext<S extends ContentStorage = ContentStorage> {
61
+ transformers: PageTreeTransformer<S>[];
62
+ builder: PageTreeBuilder;
63
+ storage: S;
64
+ storages?: Record<string, S>;
65
+ locale?: string;
66
+ custom?: Record<string, unknown>;
67
+ options: PageTreeOptions<S>;
68
+ }
69
+ interface PageTreeTransformer<S extends ContentStorage = ContentStorage> {
70
+ file?: (this: PageTreeBuilderContext<S>, node: Item, filePath?: string) => Item;
71
+ folder?: (this: PageTreeBuilderContext<S>, node: Folder, folderPath: string, metaPath?: string) => Folder;
72
+ separator?: (this: PageTreeBuilderContext<S>, node: Separator) => Separator;
73
+ root?: (this: PageTreeBuilderContext<S>, node: Root) => Root;
74
+ }
75
+ interface PageTreeOptions<S extends ContentStorage = ContentStorage> {
76
+ /** generate URL from page */
77
+ url: ResolvedLoaderConfig['url'];
78
+ idPrefix?: string;
79
+ /**
80
+ * Remove references to the file path of original nodes (`$ref`)
81
+ *
82
+ * @defaultValue false
83
+ */
84
+ noRef?: boolean;
85
+ /**
86
+ * generate fallback page tree
87
+ *
88
+ * @defaultValue true
89
+ */
90
+ generateFallback?: boolean;
91
+ /**
92
+ * Additional page tree transformers to apply
93
+ */
94
+ transformers?: PageTreeTransformer<S>[];
95
+ /** custom context */
96
+ context?: Record<string, unknown>;
97
+ /** customize the default sorting behaviour (`localeCompare`) */
98
+ sort?: {
99
+ /** @default 'path' */
100
+ by?: 'name' | 'path';
101
+ locales?: Intl.LocalesArgument;
102
+ options?: Intl.CollatorOptions;
103
+ };
104
+ }
105
+ interface PageTreeBuilder {
106
+ resolveFlattenPath(name: string, format: string): string;
107
+ root(id?: string, path?: string): Root;
108
+ }
109
+ //#endregion
110
+ //#region src/source/plugins/slugs.d.ts
111
+ /**
112
+ * a function to generate slugs, return `undefined` to generate default slugs.
113
+ *
114
+ * conflicting cases like `dir/index.mdx` vs `dir.mdx` are resolved after the function returns.
115
+ *
116
+ * @param next - generate the default slugs from file path (before conflict resolution).
117
+ */
118
+ type SlugFn<S extends ContentStorage = ContentStorage> = (file: S['$inferPage'], next: () => string[]) => string[] | undefined;
119
+ interface SlugsPluginOptions<S extends ContentStorage = ContentStorage> {
120
+ /** Slugs to prepend to every page. */
121
+ baseSlugs?: string[];
122
+ /** generate default slugs for pages */
123
+ slugs?: SlugFn<S>;
124
+ }
125
+ /**
126
+ * Generate slugs for pages if missing.
127
+ */
128
+ declare function slugsPlugin(optsOrFn?: SlugsPluginOptions | SlugFn): LoaderPlugin;
129
+ /**
130
+ * Generate slugs from file data (e.g. frontmatter).
131
+ *
132
+ * @param key - the property name in file data to generate slugs, default to `slug`.
133
+ */
134
+ declare function slugsFromData(key?: string): SlugFn;
135
+ /**
136
+ * Convert file path into slugs, also encode non-ASCII characters, so they can work in pathname
137
+ */
138
+ declare function getSlugs(file: string): string[];
139
+ //#endregion
140
+ //#region src/source/plugins/icon.d.ts
141
+ type IconResolver = (icon: string | undefined) => ReactNode;
142
+ declare namespace types_d_exports {
143
+ export { AnyInput, GenerateMeta, GenerateMetaFile, GeneratePage, GeneratePageFile, GenerateStorage };
144
+ }
145
+ type AnyInput = SourceUnion | Record<string, SourceUnion>;
146
+ type GeneratePage<T extends AnyInput> = T extends Record<infer K extends string, SourceUnion> ? { [k in K]: T[k] extends SourceUnion<infer D> ? Page<k, D['pageData']> : never; }[K] : T extends SourceUnion<infer D> ? Page<undefined, D['pageData']> : never;
147
+ type GenerateMeta<T extends AnyInput> = T extends Record<infer K extends string, SourceUnion> ? { [k in K]: T[k] extends SourceUnion<infer D> ? Meta<k, D['metaData']> : never; }[K] : T extends SourceUnion<infer D> ? Meta<undefined, D['metaData']> : never;
148
+ type GeneratePageFile<T extends AnyInput> = T extends Record<infer K extends string, SourceUnion> ? { [k in K]: T[k] extends SourceUnion<infer D> ? ContentStoragePageFile<k, D['pageData']> : never; }[K] : T extends SourceUnion<infer D> ? ContentStoragePageFile<undefined, D['pageData']> : never;
149
+ type GenerateMetaFile<T extends AnyInput> = T extends Record<infer K extends string, SourceUnion> ? { [k in K]: T[k] extends SourceUnion<infer D> ? ContentStorageMetaFile<k, D['metaData']> : never; }[K] : T extends SourceUnion<infer D> ? ContentStorageMetaFile<undefined, D['metaData']> : never;
150
+ type GenerateStorage<T extends AnyInput> = ContentStorage<GeneratePageFile<T>, GenerateMetaFile<T>>;
151
+ //#endregion
152
+ //#region src/source/loader.d.ts
153
+ type ResolvedInput = StaticSource | Record<string, StaticSource>;
154
+ interface LoaderConfig {
155
+ page: Page;
156
+ meta: Meta;
157
+ i18n: I18nConfig | undefined;
158
+ }
159
+ interface LoaderOptions<S extends ContentStorage = ContentStorage, I18n extends I18nConfig | undefined = I18nConfig | undefined> extends SlugsPluginOptions<S> {
160
+ baseUrl: string;
161
+ i18n?: I18n;
162
+ url?: (slugs: string[], locale?: string) => string;
163
+ /**
164
+ * Additional options for page tree builder
165
+ */
166
+ pageTree?: Partial<PageTreeOptions<S>>;
167
+ plugins?: LoaderPluginOption[] | ((context: {
168
+ typedPlugin: (plugin: LoaderPlugin<S>) => LoaderPlugin;
169
+ }) => LoaderPluginOption[]);
170
+ icon?: IconResolver;
171
+ }
172
+ interface ResolvedLoaderConfig {
173
+ input: ResolvedInput;
174
+ url: (slugs: string[], locale?: string) => string;
175
+ plugins: LoaderPlugin[];
176
+ pageTree?: Partial<PageTreeOptions>;
177
+ i18n?: I18nConfig | undefined;
178
+ }
179
+ interface SharedFileInfo {
180
+ /**
181
+ * Virtualized file path (relative to content directory)
182
+ *
183
+ * @example `docs/page.mdx`
184
+ */
185
+ path: string;
186
+ /**
187
+ * Absolute path of the file
188
+ */
189
+ absolutePath?: string;
190
+ }
191
+ interface Page<Type extends string | undefined = string | undefined, Data extends PageData = PageData> extends SharedFileInfo {
192
+ type: Type;
193
+ slugs: string[];
194
+ url: string;
195
+ data: Data;
196
+ locale?: string | undefined;
197
+ }
198
+ interface Meta<Type extends string | undefined = string | undefined, Data extends MetaData = MetaData> extends SharedFileInfo {
199
+ type: Type;
200
+ data: Data;
201
+ }
202
+ interface LoaderOutput<Config extends LoaderConfig = LoaderConfig> {
203
+ readonly $inferPage: Config['page'];
204
+ readonly $inferMeta: Config['meta'];
205
+ readonly $infer: Config;
206
+ pageTree: Config['i18n'] extends I18nConfig ? Record<string, Root> : Root;
207
+ getPageTree: (locale?: string) => Root;
208
+ /**
209
+ * get referenced page from href, supported:
210
+ *
211
+ * - relative file paths, like `./my/page.mdx`.
212
+ * - generated page pathname, like `/docs/my/page`.
213
+ */
214
+ getPageByHref: (href: string, options?: {
215
+ language?: string;
216
+ /**
217
+ * resolve relative file paths in `href` from specified dirname, must be a virtual path.
218
+ */
219
+ dir?: string;
220
+ }) => {
221
+ page: Config['page'];
222
+ hash?: string;
223
+ } | undefined;
224
+ /**
225
+ * resolve special hrefs in a page, including:
226
+ *
227
+ * - relative file paths, like `./my/page.mdx`.
228
+ */
229
+ resolveHref: (href: string, parent: Config['page']) => string;
230
+ /**
231
+ * @internal
232
+ */
233
+ _i18n?: I18nConfig;
234
+ /**
235
+ * Get a list of pages from specified language
236
+ *
237
+ * @param language - If unspecified, list pages from all languages.
238
+ */
239
+ getPages: (language?: string) => Config['page'][];
240
+ /**
241
+ * get each language and its pages, empty if i18n is not enabled.
242
+ */
243
+ getLanguages: () => {
244
+ language: string;
245
+ pages: Config['page'][];
246
+ }[];
247
+ /**
248
+ * Get page with slugs, the slugs can also be URI encoded.
249
+ *
250
+ * @param language - If unspecified, the default language will be used.
251
+ */
252
+ getPage: (slugs: string[] | undefined, language?: string) => Config['page'] | undefined;
253
+ getNodePage: (node: Item, language?: string) => Config['page'] | undefined;
254
+ getNodeMeta: (node: Folder | Root, language?: string) => Config['meta'] | undefined;
255
+ /**
256
+ * generate static params for Next.js SSG
257
+ *
258
+ * @param slug - customize parameter name for slugs
259
+ * @param lang - customize parameter name for lang
260
+ */
261
+ generateParams: <TSlug extends string = 'slug', TLang extends string = 'lang'>(slug?: TSlug, lang?: TLang) => (Record<TSlug, string[]> & Record<TLang, string>)[];
262
+ /**
263
+ * serialize page tree for non-RSC environments
264
+ */
265
+ serializePageTree: (tree: Root) => Promise<SerializedPageTree>;
266
+ }
267
+ declare function createGetUrl(baseUrl: string, i18n?: I18nConfig): ResolvedLoaderConfig['url'];
268
+ /** content loader API for static content sources */
269
+ declare function loader<I extends ResolvedInput, I18n extends I18nConfig | undefined = undefined>(source: I, options: LoaderOptions<NoInfer<GenerateStorage<I>>, I18n>): LoaderOutput<{
270
+ meta: GenerateMeta<I>;
271
+ page: GeneratePage<I>;
272
+ i18n: I18n;
273
+ }>;
274
+ /** content loader API for static content sources */
275
+ declare function loader<I extends ResolvedInput, I18n extends I18nConfig | undefined = undefined>(options: LoaderOptions<NoInfer<GenerateStorage<I>>, I18n> & {
276
+ source: I;
277
+ }): LoaderOutput<{
278
+ meta: GenerateMeta<I>;
279
+ page: GeneratePage<I>;
280
+ i18n: I18n;
281
+ }>;
282
+ interface LoaderPlugin<S extends ContentStorage = ContentStorage> {
283
+ name?: string;
284
+ /**
285
+ * Change the order of plugin:
286
+ * - `pre`: before normal plugins
287
+ * - `post`: after normal plugins
288
+ */
289
+ enforce?: 'pre' | 'post';
290
+ /**
291
+ * receive & replace loader options
292
+ */
293
+ config?: (config: ResolvedLoaderConfig) => ResolvedLoaderConfig | void | undefined;
294
+ /**
295
+ * transform the storage after loading
296
+ */
297
+ transformStorage?: (context: {
298
+ storage: S;
299
+ }) => void;
300
+ /**
301
+ * transform the generated page tree
302
+ */
303
+ transformPageTree?: PageTreeTransformer<S>;
304
+ }
305
+ type LoaderPluginOption<S extends ContentStorage = ContentStorage> = LoaderPlugin<S> | LoaderPluginOption<S>[] | undefined;
306
+ type InferPageType<Utils extends LoaderOutput<any>> = Utils['$inferPage'];
307
+ type InferMetaType<Utils extends LoaderOutput<any>> = Utils['$inferMeta'];
308
+ //#endregion
309
+ //#region src/source/dynamic.d.ts
310
+ interface DynamicLoaderConfig extends LoaderConfig {
311
+ source: string | undefined;
312
+ }
313
+ interface DynamicLoader<Config extends DynamicLoaderConfig = DynamicLoaderConfig> {
314
+ get: () => Promise<LoaderOutput<Config>>;
315
+ /** invalidate & re-compute dynamic sources immediately */
316
+ revalidate: (source?: Config['source']) => Promise<void>;
317
+ /** remove computed cache of dynamic sources */
318
+ invalidate: (source?: Config['source']) => void;
319
+ get $inferPage(): Config['page'];
320
+ get $inferMeta(): Config['meta'];
321
+ }
322
+ /** content loader API for static & dynamic content sources, with in-memory cache. */
323
+ declare function dynamicLoader<I extends SourceUnion | Record<string, SourceUnion>, I18n extends I18nConfig | undefined = undefined>(input: I, options: LoaderOptions<NoInfer<GenerateStorage<I>>, I18n>): DynamicLoader<{
324
+ i18n: I18n;
325
+ meta: NoInfer<GenerateMeta<I>>;
326
+ page: NoInfer<GeneratePage<I>>;
327
+ source: I extends Record<infer K, SourceUnion> ? K : undefined;
328
+ }>;
329
+ //#endregion
330
+ //#region src/source/source.d.ts
331
+ type SourceUnion<Config extends SourceConfig = SourceConfig> = StaticSource<Config> | DynamicSource<Config>;
332
+ /**
333
+ * @deprecated use `StaticSource<Config>` instead
334
+ */
335
+ type Source<Config extends SourceConfig = SourceConfig> = StaticSource<Config>;
336
+ interface GenericSourceOptions {
337
+ /** the base directory for generated virtual files */
338
+ baseDir?: string;
339
+ /**
340
+ * when the source is attached to a new static loader, before loader output is accessible.
341
+ *
342
+ * can be called multiple times when attached to a dynamic loader.
343
+ **/
344
+ configureStatic?: (opts: {
345
+ loader: LoaderOutput;
346
+ source?: string;
347
+ }) => void;
348
+ /**
349
+ * when the source is attached to a dynamic loader.
350
+ *
351
+ * called at most once for each source object.
352
+ **/
353
+ configureDynamic?: (opts: {
354
+ loader: DynamicLoader;
355
+ source?: string;
356
+ }) => void;
357
+ }
358
+ interface StaticSource<Config extends SourceConfig = SourceConfig> extends GenericSourceOptions {
359
+ files: VirtualFile<Config>[];
360
+ }
361
+ /** one dynamic source object can only be used by one dynamic loader */
362
+ type DynamicSource<Config extends SourceConfig = SourceConfig> = GenericSourceOptions & {
363
+ /**
364
+ * - `memory`: the dynamic loader's in-memory cache handles caching.
365
+ * - `custom`: the source handles caching itself. When the newer result of `files()` is (shallowly) different from the previous result, the source is considered revalidated, and all associated properties will be re-computed.
366
+ *
367
+ * @default 'memory'
368
+ **/
369
+ cache?: 'memory' | 'custom';
370
+ files: () => Awaitable<VirtualFile<Config>[]>;
371
+ /** @deprecated use `configureDynamic` instead */
372
+ configure?: (loader: DynamicLoader, opts: {
373
+ source?: string;
374
+ }) => void;
375
+ /** when the source is invalidated */
376
+ invalidate?: () => void;
377
+ } & ({
378
+ cache?: 'memory';
379
+ /** enable time-based revalidation, the previous result will be stale after the specified duration (ms) */
380
+ staleTime?: number;
381
+ } | {
382
+ cache: 'custom';
383
+ });
384
+ type SourceConfig = {
385
+ pageData: PageData;
386
+ metaData: MetaData;
387
+ };
388
+ interface MetaData {
389
+ icon?: string | undefined;
390
+ title?: string | undefined;
391
+ root?: boolean | string | undefined;
392
+ pages?: string[] | undefined;
393
+ pagesIndex?: string | undefined;
394
+ defaultOpen?: boolean | undefined;
395
+ collapsible?: boolean | undefined;
396
+ description?: string | undefined;
397
+ }
398
+ interface PageData {
399
+ icon?: string | undefined;
400
+ title?: string | undefined;
401
+ description?: string | undefined;
402
+ structuredData?: StructuredData | (() => Awaitable<StructuredData>) | undefined;
403
+ }
404
+ type VirtualFile<Config extends SourceConfig = SourceConfig> = VirtualPage<Config['pageData']> | VirtualMeta<Config['metaData']>;
405
+ interface BaseVirtualFile {
406
+ /**
407
+ * Virtualized path (relative to content directory)
408
+ *
409
+ * @example `docs/page.mdx`
410
+ */
411
+ path: string;
412
+ /**
413
+ * Absolute path of the file
414
+ */
415
+ absolutePath?: string;
416
+ }
417
+ interface VirtualPage<Data extends PageData> extends BaseVirtualFile {
418
+ type: 'page';
419
+ /**
420
+ * Specified Slugs for page
421
+ */
422
+ slugs?: string[];
423
+ data: Data;
424
+ }
425
+ interface VirtualMeta<Data extends MetaData> extends BaseVirtualFile {
426
+ type: 'meta';
427
+ data: Data;
428
+ }
429
+ /**
430
+ * @deprecated you can directly pass a record of source objects to `loader()`.
431
+ */
432
+ declare function multiple<T extends Record<string, StaticSource>>(sources: T): T extends Record<infer K extends string, StaticSource> ? { [k in K]: T[k] extends StaticSource<infer C> ? StaticSource<{
433
+ metaData: C['metaData'] & {
434
+ type: k;
435
+ };
436
+ pageData: C['pageData'] & {
437
+ type: k;
438
+ };
439
+ }> : never; } : never;
440
+ interface SourceUpdater<Config extends SourceConfig> {
441
+ files: <Page extends PageData, Meta extends MetaData>(fn: (files: VirtualFile<Config>[]) => (VirtualPage<Page> | VirtualMeta<Meta>)[]) => SourceUpdater<{
442
+ pageData: Page;
443
+ metaData: Meta;
444
+ }>;
445
+ page: <V extends PageData>(fn: (page: VirtualPage<Config['pageData']>) => VirtualPage<V>) => SourceUpdater<{
446
+ pageData: V;
447
+ metaData: Config['metaData'];
448
+ }>;
449
+ meta: <V extends MetaData>(fn: (meta: VirtualMeta<Config['metaData']>) => VirtualMeta<V>) => SourceUpdater<{
450
+ pageData: Config['pageData'];
451
+ metaData: V;
452
+ }>;
453
+ build: () => StaticSource<Config>;
454
+ }
455
+ /**
456
+ * update a **static** source object in-place.
457
+ */
458
+ declare function update<Config extends SourceConfig>(source: StaticSource<Config>): SourceUpdater<Config>;
459
+ declare namespace path_d_exports {
460
+ export { basename, dirname, extname, joinPath, normalize, slash, splitPath };
461
+ }
462
+ declare function basename(path: string, ext?: string): string;
463
+ declare function extname(path: string): string;
464
+ declare function dirname(path: string): string;
465
+ /**
466
+ * Split path into segments, trailing/leading slashes are removed
467
+ */
468
+ declare function splitPath(path: string): string[];
469
+ /**
470
+ * Resolve paths, slashes within the path will be ignored
471
+ * @param paths - Paths to join
472
+ * @example
473
+ * ```
474
+ * ['a','b'] // 'a/b'
475
+ * ['/a'] // 'a'
476
+ * ['a', '/b'] // 'a/b'
477
+ * ['a', '../b/c'] // 'b/c'
478
+ * ```
479
+ */
480
+ declare function joinPath(...paths: string[]): string;
481
+ declare function slash(path: string): string;
482
+ /**
483
+ * Convert (relative) file path to virtual file path.
484
+ *
485
+ * @param path - Relative path
486
+ * @returns Normalized path, with no trailing/leading slashes
487
+ * @throws Throws error if path starts with `./` or `../`
488
+ */
489
+ declare function normalize(path: string): string;
490
+ //#endregion
491
+ //#region src/source/llms.d.ts
492
+ interface Context {
493
+ lang?: string;
494
+ }
495
+ interface LLMsConfig {
496
+ TAB?: string;
497
+ renderName?: (item: Node | Root, ctx: Context) => string;
498
+ renderDescription?: (item: Root | Item | Folder, ctx: Context) => string;
499
+ }
500
+ declare function llms<C extends LoaderConfig = LoaderConfig>(loader: LoaderOutput<C>, config?: LLMsConfig): {
501
+ /**
502
+ * generate `llms.txt` content in Markdown format.
503
+ *
504
+ * use `indexNode(node)` instead for more control (e.g. add extra sections to output).
505
+ */
506
+ index: (lang?: string) => string;
507
+ /**
508
+ * generate `llms.txt` content for a single page tree node.
509
+ */
510
+ indexNode(node: Node, lang?: string): string;
511
+ };
512
+ //#endregion
513
+ export { SlugsPluginOptions as A, ContentStoragePageFile as B, Meta as C, loader as D, createGetUrl as E, PageTreeBuilderContext as F, PageTreeOptions as I, PageTreeTransformer as L, slugsFromData as M, slugsPlugin as N, types_d_exports as O, PageTreeBuilder as P, ContentStorage as R, LoaderPluginOption as S, ResolvedLoaderConfig as T, FileSystem as V, InferPageType as _, MetaData as a, LoaderOutput as b, SourceUnion as c, multiple as d, update as f, InferMetaType as g, dynamicLoader as h, DynamicSource as i, getSlugs as j, SlugFn as k, StaticSource as l, DynamicLoaderConfig as m, llms as n, PageData as o, DynamicLoader as p, path_d_exports as r, Source as s, LLMsConfig as t, VirtualFile as u, LoaderConfig as v, Page as w, LoaderPlugin as x, LoaderOptions as y, ContentStorageMetaFile as z };