@jongleberry/vurst-html 0.1.0 → 0.2.2

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Jonathan Ong
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/index.d.ts CHANGED
@@ -1,24 +1,7 @@
1
+ /* auto-generated by NAPI-RS */
2
+ /* eslint-disable */
1
3
  /// <reference types="node" />
2
-
3
- export interface NapiSanitizeRssHtmlOptions {
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
- }
4
+ export declare function applyDomRemovalsToHtml(html: Buffer, removals: ExtractDomRemovalsResult): Promise<Buffer>
22
5
 
23
6
  export interface CrawlerHtmlToMarkdownOptions {
24
7
  cssSelectorsToRemove?: Array<string>
@@ -31,38 +14,48 @@ export interface CrawlerHtmlToMarkdownOptions {
31
14
 
32
15
  export interface CrawlerHtmlToMarkdownResult {
33
16
  title?: string
34
- meta: Record<string, unknown>
35
- links: Record<string, unknown>
17
+ meta: Record<string, any>
18
+ links: Record<string, any>
36
19
  content: string
37
20
  canonicalUrl?: string
38
21
  lang?: string
39
22
  }
40
23
 
41
- export declare function sanitizeRssHtml(
42
- html: Buffer,
43
- options?: NapiSanitizeRssHtmlOptions,
44
- ): Promise<SanitizeRssHtmlResult>
24
+ export declare function extractDomRemovals(htmlPages: Array<Buffer>, options?: ExtractDomRemovalsOptions | undefined | null): Promise<ExtractDomRemovalsResult>
45
25
 
46
- export declare function sanitizeRssHtmlBatch(
47
- inputs: Array<Buffer>,
48
- options?: NapiSanitizeRssHtmlOptions,
49
- ): Promise<Array<SanitizeRssHtmlResult>>
26
+ export interface ExtractDomRemovalsOptions {
27
+ boilerplatePatterns?: Array<string>
28
+ }
29
+
30
+ export interface ExtractDomRemovalsResult {
31
+ cssSelectorsToRemove: Array<string>
32
+ htmlToRemove: Array<string>
33
+ }
34
+
35
+ export declare function getContentFromHtml(htmlBuffer: Buffer, options: CrawlerHtmlToMarkdownOptions): Promise<CrawlerHtmlToMarkdownResult>
50
36
 
51
37
  export declare function htmlToEmbeddingText(html: Buffer): Promise<string>
52
38
 
53
- export declare function extractDomRemovals(
54
- htmlPages: Array<Buffer>,
55
- options?: ExtractDomRemovalsOptions,
56
- ): Promise<ExtractDomRemovalsResult>
39
+ export interface NapiSanitizeRssHtmlOptions {
40
+ /** When `true`, rewrite external `<img src>` URLs through the configured proxy prefix. */
41
+ proxyImages?: boolean
42
+ /** URL path prefix prepended to proxied image URLs (default `/proxy/`). */
43
+ imageProxyUrlPrefix?: string
44
+ /** Hex-encoded HMAC-SHA256 signing keys (newest first). Empty = dev mode (no sig). */
45
+ imageProxySigningKeys?: Array<string>
46
+ }
47
+
48
+ export interface NapiSanitizeRssHtmlResult {
49
+ /** Sanitized HTML safe for rendering. */
50
+ html: Buffer
51
+ /** Raw `src` of the first external `<img>` found before proxying; `undefined` when none. */
52
+ firstImageSrc?: string
53
+ }
54
+
55
+ export type SanitizeRssHtmlResult = NapiSanitizeRssHtmlResult
57
56
 
58
- export declare function applyDomRemovalsToHtml(
59
- html: Buffer,
60
- removals: ExtractDomRemovalsResult,
61
- ): Promise<Buffer>
57
+ export declare function sanitizePromptInjection(content: Buffer, isTitle?: boolean | undefined | null): Promise<Buffer>
62
58
 
63
- export declare function getContentFromHtml(
64
- htmlBuffer: Buffer,
65
- options: CrawlerHtmlToMarkdownOptions,
66
- ): Promise<CrawlerHtmlToMarkdownResult>
59
+ export declare function sanitizeRssHtml(html: Buffer, options?: NapiSanitizeRssHtmlOptions | undefined | null): Promise<SanitizeRssHtmlResult>
67
60
 
68
- export declare function sanitizePromptInjection(content: Buffer, isTitle?: boolean): Promise<Buffer>
61
+ export declare function sanitizeRssHtmlBatch(inputs: Array<Buffer>, options?: NapiSanitizeRssHtmlOptions | undefined | null): Promise<Array<SanitizeRssHtmlResult>>
package/index.js CHANGED
@@ -1,31 +1,590 @@
1
- 'use strict'
2
-
3
- // Platform dispatcher for @jongleberry/vurst-html.
4
-
5
- const { platform, arch } = process
6
-
7
- function loadBinding() {
8
- switch (`${platform}-${arch}`) {
9
- case 'darwin-arm64':
10
- return require('./vurst-html.darwin-arm64.node')
11
- case 'linux-x64':
12
- return require('./vurst-html.linux-x64-gnu.node')
13
- case 'linux-arm64':
14
- return require('./vurst-html.linux-arm64-gnu.node')
15
- default:
16
- throw new Error(
17
- `Unsupported platform: ${platform}-${arch}. ` +
18
- `@jongleberry/vurst-html supports darwin-arm64, linux-x64 (glibc), and linux-arm64 (glibc).`,
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
- const binding = loadBinding()
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.2.1' && 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.2.1 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.2.1' && 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.2.1 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.2.1' && 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.2.1 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.2.1' && 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.2.1 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.2.1' && 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.2.1 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.2.1' && 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.2.1 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.2.1' && 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.2.1 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.2.1' && 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.2.1 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.2.1' && 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.2.1 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.2.1' && 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.2.1 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.2.1' && 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.2.1 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.2.1' && 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.2.1 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.2.1' && 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.2.1 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.2.1' && 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.2.1 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.2.1' && 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.2.1 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.2.1' && 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.2.1 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.2.1' && 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.2.1 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.2.1' && 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.2.1 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.2.1' && 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.2.1 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.2.1' && 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.2.1 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.2.1' && 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.2.1 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.2.1' && 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.2.1 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.2.1' && 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.2.1 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.2.1' && 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.2.1 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.2.1' && 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.2.1 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.2.1' && 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.2.1 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.sanitizeRssHtml = binding.sanitizeRssHtml
26
- module.exports.sanitizeRssHtmlBatch = binding.sanitizeRssHtmlBatch
27
- module.exports.htmlToEmbeddingText = binding.htmlToEmbeddingText
28
- module.exports.extractDomRemovals = binding.extractDomRemovals
29
- module.exports.applyDomRemovalsToHtml = binding.applyDomRemovalsToHtml
30
- module.exports.getContentFromHtml = binding.getContentFromHtml
31
- module.exports.sanitizePromptInjection = binding.sanitizePromptInjection
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.1.0",
3
+ "version": "0.2.2",
4
4
  "description": "Rust + N-API: HTML sanitization, extraction, and boilerstrip.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -34,12 +34,6 @@
34
34
  "x86_64-unknown-linux-gnu"
35
35
  ]
36
36
  },
37
- "scripts": {
38
- "build": "napi build --platform --release",
39
- "build:debug": "napi build --platform",
40
- "test": "node --test __test__/*.test.mjs",
41
- "prepublishOnly": "napi prepublish -t npm"
42
- },
43
37
  "publishConfig": {
44
38
  "access": "public",
45
39
  "provenance": true
@@ -49,8 +43,13 @@
49
43
  "@types/node": "^24"
50
44
  },
51
45
  "optionalDependencies": {
52
- "@jongleberry/vurst-html-darwin-arm64": "0.1.0",
53
- "@jongleberry/vurst-html-linux-arm64-gnu": "0.1.0",
54
- "@jongleberry/vurst-html-linux-x64-gnu": "0.1.0"
46
+ "@jongleberry/vurst-html-darwin-arm64": "0.2.2",
47
+ "@jongleberry/vurst-html-linux-arm64-gnu": "0.2.2",
48
+ "@jongleberry/vurst-html-linux-x64-gnu": "0.2.2"
49
+ },
50
+ "scripts": {
51
+ "build": "napi build --platform --release",
52
+ "build:debug": "napi build --platform",
53
+ "test": "node --test __test__/*.test.mjs"
55
54
  }
56
55
  }
Binary file
Binary file
Binary file