boltdocs 3.3.4 → 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.
- package/dist/{build-COgv-rkY.mjs → build-BJnL-FHG.mjs} +1 -1
- package/dist/{build-1CsvBIsN.cjs → build-CxT38vPv.cjs} +1 -1
- package/dist/client/index.cjs +80 -32
- package/dist/client/index.d.cts +1 -1
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.js +78 -31
- package/dist/client/mdx.cjs +1 -1
- package/dist/client/mdx.js +1 -1
- package/dist/client/primitives.cjs +4 -4
- package/dist/client/primitives.d.cts +40 -9
- package/dist/client/primitives.d.ts +40 -9
- package/dist/client/primitives.js +4 -4
- package/dist/config-B3_iVsbi.mjs +7 -0
- package/dist/{config-PLvresCv.cjs → config-BC_qhXws.cjs} +1 -1
- package/dist/config-BJp3lGzE.cjs +7 -0
- package/dist/{dev-C_9iBwmu.cjs → dev-46NiL0MC.cjs} +1 -1
- package/dist/{dev-UWVM3ah-.mjs → dev-C4kjO5xs.mjs} +1 -1
- package/dist/{docs-layout-CbZ7LDRe.js → docs-layout-D3Fmb0Wd.js} +16 -117
- package/dist/{docs-layout-vzfXed1Q.cjs → docs-layout-SgphExoE.cjs} +16 -123
- package/dist/{doctor-DMECtdK6.cjs → doctor-BqxOFRt3.cjs} +1 -1
- package/dist/{doctor-i8Qmd8DJ.mjs → doctor-Cv5lXnay.mjs} +1 -1
- package/dist/{doctor-FuFY1jBz.cjs → doctor-TS3JGNEU.cjs} +1 -1
- package/dist/{image-B-NDSDuY.js → image-BAiDReNd.js} +1 -1
- package/dist/{image-Hnaa2bJd.cjs → image-Bkx85rsq.cjs} +1 -1
- package/dist/{index-Cg3TmXIZ.d.ts → index-B1Mx0dHl.d.ts} +30 -6
- package/dist/{index-CSiMUBhC.d.cts → index-DLaHgD-i.d.cts} +30 -6
- package/dist/{link-vZjmD-es.cjs → link-hLWOsx0x.cjs} +59 -28
- package/dist/{link-CgdI6O2o.js → link-q1qHNGK_.js} +54 -29
- package/dist/{mdx-BRT71V5Q.js → mdx-CJGWzBGy.js} +2 -2
- package/dist/{mdx-D0Absdq5.cjs → mdx-Qi0DmaY8.cjs} +2 -2
- package/dist/node/cli-entry.cjs +1 -1
- package/dist/node/cli-entry.mjs +1 -1
- package/dist/node/highlight.d.cts +2 -2
- package/dist/node/highlight.d.mts +2 -2
- package/dist/node/index.cjs +1 -1
- package/dist/node/index.d.cts +7 -4
- package/dist/node/index.d.mts +7 -4
- package/dist/node/index.mjs +1 -1
- package/dist/node/mdx/shiki-adapter.cjs +1 -1
- package/dist/node/mdx/shiki-adapter.d.cts +7 -2
- package/dist/node/mdx/shiki-adapter.d.mts +7 -2
- package/dist/node/mdx/shiki-adapter.mjs +1 -1
- package/dist/node-7Cfw6nMr.cjs +23 -0
- package/dist/node-CT2E84nY.mjs +23 -0
- package/dist/{package-Cwma8oO7.cjs → package-Bah2tHjK.cjs} +1 -1
- package/dist/{package-CKC-4LtU.mjs → package-D6bf68FR.mjs} +1 -1
- package/dist/plugin-AgNI3ktz.cjs +69 -0
- package/dist/plugin-BAv_pYLt.mjs +69 -0
- package/dist/{plugin-context-BxF88sW4.cjs → plugin-context-BZs5lvDu.cjs} +3 -3
- package/dist/{plugin-context-BKK-nfOd.mjs → plugin-context-b5qVVQSU.mjs} +2 -2
- package/dist/{plugin-lifecycle-BjMclfc3.cjs → plugin-lifecycle-s89gzTlh.cjs} +1 -1
- package/dist/{registry-BbB6NqSv.d.cts → registry-B8pt41zj.d.cts} +1 -1
- package/dist/{registry-sJqDv0kE.d.mts → registry-BrrH2X9c.d.mts} +1 -1
- package/dist/routes-CzhKOw67.cjs +6 -0
- package/dist/{routes-C3_w9fLX.cjs → routes-Dq_2EUIB.cjs} +1 -1
- package/dist/routes-Dw6g0bfF.mjs +6 -0
- package/dist/search-dialog-BYZS9aeO.cjs +747 -0
- package/dist/{search-dialog-x_qHU8ty.cjs → search-dialog-CguKVtUu.cjs} +145 -5
- package/dist/{search-dialog-MmwxFMmE.js → search-dialog-DQwod5Xc.js} +1 -1
- package/dist/search-dialog-DzObE-Ar.js +717 -0
- package/dist/{search-dialog-DmirOMPg.cjs → search-dialog-QgKRRbsI.cjs} +1 -1
- package/dist/{search-dialog-BqkzDTq2.js → search-dialog-mYnqU4v7.js} +134 -6
- package/dist/{types-Db6zToZH.d.mts → types-74i_xUe2.d.mts} +1 -1
- package/dist/{types-o7iZ2BAR.d.cts → types-X_Pwk8Cg.d.cts} +1 -1
- package/dist/virtual-modules-C3S3Nz8r.cjs +40 -0
- package/dist/virtual-modules-CaxqrFd6.mjs +40 -0
- package/package.json +4 -3
- package/dist/config-CrsQJHQz.cjs +0 -7
- package/dist/config-DC0nMMk7.mjs +0 -7
- package/dist/node-C3HctGaH.cjs +0 -23
- package/dist/node-CUiheODn.mjs +0 -23
- package/dist/plugin-BX6TXR8x.cjs +0 -69
- package/dist/plugin-C8UMIA-4.mjs +0 -69
- package/dist/routes-C0kb4ue6.cjs +0 -6
- package/dist/routes-C4wrLWwu.mjs +0 -6
- package/dist/search-dialog-D3jtaw6w.cjs +0 -525
- package/dist/search-dialog-DRiXejws.js +0 -501
- package/dist/virtual-modules-XBiJoTsp.mjs +0 -39
- package/dist/virtual-modules-hndVivLR.cjs +0 -39
|
@@ -1,501 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Boltdocs - https://boltdocs.vercel.app
|
|
3
|
-
* Copyright (c) 2026 Jesus Alcala
|
|
4
|
-
* Licensed under the MIT License.
|
|
5
|
-
*/
|
|
6
|
-
import { R as Search, V as X, W as useConfig, l as useRoutesContext, o as cn, q as useBoltdocsContext, u as normalizePath } from "./link-CgdI6O2o.js";
|
|
7
|
-
import { E as useLocation, O as useNavigate } from "./router-CZBxMRAH.js";
|
|
8
|
-
import { i as ErrorBoundary, n as Navbar, t as SearchDialog$1 } from "./search-dialog-BqkzDTq2.js";
|
|
9
|
-
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
10
|
-
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
-
import { Index } from "flexsearch";
|
|
12
|
-
import fetchSearchData from "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 = useRoutesContext();
|
|
22
|
-
const allRoutes = routeContext.routes;
|
|
23
|
-
const routeIndex = routeContext.index || {
|
|
24
|
-
byPath: new Map(allRoutes.map((route) => [normalizePath(route.path), route])),
|
|
25
|
-
hintsByPath: /* @__PURE__ */ new Map(),
|
|
26
|
-
collectionNames: []
|
|
27
|
-
};
|
|
28
|
-
const config = useConfig();
|
|
29
|
-
const location = useLocation();
|
|
30
|
-
const { pathname } = location;
|
|
31
|
-
const { currentLocale: currentLocaleStore, currentVersion: currentVersionStore } = useBoltdocsContext();
|
|
32
|
-
const currentPath = normalizePath(pathname);
|
|
33
|
-
const currentRoute = routeIndex.byPath.get(currentPath);
|
|
34
|
-
const pathParts = pathname.split("/").filter(Boolean);
|
|
35
|
-
const urlLocale = config.i18n ? pathParts.find((part) => Array.isArray(config.i18n?.locales) ? config.i18n?.locales.includes(part) : part in (config.i18n?.locales || {})) : void 0;
|
|
36
|
-
const currentLocale = config.i18n ? urlLocale || currentLocaleStore || config.i18n.defaultLocale : void 0;
|
|
37
|
-
const configuredVersions = config.versions?.versions || [];
|
|
38
|
-
const currentVersion = config.versions ? configuredVersions.some((version) => version.path === currentVersionStore) ? currentVersionStore : config.versions.defaultVersion : void 0;
|
|
39
|
-
const routes = useMemo(() => {
|
|
40
|
-
if (!allRoutes) return [];
|
|
41
|
-
const alternateCounts = /* @__PURE__ */ new Map();
|
|
42
|
-
const defaultLocale = config.i18n?.defaultLocale || "";
|
|
43
|
-
const defaultVersion = config.versions?.defaultVersion || "";
|
|
44
|
-
for (const r of allRoutes) {
|
|
45
|
-
const locale = r.locale || defaultLocale;
|
|
46
|
-
const version = r.version || defaultVersion;
|
|
47
|
-
const key = `${r.filePath}::${locale}::${version}`;
|
|
48
|
-
alternateCounts.set(key, (alternateCounts.get(key) || 0) + 1);
|
|
49
|
-
}
|
|
50
|
-
return allRoutes.filter((r) => {
|
|
51
|
-
const localeMatch = config.i18n ? (r.locale || config.i18n.defaultLocale) === currentLocale : true;
|
|
52
|
-
const versionMatch = config.versions ? (r.version || config.versions.defaultVersion) === currentVersion : true;
|
|
53
|
-
if (!(localeMatch && versionMatch)) return false;
|
|
54
|
-
const pathParts = pathname.split("/").filter(Boolean);
|
|
55
|
-
const isCurrentLocalePrefixed = !!(config.i18n && pathParts.includes(currentLocaleStore || config.i18n.defaultLocale));
|
|
56
|
-
const isCurrentVersionPrefixed = !!(config.versions && !!currentVersion && pathParts.includes(currentVersion));
|
|
57
|
-
const isRouteLocalePrefixed = !!r.locale;
|
|
58
|
-
const isRouteVersionPrefixed = !!r.version;
|
|
59
|
-
const locale = r.locale || defaultLocale;
|
|
60
|
-
const version = r.version || defaultVersion;
|
|
61
|
-
const key = `${r.filePath}::${locale}::${version}`;
|
|
62
|
-
if ((alternateCounts.get(key) || 0) > 1) {
|
|
63
|
-
const localeMismatch = config.i18n && isCurrentLocalePrefixed !== isRouteLocalePrefixed;
|
|
64
|
-
const versionMismatch = config.versions && isCurrentVersionPrefixed !== isRouteVersionPrefixed;
|
|
65
|
-
if (localeMismatch || versionMismatch) return false;
|
|
66
|
-
}
|
|
67
|
-
return true;
|
|
68
|
-
});
|
|
69
|
-
}, [
|
|
70
|
-
allRoutes,
|
|
71
|
-
config,
|
|
72
|
-
pathname,
|
|
73
|
-
currentLocale,
|
|
74
|
-
currentVersion,
|
|
75
|
-
currentLocaleStore
|
|
76
|
-
]);
|
|
77
|
-
const collections = useMemo(() => new Set(routeIndex.collectionNames), [routeIndex.collectionNames]);
|
|
78
|
-
return {
|
|
79
|
-
routes,
|
|
80
|
-
allRoutes,
|
|
81
|
-
currentRoute,
|
|
82
|
-
isCollectionPage: !!currentRoute?.collection || location.pathname.split("/").filter(Boolean).some((segment) => collections.has(segment.toLowerCase())),
|
|
83
|
-
currentLocale,
|
|
84
|
-
currentVersion
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
//#endregion
|
|
89
|
-
//#region src/client/components/internal/error-boundary.tsx
|
|
90
|
-
function InternalFallback({ error, resetErrorBoundary, className }) {
|
|
91
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
92
|
-
role: "alert",
|
|
93
|
-
className: cn("p-2 font-mono flex flex-col items-center justify-between min-h-[30vh]", className),
|
|
94
|
-
children: [
|
|
95
|
-
/* @__PURE__ */ jsx("p", {
|
|
96
|
-
className: "text-lg font-semibold text-danger-500",
|
|
97
|
-
children: "Something went wrong"
|
|
98
|
-
}),
|
|
99
|
-
error?.message && /* @__PURE__ */ jsx("pre", {
|
|
100
|
-
className: "text-sm mt-2 max-w-md overflow-auto whitespace-pre-wrap break-word",
|
|
101
|
-
children: error.message
|
|
102
|
-
}),
|
|
103
|
-
error?.stack && /* @__PURE__ */ jsxs("details", {
|
|
104
|
-
className: "mt-2 max-w-md text-left text-xs",
|
|
105
|
-
children: [/* @__PURE__ */ jsx("summary", {
|
|
106
|
-
className: "cursor-pointer text-muted select-none outline-none",
|
|
107
|
-
children: "Error details"
|
|
108
|
-
}), /* @__PURE__ */ jsx("pre", {
|
|
109
|
-
className: "mt-2 p-2 bg-soft rounded border-subtle border overflow-auto max-h-48 whitespace-pre-wrap break-words",
|
|
110
|
-
children: error.stack
|
|
111
|
-
})]
|
|
112
|
-
}),
|
|
113
|
-
/* @__PURE__ */ jsxs("div", {
|
|
114
|
-
className: "flex items-center gap-2 mt-2",
|
|
115
|
-
children: [/* @__PURE__ */ jsx("button", {
|
|
116
|
-
type: "button",
|
|
117
|
-
onClick: resetErrorBoundary,
|
|
118
|
-
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",
|
|
119
|
-
children: "Try again"
|
|
120
|
-
}), typeof window !== "undefined" && /* @__PURE__ */ jsx("button", {
|
|
121
|
-
type: "button",
|
|
122
|
-
onClick: () => window.location.reload(),
|
|
123
|
-
className: "px-2 py-3 rounded font-mono font-semibold text-muted hover:text-body transition-colors cursor-pointer",
|
|
124
|
-
children: "Reload page"
|
|
125
|
-
})]
|
|
126
|
-
})
|
|
127
|
-
]
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
function InternalErrorBoundary({ children, fallback, resetKeys }) {
|
|
131
|
-
return /* @__PURE__ */ jsx(ErrorBoundary, {
|
|
132
|
-
fallback,
|
|
133
|
-
resetKeys,
|
|
134
|
-
FallbackComponent: !fallback ? InternalFallback : void 0,
|
|
135
|
-
children
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
//#endregion
|
|
140
|
-
//#region src/client/hooks/use-search.ts
|
|
141
|
-
function useSearch(routes) {
|
|
142
|
-
const { currentLocale, currentVersion } = useRoutes();
|
|
143
|
-
const config = useConfig();
|
|
144
|
-
const algoliaConfig = config.integrations?.search?.algolia;
|
|
145
|
-
const [isOpen, setIsOpen] = useState(false);
|
|
146
|
-
const [query, setQuery] = useState("");
|
|
147
|
-
const [index, setIndex] = useState(null);
|
|
148
|
-
const [algoliaResults, setAlgoliaResults] = useState([]);
|
|
149
|
-
const [searchData, setSearchData] = useState([]);
|
|
150
|
-
const [searchDataLoading, setSearchDataLoading] = useState(false);
|
|
151
|
-
const [searchDataError, setSearchDataError] = useState(null);
|
|
152
|
-
const searchGeneration = useRef(0);
|
|
153
|
-
const loadingGeneration = useRef(null);
|
|
154
|
-
const navigate = useNavigate();
|
|
155
|
-
useEffect(() => {
|
|
156
|
-
if (algoliaConfig || !isOpen) return;
|
|
157
|
-
if (searchData.length > 0) return;
|
|
158
|
-
setSearchDataLoading(true);
|
|
159
|
-
setSearchDataError(null);
|
|
160
|
-
let active = true;
|
|
161
|
-
const generation = ++searchGeneration.current;
|
|
162
|
-
loadingGeneration.current = generation;
|
|
163
|
-
fetchSearchData().then((data) => {
|
|
164
|
-
if (!active || generation !== searchGeneration.current) return;
|
|
165
|
-
setSearchData(data || []);
|
|
166
|
-
if (loadingGeneration.current === generation) {
|
|
167
|
-
loadingGeneration.current = null;
|
|
168
|
-
setSearchDataLoading(false);
|
|
169
|
-
}
|
|
170
|
-
}).catch((err) => {
|
|
171
|
-
if (!active || generation !== searchGeneration.current) return;
|
|
172
|
-
console.error("[boltdocs] Failed to load search index:", err);
|
|
173
|
-
setSearchDataError(err);
|
|
174
|
-
if (loadingGeneration.current === generation) {
|
|
175
|
-
loadingGeneration.current = null;
|
|
176
|
-
setSearchDataLoading(false);
|
|
177
|
-
}
|
|
178
|
-
});
|
|
179
|
-
return () => {
|
|
180
|
-
active = false;
|
|
181
|
-
};
|
|
182
|
-
}, [
|
|
183
|
-
isOpen,
|
|
184
|
-
algoliaConfig,
|
|
185
|
-
searchData.length
|
|
186
|
-
]);
|
|
187
|
-
useEffect(() => {
|
|
188
|
-
if (!import.meta.hot) return;
|
|
189
|
-
const applyFrontmatterDelta = (payload) => {
|
|
190
|
-
const updated = payload.search?.updated ?? [];
|
|
191
|
-
const deleted = new Set(payload.search?.deleted ?? []);
|
|
192
|
-
searchGeneration.current += 1;
|
|
193
|
-
if (loadingGeneration.current !== null) {
|
|
194
|
-
loadingGeneration.current = null;
|
|
195
|
-
setSearchDataLoading(false);
|
|
196
|
-
}
|
|
197
|
-
setSearchData((prev) => {
|
|
198
|
-
const map = new Map(prev.map((d) => [d.id, d]));
|
|
199
|
-
for (const doc of updated) map.set(doc.id, doc);
|
|
200
|
-
for (const id of deleted) map.delete(id);
|
|
201
|
-
return Array.from(map.values());
|
|
202
|
-
});
|
|
203
|
-
setIndex(null);
|
|
204
|
-
};
|
|
205
|
-
const refreshFromAsset = async () => {
|
|
206
|
-
const generation = ++searchGeneration.current;
|
|
207
|
-
loadingGeneration.current = generation;
|
|
208
|
-
setSearchDataLoading(true);
|
|
209
|
-
try {
|
|
210
|
-
const data = await fetchSearchData({ bustCache: true });
|
|
211
|
-
if (generation !== searchGeneration.current) return;
|
|
212
|
-
setSearchData(data || []);
|
|
213
|
-
setSearchDataError(null);
|
|
214
|
-
setIndex(null);
|
|
215
|
-
} catch (error) {
|
|
216
|
-
if (generation !== searchGeneration.current) return;
|
|
217
|
-
console.error("[boltdocs] Failed to refresh search index:", error);
|
|
218
|
-
setSearchDataError(error instanceof Error ? error : new Error(String(error)));
|
|
219
|
-
} finally {
|
|
220
|
-
if (generation === searchGeneration.current) {
|
|
221
|
-
loadingGeneration.current = null;
|
|
222
|
-
setSearchDataLoading(false);
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
};
|
|
226
|
-
const hot = import.meta.hot;
|
|
227
|
-
hot.on("boltdocs:frontmatter-update", applyFrontmatterDelta);
|
|
228
|
-
hot.on("boltdocs:mdx-update", refreshFromAsset);
|
|
229
|
-
return () => {
|
|
230
|
-
hot.off?.("boltdocs:frontmatter-update", applyFrontmatterDelta);
|
|
231
|
-
hot.off?.("boltdocs:mdx-update", refreshFromAsset);
|
|
232
|
-
};
|
|
233
|
-
}, []);
|
|
234
|
-
useEffect(() => {
|
|
235
|
-
const handleKeyDown = (e) => {
|
|
236
|
-
if ((/Mac/.test(navigator.userAgent) ? e.metaKey : e.ctrlKey) && (e.key === "k" || e.key === "j")) {
|
|
237
|
-
e.preventDefault();
|
|
238
|
-
setIsOpen((prev) => !prev);
|
|
239
|
-
}
|
|
240
|
-
};
|
|
241
|
-
window.addEventListener("keydown", handleKeyDown);
|
|
242
|
-
return () => window.removeEventListener("keydown", handleKeyDown);
|
|
243
|
-
}, []);
|
|
244
|
-
const handleSelect = useCallback((key) => {
|
|
245
|
-
const path = String(key);
|
|
246
|
-
if (!path) return;
|
|
247
|
-
setIsOpen(false);
|
|
248
|
-
const url = new URL(path, window.location.origin);
|
|
249
|
-
if (query) url.searchParams.set("hl", query);
|
|
250
|
-
navigate(`${url.pathname}${url.search}${url.hash}`);
|
|
251
|
-
}, [navigate, query]);
|
|
252
|
-
useEffect(() => {
|
|
253
|
-
if (algoliaConfig) return;
|
|
254
|
-
if (!isOpen || searchData.length === 0 || index) return;
|
|
255
|
-
const newIndex = new Index({
|
|
256
|
-
tokenize: "forward",
|
|
257
|
-
cache: true
|
|
258
|
-
});
|
|
259
|
-
for (let i = 0; i < searchData.length; i++) {
|
|
260
|
-
const doc = searchData[i];
|
|
261
|
-
if (!doc) continue;
|
|
262
|
-
newIndex.add(i, `${doc.title} ${doc.content}`);
|
|
263
|
-
}
|
|
264
|
-
setIndex(newIndex);
|
|
265
|
-
}, [
|
|
266
|
-
isOpen,
|
|
267
|
-
index,
|
|
268
|
-
algoliaConfig,
|
|
269
|
-
searchData
|
|
270
|
-
]);
|
|
271
|
-
useEffect(() => {
|
|
272
|
-
if (!algoliaConfig) return;
|
|
273
|
-
if (!query) {
|
|
274
|
-
setAlgoliaResults([]);
|
|
275
|
-
return;
|
|
276
|
-
}
|
|
277
|
-
const delayDebounceFn = setTimeout(async () => {
|
|
278
|
-
try {
|
|
279
|
-
const url = `https://${algoliaConfig.appId}-dsn.algolia.net/1/indexes/${algoliaConfig.indexName}/query`;
|
|
280
|
-
const facetFilters = [];
|
|
281
|
-
if (currentLocale) facetFilters.push(`lang:${currentLocale}`);
|
|
282
|
-
if (currentVersion) facetFilters.push(`version:${currentVersion}`);
|
|
283
|
-
let params = `query=${encodeURIComponent(query)}&hitsPerPage=20`;
|
|
284
|
-
if (facetFilters.length > 0) params += `&facetFilters=${encodeURIComponent(JSON.stringify(facetFilters))}`;
|
|
285
|
-
const response = await fetch(url, {
|
|
286
|
-
method: "POST",
|
|
287
|
-
headers: {
|
|
288
|
-
"Content-Type": "application/json",
|
|
289
|
-
"X-Algolia-API-Key": algoliaConfig.apiKey,
|
|
290
|
-
"X-Algolia-Application-Id": algoliaConfig.appId
|
|
291
|
-
},
|
|
292
|
-
body: JSON.stringify({ params })
|
|
293
|
-
});
|
|
294
|
-
if (!response.ok) throw new Error(`Algolia search request failed: ${response.statusText}`);
|
|
295
|
-
setAlgoliaResults(((await response.json()).hits || []).map((hit) => {
|
|
296
|
-
let path = hit.url || "";
|
|
297
|
-
try {
|
|
298
|
-
if (path.startsWith("http://") || path.startsWith("https://")) {
|
|
299
|
-
const urlObj = new URL(path);
|
|
300
|
-
path = urlObj.pathname + urlObj.search + urlObj.hash;
|
|
301
|
-
}
|
|
302
|
-
} catch {}
|
|
303
|
-
const hierarchy = hit.hierarchy || {};
|
|
304
|
-
const levels = [
|
|
305
|
-
hierarchy.lvl0,
|
|
306
|
-
hierarchy.lvl1,
|
|
307
|
-
hierarchy.lvl2,
|
|
308
|
-
hierarchy.lvl3,
|
|
309
|
-
hierarchy.lvl4,
|
|
310
|
-
hierarchy.lvl5,
|
|
311
|
-
hierarchy.lvl6
|
|
312
|
-
].filter(Boolean);
|
|
313
|
-
const title = levels[levels.length - 1] || "Documentation";
|
|
314
|
-
const bio = levels.join(" > ");
|
|
315
|
-
return {
|
|
316
|
-
id: hit.objectID || path,
|
|
317
|
-
title,
|
|
318
|
-
path,
|
|
319
|
-
bio,
|
|
320
|
-
groupTitle: hierarchy.lvl0 || "Docs",
|
|
321
|
-
isHeading: !!hit.anchor || path.includes("#")
|
|
322
|
-
};
|
|
323
|
-
}));
|
|
324
|
-
} catch (err) {
|
|
325
|
-
console.error("Error fetching search results from Algolia:", err);
|
|
326
|
-
}
|
|
327
|
-
}, 250);
|
|
328
|
-
return () => clearTimeout(delayDebounceFn);
|
|
329
|
-
}, [
|
|
330
|
-
query,
|
|
331
|
-
algoliaConfig,
|
|
332
|
-
currentLocale,
|
|
333
|
-
currentVersion
|
|
334
|
-
]);
|
|
335
|
-
return {
|
|
336
|
-
isOpen,
|
|
337
|
-
setIsOpen,
|
|
338
|
-
query,
|
|
339
|
-
setQuery,
|
|
340
|
-
list: useMemo(() => {
|
|
341
|
-
if (!query) return routes.filter((r) => {
|
|
342
|
-
const routeLocale = r.locale || config.i18n?.defaultLocale;
|
|
343
|
-
const routeVersion = r.version || config.versions?.defaultVersion;
|
|
344
|
-
return (!currentLocale || routeLocale === currentLocale) && (!currentVersion || routeVersion === currentVersion);
|
|
345
|
-
}).slice(0, 10).map((r) => ({
|
|
346
|
-
id: r.path,
|
|
347
|
-
title: r.title,
|
|
348
|
-
path: r.path,
|
|
349
|
-
bio: r.description || "",
|
|
350
|
-
groupTitle: r.groupTitle
|
|
351
|
-
}));
|
|
352
|
-
if (algoliaConfig) return algoliaResults;
|
|
353
|
-
if (!index) return [];
|
|
354
|
-
const searchResults = index.search(query, {
|
|
355
|
-
limit: 20,
|
|
356
|
-
suggest: true
|
|
357
|
-
});
|
|
358
|
-
const results = [];
|
|
359
|
-
const seen = /* @__PURE__ */ new Set();
|
|
360
|
-
for (const id of searchResults) {
|
|
361
|
-
const doc = searchData[typeof id === "number" ? id : Number(id)];
|
|
362
|
-
if (!doc) continue;
|
|
363
|
-
const docLocale = doc.locale || config.i18n?.defaultLocale;
|
|
364
|
-
const docVersion = doc.version || config.versions?.defaultVersion;
|
|
365
|
-
const localeMatch = !currentLocale || docLocale === currentLocale || !doc.locale && currentLocale === config.i18n?.defaultLocale;
|
|
366
|
-
if (!(!currentVersion || docVersion === currentVersion)) continue;
|
|
367
|
-
if (seen.has(doc.url)) continue;
|
|
368
|
-
seen.add(doc.url);
|
|
369
|
-
results.push({
|
|
370
|
-
id: doc.url,
|
|
371
|
-
title: doc.title,
|
|
372
|
-
path: doc.url,
|
|
373
|
-
bio: doc.display,
|
|
374
|
-
groupTitle: doc.display.split(" > ")[0],
|
|
375
|
-
isHeading: doc.url.includes("#"),
|
|
376
|
-
localeMatch
|
|
377
|
-
});
|
|
378
|
-
}
|
|
379
|
-
return results.filter((result) => result.localeMatch).slice(0, 10);
|
|
380
|
-
}, [
|
|
381
|
-
query,
|
|
382
|
-
index,
|
|
383
|
-
currentLocale,
|
|
384
|
-
currentVersion,
|
|
385
|
-
routes,
|
|
386
|
-
searchData,
|
|
387
|
-
algoliaConfig,
|
|
388
|
-
algoliaResults,
|
|
389
|
-
config
|
|
390
|
-
]),
|
|
391
|
-
searchDataLoading,
|
|
392
|
-
searchDataError,
|
|
393
|
-
handleSelect,
|
|
394
|
-
input: {
|
|
395
|
-
value: query,
|
|
396
|
-
onChange: (e) => setQuery(e.target.value)
|
|
397
|
-
}
|
|
398
|
-
};
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
//#endregion
|
|
402
|
-
//#region src/client/components/ui-base/search-dialog.tsx
|
|
403
|
-
function Highlight({ text, query, markClassName }) {
|
|
404
|
-
if (!query || !text) return /* @__PURE__ */ jsx(Fragment$1, { children: text });
|
|
405
|
-
const escapedQuery = query.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
406
|
-
const regex = new RegExp(`(${escapedQuery})`, "gi");
|
|
407
|
-
return /* @__PURE__ */ jsx(Fragment$1, { children: text.split(regex).map((part, i) => regex.test(part) ? /* @__PURE__ */ jsx("mark", {
|
|
408
|
-
className: cn("bg-primary-500/20 text-primary-600 dark:text-primary-400 font-bold px-0.5 rounded-sm", markClassName),
|
|
409
|
-
children: part
|
|
410
|
-
}, i) : part) });
|
|
411
|
-
}
|
|
412
|
-
function SearchDialog({ routes, className, markClassName }) {
|
|
413
|
-
const { isOpen, setIsOpen, query, setQuery, list, searchDataLoading, searchDataError, handleSelect } = useSearch(routes);
|
|
414
|
-
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
415
|
-
/* @__PURE__ */ jsxs(Navbar.SearchTrigger.Desktop, {
|
|
416
|
-
onPress: () => setIsOpen(true),
|
|
417
|
-
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",
|
|
418
|
-
children: [/* @__PURE__ */ jsxs("div", {
|
|
419
|
-
className: "flex items-center gap-2",
|
|
420
|
-
children: [/* @__PURE__ */ jsx(Search, { size: 16 }), /* @__PURE__ */ jsx("span", {
|
|
421
|
-
className: "hidden sm:inline-block",
|
|
422
|
-
children: "Search docs..."
|
|
423
|
-
})]
|
|
424
|
-
}), /* @__PURE__ */ jsx(Navbar.SearchTrigger.Kbd, { className: "[&_kbd]:bg-main [&_kbd]:border [&_kbd]:border-subtle [&_kbd]:rounded [&_kbd]:px-1.5 [&_kbd]:h-5 [&_kbd]:w-5" })]
|
|
425
|
-
}),
|
|
426
|
-
/* @__PURE__ */ jsx(Navbar.SearchTrigger.Mobile, {
|
|
427
|
-
onPress: () => setIsOpen(true),
|
|
428
|
-
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",
|
|
429
|
-
children: /* @__PURE__ */ jsx(Search, { size: 20 })
|
|
430
|
-
}),
|
|
431
|
-
/* @__PURE__ */ jsx(InternalErrorBoundary, { children: /* @__PURE__ */ jsx(SearchDialog$1.Overlay, {
|
|
432
|
-
isOpen,
|
|
433
|
-
isDismissable: true,
|
|
434
|
-
onOpenChange: () => setIsOpen(false),
|
|
435
|
-
className: cn("fixed inset-0 z-100 flex items-center justify-center p-4 bg-black/40 backdrop-blur-xs animate-fade-in", className),
|
|
436
|
-
children: /* @__PURE__ */ jsx(SearchDialog$1.Content, {
|
|
437
|
-
className: "w-full max-w-lg bg-main border border-subtle shadow-md rounded-2xl overflow-hidden p-6",
|
|
438
|
-
children: /* @__PURE__ */ jsx(SearchDialog$1.Dialog, {
|
|
439
|
-
"aria-label": "Search documentation",
|
|
440
|
-
className: "flex flex-col min-h-0 h-[450px]",
|
|
441
|
-
children: /* @__PURE__ */ jsxs(SearchDialog$1.Autocomplete, {
|
|
442
|
-
className: "flex flex-col min-h-0",
|
|
443
|
-
children: [/* @__PURE__ */ jsxs(SearchDialog$1.Input, {
|
|
444
|
-
value: query,
|
|
445
|
-
onChange: setQuery,
|
|
446
|
-
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",
|
|
447
|
-
children: [/* @__PURE__ */ jsx(SearchDialog$1.Input.SearchInput, {
|
|
448
|
-
placeholder: "Search documentation...",
|
|
449
|
-
className: "w-full bg-transparent outline-none text-body text-sm"
|
|
450
|
-
}), query && /* @__PURE__ */ jsx(SearchDialog$1.Input.Button, {
|
|
451
|
-
onPress: () => setQuery(""),
|
|
452
|
-
className: "text-muted hover:text-body hover:bg-surface rounded-md p-1 cursor-pointer select-none transition-colors",
|
|
453
|
-
children: /* @__PURE__ */ jsx(X, { size: 16 })
|
|
454
|
-
})]
|
|
455
|
-
}), searchDataLoading ? /* @__PURE__ */ jsx("div", {
|
|
456
|
-
className: "flex flex-1 items-center justify-center px-4 py-8 text-sm text-muted",
|
|
457
|
-
children: "Loading search index…"
|
|
458
|
-
}) : searchDataError ? /* @__PURE__ */ jsx("div", {
|
|
459
|
-
className: "flex flex-1 items-center justify-center px-4 py-8 text-center text-sm text-muted",
|
|
460
|
-
children: "Search is temporarily unavailable."
|
|
461
|
-
}) : query && list.length === 0 ? /* @__PURE__ */ jsx("div", {
|
|
462
|
-
className: "flex flex-1 items-center justify-center px-4 py-8 text-sm text-muted",
|
|
463
|
-
children: "No results found."
|
|
464
|
-
}) : /* @__PURE__ */ jsx(SearchDialog$1.List, {
|
|
465
|
-
items: list,
|
|
466
|
-
onAction: handleSelect,
|
|
467
|
-
children: (item) => /* @__PURE__ */ jsxs(SearchDialog$1.Item, {
|
|
468
|
-
textValue: item.title,
|
|
469
|
-
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",
|
|
470
|
-
children: [/* @__PURE__ */ jsx(SearchDialog$1.Item.Icon, {
|
|
471
|
-
isHeading: item.isHeading,
|
|
472
|
-
className: "text-muted group-hover:text-primary-500 group-focus:text-primary-500"
|
|
473
|
-
}), /* @__PURE__ */ jsxs("div", {
|
|
474
|
-
className: "flex flex-col justify-center min-w-0",
|
|
475
|
-
children: [/* @__PURE__ */ jsx(SearchDialog$1.Item.Title, {
|
|
476
|
-
className: "text-sm font-medium text-body truncate dark:group-hover:text-primary-100",
|
|
477
|
-
children: /* @__PURE__ */ jsx(Highlight, {
|
|
478
|
-
text: item.title,
|
|
479
|
-
query,
|
|
480
|
-
markClassName
|
|
481
|
-
})
|
|
482
|
-
}), /* @__PURE__ */ jsx(SearchDialog$1.Item.Bio, {
|
|
483
|
-
className: "text-xs text-muted truncate",
|
|
484
|
-
children: /* @__PURE__ */ jsx(Highlight, {
|
|
485
|
-
text: item.bio,
|
|
486
|
-
query,
|
|
487
|
-
markClassName
|
|
488
|
-
})
|
|
489
|
-
})]
|
|
490
|
-
})]
|
|
491
|
-
}, item.id)
|
|
492
|
-
})]
|
|
493
|
-
})
|
|
494
|
-
})
|
|
495
|
-
})
|
|
496
|
-
}) })
|
|
497
|
-
] });
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
//#endregion
|
|
501
|
-
export { useRoutes as i, useSearch as n, InternalErrorBoundary as r, SearchDialog as t };
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Boltdocs - https://boltdocs.vercel.app
|
|
3
|
-
* Copyright (c) 2026 Jesus Alcala
|
|
4
|
-
* Licensed under the MIT License.
|
|
5
|
-
*/
|
|
6
|
-
import{_ as e,g as t,h as n}from"./plugin-context-BKK-nfOd.mjs";import{u as r}from"./utils-8lzafE49.mjs";import{c as i,l as a,s as o,t as s}from"./routes-C4wrLWwu.mjs";import c from"node:path";import l from"node:fs";function u(e){return typeof e==`string`?[e]:Array.isArray(e)?e.flatMap(u):e&&typeof e==`object`?Object.values(e).flatMap(u):[]}const d=new Set([`title`,`description`,`permalink`,`sidebarPosition`,`sidebarLabel`,`sidebarHidden`,`hidden`,`category`,`order`,`badge`,`icon`,`date`,`lastUpdated`,`groupTitle`,`groupPosition`,`seo`]);function f(e){let t=[];for(let n of e){let e=``;n.frontmatter&&(e=u(Object.entries(n.frontmatter).filter(([e])=>!d.has(e)).map(([e,t])=>t)).join(` `));let r=(e?`${n._content||``} ${e}`:n._content||``).slice(0,500);if(t.push({id:n.path,title:n.title,content:r,url:n.path,display:n.groupTitle?`${n.groupTitle} > ${n.title}`:n.title,locale:n.locale,version:n.version}),n.headings)for(let e of n.headings)t.push({id:`${n.path}#${e.id}`,title:e.text,content:`${e.text} in ${n.title}`,url:`${n.path}#${e.id}`,display:`${n.title} > ${e.text}`,locale:n.locale,version:n.version})}return t}function p(e){return{path:e.path,filePath:e.filePath,title:e.title,description:e.description||``,sidebarPosition:e.sidebarPosition,badge:e.badge,icon:e.icon,headings:e.headings||[],frontmatter:e.frontmatter,locale:e.locale,version:e.version,tab:e.tab,collection:e.collection,tags:e.tags,author:e.author,draft:e.draft,excerpt:e.excerpt,coverImage:e.coverImage,group:e.group,groupTitle:e.groupTitle,groupPosition:e.groupPosition,groupIcon:e.groupIcon,subRouteGroup:e.subRouteGroup,seo:e.seo,date:e.date,lastUpdated:e.lastUpdated,category:e.category,order:e.order,sidebarLabel:e.sidebarLabel,sidebarHidden:e.sidebarHidden,slugParts:e.slugParts}}function m(e){return{routeCacheContext:e,routeGenerationFingerprint:void 0,directoryMetaCache:null,routesDataMap:new Map,collectionsDataMap:new Map,searchDataMap:new Map}}const h=m();function g(e){return e??h}function _(e){let t=g(e);t.directoryMetaCache=null,t.routeGenerationFingerprint=void 0,t.routeCacheVariant=void 0,t.routesDataMap.clear(),t.collectionsDataMap.clear(),t.searchDataMap.clear()}function v(e,t){return(!t.routeCacheContext||t.routeCacheContext.disposed)&&(t.routeCacheContext=o(e),t.routeCacheVariant=void 0,t.routeGenerationFingerprint=void 0,t.routesDataMap.clear(),t.collectionsDataMap.clear(),t.searchDataMap.clear()),t.routeCacheContext}async function y(e,t,n,r){let o=g(n),c=v(e,o),l=a(t),u=(r?.fingerprint===l&&c.variants.get(l)===r?r:void 0)??i(c,l);o.routeCacheVariant=u,o.routeGenerationFingerprint=l;let d=await s(e,t,void 0,!1,c,u);o.routesDataMap.clear();for(let e of d)o.routesDataMap.set(e.path,e);b(o)}function b(e){let t=g(e),n=Array.from(t.routesDataMap.values()),r=f(n);t.searchDataMap.clear();for(let e of r)t.searchDataMap.set(e.id,e);t.collectionsDataMap.clear();for(let e of n)if(e.collection){let n={path:e.path,title:e.title,date:e.date,excerpt:e.excerpt,tags:e.tags,author:e.author,coverImage:e.coverImage,filePath:e.filePath,locale:e.locale,version:e.version,frontmatter:e.frontmatter,draft:e.frontmatter?.draft,collection:e.collection};t.collectionsDataMap.set(e.filePath,n)}}async function x(e,t,n){let r=g(n);v(e,r);let i=a(t);(r.routesDataMap.size===0||r.routeGenerationFingerprint!==i)&&(r.routesDataMap.clear(),r.collectionsDataMap.clear(),r.searchDataMap.clear(),await y(e,t,r))}function S(e){let t=g(e),n={},r=Array.from(t.collectionsDataMap.values()).sort((e,t)=>{let n=e=>{if(!e)return-1/0;let t=new Date(e).getTime();return Number.isFinite(t)?t:-1/0},r=n(e.date),i=n(t.date)-r;return i===0?e.path.localeCompare(t.path):i});for(let e of r){let t=e.collection;t&&(n[t]||(n[t]=[]),n[t].push(e))}return n}function C(e,t=e=>e){let n=Array.from(e.values(),t).sort((e,t)=>{let n=e=>{if(typeof e!=`object`||!e)return String(e);let t=e;return`${String(t.path||``)}\u0000${String(t.id||``)}\u0000${String(t.filePath||``)}`};return n(e).localeCompare(n(t))});return`export default ${JSON.stringify(n)};`}function w(e){return Array.from(g(e).searchDataMap.values()).sort((e,t)=>e.id.localeCompare(t.id))}function T(e){return`export default ${JSON.stringify(e)};`}async function E(e,t,n,r,i){let o=g(n);r&&(o.routeCacheContext=r),i&&(o.routeCacheVariant=i);let s=a(t);o.routeGenerationFingerprint!==s&&(o.routesDataMap.clear(),o.collectionsDataMap.clear(),o.searchDataMap.clear());let c=new Map(o.routesDataMap),l=new Map(o.collectionsDataMap),u=new Map(o.searchDataMap);await y(e,t,o);let d={routes:{updated:[],deleted:[]},collections:{updated:[],deleted:[]},search:{updated:[],deleted:[]}};for(let[e,t]of o.routesDataMap){let n=c.get(e);(!n||JSON.stringify(n)!==JSON.stringify(t))&&d.routes.updated.push(p(t))}for(let e of c.keys())o.routesDataMap.has(e)||d.routes.deleted.push(e);for(let[e,t]of o.collectionsDataMap){let n=l.get(e);(!n||JSON.stringify(n)!==JSON.stringify(t))&&d.collections.updated.push(t)}for(let e of l.keys())o.collectionsDataMap.has(e)||d.collections.deleted.push(e);for(let[e,t]of o.searchDataMap){let n=u.get(e);(!n||JSON.stringify(n)!==JSON.stringify(t))&&d.search.updated.push(t)}for(let e of u.keys())o.searchDataMap.has(e)||d.search.deleted.push(e);return d}function D(i,a,o,s,u,d){let f=u?.virtualModuleRegistry??n,m=g(d);return{name:`vite-plugin-boltdocs-virtual-modules`,resolveId(e){if(o()?.root||process.cwd(),e.includes(`boltdocs-entry`)||e===`virtual:boltdocs-entry`||e===`boltdocs/entry`||e===`boltdocs-entry`||e===`\0virtual:boltdocs-entry`||e===`\0virtual:boltdocs-entry.tsx`)return`\0virtual:boltdocs-entry.tsx`;if(e.includes(`boltdocs-client`)||e===`virtual:boltdocs-client`||e===`boltdocs/client`||e===`boltdocs-client`||e===`\0virtual:boltdocs-client.mjs`)return`\0virtual:boltdocs-client.mjs`;if(e.startsWith(`\0`)){let t=e.slice(1);if(!t.startsWith(`virtual:boltdocs-`)&&f?.has(t))return e}else if(!e.startsWith(`virtual:boltdocs-`)&&f?.has(e))return`\0`+e;return e.startsWith(`virtual:boltdocs-`)?`\0`+e:e.startsWith(`\0virtual:boltdocs-`)?e:null},async load(n,u){let d=a(),h=n.startsWith(`\0`)?n.slice(1):n;if(!h.includes(`boltdocs-entry.tsx`)&&!h.includes(`boltdocs-client.mjs`)&&!h.startsWith(`virtual:boltdocs-`)&&f?.has(h)){let e=f?.get(h);if(!e)return null;try{let t=await e.loader();if(typeof t!=`string`)throw Error(`[boltdocs] Plugin virtual module '${h}' loader must return a string source code, got ${typeof t}.`);return t}catch(e){throw Error(`[boltdocs] Plugin virtual module '${h}' failed to load: ${e instanceof Error?e.message:String(e)}`)}}if(n.includes(`boltdocs-entry.tsx`)||n===`\0virtual:boltdocs-entry`){let e=this.environment?.config?.consumer,n=o(),r=e===void 0?!!n?.build?.ssr:e!==`client`;return t({...i,ssr:r,useCompiledPages:n?.command===`build`},d)}if(n.includes(`boltdocs-client.mjs`)||n===`\0virtual:boltdocs-client.ts`||n===`virtual:boltdocs-client`){let t=e,n=t;for(;t!==c.parse(t).root;){if(l.existsSync(c.join(t,`package.json`))&&JSON.parse(l.readFileSync(c.join(t,`package.json`),`utf-8`)).name===`boltdocs`){n=t;break}t=c.dirname(t)}let i=c.join(n,`src/client/index.ts`),a=c.join(n,`dist/client/index.js`);return`export * from '${r(l.existsSync(i)?i:a)}';`}if(!n.startsWith(`\0virtual:boltdocs-`))return;let g=n.replace(`\0virtual:boltdocs-`,``).replace(/\.tsx?$/,``);if(g===`routes`)return await x(s,d,m),C(m.routesDataMap,p);if(g===`collections`)return await x(s,d,m),T(S(m));if(g===`config`){await x(s,d,m);let e=m.routeCacheVariant?.directoryMeta||{};m.directoryMetaCache=e;let t=[...new Set(Array.from(m.routesDataMap.values()).map(e=>e.collection).filter(e=>!!e))].sort((e,t)=>e.localeCompare(t)),n=d?.collections,r=n?{...n,labels:{...n.labels||{},...Object.fromEntries(t.map(e=>[e,n.labels?.[e]??e]))}}:t.length>0?t:void 0,i={base:d?.base,theme:d?.theme,i18n:d?.i18n,versions:d?.versions,siteUrl:d?.siteUrl,integrations:d?.integrations,collections:r,seo:d?.seo,experimental:d?.experimental,plugins:d?.plugins?.map(e=>({name:e.name})),directoryMeta:e};return`export default ${JSON.stringify(i,null,2)};`}if(g===`entry`){let e=this,n=o(),r=e.environment?.config?.consumer,a=r===void 0?!!(u?.ssr??n?.build?.ssr):r!==`client`;return t({...i,ssr:a,useCompiledPages:n?.command===`build`},d)}if(g===`mdx-components`){let e=[`tsx`,`ts`,`jsx`,`js`],t=null;for(let n of e){let e=c.resolve(s,`mdx-components.${n}`);if(l.existsSync(e)){t=e;break}}let n={};if(d?.plugins)for(let e of d.plugins)e.components&&Object.assign(n,e.components);let i=Object.entries(n),a=i.map(([e,t],n)=>`import * as _pluginCompMod_${n} from '${t}';`).join(`
|
|
7
|
-
`),o=i.map(([e],t)=>`${JSON.stringify(e)}: _pluginCompMod_${t}[${JSON.stringify(e)}] || _pluginCompMod_${t}["default"] || _pluginCompMod_${t}`).join(`,
|
|
8
|
-
`);if(t){let e=r(t);return`${a}
|
|
9
|
-
import * as components from '${e}';
|
|
10
|
-
const userMdxComponents = components.default || components;
|
|
11
|
-
const mdxComponents = {
|
|
12
|
-
${o}${o?`,`:``}
|
|
13
|
-
...userMdxComponents,
|
|
14
|
-
};
|
|
15
|
-
export default mdxComponents;
|
|
16
|
-
export * from '${e}';`}return`${a}
|
|
17
|
-
const mdxComponents = {
|
|
18
|
-
${o}
|
|
19
|
-
};
|
|
20
|
-
export default mdxComponents;`}if(g===`layout`){let e=[`tsx`,`jsx`],t=null;for(let n of e){let e=c.resolve(s,`layout.${n}`);if(l.existsSync(e)){t=e;break}}if(t)return`import UserLayout from '${r(t)}';
|
|
21
|
-
export default UserLayout;`;throw Error(`[Boltdocs] Layout file not found. A 'layout.tsx' or 'layout.jsx' file is mandatory in your docs directory. Please create one to define your site structure.`)}if(g===`icons`){let e=[`tsx`,`jsx`,`ts`,`js`],t=null;for(let n of e){let e=c.resolve(s,`icons.${n}`);if(l.existsSync(e)){t=e;break}}return t?`import * as icons from '${r(t)}';\nexport default icons;`:`export default {};`}if(g===`search`)return await x(s,d,m),`export default async function fetchSearchData(options = {}) {
|
|
22
|
-
const base = import.meta.env.BASE_URL || '/';
|
|
23
|
-
const origin = typeof window !== 'undefined' ? window.location.origin : 'http://localhost';
|
|
24
|
-
const basePath = base.endsWith('/') ? base : base + '/';
|
|
25
|
-
const url = new URL('search.json', new URL(basePath, origin));
|
|
26
|
-
if (options.bustCache) url.searchParams.set('t', String(Date.now()));
|
|
27
|
-
const res = await fetch(url, { cache: options.bustCache ? 'no-store' : 'default' });
|
|
28
|
-
if (!res.ok) throw new Error('Failed to fetch search index');
|
|
29
|
-
return res.json();
|
|
30
|
-
}`;if(g===`page-source`){await x(s,d,m);let e={};for(let t of m.routesDataMap.values())t.path&&t._rawContent&&(e[t.path]=t._rawContent);return`export default async function fetchPageSource(options = {}) {
|
|
31
|
-
const base = import.meta.env.BASE_URL || '/';
|
|
32
|
-
const origin = typeof window !== 'undefined' ? window.location.origin : 'http://localhost';
|
|
33
|
-
const basePath = base.endsWith('/') ? base : base + '/';
|
|
34
|
-
const url = new URL('page-source.json', new URL(basePath, origin));
|
|
35
|
-
if (options.bustCache) url.searchParams.set('t', String(Date.now()));
|
|
36
|
-
const res = await fetch(url, { cache: options.bustCache ? 'no-store' : 'default' });
|
|
37
|
-
if (!res.ok) throw new Error('Failed to fetch page source');
|
|
38
|
-
return res.json();
|
|
39
|
-
}`}if(g===`client`){let t=e,n=``;for(;t&&t!==c.parse(t).root;){let e=c.join(t,`src/client/index.ts`),i=c.join(t,`dist/client/index.mjs`),a=c.join(t,`client/index.ts`);if(l.existsSync(e)){n=r(e);break}if(l.existsSync(i)){n=r(i);break}if(l.existsSync(a)){n=r(a);break}t=c.dirname(t)}if(!n)throw Error(`[boltdocs] Could not resolve boltdocs/client entry point starting from ${e}`);return`export * from '${n}';`}}}}export{E as computeFrontmatterDelta,m as createVirtualModuleState,D as createVirtualModulesPlugin,w as getSearchDataExport,_ as invalidateDirectoryMetaCache};
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Boltdocs - https://boltdocs.vercel.app
|
|
3
|
-
* Copyright (c) 2026 Jesus Alcala
|
|
4
|
-
* Licensed under the MIT License.
|
|
5
|
-
*/
|
|
6
|
-
const e=require(`./chunk-D1Md3oWO.cjs`),t=require(`./utils-ej6_SjIZ.cjs`),n=require(`./plugin-context-BxF88sW4.cjs`),r=require(`./routes-C0kb4ue6.cjs`);let i=require(`node:path`);i=e.r(i);let a=require(`node:fs`);a=e.r(a);function o(e){return typeof e==`string`?[e]:Array.isArray(e)?e.flatMap(o):e&&typeof e==`object`?Object.values(e).flatMap(o):[]}const s=new Set([`title`,`description`,`permalink`,`sidebarPosition`,`sidebarLabel`,`sidebarHidden`,`hidden`,`category`,`order`,`badge`,`icon`,`date`,`lastUpdated`,`groupTitle`,`groupPosition`,`seo`]);function c(e){let t=[];for(let n of e){let e=``;n.frontmatter&&(e=o(Object.entries(n.frontmatter).filter(([e])=>!s.has(e)).map(([e,t])=>t)).join(` `));let r=(e?`${n._content||``} ${e}`:n._content||``).slice(0,500);if(t.push({id:n.path,title:n.title,content:r,url:n.path,display:n.groupTitle?`${n.groupTitle} > ${n.title}`:n.title,locale:n.locale,version:n.version}),n.headings)for(let e of n.headings)t.push({id:`${n.path}#${e.id}`,title:e.text,content:`${e.text} in ${n.title}`,url:`${n.path}#${e.id}`,display:`${n.title} > ${e.text}`,locale:n.locale,version:n.version})}return t}function l(e){return{path:e.path,filePath:e.filePath,title:e.title,description:e.description||``,sidebarPosition:e.sidebarPosition,badge:e.badge,icon:e.icon,headings:e.headings||[],frontmatter:e.frontmatter,locale:e.locale,version:e.version,tab:e.tab,collection:e.collection,tags:e.tags,author:e.author,draft:e.draft,excerpt:e.excerpt,coverImage:e.coverImage,group:e.group,groupTitle:e.groupTitle,groupPosition:e.groupPosition,groupIcon:e.groupIcon,subRouteGroup:e.subRouteGroup,seo:e.seo,date:e.date,lastUpdated:e.lastUpdated,category:e.category,order:e.order,sidebarLabel:e.sidebarLabel,sidebarHidden:e.sidebarHidden,slugParts:e.slugParts}}function u(e){return{routeCacheContext:e,routeGenerationFingerprint:void 0,directoryMetaCache:null,routesDataMap:new Map,collectionsDataMap:new Map,searchDataMap:new Map}}const d=u();function f(e){return e??d}function p(e){let t=f(e);t.directoryMetaCache=null,t.routeGenerationFingerprint=void 0,t.routeCacheVariant=void 0,t.routesDataMap.clear(),t.collectionsDataMap.clear(),t.searchDataMap.clear()}function m(e,t){return(!t.routeCacheContext||t.routeCacheContext.disposed)&&(t.routeCacheContext=r.s(e),t.routeCacheVariant=void 0,t.routeGenerationFingerprint=void 0,t.routesDataMap.clear(),t.collectionsDataMap.clear(),t.searchDataMap.clear()),t.routeCacheContext}async function h(e,t,n,i){let a=f(n),o=m(e,a),s=r.l(t),c=(i?.fingerprint===s&&o.variants.get(s)===i?i:void 0)??r.c(o,s);a.routeCacheVariant=c,a.routeGenerationFingerprint=s;let l=await r.t(e,t,void 0,!1,o,c);a.routesDataMap.clear();for(let e of l)a.routesDataMap.set(e.path,e);g(a)}function g(e){let t=f(e),n=Array.from(t.routesDataMap.values()),r=c(n);t.searchDataMap.clear();for(let e of r)t.searchDataMap.set(e.id,e);t.collectionsDataMap.clear();for(let e of n)if(e.collection){let n={path:e.path,title:e.title,date:e.date,excerpt:e.excerpt,tags:e.tags,author:e.author,coverImage:e.coverImage,filePath:e.filePath,locale:e.locale,version:e.version,frontmatter:e.frontmatter,draft:e.frontmatter?.draft,collection:e.collection};t.collectionsDataMap.set(e.filePath,n)}}async function _(e,t,n){let i=f(n);m(e,i);let a=r.l(t);(i.routesDataMap.size===0||i.routeGenerationFingerprint!==a)&&(i.routesDataMap.clear(),i.collectionsDataMap.clear(),i.searchDataMap.clear(),await h(e,t,i))}function v(e){let t=f(e),n={},r=Array.from(t.collectionsDataMap.values()).sort((e,t)=>{let n=e=>{if(!e)return-1/0;let t=new Date(e).getTime();return Number.isFinite(t)?t:-1/0},r=n(e.date),i=n(t.date)-r;return i===0?e.path.localeCompare(t.path):i});for(let e of r){let t=e.collection;t&&(n[t]||(n[t]=[]),n[t].push(e))}return n}function y(e,t=e=>e){let n=Array.from(e.values(),t).sort((e,t)=>{let n=e=>{if(typeof e!=`object`||!e)return String(e);let t=e;return`${String(t.path||``)}\u0000${String(t.id||``)}\u0000${String(t.filePath||``)}`};return n(e).localeCompare(n(t))});return`export default ${JSON.stringify(n)};`}function b(e){return Array.from(f(e).searchDataMap.values()).sort((e,t)=>e.id.localeCompare(t.id))}function x(e){return`export default ${JSON.stringify(e)};`}async function S(e,t,n,i,a){let o=f(n);i&&(o.routeCacheContext=i),a&&(o.routeCacheVariant=a);let s=r.l(t);o.routeGenerationFingerprint!==s&&(o.routesDataMap.clear(),o.collectionsDataMap.clear(),o.searchDataMap.clear());let c=new Map(o.routesDataMap),u=new Map(o.collectionsDataMap),d=new Map(o.searchDataMap);await h(e,t,o);let p={routes:{updated:[],deleted:[]},collections:{updated:[],deleted:[]},search:{updated:[],deleted:[]}};for(let[e,t]of o.routesDataMap){let n=c.get(e);(!n||JSON.stringify(n)!==JSON.stringify(t))&&p.routes.updated.push(l(t))}for(let e of c.keys())o.routesDataMap.has(e)||p.routes.deleted.push(e);for(let[e,t]of o.collectionsDataMap){let n=u.get(e);(!n||JSON.stringify(n)!==JSON.stringify(t))&&p.collections.updated.push(t)}for(let e of u.keys())o.collectionsDataMap.has(e)||p.collections.deleted.push(e);for(let[e,t]of o.searchDataMap){let n=d.get(e);(!n||JSON.stringify(n)!==JSON.stringify(t))&&p.search.updated.push(t)}for(let e of d.keys())o.searchDataMap.has(e)||p.search.deleted.push(e);return p}function C(e,r,o,s,c,u){let d=c?.virtualModuleRegistry??n.h,p=f(u);return{name:`vite-plugin-boltdocs-virtual-modules`,resolveId(e){if(o()?.root||process.cwd(),e.includes(`boltdocs-entry`)||e===`virtual:boltdocs-entry`||e===`boltdocs/entry`||e===`boltdocs-entry`||e===`\0virtual:boltdocs-entry`||e===`\0virtual:boltdocs-entry.tsx`)return`\0virtual:boltdocs-entry.tsx`;if(e.includes(`boltdocs-client`)||e===`virtual:boltdocs-client`||e===`boltdocs/client`||e===`boltdocs-client`||e===`\0virtual:boltdocs-client.mjs`)return`\0virtual:boltdocs-client.mjs`;if(e.startsWith(`\0`)){let t=e.slice(1);if(!t.startsWith(`virtual:boltdocs-`)&&d?.has(t))return e}else if(!e.startsWith(`virtual:boltdocs-`)&&d?.has(e))return`\0`+e;return e.startsWith(`virtual:boltdocs-`)?`\0`+e:e.startsWith(`\0virtual:boltdocs-`)?e:null},async load(c,u){let f=r(),m=c.startsWith(`\0`)?c.slice(1):c;if(!m.includes(`boltdocs-entry.tsx`)&&!m.includes(`boltdocs-client.mjs`)&&!m.startsWith(`virtual:boltdocs-`)&&d?.has(m)){let e=d?.get(m);if(!e)return null;try{let t=await e.loader();if(typeof t!=`string`)throw Error(`[boltdocs] Plugin virtual module '${m}' loader must return a string source code, got ${typeof t}.`);return t}catch(e){throw Error(`[boltdocs] Plugin virtual module '${m}' failed to load: ${e instanceof Error?e.message:String(e)}`)}}if(c.includes(`boltdocs-entry.tsx`)||c===`\0virtual:boltdocs-entry`){let t=this.environment?.config?.consumer,r=o(),i=t===void 0?!!r?.build?.ssr:t!==`client`;return n.g({...e,ssr:i,useCompiledPages:r?.command===`build`},f)}if(c.includes(`boltdocs-client.mjs`)||c===`\0virtual:boltdocs-client.ts`||c===`virtual:boltdocs-client`){let e=__dirname,n=e;for(;e!==i.default.parse(e).root;){if(a.default.existsSync(i.default.join(e,`package.json`))&&JSON.parse(a.default.readFileSync(i.default.join(e,`package.json`),`utf-8`)).name===`boltdocs`){n=e;break}e=i.default.dirname(e)}let r=i.default.join(n,`src/client/index.ts`),o=i.default.join(n,`dist/client/index.js`);return`export * from '${t.u(a.default.existsSync(r)?r:o)}';`}if(!c.startsWith(`\0virtual:boltdocs-`))return;let h=c.replace(`\0virtual:boltdocs-`,``).replace(/\.tsx?$/,``);if(h===`routes`)return await _(s,f,p),y(p.routesDataMap,l);if(h===`collections`)return await _(s,f,p),x(v(p));if(h===`config`){await _(s,f,p);let e=p.routeCacheVariant?.directoryMeta||{};p.directoryMetaCache=e;let t=[...new Set(Array.from(p.routesDataMap.values()).map(e=>e.collection).filter(e=>!!e))].sort((e,t)=>e.localeCompare(t)),n=f?.collections,r=n?{...n,labels:{...n.labels||{},...Object.fromEntries(t.map(e=>[e,n.labels?.[e]??e]))}}:t.length>0?t:void 0,i={base:f?.base,theme:f?.theme,i18n:f?.i18n,versions:f?.versions,siteUrl:f?.siteUrl,integrations:f?.integrations,collections:r,seo:f?.seo,experimental:f?.experimental,plugins:f?.plugins?.map(e=>({name:e.name})),directoryMeta:e};return`export default ${JSON.stringify(i,null,2)};`}if(h===`entry`){let t=this,r=o(),i=t.environment?.config?.consumer,a=i===void 0?!!(u?.ssr??r?.build?.ssr):i!==`client`;return n.g({...e,ssr:a,useCompiledPages:r?.command===`build`},f)}if(h===`mdx-components`){let e=[`tsx`,`ts`,`jsx`,`js`],n=null;for(let t of e){let e=i.default.resolve(s,`mdx-components.${t}`);if(a.default.existsSync(e)){n=e;break}}let r={};if(f?.plugins)for(let e of f.plugins)e.components&&Object.assign(r,e.components);let o=Object.entries(r),c=o.map(([e,t],n)=>`import * as _pluginCompMod_${n} from '${t}';`).join(`
|
|
7
|
-
`),l=o.map(([e],t)=>`${JSON.stringify(e)}: _pluginCompMod_${t}[${JSON.stringify(e)}] || _pluginCompMod_${t}["default"] || _pluginCompMod_${t}`).join(`,
|
|
8
|
-
`);if(n){let e=t.u(n);return`${c}
|
|
9
|
-
import * as components from '${e}';
|
|
10
|
-
const userMdxComponents = components.default || components;
|
|
11
|
-
const mdxComponents = {
|
|
12
|
-
${l}${l?`,`:``}
|
|
13
|
-
...userMdxComponents,
|
|
14
|
-
};
|
|
15
|
-
export default mdxComponents;
|
|
16
|
-
export * from '${e}';`}return`${c}
|
|
17
|
-
const mdxComponents = {
|
|
18
|
-
${l}
|
|
19
|
-
};
|
|
20
|
-
export default mdxComponents;`}if(h===`layout`){let e=[`tsx`,`jsx`],n=null;for(let t of e){let e=i.default.resolve(s,`layout.${t}`);if(a.default.existsSync(e)){n=e;break}}if(n)return`import UserLayout from '${t.u(n)}';
|
|
21
|
-
export default UserLayout;`;throw Error(`[Boltdocs] Layout file not found. A 'layout.tsx' or 'layout.jsx' file is mandatory in your docs directory. Please create one to define your site structure.`)}if(h===`icons`){let e=[`tsx`,`jsx`,`ts`,`js`],n=null;for(let t of e){let e=i.default.resolve(s,`icons.${t}`);if(a.default.existsSync(e)){n=e;break}}return n?`import * as icons from '${t.u(n)}';\nexport default icons;`:`export default {};`}if(h===`search`)return await _(s,f,p),`export default async function fetchSearchData(options = {}) {
|
|
22
|
-
const base = import.meta.env.BASE_URL || '/';
|
|
23
|
-
const origin = typeof window !== 'undefined' ? window.location.origin : 'http://localhost';
|
|
24
|
-
const basePath = base.endsWith('/') ? base : base + '/';
|
|
25
|
-
const url = new URL('search.json', new URL(basePath, origin));
|
|
26
|
-
if (options.bustCache) url.searchParams.set('t', String(Date.now()));
|
|
27
|
-
const res = await fetch(url, { cache: options.bustCache ? 'no-store' : 'default' });
|
|
28
|
-
if (!res.ok) throw new Error('Failed to fetch search index');
|
|
29
|
-
return res.json();
|
|
30
|
-
}`;if(h===`page-source`){await _(s,f,p);let e={};for(let t of p.routesDataMap.values())t.path&&t._rawContent&&(e[t.path]=t._rawContent);return`export default async function fetchPageSource(options = {}) {
|
|
31
|
-
const base = import.meta.env.BASE_URL || '/';
|
|
32
|
-
const origin = typeof window !== 'undefined' ? window.location.origin : 'http://localhost';
|
|
33
|
-
const basePath = base.endsWith('/') ? base : base + '/';
|
|
34
|
-
const url = new URL('page-source.json', new URL(basePath, origin));
|
|
35
|
-
if (options.bustCache) url.searchParams.set('t', String(Date.now()));
|
|
36
|
-
const res = await fetch(url, { cache: options.bustCache ? 'no-store' : 'default' });
|
|
37
|
-
if (!res.ok) throw new Error('Failed to fetch page source');
|
|
38
|
-
return res.json();
|
|
39
|
-
}`}if(h===`client`){let e=__dirname,n=``;for(;e&&e!==i.default.parse(e).root;){let r=i.default.join(e,`src/client/index.ts`),o=i.default.join(e,`dist/client/index.mjs`),s=i.default.join(e,`client/index.ts`);if(a.default.existsSync(r)){n=t.u(r);break}if(a.default.existsSync(o)){n=t.u(o);break}if(a.default.existsSync(s)){n=t.u(s);break}e=i.default.dirname(e)}if(!n)throw Error(`[boltdocs] Could not resolve boltdocs/client entry point starting from ${__dirname}`);return`export * from '${n}';`}}}}exports.computeFrontmatterDelta=S,exports.createVirtualModuleState=u,exports.createVirtualModulesPlugin=C,exports.getSearchDataExport=b,exports.invalidateDirectoryMetaCache=p;
|