@jongleberry/vurst-markdown 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 CHANGED
@@ -1,6 +1,17 @@
1
+ /* auto-generated by NAPI-RS */
2
+ /* eslint-disable */
1
3
  /// <reference types="node" />
2
4
 
3
- export interface Chunk {
5
+ export declare function chunk(text: Buffer, options?: ChunkOptions | undefined | null): Promise<Array<Chunk>>
6
+
7
+ export declare function extractMarkdownUrls(text: Buffer): Promise<MarkdownUrls>
8
+
9
+ export interface MarkdownUrls {
10
+ linkUrls: Array<string>
11
+ imageUrls: Array<string>
12
+ }
13
+
14
+ export interface NapiChunk {
4
15
  level: number
5
16
  header?: string
6
17
  headers: Array<string | undefined | null>
@@ -9,13 +20,17 @@ export interface Chunk {
9
20
  length: number
10
21
  }
11
22
 
12
- export interface ChunkOptions {
23
+ export interface Chunk extends NapiChunk {}
24
+
25
+ export interface NapiChunkOptions {
13
26
  minLength?: number
14
27
  maxLength?: number
15
28
  phase?: number
16
29
  title?: string
17
30
  }
18
31
 
32
+ export interface ChunkOptions extends NapiChunkOptions {}
33
+
19
34
  export interface NapiMarkdownRenderOptions {
20
35
  allowHtml?: boolean
21
36
  nofollowLinks?: boolean
@@ -24,21 +39,6 @@ export interface NapiMarkdownRenderOptions {
24
39
  imageProxySigningKeys?: Array<string>
25
40
  }
26
41
 
27
- export interface MarkdownUrls {
28
- linkUrls: Array<string>
29
- imageUrls: Array<string>
30
- }
42
+ export declare function renderMarkdownToHtml(text: Buffer, options?: NapiMarkdownRenderOptions | undefined | null): Promise<Buffer>
31
43
 
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>
44
+ export declare function renderMarkdownToHtmlBatch(inputs: Array<Buffer>, options?: NapiMarkdownRenderOptions | undefined | null): Promise<Array<Buffer>>
package/index.js CHANGED
@@ -1,28 +1,587 @@
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
- )
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-markdown.android-arm64.node')
79
+ } catch (e) {
80
+ loadErrors.push(e)
81
+ }
82
+ try {
83
+ const binding = require('@jongleberry/vurst-markdown-android-arm64')
84
+ const bindingPackageVersion = require('@jongleberry/vurst-markdown-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-markdown.android-arm-eabi.node')
95
+ } catch (e) {
96
+ loadErrors.push(e)
97
+ }
98
+ try {
99
+ const binding = require('@jongleberry/vurst-markdown-android-arm-eabi')
100
+ const bindingPackageVersion = require('@jongleberry/vurst-markdown-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-markdown.win32-x64-gnu.node')
116
+ } catch (e) {
117
+ loadErrors.push(e)
118
+ }
119
+ try {
120
+ const binding = require('@jongleberry/vurst-markdown-win32-x64-gnu')
121
+ const bindingPackageVersion = require('@jongleberry/vurst-markdown-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-markdown.win32-x64-msvc.node')
132
+ } catch (e) {
133
+ loadErrors.push(e)
134
+ }
135
+ try {
136
+ const binding = require('@jongleberry/vurst-markdown-win32-x64-msvc')
137
+ const bindingPackageVersion = require('@jongleberry/vurst-markdown-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-markdown.win32-ia32-msvc.node')
149
+ } catch (e) {
150
+ loadErrors.push(e)
151
+ }
152
+ try {
153
+ const binding = require('@jongleberry/vurst-markdown-win32-ia32-msvc')
154
+ const bindingPackageVersion = require('@jongleberry/vurst-markdown-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-markdown.win32-arm64-msvc.node')
165
+ } catch (e) {
166
+ loadErrors.push(e)
167
+ }
168
+ try {
169
+ const binding = require('@jongleberry/vurst-markdown-win32-arm64-msvc')
170
+ const bindingPackageVersion = require('@jongleberry/vurst-markdown-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-markdown.darwin-universal.node')
184
+ } catch (e) {
185
+ loadErrors.push(e)
186
+ }
187
+ try {
188
+ const binding = require('@jongleberry/vurst-markdown-darwin-universal')
189
+ const bindingPackageVersion = require('@jongleberry/vurst-markdown-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-markdown.darwin-x64.node')
200
+ } catch (e) {
201
+ loadErrors.push(e)
202
+ }
203
+ try {
204
+ const binding = require('@jongleberry/vurst-markdown-darwin-x64')
205
+ const bindingPackageVersion = require('@jongleberry/vurst-markdown-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-markdown.darwin-arm64.node')
216
+ } catch (e) {
217
+ loadErrors.push(e)
218
+ }
219
+ try {
220
+ const binding = require('@jongleberry/vurst-markdown-darwin-arm64')
221
+ const bindingPackageVersion = require('@jongleberry/vurst-markdown-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-markdown.freebsd-x64.node')
236
+ } catch (e) {
237
+ loadErrors.push(e)
238
+ }
239
+ try {
240
+ const binding = require('@jongleberry/vurst-markdown-freebsd-x64')
241
+ const bindingPackageVersion = require('@jongleberry/vurst-markdown-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-markdown.freebsd-arm64.node')
252
+ } catch (e) {
253
+ loadErrors.push(e)
254
+ }
255
+ try {
256
+ const binding = require('@jongleberry/vurst-markdown-freebsd-arm64')
257
+ const bindingPackageVersion = require('@jongleberry/vurst-markdown-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-markdown.linux-x64-musl.node')
273
+ } catch (e) {
274
+ loadErrors.push(e)
275
+ }
276
+ try {
277
+ const binding = require('@jongleberry/vurst-markdown-linux-x64-musl')
278
+ const bindingPackageVersion = require('@jongleberry/vurst-markdown-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-markdown.linux-x64-gnu.node')
289
+ } catch (e) {
290
+ loadErrors.push(e)
291
+ }
292
+ try {
293
+ const binding = require('@jongleberry/vurst-markdown-linux-x64-gnu')
294
+ const bindingPackageVersion = require('@jongleberry/vurst-markdown-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-markdown.linux-arm64-musl.node')
307
+ } catch (e) {
308
+ loadErrors.push(e)
309
+ }
310
+ try {
311
+ const binding = require('@jongleberry/vurst-markdown-linux-arm64-musl')
312
+ const bindingPackageVersion = require('@jongleberry/vurst-markdown-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-markdown.linux-arm64-gnu.node')
323
+ } catch (e) {
324
+ loadErrors.push(e)
325
+ }
326
+ try {
327
+ const binding = require('@jongleberry/vurst-markdown-linux-arm64-gnu')
328
+ const bindingPackageVersion = require('@jongleberry/vurst-markdown-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-markdown.linux-arm-musleabihf.node')
341
+ } catch (e) {
342
+ loadErrors.push(e)
343
+ }
344
+ try {
345
+ const binding = require('@jongleberry/vurst-markdown-linux-arm-musleabihf')
346
+ const bindingPackageVersion = require('@jongleberry/vurst-markdown-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-markdown.linux-arm-gnueabihf.node')
357
+ } catch (e) {
358
+ loadErrors.push(e)
359
+ }
360
+ try {
361
+ const binding = require('@jongleberry/vurst-markdown-linux-arm-gnueabihf')
362
+ const bindingPackageVersion = require('@jongleberry/vurst-markdown-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-markdown.linux-loong64-musl.node')
375
+ } catch (e) {
376
+ loadErrors.push(e)
377
+ }
378
+ try {
379
+ const binding = require('@jongleberry/vurst-markdown-linux-loong64-musl')
380
+ const bindingPackageVersion = require('@jongleberry/vurst-markdown-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-markdown.linux-loong64-gnu.node')
391
+ } catch (e) {
392
+ loadErrors.push(e)
393
+ }
394
+ try {
395
+ const binding = require('@jongleberry/vurst-markdown-linux-loong64-gnu')
396
+ const bindingPackageVersion = require('@jongleberry/vurst-markdown-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-markdown.linux-riscv64-musl.node')
409
+ } catch (e) {
410
+ loadErrors.push(e)
411
+ }
412
+ try {
413
+ const binding = require('@jongleberry/vurst-markdown-linux-riscv64-musl')
414
+ const bindingPackageVersion = require('@jongleberry/vurst-markdown-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-markdown.linux-riscv64-gnu.node')
425
+ } catch (e) {
426
+ loadErrors.push(e)
427
+ }
428
+ try {
429
+ const binding = require('@jongleberry/vurst-markdown-linux-riscv64-gnu')
430
+ const bindingPackageVersion = require('@jongleberry/vurst-markdown-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-markdown.linux-ppc64-gnu.node')
442
+ } catch (e) {
443
+ loadErrors.push(e)
444
+ }
445
+ try {
446
+ const binding = require('@jongleberry/vurst-markdown-linux-ppc64-gnu')
447
+ const bindingPackageVersion = require('@jongleberry/vurst-markdown-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-markdown.linux-s390x-gnu.node')
458
+ } catch (e) {
459
+ loadErrors.push(e)
460
+ }
461
+ try {
462
+ const binding = require('@jongleberry/vurst-markdown-linux-s390x-gnu')
463
+ const bindingPackageVersion = require('@jongleberry/vurst-markdown-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-markdown.openharmony-arm64.node')
478
+ } catch (e) {
479
+ loadErrors.push(e)
480
+ }
481
+ try {
482
+ const binding = require('@jongleberry/vurst-markdown-openharmony-arm64')
483
+ const bindingPackageVersion = require('@jongleberry/vurst-markdown-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-markdown.openharmony-x64.node')
494
+ } catch (e) {
495
+ loadErrors.push(e)
496
+ }
497
+ try {
498
+ const binding = require('@jongleberry/vurst-markdown-openharmony-x64')
499
+ const bindingPackageVersion = require('@jongleberry/vurst-markdown-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-markdown.openharmony-arm.node')
510
+ } catch (e) {
511
+ loadErrors.push(e)
512
+ }
513
+ try {
514
+ const binding = require('@jongleberry/vurst-markdown-openharmony-arm')
515
+ const bindingPackageVersion = require('@jongleberry/vurst-markdown-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-markdown.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-markdown-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.chunk = binding.chunk
26
- module.exports.renderMarkdownToHtml = binding.renderMarkdownToHtml
27
- module.exports.renderMarkdownToHtmlBatch = binding.renderMarkdownToHtmlBatch
28
- module.exports.extractMarkdownUrls = binding.extractMarkdownUrls
583
+ module.exports = nativeBinding
584
+ module.exports.chunk = nativeBinding.chunk
585
+ module.exports.extractMarkdownUrls = nativeBinding.extractMarkdownUrls
586
+ module.exports.renderMarkdownToHtml = nativeBinding.renderMarkdownToHtml
587
+ module.exports.renderMarkdownToHtmlBatch = nativeBinding.renderMarkdownToHtmlBatch
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jongleberry/vurst-markdown",
3
- "version": "0.0.4",
3
+ "version": "0.2.1",
4
4
  "description": "Rust + N-API: Markdown chunking and rendering.",
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-markdown-darwin-arm64": "0.0.4",
53
- "@jongleberry/vurst-markdown-linux-arm64-gnu": "0.0.4",
54
- "@jongleberry/vurst-markdown-linux-x64-gnu": "0.0.4"
52
+ "@jongleberry/vurst-markdown-darwin-arm64": "0.2.1",
53
+ "@jongleberry/vurst-markdown-linux-arm64-gnu": "0.2.1",
54
+ "@jongleberry/vurst-markdown-linux-x64-gnu": "0.2.1"
55
55
  }
56
56
  }
Binary file
Binary file
Binary file