boltdocs 2.6.2 → 2.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/boltdocs.js +0 -1
- package/dist/cache-CQKlT4fI.mjs +6 -0
- package/dist/cache-DorPMFgW.cjs +6 -0
- package/dist/cards-BLoSiRuL.d.ts +30 -0
- package/dist/cards-CQn9mXZS.d.cts +30 -0
- package/dist/chunk-Ds5LZdWN.cjs +6 -0
- package/dist/client/index.cjs +1 -1
- package/dist/client/index.d.cts +168 -1339
- package/dist/client/index.d.ts +167 -1338
- package/dist/client/index.js +1 -1
- package/dist/{package-CFP44vfn.cjs → client/mdx.cjs} +1 -1
- package/dist/client/mdx.d.cts +128 -0
- package/dist/client/mdx.d.ts +129 -0
- package/dist/client/mdx.js +6 -0
- package/dist/client/primitives.cjs +6 -0
- package/dist/client/primitives.d.cts +818 -0
- package/dist/client/primitives.d.ts +818 -0
- package/dist/client/primitives.js +6 -0
- package/dist/client/theme/neutral.css +74 -361
- package/dist/client/theme/reset.css +189 -0
- package/dist/docs-layout-BlDhcQRv.cjs +6 -0
- package/dist/docs-layout-BvAOWEJw.js +6 -0
- package/dist/doctor-BQiQhCTl.cjs +6 -0
- package/dist/doctor-COpf35L2.cjs +20 -0
- package/dist/doctor-Dh1XP7Pz.mjs +20 -0
- package/dist/generator-DGW6pkCC.cjs +22 -0
- package/dist/generator-Dv3wEmhZ.mjs +22 -0
- package/dist/icons-dev-CrQLjoQp.js +6 -0
- package/dist/icons-dev-rzdz6Lf3.cjs +6 -0
- package/dist/image-BkIfa9oo.js +6 -0
- package/dist/image-DIGjCPe6.cjs +6 -0
- package/dist/mdx-K0WYBAJ3.js +7 -0
- package/dist/mdx-hpErbRUe.cjs +7 -0
- package/dist/meta-loader-0gJ4PtBC.cjs +6 -0
- package/dist/meta-loader-9IpAHWDS.mjs +6 -0
- package/dist/node/cli-entry.cjs +1 -2
- package/dist/node/cli-entry.mjs +1 -2
- package/dist/node/index.cjs +1 -1
- package/dist/node/index.d.cts +55 -11
- package/dist/node/index.d.mts +55 -12
- package/dist/node/index.mjs +1 -1
- package/dist/node/routes/worker.cjs +6 -0
- package/dist/node/routes/worker.d.cts +2 -0
- package/dist/node/routes/worker.d.mts +2 -0
- package/dist/node/routes/worker.mjs +6 -0
- package/dist/node-BzKYJJuY.cjs +111 -0
- package/dist/node-m6fKXXVs.mjs +111 -0
- package/dist/{package-Bqbn1AYK.mjs → package-2TVh81ZC.mjs} +1 -1
- package/dist/package-D1O_gJub.cjs +6 -0
- package/dist/parser-Bh11BsdA.cjs +6 -0
- package/dist/parser-D8eQvE7N.mjs +6 -0
- package/dist/parser-DYRzXWmA.cjs +6 -0
- package/dist/routes-CHf76Ye4.cjs +6 -0
- package/dist/routes-CMUZGI6T.mjs +6 -0
- package/dist/routes-Co1mRM58.cjs +6 -0
- package/dist/search-dialog-BACuzoVX.cjs +6 -0
- package/dist/search-dialog-BKagVT17.js +6 -0
- package/dist/search-dialog-C8w12eUx.js +6 -0
- package/dist/search-dialog-CGyrozZE.cjs +6 -0
- package/dist/search-dialog-D26rUnJ_.cjs +6 -0
- package/dist/sidebar-DKvg6KOc.d.cts +491 -0
- package/dist/sidebar-Dr1TiRIy.d.ts +491 -0
- package/dist/utils-BxNAXhZZ.mjs +7 -0
- package/dist/utils-Clzu7jvb.cjs +7 -0
- package/dist/worker-pool-Bd8Y9KDv.mjs +6 -0
- package/dist/worker-pool-BwU8ckrg.cjs +6 -0
- package/package.json +27 -8
- package/src/client/app/doc-page.tsx +9 -5
- package/src/client/app/docs-layout.tsx +17 -3
- package/src/client/app/head.tsx +122 -0
- package/src/client/app/helmet-compat.tsx +36 -0
- package/src/client/app/mdx-component.tsx +5 -52
- package/src/client/app/mdx-components-context.tsx +32 -8
- package/src/client/app/routes-context.tsx +2 -2
- package/src/client/app/scroll-handler.tsx +1 -1
- package/src/client/app/theme-context.tsx +5 -5
- package/src/client/app/ui-context.tsx +42 -0
- package/src/client/components/docs-layout-default.tsx +85 -0
- package/src/client/components/icons-dev.tsx +38 -15
- package/src/client/components/mdx/callout.tsx +97 -0
- package/src/client/components/mdx/card.tsx +73 -98
- package/src/client/components/mdx/cards.tsx +27 -0
- package/src/client/components/mdx/code-block.tsx +37 -17
- package/src/client/components/mdx/field.tsx +24 -56
- package/src/client/components/mdx/image.tsx +36 -15
- package/src/client/components/mdx/index.ts +19 -53
- package/src/client/components/mdx/table.tsx +46 -148
- package/src/client/components/mdx/typographics.tsx +120 -0
- package/src/client/components/mdx/{hooks/use-code-block.ts → use-code-block.ts} +5 -7
- package/src/client/components/primitives/breadcrumbs.tsx +5 -24
- package/src/client/components/primitives/button.tsx +3 -142
- package/src/client/components/primitives/code-block.tsx +104 -97
- package/src/client/components/{docs-layout.tsx → primitives/docs-layout.tsx} +15 -24
- package/src/client/components/primitives/error-boundary.tsx +107 -0
- package/src/client/components/primitives/heading.tsx +128 -0
- package/src/client/components/primitives/helpers/observer.ts +62 -32
- package/src/client/components/primitives/image.tsx +26 -0
- package/src/client/components/primitives/link.tsx +50 -52
- package/src/client/components/primitives/menu.tsx +25 -49
- package/src/client/components/primitives/navbar.tsx +234 -59
- package/src/client/components/primitives/on-this-page.tsx +169 -40
- package/src/client/components/primitives/page-nav.tsx +11 -39
- package/src/client/components/primitives/popover.tsx +12 -30
- package/src/client/components/primitives/search-dialog.tsx +77 -71
- package/src/client/components/primitives/sidebar.tsx +312 -119
- package/src/client/components/primitives/skeleton.tsx +1 -1
- package/src/client/components/primitives/tabs.tsx +5 -16
- package/src/client/components/primitives/tooltip.tsx +1 -1
- package/src/client/components/ui-base/banner.tsx +66 -0
- package/src/client/components/ui-base/breadcrumbs.tsx +26 -20
- package/src/client/components/ui-base/copy-markdown.tsx +43 -35
- package/src/client/components/ui-base/error-boundary.tsx +9 -46
- package/src/client/components/ui-base/github-stars.tsx +5 -3
- package/src/client/components/ui-base/index.ts +3 -3
- package/src/client/components/ui-base/last-updated.tsx +27 -0
- package/src/client/components/ui-base/navbar.tsx +183 -89
- package/src/client/components/ui-base/not-found.tsx +11 -9
- package/src/client/components/ui-base/on-this-page.tsx +8 -104
- package/src/client/components/ui-base/page-nav.tsx +23 -9
- package/src/client/components/ui-base/search-dialog.tsx +111 -36
- package/src/client/components/ui-base/search-highlight.tsx +10 -0
- package/src/client/components/ui-base/sidebar.tsx +77 -154
- package/src/client/components/ui-base/tabs.tsx +20 -7
- package/src/client/components/ui-base/theme-toggle.tsx +88 -10
- package/src/client/components/ui-base/version-i18n.tsx +80 -0
- package/src/client/hooks/index.ts +2 -1
- package/src/client/hooks/use-analytics.ts +272 -0
- package/src/client/hooks/use-i18n.ts +116 -50
- package/src/client/hooks/use-localized-to.ts +70 -27
- package/src/client/hooks/use-navbar.ts +69 -39
- package/src/client/hooks/use-page-nav.ts +28 -25
- package/src/client/hooks/use-routes.ts +63 -80
- package/src/client/hooks/use-search-highlight.ts +185 -0
- package/src/client/hooks/use-search.ts +12 -3
- package/src/client/hooks/use-sidebar.ts +183 -80
- package/src/client/hooks/use-tabs.ts +3 -4
- package/src/client/hooks/use-version.ts +44 -29
- package/src/client/index.ts +13 -87
- package/src/client/mdx.ts +2 -0
- package/src/client/primitives.ts +19 -0
- package/src/client/ssg/boltdocs-shell.tsx +68 -79
- package/src/client/ssg/create-routes.tsx +268 -72
- package/src/client/ssg/index.ts +1 -0
- package/src/client/ssg/mdx-page.tsx +2 -1
- package/src/client/store/boltdocs-context.tsx +72 -20
- package/src/client/theme/neutral.css +74 -361
- package/src/client/theme/reset.css +189 -0
- package/src/client/types.ts +10 -2
- package/src/client/utils/path.ts +9 -0
- package/src/client/utils/react-to-text.ts +24 -24
- package/src/client/virtual.d.ts +1 -1
- package/src/shared/types.ts +82 -22
- package/dist/node-Bogvkxao.mjs +0 -101
- package/dist/node-CXaog6St.cjs +0 -101
- package/dist/search-dialog-CV3eJzMm.cjs +0 -6
- package/dist/search-dialog-DNTomKgu.js +0 -6
- package/dist/use-search-CS3gH19M.js +0 -6
- package/dist/use-search-DBpJZQuw.cjs +0 -6
- package/src/client/components/mdx/admonition.tsx +0 -91
- package/src/client/components/mdx/badge.tsx +0 -41
- package/src/client/components/mdx/button.tsx +0 -35
- package/src/client/components/mdx/component-preview.tsx +0 -37
- package/src/client/components/mdx/component-props.tsx +0 -83
- package/src/client/components/mdx/file-tree.tsx +0 -325
- package/src/client/components/mdx/hooks/use-component-preview.ts +0 -16
- package/src/client/components/mdx/hooks/useTable.ts +0 -74
- package/src/client/components/mdx/hooks/useTabs.ts +0 -68
- package/src/client/components/mdx/link.tsx +0 -38
- package/src/client/components/mdx/list.tsx +0 -192
- package/src/client/components/mdx/tabs.tsx +0 -135
- package/src/client/components/mdx/video.tsx +0 -68
- package/src/client/components/primitives/index.ts +0 -19
- package/src/client/components/primitives/navigation-menu.tsx +0 -114
- package/src/client/components/ui-base/head.tsx +0 -83
- package/src/client/components/ui-base/loading.tsx +0 -57
- package/src/client/components/ui-base/powered-by.tsx +0 -25
- package/src/client/hooks/use-onthispage.ts +0 -23
- package/src/client/utils/use-on-change.ts +0 -15
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
@layer base {
|
|
2
|
+
*,
|
|
3
|
+
*::before,
|
|
4
|
+
*::after {
|
|
5
|
+
box-sizing: border-box;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
html,
|
|
9
|
+
body {
|
|
10
|
+
margin: 0;
|
|
11
|
+
padding: 0;
|
|
12
|
+
min-height: 100%;
|
|
13
|
+
overflow-x: hidden;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
body {
|
|
17
|
+
@apply bg-main text-body antialiased;
|
|
18
|
+
font-family: var(--font-sans);
|
|
19
|
+
line-height: 1.7;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
a {
|
|
23
|
+
text-decoration: none;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/* Scroll-margin-top for anchor scrolling */
|
|
27
|
+
h1,
|
|
28
|
+
h2,
|
|
29
|
+
h3,
|
|
30
|
+
h4,
|
|
31
|
+
h5,
|
|
32
|
+
h6 {
|
|
33
|
+
scroll-margin-top: 6rem;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/* Scrollbar */
|
|
37
|
+
::-webkit-scrollbar {
|
|
38
|
+
width: 6px;
|
|
39
|
+
height: 6px;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
::-webkit-scrollbar-track {
|
|
43
|
+
background: transparent;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
::-webkit-scrollbar-thumb {
|
|
47
|
+
background-color: var(--color-strong);
|
|
48
|
+
border-radius: 9999px;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
::-webkit-scrollbar-thumb:hover {
|
|
52
|
+
background-color: var(--color-muted);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/* ═══ Content Area ═══ */
|
|
56
|
+
.boltdocs-content {
|
|
57
|
+
scrollbar-width: none;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.boltdocs-content::-webkit-scrollbar {
|
|
61
|
+
display: none;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/* ═══ MDX Page - Mobile Text Overflow Prevention ═══ */
|
|
65
|
+
.boltdocs-page {
|
|
66
|
+
overflow-wrap: break-word;
|
|
67
|
+
word-break: break-word;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/* Inline code inside prose shouldn't force horizontal overflow */
|
|
71
|
+
.boltdocs-page :not(pre) > code {
|
|
72
|
+
word-break: break-all;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.scrollbar-hide {
|
|
76
|
+
scrollbar-width: none;
|
|
77
|
+
-ms-overflow-style: none;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.scrollbar-hide::-webkit-scrollbar {
|
|
81
|
+
display: none;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/* Hide native search cancel button */
|
|
85
|
+
input::-webkit-search-cancel-button,
|
|
86
|
+
input::-webkit-search-decoration,
|
|
87
|
+
input::-webkit-search-results-button,
|
|
88
|
+
input::-webkit-search-results-decoration {
|
|
89
|
+
display: none;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/* Shiki Styles are defined below */
|
|
93
|
+
|
|
94
|
+
/* ═══ Shiki Styles ═══ */
|
|
95
|
+
|
|
96
|
+
/* Shiki Light/Dark Mode */
|
|
97
|
+
:root .shiki,
|
|
98
|
+
:root .shiki span {
|
|
99
|
+
font-family: var(--font-mono);
|
|
100
|
+
font-size: 12px !important;
|
|
101
|
+
background-color: transparent !important;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
:root.dark .shiki,
|
|
105
|
+
:root.dark .shiki span {
|
|
106
|
+
color: var(--shiki-dark) !important;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/* Base Shiki Pre & Span Styles */
|
|
110
|
+
pre.shiki {
|
|
111
|
+
@apply py-2 text-[12px] leading-[1.6];
|
|
112
|
+
overflow-x: auto;
|
|
113
|
+
-webkit-overflow-scrolling: touch;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
pre.shiki span.line {
|
|
117
|
+
@apply relative block px-4 py-0;
|
|
118
|
+
min-height: 1.6em;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/* Shiki Word Wrap */
|
|
122
|
+
pre.shiki-word-wrap {
|
|
123
|
+
@apply whitespace-pre-wrap break-words;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
pre.shiki-word-wrap span.line {
|
|
127
|
+
@apply block w-full;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/* Shiki Line Numbers */
|
|
131
|
+
pre.shiki-line-numbers code {
|
|
132
|
+
counter-reset: step;
|
|
133
|
+
counter-increment: step 0;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
pre.shiki-line-numbers .line {
|
|
137
|
+
@apply !pl-12;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/* Hide the last line if it is completely empty to avoid extra numbers or spacing */
|
|
141
|
+
pre.shiki .line:last-child:empty,
|
|
142
|
+
pre.shiki .line:last-child:has(> :empty),
|
|
143
|
+
pre.shiki-line-numbers .line:last-child:empty,
|
|
144
|
+
pre.shiki-line-numbers .line:last-child:has(> :empty) {
|
|
145
|
+
display: none;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
pre.shiki-line-numbers .line::before {
|
|
149
|
+
counter-increment: step;
|
|
150
|
+
content: counter(step);
|
|
151
|
+
@apply absolute left-0 top-0 inline-flex w-10 justify-end pr-3;
|
|
152
|
+
@apply text-[11px] text-muted opacity-30 select-none;
|
|
153
|
+
line-height: inherit;
|
|
154
|
+
/* Sync with line text */
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/* Shiki Highlight */
|
|
158
|
+
pre span.shiki-line-highlight {
|
|
159
|
+
@apply relative z-0 inline-block w-full;
|
|
160
|
+
|
|
161
|
+
&::after {
|
|
162
|
+
content: "";
|
|
163
|
+
@apply absolute top-0 left-0 -z-10 h-full w-full border-l-2 border-primary-500 !bg-primary-500/10 opacity-100;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/* Shiki Notation Diff */
|
|
168
|
+
pre.has-diff span.line.diff {
|
|
169
|
+
@apply relative inline-block w-full;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
pre.has-diff span.line.diff.add {
|
|
173
|
+
@apply !bg-emerald-500/10 dark:!bg-emerald-500/10;
|
|
174
|
+
|
|
175
|
+
&::before {
|
|
176
|
+
content: "+";
|
|
177
|
+
@apply absolute left-2 text-emerald-500 font-bold;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
pre.has-diff span.line.diff.remove {
|
|
182
|
+
@apply !bg-danger-500/10 opacity-70;
|
|
183
|
+
|
|
184
|
+
&::before {
|
|
185
|
+
content: "-";
|
|
186
|
+
@apply absolute left-2 text-danger-500 font-bold;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
package/src/client/types.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type * as React from 'react'
|
|
1
2
|
export type { BoltdocsConfig } from '../shared/types'
|
|
2
3
|
|
|
3
4
|
/**
|
|
@@ -45,6 +46,14 @@ export interface ComponentRoute {
|
|
|
45
46
|
_content?: string
|
|
46
47
|
/** The raw markdown content of the page */
|
|
47
48
|
_rawContent?: string
|
|
49
|
+
/** The publication date */
|
|
50
|
+
date?: string | Date
|
|
51
|
+
/** The last updated timestamp or date */
|
|
52
|
+
lastUpdated?: string | number | Date
|
|
53
|
+
/** Raw extensible frontmatter data for custom components and formatters */
|
|
54
|
+
frontmatter?: Record<string, any>
|
|
55
|
+
/** Clean URL segments stripped of locale/version prefixes */
|
|
56
|
+
slugParts?: string[]
|
|
48
57
|
}
|
|
49
58
|
|
|
50
59
|
/**
|
|
@@ -99,10 +108,9 @@ export interface LayoutProps {
|
|
|
99
108
|
* Unified type for navbar links.
|
|
100
109
|
*/
|
|
101
110
|
export interface NavbarLink {
|
|
102
|
-
/** Label to display (can be a string or a map of translations) */
|
|
103
111
|
label: string | Record<string, string>
|
|
104
112
|
href: string
|
|
105
113
|
active: boolean
|
|
106
|
-
/** Optional icon or string for external link indication */
|
|
107
114
|
to?: string
|
|
115
|
+
items?: NavbarLink[]
|
|
108
116
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalizes a URL path by stripping any trailing slash unless it's the root path.
|
|
3
|
+
*
|
|
4
|
+
* @param p - The path to normalize.
|
|
5
|
+
* @returns The normalized path.
|
|
6
|
+
*/
|
|
7
|
+
export function normalizePath(p: string): string {
|
|
8
|
+
return p.endsWith('/') && p.length > 1 ? p.slice(0, -1) : p
|
|
9
|
+
}
|
|
@@ -1,34 +1,34 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
} from
|
|
2
|
+
isValidElement,
|
|
3
|
+
type ReactNode,
|
|
4
|
+
type JSXElementConstructor,
|
|
5
|
+
} from 'react'
|
|
6
6
|
|
|
7
7
|
type ResolverMap = Map<
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
string | JSXElementConstructor<object>,
|
|
9
|
+
(props: object) => string
|
|
10
|
+
>
|
|
11
11
|
|
|
12
12
|
const reactToText = (node: ReactNode, resolvers?: ResolverMap): string => {
|
|
13
|
-
|
|
13
|
+
if (node == null || typeof node === 'boolean') return ''
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
if (typeof node === 'string' || typeof node === 'number') return String(node)
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
if (Array.isArray(node))
|
|
18
|
+
return node.map((n) => reactToText(n, resolvers)).join('')
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
20
|
+
if (isValidElement(node)) {
|
|
21
|
+
const resolver = resolvers?.get(
|
|
22
|
+
node.type as string | JSXElementConstructor<object>,
|
|
23
|
+
)
|
|
24
|
+
if (resolver) return resolver(node.props as object)
|
|
25
|
+
return reactToText(
|
|
26
|
+
(node.props as { children?: ReactNode }).children,
|
|
27
|
+
resolvers,
|
|
28
|
+
)
|
|
29
|
+
}
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
}
|
|
31
|
+
return ''
|
|
32
|
+
}
|
|
33
33
|
|
|
34
|
-
export { reactToText }
|
|
34
|
+
export { reactToText }
|
package/src/client/virtual.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ declare module 'virtual:boltdocs-config' {
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
declare module 'virtual:boltdocs-layout' {
|
|
12
|
-
const Layout: React.ComponentType<{ children: React.ReactNode }>
|
|
12
|
+
const Layout: React.ComponentType<{ children: React.ReactNode; route?: any }>
|
|
13
13
|
export default Layout
|
|
14
14
|
}
|
|
15
15
|
|
package/src/shared/types.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Plugin as VitePlugin } from 'vite'
|
|
2
|
+
import type { ComponentType } from 'react'
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Represents a single social link in the configuration.
|
|
@@ -22,36 +23,40 @@ export interface BoltdocsThemeConfig {
|
|
|
22
23
|
title?: string | Record<string, string>
|
|
23
24
|
description?: string | Record<string, string>
|
|
24
25
|
logo?:
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
26
|
+
| string
|
|
27
|
+
| {
|
|
28
|
+
dark: string
|
|
29
|
+
light: string
|
|
30
|
+
alt?: string
|
|
31
|
+
width?: number
|
|
32
|
+
height?: number
|
|
33
|
+
}
|
|
33
34
|
navbar?: Array<{
|
|
34
35
|
label: string | Record<string, string>
|
|
35
36
|
href: string
|
|
37
|
+
items?: Array<{
|
|
38
|
+
label: string | Record<string, string>
|
|
39
|
+
href: string
|
|
40
|
+
}>
|
|
36
41
|
}>
|
|
37
42
|
sidebar?: Record<string, Array<{ text: string; link: string }>>
|
|
38
|
-
sidebarGroups?: Record<
|
|
43
|
+
sidebarGroups?: Record<
|
|
44
|
+
string,
|
|
45
|
+
{ title?: string | Record<string, string>; icon?: string }
|
|
46
|
+
>
|
|
39
47
|
socialLinks?: BoltdocsSocialLink[]
|
|
40
48
|
footer?: BoltdocsFooterConfig
|
|
41
|
-
breadcrumbs?: boolean
|
|
42
49
|
editLink?: string
|
|
43
50
|
communityHelp?: string
|
|
44
51
|
version?: string
|
|
45
52
|
githubRepo?: string
|
|
46
53
|
favicon?: string
|
|
47
|
-
poweredBy?: boolean
|
|
48
54
|
tabs?: Array<{
|
|
49
55
|
id: string
|
|
50
56
|
text: string | Record<string, string>
|
|
51
57
|
icon?: string
|
|
52
58
|
}>
|
|
53
59
|
codeTheme?: ShikiTheme | { light: ShikiTheme; dark: ShikiTheme }
|
|
54
|
-
copyMarkdown?: boolean | { text?: string; icon?: string }
|
|
55
60
|
}
|
|
56
61
|
|
|
57
62
|
/**
|
|
@@ -72,13 +77,13 @@ export type ShikiTheme =
|
|
|
72
77
|
export type BoltdocsRobotsConfig =
|
|
73
78
|
| string
|
|
74
79
|
| {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
rules?: Array<{
|
|
81
|
+
userAgent: string
|
|
82
|
+
allow?: string | string[]
|
|
83
|
+
disallow?: string | string[]
|
|
84
|
+
}>
|
|
85
|
+
sitemaps?: string[]
|
|
86
|
+
}
|
|
82
87
|
|
|
83
88
|
/**
|
|
84
89
|
* Configuration for a specific locale.
|
|
@@ -152,6 +157,37 @@ export interface BoltdocsSeoConfig {
|
|
|
152
157
|
}
|
|
153
158
|
}
|
|
154
159
|
|
|
160
|
+
/**
|
|
161
|
+
* Configuration for Google Analytics 4 (GA4).
|
|
162
|
+
*/
|
|
163
|
+
export interface BoltdocsGA4Config {
|
|
164
|
+
measurementId: string
|
|
165
|
+
debug?: boolean
|
|
166
|
+
anonymizeIp?: boolean
|
|
167
|
+
sendPageView?: boolean
|
|
168
|
+
cookieFlags?: string
|
|
169
|
+
autoTrack?: {
|
|
170
|
+
pageViews?: boolean
|
|
171
|
+
downloads?: boolean
|
|
172
|
+
externalLinks?: boolean
|
|
173
|
+
search?: boolean
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Configuration for Google Tag Manager (GTM).
|
|
179
|
+
*/
|
|
180
|
+
export interface BoltdocsGTMConfig {
|
|
181
|
+
tagId: string
|
|
182
|
+
dataLayerName?: string
|
|
183
|
+
preview?: string
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export interface BoltdocsIntegrationsConfig {
|
|
187
|
+
ga4?: BoltdocsGA4Config
|
|
188
|
+
gtm?: BoltdocsGTMConfig
|
|
189
|
+
}
|
|
190
|
+
|
|
155
191
|
/**
|
|
156
192
|
* The root configuration object for Boltdocs.
|
|
157
193
|
*/
|
|
@@ -159,7 +195,6 @@ export interface BoltdocsConfig {
|
|
|
159
195
|
siteUrl?: string
|
|
160
196
|
docsDir?: string
|
|
161
197
|
base?: string
|
|
162
|
-
homePage?: string
|
|
163
198
|
theme?: BoltdocsThemeConfig
|
|
164
199
|
i18n?: BoltdocsI18nConfig
|
|
165
200
|
versions?: BoltdocsVersionsConfig
|
|
@@ -167,6 +202,9 @@ export interface BoltdocsConfig {
|
|
|
167
202
|
robots?: BoltdocsRobotsConfig
|
|
168
203
|
security?: BoltdocsSecurityConfig
|
|
169
204
|
seo?: BoltdocsSeoConfig
|
|
205
|
+
integrations?: BoltdocsIntegrationsConfig
|
|
206
|
+
/** Aggregated metadata from local meta.json files */
|
|
207
|
+
directoryMeta?: Record<string, any>
|
|
170
208
|
vite?: any // Avoid pulling in entire Vite types here
|
|
171
209
|
}
|
|
172
210
|
|
|
@@ -182,6 +220,28 @@ declare global {
|
|
|
182
220
|
|
|
183
221
|
export type BoltdocsTypes = Boltdocs.Types
|
|
184
222
|
|
|
185
|
-
export type BoltdocsLocale = Boltdocs.Types extends { Locale: infer L }
|
|
186
|
-
|
|
223
|
+
export type BoltdocsLocale = Boltdocs.Types extends { Locale: infer L }
|
|
224
|
+
? L
|
|
225
|
+
: string
|
|
226
|
+
export type BoltdocsVersion = Boltdocs.Types extends { Version: infer V }
|
|
227
|
+
? V
|
|
228
|
+
: string
|
|
187
229
|
|
|
230
|
+
export type UnpackMdxComponents<T> = T extends { default: infer D } ? D : T
|
|
231
|
+
|
|
232
|
+
export type TransformMdxComponents<T> = {
|
|
233
|
+
[K in keyof T as K extends `Frontmatter_${string}` ? never : K]: T[K]
|
|
234
|
+
} & {
|
|
235
|
+
Frontmatter: {
|
|
236
|
+
[K in keyof T as K extends `Frontmatter_${infer Name}` ? Name : never]: T[K]
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
export type BoltdocsMdxComponents = Boltdocs.Types extends {
|
|
241
|
+
MdxComponents: infer M
|
|
242
|
+
}
|
|
243
|
+
? TransformMdxComponents<UnpackMdxComponents<M>>
|
|
244
|
+
: {
|
|
245
|
+
[key: string]: ComponentType<any>
|
|
246
|
+
Frontmatter: Record<string, ComponentType<any>>
|
|
247
|
+
}
|
package/dist/node-Bogvkxao.mjs
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Boltdocs - https://boltdocs.vercel.app
|
|
3
|
-
* Copyright (c) 2026 Jesus Alcala
|
|
4
|
-
* Licensed under the MIT License.
|
|
5
|
-
*/
|
|
6
|
-
import e from"@vitejs/plugin-react";import t from"@tailwindcss/vite";import n from"node:path";import{fileURLToPath as r}from"node:url";import{loadConfigFromFile as i,loadEnv as a,normalizePath as o}from"vite";import s from"fast-glob";import c from"fs";import l from"gray-matter";import u from"isomorphic-dompurify";import{z as d}from"zod";import f from"path";import p from"crypto";import m from"zlib";import{promisify as h}from"util";import ee from"github-slugger";import{ViteImageOptimizer as te}from"vite-plugin-image-optimizer";import g from"node:fs";import _ from"semver";import v from"@mdx-js/rollup";import ne from"remark-gfm";import re from"remark-frontmatter";import ie from"rehype-slug";import{visit as y}from"unist-util-visit";import{createJavaScriptRegexEngine as b}from"shiki/engine/javascript";import{createHighlighterCore as ae}from"shiki/core";import x from"@shikijs/themes/github-light";import S from"@shikijs/themes/github-dark";import C from"@shikijs/themes/tokyo-night";import w from"@shikijs/themes/dracula";import T from"@shikijs/themes/nord";import E from"@shikijs/themes/one-dark-pro";import D from"@shikijs/themes/one-light";import O from"@shikijs/langs/html";import oe from"@shikijs/langs/js";import se from"@shikijs/langs/ts";import ce from"@shikijs/langs/tsx";import le from"@shikijs/langs/css";import ue from"@shikijs/langs/json";import de from"@shikijs/langs/bash";import fe from"@shikijs/langs/markdown";import pe from"@shikijs/langs/mdx";import me from"@shikijs/langs/yaml";import he from"@shikijs/langs/rust";import ge from"@shikijs/langs/toml";const k=n.dirname(r(import.meta.url)),_e=/^[a-zA-Z0-9\-_\/\.\(\)]+$/,ve=d.object({title:d.string().max(200).optional(),description:d.string().max(500).optional(),sidebarPosition:d.number().optional(),sidebarLabel:d.string().max(100).optional(),category:d.string().max(50).optional(),order:d.number().optional(),badge:d.string().max(50).optional(),icon:d.string().max(50).optional()});var A=class e extends Error{constructor(t){super(t),this.name=`SecurityViolationError`,Object.setPrototypeOf(this,e.prototype)}},ye=class e extends A{constructor(t){super(t),this.name=`PathTraversalError`,Object.setPrototypeOf(this,e.prototype)}},be=class e extends A{constructor(t){super(t),this.name=`EncodingSecurityError`,Object.setPrototypeOf(this,e.prototype)}},xe=class e extends A{constructor(t){super(t),this.name=`ValidationError`,Object.setPrototypeOf(this,e.prototype)}};function j(e){return e.replace(/\\/g,`/`)}function M(e){return e.replace(/^\d+\./,``)}function N(e){let t=e.match(/^(\d+)\./);return t?parseInt(t[1],10):void 0}function Se(e){return/\.mdx?$/.test(e)}function P(e){try{return c.statSync(e).mtimeMs}catch{return 0}}function Ce(e){let t=c.readFileSync(e,`utf-8`);try{let{data:n,content:r,matter:i}=l(t);if(i&&i.length>10240)throw R(`FRONTMATTER_TOO_LARGE`,`Frontmatter block exceeds size limit`,{size:i.length,file:e}),new xe(`Security breach: Frontmatter size exceeds limit of 10240 bytes`);let a=ve.safeParse(n);a.success||console.warn(`[VALIDATION][${e}] Invalid frontmatter fields detected.`);let o={...a.success?a.data:{}};return o.title&&=I(o.title).trim(),o.description&&=I(o.description).trim(),{data:o,content:r}}catch(e){if(e instanceof xe)throw e;return{data:{},content:t}}}function we(e){return e.replace(/&/g,`&`).replace(/"/g,`"`).replace(/'/g,`'`).replace(/</g,`<`).replace(/>/g,`>`)}function Te(e){return we(e)}function Ee(e){let t=e.split(`/`).map(e=>M(De(e))).join(`/`).replace(/\/$/,``);return t=t.replace(/\.mdx?$/,``),(t===`index`||t.endsWith(`/index`))&&(t=t.replace(/index$/,``)),t.startsWith(`/`)||(t=`/`+t),t.length>1&&t.endsWith(`/`)&&(t=t.slice(0,-1)),t}function F(e){return u.sanitize(e,{ALLOWED_TAGS:`b.i.em.strong.a.p.br.code.pre.span.div.h1.h2.h3.h4.h5.h6.ul.ol.li.table.thead.tbody.tr.th.td.blockquote.hr`.split(`.`),ALLOWED_ATTR:[`href`,`title`,`target`,`class`,`id`,`src`,`alt`,`width`,`height`],FORCE_BODY:!0})}u.addHook(`afterSanitizeAttributes`,e=>{if(e.hasAttribute(`href`)){let t=e.getAttribute(`href`)?.toLowerCase()||``;(t.startsWith(`javascript:`)||t.startsWith(`data:`)||t.startsWith(`vbscript:`))&&e.removeAttribute(`href`)}if(e.hasAttribute(`src`)){let t=e.getAttribute(`src`)?.toLowerCase()||``;(t.startsWith(`javascript:`)||t.startsWith(`data:`)||t.startsWith(`vbscript:`))&&e.removeAttribute(`src`)}});function I(e){return u.sanitize(e,{ALLOWED_TAGS:[],KEEP_CONTENT:!0})}function L(e){return e.charAt(0).toUpperCase()+e.slice(1)}function De(e){return e.replace(/[^a-zA-Z0-9\-_\/\.]/g,``).split(`/`).filter(e=>e!==`..`&&e!==`.`).map(e=>e.replace(/\.\.+/g,`.`)).join(`/`)}function R(e,t,n={}){let r=new Date().toISOString(),i={...n};for(let e in i)typeof i[e]==`string`&&i[e].includes(`:`)&&(i[e]=i[e].split(/[\\/]/).pop()||i[e]);console.error(`[SECURITY][${r}] TYPE: ${e} | MESSAGE: ${t} | DETAILS: ${JSON.stringify(i)}`)}const Oe=h(c.writeFile),ke=h(c.readFile),z=h(c.mkdir),Ae=h(c.rename),je=process.env.BOLTDOCS_CACHE_DIR||`.boltdocs`,Me=parseInt(process.env.BOLTDOCS_CACHE_LRU_LIMIT||`2000`,10),Ne=process.env.BOLTDOCS_CACHE_COMPRESS!==`0`;var Pe=class{cache=new Map;constructor(e){this.limit=e}get(e){let t=this.cache.get(e);return t!==void 0&&(this.cache.delete(e),this.cache.set(e,t)),t}set(e,t){if(this.cache.has(e))this.cache.delete(e);else if(this.cache.size>=this.limit){let e=this.cache.keys().next().value;e!==void 0&&this.cache.delete(e)}this.cache.set(e,t)}get size(){return this.cache.size}clear(){this.cache.clear()}};const B=new class{queue=Promise.resolve();pendingCount=0;add(e){this.pendingCount++,this.queue=this.queue.then(e).finally(()=>{this.pendingCount--})}async flush(){await this.queue}get pending(){return this.pendingCount}};var Fe=class{entries=new Map;cachePath=null;compress;constructor(e={}){if(this.compress=e.compress===void 0?Ne:e.compress,e.name){let t=e.root||process.cwd(),n=this.compress?`json.gz`:`json`;this.cachePath=f.resolve(t,je,`${e.name}.${n}`)}}load(){if(process.env.BOLTDOCS_NO_CACHE!==`1`&&!(!this.cachePath||!c.existsSync(this.cachePath)))try{let e=c.readFileSync(this.cachePath);this.cachePath.endsWith(`.gz`)&&(e=m.gunzipSync(e));let t=JSON.parse(e.toString(`utf-8`));this.entries=new Map(Object.entries(t))}catch{}}save(){if(process.env.BOLTDOCS_NO_CACHE===`1`||!this.cachePath)return;let e=Object.fromEntries(this.entries),t=JSON.stringify(e),n=this.cachePath,r=this.compress;B.add(async()=>{try{await z(f.dirname(n),{recursive:!0});let e=Buffer.from(t);r&&(e=m.gzipSync(e));let i=`${n}.${p.randomBytes(4).toString(`hex`)}.tmp`;await Oe(i,e),await Ae(i,n)}catch{}})}get(e){let t=this.entries.get(e);return!t||P(e)!==t.mtime?null:t.data}set(e,t){this.entries.set(e,{data:t,mtime:P(e)})}isValid(e){let t=this.entries.get(e);return t?P(e)===t.mtime:!1}invalidate(e){this.entries.delete(e)}invalidateAll(){this.entries.clear()}pruneStale(e){for(let t of this.entries.keys())e.has(t)||this.entries.delete(t)}get size(){return this.entries.size}async flush(){await B.flush()}},Ie=class{index=new Map;memoryCache=new Pe(Me);baseDir;shardsDir;indexPath;constructor(e,t=process.cwd()){this.baseDir=f.resolve(t,je,`transform-${e}`),this.shardsDir=f.resolve(this.baseDir,`shards`),this.indexPath=f.resolve(this.baseDir,`index.json`)}load(){if(process.env.BOLTDOCS_NO_CACHE!==`1`&&c.existsSync(this.indexPath))try{let e=c.readFileSync(this.indexPath,`utf-8`);this.index=new Map(Object.entries(JSON.parse(e)))}catch{}}save(){if(process.env.BOLTDOCS_NO_CACHE===`1`)return;let e=JSON.stringify(Object.fromEntries(this.index)),t=this.indexPath;B.add(async()=>{await z(f.dirname(t),{recursive:!0}),await Oe(t,e)})}async getMany(e){let t=new Map,n=[];for(let r of e){let e=this.memoryCache.get(r);e?t.set(r,e):this.index.has(r)&&n.push(r)}if(n.length>0){let e=await Promise.all(n.map(async e=>{let t=this.index.get(e),n=f.resolve(this.shardsDir,`${t}.gz`);try{let t=await ke(n),r=m.gunzipSync(t).toString(`utf-8`);return this.memoryCache.set(e,r),{key:e,val:r}}catch{return null}}));for(let n of e)n&&t.set(n.key,n.val)}return t}get(e){let t=this.memoryCache.get(e);if(t)return t;let n=this.index.get(e);if(!n)return null;let r=f.resolve(this.shardsDir,`${n}.gz`);if(!c.existsSync(r))return null;try{let t=c.readFileSync(r),n=m.gunzipSync(t).toString(`utf-8`);return this.memoryCache.set(e,n),n}catch{return null}}set(e,t){let n=p.createHash(`md5`).update(t).digest(`hex`);this.index.set(e,n),this.memoryCache.set(e,t);let r=f.resolve(this.shardsDir,`${n}.gz`);B.add(async()=>{if(c.existsSync(r))return;await z(this.shardsDir,{recursive:!0});let e=m.gzipSync(Buffer.from(t)),n=`${r}.${p.randomBytes(4).toString(`hex`)}.tmp`;await Oe(n,e),await Ae(n,r)})}get size(){return this.index.size}async flush(){await B.flush()}};const V=new Fe({name:`routes`});function Le(){V.invalidateAll()}function Re(e){V.invalidate(e)}function ze(e,t,n,r){let i;try{i=decodeURIComponent(e)}catch{let t=f.basename(e);throw R(`ENCODING_ERROR`,`Invalid character encoding`,{file:t}),new be(`Security breach: Invalid characters or encoding in path: ${t}`)}if(i.length>260){let e=f.basename(i);throw R(`PATH_TOO_LONG`,`Path length exceeds limit`,{length:i.length,file:e}),new ye(`Security breach: Path length exceeds limit of 260 characters: ${e}`)}let a=f.resolve(i),o=f.resolve(t),s=j(f.relative(o,a));if(s.startsWith(`../`)||s===`..`||a.includes(`\0`)||!_e.test(s)){let t=f.basename(e);throw R(`PATH_TRAVERSAL_ATTEMPT`,`Path traversal or invalid characters detected`,{path:s}),new ye(`Security breach: File is outside of docs directory, contains null bytes, or invalid characters: ${t}`)}let{data:c,content:l}=Ce(e),u=s.split(`/`),d,p;if(r?.versions&&u.length>0){let e=u[0],t=r.versions.prefix||``,n=r.versions.versions.find(n=>e===t+n.path||e===n.path);n&&(p=n.path,u=u.slice(1))}if(r?.i18n&&u.length>0){let e=u[0];(Array.isArray(r.i18n.locales)?r.i18n.locales.includes(e):r.i18n.locales[e])&&(d=e,u=u.slice(1))}let m;if(u.length>0){let e=u[0].match(/^\((.+)\)$/);e&&(m=e[1].toLowerCase(),u=u.slice(1))}let h;u=u.map(e=>{let t=M(e);return t.startsWith(`_`)&&t!==`_`?(h=t.substring(1),e.substring(0,e.length-t.length)+t.substring(1)):e});let te=u.join(`/`),g;g=c.permalink?c.permalink.startsWith(`/`)?c.permalink:`/${c.permalink}`:Ee(te||`index.md`);let _=n;p&&(_+=`/`+p),d&&(_+=`/`+d),m&&(_+=`/`+m),_+=g===`/`?``:g,(!_||_===``)&&(_=`/`);let v=u[u.length-1],ne=M(v),re=M(f.basename(e,f.extname(e))),ie=c.sidebarPosition??N(v),y=u.length>=2?u[0]:void 0,b=y?M(y):void 0,ae=u.length===2&&/^index\.mdx?$/.test(ne),x=new ee,S=[];for(let e of l.matchAll(/^(#{2,4})\s+(.+)$/gm)){let t=e[1].length,n=F(e[2].replace(/\[([^\]]+)\]\([^\)]+\)/g,`$1`).replace(/[_*`]/g,``).trim()).trim(),r=x.slug(n);S.push({level:t,text:n,id:r})}let C=c.title?F(String(c.title)):re,w=c.description?F(String(c.description)):``;!w&&l&&(w=I(l.replace(/^#+.*$/gm,``).replace(/\[([^\]]+)\]\([^\)]+\)/g,`$1`).replace(/[_*`]/g,``).replace(/\s+/g,` `)).trim().slice(0,160));let T=c.badge?F(String(c.badge)):void 0,E=c.icon?String(c.icon):void 0,D=Be(l),O={},oe=[`og:`,`twitter:`,`article:`,`music:`,`video:`,`profile:`,`book:`],se=[`noindex`,`robots`,`canonical`,`keywords`,`author`];c.seo&&typeof c.seo==`object`&&Object.assign(O,c.seo);for(let e of Object.keys(c))(se.includes(e)||oe.some(t=>e.startsWith(t)))&&(O[e]=c[e]);return c.hidden===!0&&O.noindex===void 0&&(O.noindex=!0),{route:{path:_,componentPath:e,filePath:s,title:C,description:w,sidebarPosition:ie,headings:S,locale:d,version:p,badge:T,icon:E,tab:m,subRouteGroup:h,_content:D,_rawContent:l,seo:Object.keys(O).length>0?O:void 0},relativeDir:b,isGroupIndex:ae,inferredTab:m,groupMeta:ae?{title:c.groupTitle||c.title||(b?L(b):``),position:c.groupPosition??c.sidebarPosition??(y?N(y):void 0),icon:E}:void 0,inferredGroupPosition:y?N(y):void 0}}function Be(e){return I(e.replace(/^#+.*$/gm,``).replace(/\[([^\]]+)\]\([^\)]+\)/g,`$1`).replace(/\{[^\}]+\}/g,``).replace(/[_*`]/g,``).replace(/\s+/g,` `)).trim()}function Ve(e){return e.sort((e,t)=>!e.group&&!t.group?He(e,t):e.group?t.group?e.group===t.group?He(e,t):Ue(e,t):1:-1)}function He(e,t){return e.sidebarPosition!==void 0&&t.sidebarPosition!==void 0?e.sidebarPosition-t.sidebarPosition:e.sidebarPosition===void 0?t.sidebarPosition===void 0?e.title.localeCompare(t.title):1:-1}function Ue(e,t){return e.groupPosition!==void 0&&t.groupPosition!==void 0?e.groupPosition-t.groupPosition:e.groupPosition===void 0?t.groupPosition===void 0?(e.groupTitle||e.group).localeCompare(t.groupTitle||t.group):1:-1}let H=null;const U=new Map;async function W(e,t,n=`/docs`,r=!0){V.load(),U.clear(),(process.env.BOLTDOCS_FORCE_REPARSE===`true`||t?.i18n)&&V.invalidateAll();let i;!r&&H?i=H:(i=await s([`**/*.md`,`**/*.mdx`],{cwd:e,absolute:!0,suppressErrors:!0,followSymbolicLinks:!1}),H=i),V.pruneStale(new Set(i));let a=[],o=0;for(let r=0;r<i.length;r+=50){let s=i.slice(r,r+50),c=await Promise.all(s.map(async r=>{let i=V.get(r);if(i)return o++,i;let a=ze(r,e,n,t);return V.set(r,a),a}));a.push(...c),r+50<i.length&&await new Promise(e=>setImmediate(e))}V.save();let c=new Map,l=[],u=t?.i18n?.defaultLocale||``;for(let e of a)if(e.isGroupIndex&&e.relativeDir&&l.push(e),e.relativeDir){let t=`${e.route.locale||u}:${e.relativeDir}`,n=c.get(t);n?n.position===void 0&&e.inferredGroupPosition!==void 0&&(n.position=e.inferredGroupPosition):(n={title:L(e.relativeDir),position:e.inferredGroupPosition},c.set(t,n))}for(let e of l){let t=`${e.route.locale||u}:${e.relativeDir}`,n=c.get(t);e.groupMeta&&(n.title=e.groupMeta.title,e.groupMeta.position!==void 0&&(n.position=e.groupMeta.position),e.groupMeta.icon&&(n.icon=e.groupMeta.icon))}if(t?.theme?.sidebarGroups){let e=t.i18n?Object.keys(t.i18n.locales):[u];for(let[n,r]of Object.entries(t.theme.sidebarGroups))for(let t of e){let e=`${t}:${n}`,i=c.get(e),a;typeof r.title==`string`?a=r.title:r.title&&(a=r.title[t]||r.title[u]),i?(a&&(i.title=a),r.icon&&(i.icon=r.icon)):c.set(e,{title:a||L(n),icon:r.icon})}}let d=Array(a.length);for(let e=0;e<a.length;e++){let t=a[e],n=t.relativeDir,r=t.route.locale||u,i=n?`${r}:${n}`:void 0,o=i?c.get(i):void 0,s;o&&(s=typeof o.title==`string`?o.title:o.title[r]||o.title[u]),d[e]={...t.route,group:n,groupTitle:s||(n?L(n):void 0),groupPosition:o?.position,groupIcon:o?.icon}}let f=d;if(t?.i18n){let e=We(d,t,n);f=[...d,...e]}return Ve(f)}function We(e,t,n){let r=t.i18n.defaultLocale,i=Object.keys(t.i18n.locales),a=[],o=new Map,s=[];for(let t of e){let e=t.locale||r;o.has(e)||o.set(e,new Set),o.get(e).add(t.path),e===r&&s.push(t)}for(let e of i){let i=o.get(e)||new Set;for(let o of s){let s=Ge(o.path,r,e,n,t);s!==o.path&&(i.has(s)||a.push({...o,path:s,locale:e}))}}return a}function Ge(e,t,n,r,i){let a=`${e}:${n}`,o=U.get(a);if(o)return o;let s=r.startsWith(`/`)?r:`/`+r,c=s;if(i?.versions){let t=i.versions.prefix||``;for(let n of i.versions.versions){let r=`${s}/${t+n.path}`;if(e.startsWith(r)){c=r;break}let i=`${s}/${n.path}`;if(e.startsWith(i)){c=i;break}}}let l=e.substring(c.length),u=`/${t}`;if(l.startsWith(u+`/`))l=`/`+n+`/`+l.substring(u.length+1);else if(l===u)l=`/`+n;else if(l===`/`||l===``)l=`/`+n;else{let e=l.startsWith(`/`)?``:`/`;l=`/`+n+e+l}let d=c+l;return U.size>2e3&&U.clear(),U.set(a,d),d}function Ke(e){return e.map(e=>({path:e.path,filePath:e.filePath,title:e.title,description:e.description||``,sidebarPosition:e.sidebarPosition,badge:e.badge,icon:e.icon,headings:e.headings||[],_content:e._content||``,locale:e.locale,version:e.version,tab:e.tab,group:e.group,groupTitle:e.groupTitle,groupPosition:e.groupPosition,groupIcon:e.groupIcon,subRouteGroup:e.subRouteGroup,seo:e.seo}))}const qe=d.object({icon:d.string().max(50),link:d.string().url()}),Je=d.object({text:d.string().max(2e3).optional()}),Ye=d.enum([`fs:read`,`fs:write`,`vite:config`,`mdx:remark`,`mdx:rehype`,`components`,`hooks:build`,`hooks:dev`]),Xe=d.object({name:d.string(),enforce:d.enum([`pre`,`post`]).optional(),version:d.string().optional(),boltdocsVersion:d.string().optional(),permissions:d.array(Ye).optional(),remarkPlugins:d.array(d.any()).optional(),rehypePlugins:d.array(d.any()).optional(),vitePlugins:d.array(d.any()).optional(),components:d.record(d.string(),d.string()).optional(),hooks:d.record(d.string(),d.any()).optional()}),Ze=d.object({title:d.union([d.string(),d.record(d.string(),d.string())]).optional(),description:d.union([d.string(),d.record(d.string(),d.string())]).optional(),logo:d.union([d.string(),d.object({dark:d.string(),light:d.string(),alt:d.string().optional(),width:d.number().optional(),height:d.number().optional()})]).optional(),navbar:d.array(d.object({label:d.union([d.string(),d.record(d.string(),d.string())]),href:d.string()})).optional(),sidebar:d.record(d.string(),d.array(d.object({text:d.string(),link:d.string()}))).optional(),sidebarGroups:d.record(d.string(),d.object({title:d.union([d.string(),d.record(d.string(),d.string())]).optional(),icon:d.string().optional()})).optional(),socialLinks:d.array(qe).optional(),footer:Je.optional(),breadcrumbs:d.boolean().optional(),editLink:d.string().refine(e=>!e||e.includes(`:path`),{message:`editLink must contain ':path' placeholder if specified`}).optional(),communityHelp:d.string().url().optional(),version:d.string().max(50).optional(),githubRepo:d.string().max(100).optional(),favicon:d.string().optional(),poweredBy:d.boolean().optional(),tabs:d.array(d.object({id:d.string(),text:d.union([d.string(),d.record(d.string(),d.string())]),icon:d.string().optional()})).optional(),codeTheme:d.union([d.string(),d.object({light:d.string(),dark:d.string()})]).optional(),copyMarkdown:d.union([d.boolean(),d.object({text:d.string().optional(),icon:d.string().optional()})]).optional()}),Qe=d.union([d.string(),d.object({rules:d.array(d.object({userAgent:d.string(),allow:d.union([d.string(),d.array(d.string())]).optional(),disallow:d.union([d.string(),d.array(d.string())]).optional()})).optional(),sitemaps:d.array(d.string().url()).optional()})]),$e=d.object({defaultLocale:d.string(),locales:d.union([d.record(d.string(),d.string()),d.array(d.string())]).transform(e=>Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e),localeConfigs:d.record(d.string(),d.object({label:d.string().optional(),direction:d.enum([`ltr`,`rtl`]).optional(),htmlLang:d.string().optional(),calendar:d.string().optional()})).optional()}),et=d.object({defaultVersion:d.string(),prefix:d.string().optional(),versions:d.array(d.object({label:d.string(),path:d.string()}))}),tt=d.object({headers:d.record(d.string(),d.string()).optional(),enableCSP:d.boolean().optional(),customHeaders:d.record(d.string(),d.string()).optional()}),nt=d.object({metatags:d.record(d.string(),d.string()).optional(),indexing:d.enum([`all`,`public`]).optional(),thumbnails:d.object({background:d.string().optional()}).optional()}),rt=d.object({siteUrl:d.string().url().optional(),docsDir:d.string().optional(),homePage:d.string().optional(),theme:Ze.optional(),i18n:$e.optional(),versions:et.optional(),plugins:d.array(Xe).optional(),robots:Qe.optional(),security:tt.optional(),seo:nt.optional(),vite:d.record(d.string(),d.unknown()).optional()});function it(e,t=process.cwd()){let r=n.resolve(t,`.boltdocs`);g.existsSync(r)||g.mkdirSync(r,{recursive:!0});let i=e.i18n?Object.keys(e.i18n.locales):[],a=e.versions?e.versions.versions.map(e=>e.path):[],o=`// This file is automatically generated by Boltdocs.
|
|
7
|
-
// Do not edit this file manually.
|
|
8
|
-
|
|
9
|
-
declare global {
|
|
10
|
-
namespace Boltdocs {
|
|
11
|
-
interface Types {
|
|
12
|
-
Locale: ${i.length>0?i.map(e=>`'${e}'`).join(` | `):`string`}
|
|
13
|
-
Version: ${a.length>0?a.map(e=>`'${e}'`).join(` | `):`string`}
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export {}
|
|
19
|
-
`;g.writeFileSync(n.resolve(r,`types.d.ts`),o)}function at(e){return e}const G=[`boltdocs.config.js`,`boltdocs.config.mjs`,`boltdocs.config.ts`];async function ot(e,t=process.cwd()){let r=t,a={docsDir:n.resolve(e),theme:{title:`Boltdocs`,description:`A Vite documentation framework`,navbar:[{label:`Home`,href:`/`},{label:`Documentation`,href:`/docs`}],codeTheme:{light:`github-light`,dark:`github-dark`},poweredBy:!0,breadcrumbs:!0}},o={};for(let e of G){let t=n.resolve(r,e);if(g.existsSync(t))try{let e=await i({command:`serve`,mode:`development`},t,r);if(e){o=e.config;break}}catch(t){console.warn(`[boltdocs] Failed to load config from ${e}:`,t)}}let s={title:o.title,description:o.description,logo:o.logo,favicon:o.favicon,navbar:o.navbar,sidebar:o.sidebar,sidebarGroups:o.theme?.sidebarGroups,socialLinks:o.socialLinks,footer:o.footer,githubRepo:o.githubRepo,tabs:o.tabs,codeTheme:o.codeTheme,copyMarkdown:o.copyMarkdown,breadcrumbs:o.breadcrumbs,poweredBy:o.poweredBy,communityHelp:o.communityHelp,version:o.version,editLink:o.editLink,...o.theme||{}},c=Object.fromEntries(Object.entries(s).filter(([e,t])=>t!==void 0));c.navbar&&=c.navbar.map(e=>({label:e.label||e.text||``,href:e.href||e.link||e.to||``}));let l={docsDir:n.resolve(e),homePage:o.homePage,theme:{...a.theme,...c},i18n:o.i18n?{...o.i18n,locales:Array.isArray(o.i18n.locales)?Object.fromEntries(o.i18n.locales.map(e=>[e,e])):o.i18n.locales}:void 0,versions:o.versions,siteUrl:o.siteUrl,plugins:o.plugins||[],robots:o.robots,security:o.security,vite:o.vite},u=rt.safeParse(l);if(!u.success)throw new xe(`Invalid Boltdocs configuration:\n${u.error.issues.map(e=>` - ${e.path.join(`.`)}: ${e.message}`).join(`
|
|
20
|
-
`)}`);return u.data}async function K(e,t=process.cwd()){let n=await ot(e,t);return it(n,t),n}function st(e,t){let n=(t.siteUrl||``).replace(/\/$/,``);if(!n)return``;let r=t.seo?.indexing!==`all`&&t.seo?.indexing!==`public`;return`<?xml version="1.0" encoding="UTF-8"?>
|
|
21
|
-
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
|
22
|
-
${e.filter(e=>e.seo?.noindex||typeof e.seo?.robots==`string`&&e.seo.robots.includes(`noindex`)?!1:(r&&e.seo?.index,!0)).map(e=>` <url>
|
|
23
|
-
<loc>${Te(`${n}${e.path.startsWith(`/`)?e.path:`/${e.path}`}`)}</loc>
|
|
24
|
-
<changefreq>weekly</changefreq>
|
|
25
|
-
<priority>0.7</priority>
|
|
26
|
-
</url>`).join(`
|
|
27
|
-
`)}
|
|
28
|
-
</urlset>`}function ct(e){let t=e.siteUrl||``,n=t?`${t.replace(/\/$/,``)}/sitemap.xml`:``;if(e.seo?.indexing!==`all`&&e.seo?.indexing!==`public`&&e.seo?.indexing)return[`User-agent: *`,`Disallow: /`].filter(Boolean).join(`
|
|
29
|
-
`);if(typeof e.robots==`string`)return e.robots;if(e.robots&&typeof e.robots==`object`){let t=e.robots.rules||[],r=e.robots.sitemaps||[],i=t.map(e=>{let t=`User-agent: ${e.userAgent}\n`;return e.allow&&(Array.isArray(e.allow)?t+=e.allow.map(e=>`Allow: ${e}`).join(`
|
|
30
|
-
`)+`
|
|
31
|
-
`:t+=`Allow: ${e.allow}\n`),e.disallow&&(Array.isArray(e.disallow)?t+=e.disallow.map(e=>`Disallow: ${e}`).join(`
|
|
32
|
-
`)+`
|
|
33
|
-
`:t+=`Disallow: ${e.disallow}\n`),t.trim()}).join(`
|
|
34
|
-
|
|
35
|
-
`),a=[...n?[n]:[],...r].map(e=>`Sitemap: ${e}`).join(`
|
|
36
|
-
`);return`${i}${a?`\n\n${a}`:``}`}return[`User-agent: *`,`Allow: /`,``,n?`Sitemap: ${n}`:``].filter(Boolean).join(`
|
|
37
|
-
`)}function q(e,t){let n=e.homePage?`import HomePage from '${j(e.homePage)}';`:``,r=f.resolve(process.cwd(),`index.css`),i=c.existsSync(r)?`import './index.css';`:``,a=e.homePage?`homePage: HomePage,`:``,o=t?.plugins?.flatMap(e=>Object.entries(e.components||{}))||[],s=o.map(([e,t])=>`import * as _comp_${e} from '${j(t)}';
|
|
38
|
-
const ${e} = _comp_${e}.default || _comp_${e}['${e}'] || _comp_${e};`).join(`
|
|
39
|
-
`),l=o.map(([e])=>e).join(`, `),u=f.basename(e.docsDir||`docs`),d=f.resolve(process.cwd(),e.docsDir||`docs`),p=[`tsx`,`ts`,`jsx`,`js`].map(e=>f.resolve(d,`pages-external/index.${e}`)).find(e=>c.existsSync(e)),m=p?`import * as _external_module from '${j(p)}';`:``;return a=p?`homePage: _external_module.homePage || HomePage,`:e.homePage?`homePage: HomePage,`:``,`
|
|
40
|
-
import { ViteReactSSG } from '@bdocs/ssg';
|
|
41
|
-
import { createRoutes } from 'boltdocs/client';
|
|
42
|
-
import _routes from 'virtual:boltdocs-routes.ts';
|
|
43
|
-
import _config from 'virtual:boltdocs-config.ts';
|
|
44
|
-
import _user_mdx_components from 'virtual:boltdocs-mdx-components.tsx';
|
|
45
|
-
import _Layout from 'virtual:boltdocs-layout.tsx';
|
|
46
|
-
${i}
|
|
47
|
-
${n}
|
|
48
|
-
${s}
|
|
49
|
-
${m}
|
|
50
|
-
|
|
51
|
-
const mdxModules = import.meta.glob('/${u}/**/*.{md,mdx}', { eager: true });
|
|
52
|
-
|
|
53
|
-
export const createRoot = ViteReactSSG(
|
|
54
|
-
{
|
|
55
|
-
routes: createRoutes({
|
|
56
|
-
routesData: _routes,
|
|
57
|
-
config: _config,
|
|
58
|
-
mdxModules,
|
|
59
|
-
Layout: _Layout,
|
|
60
|
-
${a}
|
|
61
|
-
${p?`externalPages: _external_module.pages, externalLayout: _external_module.layout,`:``}
|
|
62
|
-
components: { ${l}${l?`, `:``} ...(_user_mdx_components || {}) },
|
|
63
|
-
}),
|
|
64
|
-
},
|
|
65
|
-
({ isClient }) => {
|
|
66
|
-
// Boltdocs initialization hook
|
|
67
|
-
if (isClient) {
|
|
68
|
-
// Client-side initialization
|
|
69
|
-
}
|
|
70
|
-
},
|
|
71
|
-
);
|
|
72
|
-
`}function lt(e){return`<!doctype html>
|
|
73
|
-
<html lang="en">
|
|
74
|
-
<head>
|
|
75
|
-
<meta charset="UTF-8" />
|
|
76
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
77
|
-
<title>${e.theme?.title||`Boltdocs`}</title>
|
|
78
|
-
</head>
|
|
79
|
-
<body>
|
|
80
|
-
<div id="root"></div>
|
|
81
|
-
</body>
|
|
82
|
-
</html>`}function ut(e,t){(!e||!e.includes(`<body`)||!e.includes(`<head`))&&(e=lt(t));let n=t.theme,r=n?.title||`Boltdocs`,i=n?.description||``,a=n?.favicon;!a&&n?.logo&&(a=typeof n.logo==`string`?n.logo:n.logo.light||n.logo.dark);let o=[a?`<link rel="icon" href="${a}">`:``,`<meta name="description" content="${i}">`,`<meta property="og:title" content="${r}">`,`<meta property="og:description" content="${i}">`,`<meta property="og:type" content="website">`,`<meta name="twitter:card" content="summary_large_image">`,`<meta name="twitter:title" content="${r}">`,`<meta name="twitter:description" content="${i}">`,`<meta name="generator" content="Boltdocs">`].filter(Boolean).join(`
|
|
83
|
-
`);return e=e.includes(`<title>`)?e.replace(/<title>.*?<\/title>/,`<title>${r}</title>`):e.replace(`</head>`,` <title>${r}</title>\n </head>`),e=e.replace(`</head>`,` ${o}\n
|
|
84
|
-
<script>
|
|
85
|
-
(function() {
|
|
86
|
-
try {
|
|
87
|
-
var stored = localStorage.getItem("boltdocs-theme");
|
|
88
|
-
var isDark =
|
|
89
|
-
stored === "dark" ||
|
|
90
|
-
(stored !== "light" && window.matchMedia("(prefers-color-scheme: dark)").matches);
|
|
91
|
-
document.documentElement.classList.toggle("dark", isDark);
|
|
92
|
-
document.documentElement.dataset.theme = isDark ? "dark" : "light";
|
|
93
|
-
} catch (e) {}
|
|
94
|
-
})();
|
|
95
|
-
<\/script>
|
|
96
|
-
</head>`),!e.includes(`src/main`)&&!e.includes(`virtual:boltdocs-entry`)&&(e=e.replace(`</body>`,` <script type="module">import "virtual:boltdocs-entry";<\/script>
|
|
97
|
-
</body>`)),e}function dt(e){let t=[];for(let n of e)if(t.push({id:n.path,title:n.title,content:n._content||``,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}const ft={"X-Content-Type-Options":`nosniff`,"X-Frame-Options":`DENY`,"X-XSS-Protection":`1; mode=block`,"Referrer-Policy":`strict-origin-when-cross-origin`,"Permissions-Policy":`camera=(), microphone=(), geolocation=()`,"Strict-Transport-Security":`max-age=31536000; includeSubDomains`};function pt(e){let t=process.env.NODE_ENV===`development`,n={"default-src":[`'self'`],"script-src":[`'self'`,`'unsafe-inline'`],"style-src":[`'self'`,`'unsafe-inline'`],"img-src":[`'self'`,`data:`,`https:`],"font-src":[`'self'`],"connect-src":[`'self'`]};return t&&(n[`script-src`]=[`'self'`,`'unsafe-eval'`,`'unsafe-inline'`],n[`style-src`]=[`'self'`,`'unsafe-inline'`]),Object.entries(n).map(([e,t])=>`${e} ${t.join(` `)}`).join(`; `)}var J=class e extends Error{pluginName;constructor(t,n){super(`[plugin:${t}] ${n}`),this.name=`PluginError`,this.pluginName=t,Object.setPrototypeOf(this,e.prototype)}},Y=class e extends J{constructor(t,n){super(t,`Validation failed: ${n}`),this.name=`PluginValidationError`,Object.setPrototypeOf(this,e.prototype)}},mt=class e extends J{constructor(t,n){super(t,`Compatibility error: ${n}`),this.name=`PluginCompatibilityError`,Object.setPrototypeOf(this,e.prototype)}},X=class e extends J{constructor(t,n){super(t,`Missing required permission: '${n}'`),this.name=`PluginPermissionError`,Object.setPrototypeOf(this,e.prototype)}},ht=class e extends J{hookName;constructor(t,n,r){super(t,`Error in hook '${n}': ${r.message}`),this.name=`PluginHookError`,this.hookName=n,this.stack=r.stack,Object.setPrototypeOf(this,e.prototype)}},gt=class{data=new Map;getNamespaceKey(e,t){return`${e}:${t}`}get(e,t){let n=this.getNamespaceKey(e,t),r=this.data.get(n);if(r!==void 0)return typeof r==`object`&&r?JSON.parse(JSON.stringify(r)):r}set(e,t,n){let r=this.getNamespaceKey(e,t),i=typeof n==`object`&&n?JSON.parse(JSON.stringify(n)):n;this.data.set(r,i)}has(e,t){let n=this.getNamespaceKey(e,t);return this.data.has(n)}};const _t=Xe.extend({version:d.string().optional(),boltdocsVersion:d.string().optional(),permissions:d.array(d.string()).optional(),hooks:d.object({beforeBuild:d.function().optional(),afterBuild:d.function().optional(),beforeDev:d.function().optional(),afterDev:d.function().optional(),configResolved:d.function().optional(),buildEnd:d.function().optional()}).optional()});function vt(e,t){let n=[],r=new Set;for(let i of e){let e=_t.safeParse(i);if(!e.success)throw new Y(i.name||`unknown`,e.error.issues.map(e=>`${e.path.join(`.`)}: ${e.message}`).join(`, `));let a=e.data;if(r.has(a.name))throw new Y(a.name,`Duplicate plugin name detected`);if(r.add(a.name),a.boltdocsVersion&&!_.satisfies(t,a.boltdocsVersion))throw new mt(a.name,`Plugin expects Boltdocs version ${a.boltdocsVersion}, but current is ${t}`);if(a.components){for(let[e,t]of Object.entries(a.components))if((t.includes(`..`)||f.isAbsolute(t))&&t.includes(`..`))throw new Y(a.name,`Component '${e}' has an invalid path: traversal sequences are not allowed.`)}n.push(a)}return n}function Z(e,t){return e.permissions?e.permissions.includes(t):!1}var Q=class{static checkPermission(e,t){if(!Z(e,t))throw new X(e.name,t)}static getSanitizedCapabilities(e){return{remarkPlugins:Z(e,`mdx:remark`)?e.remarkPlugins:[],rehypePlugins:Z(e,`mdx:rehype`)?e.rehypePlugins:[],vitePlugins:Z(e,`vite:config`)?e.vitePlugins:[],components:Z(e,`components`)?e.components:{}}}static async executeWithIsolation(e,t,n,r){try{return this.checkPermission(e,t),await r()}catch(t){if(t instanceof X){console.warn(`[boltdocs] Skipping hook '${n}' for plugin '${e.name}': ${t.message}`);return}throw t}}},yt=class{plugins;config;store;constructor(e,t){this.plugins=e,this.config=t,this.store=new gt}async runHook(e,...t){let n=this.getSortedPlugins();for(let r of n){if(!r.hooks?.[e])continue;let n=this.createContext(r),i=e.toLowerCase().includes(`build`),a=e.toLowerCase().includes(`dev`),o=i?`hooks:build`:a?`hooks:dev`:void 0;try{o?await Q.executeWithIsolation(r,o,e,()=>r.hooks[e](n,...t)):await r.hooks[e](n,...t)}catch(t){let i=new ht(r.name,e,t instanceof Error?t:Error(String(t)));n.logger.error(i)}}}getSortedPlugins(){let e=this.plugins.filter(e=>e.enforce===`pre`),t=this.plugins.filter(e=>!e.enforce),n=this.plugins.filter(e=>e.enforce===`post`);return[...e,...t,...n]}createContext(e){return{config:Object.freeze({...this.config}),meta:{name:e.name,version:e.version,boltdocsVersion:e.boltdocsVersion},store:{get:(e,t)=>this.store.get(e,t),set:(e,t,n)=>this.store.set(e,t,n),has:(e,t)=>this.store.has(e,t)},logger:this.createLogger(e.name)}}createLogger(e){let t=`[plugin:${e}]`;return{info:e=>console.log(`${t} INFO: ${e}`),warn:e=>console.warn(`${t} WARN: ${e}`),error:e=>{let n=e instanceof Error?e.message:e;console.error(`${t} ERROR: ${n}`)},debug:e=>console.debug(`${t} DEBUG: ${e}`)}}};function bt(e){return e}function xt(e={},t){let r=n.resolve(process.cwd(),e.docsDir||`docs`),i=j(r),o=t,s,c=!1,l,u=[];return[{name:`vite-plugin-boltdocs`,enforce:`pre`,async config(e,t){c=t.command===`build`;let i=e.envDir||process.cwd(),s=a(t.mode,i,``);Object.assign(process.env,s),o||=await K(r);let d=(await import(`./package-Bqbn1AYK.mjs`)).version,f=vt(o.plugins||[],d);return o.plugins=f,l=new yt(f,o),u=f.flatMap(e=>Q.getSanitizedCapabilities(e).vitePlugins||[]),c&&await l.runHook(`beforeBuild`),{ssgOptions:{entry:`boltdocs/entry`,htmlEntry:`index.html`,dirStyle:`nested`,includeAllRoutes:!0,mock:!0,script:`async`,beastiesOptions:{preload:`media`},onFinished:async e=>{let t=st(Ke(await W(r,o)),o);t&&g.writeFileSync(n.join(e,`sitemap.xml`),t);let i=ct(o);g.writeFileSync(n.join(e,`robots.txt`),i)}},build:{ssrManifest:c},async config(){let e=k;for(;e!==n.parse(e).root&&!g.existsSync(n.join(e,`package.json`));)e=n.dirname(e);if(g.existsSync(n.join(e,`package.json`))&&JSON.parse(g.readFileSync(n.join(e,`package.json`),`utf-8`)).name!==`boltdocs`){let t=n.dirname(e);for(;t!==n.parse(t).root;){if(g.existsSync(n.join(t,`package.json`))&&JSON.parse(g.readFileSync(n.join(t,`package.json`),`utf-8`)).name===`boltdocs`){e=t;break}t=n.dirname(t)}}return{optimizeDeps:{include:[`react`,`react-dom`,`react-dom/client`,`react-router-dom`,`react-helmet-async`],exclude:[`boltdocs`,`boltdocs/client`]},resolve:{dedupe:[`react`,`react-dom`]}}}}},configResolved(e){s=e,l?.runHook(`configResolved`,o)},async configureServer(e){await l?.runHook(`beforeDev`),e.middlewares.use((e,t,n)=>{process.env.NODE_ENV===`production`&&Object.entries(ft).forEach(([e,n])=>{t.setHeader(e,n)}),o.security?.enableCSP&&t.setHeader(`Content-Security-Policy`,pt(o)),n()}),e.middlewares.use((e,t,n)=>{if(e.url===`/robots.txt`){n();return}n()}),e.middlewares.use(async(t,n,r)=>{let i=t.url?.split(`?`)[0]||`/`,a=t.headers.accept||``,s=i===`/`||i.startsWith(`/docs`)||o.i18n&&Object.keys(o.i18n.locales).some(e=>i.startsWith(`/${e}/docs`)||i===`/${e}`)||!0,c=/\.(js|css|png|jpe?g|gif|svg|ico|webp|woff2?|ttf|otf|mp4|webm|ogg|mp3|wav|flac|aac|pdf|zip|gz|map|json)$/i.test(i);if(a.includes(`text/html`)&&!c&&s){let r=lt(o);r=ut(r,o),r=await e.transformIndexHtml(t.url||`/`,r),n.statusCode=200,n.setHeader(`Content-Type`,`text/html`),n.end(r);return}r()});let t=G.map(e=>n.resolve(process.cwd(),e)),a=[`tsx`,`jsx`].map(e=>n.resolve(r,`layout.${e}`)),s=[`tsx`,`ts`,`jsx`,`js`],c=s.map(e=>n.resolve(r,`mdx-components.${e}`)),u=s.map(e=>n.resolve(r,`pages-external/index.${e}`)),d=s.map(e=>n.resolve(r,`icons.${e}`));e.watcher.add([...t,...c,...a,...u,...d]);let f=async(t,n)=>{try{let a=j(t);if(G.some(e=>a.endsWith(e))){e.restart();return}if(s.some(e=>a.endsWith(`mdx-components.${e}`))){let t=e.moduleGraph.getModuleById(`\0virtual:boltdocs-mdx-components.tsx`);t&&e.moduleGraph.invalidateModule(t),e.ws.send({type:`full-reload`});return}if(s.some(e=>a.endsWith(`icons.${e}`))){let t=e.moduleGraph.getModuleById(`\0virtual:boltdocs-icons.tsx`);t&&e.moduleGraph.invalidateModule(t),e.ws.send({type:`full-reload`});return}if(a.endsWith(`layout.tsx`)||a.endsWith(`layout.jsx`)){let t=e.moduleGraph.getModuleById(`\0virtual:boltdocs-layout.tsx`);t&&e.moduleGraph.invalidateModule(t),e.ws.send({type:`full-reload`});return}if(a.includes(`/pages-external/`)||a.includes(`\\pages-external\\`)){let t=e.moduleGraph.getModuleById(`\0virtual:boltdocs-entry`);t&&e.moduleGraph.invalidateModule(t),e.ws.send({type:`full-reload`});return}if(!a.startsWith(i)||!Se(a))return;if(n===`add`||n===`unlink`){Le(),o=await K(r);let t=e.moduleGraph.getModuleById(`\0virtual:boltdocs-config.ts`);t&&e.moduleGraph.invalidateModule(t),e.ws.send({type:`custom`,event:`boltdocs:config-update`,data:{theme:o?.theme,i18n:o?.i18n,versions:o?.versions,siteUrl:o?.siteUrl}})}else Re(t);let c=e.moduleGraph.getModuleById(`\0virtual:boltdocs-routes.ts`);c&&e.moduleGraph.invalidateModule(c);let l=e.moduleGraph.getModuleById(`\0virtual:boltdocs-config.ts`);l&&e.moduleGraph.invalidateModule(l),e.ws.send({type:`full-reload`})}catch(e){console.error(`[boltdocs] HMR error during ${n} event:`,e)}};e.watcher.on(`add`,e=>f(e,`add`)),e.watcher.on(`unlink`,e=>f(e,`unlink`)),e.watcher.on(`change`,e=>f(e,`change`)),await l?.runHook(`afterDev`)},resolveId(e){let t=s?.root||process.cwd();return e.includes(`boltdocs-entry.mjs`)||e===`virtual:boltdocs-entry`||e===`boltdocs-entry`||e===`\0virtual:boltdocs-entry`?j(n.resolve(t,`boltdocs-entry.mjs`)):e.includes(`boltdocs-client.mjs`)||e===`virtual:boltdocs-client`||e===`boltdocs-client`||e===`\0virtual:boltdocs-client.ts`?j(n.resolve(t,`boltdocs-client.mjs`)):e.startsWith(`virtual:boltdocs-`)?`\0`+e:e.startsWith(`\0virtual:boltdocs-`)?e:null},async load(t){if(t.includes(`boltdocs-entry.mjs`)||t===`\0virtual:boltdocs-entry`)return q(e,o);if(t.includes(`boltdocs-client.mjs`)||t===`\0virtual:boltdocs-client.ts`||t===`virtual:boltdocs-client`){let e=k,t=e;for(;e!==n.parse(e).root;){if(g.existsSync(n.join(e,`package.json`))&&JSON.parse(g.readFileSync(n.join(e,`package.json`),`utf-8`)).name===`boltdocs`){t=e;break}e=n.dirname(e)}let r=n.join(t,`src/client/index.ts`),i=n.join(t,`dist/client/index.js`);return`export * from '${j(g.existsSync(r)?r:i)}';`}if(!t.startsWith(`\0virtual:boltdocs-`))return;let i=t.replace(`\0virtual:boltdocs-`,``).replace(/\.tsx?$/,``);if(i===`routes`){let e=Ke(await W(r,o));return`export default ${JSON.stringify(e,null,2)};`}if(i===`config`){let e={theme:o?.theme,i18n:o?.i18n,versions:o?.versions,siteUrl:o?.siteUrl,plugins:o?.plugins?.map(e=>({name:e.name}))};return`export default ${JSON.stringify(e,null,2)};`}if(i===`entry`)return q(e,o);if(i===`mdx-components`){let e=[`tsx`,`ts`,`jsx`,`js`],t=null;for(let i of e){let e=n.resolve(r,`mdx-components.${i}`);if(g.existsSync(e)){t=e;break}}if(t){let e=j(t);return`import * as components from '${e}';
|
|
98
|
-
const mdxComponents = components.default || components;
|
|
99
|
-
export default mdxComponents;
|
|
100
|
-
export * from '${e}';`}return`export default {};`}if(i===`layout`){let e=[`tsx`,`jsx`],t=null;for(let i of e){let e=n.resolve(r,`layout.${i}`);if(g.existsSync(e)){t=e;break}}if(t)return`import UserLayout from '${j(t)}';
|
|
101
|
-
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(i===`icons`){let e=[`tsx`,`jsx`,`ts`,`js`],t=null;for(let i of e){let e=n.resolve(r,`icons.${i}`);if(g.existsSync(e)){t=e;break}}return t?`import * as icons from '${j(t)}';\nexport default icons;`:`export default {};`}if(i===`search`){let e=dt(await W(r,o));return`export default ${JSON.stringify(e,null,2)};`}if(i===`client`){let e=k,t=``;for(;e&&e!==n.parse(e).root;){let r=n.join(e,`src/client/index.ts`),i=n.join(e,`dist/client/index.mjs`),a=n.join(e,`client/index.ts`);if(g.existsSync(r)){t=j(r);break}if(g.existsSync(i)){t=j(i);break}if(g.existsSync(a)){t=j(a);break}e=n.dirname(e)}if(!t)throw Error(`[boltdocs] Could not resolve boltdocs/client entry point starting from ${k}`);return`export * from '${t}';`}},transformIndexHtml:{order:`pre`,handler(e){return ut(e,o)}},async closeBundle(){!c||s?.build?.ssr||(await l?.runHook(`afterBuild`),await l?.runHook(`buildEnd`))}},te({includePublic:!0,png:{quality:80},jpeg:{quality:80},jpg:{quality:80},webp:{quality:80},avif:{quality:80},svg:{multipass:!0,plugins:[{name:`preset-default`}]}}),{name:`vite-plugin-boltdocs-extra-plugins`,async configResolved(){}},...u]}const $=new Ie(`mdx`),St=[x.default||x,S.default||S,C.default||C,w.default||w,T.default||T,E.default||E,D.default||D],Ct=[O,oe,se,ce,le,ue,de,fe,pe,me,he,ge];let wt=null,Tt=null;const Et=()=>(wt??=b(),wt),Dt=async e=>Tt||(Tt=ae({themes:St,langs:Ct,engine:Et()}),Tt),Ot=(e={})=>{let{activateByDefault:t=!1}=e;return{name:`boltdocs:line-numbers`,pre(e){let n=this.options.meta?.__raw||``,r=/lineNumbers|showLineNumbers/.test(n);(t||r)&&this.addClassToHast(e,`shiki-line-numbers`)}}},kt=(e={})=>{let{activateByDefault:t=!1}=e;return{name:`boltdocs:word-wrap`,pre(e){let n=this.options.meta?.__raw||``,r=/wordWrap|word-wrap/.test(n);(t||r)&&this.addClassToHast(e,`shiki-word-wrap`)}}},At=()=>({name:`AddTitleProperty`,pre(e){let t=this.options.meta?.__raw;if(!t)return;let n=t.match(/title=(["'])(.*?)\1/)?.[2];e.properties[`data-title`]=n}}),jt=()=>({name:`AddLanguageProperty`,pre(e){e.properties[`data-lang`]=this.options.lang||`plaintext`}});var Mt=class{config;constructor(e){this.config=e}getTheme(){return this.config?.theme?.codeTheme||{light:`github-light`,dark:`github-dark`}}async getHighlighter(){return await Dt(this.getTheme())}getOptions(e,t){let n=this.getTheme(),r={lang:e,meta:{__raw:t},transformers:[Ot(),kt(),At(),jt()]};return typeof n==`object`?r.themes={light:n.light,dark:n.dark}:r.theme=n,r}async render(e,t,n){let r=await this.getHighlighter(),i=this.getOptions(t,n);return r.codeToHtml(e,i)}};function Nt(e){let t=new Mt(e);return async e=>{let n=await t.getHighlighter();y(e,[`mdxJsxFlowElement`,`mdxJsxTextElement`],e=>{if(e.name!==`ComponentPreview`)return;let r=e.attributes?.find(e=>e.name===`code`),i=``;if(r){if(typeof r.value==`string`)i=r.value;else if(r.value?.type===`mdxJsxAttributeValueExpression`){let e=r.value.value??``;i=e.match(/^[`'"]([\s\S]+)[`'"]$/)?.[1]??e}}if(!i)return;let a=e.attributes?.find(e=>e.name===`lineNumbers`||e.name===`showLineNumbers`),o=e.attributes?.find(e=>e.name===`wordWrap`||e.name===`word-wrap`),s=e.attributes?.find(e=>e.name===`title`),c=``;a&&(c+=` lineNumbers`),o&&(c+=` wordWrap`),s&&typeof s.value==`string`&&(c+=` title="${s.value}"`);let l=t.getOptions(`tsx`,c),u=n.codeToHtml(i,l);e.attributes=(e.attributes??[]).filter(e=>e.name!==`highlightedHtml`),e.attributes.push({type:`mdxJsxAttribute`,name:`highlightedHtml`,value:u})})}}function Pt(e){let t=new Mt(e);return async e=>{let n=await t.getHighlighter();y(e,`element`,e=>{if(e.tagName===`pre`&&e.children?.[0]?.tagName===`code`){let r=e.children[0],i=(r.properties?.className||[]).find(e=>e.startsWith(`language-`)),a=i?i.slice(9):`text`,o=r.children[0]?.value||``,s=r.properties?.metastring||r.data?.meta||``,c=t.getOptions(a,s),l=n.codeToHtml(o,c);e.properties[`data-highlighted`]=`true`,e.properties[`data-highlighted-html`]=l,e.properties[`data-lang`]=a,e.children=[]}})}}function Ft(){return e=>{y(e,`code`,e=>{e.meta&&(e.data=e.data||{},e.data.hProperties=e.data.hProperties||{},e.data.hProperties.metastring=e.meta)})}}let It=!1;function Lt(e,t=v){let n=e?.plugins?.flatMap(e=>Q.getSanitizedCapabilities(e).remarkPlugins||[])||[],r=e?.plugins?.flatMap(e=>Q.getSanitizedCapabilities(e).rehypePlugins||[])||[],i=t({remarkPlugins:[ne,re,Ft,[Nt,e],...n],rehypePlugins:[ie,[Pt,e],...r],jsxRuntime:`automatic`});return{...i,name:`vite-plugin-boltdocs-mdx`,async buildStart(){It||=($.load(),!0),i.buildStart&&await i.buildStart.call(this)},async transform(e,t,n){if(!t.endsWith(`.md`)&&!t.endsWith(`.mdx`))return i.transform?.call(this,e,t,n);let r=`${t}:${p.createHash(`md5`).update(e).digest(`hex`)}:v2`,a=$.get(r);if(a)return{code:a,map:null};let o=await i.transform.call(this,e,t,n);return o&&typeof o==`object`&&o.code&&$.set(r,o.code),o},async buildEnd(){$.save(),await $.flush(),i.buildEnd&&await i.buildEnd.call(this)}}}async function Rt(e){let t=await K(e?.docsDir||`docs`);return[...xt({...e,homePage:e?.homePage||t.homePage},t),Lt(t)]}async function zt(r,i=`development`){let a=await K(`docs`,r),s=i===`production`,c=s?{...ft}:{};return a.security?.enableCSP&&(c[`Content-Security-Policy`]=pt(a)),{root:r,mode:i,oxc:{jsx:{development:!s,runtime:`automatic`,importSource:`react`}},optimizeDeps:{include:[`react`,`react-dom`,`react-dom/client`,`react-helmet-async`,`react-router-dom`,`use-sync-external-store/shim`],rolldownOptions:{}},build:{rolldownOptions:{}},plugins:[e(),t(),await Rt({...a,root:r})],resolve:{alias:[{find:`boltdocs/entry`,replacement:o(n.resolve(r,`boltdocs-entry.mjs`))},{find:`boltdocs/client`,replacement:o(n.resolve(r,`boltdocs-client.mjs`))},{find:`use-sync-external-store/shim/index.js`,replacement:`react`},{find:`use-sync-external-store/shim`,replacement:`react`},{find:`use-sync-external-store`,replacement:`react`}],dedupe:[`react`,`react-dom`,`react-router-dom`,`react-helmet-async`,`@bdocs/ssg`]},ssr:{optimizeDeps:{include:[`react`,`react-dom`,`react/jsx-runtime`,`react/jsx-dev-runtime`,...a.vite?.ssr?.optimizeDeps?.include||[]]},noExternal:[`boltdocs`,/@bdocs\/(?!ssg).*/,`react-helmet-async`,`react-aria-components`,`@react-aria/collections`,`@react-aria/utils`]},server:{headers:{...c,...a.vite?.server?.headers},...a.vite?.server},preview:{headers:{...c,...a.vite?.preview?.headers},...a.vite?.preview},...a.vite}}export{at as _,Q as a,De as b,vt as c,J as d,ht as f,ot as g,q as h,yt as i,gt as l,Y as m,zt as n,_t as o,X as p,bt as r,Z as s,Rt as t,mt as u,j as v,Ce as y};
|