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.
- package/dist/{build-BVoMHMhw.mjs → build-BJnL-FHG.mjs} +1 -1
- package/dist/{build-B672n0hL.cjs → build-CxT38vPv.cjs} +1 -1
- package/dist/client/index.cjs +29 -12
- package/dist/client/index.d.cts +1 -1
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.js +27 -11
- 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-DbuhNcF5.cjs → dev-46NiL0MC.cjs} +1 -1
- package/dist/{dev-B49V6O6p.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-B3o307nd.d.ts → index-B1Mx0dHl.d.ts} +24 -4
- package/dist/{index-Bg-JtZeK.d.cts → index-DLaHgD-i.d.cts} +24 -4
- 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-CNqjEYE1.cjs → package-Bah2tHjK.cjs} +1 -1
- package/dist/{package-sdcKhDhe.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-CscLcXjH.cjs → plugin-context-BZs5lvDu.cjs} +2 -2
- package/dist/{plugin-context-DuSg-Hax.mjs → plugin-context-b5qVVQSU.mjs} +1 -1
- package/dist/{plugin-lifecycle-BywrEoWK.cjs → plugin-lifecycle-s89gzTlh.cjs} +1 -1
- package/dist/{registry-sJqDv0kE.d.mts → registry-B8pt41zj.d.cts} +1 -1
- package/dist/{registry-BbB6NqSv.d.cts → 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-B9mdxsUC.js → search-dialog-DQwod5Xc.js} +1 -1
- package/dist/search-dialog-DzObE-Ar.js +717 -0
- package/dist/{search-dialog-DCtm2dyR.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 +6 -5
- package/dist/config-CrsQJHQz.cjs +0 -7
- package/dist/config-DC0nMMk7.mjs +0 -7
- package/dist/node-BljvHMpS.cjs +0 -23
- package/dist/node-CWxGw4H4.mjs +0 -23
- package/dist/plugin-BPcm1cU0.mjs +0 -69
- package/dist/plugin-WUhxnpko.cjs +0 -69
- package/dist/routes-C0kb4ue6.cjs +0 -6
- package/dist/routes-C4wrLWwu.mjs +0 -6
- package/dist/search-dialog-Bp_ouN1c.cjs +0 -550
- package/dist/search-dialog-an2BNMj6.js +0 -526
- package/dist/virtual-modules-B2X4Ht2r.mjs +0 -39
- package/dist/virtual-modules-DPsdHKcu.cjs +0 -39
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
const require_router = require('./router-C3kygdRK.cjs');
|
|
7
|
-
const require_link = require('./link-
|
|
7
|
+
const require_link = require('./link-hLWOsx0x.cjs');
|
|
8
8
|
let react = require("react");
|
|
9
9
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
10
10
|
let react_aria_components = require("react-aria-components");
|
|
@@ -39,6 +39,15 @@ var ErrorBoundary = class extends react.Component {
|
|
|
39
39
|
error: null
|
|
40
40
|
});
|
|
41
41
|
};
|
|
42
|
+
prevResetKeys = [];
|
|
43
|
+
componentDidUpdate(prevProps) {
|
|
44
|
+
if (prevProps.resetKeys !== this.props.resetKeys && this.state.hasError && this.props.resetKeys?.length && this.props.resetKeys.some((key, i) => !Object.is(key, this.prevResetKeys[i]))) {
|
|
45
|
+
this.prevResetKeys = this.props.resetKeys;
|
|
46
|
+
this.resetErrorBoundary();
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
this.prevResetKeys = this.props.resetKeys ?? [];
|
|
50
|
+
}
|
|
42
51
|
render() {
|
|
43
52
|
const { hasError, error } = this.state;
|
|
44
53
|
const { children, fallback, FallbackComponent } = this.props;
|
|
@@ -165,17 +174,20 @@ function NavbarLogo({ src, alt, width = 24, height = 24, className, logoClassNam
|
|
|
165
174
|
});
|
|
166
175
|
}
|
|
167
176
|
function NavbarTitle({ children, className, linkClassName, href = "/" }) {
|
|
177
|
+
const titleText = typeof children === "string" || typeof children === "number" ? String(children) : void 0;
|
|
168
178
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_link.Link, {
|
|
169
179
|
href,
|
|
170
180
|
className: require_link.cn(linkClassName),
|
|
181
|
+
"aria-label": titleText ? `Go to ${titleText} home` : void 0,
|
|
171
182
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
172
183
|
className: require_link.cn("text-lg font-bold tracking-tight hidden sm:inline-block", className),
|
|
173
184
|
children
|
|
174
185
|
})
|
|
175
186
|
});
|
|
176
187
|
}
|
|
177
|
-
function NavbarLinks({ children, className }) {
|
|
188
|
+
function NavbarLinks({ children, className, label }) {
|
|
178
189
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("nav", {
|
|
190
|
+
"aria-label": label,
|
|
179
191
|
className: require_link.cn("hidden md:flex items-center gap-6 text-sm font-medium", className),
|
|
180
192
|
children
|
|
181
193
|
});
|
|
@@ -236,18 +248,20 @@ function NavbarDropdownItem({ href, label, className }) {
|
|
|
236
248
|
children: label
|
|
237
249
|
});
|
|
238
250
|
}
|
|
239
|
-
function NavbarSearchTriggerDesktop({ className, onPress, children }) {
|
|
251
|
+
function NavbarSearchTriggerDesktop({ className, onPress, children, ...props }) {
|
|
240
252
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_aria_components.Button, {
|
|
253
|
+
...props,
|
|
241
254
|
onPress,
|
|
242
255
|
className: require_link.cn("hidden lg:flex items-center justify-between gap-2 px-3 py-2 text-sm outline-none cursor-pointer w-full max-w-[720px]", className),
|
|
243
256
|
children
|
|
244
257
|
});
|
|
245
258
|
}
|
|
246
|
-
function NavbarSearchTriggerMobile({ className, onPress, children }) {
|
|
259
|
+
function NavbarSearchTriggerMobile({ className, onPress, children, ...props }) {
|
|
247
260
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_aria_components.Button, {
|
|
261
|
+
...props,
|
|
248
262
|
onPress,
|
|
249
263
|
className: require_link.cn("lg:hidden flex h-10 w-10 items-center justify-center outline-none cursor-pointer", className),
|
|
250
|
-
"aria-label": "Search",
|
|
264
|
+
"aria-label": props["aria-label"] || "Search",
|
|
251
265
|
children
|
|
252
266
|
});
|
|
253
267
|
}
|
|
@@ -330,6 +344,7 @@ function NavbarMobileMenu({ isOpen, onClose, children, className, overlayClassNa
|
|
|
330
344
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_link.X, { size: 24 })
|
|
331
345
|
})]
|
|
332
346
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("nav", {
|
|
347
|
+
"aria-label": "Mobile navigation",
|
|
333
348
|
className: require_link.cn("flex-1 overflow-y-auto flex flex-col gap-4", navClassName),
|
|
334
349
|
children
|
|
335
350
|
})]
|
|
@@ -405,6 +420,119 @@ Navbar.MobileMenu = NavbarMobileMenu;
|
|
|
405
420
|
Navbar.MobileLink = NavbarMobileLink;
|
|
406
421
|
Navbar.MobileLinkItem = NavbarMobileLinkItem;
|
|
407
422
|
|
|
423
|
+
//#endregion
|
|
424
|
+
//#region src/client/hooks/use-search-highlight.ts
|
|
425
|
+
/**
|
|
426
|
+
* Hook to highlight search terms based on the 'hl' query parameter.
|
|
427
|
+
*/
|
|
428
|
+
function useSearchHighlight(containerSelector = ".boltdocs-page") {
|
|
429
|
+
const { search } = require_router.useLocation();
|
|
430
|
+
const query = new URLSearchParams(search).get("hl");
|
|
431
|
+
(0, react.useEffect)(() => {
|
|
432
|
+
if (!query) {
|
|
433
|
+
clearHighlights(containerSelector);
|
|
434
|
+
return;
|
|
435
|
+
}
|
|
436
|
+
const container = document.querySelector(containerSelector);
|
|
437
|
+
if (!container) return;
|
|
438
|
+
const target = container;
|
|
439
|
+
let rafId;
|
|
440
|
+
const observer = new MutationObserver((mutations) => {
|
|
441
|
+
if (mutations.some((m) => {
|
|
442
|
+
const addedNodes = Array.from(m.addedNodes);
|
|
443
|
+
const removedNodes = Array.from(m.removedNodes);
|
|
444
|
+
return addedNodes.some((n) => !(n instanceof HTMLElement && n.hasAttribute("data-search-highlight"))) || removedNodes.some((n) => !(n instanceof HTMLElement && n.hasAttribute("data-search-highlight")));
|
|
445
|
+
})) run();
|
|
446
|
+
});
|
|
447
|
+
function run() {
|
|
448
|
+
cancelAnimationFrame(rafId);
|
|
449
|
+
rafId = requestAnimationFrame(() => {
|
|
450
|
+
observer.disconnect();
|
|
451
|
+
clearHighlights(containerSelector);
|
|
452
|
+
const terms = (query ?? "").split(/\s+/).map((t) => t.trim()).filter((t) => t.length >= 2);
|
|
453
|
+
if (terms.length > 0) highlightTerms(target, terms);
|
|
454
|
+
observer.observe(target, {
|
|
455
|
+
childList: true,
|
|
456
|
+
subtree: true
|
|
457
|
+
});
|
|
458
|
+
});
|
|
459
|
+
}
|
|
460
|
+
run();
|
|
461
|
+
return () => {
|
|
462
|
+
cancelAnimationFrame(rafId);
|
|
463
|
+
observer.disconnect();
|
|
464
|
+
clearHighlights(containerSelector);
|
|
465
|
+
};
|
|
466
|
+
}, [query, containerSelector]);
|
|
467
|
+
}
|
|
468
|
+
function clearHighlights(selector) {
|
|
469
|
+
document.querySelectorAll(`${selector} mark[data-search-highlight]`).forEach((mark) => {
|
|
470
|
+
try {
|
|
471
|
+
const parent = mark.parentNode;
|
|
472
|
+
if (parent?.contains(mark)) {
|
|
473
|
+
const text = mark.textContent || "";
|
|
474
|
+
parent.replaceChild(document.createTextNode(text), mark);
|
|
475
|
+
}
|
|
476
|
+
} catch {}
|
|
477
|
+
});
|
|
478
|
+
}
|
|
479
|
+
function createSearchHighlightRegex(terms) {
|
|
480
|
+
const accentMap = {
|
|
481
|
+
a: "[aáàäâãåāăą]",
|
|
482
|
+
c: "[cçćč]",
|
|
483
|
+
d: "[dďđ]",
|
|
484
|
+
e: "[eéèëêėęě]",
|
|
485
|
+
g: "[gğģ]",
|
|
486
|
+
i: "[iíìïîīįı]",
|
|
487
|
+
l: "[lĺļł]",
|
|
488
|
+
n: "[nñńň]",
|
|
489
|
+
o: "[oóòöôõøōő]",
|
|
490
|
+
r: "[rřŕ]",
|
|
491
|
+
s: "[sśšş]",
|
|
492
|
+
t: "[tťţ]",
|
|
493
|
+
u: "[uúùüûūůűų]",
|
|
494
|
+
y: "[yýÿ]",
|
|
495
|
+
z: "[zžźż]"
|
|
496
|
+
};
|
|
497
|
+
const escapeTerm = (term) => [...term].map((char) => {
|
|
498
|
+
return accentMap[char.toLocaleLowerCase()] ?? char.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
499
|
+
}).join("");
|
|
500
|
+
const uniqueTerms = [...new Set(terms.map((term) => term.trim()).filter(Boolean))].sort((left, right) => right.length - left.length);
|
|
501
|
+
if (uniqueTerms.length === 0) return null;
|
|
502
|
+
return new RegExp(`(${uniqueTerms.map(escapeTerm).join("|")})`, "gi");
|
|
503
|
+
}
|
|
504
|
+
function highlightTerms(container, terms) {
|
|
505
|
+
const walker = document.createTreeWalker(container, NodeFilter.SHOW_TEXT, { acceptNode: (node) => {
|
|
506
|
+
const parent = node.parentElement;
|
|
507
|
+
if (parent && (parent.tagName === "SCRIPT" || parent.tagName === "STYLE" || parent.tagName === "MARK" || parent.closest("pre") || parent.closest("code"))) return NodeFilter.FILTER_REJECT;
|
|
508
|
+
return NodeFilter.FILTER_ACCEPT;
|
|
509
|
+
} });
|
|
510
|
+
const nodes = [];
|
|
511
|
+
let node = walker.nextNode();
|
|
512
|
+
while (node) {
|
|
513
|
+
nodes.push(node);
|
|
514
|
+
node = walker.nextNode();
|
|
515
|
+
}
|
|
516
|
+
const regex = createSearchHighlightRegex(terms);
|
|
517
|
+
if (!regex) return;
|
|
518
|
+
nodes.forEach((textNode) => {
|
|
519
|
+
const text = textNode.textContent;
|
|
520
|
+
regex.lastIndex = 0;
|
|
521
|
+
if (text && regex.test(text)) {
|
|
522
|
+
const fragment = document.createDocumentFragment();
|
|
523
|
+
text.split(regex).forEach((part, index) => {
|
|
524
|
+
if (index % 2 === 1) {
|
|
525
|
+
const mark = document.createElement("mark");
|
|
526
|
+
mark.textContent = part;
|
|
527
|
+
mark.setAttribute("data-search-highlight", "true");
|
|
528
|
+
fragment.appendChild(mark);
|
|
529
|
+
} else if (part) fragment.appendChild(document.createTextNode(part));
|
|
530
|
+
});
|
|
531
|
+
if (textNode.parentNode) textNode.parentNode.replaceChild(fragment, textNode);
|
|
532
|
+
}
|
|
533
|
+
});
|
|
534
|
+
}
|
|
535
|
+
|
|
408
536
|
//#endregion
|
|
409
537
|
//#region src/client/components/primitives/search-dialog.tsx
|
|
410
538
|
/**
|
|
@@ -576,4 +704,16 @@ Object.defineProperty(exports, 'SearchDialog', {
|
|
|
576
704
|
get: function () {
|
|
577
705
|
return SearchDialog;
|
|
578
706
|
}
|
|
707
|
+
});
|
|
708
|
+
Object.defineProperty(exports, 'createSearchHighlightRegex', {
|
|
709
|
+
enumerable: true,
|
|
710
|
+
get: function () {
|
|
711
|
+
return createSearchHighlightRegex;
|
|
712
|
+
}
|
|
713
|
+
});
|
|
714
|
+
Object.defineProperty(exports, 'useSearchHighlight', {
|
|
715
|
+
enumerable: true,
|
|
716
|
+
get: function () {
|
|
717
|
+
return useSearchHighlight;
|
|
718
|
+
}
|
|
579
719
|
});
|