@teddyzhu/clipboard 0.0.6 → 0.0.7

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.
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/index.js CHANGED
@@ -3,9 +3,6 @@
3
3
  // @ts-nocheck
4
4
  /* auto-generated by NAPI-RS */
5
5
 
6
- const { createRequire } = require('node:module')
7
- require = createRequire(__filename)
8
-
9
6
  const { readFileSync } = require('node:fs')
10
7
  let nativeBinding = null
11
8
  const loadErrors = []
@@ -66,7 +63,7 @@ const isMuslFromChildProcess = () => {
66
63
  function requireNative() {
67
64
  if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) {
68
65
  try {
69
- nativeBinding = require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH);
66
+ return require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH);
70
67
  } catch (err) {
71
68
  loadErrors.push(err)
72
69
  }
@@ -78,7 +75,12 @@ function requireNative() {
78
75
  loadErrors.push(e)
79
76
  }
80
77
  try {
81
- return require('@teddyzhu/clipboard-android-arm64')
78
+ const binding = require('@teddyzhu/clipboard-android-arm64')
79
+ const bindingPackageVersion = require('@teddyzhu/clipboard-android-arm64/package.json').version
80
+ if (bindingPackageVersion !== '0.0.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
81
+ throw new Error(`Native binding package version mismatch, expected 0.0.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
82
+ }
83
+ return binding
82
84
  } catch (e) {
83
85
  loadErrors.push(e)
84
86
  }
@@ -89,7 +91,12 @@ function requireNative() {
89
91
  loadErrors.push(e)
90
92
  }
91
93
  try {
92
- return require('@teddyzhu/clipboard-android-arm-eabi')
94
+ const binding = require('@teddyzhu/clipboard-android-arm-eabi')
95
+ const bindingPackageVersion = require('@teddyzhu/clipboard-android-arm-eabi/package.json').version
96
+ if (bindingPackageVersion !== '0.0.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
97
+ throw new Error(`Native binding package version mismatch, expected 0.0.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
98
+ }
99
+ return binding
93
100
  } catch (e) {
94
101
  loadErrors.push(e)
95
102
  }
@@ -98,16 +105,39 @@ function requireNative() {
98
105
  }
99
106
  } else if (process.platform === 'win32') {
100
107
  if (process.arch === 'x64') {
108
+ if (process.config?.variables?.shlib_suffix === 'dll.a' || process.config?.variables?.node_target_type === 'shared_library') {
109
+ try {
110
+ return require('./clipboard.win32-x64-gnu.node')
111
+ } catch (e) {
112
+ loadErrors.push(e)
113
+ }
101
114
  try {
115
+ const binding = require('@teddyzhu/clipboard-win32-x64-gnu')
116
+ const bindingPackageVersion = require('@teddyzhu/clipboard-win32-x64-gnu/package.json').version
117
+ if (bindingPackageVersion !== '0.0.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
118
+ throw new Error(`Native binding package version mismatch, expected 0.0.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
119
+ }
120
+ return binding
121
+ } catch (e) {
122
+ loadErrors.push(e)
123
+ }
124
+ } else {
125
+ try {
102
126
  return require('./clipboard.win32-x64-msvc.node')
103
127
  } catch (e) {
104
128
  loadErrors.push(e)
105
129
  }
106
130
  try {
107
- return require('@teddyzhu/clipboard-win32-x64-msvc')
131
+ const binding = require('@teddyzhu/clipboard-win32-x64-msvc')
132
+ const bindingPackageVersion = require('@teddyzhu/clipboard-win32-x64-msvc/package.json').version
133
+ if (bindingPackageVersion !== '0.0.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
134
+ throw new Error(`Native binding package version mismatch, expected 0.0.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
135
+ }
136
+ return binding
108
137
  } catch (e) {
109
138
  loadErrors.push(e)
110
139
  }
140
+ }
111
141
  } else if (process.arch === 'ia32') {
112
142
  try {
113
143
  return require('./clipboard.win32-ia32-msvc.node')
@@ -115,7 +145,12 @@ function requireNative() {
115
145
  loadErrors.push(e)
116
146
  }
117
147
  try {
118
- return require('@teddyzhu/clipboard-win32-ia32-msvc')
148
+ const binding = require('@teddyzhu/clipboard-win32-ia32-msvc')
149
+ const bindingPackageVersion = require('@teddyzhu/clipboard-win32-ia32-msvc/package.json').version
150
+ if (bindingPackageVersion !== '0.0.7' && 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.0.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
152
+ }
153
+ return binding
119
154
  } catch (e) {
120
155
  loadErrors.push(e)
121
156
  }
@@ -126,7 +161,12 @@ function requireNative() {
126
161
  loadErrors.push(e)
127
162
  }
128
163
  try {
129
- return require('@teddyzhu/clipboard-win32-arm64-msvc')
164
+ const binding = require('@teddyzhu/clipboard-win32-arm64-msvc')
165
+ const bindingPackageVersion = require('@teddyzhu/clipboard-win32-arm64-msvc/package.json').version
166
+ if (bindingPackageVersion !== '0.0.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
167
+ throw new Error(`Native binding package version mismatch, expected 0.0.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
168
+ }
169
+ return binding
130
170
  } catch (e) {
131
171
  loadErrors.push(e)
132
172
  }
@@ -140,7 +180,12 @@ function requireNative() {
140
180
  loadErrors.push(e)
141
181
  }
142
182
  try {
143
- return require('@teddyzhu/clipboard-darwin-universal')
183
+ const binding = require('@teddyzhu/clipboard-darwin-universal')
184
+ const bindingPackageVersion = require('@teddyzhu/clipboard-darwin-universal/package.json').version
185
+ if (bindingPackageVersion !== '0.0.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
186
+ throw new Error(`Native binding package version mismatch, expected 0.0.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
187
+ }
188
+ return binding
144
189
  } catch (e) {
145
190
  loadErrors.push(e)
146
191
  }
@@ -151,7 +196,12 @@ function requireNative() {
151
196
  loadErrors.push(e)
152
197
  }
153
198
  try {
154
- return require('@teddyzhu/clipboard-darwin-x64')
199
+ const binding = require('@teddyzhu/clipboard-darwin-x64')
200
+ const bindingPackageVersion = require('@teddyzhu/clipboard-darwin-x64/package.json').version
201
+ if (bindingPackageVersion !== '0.0.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
202
+ throw new Error(`Native binding package version mismatch, expected 0.0.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
203
+ }
204
+ return binding
155
205
  } catch (e) {
156
206
  loadErrors.push(e)
157
207
  }
@@ -162,7 +212,12 @@ function requireNative() {
162
212
  loadErrors.push(e)
163
213
  }
164
214
  try {
165
- return require('@teddyzhu/clipboard-darwin-arm64')
215
+ const binding = require('@teddyzhu/clipboard-darwin-arm64')
216
+ const bindingPackageVersion = require('@teddyzhu/clipboard-darwin-arm64/package.json').version
217
+ if (bindingPackageVersion !== '0.0.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
218
+ throw new Error(`Native binding package version mismatch, expected 0.0.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
219
+ }
220
+ return binding
166
221
  } catch (e) {
167
222
  loadErrors.push(e)
168
223
  }
@@ -177,7 +232,12 @@ function requireNative() {
177
232
  loadErrors.push(e)
178
233
  }
179
234
  try {
180
- return require('@teddyzhu/clipboard-freebsd-x64')
235
+ const binding = require('@teddyzhu/clipboard-freebsd-x64')
236
+ const bindingPackageVersion = require('@teddyzhu/clipboard-freebsd-x64/package.json').version
237
+ if (bindingPackageVersion !== '0.0.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
238
+ throw new Error(`Native binding package version mismatch, expected 0.0.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
239
+ }
240
+ return binding
181
241
  } catch (e) {
182
242
  loadErrors.push(e)
183
243
  }
@@ -188,7 +248,12 @@ function requireNative() {
188
248
  loadErrors.push(e)
189
249
  }
190
250
  try {
191
- return require('@teddyzhu/clipboard-freebsd-arm64')
251
+ const binding = require('@teddyzhu/clipboard-freebsd-arm64')
252
+ const bindingPackageVersion = require('@teddyzhu/clipboard-freebsd-arm64/package.json').version
253
+ if (bindingPackageVersion !== '0.0.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
254
+ throw new Error(`Native binding package version mismatch, expected 0.0.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
255
+ }
256
+ return binding
192
257
  } catch (e) {
193
258
  loadErrors.push(e)
194
259
  }
@@ -204,7 +269,12 @@ function requireNative() {
204
269
  loadErrors.push(e)
205
270
  }
206
271
  try {
207
- return require('@teddyzhu/clipboard-linux-x64-musl')
272
+ const binding = require('@teddyzhu/clipboard-linux-x64-musl')
273
+ const bindingPackageVersion = require('@teddyzhu/clipboard-linux-x64-musl/package.json').version
274
+ if (bindingPackageVersion !== '0.0.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
275
+ throw new Error(`Native binding package version mismatch, expected 0.0.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
276
+ }
277
+ return binding
208
278
  } catch (e) {
209
279
  loadErrors.push(e)
210
280
  }
@@ -215,7 +285,12 @@ function requireNative() {
215
285
  loadErrors.push(e)
216
286
  }
217
287
  try {
218
- return require('@teddyzhu/clipboard-linux-x64-gnu')
288
+ const binding = require('@teddyzhu/clipboard-linux-x64-gnu')
289
+ const bindingPackageVersion = require('@teddyzhu/clipboard-linux-x64-gnu/package.json').version
290
+ if (bindingPackageVersion !== '0.0.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
291
+ throw new Error(`Native binding package version mismatch, expected 0.0.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
292
+ }
293
+ return binding
219
294
  } catch (e) {
220
295
  loadErrors.push(e)
221
296
  }
@@ -228,7 +303,12 @@ function requireNative() {
228
303
  loadErrors.push(e)
229
304
  }
230
305
  try {
231
- return require('@teddyzhu/clipboard-linux-arm64-musl')
306
+ const binding = require('@teddyzhu/clipboard-linux-arm64-musl')
307
+ const bindingPackageVersion = require('@teddyzhu/clipboard-linux-arm64-musl/package.json').version
308
+ if (bindingPackageVersion !== '0.0.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
309
+ throw new Error(`Native binding package version mismatch, expected 0.0.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
310
+ }
311
+ return binding
232
312
  } catch (e) {
233
313
  loadErrors.push(e)
234
314
  }
@@ -239,7 +319,12 @@ function requireNative() {
239
319
  loadErrors.push(e)
240
320
  }
241
321
  try {
242
- return require('@teddyzhu/clipboard-linux-arm64-gnu')
322
+ const binding = require('@teddyzhu/clipboard-linux-arm64-gnu')
323
+ const bindingPackageVersion = require('@teddyzhu/clipboard-linux-arm64-gnu/package.json').version
324
+ if (bindingPackageVersion !== '0.0.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
325
+ throw new Error(`Native binding package version mismatch, expected 0.0.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
326
+ }
327
+ return binding
243
328
  } catch (e) {
244
329
  loadErrors.push(e)
245
330
  }
@@ -252,7 +337,12 @@ function requireNative() {
252
337
  loadErrors.push(e)
253
338
  }
254
339
  try {
255
- return require('@teddyzhu/clipboard-linux-arm-musleabihf')
340
+ const binding = require('@teddyzhu/clipboard-linux-arm-musleabihf')
341
+ const bindingPackageVersion = require('@teddyzhu/clipboard-linux-arm-musleabihf/package.json').version
342
+ if (bindingPackageVersion !== '0.0.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
343
+ throw new Error(`Native binding package version mismatch, expected 0.0.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
344
+ }
345
+ return binding
256
346
  } catch (e) {
257
347
  loadErrors.push(e)
258
348
  }
@@ -263,7 +353,46 @@ function requireNative() {
263
353
  loadErrors.push(e)
264
354
  }
265
355
  try {
266
- return require('@teddyzhu/clipboard-linux-arm-gnueabihf')
356
+ const binding = require('@teddyzhu/clipboard-linux-arm-gnueabihf')
357
+ const bindingPackageVersion = require('@teddyzhu/clipboard-linux-arm-gnueabihf/package.json').version
358
+ if (bindingPackageVersion !== '0.0.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
359
+ throw new Error(`Native binding package version mismatch, expected 0.0.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
360
+ }
361
+ return binding
362
+ } catch (e) {
363
+ loadErrors.push(e)
364
+ }
365
+ }
366
+ } else if (process.arch === 'loong64') {
367
+ if (isMusl()) {
368
+ try {
369
+ return require('./clipboard.linux-loong64-musl.node')
370
+ } catch (e) {
371
+ loadErrors.push(e)
372
+ }
373
+ try {
374
+ const binding = require('@teddyzhu/clipboard-linux-loong64-musl')
375
+ const bindingPackageVersion = require('@teddyzhu/clipboard-linux-loong64-musl/package.json').version
376
+ if (bindingPackageVersion !== '0.0.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
377
+ throw new Error(`Native binding package version mismatch, expected 0.0.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
378
+ }
379
+ return binding
380
+ } catch (e) {
381
+ loadErrors.push(e)
382
+ }
383
+ } else {
384
+ try {
385
+ return require('./clipboard.linux-loong64-gnu.node')
386
+ } catch (e) {
387
+ loadErrors.push(e)
388
+ }
389
+ try {
390
+ const binding = require('@teddyzhu/clipboard-linux-loong64-gnu')
391
+ const bindingPackageVersion = require('@teddyzhu/clipboard-linux-loong64-gnu/package.json').version
392
+ if (bindingPackageVersion !== '0.0.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
393
+ throw new Error(`Native binding package version mismatch, expected 0.0.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
394
+ }
395
+ return binding
267
396
  } catch (e) {
268
397
  loadErrors.push(e)
269
398
  }
@@ -276,7 +405,12 @@ function requireNative() {
276
405
  loadErrors.push(e)
277
406
  }
278
407
  try {
279
- return require('@teddyzhu/clipboard-linux-riscv64-musl')
408
+ const binding = require('@teddyzhu/clipboard-linux-riscv64-musl')
409
+ const bindingPackageVersion = require('@teddyzhu/clipboard-linux-riscv64-musl/package.json').version
410
+ if (bindingPackageVersion !== '0.0.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
411
+ throw new Error(`Native binding package version mismatch, expected 0.0.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
412
+ }
413
+ return binding
280
414
  } catch (e) {
281
415
  loadErrors.push(e)
282
416
  }
@@ -287,7 +421,12 @@ function requireNative() {
287
421
  loadErrors.push(e)
288
422
  }
289
423
  try {
290
- return require('@teddyzhu/clipboard-linux-riscv64-gnu')
424
+ const binding = require('@teddyzhu/clipboard-linux-riscv64-gnu')
425
+ const bindingPackageVersion = require('@teddyzhu/clipboard-linux-riscv64-gnu/package.json').version
426
+ if (bindingPackageVersion !== '0.0.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
427
+ throw new Error(`Native binding package version mismatch, expected 0.0.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
428
+ }
429
+ return binding
291
430
  } catch (e) {
292
431
  loadErrors.push(e)
293
432
  }
@@ -299,7 +438,12 @@ function requireNative() {
299
438
  loadErrors.push(e)
300
439
  }
301
440
  try {
302
- return require('@teddyzhu/clipboard-linux-ppc64-gnu')
441
+ const binding = require('@teddyzhu/clipboard-linux-ppc64-gnu')
442
+ const bindingPackageVersion = require('@teddyzhu/clipboard-linux-ppc64-gnu/package.json').version
443
+ if (bindingPackageVersion !== '0.0.7' && 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.0.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
445
+ }
446
+ return binding
303
447
  } catch (e) {
304
448
  loadErrors.push(e)
305
449
  }
@@ -310,7 +454,12 @@ function requireNative() {
310
454
  loadErrors.push(e)
311
455
  }
312
456
  try {
313
- return require('@teddyzhu/clipboard-linux-s390x-gnu')
457
+ const binding = require('@teddyzhu/clipboard-linux-s390x-gnu')
458
+ const bindingPackageVersion = require('@teddyzhu/clipboard-linux-s390x-gnu/package.json').version
459
+ if (bindingPackageVersion !== '0.0.7' && 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.0.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
461
+ }
462
+ return binding
314
463
  } catch (e) {
315
464
  loadErrors.push(e)
316
465
  }
@@ -320,34 +469,49 @@ function requireNative() {
320
469
  } else if (process.platform === 'openharmony') {
321
470
  if (process.arch === 'arm64') {
322
471
  try {
323
- return require('./clipboard.linux-arm64-ohos.node')
472
+ return require('./clipboard.openharmony-arm64.node')
324
473
  } catch (e) {
325
474
  loadErrors.push(e)
326
475
  }
327
476
  try {
328
- return require('@teddyzhu/clipboard-linux-arm64-ohos')
477
+ const binding = require('@teddyzhu/clipboard-openharmony-arm64')
478
+ const bindingPackageVersion = require('@teddyzhu/clipboard-openharmony-arm64/package.json').version
479
+ if (bindingPackageVersion !== '0.0.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
480
+ throw new Error(`Native binding package version mismatch, expected 0.0.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
481
+ }
482
+ return binding
329
483
  } catch (e) {
330
484
  loadErrors.push(e)
331
485
  }
332
486
  } else if (process.arch === 'x64') {
333
487
  try {
334
- return require('./clipboard.linux-x64-ohos.node')
488
+ return require('./clipboard.openharmony-x64.node')
335
489
  } catch (e) {
336
490
  loadErrors.push(e)
337
491
  }
338
492
  try {
339
- return require('@teddyzhu/clipboard-linux-x64-ohos')
493
+ const binding = require('@teddyzhu/clipboard-openharmony-x64')
494
+ const bindingPackageVersion = require('@teddyzhu/clipboard-openharmony-x64/package.json').version
495
+ if (bindingPackageVersion !== '0.0.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
496
+ throw new Error(`Native binding package version mismatch, expected 0.0.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
497
+ }
498
+ return binding
340
499
  } catch (e) {
341
500
  loadErrors.push(e)
342
501
  }
343
502
  } else if (process.arch === 'arm') {
344
503
  try {
345
- return require('./clipboard.linux-arm-ohos.node')
504
+ return require('./clipboard.openharmony-arm.node')
346
505
  } catch (e) {
347
506
  loadErrors.push(e)
348
507
  }
349
508
  try {
350
- return require('@teddyzhu/clipboard-linux-arm-ohos')
509
+ const binding = require('@teddyzhu/clipboard-openharmony-arm')
510
+ const bindingPackageVersion = require('@teddyzhu/clipboard-openharmony-arm/package.json').version
511
+ if (bindingPackageVersion !== '0.0.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
512
+ throw new Error(`Native binding package version mismatch, expected 0.0.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
513
+ }
514
+ return binding
351
515
  } catch (e) {
352
516
  loadErrors.push(e)
353
517
  }
@@ -362,22 +526,36 @@ function requireNative() {
362
526
  nativeBinding = requireNative()
363
527
 
364
528
  if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
529
+ let wasiBinding = null
530
+ let wasiBindingError = null
365
531
  try {
366
- nativeBinding = require('./clipboard.wasi.cjs')
532
+ wasiBinding = require('./clipboard.wasi.cjs')
533
+ nativeBinding = wasiBinding
367
534
  } catch (err) {
368
535
  if (process.env.NAPI_RS_FORCE_WASI) {
369
- loadErrors.push(err)
536
+ wasiBindingError = err
370
537
  }
371
538
  }
372
- if (!nativeBinding) {
539
+ if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
373
540
  try {
374
- nativeBinding = require('@teddyzhu/clipboard-wasm32-wasi')
541
+ wasiBinding = require('@teddyzhu/clipboard-wasm32-wasi')
542
+ nativeBinding = wasiBinding
375
543
  } catch (err) {
376
544
  if (process.env.NAPI_RS_FORCE_WASI) {
545
+ if (!wasiBindingError) {
546
+ wasiBindingError = err
547
+ } else {
548
+ wasiBindingError.cause = err
549
+ }
377
550
  loadErrors.push(err)
378
551
  }
379
552
  }
380
553
  }
554
+ if (process.env.NAPI_RS_FORCE_WASI === 'error' && !wasiBinding) {
555
+ const error = new Error('WASI binding not found and NAPI_RS_FORCE_WASI is set to error')
556
+ error.cause = wasiBindingError
557
+ throw error
558
+ }
381
559
  }
382
560
 
383
561
  if (!nativeBinding) {
@@ -386,7 +564,12 @@ if (!nativeBinding) {
386
564
  `Cannot find native binding. ` +
387
565
  `npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). ` +
388
566
  'Please try `npm i` again after removing both package-lock.json and node_modules directory.',
389
- { cause: loadErrors }
567
+ {
568
+ cause: loadErrors.reduce((err, cur) => {
569
+ cur.cause = err
570
+ return cur
571
+ }),
572
+ },
390
573
  )
391
574
  }
392
575
  throw new Error(`Failed to load native binding`)
package/package.json CHANGED
@@ -1,9 +1,12 @@
1
1
  {
2
2
  "name": "@teddyzhu/clipboard",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "description": "it's a node package with napi-rs wrapper clipboard-rs",
5
5
  "main": "index.js",
6
- "repository": "git@github.com:Teddy-Zhu/node-clipboard-rs.git",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/Teddy-Zhu/node-clipboard-rs.git"
9
+ },
7
10
  "license": "MIT",
8
11
  "keywords": [
9
12
  "napi-rs",
@@ -46,7 +49,7 @@
46
49
  "format:toml": "taplo format",
47
50
  "format:rs": "cargo fmt",
48
51
  "lint": "oxlint .",
49
- "prepublishOnly": "napi prepublish -t npm",
52
+ "prepublishOnly": "napi pre-publish -t npm",
50
53
  "test": "ava",
51
54
  "version": "napi version",
52
55
  "prepare": "husky"
@@ -101,13 +104,13 @@
101
104
  "singleQuote": true,
102
105
  "arrowParens": "always"
103
106
  },
104
- "packageManager": "yarn@4.9.2",
105
107
  "optionalDependencies": {
106
- "@teddyzhu/clipboard-win32-x64-msvc": "0.0.6",
107
- "@teddyzhu/clipboard-darwin-x64": "0.0.6",
108
- "@teddyzhu/clipboard-linux-x64-gnu": "0.0.6",
109
- "@teddyzhu/clipboard-linux-arm64-gnu": "0.0.6",
110
- "@teddyzhu/clipboard-darwin-arm64": "0.0.6",
111
- "@teddyzhu/clipboard-win32-arm64-msvc": "0.0.6"
112
- }
108
+ "@teddyzhu/clipboard-win32-x64-msvc": "0.0.7",
109
+ "@teddyzhu/clipboard-darwin-x64": "0.0.7",
110
+ "@teddyzhu/clipboard-linux-x64-gnu": "0.0.7",
111
+ "@teddyzhu/clipboard-linux-arm64-gnu": "0.0.7",
112
+ "@teddyzhu/clipboard-darwin-arm64": "0.0.7",
113
+ "@teddyzhu/clipboard-win32-arm64-msvc": "0.0.7"
114
+ },
115
+ "packageManager": "pnpm@10.28.2+sha512.41872f037ad22f7348e3b1debbaf7e867cfd448f2726d9cf74c08f19507c31d2c8e7a11525b983febc2df640b5438dee6023ebb1f84ed43cc2d654d2bc326264"
113
116
  }