@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,237 @@
1
+ import { n as defaultReadOptions, t as createEndpoint } from "../endpoint-MyoBU5IC.js";
2
+ import { n as buildBreadcrumbs, r as buildIndexDefault, t as buildDocuments } from "../build-doc-4OvfjVN2.js";
3
+ import { n as searchSimple, t as searchAdvanced } from "../advanced-Ct13khZr.js";
4
+ import { create, insertMultipleAsync, save } from "zbsearch";
5
+ //#region src/search/zbsearch/create-db.ts
6
+ const simpleSchema = {
7
+ url: "string",
8
+ title: "string",
9
+ breadcrumbs: "string[]",
10
+ description: "string",
11
+ content: "string",
12
+ keywords: "string",
13
+ locale: "enum"
14
+ };
15
+ const advancedSchema = {
16
+ content: "string",
17
+ page_id: "string",
18
+ type: "string",
19
+ breadcrumbs: "string[]",
20
+ tags: "enum[]",
21
+ url: "string",
22
+ locale: "enum",
23
+ embeddings: "vector[512]"
24
+ };
25
+ const DefaultLanguage = "multilingual";
26
+ async function createDB({ indexes, tokenizer, language = DefaultLanguage, search: _, localeFilter: __, ...rest }) {
27
+ const items = typeof indexes === "function" ? await indexes() : indexes;
28
+ const resolvedTokenizer = tokenizer ?? rest.components?.tokenizer;
29
+ const db = create({
30
+ schema: advancedSchema,
31
+ language: resolvedTokenizer ? void 0 : language,
32
+ ...rest,
33
+ components: {
34
+ ...rest.components,
35
+ tokenizer: resolvedTokenizer
36
+ }
37
+ });
38
+ const mapTo = buildDocuments(items);
39
+ await insertMultipleAsync(db, mapTo);
40
+ return db;
41
+ }
42
+ async function createDBSimple({ indexes, tokenizer, language = DefaultLanguage, search: _, localeFilter: __, ...rest }) {
43
+ const items = typeof indexes === "function" ? await indexes() : indexes;
44
+ const resolvedTokenizer = tokenizer ?? rest.components?.tokenizer;
45
+ const db = create({
46
+ schema: simpleSchema,
47
+ language: resolvedTokenizer ? void 0 : language,
48
+ ...rest,
49
+ components: {
50
+ ...rest.components,
51
+ tokenizer: resolvedTokenizer
52
+ }
53
+ });
54
+ await insertMultipleAsync(db, items.map((page) => ({
55
+ title: page.title,
56
+ description: page.description,
57
+ breadcrumbs: page.breadcrumbs,
58
+ url: page.url,
59
+ content: page.content,
60
+ keywords: page.keywords,
61
+ locale: page.locale
62
+ })));
63
+ return db;
64
+ }
65
+ //#endregion
66
+ //#region src/search/zbsearch/create-server.ts
67
+ function initSimpleSearch(options) {
68
+ const doc = createDBSimple(options);
69
+ return {
70
+ async export() {
71
+ return {
72
+ type: "simple",
73
+ ...options.localeFilter ? { i18n: true } : null,
74
+ ...save(await doc)
75
+ };
76
+ },
77
+ async search(query, searchOptions = {}) {
78
+ const db = await doc;
79
+ const { limit, locale } = searchOptions;
80
+ return searchSimple(db, query, {
81
+ limit,
82
+ ...options.search
83
+ }, options.localeFilter && locale ? locale : void 0);
84
+ }
85
+ };
86
+ }
87
+ function initAdvancedSearch(options) {
88
+ const get = createDB(options);
89
+ return {
90
+ async export() {
91
+ return {
92
+ type: "advanced",
93
+ ...options.localeFilter ? { i18n: true } : null,
94
+ ...save(await get)
95
+ };
96
+ },
97
+ async search(query, searchOptions = {}) {
98
+ const db = await get;
99
+ const { limit, tag, mode, locale } = searchOptions;
100
+ return searchAdvanced(db, query, tag, {
101
+ ...options.search,
102
+ limit,
103
+ mode: mode === "vector" ? "vector" : "fulltext"
104
+ }, options.localeFilter && locale ? locale : void 0).catch((err) => {
105
+ if (mode === "vector") throw new Error("failed to search, make sure your indexes include `embeddings` and a plugin/proxy is configured to vectorize search terms.", { cause: err });
106
+ throw err;
107
+ });
108
+ }
109
+ };
110
+ }
111
+ function createSearchAPI(...args) {
112
+ return toAPI(args[0] === "simple" ? initSimpleSearch(args[1]) : initAdvancedSearch(args[1]));
113
+ }
114
+ function createI18nSearchAPI(...[type, options]) {
115
+ if (options.localeMap) return createI18nSearchAPILegacy(type, options);
116
+ const server = type === "simple" ? initSimpleSearch({
117
+ ...options,
118
+ localeFilter: true
119
+ }) : initAdvancedSearch({
120
+ ...options,
121
+ localeFilter: true
122
+ });
123
+ return toAPI({
124
+ export: server.export,
125
+ async search(query, searchOptions) {
126
+ return server.search(query, {
127
+ ...searchOptions,
128
+ locale: searchOptions?.locale ?? options.i18n.defaultLanguage
129
+ });
130
+ }
131
+ });
132
+ }
133
+ function createI18nSearchAPILegacy(type, options) {
134
+ async function initSearchServers() {
135
+ const map = /* @__PURE__ */ new Map();
136
+ if (options.i18n.languages.length === 0) return map;
137
+ const indexes = typeof options.indexes === "function" ? await options.indexes() : options.indexes;
138
+ for (const locale of options.i18n.languages) {
139
+ const localeIndexes = indexes.filter((index) => index.locale === locale);
140
+ const mapped = options.localeMap?.[locale] ?? "multilingual";
141
+ if (type === "simple") map.set(locale, typeof mapped === "object" ? initSimpleSearch({
142
+ ...options,
143
+ ...mapped,
144
+ indexes: localeIndexes
145
+ }) : initSimpleSearch({
146
+ ...options,
147
+ language: mapped,
148
+ indexes: localeIndexes
149
+ }));
150
+ else map.set(locale, typeof mapped === "object" ? initAdvancedSearch({
151
+ ...options,
152
+ indexes: localeIndexes,
153
+ ...mapped
154
+ }) : initAdvancedSearch({
155
+ ...options,
156
+ language: mapped,
157
+ indexes: localeIndexes
158
+ }));
159
+ }
160
+ return map;
161
+ }
162
+ const get = initSearchServers();
163
+ return toAPI({
164
+ async export() {
165
+ const map = await get;
166
+ const entries = Array.from(map.entries()).map(async ([k, v]) => [k, await v.export()]);
167
+ return {
168
+ type: "i18n",
169
+ data: Object.fromEntries(await Promise.all(entries))
170
+ };
171
+ },
172
+ async search(query, searchOptions) {
173
+ const map = await get;
174
+ const locale = searchOptions?.locale ?? options.i18n.defaultLanguage;
175
+ const handler = map.get(locale);
176
+ if (handler) return handler.search(query, searchOptions);
177
+ return [];
178
+ }
179
+ });
180
+ }
181
+ /**
182
+ * create server from loader, if passed as function, the server will re-index all records once a different instance of loader is returned.
183
+ */
184
+ function createFromSource(loader, options = {}) {
185
+ const { buildIndex = buildIndexDefault } = options;
186
+ const cache = /* @__PURE__ */ new WeakMap();
187
+ async function initServer(loader) {
188
+ const indexes = await Promise.all(loader.getPages().map(async (page) => {
189
+ const index = await buildIndex(page);
190
+ return {
191
+ ...index,
192
+ breadcrumbs: index.breadcrumbs ?? buildBreadcrumbs(loader, page),
193
+ locale: page.locale
194
+ };
195
+ }));
196
+ if (loader._i18n) return createI18nSearchAPI("advanced", {
197
+ ...options,
198
+ indexes,
199
+ i18n: loader._i18n
200
+ });
201
+ return initAdvancedSearch({
202
+ indexes,
203
+ ...options
204
+ });
205
+ }
206
+ async function getCurrentServer() {
207
+ const l = typeof loader === "function" ? await loader() : loader;
208
+ let server = cache.get(l);
209
+ if (!server) {
210
+ const promise = initServer(l);
211
+ promise.catch(() => {
212
+ if (cache.get(l) === promise) cache.delete(l);
213
+ });
214
+ cache.set(l, promise);
215
+ server = promise;
216
+ }
217
+ return await server;
218
+ }
219
+ return toAPI({
220
+ async export() {
221
+ return (await getCurrentServer()).export();
222
+ },
223
+ async search(query, options) {
224
+ return (await getCurrentServer()).search(query, options);
225
+ }
226
+ });
227
+ }
228
+ function toAPI(server) {
229
+ return createEndpoint(server, { readOptions(url) {
230
+ return {
231
+ ...defaultReadOptions(url),
232
+ mode: url.searchParams.get("mode") === "vector" ? "vector" : "full"
233
+ };
234
+ } });
235
+ }
236
+ //#endregion
237
+ export { createFromSource, createI18nSearchAPI, createSearchAPI, initAdvancedSearch, initSimpleSearch };
@@ -0,0 +1,165 @@
1
+ import { t as Awaitable } from "./types-D89QoQR-.js";
2
+ import { i as StructuredData } from "./remark-structure-CnHwvNZr.js";
3
+ import { n as I18nConfig } from "./index-DydiXvgS.js";
4
+ import { r as SortedResult } from "./index-BM36H-xw.js";
5
+ import { b as LoaderOutput, v as LoaderConfig } from "./index-DIwKCYOz.js";
6
+ import { Language, RawData, SearchParams, TypedDocument, ZBSearch, create } from "zbsearch";
7
+ //#region src/search/zbsearch/create-db.d.ts
8
+ type SimpleDocument = TypedDocument<ZBSearch<typeof simpleSchema>>;
9
+ declare const simpleSchema: {
10
+ readonly url: "string";
11
+ readonly title: "string";
12
+ readonly breadcrumbs: "string[]";
13
+ readonly description: "string";
14
+ readonly content: "string";
15
+ readonly keywords: "string";
16
+ readonly locale: "enum";
17
+ };
18
+ type AdvancedDocument = TypedDocument<ZBSearch<typeof advancedSchema>>;
19
+ declare const advancedSchema: {
20
+ readonly content: "string";
21
+ readonly page_id: "string";
22
+ readonly type: "string";
23
+ readonly breadcrumbs: "string[]";
24
+ readonly tags: "enum[]";
25
+ readonly url: "string";
26
+ readonly locale: "enum";
27
+ readonly embeddings: "vector[512]";
28
+ };
29
+ //#endregion
30
+ //#region src/search/server/build-index.d.ts
31
+ interface SharedIndex {
32
+ id: string;
33
+ title: string;
34
+ description?: string;
35
+ breadcrumbs?: string[];
36
+ /**
37
+ * Locale of content (for i18n)
38
+ */
39
+ locale?: string;
40
+ /**
41
+ * Required if tag filter is enabled
42
+ */
43
+ tag?: string | string[];
44
+ /**
45
+ * preprocess mdx content with `structure`
46
+ */
47
+ structuredData: StructuredData;
48
+ url: string;
49
+ }
50
+ //#endregion
51
+ //#region src/search/zbsearch/create-server.d.ts
52
+ type CreateInput = NonNullable<Parameters<typeof create>[0]>;
53
+ interface SharedOptions extends Pick<CreateInput, 'sort' | 'components' | 'plugins'> {
54
+ /**
55
+ * Tokenizer language.
56
+ *
57
+ * @defaultValue 'multilingual' - works with every language, zero config needed.
58
+ */
59
+ language?: string;
60
+ tokenizer?: Required<CreateInput>['components']['tokenizer'];
61
+ /**
62
+ * Filter search results by the `locale` query option, requires indexes to include a `locale` property.
63
+ *
64
+ * Enabled automatically by i18n search servers.
65
+ */
66
+ localeFilter?: boolean;
67
+ }
68
+ interface EngineQueryOptions extends QueryOptions {
69
+ mode?: 'full' | 'vector';
70
+ }
71
+ /**
72
+ * Resolve indexes dynamically
73
+ */
74
+ type Dynamic<T> = () => Awaitable<T[]>;
75
+ interface SimpleOptions extends SharedOptions {
76
+ indexes: Index[] | Dynamic<Index>;
77
+ /**
78
+ * Customize search options on server
79
+ */
80
+ search?: Partial<SearchParams<ZBSearch<typeof simpleSchema>, SimpleDocument>>;
81
+ }
82
+ interface AdvancedOptions extends SharedOptions {
83
+ indexes: AdvancedIndex[] | Dynamic<AdvancedIndex>;
84
+ /**
85
+ * Customize search options on server
86
+ */
87
+ search?: Partial<SearchParams<ZBSearch<typeof advancedSchema>, AdvancedDocument>>;
88
+ }
89
+ interface Index {
90
+ title: string;
91
+ description?: string;
92
+ breadcrumbs?: string[];
93
+ content: string;
94
+ url: string;
95
+ keywords?: string;
96
+ locale?: string;
97
+ }
98
+ type ExportedData = (RawData & {
99
+ type: 'simple' | 'advanced';
100
+ i18n?: boolean;
101
+ }) | {
102
+ type: 'i18n';
103
+ data: Record<string, RawData & {
104
+ type: 'simple' | 'advanced';
105
+ }>;
106
+ };
107
+ declare function initSimpleSearch(options: SimpleOptions): SearchServer<EngineQueryOptions>;
108
+ type AdvancedIndex = SharedIndex;
109
+ declare function initAdvancedSearch(options: AdvancedOptions): SearchServer<EngineQueryOptions>;
110
+ declare function createSearchAPI(type: 'simple', options: SimpleOptions): SearchAPI<EngineQueryOptions>;
111
+ declare function createSearchAPI(type: 'advanced', options: AdvancedOptions): SearchAPI<EngineQueryOptions>;
112
+ type I18nOptions<O extends SimpleOptions | AdvancedOptions, Idx> = Omit<O, 'language' | 'indexes'> & {
113
+ i18n: I18nConfig;
114
+ /**
115
+ * Map locale name from i18n config to a compatible `language` or options.
116
+ *
117
+ * @deprecated No longer needed - the default `multilingual` tokenizer supports every language with zero config.
118
+ * When specified, a separate database is created for each locale (legacy behaviour).
119
+ */
120
+ localeMap?: Record<string, Language | Partial<O> | undefined>;
121
+ indexes: WithLocale<Idx>[] | Dynamic<WithLocale<Idx>>;
122
+ };
123
+ type I18nSimpleOptions = I18nOptions<SimpleOptions, Index>;
124
+ type I18nAdvancedOptions = I18nOptions<AdvancedOptions, AdvancedIndex>;
125
+ type WithLocale<T> = T & {
126
+ locale: string;
127
+ };
128
+ declare function createI18nSearchAPI(type: 'simple', options: I18nSimpleOptions): SearchAPI<EngineQueryOptions>;
129
+ declare function createI18nSearchAPI(type: 'advanced', options: I18nAdvancedOptions): SearchAPI<EngineQueryOptions>;
130
+ interface Options<C extends LoaderConfig> extends Omit<AdvancedOptions, 'indexes'> {
131
+ /**
132
+ * @deprecated No longer needed - the default `multilingual` tokenizer supports every language with zero config.
133
+ */
134
+ localeMap?: { [K in C['i18n'] extends I18nConfig<infer Languages> ? Languages : string]?: Partial<AdvancedOptions> | Language; };
135
+ buildIndex?: (page: C['page']) => Awaitable<AdvancedIndex>;
136
+ }
137
+ /**
138
+ * create server from loader, if passed as function, the server will re-index all records once a different instance of loader is returned.
139
+ */
140
+ declare function createFromSource<C extends LoaderConfig = LoaderConfig>(loader: LoaderOutput<C> | (() => Awaitable<LoaderOutput<C>>), options?: Options<C>): SearchAPI<EngineQueryOptions>;
141
+ //#endregion
142
+ //#region src/search/server/types.d.ts
143
+ interface QueryOptions {
144
+ locale?: string | null;
145
+ tag?: string | string[];
146
+ limit?: number;
147
+ }
148
+ interface SearchServer<Q extends QueryOptions = QueryOptions> {
149
+ search: (query: string, options?: Q) => Promise<SortedResult[]>;
150
+ /**
151
+ * Export the database
152
+ *
153
+ * You can reference the exported database to implement client-side search
154
+ */
155
+ export: () => Promise<unknown>;
156
+ }
157
+ interface SearchAPI<Q extends QueryOptions = QueryOptions> extends SearchServer<Q> {
158
+ GET: (request: Request) => Promise<Response>;
159
+ /**
160
+ * `GET` route handler that exports search indexes for static search.
161
+ */
162
+ staticGET: () => Promise<Response>;
163
+ }
164
+ //#endregion
165
+ export { AdvancedOptions as a, SimpleOptions as c, createSearchAPI as d, initAdvancedSearch as f, AdvancedIndex as i, createFromSource as l, SharedIndex as m, SearchAPI as n, ExportedData as o, initSimpleSearch as p, SearchServer as r, Index as s, QueryOptions as t, createI18nSearchAPI as u };
@@ -0,0 +1,13 @@
1
+ import { ElementType, ReactElement } from "react";
2
+ //#region src/server.browser.d.ts
3
+ /**
4
+ * Browser stub: Markdown rendering is server-only, components generated by
5
+ * `remarkLLMs` with `output: 'function'` render `null` in the browser.
6
+ */
7
+ declare function asMarkdown(): boolean;
8
+ declare function jsxComponents(components: Record<string, ElementType> | undefined): Record<string, ElementType>;
9
+ declare function renderToMarkdown(): Promise<string>;
10
+ declare function renderRoute(_element: ReactElement): Promise<string | undefined>;
11
+ declare const md: () => never;
12
+ //#endregion
13
+ export { asMarkdown, jsxComponents, md, renderRoute, renderToMarkdown };
@@ -0,0 +1,22 @@
1
+ //#region src/server.browser.ts
2
+ /**
3
+ * Browser stub: Markdown rendering is server-only, components generated by
4
+ * `remarkLLMs` with `output: 'function'` render `null` in the browser.
5
+ */
6
+ function asMarkdown() {
7
+ return false;
8
+ }
9
+ function jsxComponents(components) {
10
+ return components ?? {};
11
+ }
12
+ async function renderToMarkdown() {
13
+ throw new Error("`renderToMarkdown` is only available on the server.");
14
+ }
15
+ async function renderRoute(_element) {
16
+ throw new Error("`renderRoute` is only available on the server.");
17
+ }
18
+ const md = () => {
19
+ throw new Error("`md` is only available on the server.");
20
+ };
21
+ //#endregion
22
+ export { asMarkdown, jsxComponents, md, renderRoute, renderToMarkdown };
@@ -0,0 +1,42 @@
1
+ import { ElementType, ReactElement, ReactNode } from "react";
2
+ //#region src/server.d.ts
3
+ /**
4
+ * Whether the current component is being rendered into Markdown, calling it opts the component in.
5
+ */
6
+ declare function asMarkdown(): boolean;
7
+ /**
8
+ * Render a React tree into a Markdown document.
9
+ */
10
+ declare function renderToMarkdown(node: ReactNode): Promise<string>;
11
+ /**
12
+ * Render a page element into Markdown, `undefined` when its component doesn't call `asMarkdown()`.
13
+ */
14
+ declare function renderRoute(element: ReactElement): Promise<string | undefined>;
15
+ /**
16
+ * Resolve the MDX components of a generated Markdown component (`remarkLLMs` with `output: 'function'`):
17
+ * a missing component becomes a stub that `renderToMarkdown` serializes as JSX syntax.
18
+ */
19
+ declare function jsxComponents(components: Record<string, ElementType> | undefined): Record<string, ElementType>;
20
+ type MarkdownTag = (strings: TemplateStringsArray, ...values: ReactNode[]) => Promise<string>;
21
+ /**
22
+ * Tagged template for Markdown, interpolated values can be strings, React nodes, promises, or arrays of them.
23
+ *
24
+ * Use `md\`${children}\`` inside a component to stringify its children before manipulating them, the result is not
25
+ * trimmed so block-level output keeps its trailing blank line.
26
+ *
27
+ * Formatters (Prettier, oxfmt) format `md` templates as Markdown and may move the content onto its own indented lines,
28
+ * so a leading empty line, the indentation before the closing backtick and the common indentation are removed.
29
+ */
30
+ declare const md: MarkdownTag & {
31
+ /**
32
+ * Like `md`, but trims the result, prefixes every line (empty lines receive the trimmed prefix, e.g. `>` instead of
33
+ * `> `) and returns it as a block.
34
+ */
35
+ linePrefix: (prefix: string) => MarkdownTag;
36
+ /**
37
+ * Like `md`, but trims the result, indents every non-empty line and returns it as a block.
38
+ */
39
+ indent: (size?: number) => MarkdownTag;
40
+ };
41
+ //#endregion
42
+ export { MarkdownTag, asMarkdown, jsxComponents, md, renderRoute, renderToMarkdown };