boltdocs 3.3.5 → 3.3.6

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 (79) hide show
  1. package/dist/{build-BVoMHMhw.mjs → build-BJnL-FHG.mjs} +1 -1
  2. package/dist/{build-B672n0hL.cjs → build-CxT38vPv.cjs} +1 -1
  3. package/dist/client/index.cjs +29 -12
  4. package/dist/client/index.d.cts +1 -1
  5. package/dist/client/index.d.ts +1 -1
  6. package/dist/client/index.js +27 -11
  7. package/dist/client/mdx.cjs +1 -1
  8. package/dist/client/mdx.js +1 -1
  9. package/dist/client/primitives.cjs +4 -4
  10. package/dist/client/primitives.d.cts +40 -9
  11. package/dist/client/primitives.d.ts +40 -9
  12. package/dist/client/primitives.js +4 -4
  13. package/dist/config-B3_iVsbi.mjs +7 -0
  14. package/dist/{config-PLvresCv.cjs → config-BC_qhXws.cjs} +1 -1
  15. package/dist/config-BJp3lGzE.cjs +7 -0
  16. package/dist/{dev-DbuhNcF5.cjs → dev-46NiL0MC.cjs} +1 -1
  17. package/dist/{dev-B49V6O6p.mjs → dev-C4kjO5xs.mjs} +1 -1
  18. package/dist/{docs-layout-CbZ7LDRe.js → docs-layout-D3Fmb0Wd.js} +16 -117
  19. package/dist/{docs-layout-vzfXed1Q.cjs → docs-layout-SgphExoE.cjs} +16 -123
  20. package/dist/{doctor-DMECtdK6.cjs → doctor-BqxOFRt3.cjs} +1 -1
  21. package/dist/{doctor-i8Qmd8DJ.mjs → doctor-Cv5lXnay.mjs} +1 -1
  22. package/dist/{doctor-FuFY1jBz.cjs → doctor-TS3JGNEU.cjs} +1 -1
  23. package/dist/{image-B-NDSDuY.js → image-BAiDReNd.js} +1 -1
  24. package/dist/{image-Hnaa2bJd.cjs → image-Bkx85rsq.cjs} +1 -1
  25. package/dist/{index-B3o307nd.d.ts → index-B1Mx0dHl.d.ts} +24 -4
  26. package/dist/{index-Bg-JtZeK.d.cts → index-DLaHgD-i.d.cts} +24 -4
  27. package/dist/{link-vZjmD-es.cjs → link-hLWOsx0x.cjs} +59 -28
  28. package/dist/{link-CgdI6O2o.js → link-q1qHNGK_.js} +54 -29
  29. package/dist/{mdx-BRT71V5Q.js → mdx-CJGWzBGy.js} +2 -2
  30. package/dist/{mdx-D0Absdq5.cjs → mdx-Qi0DmaY8.cjs} +2 -2
  31. package/dist/node/cli-entry.cjs +1 -1
  32. package/dist/node/cli-entry.mjs +1 -1
  33. package/dist/node/highlight.d.cts +2 -2
  34. package/dist/node/highlight.d.mts +2 -2
  35. package/dist/node/index.cjs +1 -1
  36. package/dist/node/index.d.cts +7 -4
  37. package/dist/node/index.d.mts +7 -4
  38. package/dist/node/index.mjs +1 -1
  39. package/dist/node/mdx/shiki-adapter.cjs +1 -1
  40. package/dist/node/mdx/shiki-adapter.d.cts +7 -2
  41. package/dist/node/mdx/shiki-adapter.d.mts +7 -2
  42. package/dist/node/mdx/shiki-adapter.mjs +1 -1
  43. package/dist/node-7Cfw6nMr.cjs +23 -0
  44. package/dist/node-CT2E84nY.mjs +23 -0
  45. package/dist/{package-CNqjEYE1.cjs → package-Bah2tHjK.cjs} +1 -1
  46. package/dist/{package-sdcKhDhe.mjs → package-D6bf68FR.mjs} +1 -1
  47. package/dist/plugin-AgNI3ktz.cjs +69 -0
  48. package/dist/plugin-BAv_pYLt.mjs +69 -0
  49. package/dist/{plugin-context-CscLcXjH.cjs → plugin-context-BZs5lvDu.cjs} +2 -2
  50. package/dist/{plugin-context-DuSg-Hax.mjs → plugin-context-b5qVVQSU.mjs} +1 -1
  51. package/dist/{plugin-lifecycle-BywrEoWK.cjs → plugin-lifecycle-s89gzTlh.cjs} +1 -1
  52. package/dist/{registry-sJqDv0kE.d.mts → registry-B8pt41zj.d.cts} +1 -1
  53. package/dist/{registry-BbB6NqSv.d.cts → registry-BrrH2X9c.d.mts} +1 -1
  54. package/dist/routes-CzhKOw67.cjs +6 -0
  55. package/dist/{routes-C3_w9fLX.cjs → routes-Dq_2EUIB.cjs} +1 -1
  56. package/dist/routes-Dw6g0bfF.mjs +6 -0
  57. package/dist/search-dialog-BYZS9aeO.cjs +747 -0
  58. package/dist/{search-dialog-x_qHU8ty.cjs → search-dialog-CguKVtUu.cjs} +145 -5
  59. package/dist/{search-dialog-B9mdxsUC.js → search-dialog-DQwod5Xc.js} +1 -1
  60. package/dist/search-dialog-DzObE-Ar.js +717 -0
  61. package/dist/{search-dialog-DCtm2dyR.cjs → search-dialog-QgKRRbsI.cjs} +1 -1
  62. package/dist/{search-dialog-BqkzDTq2.js → search-dialog-mYnqU4v7.js} +134 -6
  63. package/dist/{types-Db6zToZH.d.mts → types-74i_xUe2.d.mts} +1 -1
  64. package/dist/{types-o7iZ2BAR.d.cts → types-X_Pwk8Cg.d.cts} +1 -1
  65. package/dist/virtual-modules-C3S3Nz8r.cjs +40 -0
  66. package/dist/virtual-modules-CaxqrFd6.mjs +40 -0
  67. package/package.json +6 -5
  68. package/dist/config-CrsQJHQz.cjs +0 -7
  69. package/dist/config-DC0nMMk7.mjs +0 -7
  70. package/dist/node-BljvHMpS.cjs +0 -23
  71. package/dist/node-CWxGw4H4.mjs +0 -23
  72. package/dist/plugin-BPcm1cU0.mjs +0 -69
  73. package/dist/plugin-WUhxnpko.cjs +0 -69
  74. package/dist/routes-C0kb4ue6.cjs +0 -6
  75. package/dist/routes-C4wrLWwu.mjs +0 -6
  76. package/dist/search-dialog-Bp_ouN1c.cjs +0 -550
  77. package/dist/search-dialog-an2BNMj6.js +0 -526
  78. package/dist/virtual-modules-B2X4Ht2r.mjs +0 -39
  79. package/dist/virtual-modules-DPsdHKcu.cjs +0 -39
@@ -1,550 +0,0 @@
1
- /**
2
- * Boltdocs - https://boltdocs.vercel.app
3
- * Copyright (c) 2026 Jesus Alcala
4
- * Licensed under the MIT License.
5
- */
6
- const require_router = require('./router-C3kygdRK.cjs');
7
- const require_link = require('./link-vZjmD-es.cjs');
8
- const require_search_dialog = require('./search-dialog-x_qHU8ty.cjs');
9
- let react = require("react");
10
- let react_jsx_runtime = require("react/jsx-runtime");
11
- let virtual_boltdocs_search = require("virtual:boltdocs-search");
12
- virtual_boltdocs_search = require_router.__toESM(virtual_boltdocs_search);
13
-
14
- //#region src/client/hooks/use-routes.ts
15
- /**
16
- * Hook to access the framework's routing state.
17
- * Returns both the complete set of routes and a filtered list based on the current
18
- * version and locale.
19
- */
20
- function useRoutes() {
21
- const routeContext = require_link.useRoutesContext();
22
- const allRoutes = routeContext.routes;
23
- const routeIndex = routeContext.index || {
24
- byPath: new Map(allRoutes.map((route) => [require_link.normalizePath(route.path), route])),
25
- hintsByPath: /* @__PURE__ */ new Map(),
26
- collectionNames: []
27
- };
28
- const config = require_link.useConfig();
29
- const location = require_router.useLocation();
30
- const { pathname } = location;
31
- const { currentLocale: currentLocaleStore, currentVersion: currentVersionStore } = require_link.useBoltdocsContext();
32
- const currentPath = require_link.normalizePath(pathname);
33
- const currentRoute = (0, react.useMemo)(() => {
34
- const direct = routeIndex.byPath.get(currentPath);
35
- if (direct) return direct;
36
- const target = currentPath.split("/").filter(Boolean);
37
- if (target.length === 0) return void 0;
38
- let best;
39
- for (const [key, route] of routeIndex.byPath) {
40
- if (!route.collection) continue;
41
- const segments = key.split("/").filter(Boolean);
42
- if (segments.length === 0 || segments.length > target.length) continue;
43
- const offset = target.length - segments.length;
44
- if (segments.every((segment, i) => segment === target[offset + i]) && (!best || segments.length > best.depth)) best = {
45
- route,
46
- depth: segments.length
47
- };
48
- }
49
- return best?.route;
50
- }, [routeIndex, currentPath]);
51
- const pathParts = pathname.split("/").filter(Boolean);
52
- const urlLocale = config.i18n ? pathParts.find((part) => Array.isArray(config.i18n?.locales) ? config.i18n?.locales.includes(part) : part in (config.i18n?.locales || {})) : void 0;
53
- const currentLocale = config.i18n ? urlLocale || currentLocaleStore || config.i18n.defaultLocale : void 0;
54
- const configuredVersions = config.versions?.versions || [];
55
- const currentVersion = config.versions ? configuredVersions.some((version) => version.path === currentVersionStore) ? currentVersionStore : config.versions.defaultVersion : void 0;
56
- const routes = (0, react.useMemo)(() => {
57
- if (!allRoutes) return [];
58
- const alternateCounts = /* @__PURE__ */ new Map();
59
- const defaultLocale = config.i18n?.defaultLocale || "";
60
- const defaultVersion = config.versions?.defaultVersion || "";
61
- for (const r of allRoutes) {
62
- const locale = r.locale || defaultLocale;
63
- const version = r.version || defaultVersion;
64
- const key = `${r.filePath}::${locale}::${version}`;
65
- alternateCounts.set(key, (alternateCounts.get(key) || 0) + 1);
66
- }
67
- return allRoutes.filter((r) => {
68
- const localeMatch = config.i18n ? (r.locale || config.i18n.defaultLocale) === currentLocale : true;
69
- const versionMatch = config.versions ? (r.version || config.versions.defaultVersion) === currentVersion : true;
70
- if (!(localeMatch && versionMatch)) return false;
71
- const pathParts = pathname.split("/").filter(Boolean);
72
- const isCurrentLocalePrefixed = !!(config.i18n && pathParts.includes(currentLocaleStore || config.i18n.defaultLocale));
73
- const isCurrentVersionPrefixed = !!(config.versions && !!currentVersion && pathParts.includes(currentVersion));
74
- const isRouteLocalePrefixed = !!r.locale;
75
- const isRouteVersionPrefixed = !!r.version;
76
- const locale = r.locale || defaultLocale;
77
- const version = r.version || defaultVersion;
78
- const key = `${r.filePath}::${locale}::${version}`;
79
- if ((alternateCounts.get(key) || 0) > 1) {
80
- const localeMismatch = config.i18n && isCurrentLocalePrefixed !== isRouteLocalePrefixed;
81
- const versionMismatch = config.versions && isCurrentVersionPrefixed !== isRouteVersionPrefixed;
82
- if (localeMismatch || versionMismatch) return false;
83
- }
84
- return true;
85
- });
86
- }, [
87
- allRoutes,
88
- config,
89
- pathname,
90
- currentLocale,
91
- currentVersion,
92
- currentLocaleStore
93
- ]);
94
- const collections = (0, react.useMemo)(() => new Set(routeIndex.collectionNames), [routeIndex.collectionNames]);
95
- return {
96
- routes,
97
- allRoutes,
98
- currentRoute,
99
- isCollectionPage: !!currentRoute?.collection || location.pathname.split("/").filter(Boolean).some((segment) => collections.has(segment.toLowerCase())),
100
- currentLocale,
101
- currentVersion
102
- };
103
- }
104
-
105
- //#endregion
106
- //#region src/client/components/internal/error-boundary.tsx
107
- function InternalFallback({ error, resetErrorBoundary, className }) {
108
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
109
- role: "alert",
110
- className: require_link.cn("p-2 font-mono flex flex-col items-center justify-between min-h-[30vh]", className),
111
- children: [
112
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
113
- className: "text-lg font-semibold text-danger-500",
114
- children: "Something went wrong"
115
- }),
116
- error?.message && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("pre", {
117
- className: "text-sm mt-2 max-w-md overflow-auto whitespace-pre-wrap break-word",
118
- children: error.message
119
- }),
120
- error?.stack && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("details", {
121
- className: "mt-2 max-w-md text-left text-xs",
122
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("summary", {
123
- className: "cursor-pointer text-muted select-none outline-none",
124
- children: "Error details"
125
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("pre", {
126
- className: "mt-2 p-2 bg-soft rounded border-subtle border overflow-auto max-h-48 whitespace-pre-wrap break-words",
127
- children: error.stack
128
- })]
129
- }),
130
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
131
- className: "flex items-center gap-2 mt-2",
132
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
133
- type: "button",
134
- onClick: resetErrorBoundary,
135
- className: "px-2 py-3 bg-soft rounded border-subtle border font-mono font-semibold text-body hover:scale-105 transition-transform active:scale-95 cursor-pointer",
136
- children: "Try again"
137
- }), typeof window !== "undefined" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
138
- type: "button",
139
- onClick: () => window.location.reload(),
140
- className: "px-2 py-3 rounded font-mono font-semibold text-muted hover:text-body transition-colors cursor-pointer",
141
- children: "Reload page"
142
- })]
143
- })
144
- ]
145
- });
146
- }
147
- function InternalErrorBoundary({ children, fallback, resetKeys }) {
148
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_search_dialog.ErrorBoundary, {
149
- fallback,
150
- resetKeys,
151
- FallbackComponent: !fallback ? InternalFallback : void 0,
152
- children
153
- });
154
- }
155
-
156
- //#endregion
157
- //#region src/client/hooks/use-search.ts
158
- function useSearch(routes) {
159
- const { currentLocale, currentVersion } = useRoutes();
160
- const config = require_link.useConfig();
161
- const algoliaConfig = config.integrations?.search?.algolia;
162
- const [isOpen, setIsOpen] = (0, react.useState)(false);
163
- const [query, setQuery] = (0, react.useState)("");
164
- const [index, setIndex] = (0, react.useState)(null);
165
- const [algoliaResults, setAlgoliaResults] = (0, react.useState)([]);
166
- const [searchData, setSearchData] = (0, react.useState)([]);
167
- const [searchDataLoading, setSearchDataLoading] = (0, react.useState)(false);
168
- const [searchDataError, setSearchDataError] = (0, react.useState)(null);
169
- const searchGeneration = (0, react.useRef)(0);
170
- const loadingGeneration = (0, react.useRef)(null);
171
- const navigate = require_router.useNavigate();
172
- (0, react.useEffect)(() => {
173
- if (algoliaConfig || !isOpen) return;
174
- if (searchData.length > 0) return;
175
- setSearchDataLoading(true);
176
- setSearchDataError(null);
177
- let active = true;
178
- const generation = ++searchGeneration.current;
179
- loadingGeneration.current = generation;
180
- (0, virtual_boltdocs_search.default)().then((data) => {
181
- if (!active || generation !== searchGeneration.current) return;
182
- setSearchData(data || []);
183
- if (loadingGeneration.current === generation) {
184
- loadingGeneration.current = null;
185
- setSearchDataLoading(false);
186
- }
187
- }).catch((err) => {
188
- if (!active || generation !== searchGeneration.current) return;
189
- console.error("[boltdocs] Failed to load search index:", err);
190
- setSearchDataError(err);
191
- if (loadingGeneration.current === generation) {
192
- loadingGeneration.current = null;
193
- setSearchDataLoading(false);
194
- }
195
- });
196
- return () => {
197
- active = false;
198
- };
199
- }, [
200
- isOpen,
201
- algoliaConfig,
202
- searchData.length
203
- ]);
204
- (0, react.useEffect)(() => {
205
- if (!{}.hot) return;
206
- const applyFrontmatterDelta = (payload) => {
207
- const updated = payload.search?.updated ?? [];
208
- const deleted = new Set(payload.search?.deleted ?? []);
209
- searchGeneration.current += 1;
210
- if (loadingGeneration.current !== null) {
211
- loadingGeneration.current = null;
212
- setSearchDataLoading(false);
213
- }
214
- setSearchData((prev) => {
215
- const map = new Map(prev.map((d) => [d.id, d]));
216
- for (const doc of updated) map.set(doc.id, doc);
217
- for (const id of deleted) map.delete(id);
218
- return Array.from(map.values());
219
- });
220
- setIndex(null);
221
- };
222
- const refreshFromAsset = async () => {
223
- const generation = ++searchGeneration.current;
224
- loadingGeneration.current = generation;
225
- setSearchDataLoading(true);
226
- try {
227
- const data = await (0, virtual_boltdocs_search.default)({ bustCache: true });
228
- if (generation !== searchGeneration.current) return;
229
- setSearchData(data || []);
230
- setSearchDataError(null);
231
- setIndex(null);
232
- } catch (error) {
233
- if (generation !== searchGeneration.current) return;
234
- console.error("[boltdocs] Failed to refresh search index:", error);
235
- setSearchDataError(error instanceof Error ? error : new Error(String(error)));
236
- } finally {
237
- if (generation === searchGeneration.current) {
238
- loadingGeneration.current = null;
239
- setSearchDataLoading(false);
240
- }
241
- }
242
- };
243
- const hot = {}.hot;
244
- hot.on("boltdocs:frontmatter-update", applyFrontmatterDelta);
245
- hot.on("boltdocs:mdx-update", refreshFromAsset);
246
- return () => {
247
- hot.off?.("boltdocs:frontmatter-update", applyFrontmatterDelta);
248
- hot.off?.("boltdocs:mdx-update", refreshFromAsset);
249
- };
250
- }, []);
251
- (0, react.useEffect)(() => {
252
- const handleKeyDown = (e) => {
253
- if ((/Mac/.test(navigator.userAgent) ? e.metaKey : e.ctrlKey) && (e.key === "k" || e.key === "j")) {
254
- e.preventDefault();
255
- setIsOpen((prev) => !prev);
256
- }
257
- };
258
- window.addEventListener("keydown", handleKeyDown);
259
- return () => window.removeEventListener("keydown", handleKeyDown);
260
- }, []);
261
- const handleSelect = (0, react.useCallback)((key) => {
262
- const path = String(key);
263
- if (!path) return;
264
- setIsOpen(false);
265
- const url = new URL(path, window.location.origin);
266
- if (query) url.searchParams.set("hl", query);
267
- navigate(`${url.pathname}${url.search}${url.hash}`);
268
- }, [navigate, query]);
269
- (0, react.useEffect)(() => {
270
- if (algoliaConfig) return;
271
- if (!isOpen || searchData.length === 0 || index) return;
272
- let cancelled = false;
273
- import("flexsearch").then(({ Index: FlexIndex }) => {
274
- if (cancelled) return;
275
- const newIndex = new FlexIndex({
276
- tokenize: "forward",
277
- cache: true
278
- });
279
- for (let i = 0; i < searchData.length; i++) {
280
- const doc = searchData[i];
281
- if (!doc) continue;
282
- newIndex.add(i, `${doc.title} ${doc.content}`);
283
- }
284
- setIndex(newIndex);
285
- }).catch((err) => {
286
- console.error("[boltdocs] Failed to load search engine:", err);
287
- });
288
- return () => {
289
- cancelled = true;
290
- };
291
- }, [
292
- isOpen,
293
- index,
294
- algoliaConfig,
295
- searchData
296
- ]);
297
- (0, react.useEffect)(() => {
298
- if (!algoliaConfig) return;
299
- if (!query) {
300
- setAlgoliaResults([]);
301
- return;
302
- }
303
- const delayDebounceFn = setTimeout(async () => {
304
- try {
305
- const url = `https://${algoliaConfig.appId}-dsn.algolia.net/1/indexes/${algoliaConfig.indexName}/query`;
306
- const facetFilters = [];
307
- if (currentLocale) facetFilters.push(`lang:${currentLocale}`);
308
- if (currentVersion) facetFilters.push(`version:${currentVersion}`);
309
- let params = `query=${encodeURIComponent(query)}&hitsPerPage=20`;
310
- if (facetFilters.length > 0) params += `&facetFilters=${encodeURIComponent(JSON.stringify(facetFilters))}`;
311
- const response = await fetch(url, {
312
- method: "POST",
313
- headers: {
314
- "Content-Type": "application/json",
315
- "X-Algolia-API-Key": algoliaConfig.apiKey,
316
- "X-Algolia-Application-Id": algoliaConfig.appId
317
- },
318
- body: JSON.stringify({ params })
319
- });
320
- if (!response.ok) throw new Error(`Algolia search request failed: ${response.statusText}`);
321
- setAlgoliaResults(((await response.json()).hits || []).map((hit) => {
322
- let path = hit.url || "";
323
- try {
324
- if (path.startsWith("http://") || path.startsWith("https://")) {
325
- const urlObj = new URL(path);
326
- path = urlObj.pathname + urlObj.search + urlObj.hash;
327
- }
328
- } catch {}
329
- const hierarchy = hit.hierarchy || {};
330
- const levels = [
331
- hierarchy.lvl0,
332
- hierarchy.lvl1,
333
- hierarchy.lvl2,
334
- hierarchy.lvl3,
335
- hierarchy.lvl4,
336
- hierarchy.lvl5,
337
- hierarchy.lvl6
338
- ].filter(Boolean);
339
- const title = levels[levels.length - 1] || "Documentation";
340
- const bio = levels.join(" > ");
341
- return {
342
- id: hit.objectID || path,
343
- title,
344
- path,
345
- bio,
346
- groupTitle: hierarchy.lvl0 || "Docs",
347
- isHeading: !!hit.anchor || path.includes("#")
348
- };
349
- }));
350
- } catch (err) {
351
- console.error("Error fetching search results from Algolia:", err);
352
- }
353
- }, 250);
354
- return () => clearTimeout(delayDebounceFn);
355
- }, [
356
- query,
357
- algoliaConfig,
358
- currentLocale,
359
- currentVersion
360
- ]);
361
- return {
362
- isOpen,
363
- setIsOpen,
364
- query,
365
- setQuery,
366
- list: (0, react.useMemo)(() => {
367
- if (!query) return routes.filter((r) => {
368
- const routeLocale = r.locale || config.i18n?.defaultLocale;
369
- const routeVersion = r.version || config.versions?.defaultVersion;
370
- return (!currentLocale || routeLocale === currentLocale) && (!currentVersion || routeVersion === currentVersion);
371
- }).slice(0, 10).map((r) => ({
372
- id: r.path,
373
- title: r.title,
374
- path: r.path,
375
- bio: r.description || "",
376
- groupTitle: r.groupTitle
377
- }));
378
- if (algoliaConfig) return algoliaResults;
379
- if (!index) return [];
380
- const searchResults = index.search(query, {
381
- limit: 20,
382
- suggest: true
383
- });
384
- const results = [];
385
- const seen = /* @__PURE__ */ new Set();
386
- for (const id of searchResults) {
387
- const doc = searchData[typeof id === "number" ? id : Number(id)];
388
- if (!doc) continue;
389
- const docLocale = doc.locale || config.i18n?.defaultLocale;
390
- const docVersion = doc.version || config.versions?.defaultVersion;
391
- const localeMatch = !currentLocale || docLocale === currentLocale || !doc.locale && currentLocale === config.i18n?.defaultLocale;
392
- if (!(!currentVersion || docVersion === currentVersion)) continue;
393
- if (seen.has(doc.url)) continue;
394
- seen.add(doc.url);
395
- results.push({
396
- id: doc.url,
397
- title: doc.title,
398
- path: doc.url,
399
- bio: doc.display,
400
- groupTitle: doc.display.split(" > ")[0],
401
- isHeading: doc.url.includes("#"),
402
- localeMatch
403
- });
404
- }
405
- return results.filter((result) => result.localeMatch).slice(0, 10);
406
- }, [
407
- query,
408
- index,
409
- currentLocale,
410
- currentVersion,
411
- routes,
412
- searchData,
413
- algoliaConfig,
414
- algoliaResults,
415
- config
416
- ]),
417
- searchDataLoading,
418
- searchDataError,
419
- handleSelect,
420
- input: {
421
- value: query,
422
- onChange: (e) => setQuery(e.target.value)
423
- }
424
- };
425
- }
426
-
427
- //#endregion
428
- //#region src/client/components/ui-base/search-dialog.tsx
429
- function Highlight({ text, query, markClassName }) {
430
- if (!query || !text) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: text });
431
- const escapedQuery = query.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
432
- const regex = new RegExp(`(${escapedQuery})`, "gi");
433
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: text.split(regex).map((part, i) => regex.test(part) ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("mark", {
434
- className: require_link.cn("bg-primary-500/20 text-primary-600 dark:text-primary-400 font-bold px-0.5 rounded-sm", markClassName),
435
- children: part
436
- }, i) : part) });
437
- }
438
- function SearchDialog({ routes, className, markClassName }) {
439
- const { isOpen, setIsOpen, query, setQuery, list, searchDataLoading, searchDataError, handleSelect } = useSearch(routes);
440
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
441
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_search_dialog.Navbar.SearchTrigger.Desktop, {
442
- onPress: () => setIsOpen(true),
443
- className: "rounded-xl border border-subtle bg-surface text-muted transition-all duration-200 hover:border-primary-500/50 hover:text-body hover:bg-soft/50 hover:shadow-sm active:scale-[0.98] focus-visible:ring-2 focus-visible:ring-primary-500/30",
444
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
445
- className: "flex items-center gap-2",
446
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_link.Search, { size: 16 }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
447
- className: "hidden sm:inline-block",
448
- children: "Search docs..."
449
- })]
450
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_search_dialog.Navbar.SearchTrigger.Kbd, { className: "[&_kbd]:bg-main [&_kbd]:border [&_kbd]:border-subtle [&_kbd]:rounded [&_kbd]:px-1.5 [&_kbd]:h-5 [&_kbd]:w-5" })]
451
- }),
452
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_search_dialog.Navbar.SearchTrigger.Mobile, {
453
- onPress: () => setIsOpen(true),
454
- className: "rounded-xl text-muted transition-all duration-200 hover:text-body active:scale-95 focus-visible:ring-2 focus-visible:ring-primary-500/30",
455
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_link.Search, { size: 20 })
456
- }),
457
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(InternalErrorBoundary, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_search_dialog.SearchDialog.Overlay, {
458
- isOpen,
459
- isDismissable: true,
460
- onOpenChange: () => setIsOpen(false),
461
- className: require_link.cn("fixed inset-0 z-100 flex items-center justify-center p-4 bg-black/40 backdrop-blur-xs animate-fade-in", className),
462
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_search_dialog.SearchDialog.Content, {
463
- className: "w-full max-w-lg bg-main border border-subtle shadow-md rounded-2xl overflow-hidden p-6",
464
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_search_dialog.SearchDialog.Dialog, {
465
- "aria-label": "Search documentation",
466
- className: "flex flex-col min-h-0 h-[450px]",
467
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_search_dialog.SearchDialog.Autocomplete, {
468
- className: "flex flex-col min-h-0",
469
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_search_dialog.SearchDialog.Input, {
470
- value: query,
471
- onChange: setQuery,
472
- className: "flex items-center gap-2 border border-subtle bg-surface px-4 py-2.5 rounded-xl focus-within:border-primary-500 mb-4",
473
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_search_dialog.SearchDialog.Input.SearchInput, {
474
- placeholder: "Search documentation...",
475
- className: "w-full bg-transparent outline-none text-body text-sm"
476
- }), query && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_search_dialog.SearchDialog.Input.Button, {
477
- onPress: () => setQuery(""),
478
- className: "text-muted hover:text-body hover:bg-surface rounded-md p-1 cursor-pointer select-none transition-colors",
479
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_link.X, { size: 16 })
480
- })]
481
- }), searchDataLoading ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
482
- className: "flex flex-1 items-center justify-center px-4 py-8 text-sm text-muted",
483
- children: "Loading search index…"
484
- }) : searchDataError ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
485
- className: "flex flex-1 items-center justify-center px-4 py-8 text-center text-sm text-muted",
486
- children: "Search is temporarily unavailable."
487
- }) : query && list.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
488
- className: "flex flex-1 items-center justify-center px-4 py-8 text-sm text-muted",
489
- children: "No results found."
490
- }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_search_dialog.SearchDialog.List, {
491
- items: list,
492
- onAction: handleSelect,
493
- children: (item) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_search_dialog.SearchDialog.Item, {
494
- textValue: item.title,
495
- className: "flex items-center gap-3 px-4 py-2 rounded-xl group dark:hover:bg-primary-300/40 hover:bg-primary-200/50 transition-colors duration-100",
496
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_search_dialog.SearchDialog.Item.Icon, {
497
- isHeading: item.isHeading,
498
- className: "text-muted group-hover:text-primary-500 group-focus:text-primary-500"
499
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
500
- className: "flex flex-col justify-center min-w-0",
501
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_search_dialog.SearchDialog.Item.Title, {
502
- className: "text-sm font-medium text-body truncate dark:group-hover:text-primary-100",
503
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Highlight, {
504
- text: item.title,
505
- query,
506
- markClassName
507
- })
508
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_search_dialog.SearchDialog.Item.Bio, {
509
- className: "text-xs text-muted truncate",
510
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Highlight, {
511
- text: item.bio,
512
- query,
513
- markClassName
514
- })
515
- })]
516
- })]
517
- }, item.id)
518
- })]
519
- })
520
- })
521
- })
522
- }) })
523
- ] });
524
- }
525
-
526
- //#endregion
527
- Object.defineProperty(exports, 'InternalErrorBoundary', {
528
- enumerable: true,
529
- get: function () {
530
- return InternalErrorBoundary;
531
- }
532
- });
533
- Object.defineProperty(exports, 'SearchDialog', {
534
- enumerable: true,
535
- get: function () {
536
- return SearchDialog;
537
- }
538
- });
539
- Object.defineProperty(exports, 'useRoutes', {
540
- enumerable: true,
541
- get: function () {
542
- return useRoutes;
543
- }
544
- });
545
- Object.defineProperty(exports, 'useSearch', {
546
- enumerable: true,
547
- get: function () {
548
- return useSearch;
549
- }
550
- });