@d0paminedriven/pdfdown-ocr 0.9.8 → 0.10.0
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/README.md +79 -78
- package/index.d.ts +168 -152
- package/index.js +371 -93
- package/package.json +12 -14
package/index.js
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
|
-
// prettier-ignore
|
|
2
1
|
/* eslint-disable */
|
|
3
2
|
// @ts-nocheck
|
|
4
3
|
/* auto-generated by NAPI-RS */
|
|
5
4
|
|
|
6
|
-
const {
|
|
7
|
-
require = createRequire(__filename)
|
|
8
|
-
|
|
9
|
-
const { readFileSync } = require('node:fs')
|
|
5
|
+
const { readFileSync } = require('fs')
|
|
10
6
|
let nativeBinding = null
|
|
7
|
+
// Which artifact actually loaded. The WASI fallback chain overwrites it with
|
|
8
|
+
// the flavor it resolved; the late native retry below leaves it alone because
|
|
9
|
+
// it only runs while no WASI candidate has been loaded. The take-over check
|
|
10
|
+
// after the load-failure block can also set it.
|
|
11
|
+
let __napiLoadedBindingTarget = 'native'
|
|
12
|
+
// What this loader's own `requireNative()` calls returned. The check after
|
|
13
|
+
// the load-failure block compares it with `nativeBinding` to tell a binding
|
|
14
|
+
// this loader loaded from one that code outside it put in its place.
|
|
15
|
+
let __napiRequiredNativeBinding = null
|
|
11
16
|
const loadErrors = []
|
|
12
17
|
|
|
13
18
|
const isMusl = () => {
|
|
@@ -36,7 +41,7 @@ const isMuslFromFilesystem = () => {
|
|
|
36
41
|
|
|
37
42
|
const isMuslFromReport = () => {
|
|
38
43
|
let report = null
|
|
39
|
-
if (typeof process.report
|
|
44
|
+
if (process.report && typeof process.report.getReport === 'function') {
|
|
40
45
|
process.report.excludeNetwork = true
|
|
41
46
|
report = process.report.getReport()
|
|
42
47
|
}
|
|
@@ -66,7 +71,16 @@ const isMuslFromChildProcess = () => {
|
|
|
66
71
|
function requireNative() {
|
|
67
72
|
if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) {
|
|
68
73
|
try {
|
|
69
|
-
|
|
74
|
+
const overrideBinding = require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH)
|
|
75
|
+
// The override may be a generated WASI loader, which already reports its
|
|
76
|
+
// own flavor. Adopt it: `module.exports` aliases this object, so claiming
|
|
77
|
+
// 'native' would both misreport the artifact and overwrite the loader's
|
|
78
|
+
// marker through the alias.
|
|
79
|
+
__napiLoadedBindingTarget =
|
|
80
|
+
overrideBinding && typeof overrideBinding.__napiBindingTarget === 'string'
|
|
81
|
+
? overrideBinding.__napiBindingTarget
|
|
82
|
+
: 'native'
|
|
83
|
+
return overrideBinding
|
|
70
84
|
} catch (err) {
|
|
71
85
|
loadErrors.push(err)
|
|
72
86
|
}
|
|
@@ -80,8 +94,8 @@ function requireNative() {
|
|
|
80
94
|
try {
|
|
81
95
|
const binding = require('@d0paminedriven/pdfdown-ocr-android-arm64')
|
|
82
96
|
const bindingPackageVersion = require('@d0paminedriven/pdfdown-ocr-android-arm64/package.json').version
|
|
83
|
-
if (bindingPackageVersion !== '0.9.
|
|
84
|
-
throw new Error(`Native binding package version mismatch, expected 0.9.
|
|
97
|
+
if (bindingPackageVersion !== '0.9.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
98
|
+
throw new Error(`Native binding package version mismatch, expected 0.9.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
85
99
|
}
|
|
86
100
|
return binding
|
|
87
101
|
} catch (e) {
|
|
@@ -96,8 +110,8 @@ function requireNative() {
|
|
|
96
110
|
try {
|
|
97
111
|
const binding = require('@d0paminedriven/pdfdown-ocr-android-arm-eabi')
|
|
98
112
|
const bindingPackageVersion = require('@d0paminedriven/pdfdown-ocr-android-arm-eabi/package.json').version
|
|
99
|
-
if (bindingPackageVersion !== '0.9.
|
|
100
|
-
throw new Error(`Native binding package version mismatch, expected 0.9.
|
|
113
|
+
if (bindingPackageVersion !== '0.9.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
114
|
+
throw new Error(`Native binding package version mismatch, expected 0.9.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
101
115
|
}
|
|
102
116
|
return binding
|
|
103
117
|
} catch (e) {
|
|
@@ -108,20 +122,38 @@ function requireNative() {
|
|
|
108
122
|
}
|
|
109
123
|
} else if (process.platform === 'win32') {
|
|
110
124
|
if (process.arch === 'x64') {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
125
|
+
if ((process.config && process.config.variables && process.config.variables.shlib_suffix === 'dll.a') || (process.config && process.config.variables && process.config.variables.node_target_type === 'shared_library')) {
|
|
126
|
+
try {
|
|
127
|
+
return require('./pdfdown_ocr.win32-x64-gnu.node')
|
|
128
|
+
} catch (e) {
|
|
129
|
+
loadErrors.push(e)
|
|
130
|
+
}
|
|
131
|
+
try {
|
|
132
|
+
const binding = require('@d0paminedriven/pdfdown-ocr-win32-x64-gnu')
|
|
133
|
+
const bindingPackageVersion = require('@d0paminedriven/pdfdown-ocr-win32-x64-gnu/package.json').version
|
|
134
|
+
if (bindingPackageVersion !== '0.9.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
135
|
+
throw new Error(`Native binding package version mismatch, expected 0.9.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
136
|
+
}
|
|
137
|
+
return binding
|
|
138
|
+
} catch (e) {
|
|
139
|
+
loadErrors.push(e)
|
|
140
|
+
}
|
|
141
|
+
} else {
|
|
142
|
+
try {
|
|
143
|
+
return require('./pdfdown_ocr.win32-x64-msvc.node')
|
|
144
|
+
} catch (e) {
|
|
145
|
+
loadErrors.push(e)
|
|
146
|
+
}
|
|
147
|
+
try {
|
|
148
|
+
const binding = require('@d0paminedriven/pdfdown-ocr-win32-x64-msvc')
|
|
149
|
+
const bindingPackageVersion = require('@d0paminedriven/pdfdown-ocr-win32-x64-msvc/package.json').version
|
|
150
|
+
if (bindingPackageVersion !== '0.9.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
151
|
+
throw new Error(`Native binding package version mismatch, expected 0.9.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
152
|
+
}
|
|
153
|
+
return binding
|
|
154
|
+
} catch (e) {
|
|
155
|
+
loadErrors.push(e)
|
|
121
156
|
}
|
|
122
|
-
return binding
|
|
123
|
-
} catch (e) {
|
|
124
|
-
loadErrors.push(e)
|
|
125
157
|
}
|
|
126
158
|
} else if (process.arch === 'ia32') {
|
|
127
159
|
try {
|
|
@@ -132,8 +164,8 @@ function requireNative() {
|
|
|
132
164
|
try {
|
|
133
165
|
const binding = require('@d0paminedriven/pdfdown-ocr-win32-ia32-msvc')
|
|
134
166
|
const bindingPackageVersion = require('@d0paminedriven/pdfdown-ocr-win32-ia32-msvc/package.json').version
|
|
135
|
-
if (bindingPackageVersion !== '0.9.
|
|
136
|
-
throw new Error(`Native binding package version mismatch, expected 0.9.
|
|
167
|
+
if (bindingPackageVersion !== '0.9.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
168
|
+
throw new Error(`Native binding package version mismatch, expected 0.9.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
137
169
|
}
|
|
138
170
|
return binding
|
|
139
171
|
} catch (e) {
|
|
@@ -148,8 +180,8 @@ function requireNative() {
|
|
|
148
180
|
try {
|
|
149
181
|
const binding = require('@d0paminedriven/pdfdown-ocr-win32-arm64-msvc')
|
|
150
182
|
const bindingPackageVersion = require('@d0paminedriven/pdfdown-ocr-win32-arm64-msvc/package.json').version
|
|
151
|
-
if (bindingPackageVersion !== '0.9.
|
|
152
|
-
throw new Error(`Native binding package version mismatch, expected 0.9.
|
|
183
|
+
if (bindingPackageVersion !== '0.9.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
184
|
+
throw new Error(`Native binding package version mismatch, expected 0.9.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
153
185
|
}
|
|
154
186
|
return binding
|
|
155
187
|
} catch (e) {
|
|
@@ -167,8 +199,8 @@ function requireNative() {
|
|
|
167
199
|
try {
|
|
168
200
|
const binding = require('@d0paminedriven/pdfdown-ocr-darwin-universal')
|
|
169
201
|
const bindingPackageVersion = require('@d0paminedriven/pdfdown-ocr-darwin-universal/package.json').version
|
|
170
|
-
if (bindingPackageVersion !== '0.9.
|
|
171
|
-
throw new Error(`Native binding package version mismatch, expected 0.9.
|
|
202
|
+
if (bindingPackageVersion !== '0.9.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
203
|
+
throw new Error(`Native binding package version mismatch, expected 0.9.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
172
204
|
}
|
|
173
205
|
return binding
|
|
174
206
|
} catch (e) {
|
|
@@ -183,8 +215,8 @@ function requireNative() {
|
|
|
183
215
|
try {
|
|
184
216
|
const binding = require('@d0paminedriven/pdfdown-ocr-darwin-x64')
|
|
185
217
|
const bindingPackageVersion = require('@d0paminedriven/pdfdown-ocr-darwin-x64/package.json').version
|
|
186
|
-
if (bindingPackageVersion !== '0.9.
|
|
187
|
-
throw new Error(`Native binding package version mismatch, expected 0.9.
|
|
218
|
+
if (bindingPackageVersion !== '0.9.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
219
|
+
throw new Error(`Native binding package version mismatch, expected 0.9.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
188
220
|
}
|
|
189
221
|
return binding
|
|
190
222
|
} catch (e) {
|
|
@@ -199,8 +231,8 @@ function requireNative() {
|
|
|
199
231
|
try {
|
|
200
232
|
const binding = require('@d0paminedriven/pdfdown-ocr-darwin-arm64')
|
|
201
233
|
const bindingPackageVersion = require('@d0paminedriven/pdfdown-ocr-darwin-arm64/package.json').version
|
|
202
|
-
if (bindingPackageVersion !== '0.9.
|
|
203
|
-
throw new Error(`Native binding package version mismatch, expected 0.9.
|
|
234
|
+
if (bindingPackageVersion !== '0.9.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
235
|
+
throw new Error(`Native binding package version mismatch, expected 0.9.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
204
236
|
}
|
|
205
237
|
return binding
|
|
206
238
|
} catch (e) {
|
|
@@ -219,8 +251,8 @@ function requireNative() {
|
|
|
219
251
|
try {
|
|
220
252
|
const binding = require('@d0paminedriven/pdfdown-ocr-freebsd-x64')
|
|
221
253
|
const bindingPackageVersion = require('@d0paminedriven/pdfdown-ocr-freebsd-x64/package.json').version
|
|
222
|
-
if (bindingPackageVersion !== '0.9.
|
|
223
|
-
throw new Error(`Native binding package version mismatch, expected 0.9.
|
|
254
|
+
if (bindingPackageVersion !== '0.9.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
255
|
+
throw new Error(`Native binding package version mismatch, expected 0.9.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
224
256
|
}
|
|
225
257
|
return binding
|
|
226
258
|
} catch (e) {
|
|
@@ -235,8 +267,24 @@ function requireNative() {
|
|
|
235
267
|
try {
|
|
236
268
|
const binding = require('@d0paminedriven/pdfdown-ocr-freebsd-arm64')
|
|
237
269
|
const bindingPackageVersion = require('@d0paminedriven/pdfdown-ocr-freebsd-arm64/package.json').version
|
|
238
|
-
if (bindingPackageVersion !== '0.9.
|
|
239
|
-
throw new Error(`Native binding package version mismatch, expected 0.9.
|
|
270
|
+
if (bindingPackageVersion !== '0.9.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
271
|
+
throw new Error(`Native binding package version mismatch, expected 0.9.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
272
|
+
}
|
|
273
|
+
return binding
|
|
274
|
+
} catch (e) {
|
|
275
|
+
loadErrors.push(e)
|
|
276
|
+
}
|
|
277
|
+
} else if (process.arch === 'ppc64') {
|
|
278
|
+
try {
|
|
279
|
+
return require('./pdfdown_ocr.freebsd-ppc64.node')
|
|
280
|
+
} catch (e) {
|
|
281
|
+
loadErrors.push(e)
|
|
282
|
+
}
|
|
283
|
+
try {
|
|
284
|
+
const binding = require('@d0paminedriven/pdfdown-ocr-freebsd-ppc64')
|
|
285
|
+
const bindingPackageVersion = require('@d0paminedriven/pdfdown-ocr-freebsd-ppc64/package.json').version
|
|
286
|
+
if (bindingPackageVersion !== '0.9.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
287
|
+
throw new Error(`Native binding package version mismatch, expected 0.9.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
240
288
|
}
|
|
241
289
|
return binding
|
|
242
290
|
} catch (e) {
|
|
@@ -256,8 +304,8 @@ function requireNative() {
|
|
|
256
304
|
try {
|
|
257
305
|
const binding = require('@d0paminedriven/pdfdown-ocr-linux-x64-musl')
|
|
258
306
|
const bindingPackageVersion = require('@d0paminedriven/pdfdown-ocr-linux-x64-musl/package.json').version
|
|
259
|
-
if (bindingPackageVersion !== '0.9.
|
|
260
|
-
throw new Error(`Native binding package version mismatch, expected 0.9.
|
|
307
|
+
if (bindingPackageVersion !== '0.9.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
308
|
+
throw new Error(`Native binding package version mismatch, expected 0.9.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
261
309
|
}
|
|
262
310
|
return binding
|
|
263
311
|
} catch (e) {
|
|
@@ -272,8 +320,8 @@ function requireNative() {
|
|
|
272
320
|
try {
|
|
273
321
|
const binding = require('@d0paminedriven/pdfdown-ocr-linux-x64-gnu')
|
|
274
322
|
const bindingPackageVersion = require('@d0paminedriven/pdfdown-ocr-linux-x64-gnu/package.json').version
|
|
275
|
-
if (bindingPackageVersion !== '0.9.
|
|
276
|
-
throw new Error(`Native binding package version mismatch, expected 0.9.
|
|
323
|
+
if (bindingPackageVersion !== '0.9.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
324
|
+
throw new Error(`Native binding package version mismatch, expected 0.9.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
277
325
|
}
|
|
278
326
|
return binding
|
|
279
327
|
} catch (e) {
|
|
@@ -290,8 +338,8 @@ function requireNative() {
|
|
|
290
338
|
try {
|
|
291
339
|
const binding = require('@d0paminedriven/pdfdown-ocr-linux-arm64-musl')
|
|
292
340
|
const bindingPackageVersion = require('@d0paminedriven/pdfdown-ocr-linux-arm64-musl/package.json').version
|
|
293
|
-
if (bindingPackageVersion !== '0.9.
|
|
294
|
-
throw new Error(`Native binding package version mismatch, expected 0.9.
|
|
341
|
+
if (bindingPackageVersion !== '0.9.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
342
|
+
throw new Error(`Native binding package version mismatch, expected 0.9.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
295
343
|
}
|
|
296
344
|
return binding
|
|
297
345
|
} catch (e) {
|
|
@@ -306,8 +354,8 @@ function requireNative() {
|
|
|
306
354
|
try {
|
|
307
355
|
const binding = require('@d0paminedriven/pdfdown-ocr-linux-arm64-gnu')
|
|
308
356
|
const bindingPackageVersion = require('@d0paminedriven/pdfdown-ocr-linux-arm64-gnu/package.json').version
|
|
309
|
-
if (bindingPackageVersion !== '0.9.
|
|
310
|
-
throw new Error(`Native binding package version mismatch, expected 0.9.
|
|
357
|
+
if (bindingPackageVersion !== '0.9.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
358
|
+
throw new Error(`Native binding package version mismatch, expected 0.9.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
311
359
|
}
|
|
312
360
|
return binding
|
|
313
361
|
} catch (e) {
|
|
@@ -324,8 +372,8 @@ function requireNative() {
|
|
|
324
372
|
try {
|
|
325
373
|
const binding = require('@d0paminedriven/pdfdown-ocr-linux-arm-musleabihf')
|
|
326
374
|
const bindingPackageVersion = require('@d0paminedriven/pdfdown-ocr-linux-arm-musleabihf/package.json').version
|
|
327
|
-
if (bindingPackageVersion !== '0.9.
|
|
328
|
-
throw new Error(`Native binding package version mismatch, expected 0.9.
|
|
375
|
+
if (bindingPackageVersion !== '0.9.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
376
|
+
throw new Error(`Native binding package version mismatch, expected 0.9.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
329
377
|
}
|
|
330
378
|
return binding
|
|
331
379
|
} catch (e) {
|
|
@@ -340,8 +388,8 @@ function requireNative() {
|
|
|
340
388
|
try {
|
|
341
389
|
const binding = require('@d0paminedriven/pdfdown-ocr-linux-arm-gnueabihf')
|
|
342
390
|
const bindingPackageVersion = require('@d0paminedriven/pdfdown-ocr-linux-arm-gnueabihf/package.json').version
|
|
343
|
-
if (bindingPackageVersion !== '0.9.
|
|
344
|
-
throw new Error(`Native binding package version mismatch, expected 0.9.
|
|
391
|
+
if (bindingPackageVersion !== '0.9.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
392
|
+
throw new Error(`Native binding package version mismatch, expected 0.9.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
345
393
|
}
|
|
346
394
|
return binding
|
|
347
395
|
} catch (e) {
|
|
@@ -358,8 +406,8 @@ function requireNative() {
|
|
|
358
406
|
try {
|
|
359
407
|
const binding = require('@d0paminedriven/pdfdown-ocr-linux-loong64-musl')
|
|
360
408
|
const bindingPackageVersion = require('@d0paminedriven/pdfdown-ocr-linux-loong64-musl/package.json').version
|
|
361
|
-
if (bindingPackageVersion !== '0.9.
|
|
362
|
-
throw new Error(`Native binding package version mismatch, expected 0.9.
|
|
409
|
+
if (bindingPackageVersion !== '0.9.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
410
|
+
throw new Error(`Native binding package version mismatch, expected 0.9.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
363
411
|
}
|
|
364
412
|
return binding
|
|
365
413
|
} catch (e) {
|
|
@@ -374,8 +422,8 @@ function requireNative() {
|
|
|
374
422
|
try {
|
|
375
423
|
const binding = require('@d0paminedriven/pdfdown-ocr-linux-loong64-gnu')
|
|
376
424
|
const bindingPackageVersion = require('@d0paminedriven/pdfdown-ocr-linux-loong64-gnu/package.json').version
|
|
377
|
-
if (bindingPackageVersion !== '0.9.
|
|
378
|
-
throw new Error(`Native binding package version mismatch, expected 0.9.
|
|
425
|
+
if (bindingPackageVersion !== '0.9.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
426
|
+
throw new Error(`Native binding package version mismatch, expected 0.9.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
379
427
|
}
|
|
380
428
|
return binding
|
|
381
429
|
} catch (e) {
|
|
@@ -392,8 +440,8 @@ function requireNative() {
|
|
|
392
440
|
try {
|
|
393
441
|
const binding = require('@d0paminedriven/pdfdown-ocr-linux-riscv64-musl')
|
|
394
442
|
const bindingPackageVersion = require('@d0paminedriven/pdfdown-ocr-linux-riscv64-musl/package.json').version
|
|
395
|
-
if (bindingPackageVersion !== '0.9.
|
|
396
|
-
throw new Error(`Native binding package version mismatch, expected 0.9.
|
|
443
|
+
if (bindingPackageVersion !== '0.9.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
444
|
+
throw new Error(`Native binding package version mismatch, expected 0.9.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
397
445
|
}
|
|
398
446
|
return binding
|
|
399
447
|
} catch (e) {
|
|
@@ -408,8 +456,8 @@ function requireNative() {
|
|
|
408
456
|
try {
|
|
409
457
|
const binding = require('@d0paminedriven/pdfdown-ocr-linux-riscv64-gnu')
|
|
410
458
|
const bindingPackageVersion = require('@d0paminedriven/pdfdown-ocr-linux-riscv64-gnu/package.json').version
|
|
411
|
-
if (bindingPackageVersion !== '0.9.
|
|
412
|
-
throw new Error(`Native binding package version mismatch, expected 0.9.
|
|
459
|
+
if (bindingPackageVersion !== '0.9.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
460
|
+
throw new Error(`Native binding package version mismatch, expected 0.9.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
413
461
|
}
|
|
414
462
|
return binding
|
|
415
463
|
} catch (e) {
|
|
@@ -425,8 +473,8 @@ function requireNative() {
|
|
|
425
473
|
try {
|
|
426
474
|
const binding = require('@d0paminedriven/pdfdown-ocr-linux-ppc64-gnu')
|
|
427
475
|
const bindingPackageVersion = require('@d0paminedriven/pdfdown-ocr-linux-ppc64-gnu/package.json').version
|
|
428
|
-
if (bindingPackageVersion !== '0.9.
|
|
429
|
-
throw new Error(`Native binding package version mismatch, expected 0.9.
|
|
476
|
+
if (bindingPackageVersion !== '0.9.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
477
|
+
throw new Error(`Native binding package version mismatch, expected 0.9.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
430
478
|
}
|
|
431
479
|
return binding
|
|
432
480
|
} catch (e) {
|
|
@@ -441,8 +489,8 @@ function requireNative() {
|
|
|
441
489
|
try {
|
|
442
490
|
const binding = require('@d0paminedriven/pdfdown-ocr-linux-s390x-gnu')
|
|
443
491
|
const bindingPackageVersion = require('@d0paminedriven/pdfdown-ocr-linux-s390x-gnu/package.json').version
|
|
444
|
-
if (bindingPackageVersion !== '0.9.
|
|
445
|
-
throw new Error(`Native binding package version mismatch, expected 0.9.
|
|
492
|
+
if (bindingPackageVersion !== '0.9.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
493
|
+
throw new Error(`Native binding package version mismatch, expected 0.9.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
446
494
|
}
|
|
447
495
|
return binding
|
|
448
496
|
} catch (e) {
|
|
@@ -461,8 +509,8 @@ function requireNative() {
|
|
|
461
509
|
try {
|
|
462
510
|
const binding = require('@d0paminedriven/pdfdown-ocr-openharmony-arm64')
|
|
463
511
|
const bindingPackageVersion = require('@d0paminedriven/pdfdown-ocr-openharmony-arm64/package.json').version
|
|
464
|
-
if (bindingPackageVersion !== '0.9.
|
|
465
|
-
throw new Error(`Native binding package version mismatch, expected 0.9.
|
|
512
|
+
if (bindingPackageVersion !== '0.9.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
513
|
+
throw new Error(`Native binding package version mismatch, expected 0.9.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
466
514
|
}
|
|
467
515
|
return binding
|
|
468
516
|
} catch (e) {
|
|
@@ -477,8 +525,8 @@ function requireNative() {
|
|
|
477
525
|
try {
|
|
478
526
|
const binding = require('@d0paminedriven/pdfdown-ocr-openharmony-x64')
|
|
479
527
|
const bindingPackageVersion = require('@d0paminedriven/pdfdown-ocr-openharmony-x64/package.json').version
|
|
480
|
-
if (bindingPackageVersion !== '0.9.
|
|
481
|
-
throw new Error(`Native binding package version mismatch, expected 0.9.
|
|
528
|
+
if (bindingPackageVersion !== '0.9.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
529
|
+
throw new Error(`Native binding package version mismatch, expected 0.9.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
482
530
|
}
|
|
483
531
|
return binding
|
|
484
532
|
} catch (e) {
|
|
@@ -493,8 +541,8 @@ function requireNative() {
|
|
|
493
541
|
try {
|
|
494
542
|
const binding = require('@d0paminedriven/pdfdown-ocr-openharmony-arm')
|
|
495
543
|
const bindingPackageVersion = require('@d0paminedriven/pdfdown-ocr-openharmony-arm/package.json').version
|
|
496
|
-
if (bindingPackageVersion !== '0.9.
|
|
497
|
-
throw new Error(`Native binding package version mismatch, expected 0.9.
|
|
544
|
+
if (bindingPackageVersion !== '0.9.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
545
|
+
throw new Error(`Native binding package version mismatch, expected 0.9.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
498
546
|
}
|
|
499
547
|
return binding
|
|
500
548
|
} catch (e) {
|
|
@@ -508,54 +556,284 @@ function requireNative() {
|
|
|
508
556
|
}
|
|
509
557
|
}
|
|
510
558
|
|
|
511
|
-
|
|
559
|
+
function createLoadErrorChain(errors) {
|
|
560
|
+
return errors.reduce((previous, current) => {
|
|
561
|
+
let message
|
|
562
|
+
try {
|
|
563
|
+
message =
|
|
564
|
+
current && typeof current.message === 'string'
|
|
565
|
+
? current.message
|
|
566
|
+
: String(current)
|
|
567
|
+
} catch {
|
|
568
|
+
message = 'Unknown error'
|
|
569
|
+
}
|
|
570
|
+
const error = new Error(message)
|
|
571
|
+
error.cause = previous
|
|
572
|
+
return error
|
|
573
|
+
}, null)
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
// NAPI_RS_FORCE_WASI is a tri-state flag:
|
|
577
|
+
// unset / any other value → native binding preferred, WASI is only a fallback
|
|
578
|
+
// 'true' → prefer WASI, but retain native as a lazy fallback
|
|
579
|
+
// 'error' → require WASI without initializing a native fallback
|
|
580
|
+
// Treating any non-empty string as truthy (the historical behavior) meant
|
|
581
|
+
// NAPI_RS_FORCE_WASI=false, NAPI_RS_FORCE_WASI=0, etc. inadvertently triggered
|
|
582
|
+
// the WASI path, causing ENOENT for packages shipped without a .wasi.cjs file.
|
|
583
|
+
//
|
|
584
|
+
// NAPI_RS_WASI_FLAVOR selects one exact generated flavor and implies strict
|
|
585
|
+
// WASI loading. It never crosses into another flavor or falls back to native.
|
|
586
|
+
const __napiWasiFlavors = ['wasm32-wasi']
|
|
587
|
+
const __napiWasiFlavor = process.env.NAPI_RS_WASI_FLAVOR
|
|
588
|
+
const __napiWasiFlavorRequested =
|
|
589
|
+
typeof __napiWasiFlavor === 'string' && __napiWasiFlavor.length > 0
|
|
590
|
+
if (
|
|
591
|
+
__napiWasiFlavorRequested &&
|
|
592
|
+
__napiWasiFlavors.indexOf(__napiWasiFlavor) === -1
|
|
593
|
+
) {
|
|
594
|
+
throw new Error(
|
|
595
|
+
'Unsupported WASI flavor "' +
|
|
596
|
+
__napiWasiFlavor +
|
|
597
|
+
'". Available flavors: ' +
|
|
598
|
+
__napiWasiFlavors.join(', '),
|
|
599
|
+
)
|
|
600
|
+
}
|
|
601
|
+
const forceWasiError = process.env.NAPI_RS_FORCE_WASI === 'error'
|
|
602
|
+
const forceWasi =
|
|
603
|
+
process.env.NAPI_RS_FORCE_WASI === 'true' ||
|
|
604
|
+
forceWasiError ||
|
|
605
|
+
__napiWasiFlavorRequested
|
|
606
|
+
|
|
607
|
+
if (!forceWasi) {
|
|
608
|
+
nativeBinding = requireNative()
|
|
609
|
+
__napiRequiredNativeBinding = nativeBinding
|
|
610
|
+
}
|
|
512
611
|
|
|
513
|
-
if (!nativeBinding ||
|
|
612
|
+
if (!nativeBinding || forceWasi) {
|
|
514
613
|
let wasiBinding = null
|
|
515
|
-
let
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
614
|
+
let wasiBindingLoaded = false
|
|
615
|
+
const wasiBindingErrors = []
|
|
616
|
+
const __napiWasiResolveCandidate = (specifier, isPackage, localArtifacts) => {
|
|
617
|
+
try {
|
|
618
|
+
require.resolve(specifier)
|
|
619
|
+
} catch (resolveError) {
|
|
620
|
+
if (!resolveError || resolveError.code !== 'MODULE_NOT_FOUND') {
|
|
621
|
+
throw resolveError
|
|
622
|
+
}
|
|
623
|
+
if (isPackage) {
|
|
624
|
+
try {
|
|
625
|
+
require.resolve(specifier + '/package.json')
|
|
626
|
+
} catch (packageError) {
|
|
627
|
+
if (packageError && packageError.code === 'MODULE_NOT_FOUND') {
|
|
628
|
+
return resolveError
|
|
629
|
+
}
|
|
630
|
+
// An exports restriction proves the package exists even when its
|
|
631
|
+
// package.json is not public. Preserve the root resolution failure.
|
|
632
|
+
throw resolveError
|
|
633
|
+
}
|
|
634
|
+
// The package exists but its main/export target is broken.
|
|
635
|
+
throw resolveError
|
|
636
|
+
}
|
|
637
|
+
return resolveError
|
|
638
|
+
}
|
|
639
|
+
if (localArtifacts) {
|
|
640
|
+
let artifactError = null
|
|
641
|
+
for (let i = 0; i < localArtifacts.length; i++) {
|
|
642
|
+
try {
|
|
643
|
+
require.resolve(localArtifacts[i])
|
|
644
|
+
return null
|
|
645
|
+
} catch (resolveError) {
|
|
646
|
+
if (!resolveError || resolveError.code !== 'MODULE_NOT_FOUND') {
|
|
647
|
+
throw resolveError
|
|
648
|
+
}
|
|
649
|
+
artifactError = resolveError
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
return artifactError
|
|
522
653
|
}
|
|
654
|
+
return null
|
|
523
655
|
}
|
|
524
|
-
if (!
|
|
656
|
+
if (!wasiBindingLoaded && (!__napiWasiFlavorRequested || __napiWasiFlavor === 'wasm32-wasi')) {
|
|
657
|
+
let candidateError = null
|
|
658
|
+
let candidateFailed = false
|
|
525
659
|
try {
|
|
526
|
-
|
|
527
|
-
|
|
660
|
+
candidateError = __napiWasiResolveCandidate('./pdfdown_ocr.wasi.cjs', false, ['./pdfdown_ocr.wasm32-wasi.debug.wasm', './pdfdown_ocr.wasm32-wasi.wasm'])
|
|
661
|
+
candidateFailed = candidateError !== null
|
|
662
|
+
if (!candidateFailed) {
|
|
663
|
+
wasiBinding = require('./pdfdown_ocr.wasi.cjs')
|
|
664
|
+
nativeBinding = wasiBinding
|
|
665
|
+
__napiLoadedBindingTarget = 'wasm32-wasi'
|
|
666
|
+
wasiBindingLoaded = true
|
|
667
|
+
}
|
|
528
668
|
} catch (err) {
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
669
|
+
candidateError = err
|
|
670
|
+
candidateFailed = true
|
|
671
|
+
}
|
|
672
|
+
if (candidateFailed) {
|
|
673
|
+
wasiBindingErrors.push(candidateError)
|
|
674
|
+
loadErrors.push(candidateError)
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
if (!wasiBindingLoaded && (!__napiWasiFlavorRequested || __napiWasiFlavor === 'wasm32-wasi')) {
|
|
678
|
+
let candidateError = null
|
|
679
|
+
let candidateFailed = false
|
|
680
|
+
try {
|
|
681
|
+
candidateError = __napiWasiResolveCandidate('@d0paminedriven/pdfdown-ocr-wasm32-wasi', true, undefined)
|
|
682
|
+
candidateFailed = candidateError !== null
|
|
683
|
+
if (!candidateFailed) {
|
|
684
|
+
if (process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
685
|
+
const bindingPackageVersion = require('@d0paminedriven/pdfdown-ocr-wasm32-wasi/package.json').version
|
|
686
|
+
if (bindingPackageVersion !== '0.9.9') {
|
|
687
|
+
throw new Error(`WASI binding package version mismatch, expected 0.9.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
wasiBinding = require('@d0paminedriven/pdfdown-ocr-wasm32-wasi')
|
|
691
|
+
nativeBinding = wasiBinding
|
|
692
|
+
__napiLoadedBindingTarget = 'wasm32-wasi'
|
|
693
|
+
wasiBindingLoaded = true
|
|
532
694
|
}
|
|
695
|
+
} catch (err) {
|
|
696
|
+
candidateError = err
|
|
697
|
+
candidateFailed = true
|
|
698
|
+
}
|
|
699
|
+
if (candidateFailed) {
|
|
700
|
+
wasiBindingErrors.push(candidateError)
|
|
701
|
+
loadErrors.push(candidateError)
|
|
533
702
|
}
|
|
534
703
|
}
|
|
535
|
-
if (
|
|
536
|
-
|
|
537
|
-
|
|
704
|
+
if (
|
|
705
|
+
!wasiBindingLoaded &&
|
|
706
|
+
forceWasi &&
|
|
707
|
+
!forceWasiError &&
|
|
708
|
+
!__napiWasiFlavorRequested
|
|
709
|
+
) {
|
|
710
|
+
nativeBinding = requireNative()
|
|
711
|
+
__napiRequiredNativeBinding = nativeBinding
|
|
712
|
+
}
|
|
713
|
+
if ((forceWasiError || __napiWasiFlavorRequested) && !wasiBindingLoaded) {
|
|
714
|
+
const error = new Error(
|
|
715
|
+
__napiWasiFlavorRequested
|
|
716
|
+
? 'WASI binding for flavor "' + __napiWasiFlavor + '" not found'
|
|
717
|
+
: 'WASI binding not found and NAPI_RS_FORCE_WASI is set to error',
|
|
718
|
+
)
|
|
719
|
+
error.cause = createLoadErrorChain(wasiBindingErrors)
|
|
538
720
|
throw error
|
|
539
721
|
}
|
|
540
722
|
}
|
|
541
723
|
|
|
542
724
|
if (!nativeBinding) {
|
|
543
725
|
if (loadErrors.length > 0) {
|
|
544
|
-
|
|
726
|
+
const error = new Error(
|
|
545
727
|
`Cannot find native binding. ` +
|
|
546
728
|
`npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). ` +
|
|
547
729
|
'Please try `npm i` again after removing both package-lock.json and node_modules directory.',
|
|
548
|
-
{
|
|
549
|
-
cause: loadErrors.reduce((err, cur) => {
|
|
550
|
-
cur.cause = err
|
|
551
|
-
return cur
|
|
552
|
-
}),
|
|
553
|
-
},
|
|
554
730
|
)
|
|
731
|
+
// assign instead of the `new Error(message, { cause })` options form,
|
|
732
|
+
// which Node < 16.9 silently ignores
|
|
733
|
+
error.cause = createLoadErrorChain(loadErrors)
|
|
734
|
+
throw error
|
|
555
735
|
}
|
|
556
736
|
throw new Error(`Failed to load native binding`)
|
|
557
737
|
}
|
|
558
738
|
|
|
739
|
+
// A package can patch its own fallback in front of the load-failure check
|
|
740
|
+
// above, e.g. a WebContainer download through `napi-postinstall/fallback`.
|
|
741
|
+
// That fallback swaps `nativeBinding` for a generated WASI loader, which has
|
|
742
|
+
// already stamped its own flavor, while the target above still says 'native'.
|
|
743
|
+
// Take that flavor over, or the CommonJS stamp throws a conflict and the ESM
|
|
744
|
+
// export reports the wrong artifact. Three limits keep the conflict check:
|
|
745
|
+
// - only a binding this loader did not load itself, so a native addon whose
|
|
746
|
+
// `#[napi(module_exports)]` hook claims the name is still rejected;
|
|
747
|
+
// - only an own data property, read through its descriptor, so no addon
|
|
748
|
+
// getter runs here, and it must read back the same, as the stamp reads it;
|
|
749
|
+
// - only a flavor in `__napiWasiFlavors`, the ones this loader's own WASI
|
|
750
|
+
// chain can report ('wasm32-wasi' for a package without a WASI target).
|
|
751
|
+
// This is metadata and never fails a load: a throwing Proxy trap keeps 'native'.
|
|
752
|
+
if (
|
|
753
|
+
__napiLoadedBindingTarget === 'native' &&
|
|
754
|
+
nativeBinding !== __napiRequiredNativeBinding
|
|
755
|
+
) {
|
|
756
|
+
try {
|
|
757
|
+
const __napiBindingTargetDescriptor = Object.getOwnPropertyDescriptor(
|
|
758
|
+
nativeBinding,
|
|
759
|
+
'__napiBindingTarget',
|
|
760
|
+
)
|
|
761
|
+
if (
|
|
762
|
+
__napiBindingTargetDescriptor &&
|
|
763
|
+
__napiWasiFlavors.indexOf(__napiBindingTargetDescriptor.value) !== -1 &&
|
|
764
|
+
nativeBinding.__napiBindingTarget === __napiBindingTargetDescriptor.value
|
|
765
|
+
) {
|
|
766
|
+
__napiLoadedBindingTarget = __napiBindingTargetDescriptor.value
|
|
767
|
+
}
|
|
768
|
+
} catch {
|
|
769
|
+
// keep 'native'
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
function __napiStampBindingTarget(exportsObject, target) {
|
|
774
|
+
if (
|
|
775
|
+
Object.prototype.hasOwnProperty.call(exportsObject, '__napiBindingTarget')
|
|
776
|
+
) {
|
|
777
|
+
if (exportsObject.__napiBindingTarget === target) {
|
|
778
|
+
// Already ours: the root entry aliases the object it loaded, so a WASI
|
|
779
|
+
// fallback candidate — or a `NAPI_RS_NATIVE_LIBRARY_PATH` override that
|
|
780
|
+
// is a generated loader — arrives already stamped with this same value.
|
|
781
|
+
return target
|
|
782
|
+
}
|
|
783
|
+
const error = new Error(
|
|
784
|
+
'`__napiBindingTarget` is reserved by the generated binding loader, but the loaded binding already exports it. Rename the export, e.g. #[napi(js_name = "...")].',
|
|
785
|
+
)
|
|
786
|
+
error.code = 'ERR_NAPI_BINDING_TARGET_CONFLICT'
|
|
787
|
+
throw error
|
|
788
|
+
}
|
|
789
|
+
if (!Object.isExtensible(exportsObject)) {
|
|
790
|
+
// A `#[napi(module_exports)]` hook may seal or freeze this object
|
|
791
|
+
// (`Object::seal` / `Object::freeze`). Reporting the artifact is metadata,
|
|
792
|
+
// never a reason to fail an otherwise successful load, so the stamp is
|
|
793
|
+
// skipped. What a consumer still sees then follows the entry point: the
|
|
794
|
+
// browser and deferred loaders declare `__napiBindingTarget` at module
|
|
795
|
+
// level and go on reporting it, while the CommonJS entries hand back this
|
|
796
|
+
// very object as `module.exports`, so there the value is absent.
|
|
797
|
+
return target
|
|
798
|
+
}
|
|
799
|
+
try {
|
|
800
|
+
// [[Define]], not [[Set]]: an ordinary assignment walks the prototype
|
|
801
|
+
// chain, so an inherited accessor could swallow the value or throw and
|
|
802
|
+
// fail an otherwise successful load. The descriptor is what a successful
|
|
803
|
+
// assignment would have produced.
|
|
804
|
+
Object.defineProperty(exportsObject, '__napiBindingTarget', {
|
|
805
|
+
configurable: true,
|
|
806
|
+
enumerable: true,
|
|
807
|
+
value: target,
|
|
808
|
+
writable: true,
|
|
809
|
+
})
|
|
810
|
+
} catch {
|
|
811
|
+
// Same rule as the non-extensible skip above: reporting the artifact is
|
|
812
|
+
// metadata, never a reason to fail an otherwise successful load. An exotic
|
|
813
|
+
// object (a Proxy whose defineProperty trap refuses) is skipped, not
|
|
814
|
+
// thrown over.
|
|
815
|
+
}
|
|
816
|
+
// The CommonJS loaders assign this return value so `cjs-module-lexer` — and
|
|
817
|
+
// therefore Node's CJS -> ESM named export detection — can see
|
|
818
|
+
// `__napiBindingTarget` statically.
|
|
819
|
+
return target
|
|
820
|
+
}
|
|
821
|
+
// Stamp before the alias, not after. The guard only reads `nativeBinding`
|
|
822
|
+
// (`hasOwnProperty` plus a comparison), which is safe against any addon
|
|
823
|
+
// accessor; an assignment is not, because a `#[napi(module_exports)]` hook can
|
|
824
|
+
// expose a getter reporting this very value and a setter that throws. So the
|
|
825
|
+
// assignment lands on the loader's own `module.exports`, still the original
|
|
826
|
+
// object here, and the alias below replaces it.
|
|
827
|
+
//
|
|
828
|
+
// The assignment is what keeps the marker a statically visible CommonJS export:
|
|
829
|
+
// `cjs-module-lexer` is Node's CJS -> ESM named export detection, it cannot see
|
|
830
|
+
// a bare call, and the later `module.exports = nativeBinding` does not undo the
|
|
831
|
+
// detection. The assignment itself always succeeds — its target is this
|
|
832
|
+
// loader's own, still extensible `module.exports` — and the alias below then
|
|
833
|
+
// discards the value it wrote. What a consumer reads is whatever the guard put
|
|
834
|
+
// on `nativeBinding`, so on a frozen binding, where the guard skips, the
|
|
835
|
+
// linked import resolves to `undefined`.
|
|
836
|
+
module.exports.__napiBindingTarget = __napiStampBindingTarget(nativeBinding, __napiLoadedBindingTarget)
|
|
559
837
|
module.exports = nativeBinding
|
|
560
838
|
module.exports.PdfDown = nativeBinding.PdfDown
|
|
561
839
|
module.exports.BoxType = nativeBinding.BoxType
|