boltdocs 3.1.0 → 3.2.2
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/{adapters-DEXNIv3x.mjs → adapters-ByYY44Zy.mjs} +1 -1
- package/dist/{adapters-uGz-UKQa.cjs → adapters-DvmtpdSF.cjs} +1 -1
- package/dist/{banner-DjujkctF.d.ts → banner-BMop1KLF.d.ts} +2 -2
- package/dist/{banner-DdSgCs4G.d.cts → banner-CVD0GugR.d.cts} +2 -2
- package/dist/{cache-CfRTUzWC.cjs → cache-CO4Dy2uQ.cjs} +1 -1
- package/dist/{cache-B0C2i0yP.mjs → cache-Dk53iOo6.mjs} +1 -1
- package/dist/chunk-BFSpntXv.mjs +6 -0
- package/dist/{chunk-Ds5LZdWN.cjs → chunk-D1Md3oWO.cjs} +1 -1
- package/dist/client/index.cjs +219 -172
- package/dist/client/index.d.cts +75 -9
- package/dist/client/index.d.ts +75 -9
- package/dist/client/index.js +119 -73
- package/dist/client/mdx.cjs +1 -1
- package/dist/client/mdx.d.cts +1 -1
- package/dist/client/mdx.d.ts +1 -1
- package/dist/client/mdx.js +1 -1
- package/dist/client/primitives.cjs +7 -7
- package/dist/client/primitives.d.cts +5 -22
- package/dist/client/primitives.d.ts +5 -22
- package/dist/client/primitives.js +4 -4
- package/dist/client/theme/reset.css +31 -4
- package/dist/{shiki-adapter-fS94vy-z.d.mts → config-BpzaPsJj.d.cts} +325 -78
- package/dist/config-CCXp3aXO.mjs +7 -0
- package/dist/{config-BxsogK5A.cjs → config-CMd4XoFq.cjs} +1 -1
- package/dist/config-DlGoEM9D.cjs +7 -0
- package/dist/{shiki-adapter-l2kEP5rn.d.cts → config-xtS0ZkMm.d.mts} +325 -78
- package/dist/{csp-BX06rvdg.cjs → csp-CRp_3U7a.cjs} +1 -1
- package/dist/csp-oTC2ygvF.mjs +6 -0
- package/dist/{docs-layout-DyLDBwS6.js → docs-layout-BdtZ9z6s.js} +9 -28
- package/dist/{docs-layout-D1buSdua.cjs → docs-layout-CFWI15Id.cjs} +69 -88
- package/dist/{doctor-DPDcRKM1.cjs → doctor-BBtmNJE0.cjs} +1 -1
- package/dist/doctor-Bv16QSrI.cjs +7 -0
- package/dist/doctor-DOAbSaiL.mjs +7 -0
- package/dist/{generator-BN75lJOv.cjs → generator-COepVWGi.cjs} +1 -1
- package/dist/{handler-Btd4t_67.mjs → handler-DzQae4eA.mjs} +1 -1
- package/dist/{handler-1LRMYeI4.cjs → handler-XX7cLTqe.cjs} +1 -1
- package/dist/headers-Ddwek8K7.mjs +6 -0
- package/dist/{headers-YpD10rDb.cjs → headers-dg4SDrjY.cjs} +1 -1
- package/dist/{image-5WsgWYTh.js → image-Bz87fCla.js} +1 -1
- package/dist/{image-Hb105Gu6.cjs → image-C4TlpMHn.cjs} +18 -18
- package/dist/link-2PzgTnaP.js +673 -0
- package/dist/{icons-dev-YtDoLUsb.cjs → link-D1Gjkb-2.cjs} +0 -350
- package/dist/{mdx-Bv-pS6-O.js → mdx-BuO6a1f7.js} +195 -40
- package/dist/{mdx-CDUcJmye.cjs → mdx-CD-tSjRG.cjs} +234 -73
- package/dist/{meta-loader-CTB62-Mo.cjs → meta-loader-Dq1zcFnh.cjs} +1 -1
- package/dist/node/cache.cjs +1 -1
- package/dist/node/cache.d.cts +2 -1
- package/dist/node/cache.d.mts +2 -1
- package/dist/node/cache.mjs +1 -1
- package/dist/node/cli-entry.cjs +6 -6
- package/dist/node/cli-entry.mjs +9 -9
- package/dist/node/index.cjs +1 -1
- package/dist/node/index.d.cts +20 -174
- package/dist/node/index.d.mts +18 -175
- package/dist/node/index.mjs +1 -1
- package/dist/node/mdx/shiki-adapter.cjs +1 -1
- package/dist/node/mdx/shiki-adapter.d.cts +49 -1
- package/dist/node/mdx/shiki-adapter.d.mts +49 -1
- package/dist/node/mdx/shiki-adapter.mjs +1 -1
- package/dist/node-B5hu_6qj.cjs +104 -0
- package/dist/node-BXtqM1uH.mjs +6 -0
- package/dist/node-C8725aw7.mjs +104 -0
- package/dist/node-aD1eisrR.cjs +6 -0
- package/dist/{package-_-Oa8-qN.cjs → package-CH2ChQqw.cjs} +1 -1
- package/dist/{package-CoHWTf0N.mjs → package-DSSB8B5L.mjs} +1 -1
- package/dist/{pages-external-CX2uyW95.cjs → pages-external-XkYIs-d5.cjs} +1 -1
- package/dist/parser-DCiEWkSk.cjs +8 -0
- package/dist/parser-qk9FIHJ7.mjs +8 -0
- package/dist/plugin-CX1OZ6jB.cjs +73 -0
- package/dist/plugin-CgfiWaFZ.mjs +73 -0
- package/dist/routes-BW6zsk7Z.mjs +6 -0
- package/dist/routes-BgoIB5wb.cjs +6 -0
- package/dist/{routes-D_S9kjkS.cjs → routes-CORVxc02.cjs} +1 -1
- package/dist/{search-dialog-BpNULmrl.cjs → search-dialog-B1NERUNx.cjs} +101 -55
- package/dist/{search-dialog-BbtxA1uT.cjs → search-dialog-BRFno7HD.cjs} +8 -8
- package/dist/{search-dialog-DC7oXU-5.js → search-dialog-BmxHiKwt.js} +2 -2
- package/dist/{search-dialog-gp9lrJXm.js → search-dialog-D6TvjcuV.js} +1 -1
- package/dist/{search-dialog-PJrFRU5G.js → search-dialog-DFnlx8LO.js} +44 -4
- package/dist/{search-dialog-BIuxGQsg.cjs → search-dialog-DHqwjJuG.cjs} +1 -1
- package/dist/server/index.cjs +1 -1
- package/dist/server/index.d.mts +1 -1
- package/dist/server/index.mjs +1 -1
- package/dist/shiki-adapter-CoQ6jyJ4.cjs +6 -0
- package/dist/shiki-adapter-D-aKw7PP.mjs +6 -0
- package/dist/{sidebar-DknLUI1R.d.ts → sidebar-COTaMHR-.d.ts} +349 -41
- package/dist/{sidebar-DH2iPKXM.d.cts → sidebar-CrEdJuHX.d.cts} +349 -41
- package/dist/{types-generator-CYcHkDzZ.cjs → types-generator-BXhv7Ill.cjs} +1 -1
- package/dist/types-generator-bDPvUztF.mjs +26 -0
- package/dist/utils-Crm9oPcV.mjs +7 -0
- package/dist/utils-D6Xtj0FZ.cjs +7 -0
- package/package.json +13 -10
- package/src/shared/types.ts +361 -19
- package/dist/chunk-hT5z_Zn9-DsJawvsz.mjs +0 -6
- package/dist/chunk-hT5z_Zn9-SKz6VFXu.cjs +0 -6
- package/dist/config-DAgpZyh6.mjs +0 -7
- package/dist/config-DrRQYDCI.cjs +0 -7
- package/dist/csp-z2D0FuRW.mjs +0 -6
- package/dist/doctor-BadGEhXv.cjs +0 -7
- package/dist/doctor-vDsUDgqp.mjs +0 -7
- package/dist/escape-string-regexp-AG8q1e25-9Un9V90q.mjs +0 -6
- package/dist/escape-string-regexp-AG8q1e25-bJ9Ixe7c.cjs +0 -6
- package/dist/esm-shims-DSep1HcR.mjs +0 -6
- package/dist/headers-CL0pMcwm.mjs +0 -6
- package/dist/icons-dev-CHZOwhQA.js +0 -921
- package/dist/lib-BR0SoanK-CLswltLI.cjs +0 -6
- package/dist/lib-BR0SoanK-DcYeDrE6.mjs +0 -6
- package/dist/lib-DPoCz1YB-CLYXwKST.cjs +0 -6
- package/dist/lib-DPoCz1YB-CyGOqgSO.mjs +0 -6
- package/dist/micromark-util-character-5KqJafVT-C6gnc770.cjs +0 -6
- package/dist/micromark-util-character-5KqJafVT-DkPKsbgn.mjs +0 -6
- package/dist/node-BDBv8CT6.mjs +0 -104
- package/dist/node-DFV_FV0y.mjs +0 -6
- package/dist/node-DqsP7kXz.cjs +0 -6
- package/dist/node-yFmAavND.cjs +0 -104
- package/dist/parser-BZJgAa9E.mjs +0 -8
- package/dist/parser-DlanzESE.cjs +0 -8
- package/dist/plugin-BVuwx5D9.cjs +0 -73
- package/dist/plugin-BoxD91Yh.mjs +0 -73
- package/dist/rehype-slug--ZOxZ-_K-BNeYC4aT.cjs +0 -6
- package/dist/rehype-slug--ZOxZ-_K-CjIQEJCs.mjs +0 -6
- package/dist/remark-frontmatter-wFYRLcCt-CutW0gA3.mjs +0 -8
- package/dist/remark-frontmatter-wFYRLcCt-ENB5qG3y.cjs +0 -8
- package/dist/remark-gfm-B8TMkQbX-CjUJo8Rd.cjs +0 -21
- package/dist/remark-gfm-B8TMkQbX-Ctu0VV1_.mjs +0 -21
- package/dist/rolldown-runtime-fkIsjY3S.mjs +0 -6
- package/dist/rollup-DMqoG11U-CKcJ37u_.mjs +0 -59
- package/dist/rollup-DMqoG11U-DKdxvZIj.cjs +0 -59
- package/dist/routes-BN2XbGcT.mjs +0 -6
- package/dist/routes-Cnq8xTCv.cjs +0 -6
- package/dist/shiki-adapter-CGTmrR6S.cjs +0 -6
- package/dist/shiki-adapter-CK3llqw2.mjs +0 -6
- package/dist/types-generator-DVOnRVKU.mjs +0 -26
- package/dist/utils-B3xYMrpK.mjs +0 -7
- package/dist/utils-Bz1tG9Dg.cjs +0 -7
- /package/dist/{errors-C0Hx15Ag.mjs → errors-0zGHRLue.mjs} +0 -0
- /package/dist/{errors-Dx6JHoKE.cjs → errors-vKw8CkiX.cjs} +0 -0
- /package/dist/{index-DJYJzs-Z.d.mts → index-1KsTDq4o.d.mts} +0 -0
- /package/dist/{meta-loader-Bq-MjTXB.mjs → meta-loader-C4Hu9RN9.mjs} +0 -0
package/dist/node/index.d.mts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
|
|
2
2
|
import { flushCache } from "./cache.mjs";
|
|
3
|
-
import { i as handleVercelFeedback, n as handleWebFeedback, r as handleNetlifyFeedback, t as handleAwsFeedback } from "../index-
|
|
4
|
-
import { a as
|
|
3
|
+
import { i as handleVercelFeedback, n as handleWebFeedback, r as handleNetlifyFeedback, t as handleAwsFeedback } from "../index-1KsTDq4o.mjs";
|
|
4
|
+
import { a as BoltdocsThemeConfig, c as PluginLogger, d as PluginTransformMiddleware, f as RouteMeta, i as BoltdocsPlugin, l as PluginMeta, n as defineConfig, o as PluginContext, r as BoltdocsConfig, s as PluginLifecycleHooks, t as resolveConfig, u as PluginStore } from "../config-xtS0ZkMm.mjs";
|
|
5
5
|
import { z } from "zod";
|
|
6
|
-
import { EXIT, SKIP } from "unist-util-visit";
|
|
7
6
|
import { InlineConfig, Plugin } from "vite";
|
|
7
|
+
export * from "@bdocs/unist-utils";
|
|
8
8
|
|
|
9
9
|
//#region src/node/plugin/types.d.ts
|
|
10
10
|
/**
|
|
@@ -56,6 +56,8 @@ interface SecureBoltdocsPlugin {
|
|
|
56
56
|
rehypePlugins?: unknown[];
|
|
57
57
|
vitePlugins?: Plugin[];
|
|
58
58
|
components?: Record<string, string>;
|
|
59
|
+
metadata?: Record<string, unknown>;
|
|
60
|
+
middleware?: PluginTransformMiddleware[];
|
|
59
61
|
hooks?: PluginLifecycleHooks;
|
|
60
62
|
}
|
|
61
63
|
//#endregion
|
|
@@ -115,181 +117,21 @@ declare class PluginLifecycleManager {
|
|
|
115
117
|
private outDir;
|
|
116
118
|
constructor(plugins: SecureBoltdocsPlugin[], config: BoltdocsConfig, docsDir?: string, rootDir?: string, routes?: RouteMeta[], outDir?: string);
|
|
117
119
|
runHook(hookName: keyof PluginLifecycleHooks, ...args: unknown[]): Promise<void>;
|
|
118
|
-
runChain<TParams
|
|
120
|
+
runChain<TParams extends Record<string, unknown>>(hookName: keyof PluginLifecycleHooks, initialParams: TParams): Promise<TParams>;
|
|
121
|
+
/**
|
|
122
|
+
* Run registered transform middleware in `enforce` order over a chain of
|
|
123
|
+
* params. Middleware registered via `ctx.middleware.add()` from lifecycle
|
|
124
|
+
* hooks or declared statically via `BoltdocsPlugin.middleware` are all
|
|
125
|
+
* collected. Execution respects `__signal: 'skip'` and `__signal: 'break'`.
|
|
126
|
+
*/
|
|
127
|
+
runMiddlewareChain<TParams extends Record<string, unknown>>(hookName: 'transformSource' | 'transformMdx' | 'transformHtml', initialParams: TParams): Promise<TParams>;
|
|
119
128
|
private getSortedPlugins;
|
|
120
129
|
private createStep;
|
|
121
130
|
private createContext;
|
|
131
|
+
private createGenericContext;
|
|
122
132
|
private createLogger;
|
|
123
133
|
}
|
|
124
134
|
//#endregion
|
|
125
|
-
//#region ../../node_modules/.pnpm/@types+unist@3.0.3/node_modules/@types/unist/index.d.ts
|
|
126
|
-
// ## Interfaces
|
|
127
|
-
/**
|
|
128
|
-
* Info associated with nodes by the ecosystem.
|
|
129
|
-
*
|
|
130
|
-
* This space is guaranteed to never be specified by unist or specifications
|
|
131
|
-
* implementing unist.
|
|
132
|
-
* But you can use it in utilities and plugins to store data.
|
|
133
|
-
*
|
|
134
|
-
* This type can be augmented to register custom data.
|
|
135
|
-
* For example:
|
|
136
|
-
*
|
|
137
|
-
* ```ts
|
|
138
|
-
* declare module 'unist' {
|
|
139
|
-
* interface Data {
|
|
140
|
-
* // `someNode.data.myId` is typed as `number | undefined`
|
|
141
|
-
* myId?: number | undefined
|
|
142
|
-
* }
|
|
143
|
-
* }
|
|
144
|
-
* ```
|
|
145
|
-
*/
|
|
146
|
-
interface Data {}
|
|
147
|
-
/**
|
|
148
|
-
* One place in a source file.
|
|
149
|
-
*/
|
|
150
|
-
interface Point {
|
|
151
|
-
/**
|
|
152
|
-
* Line in a source file (1-indexed integer).
|
|
153
|
-
*/
|
|
154
|
-
line: number;
|
|
155
|
-
/**
|
|
156
|
-
* Column in a source file (1-indexed integer).
|
|
157
|
-
*/
|
|
158
|
-
column: number;
|
|
159
|
-
/**
|
|
160
|
-
* Character in a source file (0-indexed integer).
|
|
161
|
-
*/
|
|
162
|
-
offset?: number | undefined;
|
|
163
|
-
}
|
|
164
|
-
/**
|
|
165
|
-
* Position of a node in a source document.
|
|
166
|
-
*
|
|
167
|
-
* A position is a range between two points.
|
|
168
|
-
*/
|
|
169
|
-
interface Position {
|
|
170
|
-
/**
|
|
171
|
-
* Place of the first character of the parsed source region.
|
|
172
|
-
*/
|
|
173
|
-
start: Point;
|
|
174
|
-
/**
|
|
175
|
-
* Place of the first character after the parsed source region.
|
|
176
|
-
*/
|
|
177
|
-
end: Point;
|
|
178
|
-
}
|
|
179
|
-
/**
|
|
180
|
-
* Abstract unist node.
|
|
181
|
-
*
|
|
182
|
-
* The syntactic unit in unist syntax trees are called nodes.
|
|
183
|
-
*
|
|
184
|
-
* This interface is supposed to be extended.
|
|
185
|
-
* If you can use {@link Literal} or {@link Parent}, you should.
|
|
186
|
-
* But for example in markdown, a `thematicBreak` (`***`), is neither literal
|
|
187
|
-
* nor parent, but still a node.
|
|
188
|
-
*/
|
|
189
|
-
interface Node {
|
|
190
|
-
/**
|
|
191
|
-
* Node type.
|
|
192
|
-
*/
|
|
193
|
-
type: string;
|
|
194
|
-
/**
|
|
195
|
-
* Info from the ecosystem.
|
|
196
|
-
*/
|
|
197
|
-
data?: Data | undefined;
|
|
198
|
-
/**
|
|
199
|
-
* Position of a node in a source document.
|
|
200
|
-
*
|
|
201
|
-
* Nodes that are generated (not in the original source document) must not
|
|
202
|
-
* have a position.
|
|
203
|
-
*/
|
|
204
|
-
position?: Position | undefined;
|
|
205
|
-
}
|
|
206
|
-
/**
|
|
207
|
-
* Abstract unist node that contains other nodes (*children*).
|
|
208
|
-
*
|
|
209
|
-
* This interface is supposed to be extended.
|
|
210
|
-
*
|
|
211
|
-
* For example, in XML, an element is a parent of different things, such as
|
|
212
|
-
* comments, text, and further elements.
|
|
213
|
-
*/
|
|
214
|
-
interface Parent extends Node {
|
|
215
|
-
/**
|
|
216
|
-
* List of children.
|
|
217
|
-
*/
|
|
218
|
-
children: Node[];
|
|
219
|
-
}
|
|
220
|
-
//#endregion
|
|
221
|
-
//#region src/node/mdx/types.d.ts
|
|
222
|
-
interface MdxJsxAttributeValueExpression {
|
|
223
|
-
type: 'mdxJsxAttributeValueExpression';
|
|
224
|
-
value: string;
|
|
225
|
-
data?: {
|
|
226
|
-
estree?: any;
|
|
227
|
-
};
|
|
228
|
-
}
|
|
229
|
-
interface MdxJsxAttribute {
|
|
230
|
-
type: 'mdxJsxAttribute';
|
|
231
|
-
name: string;
|
|
232
|
-
value?: string | MdxJsxAttributeValueExpression;
|
|
233
|
-
}
|
|
234
|
-
interface MdxJsxElement {
|
|
235
|
-
type: 'mdxJsxFlowElement' | 'mdxJsxTextElement';
|
|
236
|
-
name: string | null;
|
|
237
|
-
attributes?: MdxJsxAttribute[];
|
|
238
|
-
children?: any[];
|
|
239
|
-
}
|
|
240
|
-
interface ElementNode {
|
|
241
|
-
type: 'element';
|
|
242
|
-
tagName: string;
|
|
243
|
-
properties?: Record<string, any>;
|
|
244
|
-
children?: any[];
|
|
245
|
-
}
|
|
246
|
-
//#endregion
|
|
247
|
-
//#region src/node/plugins/plugin-utils.d.ts
|
|
248
|
-
interface NodeWithHProperties extends Node {
|
|
249
|
-
data?: {
|
|
250
|
-
hProperties?: Record<string, unknown>;
|
|
251
|
-
[key: string]: unknown;
|
|
252
|
-
};
|
|
253
|
-
}
|
|
254
|
-
/**
|
|
255
|
-
* General, type-safe utility to visit nodes in the AST (MDAST/HAST/MDX).
|
|
256
|
-
*/
|
|
257
|
-
declare function visitNodes<T extends Node>(tree: Node, test: string | string[] | ((node: Node) => boolean), callback: (node: T, index: number, parent: Parent) => void | number | boolean | symbol): void;
|
|
258
|
-
declare function visitRehypeElements(tree: Node, tagName: string, callback: (node: ElementNode, index: number, parent: Parent) => void | number | boolean | symbol): void;
|
|
259
|
-
declare function visitMdxElements(tree: Node, name: string | string[], callback: (node: MdxJsxElement, index: number, parent: Parent) => void | number | boolean | symbol): void;
|
|
260
|
-
declare function setNodeProperty(node: NodeWithHProperties, key: string, value: unknown): void;
|
|
261
|
-
declare function getNodeProperty(node: NodeWithHProperties, key: string): unknown;
|
|
262
|
-
declare function createMdxAttribute(name: string, value: unknown): MdxJsxAttribute;
|
|
263
|
-
declare function createRehypeElement(tagName: string, properties?: Record<string, unknown>, children?: Node[]): ElementNode;
|
|
264
|
-
declare function createMdxElement(name: string, attributes?: Record<string, unknown>, children?: Node[], isFlow?: boolean): MdxJsxElement;
|
|
265
|
-
declare function visitRemarkHeadings(tree: Node, callback: (node: any, index: number, parent: Parent) => void | number | boolean | symbol): void;
|
|
266
|
-
declare function visitRemarkLinks(tree: Node, callback: (node: any, index: number, parent: Parent) => void | number | boolean | symbol): void;
|
|
267
|
-
declare function addNodeClass(node: ElementNode, className: string): void;
|
|
268
|
-
declare function removeNodeClass(node: ElementNode, className: string): void;
|
|
269
|
-
declare function hasNodeClass(node: ElementNode, className: string): boolean;
|
|
270
|
-
//#endregion
|
|
271
|
-
//#region src/node/mdx/constants.d.ts
|
|
272
|
-
declare const MDX_NODES: {
|
|
273
|
-
readonly ROOT: "root";
|
|
274
|
-
readonly ELEMENT: "element";
|
|
275
|
-
readonly TEXT: "text";
|
|
276
|
-
readonly COMMENT: "comment";
|
|
277
|
-
readonly CODE: "code";
|
|
278
|
-
readonly INLINE_CODE: "inlineCode";
|
|
279
|
-
readonly HEADING: "heading";
|
|
280
|
-
readonly PARAGRAPH: "paragraph";
|
|
281
|
-
readonly LINK: "link";
|
|
282
|
-
readonly IMAGE: "image";
|
|
283
|
-
readonly LIST: "list";
|
|
284
|
-
readonly LIST_ITEM: "listItem";
|
|
285
|
-
readonly JSX_FLOW_ELEMENT: "mdxJsxFlowElement";
|
|
286
|
-
readonly JSX_TEXT_ELEMENT: "mdxJsxTextElement";
|
|
287
|
-
readonly JSX_ATTRIBUTE: "mdxJsxAttribute";
|
|
288
|
-
readonly FLOW_EXPRESSION: "mdxFlowExpression";
|
|
289
|
-
readonly TEXT_EXPRESSION: "mdxTextExpression";
|
|
290
|
-
readonly ESM: "mdxjsEsm";
|
|
291
|
-
};
|
|
292
|
-
//#endregion
|
|
293
135
|
//#region src/node/plugins/index.d.ts
|
|
294
136
|
declare function createPlugin(plugin: SecureBoltdocsPlugin): SecureBoltdocsPlugin;
|
|
295
137
|
//#endregion
|
|
@@ -324,8 +166,9 @@ declare function normalizePath(p: string): string;
|
|
|
324
166
|
* @returns The sanitized name
|
|
325
167
|
*/
|
|
326
168
|
declare function sanitizeFilename(name: string): string;
|
|
327
|
-
|
|
328
|
-
|
|
169
|
+
declare namespace index_d_exports {
|
|
170
|
+
export { BoltdocsConfig, BoltdocsPlugin, BoltdocsPluginOptions, BoltdocsPluginStore, BoltdocsThemeConfig, PluginCompatibilityError, PluginContext, PluginError, PluginHookError, PluginLifecycleHooks, PluginLifecycleManager, PluginLogger, PluginMeta, PluginStore, PluginValidationError, RouteMeta, SecureBoltdocsPlugin, createPlugin, createViteConfig, boltdocs as default, defineConfig, flushCache, generateEntryCode, generateRoutes, handleAwsFeedback, handleFeedback, handleNetlifyFeedback, handleVercelFeedback, handleWebFeedback, invalidateRouteCache, normalizePath, resolveConfig, sanitizeFilename, validatePlugins };
|
|
171
|
+
}
|
|
329
172
|
declare function boltdocs(options?: BoltdocsPluginOptions): Promise<Plugin[]>;
|
|
330
173
|
/**
|
|
331
174
|
* Generates the complete Vite configuration for a Boltdocs project.
|
|
@@ -333,4 +176,4 @@ declare function boltdocs(options?: BoltdocsPluginOptions): Promise<Plugin[]>;
|
|
|
333
176
|
*/
|
|
334
177
|
declare function createViteConfig(root: string, mode?: 'development' | 'production', preResolvedConfig?: BoltdocsConfig, turbo?: boolean): Promise<InlineConfig>;
|
|
335
178
|
//#endregion
|
|
336
|
-
export { type BoltdocsConfig, type BoltdocsPlugin, type BoltdocsPluginOptions, BoltdocsPluginStore, type BoltdocsThemeConfig,
|
|
179
|
+
export { type BoltdocsConfig, type BoltdocsPlugin, type BoltdocsPluginOptions, BoltdocsPluginStore, type BoltdocsThemeConfig, PluginCompatibilityError, type PluginContext, PluginError, PluginHookError, type PluginLifecycleHooks, PluginLifecycleManager, type PluginLogger, type PluginMeta, type PluginStore, PluginValidationError, type RouteMeta, SecureBoltdocsPlugin, createPlugin, createViteConfig, boltdocs as default, defineConfig, flushCache, generateEntryCode, generateRoutes, handleAwsFeedback, handleFeedback, handleNetlifyFeedback, handleVercelFeedback, handleWebFeedback, invalidateRouteCache, normalizePath, resolveConfig, sanitizeFilename, validatePlugins };
|
package/dist/node/index.mjs
CHANGED
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* Copyright (c) 2026 Jesus Alcala
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
|
-
import{
|
|
6
|
+
import{_ as e,b as t,g as n,h as r,i,m as a,n as o,r as s,t as c,v as l,y as u}from"../node-C8725aw7.mjs";import{f as d,u as f}from"../utils-Crm9oPcV.mjs";import{flushCache as p}from"./cache.mjs";import{r as m,t as h}from"../routes-BW6zsk7Z.mjs";import{a as g,r as _}from"../config-CCXp3aXO.mjs";import{t as v}from"../handler-DzQae4eA.mjs";import{i as y,n as b,r as x,t as S}from"../adapters-ByYY44Zy.mjs";export*from"@bdocs/unist-utils";export{r as BoltdocsPluginStore,n as PluginCompatibilityError,e as PluginError,l as PluginHookError,i as PluginLifecycleManager,u as PluginValidationError,s as createPlugin,o as createViteConfig,c as default,g as defineConfig,p as flushCache,t as generateEntryCode,h as generateRoutes,S as handleAwsFeedback,v as handleFeedback,x as handleNetlifyFeedback,y as handleVercelFeedback,b as handleWebFeedback,m as invalidateRouteCache,f as normalizePath,_ as resolveConfig,d as sanitizeFilename,a as validatePlugins};
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* Copyright (c) 2026 Jesus Alcala
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../../shiki-adapter-
|
|
6
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../../shiki-adapter-CoQ6jyJ4.cjs`);exports.ShikiAdapter=e.t,exports.getShikiAdapter=e.n,exports.parseMetaString=e.r;
|
|
@@ -1,3 +1,51 @@
|
|
|
1
1
|
|
|
2
|
-
import {
|
|
2
|
+
import { p as ShikiTheme, r as BoltdocsConfig } from "../../config-BpzaPsJj.cjs";
|
|
3
|
+
import * as _$shiki from "shiki";
|
|
4
|
+
import { CodeToHastOptions } from "shiki";
|
|
5
|
+
|
|
6
|
+
//#region src/node/mdx/shiki-adapter.d.ts
|
|
7
|
+
interface ParsedMeta {
|
|
8
|
+
title?: string;
|
|
9
|
+
lineNumbers?: boolean;
|
|
10
|
+
wordWrap?: boolean;
|
|
11
|
+
[key: string]: any;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Parses a meta string into a structured ParsedMeta object.
|
|
15
|
+
*/
|
|
16
|
+
declare function parseMetaString(metaStr: string): ParsedMeta;
|
|
17
|
+
/**
|
|
18
|
+
* Unified Shiki Adapter for Boltdocs.
|
|
19
|
+
* Centralizes theme resolution, transformer configuration, and rendering logic.
|
|
20
|
+
*/
|
|
21
|
+
declare class ShikiAdapter {
|
|
22
|
+
private config;
|
|
23
|
+
constructor(config?: BoltdocsConfig);
|
|
24
|
+
/**
|
|
25
|
+
* Resolves the code theme from Boltdocs configuration.
|
|
26
|
+
*/
|
|
27
|
+
getTheme(): ShikiTheme | {
|
|
28
|
+
light: ShikiTheme;
|
|
29
|
+
dark: ShikiTheme;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Creates a Shiki highlighter instance with the configured themes.
|
|
33
|
+
*/
|
|
34
|
+
getHighlighter(): Promise<_$shiki.HighlighterCore>;
|
|
35
|
+
/**
|
|
36
|
+
* Assembles Shiki options including transformers for a specific code block.
|
|
37
|
+
*/
|
|
38
|
+
getOptions(lang: string, meta: string | ParsedMeta): CodeToHastOptions;
|
|
39
|
+
/**
|
|
40
|
+
* Renders code to HTML using the Boltdocs Shiki pipeline.
|
|
41
|
+
* Safely handles highlighter exceptions by falling back to escaped pre.
|
|
42
|
+
*/
|
|
43
|
+
render(code: string, lang: string, meta: string | ParsedMeta): Promise<string>;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Returns a cached ShikiAdapter instance.
|
|
47
|
+
* Recreates only if the relevant codeTheme configuration values change deeply.
|
|
48
|
+
*/
|
|
49
|
+
declare function getShikiAdapter(config?: BoltdocsConfig): ShikiAdapter;
|
|
50
|
+
//#endregion
|
|
3
51
|
export { ParsedMeta, ShikiAdapter, getShikiAdapter, parseMetaString };
|
|
@@ -1,3 +1,51 @@
|
|
|
1
1
|
|
|
2
|
-
import {
|
|
2
|
+
import { p as ShikiTheme, r as BoltdocsConfig } from "../../config-xtS0ZkMm.mjs";
|
|
3
|
+
import * as _$shiki from "shiki";
|
|
4
|
+
import { CodeToHastOptions } from "shiki";
|
|
5
|
+
|
|
6
|
+
//#region src/node/mdx/shiki-adapter.d.ts
|
|
7
|
+
interface ParsedMeta {
|
|
8
|
+
title?: string;
|
|
9
|
+
lineNumbers?: boolean;
|
|
10
|
+
wordWrap?: boolean;
|
|
11
|
+
[key: string]: any;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Parses a meta string into a structured ParsedMeta object.
|
|
15
|
+
*/
|
|
16
|
+
declare function parseMetaString(metaStr: string): ParsedMeta;
|
|
17
|
+
/**
|
|
18
|
+
* Unified Shiki Adapter for Boltdocs.
|
|
19
|
+
* Centralizes theme resolution, transformer configuration, and rendering logic.
|
|
20
|
+
*/
|
|
21
|
+
declare class ShikiAdapter {
|
|
22
|
+
private config;
|
|
23
|
+
constructor(config?: BoltdocsConfig);
|
|
24
|
+
/**
|
|
25
|
+
* Resolves the code theme from Boltdocs configuration.
|
|
26
|
+
*/
|
|
27
|
+
getTheme(): ShikiTheme | {
|
|
28
|
+
light: ShikiTheme;
|
|
29
|
+
dark: ShikiTheme;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Creates a Shiki highlighter instance with the configured themes.
|
|
33
|
+
*/
|
|
34
|
+
getHighlighter(): Promise<_$shiki.HighlighterCore>;
|
|
35
|
+
/**
|
|
36
|
+
* Assembles Shiki options including transformers for a specific code block.
|
|
37
|
+
*/
|
|
38
|
+
getOptions(lang: string, meta: string | ParsedMeta): CodeToHastOptions;
|
|
39
|
+
/**
|
|
40
|
+
* Renders code to HTML using the Boltdocs Shiki pipeline.
|
|
41
|
+
* Safely handles highlighter exceptions by falling back to escaped pre.
|
|
42
|
+
*/
|
|
43
|
+
render(code: string, lang: string, meta: string | ParsedMeta): Promise<string>;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Returns a cached ShikiAdapter instance.
|
|
47
|
+
* Recreates only if the relevant codeTheme configuration values change deeply.
|
|
48
|
+
*/
|
|
49
|
+
declare function getShikiAdapter(config?: BoltdocsConfig): ShikiAdapter;
|
|
50
|
+
//#endregion
|
|
3
51
|
export { ParsedMeta, ShikiAdapter, getShikiAdapter, parseMetaString };
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* Copyright (c) 2026 Jesus Alcala
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
|
-
import{n as e,r as t,t as n}from"../../shiki-adapter-
|
|
6
|
+
import{n as e,r as t,t as n}from"../../shiki-adapter-D-aKw7PP.mjs";export{n as ShikiAdapter,e as getShikiAdapter,t as parseMetaString};
|
|
@@ -0,0 +1,104 @@
|
|
|
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-D6Xtj0FZ.cjs`),n=require(`./node/cache.cjs`),r=require(`./routes-BgoIB5wb.cjs`),i=require(`./pages-external-XkYIs-d5.cjs`),a=require(`./config-DlGoEM9D.cjs`),o=require(`./types-generator-BXhv7Ill.cjs`),s=require(`./handler-XX7cLTqe.cjs`),c=require(`./adapters-DvmtpdSF.cjs`);let l=require(`node:path`);l=e.r(l);let u=require(`node:fs`);u=e.r(u);let d=require(`zod`),f=require(`@bdocs/dui`);f=e.r(f);let p=require(`semver`);p=e.r(p);let m=require(`node:module`),h=require(`@bdocs/ssg/node`);function g(){return{name:`boltdocs-ssr-dirname-polyfill`,config:(e,{isSsrBuild:t})=>t?{define:{__dirname:`import.meta.dirname`}}:{}}}function _(e,n){let r=l.default.resolve(process.cwd(),`index.css`),i=u.default.existsSync(r)?`import './index.css';`:``,a=n?.plugins?.flatMap(e=>Object.entries(e.components||{}))||[],o=a.map(([e,n])=>`import { ${e} as _comp_${e} } from '${t.u(n)}';`).join(`
|
|
7
|
+
`),s=a.map(([e])=>`${e}: _comp_${e}`).join(`, `),c=l.default.basename(e.docsDir||`docs`),d=l.default.resolve(process.cwd(),e.docsDir||`docs`),f=[`tsx`,`ts`,`jsx`,`js`].map(e=>l.default.resolve(d,`pages-external/index.${e}`)).find(e=>u.default.existsSync(e)),p=f?`import * as _external_module from '${t.u(f)}';`:``,m=f?`externalPages: _external_module.pages, externalLayout: _external_module.layout,`:``,h=process.env.VITE_SSG===`true`,g=h?`{ eager: true }`:`{}`,_=h?``:`
|
|
8
|
+
if (typeof window !== 'undefined') {
|
|
9
|
+
const prefetchAll = () => {
|
|
10
|
+
const getters = Object.values(mdxModules)
|
|
11
|
+
if (getters.length === 0) return
|
|
12
|
+
let i = 0
|
|
13
|
+
const nextBatch = () => {
|
|
14
|
+
if (i >= getters.length) return
|
|
15
|
+
const batch = getters.slice(i, i + 6)
|
|
16
|
+
i += batch.length
|
|
17
|
+
Promise.allSettled(batch.map(fn => fn())).then(() => {
|
|
18
|
+
setTimeout(nextBatch, 0)
|
|
19
|
+
})
|
|
20
|
+
}
|
|
21
|
+
;(typeof requestIdleCallback === 'function' ? requestIdleCallback : function(cb) { setTimeout(cb, 500) })(nextBatch)
|
|
22
|
+
}
|
|
23
|
+
prefetchAll()
|
|
24
|
+
}
|
|
25
|
+
`;return`
|
|
26
|
+
import { ViteReactSSG, createRoutes } from 'boltdocs/client'
|
|
27
|
+
import _routes from 'virtual:boltdocs-routes.ts'
|
|
28
|
+
import _collections from 'virtual:boltdocs-collections.ts'
|
|
29
|
+
import _config from 'virtual:boltdocs-config.ts'
|
|
30
|
+
import _user_mdx_components from 'virtual:boltdocs-mdx-components.tsx'
|
|
31
|
+
${i}
|
|
32
|
+
${o}
|
|
33
|
+
${p}
|
|
34
|
+
|
|
35
|
+
const mdxModules = import.meta.glob('/${c}/**/*.{md,mdx}', ${g});
|
|
36
|
+
|
|
37
|
+
const _collLayoutMods = import.meta.glob('${`/${c}/**/layout.tsx`}', { eager: true });
|
|
38
|
+
const _collListMods = import.meta.glob('${`/${c}/**/list.tsx`}', { eager: true });
|
|
39
|
+
const _collPostMods = import.meta.glob('${`/${c}/**/post.tsx`}', { eager: true });
|
|
40
|
+
|
|
41
|
+
const _collectionLayouts = {};
|
|
42
|
+
for (const [p, mod] of Object.entries(_collLayoutMods)) {
|
|
43
|
+
const dir = p.split('/').slice(-2, -1)[0];
|
|
44
|
+
if (dir.startsWith('[') && dir.endsWith(']')) {
|
|
45
|
+
_collectionLayouts[dir.slice(1, -1)] = mod.default || mod;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const _collectionLists = {};
|
|
50
|
+
for (const [p, mod] of Object.entries(_collListMods)) {
|
|
51
|
+
const dir = p.split('/').slice(-2, -1)[0];
|
|
52
|
+
if (dir.startsWith('[') && dir.endsWith(']')) {
|
|
53
|
+
_collectionLists[dir.slice(1, -1)] = mod.default || mod;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const _collectionPosts = {};
|
|
58
|
+
for (const [p, mod] of Object.entries(_collPostMods)) {
|
|
59
|
+
const dir = p.split('/').slice(-2, -1)[0];
|
|
60
|
+
if (dir.startsWith('[') && dir.endsWith(']')) {
|
|
61
|
+
_collectionPosts[dir.slice(1, -1)] = mod.default || mod;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export const createRoot = ViteReactSSG(
|
|
66
|
+
{
|
|
67
|
+
routes: createRoutes({
|
|
68
|
+
routesData: _routes,
|
|
69
|
+
collectionsData: _collections,
|
|
70
|
+
collectionLayouts: _collectionLayouts,
|
|
71
|
+
collectionLists: _collectionLists,
|
|
72
|
+
collectionPosts: _collectionPosts,
|
|
73
|
+
config: _config,
|
|
74
|
+
mdxModules,
|
|
75
|
+
${m}
|
|
76
|
+
components: { ${s}${s?`, `:``} ...(_user_mdx_components || {}) },
|
|
77
|
+
}),
|
|
78
|
+
},
|
|
79
|
+
({ isClient }) => {
|
|
80
|
+
// Boltdocs initialization hook
|
|
81
|
+
if (isClient) {
|
|
82
|
+
// Client-side initialization
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
);
|
|
86
|
+
${_}
|
|
87
|
+
`}var v=class extends Error{name=this.constructor.name;constructor(e,t,n){super(`[plugin:${e}] ${t}`,n),this.pluginName=e}},y=class extends v{constructor(e,t){super(e,`Validation failed: ${t}`)}},b=class extends v{constructor(e,t){super(e,`Compatibility error: ${t}`)}},x=class extends v{constructor(e,t,n){super(e,`Error in hook '${t}': ${n.message}`,{cause:n}),this.hookName=t}},S=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 C=a.i.extend({version:d.z.string().optional(),boltdocsVersion:d.z.string().optional(),hooks:d.z.object({beforeBuild:d.z.function().optional(),afterBuild:d.z.function().optional(),beforeDev:d.z.function().optional(),afterDev:d.z.function().optional(),buildEnd:d.z.function().optional(),transformSource:d.z.function().optional(),transformMdx:d.z.function().optional(),transformHtml:d.z.function().optional()}).optional()});function w(e,t){let n=[],r=new Set;for(let i of e){let e=C.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&&!p.default.satisfies(t,a.boltdocsVersion))throw new b(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(`..`))throw new y(a.name,`Component '${e}' has an invalid path: traversal sequences are not allowed.`);if(l.default.isAbsolute(t))throw new y(a.name,`Component '${e}' has an invalid path: absolute paths are not allowed.`)}n.push(a)}return n}function T(e,t=process.cwd()){let n=e.plugins||[];for(let e of n)if(e.name)try{let n=null;try{n=(0,m.createRequire)(l.default.resolve(t,`package.json`)).resolve(`${e.name}/package.json`)}catch{let r=l.default.resolve(t,`node_modules`,e.name,`package.json`);u.default.existsSync(r)&&(n=r)}if(n&&u.default.existsSync(n)){let t=JSON.parse(u.default.readFileSync(n,`utf-8`)).scripts||{};(t.preinstall||t.postinstall||t.install)&&(0,f.warn)(`💡 ${f.colors.yellow(f.colors.bold(`Nota de seguridad:`))} El plugin ${f.colors.cyan(e.name)} ejecuta scripts nativos al instalarse. Corre ${f.colors.bold(`boltdocs audit`)} para un análisis detallado.`)}}catch{}}var E=class{name=`ConfigResolve`;async execute(e){e.config=await a.n(`docs`,e.root),T(e.config,e.root),e.viteConfig=await $(e.root,`production`,e.config,e.turbo)}};function D(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||``,_rawContent:e._rawContent||``,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,frontmatter:e.frontmatter,slugParts:e.slugParts}))}var ee=class{name=`RouteGenerate`;async execute(e){if(!e.config)throw Error(`Config not resolved. Run ConfigResolve first.`);let t=l.default.resolve(e.root,`docs`),n=e.viteConfig?.base||e.config.base||`/docs`;e.routes=[...await r.t(t,e.config,n,!1,e.turbo)],e.ssgRoutes=D(e.routes)}};const te=d.z.object({title:d.z.string().optional(),description:d.z.string().optional(),canonical:d.z.string().url().optional(),robots:d.z.string().optional(),noindex:d.z.boolean().optional(),"og:title":d.z.string().optional(),"og:description":d.z.string().optional(),"og:image":d.z.string().optional(),"og:type":d.z.string().optional(),"og:url":d.z.string().url().optional()});var ne=class{name=`SEOValidate`;async execute(e){if(!e.routes||!e.config)throw Error(`Routes or Config not initialized.`);let t=e.config?.siteUrl;e.routes=e.routes.map(n=>{let r=n.seo||{},i=r.canonical||(t?`${t.replace(/\/$/,``)}${n.path}`:void 0),a=r[`og:url`]||i||void 0,o=e.config?.seo?.thumbnails?.background??void 0,s=r[`og:image`]||n.coverImage||o;s&&t&&!/^https?:\/\/|^\/\//.test(s)&&(s=`${t.endsWith(`/`)?t.slice(0,-1):t}${s.startsWith(`/`)?s:`/${s}`}`);let c={...r};i&&(c.canonical=i),a&&(c[`og:url`]=a),s&&(c[`og:image`]=s),!c[`og:title`]&&n.title&&(c[`og:title`]=String(n.title)),!c[`og:description`]&&n.description&&(c[`og:description`]=String(n.description));let l=te.safeParse(c);return l.success||(0,f.warn)(`[SEOValidate] Validation issues on route "${n.path}": ${l.error.message}`),n.title||(0,f.warn)(`[SEOValidate] Route "${n.path}" is missing a title.`),{...n,seo:c}}),e.ssgRoutes=D(e.routes)}},re=class{name=`TypeGenerate`;async execute(e){if(!e.config||!e.routes)throw Error(`Config or Routes not initialized.`);let t=l.default.resolve(e.root,`docs`),n=e.routes.map(e=>e.path),r=(e.config.base||`/docs`).replace(/\/$/,``);n.includes(r)||n.push(r);let a=i.t(t,e.config);for(let e of a)n.includes(e)||n.push(e);o.t(e.config,t,e.root,n),o.r(n)}},ie=class{name=`SSGBuild`;async execute(e){if(!e.routes||!e.viteConfig)throw Error(`Routes or ViteConfig not initialized.`);let t={};for(let n of e.routes)if(n.path&&n.componentPath){t[n.path]=n.componentPath;let e=n.path.replace(/\/$/,``);t[e]=n.componentPath}let n=[];await(0,h.build)({entry:`boltdocs/entry`,routeToSourceFileMap:t,cacheDir:l.default.resolve(e.root,`.boltdocs/build`),turbo:e.turbo,onStep:e=>{n.push(e)}},e.viteConfig),e.ssgSubSteps=n,e.outDir=e.viteConfig.build?.outDir||`dist`}};function ae(e,n){let r=(n.siteUrl||``).replace(/\/$/,``);if(!r)return``;let i=n.seo?.indexing!==`all`&&n.seo?.indexing!==`public`;return`<?xml version="1.0" encoding="UTF-8"?>
|
|
88
|
+
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
|
89
|
+
${e.filter(e=>e.seo?.noindex||typeof e.seo?.robots==`string`&&e.seo.robots.includes(`noindex`)?!1:(i&&e.seo?.index,!0)).map(e=>` <url>
|
|
90
|
+
<loc>${t.r(`${r}${e.path.startsWith(`/`)?e.path:`/${e.path}`}`)}</loc>
|
|
91
|
+
<changefreq>weekly</changefreq>
|
|
92
|
+
<priority>0.7</priority>
|
|
93
|
+
</url>`).join(`
|
|
94
|
+
`)}
|
|
95
|
+
</urlset>`}function oe(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(`
|
|
96
|
+
`);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(`
|
|
97
|
+
`)+`
|
|
98
|
+
`:t+=`Allow: ${e.allow}\n`),e.disallow&&(Array.isArray(e.disallow)?t+=e.disallow.map(e=>`Disallow: ${e}`).join(`
|
|
99
|
+
`)+`
|
|
100
|
+
`:t+=`Disallow: ${e.disallow}\n`),t.trim()}).join(`
|
|
101
|
+
|
|
102
|
+
`),a=[...n?[n]:[],...r].map(e=>`Sitemap: ${e}`).join(`
|
|
103
|
+
`);return`${i}${a?`\n\n${a}`:``}`}return[`User-agent: *`,`Allow: /`,``,n?`Sitemap: ${n}`:``].filter(Boolean).join(`
|
|
104
|
+
`)}var se=class{name=`SEOWrite`;async execute(e){if(!e.ssgRoutes||!e.config||!e.outDir)throw Error(`SSG Routes, Config, or OutDir not initialized.`);let t=ae(e.ssgRoutes,e.config),n=l.default.resolve(e.root,e.outDir);t&&u.default.writeFileSync(l.default.join(n,`sitemap.xml`),t,`utf-8`);let r=oe(e.config);u.default.writeFileSync(l.default.join(n,`robots.txt`),r,`utf-8`)}};function ce(){return new O().addStep(new E).addStep(new ee).addParallelSteps([new ne,new re]).addStep(new ie).addStep(new se)}var O=class{steps=[];addStep(e){return this.steps.push(e),this}addParallelSteps(e){return this.steps.push(e),this}async run(e){let t=[],n=performance.now(),r={...e,timing:{}};for(let e of this.steps){let i=Array.isArray(e),a=i?e:[e],o=performance.now();try{i?await Promise.all(a.map(e=>e.execute(r))):await a[0].execute(r);let e=performance.now()-o;for(let n of a){let i=r.stepDetails?.[n.name];t.push({name:n.name,duration:e,success:!0,details:i}),r.timing[n.name]=e}if(r.ssgSubSteps){for(let e of r.ssgSubSteps)t.push(e);delete r.ssgSubSteps}}catch(e){let i=performance.now()-o,s=a.find(e=>!t.some(t=>t.name===e.name&&t.success))?.name||a.map(e=>e.name).join(` | `);t.push({name:s,duration:i,success:!1,error:e instanceof Error?e:Error(String(e))});for(let e of t.filter(e=>e.success).reverse()){let t=this.steps.flat().find(t=>t.name===e.name);if(t?.rollback)try{await t.rollback(r)}catch(t){console.error(`[pipeline] rollback failed for step "${e.name}":`,t)}}let c=performance.now()-n;return{success:!1,failedStep:s,error:e instanceof Error?e:Error(String(e)),timing:{total:c,steps:r.timing},stepResults:t}}}return{success:!0,timing:{total:performance.now()-n,steps:r.timing},stepResults:t}}};let k=0;const A=`virtual:boltdocs-`,j=new Map,M=new Map,N=[];function le(){return new Date}function P(){return{transform(e){let t=new n.TransformCache(`plugin:${e}`);return{async get(e){return t.getAsync(e)},set(e,n){t.set(e,n)},async flush(){await t.flush()}}},routes:ue(),memory(e,t){let n=`${e}:`,r=t?.ttl,i=t?.max??100,a=new Map;function o(e){return e.expiresAt!==null&&e.expiresAt<=Date.now()}return{get(e){let t=a.get(n+e);if(t){if(o(t)){a.delete(n+e);return}return t.value}},set(e,t){let o=n+e;if(!a.has(o)&&a.size>=i){let e=a.keys().next().value;e!==void 0&&a.delete(e)}a.set(o,{value:t,expiresAt:r===void 0?null:Date.now()+r})},has(e){let t=a.get(n+e);return t?o(t)?(a.delete(n+e),!1):!0:!1}}}}}function ue(){return{get(e){return r.i.get(e)?.route??null},set(e,t){r.i.set(e,{route:t})},invalidate(e){r.i.invalidate(e)},invalidateAll(){r.i.invalidateAll()}}}function F(e){return{report(t,n,r,i){let a={id:++k,severity:t,code:n,message:r,pluginName:e,filePath:i?.filePath,routePath:i?.routePath,time:le()};if(N.push(a),N.length>256){let e=N.length-256;N.splice(0,e)}},list(){return Object.freeze([...N])},clear(){N.length=0}}}function I(e,t){return{resolveDocs(...t){return L(e,...t)},resolveAsset(...e){return L(t,...e)},safeFileURL(e){return`file://${l.default.resolve(e).replace(/\\/g,`/`)}`}}}function L(e,...n){let r=l.default.resolve(e),i=l.default.resolve(r,...n),a=l.default.relative(r,i);if(a.startsWith(`..`)||l.default.isAbsolute(a))throw Error(`[boltdocs/plugin-context] Path '${n.join(`/`)}' resolves to '${i}' which is outside the workspace boundary '${r}'.`);return t.u(i)}function R(){return{add(e,t,n){if(j.has(e))throw Error(`[boltdocs] Virtual module '${e}' is already registered. Pick a unique id (e.g. prefix it with your plugin name) so two plugins do not collide.`);if(e.startsWith(A))throw Error(`[boltdocs] Virtual module id '${e}' starts with the reserved prefix '${A}'. Use your own plugin namespace (e.g. 'virtual:my-plugin/...').`);j.set(e,{id:e,eager:n?.eager??!1,loader:t})},has(e){return j.has(e)},list(){return Object.freeze([...j.values()])}}}function z(){j.clear()}function B(){function e(e){return U.has(e)||U.set(e,new Set),U.get(e)}return{onFileEvent(t,n){e(t).add(n)},onFileAdd(t){e(`add`).add(t)},onFileChange(t){e(`change`).add(t)},onFileUnlink(t){e(`unlink`).add(t)},send(e,t){W?.(`boltdocs:plugin:${e}`,t)}}}async function V(e,t){let n=U.get(e);if(n)for(let e of n)await e(t)}let H=0;const U=new Map;let W=null;function de(e){W=e}const G=[],K=[],fe=[];function q(e){for(let t of G)e.middlewares.use(t)}async function pe(){for(let e of K)await e()}function J(){return{use(e){G.push(e)},useAt(e,t){G.push((n,r,i)=>{if(n.url?.startsWith(e))return t(n,r,i);i()})},onStart(e){K.push(e)},onEnd(e){fe.push(e)}}}function Y(){return{add(e){let t=e.name??`_unnamed_${H++}`;if(M.has(t))throw Error(`[boltdocs] Middleware '${e.name??`<unnamed>`}' is already registered.`);M.set(t,e)},remove(e){M.delete(e)},has(e){return M.has(e)},list(){return Object.freeze([...M.values()])}}}var X=class{plugins;config;store;docsDir;rootDir;routes;outDir;constructor(e,t,n,r,i,a){this.plugins=e,this.config=t,this.store=new S,this.docsDir=n||process.cwd(),this.rootDir=r||process.cwd(),this.routes=i||[],this.outDir=a||`dist`}async runHook(e,...t){let n=this.getSortedPlugins(),r=new O;for(let i of n)i.hooks?.[e]&&r.addStep(this.createStep(i,e,t));await r.run({})}async runChain(e,t){let n=this.getSortedPlugins(),r=t;for(let t of n){if(!t.hooks?.[e])continue;let n=this.createContext(t);try{let i=t.hooks[e],a=await i(n,r);if(a!==void 0){let e=a.__signal;if(e===`break`)break;if(e===`skip`){r=a;break}r=a}}catch(r){let i=new x(t.name,e,r instanceof Error?r:Error(String(r)));n.logger.error(i),n.diagnostics.report(`error`,`PLUGIN_HOOK_ERROR`,i.message)}}return r}async runMiddlewareChain(e,t){let n=this.plugins.flatMap(e=>e.middleware??[]),r=[...M.values()],i=[...n,...r],a=[...i.filter(e=>e.enforce===`pre`),...i.filter(e=>!e.enforce),...i.filter(e=>e.enforce===`post`)],o=t;for(let t of a){let n=t[e];if(!n)continue;let r=this.createGenericContext();try{let e=await n(r,o);if(e!==void 0){let t=e.__signal;if(t===`break`)break;if(t===`skip`){o=e;break}o=e}}catch(e){let n=t.name??`<unnamed>`;r.diagnostics.report(`error`,`MIDDLEWARE_ERROR`,`Middleware '${n}' threw: ${e instanceof Error?e.message:String(e)}`)}}return o}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]}createStep(e,t,n){return{name:`${e.name}:${String(t)}`,execute:async()=>{let r=this.createContext(e);try{let i=e.hooks[t];await i(r,...n)}catch(n){let i=new x(e.name,t,n instanceof Error?n:Error(String(n)));r.logger.error(i)}},rollback:async()=>{let t=e.hooks?.buildEnd;if(t){let n=this.createContext(e);try{await t(n)}catch{}}}}}createContext(e){return{config:Object.freeze({...this.config}),docsDir:this.docsDir,rootDir:this.rootDir,outDir:this.outDir,routes:this.routes,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),caches:P(),diagnostics:F(e.name),paths:I(this.docsDir,this.rootDir),virtualModules:R(),middleware:Y(),hmr:B(),server:J()}}createGenericContext(){let e=`<middleware>`;return{config:Object.freeze({...this.config}),docsDir:this.docsDir,rootDir:this.rootDir,outDir:this.outDir,routes:this.routes,meta:{name:e},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),caches:P(),diagnostics:F(e),paths:I(this.docsDir,this.rootDir),virtualModules:R(),middleware:Y(),hmr:B(),server:J()}}createLogger(e){let t=`[plugin:${e}]`;return{info:e=>f.info(`${t} ${e}`),warn:e=>f.warn(`${t} ${e}`),error:e=>{f.error(`${t} ${e instanceof Error?e.message:e}`)},debug:e=>f.debug(`${t} ${e}`)}}};function Z(e){return e}var me=e.t({BoltdocsPluginStore:()=>S,PluginCompatibilityError:()=>b,PluginError:()=>v,PluginHookError:()=>x,PluginLifecycleManager:()=>X,PluginValidationError:()=>y,createPlugin:()=>Z,createViteConfig:()=>$,default:()=>Q,defineConfig:()=>a.a,flushCache:()=>n.flushCache,generateEntryCode:()=>_,generateRoutes:()=>r.t,handleAwsFeedback:()=>c.t,handleFeedback:()=>s.t,handleNetlifyFeedback:()=>c.r,handleVercelFeedback:()=>c.i,handleWebFeedback:()=>c.n,invalidateRouteCache:()=>r.r,normalizePath:()=>t.u,resolveConfig:()=>a.n,sanitizeFilename:()=>t.f,validatePlugins:()=>w});async function Q(e){let{resolveConfig:t}=await Promise.resolve().then(()=>require(`./config-CMd4XoFq.cjs`)),{generateRoutes:n,getExternalRoutePaths:r}=await Promise.resolve().then(()=>require(`./routes-CORVxc02.cjs`)),{generateProjectTypes:i,writeLinkTree:a}=await Promise.resolve().then(()=>require(`./types-generator-BXhv7Ill.cjs`)).then(e=>e.n),{boltdocsPlugin:o}=await Promise.resolve().then(()=>require(`./plugin-CX1OZ6jB.cjs`)),s=e?.docsDir||`docs`,c=await t(s),l=(await n(s,c)).map(e=>e.path),u=(c.base||`/docs`).replace(/\/$/,``);l.includes(u)||l.push(u);let d=r(s,c);for(let e of d)l.includes(e)||l.push(e);return i(c,s,void 0,l),a(l),o({...e},c)}async function $(e,t=`development`,n,r){let i=r||process.env.BOLTDOCS_TURBO===`true`,[a,o,{boltdocsPlugin:s,getExternalAbsolutePaths:c},{SECURITY_HEADERS:u},{getCSPHeader:d},{resolveConfig:f},{generateRoutes:p,getExternalRoutePaths:m},{generateProjectTypes:h,writeLinkTree:_},{normalizePath:v}]=await Promise.all([import(`@vitejs/plugin-react`),import(`@tailwindcss/vite`),Promise.resolve().then(()=>require(`./plugin-CX1OZ6jB.cjs`)),Promise.resolve().then(()=>require(`./headers-dg4SDrjY.cjs`)).then(e=>e.n),Promise.resolve().then(()=>require(`./csp-CRp_3U7a.cjs`)).then(e=>e.t),Promise.resolve().then(()=>require(`./config-CMd4XoFq.cjs`)),Promise.resolve().then(()=>require(`./routes-CORVxc02.cjs`)),Promise.resolve().then(()=>require(`./types-generator-BXhv7Ill.cjs`)).then(e=>e.n),import(`vite`).then(e=>({normalizePath:e.normalizePath}))]),y=a.default,b=o.default,x=n||await f(`docs`,e),S=(await p(`docs`,x,void 0,!1,i)).map(e=>e.path),C=(x.base||`/docs`).replace(/\/$/,``);S.includes(C)||S.push(C);let w=m(`docs`,x);for(let e of w)S.includes(e)||S.push(e);h(x,`docs`,e,S),_(S);let T=t===`production`,E=T?{...u}:{};return x.security?.enableCSP&&(E[`Content-Security-Policy`]=d(x)),{root:e,mode:t,oxc:{jsx:{development:!T,runtime:`automatic`,importSource:`react`}},optimizeDeps:{include:[`react`,`react-dom`,`react-dom/client`,`react-helmet-async`,`react-router-dom`,`react-fast-compare`,`invariant`,`use-sync-external-store/shim`]},build:{},plugins:[g(),y(),b(),...s({docsDir:`docs`,root:e,turbo:i},x)],resolve:{alias:[{find:`boltdocs/entry`,replacement:v(l.default.resolve(e,`boltdocs-entry.tsx`))},{find:`boltdocs/client`,replacement:v(l.default.resolve(e,`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`},{find:`@`,replacement:v(l.default.resolve(e,`../packages/core/src`))}],dedupe:[`react`,`react-dom`,`react-router-dom`]},ssr:{external:[`react`,`react-dom`,`react-helmet-async`,`react-router-dom`,`@bdocs/ssg`,`jsdom`,...c()],optimizeDeps:{include:[`react`,`react-dom`,`react-fast-compare`,...x.vite?.ssr?.optimizeDeps?.include??[]]},noExternal:[]},server:{watch:{ignored:[`**/.boltdocs/**`,...x.vite?.server?.watch?.ignored??[]]},headers:{...E,...x.vite?.server?.headers},...x.vite?.server},preview:{headers:{...E,...x.vite?.preview?.headers},...x.vite?.preview},...x.vite??{}}}Object.defineProperty(exports,`_`,{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return X}}),Object.defineProperty(exports,`b`,{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return V}}),Object.defineProperty(exports,`d`,{enumerable:!0,get:function(){return j}}),Object.defineProperty(exports,`f`,{enumerable:!0,get:function(){return ce}}),Object.defineProperty(exports,`g`,{enumerable:!0,get:function(){return S}}),Object.defineProperty(exports,`h`,{enumerable:!0,get:function(){return w}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return Z}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return pe}}),Object.defineProperty(exports,`m`,{enumerable:!0,get:function(){return T}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return $}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return q}}),Object.defineProperty(exports,`p`,{enumerable:!0,get:function(){return D}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return me}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return z}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return Q}}),Object.defineProperty(exports,`u`,{enumerable:!0,get:function(){return de}}),Object.defineProperty(exports,`v`,{enumerable:!0,get:function(){return v}}),Object.defineProperty(exports,`x`,{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,`y`,{enumerable:!0,get:function(){return x}});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Boltdocs - https://boltdocs.vercel.app
|
|
3
|
+
* Copyright (c) 2026 Jesus Alcala
|
|
4
|
+
* Licensed under the MIT License.
|
|
5
|
+
*/
|
|
6
|
+
import e from"node:fs";import t from"node:crypto";import{defineHastPlugin as n,defineMdastPlugin as r,mdxToJs as i}from"satteri";import{transformSync as a}from"esbuild";function o(){return r({name:`boltdocs-remark-meta`,code(e,t){e.meta&&t.setProperty(e,`data`,{...e.data||{},hProperties:{...e.data?.hProperties||{},metastring:e.meta}})}})}function s(e){return e.toLowerCase().replace(/<[^>]+>/g,``).replace(/[^\w\s-]/g,``).replace(/\s+/g,`-`).trim()}function c(){return n({name:`boltdocs-rehype-slug`,element:{filter:[`h1`,`h2`,`h3`,`h4`,`h5`,`h6`],visit(e,t){let n=t.textContent(e);n&&t.setProperty(e,`id`,s(n))}}})}function l(e){let t={};if(!e)return t;/lineNumbers|showLineNumbers/.test(e)&&(t.lineNumbers=!0),/wordWrap|word-wrap/.test(e)&&(t.wordWrap=!0);let n=e.match(/title=(["'])(.*?)\1/);return n&&(t.title=n[2]),t}function u(e,t){let n=e?.className??e?.class??[],r=t?.className??t?.class??[];return[...Array.isArray(r)?r:[r],...Array.isArray(n)?n:[n]].filter(Boolean)}function d(){let e=null,t=null;return n({name:`boltdocs-rehype-shiki`,element:{filter:[`pre`],async visit(n,r){e||(e=(await import(`boltdocs/node/mdx/shiki-adapter`)).getShikiAdapter(),t=e.getHighlighter());let i=await t,a=n.children?.[0];if(!a||a.type!==`element`||a.tagName!==`code`)return;let o=(a.properties?.className??a.properties?.class??[]).find(e=>e.startsWith(`language-`)),s=o?o.slice(9):`text`;if(s===`mermaid`)return;let c=l(a.properties?.metastring??a.data?.meta??``),d=e.getOptions(s,c),f=a.children?.[0]?.value??``;try{let e=i.codeToHast(f,d),t=e.type===`root`?e.children[0]:e,r=u(n.properties,t.properties),a={},o=n.properties??{};for(let e of Object.keys(o))e===`class`||e===`className`||(a[e]=o[e]);let l=t.properties??{};for(let[e,t]of Object.entries(l))e===`class`||e===`className`||(a[e]=t);return a.className=r,a[`data-highlighted`]=`true`,a[`data-lang`]=s,c.title&&(a[`data-title`]=c.title),{type:`element`,tagName:`pre`,properties:a,children:t.children}}catch{let e={},t=n.properties??{};for(let n of Object.keys(t))n===`class`||n===`className`||(e[n]=t[n]);return e.className=[...t?.className??t?.class??[],`shiki-fallback`],e[`data-highlighted`]=`false`,e[`data-lang`]=s,c.title&&(e[`data-title`]=c.title),{type:`element`,tagName:`pre`,properties:e,children:n.children}}}}})}function f(e){if(!e)return null;if(typeof e==`object`&&`name`in e&&[`paragraph`,`heading`,`thematicBreak`,`blockquote`,`list`,`listItem`,`html`,`code`,`definition`,`text`,`emphasis`,`strong`,`inlineCode`,`break`,`link`,`image`].some(t=>t in e&&typeof e[t]==`function`))return e;let t;try{t=typeof e==`function`?e():null}catch{t=null}return typeof t==`function`?p(t):typeof e==`function`?p(e):(console.warn(`[satteri] Cannot convert remark plugin "${e?.name??`unknown`}" to Sätteri MDAST.`),null)}function p(e){return r({name:`satteri-remark-adapter`,code(t,n){try{if(!n.parent(t)||n.indexOf(t)===void 0)return;let r={type:`root`,children:[t]},i=e(r);if(i&&typeof i.then==`function`)return;if(r.children[0]!==t){let e=r.children[0];if(e)return e}}catch{}}})}function m(e,t,n,i){if(!e)return null;let a;try{a=typeof e==`function`?e(t):null}catch{return null}return typeof a==`function`?r({name:`satteri-${i}-adapter`,code(e,r){if((e.lang||``)===i)return{type:`mdxJsxFlowElement`,name:n,attributes:[{type:`mdxJsxAttribute`,name:`chart`,value:e.value||``},{type:`mdxJsxAttribute`,name:`config`,value:JSON.stringify(t)}],children:[]}}}):null}function h(e){if(!e)return null;if(typeof e==`object`&&`name`in e&&[`root`,`element`,`text`,`comment`,`doctype`,`script`,`style`,`template`].some(t=>{let n=e[t];return typeof n==`function`||typeof n==`object`&&!!n&&`visit`in n}))return e;let t;try{t=typeof e==`function`?e():e}catch{return null}return typeof t==`function`?g(t):(console.warn(`[satteri] Cannot convert rehype plugin "${(typeof t==`object`&&t?t:null)?.name??`unknown`}" to Sätteri HAST.`),null)}function g(e){return n({name:`satteri-rehype-adapter`,element:{filter:[],async visit(t,n){try{let n={type:`root`,children:[t]},r=e(n);if(r instanceof Promise&&await r,n.children[0]!==t){let e=n.children[0];if(e)return e}}catch{}}}})}function _(e){let t=[],n=[];for(let r of e?.plugins??[]){let e=r;if(e.remarkPlugins)for(let n of e.remarkPlugins)if(Array.isArray(n)){let[r,i]=n;if(e.name===`boltdocs-plugin-mermaid`){let e=m(r,i,`Mermaid`,`mermaid`);e&&t.push(e)}else{let e=f(r);e&&t.push(e)}}else{let e=f(n);e&&t.push(e)}if(e.rehypePlugins)for(let t of e.rehypePlugins)if(Array.isArray(t)){let e=h(t[0]);e&&n.push(e)}else{let e=h(t);e&&n.push(e)}}return{remarkPlugins:t,rehypePlugins:n}}var v=class{mdastPlugins;hastPlugins;cache;cacheReady=!1;fallbackCompiler=null;fallbackPromise=null;constructor(e,t){this.mdastPlugins=e,this.hastPlugins=t}async ensureCache(){return this.cacheReady||=(this.cache=new(await(import(`boltdocs/node/cache`))).TransformCache(`mdx`),!0),this.cache}async getCache(){return this.ensureCache()}async ensureFallback(){return this.fallbackCompiler?this.fallbackCompiler:this.fallbackPromise?this.fallbackPromise:(this.fallbackPromise=this.loadFallback(),this.fallbackCompiler=await this.fallbackPromise,this.fallbackCompiler)}async loadFallback(){try{let e=await import(`@mdx-js/rollup`),[t,n,r]=await Promise.all([import(`remark-gfm`).then(e=>e.default),import(`remark-frontmatter`).then(e=>e.default),import(`rehype-slug`).then(e=>e.default)]);return e.default({jsxRuntime:`automatic`,jsxImportSource:`react`,remarkPlugins:[t,n],rehypePlugins:[r]})}catch{return null}}async satteriCompile(e,n){let r=`${n}:${t.createHash(`md5`).update(e).digest(`hex`)}:${process.env.NODE_ENV===`production`?`prod`:`dev`}:v6-fallback`;try{let e=await(await this.getCache()).getAsync(r);if(e)return e}catch{}try{if(typeof i!=`function`)return null;let t=await i(e,{jsxRuntime:`automatic`,jsxImportSource:`react`,outputFormat:`program`,mdastPlugins:[...this.mdastPlugins],hastPlugins:[...this.hastPlugins],features:{gfm:!0,frontmatter:!0}});if(!t?.code)return null;let n=t.code;if(/<\w+/.test(n))try{let e=a(n,{loader:`jsx`,jsx:`automatic`,jsxImportSource:`react`});e?.code&&(n=e.code)}catch(e){console.error(`[boltdocs-satteri-mdx] esbuild error:`,e)}try{(await this.getCache()).set(r,n)}catch{}return n}catch{return null}}async fallbackCompile(e,t){let n=await this.ensureFallback();if(!n)return null;try{let r=await n.transform(e,t);if(r?.code)return r.code}catch{}return null}async compile(e,t){return await this.satteriCompile(e,t)||this.fallbackCompile(e,t)}async flushCache(){this.cache&&(this.cache.save(),await this.cache.flush())}};function y(e){let[t]=e.split(`?`);return t.endsWith(`.md`)||t.endsWith(`.mdx`)}function b(e){return e.includes(`function _createMdxContent`)||e.includes(`react/jsx-runtime`)||e.includes(`export default function MDXContent`)}function x(t,n){let r=S(),i=r.mdastPlugins??[],a=r.hastPlugins??[],{remarkPlugins:o,rehypePlugins:s}=_(t),c=new v([...i,...o],[...a,...s]);return{name:`vite-plugin-boltdocs-satteri-mdx`,enforce:`pre`,async load(t){if(!y(t))return null;let[r]=t.split(`?`),i;try{i=e.readFileSync(r,`utf-8`)}catch{return null}let a=n?.(),o=i;if(a)try{let e=await a.runChain(`transformSource`,{code:i,filePath:r});e?.code&&(o=e.code)}catch{}return await c.compile(o,r)??o},async transform(e,t){if(!y(t))return null;let r=e;if(!b(r)){let e=await c.compile(r,t.split(`?`)[0]);e&&(r=e)}let i=r,a=n?.();if(a)try{let e=await a.runChain(`transformMdx`,{code:r,filePath:t.split(`?`)[0]});e?.code&&(i=e.code)}catch{}return{code:i,map:null}},async buildEnd(){await c.flushCache()}}}function S(){return{name:`boltdocs-processor-satteri`,version:`0.1.0`,boltdocsVersion:`>=3.0.0`,mdastPlugins:[o()],hastPlugins:[c(),d()]}}export{x as createSatteriMdxPlugin};
|