@jongleberry/vurst-markdown 0.0.1
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 +44 -0
- package/index.js +28 -0
- package/package.json +24 -0
package/index.d.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
|
|
3
|
+
export interface Chunk {
|
|
4
|
+
level: number
|
|
5
|
+
header?: string
|
|
6
|
+
headers: Array<string | undefined | null>
|
|
7
|
+
breadcrumb: string
|
|
8
|
+
text: string
|
|
9
|
+
length: number
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface ChunkOptions {
|
|
13
|
+
minLength?: number
|
|
14
|
+
maxLength?: number
|
|
15
|
+
phase?: number
|
|
16
|
+
title?: string
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface NapiMarkdownRenderOptions {
|
|
20
|
+
allowHtml?: boolean
|
|
21
|
+
nofollowLinks?: boolean
|
|
22
|
+
proxyImages?: boolean
|
|
23
|
+
imageProxyUrlPrefix?: string
|
|
24
|
+
imageProxySigningKeys?: Array<string>
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface MarkdownUrls {
|
|
28
|
+
linkUrls: Array<string>
|
|
29
|
+
imageUrls: Array<string>
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export declare function chunk(text: Buffer, options?: ChunkOptions): Promise<Array<Chunk>>
|
|
33
|
+
|
|
34
|
+
export declare function renderMarkdownToHtml(
|
|
35
|
+
text: Buffer,
|
|
36
|
+
options?: NapiMarkdownRenderOptions,
|
|
37
|
+
): Promise<Buffer>
|
|
38
|
+
|
|
39
|
+
export declare function renderMarkdownToHtmlBatch(
|
|
40
|
+
inputs: Array<Buffer>,
|
|
41
|
+
options?: NapiMarkdownRenderOptions,
|
|
42
|
+
): Promise<Array<Buffer>>
|
|
43
|
+
|
|
44
|
+
export declare function extractMarkdownUrls(text: Buffer): Promise<MarkdownUrls>
|
package/index.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
// Platform dispatcher for @jongleberry/vurst-markdown.
|
|
4
|
+
|
|
5
|
+
const { platform, arch } = process
|
|
6
|
+
|
|
7
|
+
function loadBinding() {
|
|
8
|
+
switch (`${platform}-${arch}`) {
|
|
9
|
+
case 'darwin-arm64':
|
|
10
|
+
return require('./vurst-markdown.darwin-arm64.node')
|
|
11
|
+
case 'linux-x64':
|
|
12
|
+
return require('./vurst-markdown.linux-x64-gnu.node')
|
|
13
|
+
case 'linux-arm64':
|
|
14
|
+
return require('./vurst-markdown.linux-arm64-gnu.node')
|
|
15
|
+
default:
|
|
16
|
+
throw new Error(
|
|
17
|
+
`Unsupported platform: ${platform}-${arch}. ` +
|
|
18
|
+
`@jongleberry/vurst-markdown supports darwin-arm64, linux-x64 (glibc), and linux-arm64 (glibc).`,
|
|
19
|
+
)
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const binding = loadBinding()
|
|
24
|
+
|
|
25
|
+
module.exports.chunk = binding.chunk
|
|
26
|
+
module.exports.renderMarkdownToHtml = binding.renderMarkdownToHtml
|
|
27
|
+
module.exports.renderMarkdownToHtmlBatch = binding.renderMarkdownToHtmlBatch
|
|
28
|
+
module.exports.extractMarkdownUrls = binding.extractMarkdownUrls
|
package/package.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@jongleberry/vurst-markdown",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Rust + N-API: Markdown chunking and rendering.",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"types": "index.d.ts",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"engines": { "node": ">= 18" },
|
|
9
|
+
"repository": { "type": "git", "url": "git+https://github.com/jonathanong/vurst.git" },
|
|
10
|
+
"keywords": ["rust", "napi", "markdown", "chunking", "rag", "rendering"],
|
|
11
|
+
"files": ["index.js", "index.d.ts", "README.md", "*.node"],
|
|
12
|
+
"napi": {
|
|
13
|
+
"binaryName": "vurst-markdown",
|
|
14
|
+
"targets": ["aarch64-apple-darwin", "aarch64-unknown-linux-gnu", "x86_64-unknown-linux-gnu"]
|
|
15
|
+
},
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "napi build --platform --release",
|
|
18
|
+
"build:debug": "napi build --platform",
|
|
19
|
+
"test": "node --test __test__/*.test.mjs",
|
|
20
|
+
"prepublishOnly": "napi prepublish -t npm"
|
|
21
|
+
},
|
|
22
|
+
"publishConfig": { "access": "public", "provenance": true },
|
|
23
|
+
"devDependencies": { "@napi-rs/cli": "^3.6.2", "@types/node": "^24" }
|
|
24
|
+
}
|