@ox-content/napi 0.3.0-alpha.5 → 0.4.0

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.
Files changed (3) hide show
  1. package/index.d.ts +448 -0
  2. package/index.js +7 -1
  3. package/package.json +11 -11
package/index.d.ts CHANGED
@@ -0,0 +1,448 @@
1
+ /* auto-generated by NAPI-RS */
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
9
+
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
16
+
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>
34
+ }
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
48
+ }
49
+
50
+ /** Hero action for entry page. */
51
+ export interface JsHeroAction {
52
+ /** Button theme: "brand" or "alt". */
53
+ theme?: string
54
+ /** Button text. */
55
+ text: string
56
+ /** Link URL. */
57
+ link: string
58
+ }
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>
72
+ }
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
84
+ }
85
+
86
+ /** OG image configuration for JavaScript. */
87
+ export interface JsOgImageConfig {
88
+ /** Image width in pixels. */
89
+ width?: number
90
+ /** Image height in pixels. */
91
+ height?: number
92
+ /** Background color (hex). */
93
+ backgroundColor?: string
94
+ /** Text color (hex). */
95
+ textColor?: string
96
+ /** Title font size. */
97
+ titleFontSize?: number
98
+ /** Description font size. */
99
+ descriptionFontSize?: number
100
+ }
101
+
102
+ /** OG image data for JavaScript. */
103
+ export interface JsOgImageData {
104
+ /** Page title. */
105
+ title: string
106
+ /** Page description. */
107
+ description?: string
108
+ /** Site name. */
109
+ siteName?: string
110
+ /** Author name. */
111
+ author?: string
112
+ }
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
+
130
+ /** Search document for JavaScript. */
131
+ export interface JsSearchDocument {
132
+ /** Unique document identifier. */
133
+ id: string
134
+ /** Document title. */
135
+ title: string
136
+ /** Document URL. */
137
+ url: string
138
+ /** Document body text. */
139
+ body: string
140
+ /** Document headings. */
141
+ headings: Array<string>
142
+ /** Code snippets. */
143
+ code: Array<string>
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
+
158
+ /** Search result for JavaScript. */
159
+ export interface JsSearchResult {
160
+ /** Document ID. */
161
+ id: string
162
+ /** Document title. */
163
+ title: string
164
+ /** Document URL. */
165
+ url: string
166
+ /** Relevance score. */
167
+ score: number
168
+ /** Matched terms. */
169
+ matches: Array<string>
170
+ /** Content snippet. */
171
+ snippet: string
172
+ }
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
182
+ }
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
+
204
+ /** Navigation item for SSG. */
205
+ export interface JsSsgNavItem {
206
+ /** Display title. */
207
+ title: string
208
+ /** URL path. */
209
+ path: string
210
+ /** Full href. */
211
+ href: string
212
+ }
213
+
214
+ /** Page data for SSG. */
215
+ export interface JsSsgPageData {
216
+ /** Page title. */
217
+ title: string
218
+ /** Page description. */
219
+ description?: string
220
+ /** Page content HTML. */
221
+ content: string
222
+ /** Table of contents entries. */
223
+ toc: Array<TocEntry>
224
+ /** URL path. */
225
+ path: string
226
+ /** Entry page configuration (if layout: entry). */
227
+ entryPage?: JsEntryPageConfig
228
+ }
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
250
+ }
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
+
366
+ /**
367
+ * Parses Markdown source into an AST.
368
+ *
369
+ * Returns the AST as a JSON string for zero-copy transfer to JavaScript.
370
+ */
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 @ox-content/unplugin.
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
@@ -2,7 +2,13 @@ const { existsSync } = require("fs")
2
2
  const path = require("path")
3
3
 
4
4
  function loadBinding() {
5
- // 1. Try loading the local development binary first (index.node)
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)
6
12
  const localBinary = path.join(__dirname, "index.node")
7
13
  if (existsSync(localBinary)) {
8
14
  return require(localBinary)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ox-content/napi",
3
- "version": "0.3.0-alpha.5",
3
+ "version": "0.4.0",
4
4
  "description": "Node.js bindings for Ox Content - High-performance Markdown parser",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -19,8 +19,12 @@
19
19
  "x86_64-pc-windows-msvc"
20
20
  ]
21
21
  },
22
+ "scripts": {
23
+ "build": "napi build --release",
24
+ "build:debug": "napi build"
25
+ },
22
26
  "devDependencies": {
23
- "@napi-rs/cli": "^3.0.0"
27
+ "@napi-rs/cli": "^3.5.1"
24
28
  },
25
29
  "repository": {
26
30
  "type": "git",
@@ -41,14 +45,10 @@
41
45
  "author": "ubugeeei",
42
46
  "license": "MIT",
43
47
  "optionalDependencies": {
44
- "@ox-content/binding-darwin-x64": "0.3.0-alpha.5",
45
- "@ox-content/binding-darwin-arm64": "0.3.0-alpha.5",
46
- "@ox-content/binding-linux-x64-gnu": "0.3.0-alpha.5",
47
- "@ox-content/binding-linux-arm64-gnu": "0.3.0-alpha.5",
48
- "@ox-content/binding-win32-x64-msvc": "0.3.0-alpha.5"
49
- },
50
- "scripts": {
51
- "build": "napi build --release",
52
- "build:debug": "napi build"
48
+ "@ox-content/binding-darwin-x64": "0.4.0",
49
+ "@ox-content/binding-darwin-arm64": "0.4.0",
50
+ "@ox-content/binding-linux-x64-gnu": "0.4.0",
51
+ "@ox-content/binding-linux-arm64-gnu": "0.4.0",
52
+ "@ox-content/binding-win32-x64-msvc": "0.4.0"
53
53
  }
54
54
  }