@ox-content/napi 1.0.0-alpha.0 → 2.0.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.
- package/index.d.ts +73 -0
- package/index.js +42 -41
- package/package.json +33 -33
package/index.d.ts
CHANGED
|
@@ -15,6 +15,9 @@ export declare function buildSearchIndex(documents: Array<JsSearchDocument>): st
|
|
|
15
15
|
*/
|
|
16
16
|
export declare function checkI18n(dictDir: string, usedKeys: Array<string>): I18NCheckResult
|
|
17
17
|
|
|
18
|
+
/** Extracts documented declarations from a JavaScript/TypeScript file using Oxc. */
|
|
19
|
+
export declare function extractFileDocs(filePath: string, includePrivate?: boolean | undefined | null): Array<JsSourceDocItem>
|
|
20
|
+
|
|
18
21
|
/**
|
|
19
22
|
* Extracts searchable content from Markdown source.
|
|
20
23
|
*
|
|
@@ -126,6 +129,8 @@ export interface JsHeroConfig {
|
|
|
126
129
|
text?: string
|
|
127
130
|
/** Tagline. */
|
|
128
131
|
tagline?: string
|
|
132
|
+
/** Optional notice shown in the hero. */
|
|
133
|
+
notice?: JsHeroNotice
|
|
129
134
|
/** Hero image. */
|
|
130
135
|
image?: JsHeroImage
|
|
131
136
|
/** Action buttons. */
|
|
@@ -136,6 +141,10 @@ export interface JsHeroConfig {
|
|
|
136
141
|
export interface JsHeroImage {
|
|
137
142
|
/** Image source URL. */
|
|
138
143
|
src: string
|
|
144
|
+
/** Light mode image source URL. */
|
|
145
|
+
lightSrc?: string
|
|
146
|
+
/** Dark mode image source URL. */
|
|
147
|
+
darkSrc?: string
|
|
139
148
|
/** Alt text. */
|
|
140
149
|
alt?: string
|
|
141
150
|
/** Image width. */
|
|
@@ -144,6 +153,14 @@ export interface JsHeroImage {
|
|
|
144
153
|
height?: number
|
|
145
154
|
}
|
|
146
155
|
|
|
156
|
+
/** Hero notice for entry page. */
|
|
157
|
+
export interface JsHeroNotice {
|
|
158
|
+
/** Notice title. */
|
|
159
|
+
title?: string
|
|
160
|
+
/** Notice paragraphs. */
|
|
161
|
+
body?: Array<string>
|
|
162
|
+
}
|
|
163
|
+
|
|
147
164
|
/** Locale information for the locale switcher. */
|
|
148
165
|
export interface JsLocaleInfo {
|
|
149
166
|
/** BCP 47 locale tag. */
|
|
@@ -252,6 +269,37 @@ export interface JsSocialLinks {
|
|
|
252
269
|
discord?: string
|
|
253
270
|
}
|
|
254
271
|
|
|
272
|
+
/** Source documentation item extracted from a JS/TS file. */
|
|
273
|
+
export interface JsSourceDocItem {
|
|
274
|
+
name: string
|
|
275
|
+
kind: string
|
|
276
|
+
doc?: string
|
|
277
|
+
jsdoc?: string
|
|
278
|
+
sourcePath: string
|
|
279
|
+
line: number
|
|
280
|
+
endLine: number
|
|
281
|
+
exported: boolean
|
|
282
|
+
signature?: string
|
|
283
|
+
params: Array<JsSourceDocParam>
|
|
284
|
+
returnType?: string
|
|
285
|
+
tags: Array<JsSourceDocTag>
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/** Parameter documentation extracted from source code. */
|
|
289
|
+
export interface JsSourceDocParam {
|
|
290
|
+
name: string
|
|
291
|
+
typeAnnotation?: string
|
|
292
|
+
optional: boolean
|
|
293
|
+
defaultValue?: string
|
|
294
|
+
description?: string
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
/** Raw JSDoc tag extracted from source code. */
|
|
298
|
+
export interface JsSourceDocTag {
|
|
299
|
+
tag: string
|
|
300
|
+
value: string
|
|
301
|
+
}
|
|
302
|
+
|
|
255
303
|
/** SSG configuration. */
|
|
256
304
|
export interface JsSsgConfig {
|
|
257
305
|
/** Site name. */
|
|
@@ -332,6 +380,8 @@ export interface JsThemeConfig {
|
|
|
332
380
|
darkColors?: JsThemeColors
|
|
333
381
|
/** Font configuration. */
|
|
334
382
|
fonts?: JsThemeFonts
|
|
383
|
+
/** Entry page configuration. */
|
|
384
|
+
entryPage?: JsThemeEntryPage
|
|
335
385
|
/** Layout configuration. */
|
|
336
386
|
layout?: JsThemeLayout
|
|
337
387
|
/** Header configuration. */
|
|
@@ -370,6 +420,12 @@ export interface JsThemeEmbed {
|
|
|
370
420
|
footer?: string
|
|
371
421
|
}
|
|
372
422
|
|
|
423
|
+
/** Entry page theme configuration for JavaScript. */
|
|
424
|
+
export interface JsThemeEntryPage {
|
|
425
|
+
/** Landing page presentation mode. */
|
|
426
|
+
mode?: string
|
|
427
|
+
}
|
|
428
|
+
|
|
373
429
|
/** Theme fonts for JavaScript. */
|
|
374
430
|
export interface JsThemeFonts {
|
|
375
431
|
/** Sans-serif font stack. */
|
|
@@ -390,6 +446,12 @@ export interface JsThemeFooter {
|
|
|
390
446
|
export interface JsThemeHeader {
|
|
391
447
|
/** Logo image URL. */
|
|
392
448
|
logo?: string
|
|
449
|
+
/** Light mode logo image URL. */
|
|
450
|
+
logoLight?: string
|
|
451
|
+
/** Dark mode logo image URL. */
|
|
452
|
+
logoDark?: string
|
|
453
|
+
/** Whether to render the site name text next to the logo. */
|
|
454
|
+
showSiteNameText?: boolean
|
|
393
455
|
/** Logo width in pixels. */
|
|
394
456
|
logoWidth?: number
|
|
395
457
|
/** Logo height in pixels. */
|
|
@@ -428,6 +490,14 @@ export interface JsTransformOptions {
|
|
|
428
490
|
baseUrl?: string
|
|
429
491
|
/** Source file path for relative link resolution. */
|
|
430
492
|
sourcePath?: string
|
|
493
|
+
/** Enable line annotations for code blocks using fence meta. */
|
|
494
|
+
codeAnnotations?: boolean
|
|
495
|
+
/** Fence meta key used to read code annotations. */
|
|
496
|
+
codeAnnotationMetaKey?: string
|
|
497
|
+
/** Code annotation syntax mode. */
|
|
498
|
+
codeAnnotationSyntax?: string
|
|
499
|
+
/** Enable line numbers for all code blocks by default. */
|
|
500
|
+
codeAnnotationDefaultLineNumbers?: boolean
|
|
431
501
|
}
|
|
432
502
|
|
|
433
503
|
/**
|
|
@@ -446,6 +516,9 @@ export declare function loadDictionaries(dir: string): I18NLoadResult
|
|
|
446
516
|
*/
|
|
447
517
|
export declare function loadDictionariesFlat(dir: string): Record<string, Record<string, string>>
|
|
448
518
|
|
|
519
|
+
/** Restores code block metadata after JavaScript-side syntax highlighting. */
|
|
520
|
+
export declare function mergeHighlightedCodeBlocks(originalHtml: string, highlightedHtml: string): string
|
|
521
|
+
|
|
449
522
|
/** Mermaid transform result. */
|
|
450
523
|
export interface MermaidTransformResult {
|
|
451
524
|
/** The transformed HTML with mermaid code blocks replaced by rendered SVGs. */
|
package/index.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
const { existsSync } = require("fs")
|
|
2
|
-
const path = require("path")
|
|
1
|
+
const { existsSync } = require("fs");
|
|
2
|
+
const path = require("path");
|
|
3
3
|
|
|
4
4
|
function loadBinding() {
|
|
5
5
|
// 1. Try loading the local binary (napi build output)
|
|
6
|
-
const napiOutput = path.join(__dirname, "ox-content.node")
|
|
6
|
+
const napiOutput = path.join(__dirname, "ox-content.node");
|
|
7
7
|
if (existsSync(napiOutput)) {
|
|
8
|
-
return require(napiOutput)
|
|
8
|
+
return require(napiOutput);
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
// 1b. Legacy: index.node (napi-rs v2)
|
|
12
|
-
const localBinary = path.join(__dirname, "index.node")
|
|
12
|
+
const localBinary = path.join(__dirname, "index.node");
|
|
13
13
|
if (existsSync(localBinary)) {
|
|
14
|
-
return require(localBinary)
|
|
14
|
+
return require(localBinary);
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
// 2. Try platform-specific binary in same directory (CI build artifact)
|
|
18
|
-
const platform = process.platform
|
|
19
|
-
const arch = process.arch
|
|
18
|
+
const platform = process.platform;
|
|
19
|
+
const arch = process.arch;
|
|
20
20
|
|
|
21
21
|
const platforms = {
|
|
22
22
|
"darwin-arm64": "ox-content.darwin-arm64.node",
|
|
@@ -24,22 +24,22 @@ function loadBinding() {
|
|
|
24
24
|
"linux-x64-gnu": "ox-content.linux-x64-gnu.node",
|
|
25
25
|
"linux-arm64-gnu": "ox-content.linux-arm64-gnu.node",
|
|
26
26
|
"win32-x64-msvc": "ox-content.win32-x64-msvc.node",
|
|
27
|
-
}
|
|
27
|
+
};
|
|
28
28
|
|
|
29
|
-
let key
|
|
29
|
+
let key;
|
|
30
30
|
if (platform === "darwin") {
|
|
31
|
-
key = `darwin-${arch}
|
|
31
|
+
key = `darwin-${arch}`;
|
|
32
32
|
} else if (platform === "linux") {
|
|
33
|
-
key = `linux-${arch}-gnu
|
|
33
|
+
key = `linux-${arch}-gnu`;
|
|
34
34
|
} else if (platform === "win32") {
|
|
35
|
-
key = `win32-${arch}-msvc
|
|
35
|
+
key = `win32-${arch}-msvc`;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
const binaryName = platforms[key]
|
|
38
|
+
const binaryName = platforms[key];
|
|
39
39
|
if (binaryName) {
|
|
40
|
-
const binaryPath = path.join(__dirname, binaryName)
|
|
40
|
+
const binaryPath = path.join(__dirname, binaryName);
|
|
41
41
|
if (existsSync(binaryPath)) {
|
|
42
|
-
return require(binaryPath)
|
|
42
|
+
return require(binaryPath);
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
|
|
@@ -50,40 +50,41 @@ function loadBinding() {
|
|
|
50
50
|
"linux-x64-gnu": "@ox-content/binding-linux-x64-gnu",
|
|
51
51
|
"linux-arm64-gnu": "@ox-content/binding-linux-arm64-gnu",
|
|
52
52
|
"win32-x64-msvc": "@ox-content/binding-win32-x64-msvc",
|
|
53
|
-
}
|
|
53
|
+
};
|
|
54
54
|
|
|
55
|
-
const subPackage = subPackages[key]
|
|
55
|
+
const subPackage = subPackages[key];
|
|
56
56
|
if (subPackage) {
|
|
57
57
|
try {
|
|
58
|
-
return require(subPackage)
|
|
58
|
+
return require(subPackage);
|
|
59
59
|
} catch {}
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
throw new Error(
|
|
63
63
|
`@ox-content/napi: No compatible binary found for ${platform}-${arch}. ` +
|
|
64
|
-
`
|
|
65
|
-
)
|
|
64
|
+
`If you're working from the repository, run 'nix develop -c vp run build:napi' from the repository root.`,
|
|
65
|
+
);
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
const binding = loadBinding()
|
|
68
|
+
const binding = loadBinding();
|
|
69
69
|
|
|
70
70
|
// Export individual functions for ESM compatibility
|
|
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.
|
|
80
|
-
module.exports.
|
|
81
|
-
module.exports.
|
|
82
|
-
module.exports.
|
|
83
|
-
module.exports.
|
|
84
|
-
module.exports.
|
|
85
|
-
module.exports.
|
|
86
|
-
module.exports.
|
|
87
|
-
module.exports.
|
|
88
|
-
module.exports.
|
|
89
|
-
module.exports.
|
|
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.extractFileDocs = binding.extractFileDocs;
|
|
80
|
+
module.exports.generateOgImageSvg = binding.generateOgImageSvg;
|
|
81
|
+
module.exports.buildSearchIndex = binding.buildSearchIndex;
|
|
82
|
+
module.exports.searchIndex = binding.searchIndex;
|
|
83
|
+
module.exports.extractSearchContent = binding.extractSearchContent;
|
|
84
|
+
module.exports.generateSsgHtml = binding.generateSsgHtml;
|
|
85
|
+
module.exports.transformMermaid = binding.transformMermaid;
|
|
86
|
+
module.exports.loadDictionaries = binding.loadDictionaries;
|
|
87
|
+
module.exports.loadDictionariesFlat = binding.loadDictionariesFlat;
|
|
88
|
+
module.exports.validateMf2 = binding.validateMf2;
|
|
89
|
+
module.exports.checkI18n = binding.checkI18n;
|
|
90
|
+
module.exports.extractTranslationKeys = binding.extractTranslationKeys;
|
package/package.json
CHANGED
|
@@ -1,13 +1,38 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ox-content/napi",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Node.js bindings for Ox Content - High-performance Markdown parser",
|
|
5
|
-
"
|
|
6
|
-
|
|
5
|
+
"keywords": [
|
|
6
|
+
"markdown",
|
|
7
|
+
"napi",
|
|
8
|
+
"oxc",
|
|
9
|
+
"parser",
|
|
10
|
+
"rust"
|
|
11
|
+
],
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"author": "ubugeeei",
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "https://github.com/ubugeeei/ox-content.git",
|
|
17
|
+
"directory": "crates/ox_content_napi"
|
|
18
|
+
},
|
|
7
19
|
"files": [
|
|
8
20
|
"index.js",
|
|
9
21
|
"index.d.ts"
|
|
10
22
|
],
|
|
23
|
+
"main": "index.js",
|
|
24
|
+
"types": "index.d.ts",
|
|
25
|
+
"publishConfig": {
|
|
26
|
+
"access": "public",
|
|
27
|
+
"provenance": true
|
|
28
|
+
},
|
|
29
|
+
"scripts": {
|
|
30
|
+
"build": "napi build --release",
|
|
31
|
+
"build:debug": "napi build"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@napi-rs/cli": "^3.5.1"
|
|
35
|
+
},
|
|
11
36
|
"napi": {
|
|
12
37
|
"binaryName": "ox-content",
|
|
13
38
|
"packageName": "@ox-content/binding",
|
|
@@ -19,36 +44,11 @@
|
|
|
19
44
|
"x86_64-pc-windows-msvc"
|
|
20
45
|
]
|
|
21
46
|
},
|
|
22
|
-
"scripts": {
|
|
23
|
-
"build": "napi build --release",
|
|
24
|
-
"build:debug": "napi build"
|
|
25
|
-
},
|
|
26
|
-
"devDependencies": {
|
|
27
|
-
"@napi-rs/cli": "^3.5.1"
|
|
28
|
-
},
|
|
29
|
-
"repository": {
|
|
30
|
-
"type": "git",
|
|
31
|
-
"url": "https://github.com/ubugeeei/ox-content.git",
|
|
32
|
-
"directory": "crates/ox_content_napi"
|
|
33
|
-
},
|
|
34
|
-
"publishConfig": {
|
|
35
|
-
"provenance": true,
|
|
36
|
-
"access": "public"
|
|
37
|
-
},
|
|
38
|
-
"keywords": [
|
|
39
|
-
"markdown",
|
|
40
|
-
"parser",
|
|
41
|
-
"napi",
|
|
42
|
-
"rust",
|
|
43
|
-
"oxc"
|
|
44
|
-
],
|
|
45
|
-
"author": "ubugeeei",
|
|
46
|
-
"license": "MIT",
|
|
47
47
|
"optionalDependencies": {
|
|
48
|
-
"@ox-content/binding-darwin-x64": "
|
|
49
|
-
"@ox-content/binding-darwin-arm64": "
|
|
50
|
-
"@ox-content/binding-linux-x64-gnu": "
|
|
51
|
-
"@ox-content/binding-linux-arm64-gnu": "
|
|
52
|
-
"@ox-content/binding-win32-x64-msvc": "
|
|
48
|
+
"@ox-content/binding-darwin-x64": "2.0.0",
|
|
49
|
+
"@ox-content/binding-darwin-arm64": "2.0.0",
|
|
50
|
+
"@ox-content/binding-linux-x64-gnu": "2.0.0",
|
|
51
|
+
"@ox-content/binding-linux-arm64-gnu": "2.0.0",
|
|
52
|
+
"@ox-content/binding-win32-x64-msvc": "2.0.0"
|
|
53
53
|
}
|
|
54
54
|
}
|