@jongleberry/vurst-html 0.0.4 → 0.2.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 +37 -42
- package/index.js +586 -27
- package/package.json +4 -4
- package/vurst-html.darwin-arm64.node +0 -0
- package/vurst-html.linux-arm64-gnu.node +0 -0
- package/vurst-html.linux-x64-gnu.node +0 -0
package/index.d.ts
CHANGED
|
@@ -1,24 +1,9 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
+
/* auto-generated by NAPI-RS */
|
|
3
|
+
/// <reference types="node" />
|
|
4
|
+
/* eslint-disable */
|
|
2
5
|
|
|
3
|
-
export
|
|
4
|
-
proxyImages?: boolean
|
|
5
|
-
imageProxyUrlPrefix?: string
|
|
6
|
-
imageProxySigningKeys?: Array<string>
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export interface SanitizeRssHtmlResult {
|
|
10
|
-
html: Buffer
|
|
11
|
-
firstImageSrc?: string
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export interface ExtractDomRemovalsOptions {
|
|
15
|
-
boilerplatePatterns?: Array<string>
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export interface ExtractDomRemovalsResult {
|
|
19
|
-
cssSelectorsToRemove: Array<string>
|
|
20
|
-
htmlToRemove: Array<string>
|
|
21
|
-
}
|
|
6
|
+
export declare function applyDomRemovalsToHtml(html: Buffer, removals: ExtractDomRemovalsResult): Promise<Buffer>
|
|
22
7
|
|
|
23
8
|
export interface CrawlerHtmlToMarkdownOptions {
|
|
24
9
|
cssSelectorsToRemove?: Array<string>
|
|
@@ -31,38 +16,48 @@ export interface CrawlerHtmlToMarkdownOptions {
|
|
|
31
16
|
|
|
32
17
|
export interface CrawlerHtmlToMarkdownResult {
|
|
33
18
|
title?: string
|
|
34
|
-
meta: Record<string,
|
|
35
|
-
links: Record<string,
|
|
19
|
+
meta: Record<string, any>
|
|
20
|
+
links: Record<string, any>
|
|
36
21
|
content: string
|
|
37
22
|
canonicalUrl?: string
|
|
38
23
|
lang?: string
|
|
39
24
|
}
|
|
40
25
|
|
|
41
|
-
export declare function
|
|
42
|
-
html: Buffer,
|
|
43
|
-
options?: NapiSanitizeRssHtmlOptions,
|
|
44
|
-
): Promise<SanitizeRssHtmlResult>
|
|
26
|
+
export declare function extractDomRemovals(htmlPages: Array<Buffer>, options?: ExtractDomRemovalsOptions | undefined | null): Promise<ExtractDomRemovalsResult>
|
|
45
27
|
|
|
46
|
-
export
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
28
|
+
export interface ExtractDomRemovalsOptions {
|
|
29
|
+
boilerplatePatterns?: Array<string>
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface ExtractDomRemovalsResult {
|
|
33
|
+
cssSelectorsToRemove: Array<string>
|
|
34
|
+
htmlToRemove: Array<string>
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export declare function getContentFromHtml(htmlBuffer: Buffer, options: CrawlerHtmlToMarkdownOptions): Promise<CrawlerHtmlToMarkdownResult>
|
|
50
38
|
|
|
51
39
|
export declare function htmlToEmbeddingText(html: Buffer): Promise<string>
|
|
52
40
|
|
|
53
|
-
export
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
)
|
|
41
|
+
export interface NapiSanitizeRssHtmlOptions {
|
|
42
|
+
/** When `true`, rewrite external `<img src>` URLs through the configured proxy prefix. */
|
|
43
|
+
proxyImages?: boolean
|
|
44
|
+
/** URL path prefix prepended to proxied image URLs (default `/proxy/`). */
|
|
45
|
+
imageProxyUrlPrefix?: string
|
|
46
|
+
/** Hex-encoded HMAC-SHA256 signing keys (newest first). Empty = dev mode (no sig). */
|
|
47
|
+
imageProxySigningKeys?: Array<string>
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface NapiSanitizeRssHtmlResult {
|
|
51
|
+
/** Sanitized HTML safe for rendering. */
|
|
52
|
+
html: Buffer
|
|
53
|
+
/** Raw `src` of the first external `<img>` found before proxying; `undefined` when none. */
|
|
54
|
+
firstImageSrc?: string
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export type SanitizeRssHtmlResult = NapiSanitizeRssHtmlResult
|
|
57
58
|
|
|
58
|
-
export declare function
|
|
59
|
-
html: Buffer,
|
|
60
|
-
removals: ExtractDomRemovalsResult,
|
|
61
|
-
): Promise<Buffer>
|
|
59
|
+
export declare function sanitizePromptInjection(content: Buffer, isTitle?: boolean | undefined | null): Promise<Buffer>
|
|
62
60
|
|
|
63
|
-
export declare function
|
|
64
|
-
htmlBuffer: Buffer,
|
|
65
|
-
options: CrawlerHtmlToMarkdownOptions,
|
|
66
|
-
): Promise<CrawlerHtmlToMarkdownResult>
|
|
61
|
+
export declare function sanitizeRssHtml(html: Buffer, options?: NapiSanitizeRssHtmlOptions | undefined | null): Promise<SanitizeRssHtmlResult>
|
|
67
62
|
|
|
68
|
-
export declare function
|
|
63
|
+
export declare function sanitizeRssHtmlBatch(inputs: Array<Buffer>, options?: NapiSanitizeRssHtmlOptions | undefined | null): Promise<Array<SanitizeRssHtmlResult>>
|
package/index.js
CHANGED
|
@@ -1,31 +1,590 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
1
|
+
// prettier-ignore
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
// @ts-nocheck
|
|
4
|
+
/* auto-generated by NAPI-RS */
|
|
5
|
+
|
|
6
|
+
const { readFileSync } = require('node:fs')
|
|
7
|
+
let nativeBinding = null
|
|
8
|
+
const loadErrors = []
|
|
9
|
+
|
|
10
|
+
const isMusl = () => {
|
|
11
|
+
let musl = false
|
|
12
|
+
if (process.platform === 'linux') {
|
|
13
|
+
musl = isMuslFromFilesystem()
|
|
14
|
+
if (musl === null) {
|
|
15
|
+
musl = isMuslFromReport()
|
|
16
|
+
}
|
|
17
|
+
if (musl === null) {
|
|
18
|
+
musl = isMuslFromChildProcess()
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return musl
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const isFileMusl = (f) => f.includes('libc.musl-') || f.includes('ld-musl-')
|
|
25
|
+
|
|
26
|
+
const isMuslFromFilesystem = () => {
|
|
27
|
+
try {
|
|
28
|
+
return readFileSync('/usr/bin/ldd', 'utf-8').includes('musl')
|
|
29
|
+
} catch {
|
|
30
|
+
return null
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const isMuslFromReport = () => {
|
|
35
|
+
let report = null
|
|
36
|
+
if (typeof process.report?.getReport === 'function') {
|
|
37
|
+
const originalExcludeNetwork = process.report.excludeNetwork
|
|
38
|
+
try {
|
|
39
|
+
process.report.excludeNetwork = true
|
|
40
|
+
report = process.report.getReport()
|
|
41
|
+
} finally {
|
|
42
|
+
process.report.excludeNetwork = originalExcludeNetwork
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (!report) {
|
|
46
|
+
return null
|
|
47
|
+
}
|
|
48
|
+
if (report.header && report.header.glibcVersionRuntime) {
|
|
49
|
+
return false
|
|
50
|
+
}
|
|
51
|
+
if (Array.isArray(report.sharedObjects)) {
|
|
52
|
+
if (report.sharedObjects.some(isFileMusl)) {
|
|
53
|
+
return true
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return false
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const isMuslFromChildProcess = () => {
|
|
60
|
+
try {
|
|
61
|
+
return require('child_process').execSync('ldd --version', { encoding: 'utf8' }).includes('musl')
|
|
62
|
+
} catch (e) {
|
|
63
|
+
// If we reach this case, we don't know if the system is musl or not, so is better to just fallback to false
|
|
64
|
+
return false
|
|
20
65
|
}
|
|
21
66
|
}
|
|
22
67
|
|
|
23
|
-
|
|
68
|
+
function requireNative() {
|
|
69
|
+
if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) {
|
|
70
|
+
try {
|
|
71
|
+
return require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH);
|
|
72
|
+
} catch (err) {
|
|
73
|
+
loadErrors.push(err)
|
|
74
|
+
}
|
|
75
|
+
} else if (process.platform === 'android') {
|
|
76
|
+
if (process.arch === 'arm64') {
|
|
77
|
+
try {
|
|
78
|
+
return require('./vurst-html.android-arm64.node')
|
|
79
|
+
} catch (e) {
|
|
80
|
+
loadErrors.push(e)
|
|
81
|
+
}
|
|
82
|
+
try {
|
|
83
|
+
const binding = require('@jongleberry/vurst-html-android-arm64')
|
|
84
|
+
const bindingPackageVersion = require('@jongleberry/vurst-html-android-arm64/package.json').version
|
|
85
|
+
if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
86
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
87
|
+
}
|
|
88
|
+
return binding
|
|
89
|
+
} catch (e) {
|
|
90
|
+
loadErrors.push(e)
|
|
91
|
+
}
|
|
92
|
+
} else if (process.arch === 'arm') {
|
|
93
|
+
try {
|
|
94
|
+
return require('./vurst-html.android-arm-eabi.node')
|
|
95
|
+
} catch (e) {
|
|
96
|
+
loadErrors.push(e)
|
|
97
|
+
}
|
|
98
|
+
try {
|
|
99
|
+
const binding = require('@jongleberry/vurst-html-android-arm-eabi')
|
|
100
|
+
const bindingPackageVersion = require('@jongleberry/vurst-html-android-arm-eabi/package.json').version
|
|
101
|
+
if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
102
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
103
|
+
}
|
|
104
|
+
return binding
|
|
105
|
+
} catch (e) {
|
|
106
|
+
loadErrors.push(e)
|
|
107
|
+
}
|
|
108
|
+
} else {
|
|
109
|
+
loadErrors.push(new Error(`Unsupported architecture on Android ${process.arch}`))
|
|
110
|
+
}
|
|
111
|
+
} else if (process.platform === 'win32') {
|
|
112
|
+
if (process.arch === 'x64') {
|
|
113
|
+
if (process.config?.variables?.shlib_suffix === 'dll.a' || process.config?.variables?.node_target_type === 'shared_library') {
|
|
114
|
+
try {
|
|
115
|
+
return require('./vurst-html.win32-x64-gnu.node')
|
|
116
|
+
} catch (e) {
|
|
117
|
+
loadErrors.push(e)
|
|
118
|
+
}
|
|
119
|
+
try {
|
|
120
|
+
const binding = require('@jongleberry/vurst-html-win32-x64-gnu')
|
|
121
|
+
const bindingPackageVersion = require('@jongleberry/vurst-html-win32-x64-gnu/package.json').version
|
|
122
|
+
if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
123
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
124
|
+
}
|
|
125
|
+
return binding
|
|
126
|
+
} catch (e) {
|
|
127
|
+
loadErrors.push(e)
|
|
128
|
+
}
|
|
129
|
+
} else {
|
|
130
|
+
try {
|
|
131
|
+
return require('./vurst-html.win32-x64-msvc.node')
|
|
132
|
+
} catch (e) {
|
|
133
|
+
loadErrors.push(e)
|
|
134
|
+
}
|
|
135
|
+
try {
|
|
136
|
+
const binding = require('@jongleberry/vurst-html-win32-x64-msvc')
|
|
137
|
+
const bindingPackageVersion = require('@jongleberry/vurst-html-win32-x64-msvc/package.json').version
|
|
138
|
+
if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
139
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
140
|
+
}
|
|
141
|
+
return binding
|
|
142
|
+
} catch (e) {
|
|
143
|
+
loadErrors.push(e)
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
} else if (process.arch === 'ia32') {
|
|
147
|
+
try {
|
|
148
|
+
return require('./vurst-html.win32-ia32-msvc.node')
|
|
149
|
+
} catch (e) {
|
|
150
|
+
loadErrors.push(e)
|
|
151
|
+
}
|
|
152
|
+
try {
|
|
153
|
+
const binding = require('@jongleberry/vurst-html-win32-ia32-msvc')
|
|
154
|
+
const bindingPackageVersion = require('@jongleberry/vurst-html-win32-ia32-msvc/package.json').version
|
|
155
|
+
if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
156
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
157
|
+
}
|
|
158
|
+
return binding
|
|
159
|
+
} catch (e) {
|
|
160
|
+
loadErrors.push(e)
|
|
161
|
+
}
|
|
162
|
+
} else if (process.arch === 'arm64') {
|
|
163
|
+
try {
|
|
164
|
+
return require('./vurst-html.win32-arm64-msvc.node')
|
|
165
|
+
} catch (e) {
|
|
166
|
+
loadErrors.push(e)
|
|
167
|
+
}
|
|
168
|
+
try {
|
|
169
|
+
const binding = require('@jongleberry/vurst-html-win32-arm64-msvc')
|
|
170
|
+
const bindingPackageVersion = require('@jongleberry/vurst-html-win32-arm64-msvc/package.json').version
|
|
171
|
+
if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
172
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
173
|
+
}
|
|
174
|
+
return binding
|
|
175
|
+
} catch (e) {
|
|
176
|
+
loadErrors.push(e)
|
|
177
|
+
}
|
|
178
|
+
} else {
|
|
179
|
+
loadErrors.push(new Error(`Unsupported architecture on Windows: ${process.arch}`))
|
|
180
|
+
}
|
|
181
|
+
} else if (process.platform === 'darwin') {
|
|
182
|
+
try {
|
|
183
|
+
return require('./vurst-html.darwin-universal.node')
|
|
184
|
+
} catch (e) {
|
|
185
|
+
loadErrors.push(e)
|
|
186
|
+
}
|
|
187
|
+
try {
|
|
188
|
+
const binding = require('@jongleberry/vurst-html-darwin-universal')
|
|
189
|
+
const bindingPackageVersion = require('@jongleberry/vurst-html-darwin-universal/package.json').version
|
|
190
|
+
if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
191
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
192
|
+
}
|
|
193
|
+
return binding
|
|
194
|
+
} catch (e) {
|
|
195
|
+
loadErrors.push(e)
|
|
196
|
+
}
|
|
197
|
+
if (process.arch === 'x64') {
|
|
198
|
+
try {
|
|
199
|
+
return require('./vurst-html.darwin-x64.node')
|
|
200
|
+
} catch (e) {
|
|
201
|
+
loadErrors.push(e)
|
|
202
|
+
}
|
|
203
|
+
try {
|
|
204
|
+
const binding = require('@jongleberry/vurst-html-darwin-x64')
|
|
205
|
+
const bindingPackageVersion = require('@jongleberry/vurst-html-darwin-x64/package.json').version
|
|
206
|
+
if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
207
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
208
|
+
}
|
|
209
|
+
return binding
|
|
210
|
+
} catch (e) {
|
|
211
|
+
loadErrors.push(e)
|
|
212
|
+
}
|
|
213
|
+
} else if (process.arch === 'arm64') {
|
|
214
|
+
try {
|
|
215
|
+
return require('./vurst-html.darwin-arm64.node')
|
|
216
|
+
} catch (e) {
|
|
217
|
+
loadErrors.push(e)
|
|
218
|
+
}
|
|
219
|
+
try {
|
|
220
|
+
const binding = require('@jongleberry/vurst-html-darwin-arm64')
|
|
221
|
+
const bindingPackageVersion = require('@jongleberry/vurst-html-darwin-arm64/package.json').version
|
|
222
|
+
if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
223
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
224
|
+
}
|
|
225
|
+
return binding
|
|
226
|
+
} catch (e) {
|
|
227
|
+
loadErrors.push(e)
|
|
228
|
+
}
|
|
229
|
+
} else {
|
|
230
|
+
loadErrors.push(new Error(`Unsupported architecture on macOS: ${process.arch}`))
|
|
231
|
+
}
|
|
232
|
+
} else if (process.platform === 'freebsd') {
|
|
233
|
+
if (process.arch === 'x64') {
|
|
234
|
+
try {
|
|
235
|
+
return require('./vurst-html.freebsd-x64.node')
|
|
236
|
+
} catch (e) {
|
|
237
|
+
loadErrors.push(e)
|
|
238
|
+
}
|
|
239
|
+
try {
|
|
240
|
+
const binding = require('@jongleberry/vurst-html-freebsd-x64')
|
|
241
|
+
const bindingPackageVersion = require('@jongleberry/vurst-html-freebsd-x64/package.json').version
|
|
242
|
+
if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
243
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
244
|
+
}
|
|
245
|
+
return binding
|
|
246
|
+
} catch (e) {
|
|
247
|
+
loadErrors.push(e)
|
|
248
|
+
}
|
|
249
|
+
} else if (process.arch === 'arm64') {
|
|
250
|
+
try {
|
|
251
|
+
return require('./vurst-html.freebsd-arm64.node')
|
|
252
|
+
} catch (e) {
|
|
253
|
+
loadErrors.push(e)
|
|
254
|
+
}
|
|
255
|
+
try {
|
|
256
|
+
const binding = require('@jongleberry/vurst-html-freebsd-arm64')
|
|
257
|
+
const bindingPackageVersion = require('@jongleberry/vurst-html-freebsd-arm64/package.json').version
|
|
258
|
+
if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
259
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
260
|
+
}
|
|
261
|
+
return binding
|
|
262
|
+
} catch (e) {
|
|
263
|
+
loadErrors.push(e)
|
|
264
|
+
}
|
|
265
|
+
} else {
|
|
266
|
+
loadErrors.push(new Error(`Unsupported architecture on FreeBSD: ${process.arch}`))
|
|
267
|
+
}
|
|
268
|
+
} else if (process.platform === 'linux') {
|
|
269
|
+
if (process.arch === 'x64') {
|
|
270
|
+
if (isMusl()) {
|
|
271
|
+
try {
|
|
272
|
+
return require('./vurst-html.linux-x64-musl.node')
|
|
273
|
+
} catch (e) {
|
|
274
|
+
loadErrors.push(e)
|
|
275
|
+
}
|
|
276
|
+
try {
|
|
277
|
+
const binding = require('@jongleberry/vurst-html-linux-x64-musl')
|
|
278
|
+
const bindingPackageVersion = require('@jongleberry/vurst-html-linux-x64-musl/package.json').version
|
|
279
|
+
if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
280
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
281
|
+
}
|
|
282
|
+
return binding
|
|
283
|
+
} catch (e) {
|
|
284
|
+
loadErrors.push(e)
|
|
285
|
+
}
|
|
286
|
+
} else {
|
|
287
|
+
try {
|
|
288
|
+
return require('./vurst-html.linux-x64-gnu.node')
|
|
289
|
+
} catch (e) {
|
|
290
|
+
loadErrors.push(e)
|
|
291
|
+
}
|
|
292
|
+
try {
|
|
293
|
+
const binding = require('@jongleberry/vurst-html-linux-x64-gnu')
|
|
294
|
+
const bindingPackageVersion = require('@jongleberry/vurst-html-linux-x64-gnu/package.json').version
|
|
295
|
+
if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
296
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
297
|
+
}
|
|
298
|
+
return binding
|
|
299
|
+
} catch (e) {
|
|
300
|
+
loadErrors.push(e)
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
} else if (process.arch === 'arm64') {
|
|
304
|
+
if (isMusl()) {
|
|
305
|
+
try {
|
|
306
|
+
return require('./vurst-html.linux-arm64-musl.node')
|
|
307
|
+
} catch (e) {
|
|
308
|
+
loadErrors.push(e)
|
|
309
|
+
}
|
|
310
|
+
try {
|
|
311
|
+
const binding = require('@jongleberry/vurst-html-linux-arm64-musl')
|
|
312
|
+
const bindingPackageVersion = require('@jongleberry/vurst-html-linux-arm64-musl/package.json').version
|
|
313
|
+
if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
314
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
315
|
+
}
|
|
316
|
+
return binding
|
|
317
|
+
} catch (e) {
|
|
318
|
+
loadErrors.push(e)
|
|
319
|
+
}
|
|
320
|
+
} else {
|
|
321
|
+
try {
|
|
322
|
+
return require('./vurst-html.linux-arm64-gnu.node')
|
|
323
|
+
} catch (e) {
|
|
324
|
+
loadErrors.push(e)
|
|
325
|
+
}
|
|
326
|
+
try {
|
|
327
|
+
const binding = require('@jongleberry/vurst-html-linux-arm64-gnu')
|
|
328
|
+
const bindingPackageVersion = require('@jongleberry/vurst-html-linux-arm64-gnu/package.json').version
|
|
329
|
+
if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
330
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
331
|
+
}
|
|
332
|
+
return binding
|
|
333
|
+
} catch (e) {
|
|
334
|
+
loadErrors.push(e)
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
} else if (process.arch === 'arm') {
|
|
338
|
+
if (isMusl()) {
|
|
339
|
+
try {
|
|
340
|
+
return require('./vurst-html.linux-arm-musleabihf.node')
|
|
341
|
+
} catch (e) {
|
|
342
|
+
loadErrors.push(e)
|
|
343
|
+
}
|
|
344
|
+
try {
|
|
345
|
+
const binding = require('@jongleberry/vurst-html-linux-arm-musleabihf')
|
|
346
|
+
const bindingPackageVersion = require('@jongleberry/vurst-html-linux-arm-musleabihf/package.json').version
|
|
347
|
+
if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
348
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
349
|
+
}
|
|
350
|
+
return binding
|
|
351
|
+
} catch (e) {
|
|
352
|
+
loadErrors.push(e)
|
|
353
|
+
}
|
|
354
|
+
} else {
|
|
355
|
+
try {
|
|
356
|
+
return require('./vurst-html.linux-arm-gnueabihf.node')
|
|
357
|
+
} catch (e) {
|
|
358
|
+
loadErrors.push(e)
|
|
359
|
+
}
|
|
360
|
+
try {
|
|
361
|
+
const binding = require('@jongleberry/vurst-html-linux-arm-gnueabihf')
|
|
362
|
+
const bindingPackageVersion = require('@jongleberry/vurst-html-linux-arm-gnueabihf/package.json').version
|
|
363
|
+
if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
364
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
365
|
+
}
|
|
366
|
+
return binding
|
|
367
|
+
} catch (e) {
|
|
368
|
+
loadErrors.push(e)
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
} else if (process.arch === 'loong64') {
|
|
372
|
+
if (isMusl()) {
|
|
373
|
+
try {
|
|
374
|
+
return require('./vurst-html.linux-loong64-musl.node')
|
|
375
|
+
} catch (e) {
|
|
376
|
+
loadErrors.push(e)
|
|
377
|
+
}
|
|
378
|
+
try {
|
|
379
|
+
const binding = require('@jongleberry/vurst-html-linux-loong64-musl')
|
|
380
|
+
const bindingPackageVersion = require('@jongleberry/vurst-html-linux-loong64-musl/package.json').version
|
|
381
|
+
if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
382
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
383
|
+
}
|
|
384
|
+
return binding
|
|
385
|
+
} catch (e) {
|
|
386
|
+
loadErrors.push(e)
|
|
387
|
+
}
|
|
388
|
+
} else {
|
|
389
|
+
try {
|
|
390
|
+
return require('./vurst-html.linux-loong64-gnu.node')
|
|
391
|
+
} catch (e) {
|
|
392
|
+
loadErrors.push(e)
|
|
393
|
+
}
|
|
394
|
+
try {
|
|
395
|
+
const binding = require('@jongleberry/vurst-html-linux-loong64-gnu')
|
|
396
|
+
const bindingPackageVersion = require('@jongleberry/vurst-html-linux-loong64-gnu/package.json').version
|
|
397
|
+
if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
398
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
399
|
+
}
|
|
400
|
+
return binding
|
|
401
|
+
} catch (e) {
|
|
402
|
+
loadErrors.push(e)
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
} else if (process.arch === 'riscv64') {
|
|
406
|
+
if (isMusl()) {
|
|
407
|
+
try {
|
|
408
|
+
return require('./vurst-html.linux-riscv64-musl.node')
|
|
409
|
+
} catch (e) {
|
|
410
|
+
loadErrors.push(e)
|
|
411
|
+
}
|
|
412
|
+
try {
|
|
413
|
+
const binding = require('@jongleberry/vurst-html-linux-riscv64-musl')
|
|
414
|
+
const bindingPackageVersion = require('@jongleberry/vurst-html-linux-riscv64-musl/package.json').version
|
|
415
|
+
if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
416
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
417
|
+
}
|
|
418
|
+
return binding
|
|
419
|
+
} catch (e) {
|
|
420
|
+
loadErrors.push(e)
|
|
421
|
+
}
|
|
422
|
+
} else {
|
|
423
|
+
try {
|
|
424
|
+
return require('./vurst-html.linux-riscv64-gnu.node')
|
|
425
|
+
} catch (e) {
|
|
426
|
+
loadErrors.push(e)
|
|
427
|
+
}
|
|
428
|
+
try {
|
|
429
|
+
const binding = require('@jongleberry/vurst-html-linux-riscv64-gnu')
|
|
430
|
+
const bindingPackageVersion = require('@jongleberry/vurst-html-linux-riscv64-gnu/package.json').version
|
|
431
|
+
if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
432
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
433
|
+
}
|
|
434
|
+
return binding
|
|
435
|
+
} catch (e) {
|
|
436
|
+
loadErrors.push(e)
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
} else if (process.arch === 'ppc64') {
|
|
440
|
+
try {
|
|
441
|
+
return require('./vurst-html.linux-ppc64-gnu.node')
|
|
442
|
+
} catch (e) {
|
|
443
|
+
loadErrors.push(e)
|
|
444
|
+
}
|
|
445
|
+
try {
|
|
446
|
+
const binding = require('@jongleberry/vurst-html-linux-ppc64-gnu')
|
|
447
|
+
const bindingPackageVersion = require('@jongleberry/vurst-html-linux-ppc64-gnu/package.json').version
|
|
448
|
+
if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
449
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
450
|
+
}
|
|
451
|
+
return binding
|
|
452
|
+
} catch (e) {
|
|
453
|
+
loadErrors.push(e)
|
|
454
|
+
}
|
|
455
|
+
} else if (process.arch === 's390x') {
|
|
456
|
+
try {
|
|
457
|
+
return require('./vurst-html.linux-s390x-gnu.node')
|
|
458
|
+
} catch (e) {
|
|
459
|
+
loadErrors.push(e)
|
|
460
|
+
}
|
|
461
|
+
try {
|
|
462
|
+
const binding = require('@jongleberry/vurst-html-linux-s390x-gnu')
|
|
463
|
+
const bindingPackageVersion = require('@jongleberry/vurst-html-linux-s390x-gnu/package.json').version
|
|
464
|
+
if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
465
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
466
|
+
}
|
|
467
|
+
return binding
|
|
468
|
+
} catch (e) {
|
|
469
|
+
loadErrors.push(e)
|
|
470
|
+
}
|
|
471
|
+
} else {
|
|
472
|
+
loadErrors.push(new Error(`Unsupported architecture on Linux: ${process.arch}`))
|
|
473
|
+
}
|
|
474
|
+
} else if (process.platform === 'openharmony') {
|
|
475
|
+
if (process.arch === 'arm64') {
|
|
476
|
+
try {
|
|
477
|
+
return require('./vurst-html.openharmony-arm64.node')
|
|
478
|
+
} catch (e) {
|
|
479
|
+
loadErrors.push(e)
|
|
480
|
+
}
|
|
481
|
+
try {
|
|
482
|
+
const binding = require('@jongleberry/vurst-html-openharmony-arm64')
|
|
483
|
+
const bindingPackageVersion = require('@jongleberry/vurst-html-openharmony-arm64/package.json').version
|
|
484
|
+
if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
485
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
486
|
+
}
|
|
487
|
+
return binding
|
|
488
|
+
} catch (e) {
|
|
489
|
+
loadErrors.push(e)
|
|
490
|
+
}
|
|
491
|
+
} else if (process.arch === 'x64') {
|
|
492
|
+
try {
|
|
493
|
+
return require('./vurst-html.openharmony-x64.node')
|
|
494
|
+
} catch (e) {
|
|
495
|
+
loadErrors.push(e)
|
|
496
|
+
}
|
|
497
|
+
try {
|
|
498
|
+
const binding = require('@jongleberry/vurst-html-openharmony-x64')
|
|
499
|
+
const bindingPackageVersion = require('@jongleberry/vurst-html-openharmony-x64/package.json').version
|
|
500
|
+
if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
501
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
502
|
+
}
|
|
503
|
+
return binding
|
|
504
|
+
} catch (e) {
|
|
505
|
+
loadErrors.push(e)
|
|
506
|
+
}
|
|
507
|
+
} else if (process.arch === 'arm') {
|
|
508
|
+
try {
|
|
509
|
+
return require('./vurst-html.openharmony-arm.node')
|
|
510
|
+
} catch (e) {
|
|
511
|
+
loadErrors.push(e)
|
|
512
|
+
}
|
|
513
|
+
try {
|
|
514
|
+
const binding = require('@jongleberry/vurst-html-openharmony-arm')
|
|
515
|
+
const bindingPackageVersion = require('@jongleberry/vurst-html-openharmony-arm/package.json').version
|
|
516
|
+
if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
517
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
518
|
+
}
|
|
519
|
+
return binding
|
|
520
|
+
} catch (e) {
|
|
521
|
+
loadErrors.push(e)
|
|
522
|
+
}
|
|
523
|
+
} else {
|
|
524
|
+
loadErrors.push(new Error(`Unsupported architecture on OpenHarmony: ${process.arch}`))
|
|
525
|
+
}
|
|
526
|
+
} else {
|
|
527
|
+
loadErrors.push(new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`))
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
nativeBinding = requireNative()
|
|
532
|
+
|
|
533
|
+
if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
|
|
534
|
+
let wasiBinding = null
|
|
535
|
+
let wasiBindingError = null
|
|
536
|
+
try {
|
|
537
|
+
wasiBinding = require('./vurst-html.wasi.cjs')
|
|
538
|
+
nativeBinding = wasiBinding
|
|
539
|
+
} catch (err) {
|
|
540
|
+
if (process.env.NAPI_RS_FORCE_WASI) {
|
|
541
|
+
wasiBindingError = err
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
|
|
545
|
+
try {
|
|
546
|
+
wasiBinding = require('@jongleberry/vurst-html-wasm32-wasi')
|
|
547
|
+
nativeBinding = wasiBinding
|
|
548
|
+
} catch (err) {
|
|
549
|
+
if (process.env.NAPI_RS_FORCE_WASI) {
|
|
550
|
+
if (!wasiBindingError) {
|
|
551
|
+
wasiBindingError = err
|
|
552
|
+
} else {
|
|
553
|
+
wasiBindingError.cause = err
|
|
554
|
+
}
|
|
555
|
+
loadErrors.push(err)
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
if (process.env.NAPI_RS_FORCE_WASI === 'error' && !wasiBinding) {
|
|
560
|
+
const error = new Error('WASI binding not found and NAPI_RS_FORCE_WASI is set to error')
|
|
561
|
+
error.cause = wasiBindingError
|
|
562
|
+
throw error
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
if (!nativeBinding) {
|
|
567
|
+
if (loadErrors.length > 0) {
|
|
568
|
+
throw new Error(
|
|
569
|
+
`Cannot find native binding. ` +
|
|
570
|
+
`npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). ` +
|
|
571
|
+
'Please try `npm i` again after removing both package-lock.json and node_modules directory.',
|
|
572
|
+
{
|
|
573
|
+
cause: loadErrors.reduce((err, cur) => {
|
|
574
|
+
cur.cause = err
|
|
575
|
+
return cur
|
|
576
|
+
}),
|
|
577
|
+
},
|
|
578
|
+
)
|
|
579
|
+
}
|
|
580
|
+
throw new Error(`Failed to load native binding`)
|
|
581
|
+
}
|
|
24
582
|
|
|
25
|
-
module.exports
|
|
26
|
-
module.exports.
|
|
27
|
-
module.exports.
|
|
28
|
-
module.exports.
|
|
29
|
-
module.exports.
|
|
30
|
-
module.exports.
|
|
31
|
-
module.exports.
|
|
583
|
+
module.exports = nativeBinding
|
|
584
|
+
module.exports.applyDomRemovalsToHtml = nativeBinding.applyDomRemovalsToHtml
|
|
585
|
+
module.exports.extractDomRemovals = nativeBinding.extractDomRemovals
|
|
586
|
+
module.exports.getContentFromHtml = nativeBinding.getContentFromHtml
|
|
587
|
+
module.exports.htmlToEmbeddingText = nativeBinding.htmlToEmbeddingText
|
|
588
|
+
module.exports.sanitizePromptInjection = nativeBinding.sanitizePromptInjection
|
|
589
|
+
module.exports.sanitizeRssHtml = nativeBinding.sanitizeRssHtml
|
|
590
|
+
module.exports.sanitizeRssHtmlBatch = nativeBinding.sanitizeRssHtmlBatch
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jongleberry/vurst-html",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Rust + N-API: HTML sanitization, extraction, and boilerstrip.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -49,8 +49,8 @@
|
|
|
49
49
|
"@types/node": "^24"
|
|
50
50
|
},
|
|
51
51
|
"optionalDependencies": {
|
|
52
|
-
"@jongleberry/vurst-html-darwin-arm64": "0.
|
|
53
|
-
"@jongleberry/vurst-html-linux-arm64-gnu": "0.
|
|
54
|
-
"@jongleberry/vurst-html-linux-x64-gnu": "0.
|
|
52
|
+
"@jongleberry/vurst-html-darwin-arm64": "0.2.1",
|
|
53
|
+
"@jongleberry/vurst-html-linux-arm64-gnu": "0.2.1",
|
|
54
|
+
"@jongleberry/vurst-html-linux-x64-gnu": "0.2.1"
|
|
55
55
|
}
|
|
56
56
|
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|