@ox-content/napi 0.0.1-alpha.0 → 0.3.0-alpha.5
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 +0 -230
- package/index.js +58 -41
- package/package.json +18 -10
- package/index.node +0 -0
package/index.d.ts
CHANGED
|
@@ -1,230 +0,0 @@
|
|
|
1
|
-
/* tslint:disable */
|
|
2
|
-
/* eslint-disable */
|
|
3
|
-
|
|
4
|
-
/* auto-generated by NAPI-RS */
|
|
5
|
-
|
|
6
|
-
/** Parse result containing the AST as JSON. */
|
|
7
|
-
export interface ParseResult {
|
|
8
|
-
/** The AST as a JSON string. */
|
|
9
|
-
ast: string
|
|
10
|
-
/** Parse errors, if any. */
|
|
11
|
-
errors: Array<string>
|
|
12
|
-
}
|
|
13
|
-
/** Render result containing the HTML output. */
|
|
14
|
-
export interface RenderResult {
|
|
15
|
-
/** The rendered HTML. */
|
|
16
|
-
html: string
|
|
17
|
-
/** Render errors, if any. */
|
|
18
|
-
errors: Array<string>
|
|
19
|
-
}
|
|
20
|
-
/** Table of contents entry. */
|
|
21
|
-
export interface TocEntry {
|
|
22
|
-
/** Heading depth (1-6). */
|
|
23
|
-
depth: number
|
|
24
|
-
/** Heading text. */
|
|
25
|
-
text: string
|
|
26
|
-
/** URL-friendly slug. */
|
|
27
|
-
slug: string
|
|
28
|
-
}
|
|
29
|
-
/** Transform result containing HTML, frontmatter, and TOC. */
|
|
30
|
-
export interface TransformResult {
|
|
31
|
-
/** The rendered HTML. */
|
|
32
|
-
html: string
|
|
33
|
-
/** Parsed frontmatter as JSON string. */
|
|
34
|
-
frontmatter: string
|
|
35
|
-
/** Table of contents entries. */
|
|
36
|
-
toc: Array<TocEntry>
|
|
37
|
-
/** Parse/render errors, if any. */
|
|
38
|
-
errors: Array<string>
|
|
39
|
-
}
|
|
40
|
-
/** Transform options for JavaScript. */
|
|
41
|
-
export interface JsTransformOptions {
|
|
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
|
|
60
|
-
}
|
|
61
|
-
/** Parser options for JavaScript. */
|
|
62
|
-
export interface JsParserOptions {
|
|
63
|
-
/** Enable GFM extensions. */
|
|
64
|
-
gfm?: boolean
|
|
65
|
-
/** Enable footnotes. */
|
|
66
|
-
footnotes?: boolean
|
|
67
|
-
/** Enable task lists. */
|
|
68
|
-
taskLists?: boolean
|
|
69
|
-
/** Enable tables. */
|
|
70
|
-
tables?: boolean
|
|
71
|
-
/** Enable strikethrough. */
|
|
72
|
-
strikethrough?: boolean
|
|
73
|
-
/** Enable autolinks. */
|
|
74
|
-
autolinks?: boolean
|
|
75
|
-
}
|
|
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>
|
|
98
|
-
/** OG image configuration for JavaScript. */
|
|
99
|
-
export interface JsOgImageConfig {
|
|
100
|
-
/** Image width in pixels. */
|
|
101
|
-
width?: number
|
|
102
|
-
/** Image height in pixels. */
|
|
103
|
-
height?: number
|
|
104
|
-
/** Background color (hex). */
|
|
105
|
-
backgroundColor?: string
|
|
106
|
-
/** Text color (hex). */
|
|
107
|
-
textColor?: string
|
|
108
|
-
/** Title font size. */
|
|
109
|
-
titleFontSize?: number
|
|
110
|
-
/** Description font size. */
|
|
111
|
-
descriptionFontSize?: number
|
|
112
|
-
}
|
|
113
|
-
/** OG image data for JavaScript. */
|
|
114
|
-
export interface JsOgImageData {
|
|
115
|
-
/** Page title. */
|
|
116
|
-
title: string
|
|
117
|
-
/** Page description. */
|
|
118
|
-
description?: string
|
|
119
|
-
/** Site name. */
|
|
120
|
-
siteName?: string
|
|
121
|
-
/** Author name. */
|
|
122
|
-
author?: string
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Generates an OG image as SVG.
|
|
126
|
-
*
|
|
127
|
-
* This function generates an SVG representation of an OG image
|
|
128
|
-
* that can be used for social media previews.
|
|
129
|
-
*/
|
|
130
|
-
export declare function generateOgImageSvg(data: JsOgImageData, config?: JsOgImageConfig | undefined | null): string
|
|
131
|
-
/** Search document for JavaScript. */
|
|
132
|
-
export interface JsSearchDocument {
|
|
133
|
-
/** Unique document identifier. */
|
|
134
|
-
id: string
|
|
135
|
-
/** Document title. */
|
|
136
|
-
title: string
|
|
137
|
-
/** Document URL. */
|
|
138
|
-
url: string
|
|
139
|
-
/** Document body text. */
|
|
140
|
-
body: string
|
|
141
|
-
/** Document headings. */
|
|
142
|
-
headings: Array<string>
|
|
143
|
-
/** Code snippets. */
|
|
144
|
-
code: Array<string>
|
|
145
|
-
}
|
|
146
|
-
/** Search result for JavaScript. */
|
|
147
|
-
export interface JsSearchResult {
|
|
148
|
-
/** Document ID. */
|
|
149
|
-
id: string
|
|
150
|
-
/** Document title. */
|
|
151
|
-
title: string
|
|
152
|
-
/** Document URL. */
|
|
153
|
-
url: string
|
|
154
|
-
/** Relevance score. */
|
|
155
|
-
score: number
|
|
156
|
-
/** Matched terms. */
|
|
157
|
-
matches: Array<string>
|
|
158
|
-
/** Content snippet. */
|
|
159
|
-
snippet: string
|
|
160
|
-
}
|
|
161
|
-
/** Search options for JavaScript. */
|
|
162
|
-
export interface JsSearchOptions {
|
|
163
|
-
/** Maximum number of results. */
|
|
164
|
-
limit?: number
|
|
165
|
-
/** Enable prefix matching. */
|
|
166
|
-
prefix?: boolean
|
|
167
|
-
/** Enable fuzzy matching. */
|
|
168
|
-
fuzzy?: boolean
|
|
169
|
-
/** Minimum score threshold. */
|
|
170
|
-
threshold?: number
|
|
171
|
-
}
|
|
172
|
-
/**
|
|
173
|
-
* Builds a search index from documents.
|
|
174
|
-
*
|
|
175
|
-
* Takes an array of documents and returns a serialized search index as JSON.
|
|
176
|
-
*/
|
|
177
|
-
export declare function buildSearchIndex(documents: Array<JsSearchDocument>): string
|
|
178
|
-
/**
|
|
179
|
-
* Searches a serialized index.
|
|
180
|
-
*
|
|
181
|
-
* Takes a JSON-serialized index, query string, and options.
|
|
182
|
-
* Returns an array of search results.
|
|
183
|
-
*/
|
|
184
|
-
export declare function searchIndex(indexJson: string, query: string, options?: JsSearchOptions | undefined | null): Array<JsSearchResult>
|
|
185
|
-
/** Navigation item for SSG. */
|
|
186
|
-
export interface JsSsgNavItem {
|
|
187
|
-
/** Display title. */
|
|
188
|
-
title: string
|
|
189
|
-
/** URL path. */
|
|
190
|
-
path: string
|
|
191
|
-
/** Full href. */
|
|
192
|
-
href: string
|
|
193
|
-
}
|
|
194
|
-
/** Navigation group for SSG. */
|
|
195
|
-
export interface JsSsgNavGroup {
|
|
196
|
-
/** Group title. */
|
|
197
|
-
title: string
|
|
198
|
-
/** Navigation items. */
|
|
199
|
-
items: Array<JsSsgNavItem>
|
|
200
|
-
}
|
|
201
|
-
/** Page data for SSG. */
|
|
202
|
-
export interface JsSsgPageData {
|
|
203
|
-
/** Page title. */
|
|
204
|
-
title: string
|
|
205
|
-
/** Page description. */
|
|
206
|
-
description?: string
|
|
207
|
-
/** Page content HTML. */
|
|
208
|
-
content: string
|
|
209
|
-
/** Table of contents entries. */
|
|
210
|
-
toc: Array<TocEntry>
|
|
211
|
-
/** URL path. */
|
|
212
|
-
path: string
|
|
213
|
-
}
|
|
214
|
-
/** SSG configuration. */
|
|
215
|
-
export interface JsSsgConfig {
|
|
216
|
-
/** Site name. */
|
|
217
|
-
siteName: string
|
|
218
|
-
/** Base URL path. */
|
|
219
|
-
base: string
|
|
220
|
-
/** OG image URL. */
|
|
221
|
-
ogImage?: string
|
|
222
|
-
}
|
|
223
|
-
/** Generates SSG HTML page with navigation and search. */
|
|
224
|
-
export declare function generateSsgHtml(pageData: JsSsgPageData, navGroups: Array<JsSsgNavGroup>, config: JsSsgConfig): string
|
|
225
|
-
/**
|
|
226
|
-
* Extracts searchable content from Markdown source.
|
|
227
|
-
*
|
|
228
|
-
* Parses the Markdown and extracts title, body text, headings, and code.
|
|
229
|
-
*/
|
|
230
|
-
export declare function extractSearchContent(source: string, id: string, url: string, options?: JsParserOptions | undefined | null): JsSearchDocument
|
package/index.js
CHANGED
|
@@ -1,61 +1,78 @@
|
|
|
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 development binary first (index.node)
|
|
6
|
-
const localBinary = join(__dirname,
|
|
5
|
+
// 1. Try loading the local development binary first (index.node)
|
|
6
|
+
const localBinary = path.join(__dirname, "index.node")
|
|
7
7
|
if (existsSync(localBinary)) {
|
|
8
|
-
return require(localBinary)
|
|
8
|
+
return require(localBinary)
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
// Try platform-specific binary
|
|
12
|
-
const platform = process.platform
|
|
13
|
-
const arch = process.arch
|
|
11
|
+
// 2. Try platform-specific binary in same directory (CI build artifact)
|
|
12
|
+
const platform = process.platform
|
|
13
|
+
const arch = process.arch
|
|
14
14
|
|
|
15
15
|
const platforms = {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
let key;
|
|
24
|
-
if (platform === 'darwin') {
|
|
25
|
-
key = `darwin-${arch}`;
|
|
26
|
-
} else if (platform === 'linux') {
|
|
27
|
-
key = `linux-${arch}-gnu`;
|
|
28
|
-
} else if (platform === 'win32') {
|
|
29
|
-
key = `win32-${arch}-msvc`;
|
|
16
|
+
"darwin-arm64": "ox-content.darwin-arm64.node",
|
|
17
|
+
"darwin-x64": "ox-content.darwin-x64.node",
|
|
18
|
+
"linux-x64-gnu": "ox-content.linux-x64-gnu.node",
|
|
19
|
+
"linux-arm64-gnu": "ox-content.linux-arm64-gnu.node",
|
|
20
|
+
"win32-x64-msvc": "ox-content.win32-x64-msvc.node",
|
|
30
21
|
}
|
|
31
22
|
|
|
32
|
-
|
|
23
|
+
let key
|
|
24
|
+
if (platform === "darwin") {
|
|
25
|
+
key = `darwin-${arch}`
|
|
26
|
+
} else if (platform === "linux") {
|
|
27
|
+
key = `linux-${arch}-gnu`
|
|
28
|
+
} else if (platform === "win32") {
|
|
29
|
+
key = `win32-${arch}-msvc`
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const binaryName = platforms[key]
|
|
33
33
|
if (binaryName) {
|
|
34
|
-
const binaryPath = join(__dirname, binaryName)
|
|
34
|
+
const binaryPath = path.join(__dirname, binaryName)
|
|
35
35
|
if (existsSync(binaryPath)) {
|
|
36
|
-
return require(binaryPath)
|
|
36
|
+
return require(binaryPath)
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
// 3. Try npm sub-packages (@ox-content/binding-darwin-arm64 etc.)
|
|
41
|
+
const subPackages = {
|
|
42
|
+
"darwin-arm64": "@ox-content/binding-darwin-arm64",
|
|
43
|
+
"darwin-x64": "@ox-content/binding-darwin-x64",
|
|
44
|
+
"linux-x64-gnu": "@ox-content/binding-linux-x64-gnu",
|
|
45
|
+
"linux-arm64-gnu": "@ox-content/binding-linux-arm64-gnu",
|
|
46
|
+
"win32-x64-msvc": "@ox-content/binding-win32-x64-msvc",
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const subPackage = subPackages[key]
|
|
50
|
+
if (subPackage) {
|
|
51
|
+
try {
|
|
52
|
+
return require(subPackage)
|
|
53
|
+
} catch {}
|
|
54
|
+
}
|
|
55
|
+
|
|
40
56
|
throw new Error(
|
|
41
57
|
`@ox-content/napi: No compatible binary found for ${platform}-${arch}. ` +
|
|
42
|
-
|
|
43
|
-
)
|
|
58
|
+
`Please run 'pnpm build' in crates/ox_content_napi.`,
|
|
59
|
+
)
|
|
44
60
|
}
|
|
45
61
|
|
|
46
|
-
const binding = loadBinding()
|
|
62
|
+
const binding = loadBinding()
|
|
47
63
|
|
|
48
64
|
// 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
|
|
65
|
+
module.exports = binding
|
|
66
|
+
module.exports.parse = binding.parse
|
|
67
|
+
module.exports.parseAndRender = binding.parseAndRender
|
|
68
|
+
module.exports.parseAndRenderAsync = binding.parseAndRenderAsync
|
|
69
|
+
module.exports.render = binding.render
|
|
70
|
+
module.exports.transform = binding.transform
|
|
71
|
+
module.exports.transformAsync = binding.transformAsync
|
|
72
|
+
module.exports.version = binding.version
|
|
73
|
+
module.exports.generateOgImageSvg = binding.generateOgImageSvg
|
|
74
|
+
module.exports.buildSearchIndex = binding.buildSearchIndex
|
|
75
|
+
module.exports.searchIndex = binding.searchIndex
|
|
76
|
+
module.exports.extractSearchContent = binding.extractSearchContent
|
|
77
|
+
module.exports.generateSsgHtml = binding.generateSsgHtml
|
|
78
|
+
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.5",
|
|
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",
|
|
@@ -19,12 +19,8 @@
|
|
|
19
19
|
"x86_64-pc-windows-msvc"
|
|
20
20
|
]
|
|
21
21
|
},
|
|
22
|
-
"scripts": {
|
|
23
|
-
"build": "napi build --release",
|
|
24
|
-
"build:debug": "napi build"
|
|
25
|
-
},
|
|
26
22
|
"devDependencies": {
|
|
27
|
-
"@napi-rs/cli": "^
|
|
23
|
+
"@napi-rs/cli": "^3.0.0"
|
|
28
24
|
},
|
|
29
25
|
"repository": {
|
|
30
26
|
"type": "git",
|
|
@@ -32,6 +28,7 @@
|
|
|
32
28
|
"directory": "crates/ox_content_napi"
|
|
33
29
|
},
|
|
34
30
|
"publishConfig": {
|
|
31
|
+
"provenance": true,
|
|
35
32
|
"access": "public"
|
|
36
33
|
},
|
|
37
34
|
"keywords": [
|
|
@@ -42,5 +39,16 @@
|
|
|
42
39
|
"oxc"
|
|
43
40
|
],
|
|
44
41
|
"author": "ubugeeei",
|
|
45
|
-
"license": "MIT"
|
|
46
|
-
|
|
42
|
+
"license": "MIT",
|
|
43
|
+
"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"
|
|
53
|
+
}
|
|
54
|
+
}
|
package/index.node
DELETED
|
Binary file
|