@ox-content/napi 0.0.1-alpha.0 → 0.3.0-alpha.11
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/index.d.ts +356 -138
- package/index.js +64 -41
- package/package.json +14 -6
- package/index.node +0 -0
package/index.d.ts
CHANGED
|
@@ -1,100 +1,88 @@
|
|
|
1
|
-
/*
|
|
1
|
+
/* auto-generated by NAPI-RS */
|
|
2
2
|
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* Builds a search index from documents.
|
|
5
|
+
*
|
|
6
|
+
* Takes an array of documents and returns a serialized search index as JSON.
|
|
7
|
+
*/
|
|
8
|
+
export declare function buildSearchIndex(documents: Array<JsSearchDocument>): string
|
|
3
9
|
|
|
4
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Extracts searchable content from Markdown source.
|
|
12
|
+
*
|
|
13
|
+
* Parses the Markdown and extracts title, body text, headings, and code.
|
|
14
|
+
*/
|
|
15
|
+
export declare function extractSearchContent(source: string, id: string, url: string, options?: JsParserOptions | undefined | null): JsSearchDocument
|
|
5
16
|
|
|
6
|
-
/**
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Generates an OG image as SVG.
|
|
19
|
+
*
|
|
20
|
+
* This function generates an SVG representation of an OG image
|
|
21
|
+
* that can be used for social media previews.
|
|
22
|
+
*/
|
|
23
|
+
export declare function generateOgImageSvg(data: JsOgImageData, config?: JsOgImageConfig | undefined | null): string
|
|
24
|
+
|
|
25
|
+
/** Generates SSG HTML page with navigation and search. */
|
|
26
|
+
export declare function generateSsgHtml(pageData: JsSsgPageData, navGroups: Array<JsSsgNavGroup>, config: JsSsgConfig): string
|
|
27
|
+
|
|
28
|
+
/** Entry page configuration. */
|
|
29
|
+
export interface JsEntryPageConfig {
|
|
30
|
+
/** Hero section. */
|
|
31
|
+
hero?: JsHeroConfig
|
|
32
|
+
/** Feature cards. */
|
|
33
|
+
features?: Array<JsFeatureConfig>
|
|
12
34
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
35
|
+
|
|
36
|
+
/** Feature card for entry page. */
|
|
37
|
+
export interface JsFeatureConfig {
|
|
38
|
+
/** Icon - supports: "mdi:icon-name" (Iconify), image URL, or emoji. */
|
|
39
|
+
icon?: string
|
|
40
|
+
/** Feature title. */
|
|
41
|
+
title: string
|
|
42
|
+
/** Feature description. */
|
|
43
|
+
details?: string
|
|
44
|
+
/** Optional link. */
|
|
45
|
+
link?: string
|
|
46
|
+
/** Link text. */
|
|
47
|
+
linkText?: string
|
|
19
48
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
49
|
+
|
|
50
|
+
/** Hero action for entry page. */
|
|
51
|
+
export interface JsHeroAction {
|
|
52
|
+
/** Button theme: "brand" or "alt". */
|
|
53
|
+
theme?: string
|
|
54
|
+
/** Button text. */
|
|
25
55
|
text: string
|
|
26
|
-
/** URL
|
|
27
|
-
|
|
56
|
+
/** Link URL. */
|
|
57
|
+
link: string
|
|
28
58
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
|
|
42
|
-
/** Enable GFM extensions. */
|
|
43
|
-
gfm?: boolean
|
|
44
|
-
/** Enable footnotes. */
|
|
45
|
-
footnotes?: boolean
|
|
46
|
-
/** Enable task lists. */
|
|
47
|
-
taskLists?: boolean
|
|
48
|
-
/** Enable tables. */
|
|
49
|
-
tables?: boolean
|
|
50
|
-
/** Enable strikethrough. */
|
|
51
|
-
strikethrough?: boolean
|
|
52
|
-
/** Enable autolinks. */
|
|
53
|
-
autolinks?: boolean
|
|
54
|
-
/** Maximum TOC depth (1-6). */
|
|
55
|
-
tocMaxDepth?: number
|
|
56
|
-
/** Convert `.md` links to `.html` links for SSG output. */
|
|
57
|
-
convertMdLinks?: boolean
|
|
58
|
-
/** Base URL for absolute link conversion (e.g., "/" or "/docs/"). */
|
|
59
|
-
baseUrl?: string
|
|
59
|
+
|
|
60
|
+
/** Hero section configuration for entry page. */
|
|
61
|
+
export interface JsHeroConfig {
|
|
62
|
+
/** Main title (large, gradient text). */
|
|
63
|
+
name?: string
|
|
64
|
+
/** Secondary text. */
|
|
65
|
+
text?: string
|
|
66
|
+
/** Tagline. */
|
|
67
|
+
tagline?: string
|
|
68
|
+
/** Hero image. */
|
|
69
|
+
image?: JsHeroImage
|
|
70
|
+
/** Action buttons. */
|
|
71
|
+
actions?: Array<JsHeroAction>
|
|
60
72
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
strikethrough?: boolean
|
|
73
|
-
/** Enable autolinks. */
|
|
74
|
-
autolinks?: boolean
|
|
73
|
+
|
|
74
|
+
/** Hero image for entry page. */
|
|
75
|
+
export interface JsHeroImage {
|
|
76
|
+
/** Image source URL. */
|
|
77
|
+
src: string
|
|
78
|
+
/** Alt text. */
|
|
79
|
+
alt?: string
|
|
80
|
+
/** Image width. */
|
|
81
|
+
width?: number
|
|
82
|
+
/** Image height. */
|
|
83
|
+
height?: number
|
|
75
84
|
}
|
|
76
|
-
|
|
77
|
-
* Parses Markdown source into an AST.
|
|
78
|
-
*
|
|
79
|
-
* Returns the AST as a JSON string for zero-copy transfer to JavaScript.
|
|
80
|
-
*/
|
|
81
|
-
export declare function parse(source: string, options?: JsParserOptions | undefined | null): ParseResult
|
|
82
|
-
/** Parses Markdown and renders to HTML. */
|
|
83
|
-
export declare function parseAndRender(source: string, options?: JsParserOptions | undefined | null): RenderResult
|
|
84
|
-
/** Renders an AST (provided as JSON) to HTML. */
|
|
85
|
-
export declare function render(astJson: string): RenderResult
|
|
86
|
-
/** Returns the version of ox_content_napi. */
|
|
87
|
-
export declare function version(): string
|
|
88
|
-
/**
|
|
89
|
-
* Transforms Markdown source into HTML, frontmatter, and TOC.
|
|
90
|
-
*
|
|
91
|
-
* This is the main entry point for unplugin-ox-content.
|
|
92
|
-
*/
|
|
93
|
-
export declare function transform(source: string, options?: JsTransformOptions | undefined | null): TransformResult
|
|
94
|
-
/** Parses Markdown and renders to HTML asynchronously (runs on worker thread). */
|
|
95
|
-
export declare function parseAndRenderAsync(source: string, options?: JsParserOptions | undefined | null): Promise<unknown>
|
|
96
|
-
/** Transforms Markdown source asynchronously (runs on worker thread). */
|
|
97
|
-
export declare function transformAsync(source: string, options?: JsTransformOptions | undefined | null): Promise<unknown>
|
|
85
|
+
|
|
98
86
|
/** OG image configuration for JavaScript. */
|
|
99
87
|
export interface JsOgImageConfig {
|
|
100
88
|
/** Image width in pixels. */
|
|
@@ -110,6 +98,7 @@ export interface JsOgImageConfig {
|
|
|
110
98
|
/** Description font size. */
|
|
111
99
|
descriptionFontSize?: number
|
|
112
100
|
}
|
|
101
|
+
|
|
113
102
|
/** OG image data for JavaScript. */
|
|
114
103
|
export interface JsOgImageData {
|
|
115
104
|
/** Page title. */
|
|
@@ -121,13 +110,23 @@ export interface JsOgImageData {
|
|
|
121
110
|
/** Author name. */
|
|
122
111
|
author?: string
|
|
123
112
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
*/
|
|
130
|
-
|
|
113
|
+
|
|
114
|
+
/** Parser options for JavaScript. */
|
|
115
|
+
export interface JsParserOptions {
|
|
116
|
+
/** Enable GFM extensions. */
|
|
117
|
+
gfm?: boolean
|
|
118
|
+
/** Enable footnotes. */
|
|
119
|
+
footnotes?: boolean
|
|
120
|
+
/** Enable task lists. */
|
|
121
|
+
taskLists?: boolean
|
|
122
|
+
/** Enable tables. */
|
|
123
|
+
tables?: boolean
|
|
124
|
+
/** Enable strikethrough. */
|
|
125
|
+
strikethrough?: boolean
|
|
126
|
+
/** Enable autolinks. */
|
|
127
|
+
autolinks?: boolean
|
|
128
|
+
}
|
|
129
|
+
|
|
131
130
|
/** Search document for JavaScript. */
|
|
132
131
|
export interface JsSearchDocument {
|
|
133
132
|
/** Unique document identifier. */
|
|
@@ -143,6 +142,19 @@ export interface JsSearchDocument {
|
|
|
143
142
|
/** Code snippets. */
|
|
144
143
|
code: Array<string>
|
|
145
144
|
}
|
|
145
|
+
|
|
146
|
+
/** Search options for JavaScript. */
|
|
147
|
+
export interface JsSearchOptions {
|
|
148
|
+
/** Maximum number of results. */
|
|
149
|
+
limit?: number
|
|
150
|
+
/** Enable prefix matching. */
|
|
151
|
+
prefix?: boolean
|
|
152
|
+
/** Enable fuzzy matching. */
|
|
153
|
+
fuzzy?: boolean
|
|
154
|
+
/** Minimum score threshold. */
|
|
155
|
+
threshold?: number
|
|
156
|
+
}
|
|
157
|
+
|
|
146
158
|
/** Search result for JavaScript. */
|
|
147
159
|
export interface JsSearchResult {
|
|
148
160
|
/** Document ID. */
|
|
@@ -158,30 +170,37 @@ export interface JsSearchResult {
|
|
|
158
170
|
/** Content snippet. */
|
|
159
171
|
snippet: string
|
|
160
172
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
threshold?: number
|
|
173
|
+
|
|
174
|
+
/** Social links for JavaScript. */
|
|
175
|
+
export interface JsSocialLinks {
|
|
176
|
+
/** GitHub URL. */
|
|
177
|
+
github?: string
|
|
178
|
+
/** Twitter/X URL. */
|
|
179
|
+
twitter?: string
|
|
180
|
+
/** Discord URL. */
|
|
181
|
+
discord?: string
|
|
171
182
|
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
183
|
+
|
|
184
|
+
/** SSG configuration. */
|
|
185
|
+
export interface JsSsgConfig {
|
|
186
|
+
/** Site name. */
|
|
187
|
+
siteName: string
|
|
188
|
+
/** Base URL path. */
|
|
189
|
+
base: string
|
|
190
|
+
/** OG image URL. */
|
|
191
|
+
ogImage?: string
|
|
192
|
+
/** Theme configuration. */
|
|
193
|
+
theme?: JsThemeConfig
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/** Navigation group for SSG. */
|
|
197
|
+
export interface JsSsgNavGroup {
|
|
198
|
+
/** Group title. */
|
|
199
|
+
title: string
|
|
200
|
+
/** Navigation items. */
|
|
201
|
+
items: Array<JsSsgNavItem>
|
|
202
|
+
}
|
|
203
|
+
|
|
185
204
|
/** Navigation item for SSG. */
|
|
186
205
|
export interface JsSsgNavItem {
|
|
187
206
|
/** Display title. */
|
|
@@ -191,13 +210,7 @@ export interface JsSsgNavItem {
|
|
|
191
210
|
/** Full href. */
|
|
192
211
|
href: string
|
|
193
212
|
}
|
|
194
|
-
|
|
195
|
-
export interface JsSsgNavGroup {
|
|
196
|
-
/** Group title. */
|
|
197
|
-
title: string
|
|
198
|
-
/** Navigation items. */
|
|
199
|
-
items: Array<JsSsgNavItem>
|
|
200
|
-
}
|
|
213
|
+
|
|
201
214
|
/** Page data for SSG. */
|
|
202
215
|
export interface JsSsgPageData {
|
|
203
216
|
/** Page title. */
|
|
@@ -210,21 +223,226 @@ export interface JsSsgPageData {
|
|
|
210
223
|
toc: Array<TocEntry>
|
|
211
224
|
/** URL path. */
|
|
212
225
|
path: string
|
|
226
|
+
/** Entry page configuration (if layout: entry). */
|
|
227
|
+
entryPage?: JsEntryPageConfig
|
|
213
228
|
}
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
229
|
+
|
|
230
|
+
/** Theme colors for JavaScript. */
|
|
231
|
+
export interface JsThemeColors {
|
|
232
|
+
/** Primary accent color. */
|
|
233
|
+
primary?: string
|
|
234
|
+
/** Primary color on hover. */
|
|
235
|
+
primaryHover?: string
|
|
236
|
+
/** Background color. */
|
|
237
|
+
background?: string
|
|
238
|
+
/** Alternative background color. */
|
|
239
|
+
backgroundAlt?: string
|
|
240
|
+
/** Main text color. */
|
|
241
|
+
text?: string
|
|
242
|
+
/** Muted text color. */
|
|
243
|
+
textMuted?: string
|
|
244
|
+
/** Border color. */
|
|
245
|
+
border?: string
|
|
246
|
+
/** Code block background color. */
|
|
247
|
+
codeBackground?: string
|
|
248
|
+
/** Code block text color. */
|
|
249
|
+
codeText?: string
|
|
222
250
|
}
|
|
223
|
-
|
|
224
|
-
|
|
251
|
+
|
|
252
|
+
/** Theme configuration for JavaScript. */
|
|
253
|
+
export interface JsThemeConfig {
|
|
254
|
+
/** Light mode colors. */
|
|
255
|
+
colors?: JsThemeColors
|
|
256
|
+
/** Dark mode colors. */
|
|
257
|
+
darkColors?: JsThemeColors
|
|
258
|
+
/** Font configuration. */
|
|
259
|
+
fonts?: JsThemeFonts
|
|
260
|
+
/** Layout configuration. */
|
|
261
|
+
layout?: JsThemeLayout
|
|
262
|
+
/** Header configuration. */
|
|
263
|
+
header?: JsThemeHeader
|
|
264
|
+
/** Footer configuration. */
|
|
265
|
+
footer?: JsThemeFooter
|
|
266
|
+
/** Social links configuration. */
|
|
267
|
+
socialLinks?: JsSocialLinks
|
|
268
|
+
/** Embedded HTML content at specific positions. */
|
|
269
|
+
embed?: JsThemeEmbed
|
|
270
|
+
/** Additional custom CSS. */
|
|
271
|
+
css?: string
|
|
272
|
+
/** Additional custom JavaScript. */
|
|
273
|
+
js?: string
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/** Embedded HTML content for specific positions. */
|
|
277
|
+
export interface JsThemeEmbed {
|
|
278
|
+
/** Content to embed into `<head>`. */
|
|
279
|
+
head?: string
|
|
280
|
+
/** Content before header. */
|
|
281
|
+
headerBefore?: string
|
|
282
|
+
/** Content after header. */
|
|
283
|
+
headerAfter?: string
|
|
284
|
+
/** Content before sidebar navigation. */
|
|
285
|
+
sidebarBefore?: string
|
|
286
|
+
/** Content after sidebar navigation. */
|
|
287
|
+
sidebarAfter?: string
|
|
288
|
+
/** Content before main content. */
|
|
289
|
+
contentBefore?: string
|
|
290
|
+
/** Content after main content. */
|
|
291
|
+
contentAfter?: string
|
|
292
|
+
/** Content before footer. */
|
|
293
|
+
footerBefore?: string
|
|
294
|
+
/** Custom footer content. */
|
|
295
|
+
footer?: string
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/** Theme fonts for JavaScript. */
|
|
299
|
+
export interface JsThemeFonts {
|
|
300
|
+
/** Sans-serif font stack. */
|
|
301
|
+
sans?: string
|
|
302
|
+
/** Monospace font stack. */
|
|
303
|
+
mono?: string
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
/** Theme footer for JavaScript. */
|
|
307
|
+
export interface JsThemeFooter {
|
|
308
|
+
/** Footer message (supports HTML). */
|
|
309
|
+
message?: string
|
|
310
|
+
/** Copyright text (supports HTML). */
|
|
311
|
+
copyright?: string
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/** Theme header for JavaScript. */
|
|
315
|
+
export interface JsThemeHeader {
|
|
316
|
+
/** Logo image URL. */
|
|
317
|
+
logo?: string
|
|
318
|
+
/** Logo width in pixels. */
|
|
319
|
+
logoWidth?: number
|
|
320
|
+
/** Logo height in pixels. */
|
|
321
|
+
logoHeight?: number
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
/** Theme layout for JavaScript. */
|
|
325
|
+
export interface JsThemeLayout {
|
|
326
|
+
/** Sidebar width (CSS value). */
|
|
327
|
+
sidebarWidth?: string
|
|
328
|
+
/** Header height (CSS value). */
|
|
329
|
+
headerHeight?: string
|
|
330
|
+
/** Maximum content width (CSS value). */
|
|
331
|
+
maxContentWidth?: string
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
/** Transform options for JavaScript. */
|
|
335
|
+
export interface JsTransformOptions {
|
|
336
|
+
/** Enable GFM extensions. */
|
|
337
|
+
gfm?: boolean
|
|
338
|
+
/** Enable footnotes. */
|
|
339
|
+
footnotes?: boolean
|
|
340
|
+
/** Enable task lists. */
|
|
341
|
+
taskLists?: boolean
|
|
342
|
+
/** Enable tables. */
|
|
343
|
+
tables?: boolean
|
|
344
|
+
/** Enable strikethrough. */
|
|
345
|
+
strikethrough?: boolean
|
|
346
|
+
/** Enable autolinks. */
|
|
347
|
+
autolinks?: boolean
|
|
348
|
+
/** Maximum TOC depth (1-6). */
|
|
349
|
+
tocMaxDepth?: number
|
|
350
|
+
/** Convert `.md` links to `.html` links for SSG output. */
|
|
351
|
+
convertMdLinks?: boolean
|
|
352
|
+
/** Base URL for absolute link conversion (e.g., "/" or "/docs/"). */
|
|
353
|
+
baseUrl?: string
|
|
354
|
+
/** Source file path for relative link resolution. */
|
|
355
|
+
sourcePath?: string
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
/** Mermaid transform result. */
|
|
359
|
+
export interface MermaidTransformResult {
|
|
360
|
+
/** The transformed HTML with mermaid code blocks replaced by rendered SVGs. */
|
|
361
|
+
html: string
|
|
362
|
+
/** Non-fatal errors encountered during rendering (per-diagram). */
|
|
363
|
+
errors: Array<string>
|
|
364
|
+
}
|
|
365
|
+
|
|
225
366
|
/**
|
|
226
|
-
*
|
|
367
|
+
* Parses Markdown source into an AST.
|
|
227
368
|
*
|
|
228
|
-
*
|
|
369
|
+
* Returns the AST as a JSON string for zero-copy transfer to JavaScript.
|
|
229
370
|
*/
|
|
230
|
-
export declare function
|
|
371
|
+
export declare function parse(source: string, options?: JsParserOptions | undefined | null): ParseResult
|
|
372
|
+
|
|
373
|
+
/** Parses Markdown and renders to HTML. */
|
|
374
|
+
export declare function parseAndRender(source: string, options?: JsParserOptions | undefined | null): RenderResult
|
|
375
|
+
|
|
376
|
+
/** Parses Markdown and renders to HTML asynchronously (runs on worker thread). */
|
|
377
|
+
export declare function parseAndRenderAsync(source: string, options?: JsParserOptions | undefined | null): Promise<unknown>
|
|
378
|
+
|
|
379
|
+
/** Parse result containing the AST as JSON. */
|
|
380
|
+
export interface ParseResult {
|
|
381
|
+
/** The AST as a JSON string. */
|
|
382
|
+
ast: string
|
|
383
|
+
/** Parse errors, if any. */
|
|
384
|
+
errors: Array<string>
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
/** Renders an AST (provided as JSON) to HTML. */
|
|
388
|
+
export declare function render(astJson: string): RenderResult
|
|
389
|
+
|
|
390
|
+
/** Render result containing the HTML output. */
|
|
391
|
+
export interface RenderResult {
|
|
392
|
+
/** The rendered HTML. */
|
|
393
|
+
html: string
|
|
394
|
+
/** Render errors, if any. */
|
|
395
|
+
errors: Array<string>
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
/**
|
|
399
|
+
* Searches a serialized index.
|
|
400
|
+
*
|
|
401
|
+
* Takes a JSON-serialized index, query string, and options.
|
|
402
|
+
* Returns an array of search results.
|
|
403
|
+
*/
|
|
404
|
+
export declare function searchIndex(indexJson: string, query: string, options?: JsSearchOptions | undefined | null): Array<JsSearchResult>
|
|
405
|
+
|
|
406
|
+
/** Table of contents entry. */
|
|
407
|
+
export interface TocEntry {
|
|
408
|
+
/** Heading depth (1-6). */
|
|
409
|
+
depth: number
|
|
410
|
+
/** Heading text. */
|
|
411
|
+
text: string
|
|
412
|
+
/** URL-friendly slug. */
|
|
413
|
+
slug: string
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
/**
|
|
417
|
+
* Transforms Markdown source into HTML, frontmatter, and TOC.
|
|
418
|
+
*
|
|
419
|
+
* This is the main entry point for unplugin-ox-content.
|
|
420
|
+
*/
|
|
421
|
+
export declare function transform(source: string, options?: JsTransformOptions | undefined | null): TransformResult
|
|
422
|
+
|
|
423
|
+
/** Transforms Markdown source asynchronously (runs on worker thread). */
|
|
424
|
+
export declare function transformAsync(source: string, options?: JsTransformOptions | undefined | null): Promise<unknown>
|
|
425
|
+
|
|
426
|
+
/**
|
|
427
|
+
* Transforms mermaid code blocks in HTML to rendered SVG diagrams.
|
|
428
|
+
*
|
|
429
|
+
* Extracts `<pre><code class="language-mermaid">...</code></pre>` blocks,
|
|
430
|
+
* renders each in parallel using the mmdc CLI, and replaces them with
|
|
431
|
+
* `<div class="ox-mermaid">...</div>`.
|
|
432
|
+
*/
|
|
433
|
+
export declare function transformMermaid(html: string, mmdcPath: string): MermaidTransformResult
|
|
434
|
+
|
|
435
|
+
/** Transform result containing HTML, frontmatter, and TOC. */
|
|
436
|
+
export interface TransformResult {
|
|
437
|
+
/** The rendered HTML. */
|
|
438
|
+
html: string
|
|
439
|
+
/** Parsed frontmatter as JSON string. */
|
|
440
|
+
frontmatter: string
|
|
441
|
+
/** Table of contents entries. */
|
|
442
|
+
toc: Array<TocEntry>
|
|
443
|
+
/** Parse/render errors, if any. */
|
|
444
|
+
errors: Array<string>
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
/** Returns the version of ox_content_napi. */
|
|
448
|
+
export declare function version(): string
|
package/index.js
CHANGED
|
@@ -1,61 +1,84 @@
|
|
|
1
|
-
const { existsSync } = require(
|
|
2
|
-
const
|
|
1
|
+
const { existsSync } = require("fs")
|
|
2
|
+
const path = require("path")
|
|
3
3
|
|
|
4
4
|
function loadBinding() {
|
|
5
|
-
// Try loading the local
|
|
6
|
-
const
|
|
5
|
+
// 1. Try loading the local binary (napi build output)
|
|
6
|
+
const napiOutput = path.join(__dirname, "ox-content.node")
|
|
7
|
+
if (existsSync(napiOutput)) {
|
|
8
|
+
return require(napiOutput)
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// 1b. Legacy: index.node (napi-rs v2)
|
|
12
|
+
const localBinary = path.join(__dirname, "index.node")
|
|
7
13
|
if (existsSync(localBinary)) {
|
|
8
|
-
return require(localBinary)
|
|
14
|
+
return require(localBinary)
|
|
9
15
|
}
|
|
10
16
|
|
|
11
|
-
// Try platform-specific binary
|
|
12
|
-
const platform = process.platform
|
|
13
|
-
const arch = process.arch
|
|
17
|
+
// 2. Try platform-specific binary in same directory (CI build artifact)
|
|
18
|
+
const platform = process.platform
|
|
19
|
+
const arch = process.arch
|
|
14
20
|
|
|
15
21
|
const platforms = {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
let key
|
|
24
|
-
if (platform ===
|
|
25
|
-
key = `darwin-${arch}
|
|
26
|
-
} else if (platform ===
|
|
27
|
-
key = `linux-${arch}-gnu
|
|
28
|
-
} else if (platform ===
|
|
29
|
-
key = `win32-${arch}-msvc
|
|
22
|
+
"darwin-arm64": "ox-content.darwin-arm64.node",
|
|
23
|
+
"darwin-x64": "ox-content.darwin-x64.node",
|
|
24
|
+
"linux-x64-gnu": "ox-content.linux-x64-gnu.node",
|
|
25
|
+
"linux-arm64-gnu": "ox-content.linux-arm64-gnu.node",
|
|
26
|
+
"win32-x64-msvc": "ox-content.win32-x64-msvc.node",
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
let key
|
|
30
|
+
if (platform === "darwin") {
|
|
31
|
+
key = `darwin-${arch}`
|
|
32
|
+
} else if (platform === "linux") {
|
|
33
|
+
key = `linux-${arch}-gnu`
|
|
34
|
+
} else if (platform === "win32") {
|
|
35
|
+
key = `win32-${arch}-msvc`
|
|
30
36
|
}
|
|
31
37
|
|
|
32
|
-
const binaryName = platforms[key]
|
|
38
|
+
const binaryName = platforms[key]
|
|
33
39
|
if (binaryName) {
|
|
34
|
-
const binaryPath = join(__dirname, binaryName)
|
|
40
|
+
const binaryPath = path.join(__dirname, binaryName)
|
|
35
41
|
if (existsSync(binaryPath)) {
|
|
36
|
-
return require(binaryPath)
|
|
42
|
+
return require(binaryPath)
|
|
37
43
|
}
|
|
38
44
|
}
|
|
39
45
|
|
|
46
|
+
// 3. Try npm sub-packages (@ox-content/binding-darwin-arm64 etc.)
|
|
47
|
+
const subPackages = {
|
|
48
|
+
"darwin-arm64": "@ox-content/binding-darwin-arm64",
|
|
49
|
+
"darwin-x64": "@ox-content/binding-darwin-x64",
|
|
50
|
+
"linux-x64-gnu": "@ox-content/binding-linux-x64-gnu",
|
|
51
|
+
"linux-arm64-gnu": "@ox-content/binding-linux-arm64-gnu",
|
|
52
|
+
"win32-x64-msvc": "@ox-content/binding-win32-x64-msvc",
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const subPackage = subPackages[key]
|
|
56
|
+
if (subPackage) {
|
|
57
|
+
try {
|
|
58
|
+
return require(subPackage)
|
|
59
|
+
} catch {}
|
|
60
|
+
}
|
|
61
|
+
|
|
40
62
|
throw new Error(
|
|
41
63
|
`@ox-content/napi: No compatible binary found for ${platform}-${arch}. ` +
|
|
42
|
-
|
|
43
|
-
)
|
|
64
|
+
`Please run 'pnpm build' in crates/ox_content_napi.`,
|
|
65
|
+
)
|
|
44
66
|
}
|
|
45
67
|
|
|
46
|
-
const binding = loadBinding()
|
|
68
|
+
const binding = loadBinding()
|
|
47
69
|
|
|
48
70
|
// Export individual functions for ESM compatibility
|
|
49
|
-
module.exports = binding
|
|
50
|
-
module.exports.parse = binding.parse
|
|
51
|
-
module.exports.parseAndRender = binding.parseAndRender
|
|
52
|
-
module.exports.parseAndRenderAsync = binding.parseAndRenderAsync
|
|
53
|
-
module.exports.render = binding.render
|
|
54
|
-
module.exports.transform = binding.transform
|
|
55
|
-
module.exports.transformAsync = binding.transformAsync
|
|
56
|
-
module.exports.version = binding.version
|
|
57
|
-
module.exports.generateOgImageSvg = binding.generateOgImageSvg
|
|
58
|
-
module.exports.buildSearchIndex = binding.buildSearchIndex
|
|
59
|
-
module.exports.searchIndex = binding.searchIndex
|
|
60
|
-
module.exports.extractSearchContent = binding.extractSearchContent
|
|
61
|
-
module.exports.generateSsgHtml = binding.generateSsgHtml
|
|
71
|
+
module.exports = binding
|
|
72
|
+
module.exports.parse = binding.parse
|
|
73
|
+
module.exports.parseAndRender = binding.parseAndRender
|
|
74
|
+
module.exports.parseAndRenderAsync = binding.parseAndRenderAsync
|
|
75
|
+
module.exports.render = binding.render
|
|
76
|
+
module.exports.transform = binding.transform
|
|
77
|
+
module.exports.transformAsync = binding.transformAsync
|
|
78
|
+
module.exports.version = binding.version
|
|
79
|
+
module.exports.generateOgImageSvg = binding.generateOgImageSvg
|
|
80
|
+
module.exports.buildSearchIndex = binding.buildSearchIndex
|
|
81
|
+
module.exports.searchIndex = binding.searchIndex
|
|
82
|
+
module.exports.extractSearchContent = binding.extractSearchContent
|
|
83
|
+
module.exports.generateSsgHtml = binding.generateSsgHtml
|
|
84
|
+
module.exports.transformMermaid = binding.transformMermaid
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ox-content/napi",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.3.0-alpha.11",
|
|
4
4
|
"description": "Node.js bindings for Ox Content - High-performance Markdown parser",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
7
7
|
"files": [
|
|
8
8
|
"index.js",
|
|
9
|
-
"index.d.ts"
|
|
10
|
-
"*.node"
|
|
9
|
+
"index.d.ts"
|
|
11
10
|
],
|
|
12
11
|
"napi": {
|
|
13
12
|
"binaryName": "ox-content",
|
|
13
|
+
"packageName": "@ox-content/binding",
|
|
14
14
|
"targets": [
|
|
15
15
|
"x86_64-apple-darwin",
|
|
16
16
|
"aarch64-apple-darwin",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"build:debug": "napi build"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@napi-rs/cli": "^
|
|
27
|
+
"@napi-rs/cli": "^3.0.0"
|
|
28
28
|
},
|
|
29
29
|
"repository": {
|
|
30
30
|
"type": "git",
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
"directory": "crates/ox_content_napi"
|
|
33
33
|
},
|
|
34
34
|
"publishConfig": {
|
|
35
|
+
"provenance": true,
|
|
35
36
|
"access": "public"
|
|
36
37
|
},
|
|
37
38
|
"keywords": [
|
|
@@ -42,5 +43,12 @@
|
|
|
42
43
|
"oxc"
|
|
43
44
|
],
|
|
44
45
|
"author": "ubugeeei",
|
|
45
|
-
"license": "MIT"
|
|
46
|
-
|
|
46
|
+
"license": "MIT",
|
|
47
|
+
"optionalDependencies": {
|
|
48
|
+
"@ox-content/binding-darwin-x64": "0.3.0-alpha.11",
|
|
49
|
+
"@ox-content/binding-darwin-arm64": "0.3.0-alpha.11",
|
|
50
|
+
"@ox-content/binding-linux-x64-gnu": "0.3.0-alpha.11",
|
|
51
|
+
"@ox-content/binding-linux-arm64-gnu": "0.3.0-alpha.11",
|
|
52
|
+
"@ox-content/binding-win32-x64-msvc": "0.3.0-alpha.11"
|
|
53
|
+
}
|
|
54
|
+
}
|
package/index.node
DELETED
|
Binary file
|